-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #721 from Xiangyu-Hu/ck-sycl/surface_indication_ck
Add Surface Indication With CK/SYCL? Feature to SPHinXsys
- Loading branch information
Showing
6 changed files
with
417 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...ared_ck/particle_dynamics/general_dynamics/surface_indication/all_surface_indication_ck.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* ------------------------------------------------------------------------- * | ||
* SPHinXsys * | ||
* ------------------------------------------------------------------------- * | ||
* SPHinXsys (pronunciation: s'finksis) is an acronym from Smoothed Particle * | ||
* Hydrodynamics for industrial compleX systems. It provides C++ APIs for * | ||
* physical accurate simulation and aims to model coupled industrial dynamic * | ||
* systems including fluid, solid, multi-body dynamics and beyond with SPH * | ||
* (smoothed particle hydrodynamics), a meshless computational method using * | ||
* particle discretization. * | ||
* * | ||
* SPHinXsys is partially funded by German Research Foundation * | ||
* (Deutsche Forschungsgemeinschaft) DFG HU1527/6-1, HU1527/10-1, * | ||
* HU1527/12-1 and HU1527/12-4. * | ||
* * | ||
* Portions copyright (c) 2017-2023 Technical University of Munich and * | ||
* the authors' affiliations. * | ||
* * | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may * | ||
* not use this file except in compliance with the License. You may obtain a * | ||
* copy of the License at http://www.apache.org/licenses/LICENSE-2.0. * | ||
* * | ||
* ------------------------------------------------------------------------- */ | ||
|
||
#ifndef B9F4AD2C_8E17_4C49_BCAA_4BD2C6A6951F | ||
#define B9F4AD2C_8E17_4C49_BCAA_4BD2C6A6951F | ||
/** | ||
* @file all_general_dynamics.h | ||
* @brief This is the header file that user code should include to pick up all | ||
* general dynamics used in SPHinXsys. | ||
* @author Chi Zhang and Xiangyu Hu | ||
*/ | ||
|
||
|
||
#include "surface_indication_ck.hpp" | ||
|
||
|
||
#endif /* B9F4AD2C_8E17_4C49_BCAA_4BD2C6A6951F */ |
183 changes: 183 additions & 0 deletions
183
...d/shared_ck/particle_dynamics/general_dynamics/surface_indication/surface_indication_ck.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
#ifndef SURFACE_INDICATION_CK_H | ||
#define SURFACE_INDICATION_CK_H | ||
|
||
#include "base_general_dynamics.h" | ||
#include "base_fluid_dynamics.h" | ||
#include "interaction_ck.hpp" | ||
|
||
namespace SPH | ||
{ | ||
namespace fluid_dynamics | ||
{ | ||
/** | ||
* @class FreeSurfaceIndicationCK | ||
* @brief Free-surface indication with configurable relationship types. | ||
* | ||
* This template is specialized for different combinations of | ||
* "Base" + "Inner" / "Contact" relations to handle free-surface | ||
* detection and updating in SPH simulations. | ||
*/ | ||
template <typename... RelationTypes> | ||
class FreeSurfaceIndicationCK; | ||
|
||
//=================================================================================================// | ||
// Base relation version | ||
//=================================================================================================// | ||
/** | ||
* @class FreeSurfaceIndicationCK<Base, RelationType<Parameters...>> | ||
* @brief Basic free-surface indication logic, storing and computing | ||
* positional divergence, surface indicators, etc. | ||
*/ | ||
template <template <typename...> class RelationType, typename... Parameters> | ||
class FreeSurfaceIndicationCK<Base, RelationType<Parameters...>> | ||
: public Interaction<RelationType<Parameters...>> | ||
{ | ||
public: | ||
template <class BaseRelationType> | ||
explicit FreeSurfaceIndicationCK(BaseRelationType &base_relation); | ||
virtual ~FreeSurfaceIndicationCK() {} | ||
|
||
//------------------------------------------------------------------------------------------// | ||
/** | ||
* @class InteractKernel | ||
* @brief Base interaction kernel that calculates positional divergence, | ||
* used in detecting free-surface particles. | ||
*/ | ||
class InteractKernel : public Interaction<RelationType<Parameters...>>::InteractKernel | ||
{ | ||
public: | ||
template <class ExecutionPolicy, typename... Args> | ||
InteractKernel(const ExecutionPolicy &ex_policy, | ||
FreeSurfaceIndicationCK<Base, RelationType<Parameters...>> &encloser, | ||
Args &&...args); | ||
|
||
void interact(size_t index_i, Real dt = 0.0); | ||
|
||
protected: | ||
int *indicator_; | ||
Real *pos_div_; | ||
Real *Vol_; | ||
Real threshold_by_dimensions_; | ||
Real smoothing_length_; | ||
}; | ||
|
||
protected: | ||
DiscreteVariable<int> *dv_indicator_; | ||
DiscreteVariable<Real> *dv_pos_div_; | ||
DiscreteVariable<Real> *dv_Vol_; | ||
Real dv_threshold_by_dimensions_; | ||
Real dv_smoothing_length_; | ||
}; | ||
|
||
//=================================================================================================// | ||
// Inner relation version with "WithUpdate" | ||
//=================================================================================================// | ||
/** | ||
* @class FreeSurfaceIndicationCK<Inner<WithUpdate, FlowType, Parameters...>> | ||
* @brief Extends the base free-surface indication for inner relations that also require | ||
* an updating step (e.g., "WithUpdate"). | ||
*/ | ||
template <class FlowType, typename... Parameters> | ||
class FreeSurfaceIndicationCK<Inner<WithUpdate, FlowType, Parameters...>> | ||
: public FreeSurfaceIndicationCK<Base, Inner<Parameters...>> | ||
{ | ||
public: | ||
explicit FreeSurfaceIndicationCK(Relation<Inner<Parameters...>> &inner_relation); | ||
virtual ~FreeSurfaceIndicationCK() {} | ||
|
||
//------------------------------------------------------------------------------------------// | ||
/** | ||
* @class InteractKernel | ||
* @brief Interaction kernel for detecting free surface in an inner relation. | ||
*/ | ||
class InteractKernel | ||
: public FreeSurfaceIndicationCK<Base, Inner<Parameters...>>::InteractKernel | ||
{ | ||
public: | ||
template <class ExecutionPolicy> | ||
InteractKernel(const ExecutionPolicy &ex_policy, | ||
FreeSurfaceIndicationCK<Inner<WithUpdate, FlowType, Parameters...>> &encloser); | ||
|
||
void interact(size_t index_i, Real dt = 0.0); | ||
|
||
/// Pointer to the previously stored surface indicator. | ||
int *previous_surface_indicator_; | ||
}; | ||
|
||
//------------------------------------------------------------------------------------------// | ||
/** | ||
* @class UpdateKernel | ||
* @brief Post-processing/update kernel that modifies the surface indicator | ||
* based on the newly computed positional divergences and neighbor information. | ||
*/ | ||
class UpdateKernel | ||
: public FreeSurfaceIndicationCK<Base, Inner<Parameters...>>::InteractKernel | ||
{ | ||
public: | ||
template <class ExecutionPolicy> | ||
UpdateKernel(const ExecutionPolicy &ex_policy, | ||
FreeSurfaceIndicationCK<Inner<WithUpdate, FlowType, Parameters...>> &encloser); | ||
|
||
void update(size_t index_i, Real dt = 0.0); | ||
|
||
protected: | ||
int *previous_surface_indicator_; | ||
FreeSurfaceIndicationCK<Inner<WithUpdate, FlowType, Parameters...>> *outer_; | ||
}; | ||
|
||
protected: | ||
DiscreteVariable<int> *dv_previous_surface_indicator_; | ||
}; | ||
|
||
//------------------------------------------------------------------------------------------// | ||
// Common type alias for internal flow with free-surface indication (with update). | ||
using FreeSurfaceIndicationInnerCK = FreeSurfaceIndicationCK<Inner<WithUpdate, Internal>>; | ||
|
||
//=================================================================================================// | ||
// Contact relation version | ||
//=================================================================================================// | ||
/** | ||
* @class FreeSurfaceIndicationCK<Contact<Parameters...>> | ||
* @brief Extends the base free-surface indication for contact relations. | ||
*/ | ||
template <typename... Parameters> | ||
class FreeSurfaceIndicationCK<Contact<Parameters...>> | ||
: public FreeSurfaceIndicationCK<Base, Contact<Parameters...>> | ||
{ | ||
public: | ||
explicit FreeSurfaceIndicationCK(Relation<Contact<Parameters...>> &contact_relation); | ||
virtual ~FreeSurfaceIndicationCK() {} | ||
|
||
//------------------------------------------------------------------------------------------// | ||
/** | ||
* @class InteractKernel | ||
* @brief Interaction kernel for a contact relation, combining data from multiple contact bodies. | ||
*/ | ||
class InteractKernel | ||
: public FreeSurfaceIndicationCK<Base, Contact<Parameters...>>::InteractKernel | ||
{ | ||
public: | ||
template <class ExecutionPolicy> | ||
InteractKernel(const ExecutionPolicy &ex_policy, | ||
FreeSurfaceIndicationCK<Contact<Parameters...>> &encloser, | ||
size_t contact_index); | ||
|
||
void interact(size_t index_i, Real dt = 0.0); | ||
|
||
protected: | ||
Real *contact_Vol_; | ||
}; | ||
|
||
protected: | ||
StdVec<DiscreteVariable<Real> *> dv_contact_Vol_; | ||
}; | ||
|
||
//------------------------------------------------------------------------------------------// | ||
// Common type alias for complex free-surface indication (inner + contact). | ||
using FreeSurfaceIndicationComplexCK = FreeSurfaceIndicationCK<Inner<WithUpdate, Internal>, Contact<>>; | ||
//------------------------------------------------------------------------------------------// | ||
|
||
} // namespace fluid_dynamics | ||
} // namespace SPH | ||
|
||
#endif // SURFACE_INDICATION_CK_H |
Oops, something went wrong.