7 #ifndef BASE_PARTICLE_DYNAMICS_HPP 8 #define BASE_PARTICLE_DYNAMICS_HPP 16 template <
class ReturnType>
17 ParticleDynamics<ReturnType>::ParticleDynamics(SPHBody &sph_body)
18 : GlobalStaticVariables(), sph_body_(&sph_body),
19 sph_adaptation_(sph_body.sph_adaptation_),
20 base_particles_(sph_body.base_particles_) {}
22 template <
class BodyType,
25 class ContactBodyType,
26 class ContactParticlesType,
27 class ContactMaterialType,
29 DataDelegateContact<BodyType, ParticlesType, MaterialType, ContactBodyType, ContactParticlesType, ContactMaterialType, BaseDataDelegateType>::
30 DataDelegateContact(BaseBodyRelationContact &body_contact_relation) :
BaseDataDelegateType(*body_contact_relation.sph_body_)
32 RealBodyVector contact_sph_bodies = body_contact_relation.contact_bodies_;
33 for (
size_t i = 0; i != contact_sph_bodies.size(); ++i)
35 contact_bodies_.push_back(DynamicCast<ContactBodyType>(
this, contact_sph_bodies[i]));
36 contact_particles_.push_back(DynamicCast<ContactParticlesType>(
this, contact_sph_bodies[i]->base_particles_));
37 contact_material_.push_back(DynamicCast<ContactMaterialType>(
this, contact_sph_bodies[i]->base_material_));
38 contact_configuration_.push_back(&body_contact_relation.contact_configuration_[i]);
42 template <
class ReturnType,
typename ReduceOperation>
46 for (
size_t i = 0; i < total_real_particles; ++i)
48 temp = reduce_operation(temp, reduce_functor(i, dt));
53 template <
class ReturnType,
typename ReduceOperation>
57 return parallel_reduce(
58 blocked_range<size_t>(0, total_real_particles),
59 temp, [&](
const blocked_range<size_t> &r, ReturnType temp0) -> ReturnType
61 for (
size_t i = r.begin(); i != r.end(); ++i)
63 temp0 = reduce_operation(temp0, reduce_functor(i, dt));
67 [&](ReturnType x, ReturnType y) -> ReturnType
69 return reduce_operation(x, y);
73 template <
class ParticleDynamicsInnerType,
class ContactDataType>
74 ParticleDynamicsComplex<ParticleDynamicsInnerType, ContactDataType>::
75 ParticleDynamicsComplex(ComplexBodyRelation &complex_relation,
76 BaseBodyRelationContact &extra_contact_relation)
80 if (complex_relation.sph_body_ != extra_contact_relation.sph_body_)
82 std::cout <<
"\n Error: the two body_realtions do not have the same source body!" << std::endl;
83 std::cout << __FILE__ <<
':' << __LINE__ << std::endl;
87 for (
auto &extra_body : extra_contact_relation.contact_bodies_)
91 this->contact_bodies_.push_back(extra_body->ThisObjectPtr());
92 this->contact_particles_.push_back(extra_body->base_particles_->ThisObjectPtr());
93 this->contact_material_.push_back(extra_body->base_material_->ThisObjectPtr());
96 for (
size_t i = 0; i != extra_contact_relation.contact_bodies_.size(); ++i)
98 this->contact_configuration_.push_back(&extra_contact_relation.contact_configuration_[i]);
104 #endif //BASE_PARTICLE_DYNAMICS_HPP
std::function< ReturnType(size_t, Real)> ReduceFunctor
Definition: base_particle_dynamics.h:52
This is the base classes of SPH bodies. The real body is for that with cell linked list and the ficti...
ReturnType ReduceIterator(size_t total_real_particles, ReturnType temp, ReduceFunctor< ReturnType > &reduce_functor, ReduceOperation &reduce_operation, Real dt=0.0)
Definition: base_particle_dynamics.hpp:43
This is for the base classes of particle dynamics, which describe the interaction between particles...
ReturnType ReduceIterator_parallel(size_t total_real_particles, ReturnType temp, ReduceFunctor< ReturnType > &reduce_functor, ReduceOperation &reduce_operation, Real dt=0.0)
Definition: base_particle_dynamics.hpp:54
Definition: solid_body_supplementary.cpp:9