32 #ifndef PARTICLE_DYNAMICS_BODYPART_H 33 #define PARTICLE_DYNAMICS_BODYPART_H 76 virtual void exec(Real dt = 0.0)
override;
77 virtual void parallel_exec(Real dt = 0.0)
override;
81 virtual void Update(
size_t index_i, Real dt = 0.0) = 0;
94 virtual void exec(Real dt = 0.0)
override;
95 virtual void parallel_exec(Real dt = 0.0)
override;
99 virtual void Interaction(
size_t index_i, Real dt = 0.0) = 0;
112 virtual void exec(Real dt = 0.0)
override;
113 virtual void parallel_exec(Real dt = 0.0)
override;
116 virtual void Update(
size_t index_i, Real dt = 0.0) = 0;
130 virtual void exec(Real dt = 0.0)
override;
131 virtual void parallel_exec(Real dt = 0.0)
override;
134 virtual void Initialization(
size_t index_i, Real dt = 0.0) = 0;
149 virtual void exec(Real dt = 0.0)
override;
150 virtual void parallel_exec(Real dt = 0.0)
override;
155 virtual void Update(
size_t index_i, Real dt = 0.0) = 0;
161 template <
class ReturnType,
typename ReduceOperation>
167 quantity_name_(
"ReducedQuantity"), initial_reference_(){};
170 ReturnType InitialReference() {
return initial_reference_; };
171 std::string QuantityName() {
return quantity_name_; };
173 virtual ReturnType
exec(Real dt = 0.0)
override 175 ReturnType temp = initial_reference_;
177 for (
size_t i = 0; i != body_part_cells_.size(); ++i)
180 for (
size_t num = 0; num < list_data.size(); ++num)
182 temp = reduce_operation_(temp, ReduceFunction(list_data[num].first, dt));
185 return OutputResult(temp);
188 virtual ReturnType parallel_exec(Real dt = 0.0)
override 190 ReturnType temp = initial_reference_;
192 temp = parallel_reduce(
193 blocked_range<size_t>(0, body_part_cells_.size()),
195 [&](
const blocked_range<size_t> &r, ReturnType temp0) -> ReturnType
197 for (
size_t i = r.begin(); i != r.end(); ++i)
200 for (
size_t num = 0; num < list_data.size(); ++num)
202 temp0 = reduce_operation_(temp0, ReduceFunction(list_data[num].first, dt));
207 [
this](ReturnType x, ReturnType y) -> ReturnType
208 {
return reduce_operation_(x, y); });
210 return OutputResult(temp);
214 ReduceOperation reduce_operation_;
216 std::string quantity_name_;
217 ReturnType initial_reference_;
218 virtual void SetupReduce(){};
219 virtual ReturnType ReduceFunction(
size_t index_i, Real dt = 0.0) = 0;
220 virtual ReturnType OutputResult(ReturnType reduced_value) {
return reduced_value; };
226 template <
class ReturnType,
typename ReduceOperation>
233 quantity_name_(
"ReducedQuantity"), initial_reference_(){};
236 ReturnType InitialReference() {
return initial_reference_; };
237 std::string QuantityName() {
return quantity_name_; };
239 virtual ReturnType
exec(Real dt = 0.0)
override 241 ReturnType temp = initial_reference_;
243 for (
size_t i = 0; i < body_part_particles_.size(); ++i)
245 temp = reduce_operation_(temp, ReduceFunction(body_part_particles_[i], dt));
247 return OutputResult(temp);
249 virtual ReturnType parallel_exec(Real dt = 0.0)
override 251 ReturnType temp = initial_reference_;
253 temp = parallel_reduce(
254 blocked_range<size_t>(0, body_part_particles_.size()),
256 [&](
const blocked_range<size_t> &r, ReturnType temp0) -> ReturnType
258 for (
size_t n = r.begin(); n != r.end(); ++n)
260 temp0 = reduce_operation_(temp0, ReduceFunction(body_part_particles_[n], dt));
264 [
this](ReturnType x, ReturnType y) -> ReturnType
266 return reduce_operation_(x, y);
269 return OutputResult(temp);
273 ReduceOperation reduce_operation_;
275 std::string quantity_name_;
276 ReturnType initial_reference_;
277 virtual void SetupReduce(){};
278 virtual ReturnType ReduceFunction(
size_t index_i, Real dt = 0.0) = 0;
279 virtual ReturnType OutputResult(ReturnType reduced_value) {
return reduced_value; };
282 #endif // PARTICLE_DYNAMICS_BODYPART_H Abstract class for particle interaction involving in a body part.
Definition: particle_dynamics_bodypart.h:88
A body part with a collection of cell lists.
Definition: base_body_part.h:100
StdVec< size_t > IndexVector
Definition: sph_data_containers.h:37
This is the implementation of the template class for 3D build.
This is the base classes of body parts.
A body part with a collection of particles.
Definition: base_body_part.h:64
StdLargeVec< CellList * > CellLists
Definition: sph_data_containers.h:46
void PartIteratorByCell_parallel(const CellLists &body_part_cells, const ParticleFunctor &particle_functor, Real dt)
Definition: particle_dynamics_bodypart.cpp:44
virtual ReturnType exec(Real dt=0.0) override
Definition: particle_dynamics_bodypart.h:239
Abstract class for reduce operation in a Eulerian constrain region.
Definition: particle_dynamics_bodypart.h:162
virtual void exec(Real dt=0.0) override
Definition: particle_dynamics_bodypart.cpp:88
Abstract class for body part simple particle dynamics.
Definition: particle_dynamics_bodypart.h:70
StdLargeVec< ListData > ListDataVector
Definition: sph_data_containers.h:44
IndexVector body_part_particles_
Definition: base_body_part.h:67
Abstract class for particle interaction involving in a body part with an extra update step...
Definition: particle_dynamics_bodypart.h:106
virtual ReturnType exec(Real dt=0.0) override
Definition: particle_dynamics_bodypart.h:173
This is for the base classes of particle dynamics, which describe the interaction between particles...
virtual void exec(Real dt=0.0) override
Definition: particle_dynamics_bodypart.cpp:69
CellLists body_part_cells_
Definition: base_body_part.h:103
Abstract class for imposing body part dynamics by particles. That is the constrained particles will b...
Definition: particle_dynamics_bodypart.h:56
Abstract class for imposing Eulerian constrain to a body. The constrained particles are in the tagged...
Definition: particle_dynamics_bodypart.h:143
virtual void exec(Real dt=0.0) override
Definition: particle_dynamics_bodypart.cpp:107
SPHBody is a base body with basic data and functions. Its derived class can be a real fluid body...
Definition: base_body.h:61
reduce operation in a Lagrangian contrained region.
Definition: particle_dynamics_bodypart.h:227
Definition: particle_dynamics_bodypart.h:124
virtual void exec(Real dt=0.0) override
Definition: particle_dynamics_bodypart.cpp:152
void PartIteratorByParticle(const IndexVector &body_part_particles, const ParticleFunctor &particle_functor, Real dt)
Definition: particle_dynamics_bodypart.cpp:12
void PartIteratorByParticle_parallel(const IndexVector &body_part_particles, const ParticleFunctor &particle_functor, Real dt)
Definition: particle_dynamics_bodypart.cpp:20
std::function< void(size_t, Real)> ParticleFunctor
Definition: base_particle_dynamics.h:49
virtual void exec(Real dt=0.0) override
Definition: particle_dynamics_bodypart.cpp:129
void PartIteratorByCell(const CellLists &body_part_cells, const ParticleFunctor &particle_functor, Real dt)
Definition: particle_dynamics_bodypart.cpp:34
Definition: solid_body_supplementary.cpp:9
The base class for all particle dynamics This class contains the only two interface functions availab...
Definition: base_particle_dynamics.h:145