7 #ifndef PARTICLE_DYNAMICS_DISSIPATION_HPP 8 #define PARTICLE_DYNAMICS_DISSIPATION_HPP 15 template <
typename VariableType>
16 DampingBySplittingInner<VariableType>::
17 DampingBySplittingInner(BaseBodyRelationInner &inner_relation,
18 const std::string &variable_name, Real eta)
19 : InteractionDynamicsSplitting(*inner_relation.sph_body_),
20 DissipationDataInner(inner_relation), eta_(eta),
21 Vol_(particles_->Vol_), mass_(particles_->mass_),
22 variable_(*particles_->getVariableByName<
VariableType>(variable_name)) {}
24 template <
typename VariableType>
25 ErrorAndParameters<VariableType>
26 DampingBySplittingInner<VariableType>::computeErrorAndParameters(
size_t index_i, Real dt)
28 Real Vol_i = Vol_[index_i];
29 Real mass_i = mass_[index_i];
31 ErrorAndParameters<VariableType> error_and_parameters(0);
32 Neighborhood &inner_neighborhood = inner_configuration_[index_i];
33 for (
size_t n = 0; n != inner_neighborhood.current_size_; ++n)
35 size_t index_j = inner_neighborhood.j_[n];
37 VariableType variable_derivative = (variable_i - variable_[index_j]);
38 Real parameter_b = 2.0 * eta_ * inner_neighborhood.dW_ij_[n] * Vol_i * Vol_[index_j] * dt / inner_neighborhood.r_ij_[n];
40 error_and_parameters.error_ -= variable_derivative * parameter_b;
41 error_and_parameters.a_ += parameter_b;
42 error_and_parameters.c_ += parameter_b * parameter_b;
44 error_and_parameters.a_ -= mass_i;
45 return error_and_parameters;
48 template <
typename VariableType>
49 void DampingBySplittingInner<VariableType>::
50 updateStates(
size_t index_i, Real dt,
const ErrorAndParameters<VariableType> &error_and_parameters)
52 Real parameter_l = error_and_parameters.a_ * error_and_parameters.a_ + error_and_parameters.c_;
53 VariableType parameter_k = error_and_parameters.error_ / (parameter_l + TinyReal);
54 variable_[index_i] += parameter_k * error_and_parameters.a_;
56 Real Vol_i = Vol_[index_i];
58 Neighborhood &inner_neighborhood = inner_configuration_[index_i];
59 for (
size_t n = 0; n != inner_neighborhood.current_size_; ++n)
61 size_t index_j = inner_neighborhood.j_[n];
63 Real parameter_b = 2.0 * eta_ * inner_neighborhood.dW_ij_[n] * Vol_i * Vol_[index_j] * dt / inner_neighborhood.r_ij_[n];
66 VariableType variable_j = variable_[index_j] - parameter_k * parameter_b;
67 VariableType variable_derivative = (variable_i - variable_j);
70 variable_[index_j] -= variable_derivative * parameter_b / mass_[index_j];
74 template <
typename VariableType>
75 void DampingBySplittingInner<VariableType>::Interaction(
size_t index_i, Real dt)
77 ErrorAndParameters<VariableType> error_and_parameters = computeErrorAndParameters(index_i, dt);
78 updateStates(index_i, dt, error_and_parameters);
81 template <
typename VariableType>
82 DampingBySplittingComplex<VariableType>::
83 DampingBySplittingComplex(ComplexBodyRelation &complex_relation,
84 const std::string &variable_name, Real eta)
85 : DampingBySplittingInner<
VariableType>(complex_relation.inner_relation_, variable_name, eta),
86 DissipationDataContact(complex_relation.contact_relation_)
88 for (
size_t k = 0; k != contact_particles_.size(); ++k)
90 contact_Vol_.push_back(&(contact_particles_[k]->Vol_));
91 contact_mass_.push_back(&(contact_particles_[k]->mass_));
92 contact_variable_.push_back(contact_particles_[k]->
template getVariableByName<VariableType>(variable_name));
96 template <
typename VariableType>
97 ErrorAndParameters<VariableType>
104 Real Vol_i = this->Vol_[index_i];
106 for (
size_t k = 0; k < this->contact_configuration_.size(); ++k)
110 StdLargeVec<VariableType> &variable_k = *(this->contact_variable_[k]);
111 Neighborhood &contact_neighborhood = (*this->contact_configuration_[k])[index_i];
112 for (
size_t n = 0; n != contact_neighborhood.
current_size_; ++n)
114 size_t index_j = contact_neighborhood.
j_[n];
117 VariableType variable_derivative = (variable_i - variable_k[index_j]);
118 Real parameter_b = 2.0 * this->eta_ * contact_neighborhood.
dW_ij_[n] * Vol_i * Vol_k[index_j] * dt / contact_neighborhood.
r_ij_[n];
120 error_and_parameters.error_ -= variable_derivative * parameter_b;
121 error_and_parameters.a_ += parameter_b;
122 error_and_parameters.c_ += parameter_b * parameter_b;
124 return error_and_parameters;
128 template <
typename VariableType>
134 Real parameter_l = error_and_parameters.a_ * error_and_parameters.a_ + error_and_parameters.c_;
135 VariableType parameter_k = error_and_parameters.error_ / (parameter_l + TinyReal);
137 Real Vol_i = this->Vol_[index_i];
139 for (
size_t k = 0; k < this->contact_configuration_.size(); ++k)
143 StdLargeVec<VariableType> &variable_k = *(this->contact_variable_[k]);
144 Neighborhood &contact_neighborhood = (*this->contact_configuration_[k])[index_i];
145 for (
size_t n = 0; n != contact_neighborhood.
current_size_; ++n)
147 size_t index_j = contact_neighborhood.
j_[n];
150 Real parameter_b = 2.0 * this->eta_ * contact_neighborhood.
dW_ij_[n] * Vol_i * Vol_k[index_j] * dt / contact_neighborhood.
r_ij_[n];
153 VariableType variable_j = this->variable_k[index_j] - parameter_k * parameter_b;
154 VariableType variable_derivative = (variable_i - variable_j);
157 this->variable_k[index_j] -= variable_derivative * parameter_b / mass_k[index_j];
166 const std::string &variable_name, Real eta)
170 for (
size_t k = 0; k != DissipationDataWithWall::contact_particles_.size(); ++k)
172 wall_Vol_.push_back(&(contact_particles_[k]->Vol_));
173 wall_variable_.push_back(contact_particles_[k]->
template getVariableByName<VariableType>(variable_name));
179 ErrorAndParameters<VariableType>
187 Real Vol_i = this->Vol_[index_i];
189 for (
size_t k = 0; k < this->contact_configuration_.size(); ++k)
192 StdLargeVec<VariableType> &variable_k = *(this->wall_variable_[k]);
194 for (
size_t n = 0; n != contact_neighborhood.
current_size_; ++n)
196 size_t index_j = contact_neighborhood.
j_[n];
199 VariableType variable_derivative = (variable_i - variable_k[index_j]);
200 Real parameter_b = 2.0 * this->eta_ * contact_neighborhood.
dW_ij_[n] * Vol_i * Vol_k[index_j] * dt / contact_neighborhood.
r_ij_[n];
202 error_and_parameters.error_ -= variable_derivative * parameter_b;
203 error_and_parameters.a_ += parameter_b;
204 error_and_parameters.c_ += parameter_b * parameter_b;
207 return error_and_parameters;
210 template <
typename VariableType>
213 const std::string &variable_name, Real eta)
216 Vol_(particles_->Vol_), mass_(particles_->mass_),
217 variable_(*particles_->getVariableByName<
VariableType>(variable_name)),
220 template <
typename VariableType>
221 void DampingPairwiseInner<VariableType>::Interaction(
size_t index_i, Real dt)
223 Real Vol_i = Vol_[index_i];
224 Real mass_i = mass_[index_i];
227 std::array<Real, MaximumNeighborhoodSize> parameter_b;
228 Neighborhood &inner_neighborhood = inner_configuration_[index_i];
230 for (
size_t n = 0; n != inner_neighborhood.current_size_; ++n)
232 size_t index_j = inner_neighborhood.j_[n];
233 Real mass_j = mass_[index_j];
235 VariableType variable_derivative = (variable_i - variable_[index_j]);
236 parameter_b[n] = eta_ * inner_neighborhood.dW_ij_[n] * Vol_i * Vol_[index_j] * dt / inner_neighborhood.r_ij_[n];
238 VariableType increment = parameter_b[n] * variable_derivative / (mass_i * mass_j - parameter_b[n] * (mass_i + mass_j));
239 variable_[index_i] += increment * mass_j;
240 variable_[index_j] -= increment * mass_i;
244 for (
size_t n = inner_neighborhood.current_size_; n != 0; --n)
246 size_t index_j = inner_neighborhood.j_[n - 1];
247 Real mass_j = mass_[index_j];
249 VariableType variable_derivative = (variable_i - variable_[index_j]);
250 VariableType increment = parameter_b[n - 1] * variable_derivative / (mass_i * mass_j - parameter_b[n - 1] * (mass_i + mass_j));
252 variable_[index_i] += increment * mass_j;
253 variable_[index_j] -= increment * mass_i;
257 template <
typename VariableType>
258 DampingPairwiseComplex<VariableType>::DampingPairwiseComplex(BaseBodyRelationInner &inner_relation,
259 BaseBodyRelationContact &contact_relation,
const std::string &variable_name, Real eta)
260 : DampingPairwiseInner<
VariableType>(inner_relation, variable_name, eta),
261 DissipationDataContact(contact_relation)
263 for (
size_t k = 0; k != contact_particles_.size(); ++k)
265 contact_Vol_.push_back(&(contact_particles_[k]->Vol_));
266 contact_mass_.push_back(&(contact_particles_[k]->mass_));
267 contact_variable_.push_back(contact_particles_[k]->
template getVariableByName<VariableType>(variable_name));
271 template <
typename VariableType>
272 DampingPairwiseComplex<VariableType>::
273 DampingPairwiseComplex(ComplexBodyRelation &complex_relation,
const std::string &variable_name, Real eta)
274 : DampingPairwiseComplex(complex_relation.inner_relation_,
275 complex_relation.contact_relation_, variable_name, eta) {}
277 template <
typename VariableType>
282 Real Vol_i = this->Vol_[index_i];
283 Real mass_i = this->mass_[index_i];
286 std::array<Real, MaximumNeighborhoodSize> parameter_b;
289 for (
size_t k = 0; k < this->contact_configuration_.size(); ++k)
293 StdLargeVec<VariableType> &variable_k = *(this->contact_variable_[k]);
294 Neighborhood &contact_neighborhood = (*this->contact_configuration_[k])[index_i];
296 for (
size_t n = 0; n != contact_neighborhood.
current_size_; ++n)
298 size_t index_j = contact_neighborhood.
j_[n];
299 Real mass_j = mass_k[index_j];
301 VariableType variable_derivative = (variable_i - variable_k[index_j]);
302 parameter_b[n] = this->eta_ * contact_neighborhood.
dW_ij_[n] * Vol_i * Vol_k[index_j] * dt / contact_neighborhood.
r_ij_[n];
304 VariableType increment = parameter_b[n] * variable_derivative / (mass_i * mass_j - parameter_b[n] * (mass_i + mass_j));
305 this->variable_[index_i] += increment * mass_j;
306 variable_k[index_j] -= increment * mass_i;
309 for (
size_t n = contact_neighborhood.
current_size_; n != 0; --n)
311 size_t index_j = contact_neighborhood.
j_[n - 1];
312 Real mass_j = mass_k[index_j];
314 VariableType variable_derivative = (variable_i - variable_k[index_j]);
315 VariableType increment = parameter_b[n - 1] * variable_derivative / (mass_i * mass_j - parameter_b[n - 1] * (mass_i + mass_j));
317 this->variable_[index_i] += increment * mass_j;
318 variable_k[index_j] -= increment * mass_i;
331 for (
size_t k = 0; k != DissipationDataWithWall::contact_particles_.size(); ++k)
333 wall_Vol_.push_back(&(contact_particles_[k]->Vol_));
334 wall_variable_.push_back(contact_particles_[k]->
template getVariableByName<VariableType>(variable_name));
340 DampingPairwiseWithWall<VariableType, BaseDampingPairwiseType>::
341 DampingPairwiseWithWall(ComplexBodyRelation &complex_wall_relation,
const std::string &variable_name, Real eta)
342 : DampingPairwiseWithWall(complex_wall_relation.inner_relation_,
343 complex_wall_relation.contact_relation_, variable_name, eta) {}
352 Real Vol_i = this->Vol_[index_i];
353 Real mass_i = this->mass_[index_i];
356 std::array<Real, MaximumNeighborhoodSize> parameter_b;
359 for (
size_t k = 0; k < this->contact_configuration_.size(); ++k)
362 StdLargeVec<VariableType> &variable_k = *(this->wall_variable_[k]);
365 for (
size_t n = 0; n != contact_neighborhood.
current_size_; ++n)
367 size_t index_j = contact_neighborhood.
j_[n];
369 parameter_b[n] = this->eta_ * contact_neighborhood.
dW_ij_[n] * Vol_i * Vol_k[index_j] * dt / contact_neighborhood.
r_ij_[n];
372 this->variable_[index_i] += parameter_b[n] * (variable_i - variable_k[index_j]) / (mass_i - 2.0 * parameter_b[n]);
375 for (
size_t n = contact_neighborhood.
current_size_; n != 0; --n)
377 size_t index_j = contact_neighborhood.
j_[n - 1];
380 this->variable_[index_i] += parameter_b[n - 1] * (variable_i - variable_k[index_j]) / (mass_i - 2.0 * parameter_b[n - 1]);
385 template <
typename VariableType>
390 eta_(eta), Vol_(particles_->Vol_), mass_(particles_->mass_),
391 variable_(*particles_->getVariableByName<
VariableType>(variable_name))
393 for (
size_t k = 0; k != contact_particles_.size(); ++k)
395 wall_Vol_.push_back(&(contact_particles_[k]->Vol_));
396 wall_variable_.push_back(contact_particles_[k]->
template getVariableByName<VariableType>(variable_name));
400 template <
typename VariableType>
403 Real Vol_i = Vol_[index_i];
404 Real mass_i = mass_[index_i];
407 std::array<Real, MaximumNeighborhoodSize> parameter_b;
410 for (
size_t k = 0; k < contact_configuration_.size(); ++k)
413 StdLargeVec<VariableType> &variable_k = *(wall_variable_[k]);
414 Neighborhood &contact_neighborhood = (*contact_configuration_[k])[index_i];
416 for (
size_t n = 0; n != contact_neighborhood.
current_size_; ++n)
418 size_t index_j = contact_neighborhood.
j_[n];
420 parameter_b[n] = eta_ * contact_neighborhood.
dW_ij_[n] * Vol_i * Vol_k[index_j] * dt / contact_neighborhood.
r_ij_[n];
423 variable_[index_i] += parameter_b[n] * (variable_i - variable_k[index_j]) / (mass_i - 2.0 * parameter_b[n]);
426 for (
size_t n = contact_neighborhood.
current_size_; n != 0; --n)
428 size_t index_j = contact_neighborhood.
j_[n - 1];
431 variable_[index_i] += parameter_b[n - 1] * (variable_i - variable_k[index_j]) / (mass_i - 2.0 * parameter_b[n - 1]);
436 template <
class DampingAlgorithmType>
437 template <
typename... ConstructorArgs>
442 this->eta_ /= random_ratio;
445 template <
class DampingAlgorithmType>
446 bool DampingWithRandomChoice<DampingAlgorithmType>::RandomChoice()
448 return ((
double)rand() / (RAND_MAX)) < random_ratio_ ? true :
false;
451 template <
class DampingAlgorithmType>
452 void DampingWithRandomChoice<DampingAlgorithmType>::exec(Real dt)
455 DampingAlgorithmType::exec(dt);
458 template <
class DampingAlgorithmType>
459 void DampingWithRandomChoice<DampingAlgorithmType>::parallel_exec(Real dt)
462 DampingAlgorithmType::parallel_exec(dt);
466 #endif // PARTICLE_DYNAMICS_DISSIPATION_HPP A neighborhood around particle i.
Definition: neighbor_relation.h:47
Particles with essential (geometric and kinematic) data. There are three types of particles, all par...
Definition: base_particles.h:81
prepare data for inner particle dynamics
Definition: base_particle_dynamics.h:216
The base relation between a SPH body and its contact SPH bodies.
Definition: base_body_relation.h:136
virtual void Interaction(size_t index_i, Real dt=0.0) override
Definition: particle_dynamics_dissipation.hpp:348
size_t current_size_
Definition: neighbor_relation.h:50
Definition: particle_dynamics_dissipation.h:98
Base of all materials.
Definition: base_material.h:52
Base class of all solid materials.
Definition: base_material.h:113
Definition: particle_dynamics_dissipation.h:61
virtual void updateStates(size_t index_i, Real dt, const ErrorAndParameters< VariableType > &error_and_parameters) override
Definition: particle_dynamics_dissipation.hpp:130
Declaration of solidbody which is used for Solid BCs and derived from RealBody.
Definition: solid_body.h:46
StdLargeVec< Real > r_ij_
Definition: neighbor_relation.h:56
Definition: particle_dynamics_dissipation.h:45
A group of particles with solid body particle data.
Definition: solid_particles.h:49
virtual ErrorAndParameters< VariableType > computeErrorAndParameters(size_t index_i, Real dt=0.0) override
Definition: particle_dynamics_dissipation.hpp:98
This is for the splitting algorithm.
Definition: particle_dynamics_algorithms.h:202
This is the particle dynamics aplliable for all type bodies.
Damping to wall by which the wall velocity is not updated and the mass of wall particle is not consid...
Definition: particle_dynamics_dissipation.h:183
StdLargeVec< Real > dW_ij_
Definition: neighbor_relation.h:55
The relation combined an inner and a contact body relation. The interaction is in a inner-boundary-co...
Definition: complex_body_relation.h:42
virtual void Interaction(size_t index_i, Real dt=0.0) override
Definition: particle_dynamics_dissipation.hpp:278
virtual ErrorAndParameters< VariableType > computeErrorAndParameters(size_t index_i, Real dt=0.0) override
Definition: particle_dynamics_dissipation.hpp:181
SPHBody is a base body with basic data and functions. Its derived class can be a real fluid body...
Definition: base_body.h:61
Damping with wall by which the wall velocity is not updated and the mass of wall particle is not cons...
Definition: particle_dynamics_dissipation.h:160
virtual void Interaction(size_t index_i, Real dt=0.0) override
Definition: particle_dynamics_dissipation.hpp:401
The abstract relation within a SPH body.
Definition: base_body_relation.h:117
StdLargeVec< size_t > j_
Definition: neighbor_relation.h:53
A quantity damping by a pairwise splitting scheme this method modifies the quantity directly Note tha...
Definition: particle_dynamics_dissipation.h:121
A random choice method for obstaining static equilibrium state Note that, if periodic boundary condit...
Definition: particle_dynamics_dissipation.h:210
Definition: solid_body_supplementary.cpp:9