Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
ib_particles_dem.cc
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2022-2026 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
5
7
8#include <deal.II/base/mpi.h>
9
10#include <deal.II/fe/fe_system.h>
11#include <deal.II/fe/fe_values.h>
12
13#include <boost/serialization/map.hpp>
14#include <boost/serialization/utility.hpp>
15
16#include <algorithm>
17#include <map>
18#include <utility>
19
20template <int dim>
21void
23 const std::shared_ptr<Parameters::IBParticles<dim>> &p_nsparam,
25 &fw_parameters,
26 const std::shared_ptr<Parameters::Lagrangian::BCDEM>
27 &boundary_conditions_parameters_input,
28 const MPI_Comm &mpi_communicator_input,
29 const std::vector<IBParticle<dim>> &particles)
30{
31 parameters = p_nsparam;
32 floating_walls_parameters = fw_parameters;
33 boundary_conditions_parameters = boundary_conditions_parameters_input;
34 mpi_communicator = mpi_communicator_input;
35 dem_particles = particles;
36 boundary_cells.resize(dem_particles.size());
37}
38
39template <int dim>
40bool
42 const types::boundary_id boundary_id) const
43{
45 return false;
46
47 if (boundary_conditions_parameters->outlet_boundaries.contains(boundary_id))
48 return true;
49
50 // A boundary is periodic if it is a principal periodic boundary (a key of
51 // periodic_boundaries) or a neighbor periodic boundary (the neighbor id of
52 // one of its entries).
53 const auto &periodic_boundaries =
54 boundary_conditions_parameters->periodic_boundaries;
55 if (periodic_boundaries.contains(boundary_id) ||
56 std::ranges::any_of(periodic_boundaries, [boundary_id](const auto &p) {
57 return p.second.neighbor_id == boundary_id;
58 }))
59 return true;
60
61 return false;
62}
63
64template <int dim>
65void
66IBParticlesDEM<dim>::get_wall_motion(const types::boundary_id boundary_id,
67 const Point<dim> &point_on_boundary,
68 Tensor<1, 3> &wall_velocity,
69 Tensor<1, 3> &wall_angular_velocity,
70 Point<dim> &wall_rotation_axis_point) const
71{
72 wall_velocity = Tensor<1, 3>();
73 wall_angular_velocity = Tensor<1, 3>();
74
75 // Always return a defined point on the wall rotation axis.
76 //
77 // Two cases are possible:
78 // 1. A rotational DEM boundary condition is prescribed on this boundary.
79 // In that case, the fallback value is overwritten below with the
80 // user-specified point on the rotation axis and is then used together
81 // with the angular velocity to reconstruct the wall velocity at the
82 // contact or boundary point.
83 // 2. No rotational boundary condition is prescribed.
84 // In that case, wall_angular_velocity remains zero, so the choice of
85 // wall_rotation_axis_point is irrelevant because the rotational
86 // contribution omega x (x - x_axis) vanishes identically. We still
87 // initialize it here because get_wall_motion() always returns a complete
88 // wall-motion state.
89 wall_rotation_axis_point = point_on_boundary;
90
92 return;
93
94 const auto &translational_velocity_map =
95 boundary_conditions_parameters->boundary_translational_velocity;
96 const auto translational_it = translational_velocity_map.find(boundary_id);
97 if (translational_it != translational_velocity_map.end())
98 wall_velocity = translational_it->second;
99
100 const auto &rotational_speed_map =
101 boundary_conditions_parameters->boundary_rotational_speed;
102 const auto &rotational_vector_map =
103 boundary_conditions_parameters->boundary_rotational_vector;
104 const auto rotational_speed_it = rotational_speed_map.find(boundary_id);
105 const auto rotational_vector_it = rotational_vector_map.find(boundary_id);
106 if (rotational_speed_it != rotational_speed_map.end() &&
107 rotational_vector_it != rotational_vector_map.end())
108 {
109 wall_angular_velocity =
110 rotational_speed_it->second * rotational_vector_it->second;
111 }
112
113 const auto &rotation_axis_map =
114 boundary_conditions_parameters->point_on_rotation_axis;
115 const auto rotation_axis_it = rotation_axis_map.find(boundary_id);
116 if (rotation_axis_it != rotation_axis_map.end())
117 {
118 wall_rotation_axis_point[0] = rotation_axis_it->second[0];
119 wall_rotation_axis_point[1] = rotation_axis_it->second[1];
120 if constexpr (dim == 3)
121 wall_rotation_axis_point[2] = rotation_axis_it->second[2];
122 }
123}
124
125template <int dim>
126void
128 const std::vector<IBParticle<dim>> &particles,
129 double time)
130{
131 dem_particles = particles;
132 cfd_time = time;
133}
134
135template <int dim>
136void
138{
139 // The candidates of the last search are discarded so that pairs of particles
140 // which moved apart are not kept forever.
142 std::set<unsigned int>());
143
144 double radius_factor = parameters->contact_search_radius_factor;
145
146 for (auto &particle_one : dem_particles)
147 {
148 const Point<dim> particle_one_location = particle_one.position;
149 for (auto &particle_two : dem_particles)
150 {
151 if (particle_one.particle_id < particle_two.particle_id)
152 {
153 const Point<dim> particle_two_location = particle_two.position;
154 double distance =
155 (particle_one_location - particle_two_location).norm();
156 if (typeid(*particle_one.shape) == typeid(Sphere<dim>) &&
157 typeid(*particle_two.shape) == typeid(Sphere<dim>))
158 {
159 distance =
160 (particle_one_location - particle_two_location).norm();
161 }
162 else if (typeid(*particle_one.shape) == typeid(Sphere<dim>) &&
163 typeid(*particle_two.shape) != typeid(Sphere<dim>))
164 {
165 distance = particle_two.shape->value(particle_one_location);
166 }
167 else if (typeid(*particle_one.shape) != typeid(Sphere<dim>) &&
168 typeid(*particle_two.shape) == typeid(Sphere<dim>))
169 {
170 distance = particle_one.shape->value(particle_two_location);
171 }
172 else
173 {
174 distance = ((particle_one.shape->get_rotation_matrix() *
176 particle_one.shape->bounding_box_center) +
177 point_nd_to_3d(particle_one.position)) -
178 (particle_two.shape->get_rotation_matrix() *
180 particle_two.shape->bounding_box_center) +
181 point_nd_to_3d(particle_two.position)))
182 .norm();
183 }
184
185 if (distance <
186 (particle_one.shape->bounding_box_half_length.norm() +
187 particle_two.shape->bounding_box_half_length.norm()) *
188 radius_factor)
189 {
190 (particles_contact_candidates[particle_one.particle_id])
191 .insert(particle_two.particle_id);
192 }
193 }
194 }
195 }
196}
197
198template <int dim>
199void
201 const double dt_dem,
202 std::vector<Tensor<1, 3>> &contact_force,
203 std::vector<Tensor<1, 3>> &contact_torque)
204{
205 using dealii::numbers::PI;
206
207 for (auto &particle_one : dem_particles)
208 {
209 std::set<unsigned int>::iterator particle_contact_candidates_id;
210 for (particle_contact_candidates_id =
211 particles_contact_candidates[particle_one.particle_id].begin();
212 particle_contact_candidates_id !=
213 particles_contact_candidates[particle_one.particle_id].end();
214 ++particle_contact_candidates_id)
215 {
216 const unsigned int particle_contact_id =
217 *particle_contact_candidates_id;
218
219 auto &particle_two = dem_particles[particle_contact_id];
220 if (particle_one.particle_id < particle_two.particle_id)
221 {
222 ContactInfo contact_info;
223 // Check if there is already information on the contact of
224 // these to particles. If not initialize it in the contact map
225 // with 0 values.
226 try
227 {
228 contact_info = pp_contact_map[particle_one.particle_id]
229 [particle_two.particle_id];
230 }
231 catch (...)
232 {
233 for (int d = 0; d < dim; ++d)
234 {
235 contact_info.tangential_displacement[d] = 0.;
236 contact_info.rolling_resistance_spring_torque[d] = 0.;
237 }
238 pp_contact_map[particle_one.particle_id]
239 [particle_two.particle_id] = contact_info;
240 }
241
242 // Calculation of normal overlap
243 double normal_overlap;
244 Point<dim> contact_point;
245 Tensor<1, dim> normal;
246 std::vector<Point<dim>> contact_points_candidate;
247
248 auto iterator =
249 previous_wall_contact_point[particle_one.particle_id].find(
250 particle_two.particle_id);
251 if (iterator !=
252 previous_wall_contact_point[particle_one.particle_id].end())
253 {
254 contact_points_candidate.push_back(iterator->second);
255 }
256 else
257 {
258 contact_points_candidate.push_back(
259 particle_one.position +
260 (particle_two.position - particle_one.position) *
261 (particle_one.radius /
262 (particle_one.radius + particle_two.radius)));
263 }
264 // The normal vector goes from particle one to particle two.
265 if (typeid(*particle_one.shape) == typeid(Sphere<dim>) &&
266 typeid(*particle_two.shape) == typeid(Sphere<dim>))
267 {
268 auto contact_state = particle_one.shape->distance_to_shape(
269 *particle_two.shape, contact_points_candidate);
270 normal_overlap = -std::get<double>(contact_state);
271 contact_point = std::get<Point<dim>>(contact_state);
272 normal = std::get<Tensor<1, dim>>(contact_state);
273 }
274 else if (typeid(*particle_one.shape) == typeid(Sphere<dim>) &&
275 typeid(*particle_two.shape) != typeid(Sphere<dim>))
276 {
277 auto contact_state = particle_one.shape->distance_to_shape(
278 *particle_two.shape, contact_points_candidate);
279 normal_overlap = -std::get<double>(contact_state);
280 contact_point = std::get<Point<dim>>(contact_state);
281 normal = std::get<Tensor<1, dim>>(contact_state);
282 }
283 else if (typeid(*particle_one.shape) != typeid(Sphere<dim>) &&
284 typeid(*particle_two.shape) == typeid(Sphere<dim>))
285 {
286 auto contact_state = particle_two.shape->distance_to_shape(
287 *particle_one.shape, contact_points_candidate);
288 normal_overlap = -std::get<double>(contact_state);
289 contact_point = std::get<Point<dim>>(contact_state);
290 normal = -std::get<Tensor<1, dim>>(
291 contact_state); // Flip the normal since it returns the
292 // normal using the second particle;
293 }
294 else
295 {
296 auto contact_state = particle_one.shape->distance_to_shape(
297 *particle_two.shape, contact_points_candidate);
298 normal_overlap = -std::get<double>(contact_state);
299 contact_point = std::get<Point<dim>>(contact_state);
300 normal = std::get<Tensor<1, dim>>(contact_state);
301 }
302 previous_wall_contact_point[particle_one.particle_id]
303 [particle_two.particle_id] =
304 contact_point;
305 Point<3> contact_point_3d = point_nd_to_3d(contact_point);
306 Tensor<1, 3> contact_normal = tensor_nd_to_3d(normal);
307
308
309 if (normal_overlap > 0)
310 // This means that the adjacent particles are in contact
311 {
312 double contact_radius_particle_one;
313 double contact_radius_particle_two;
314 if (parameters->approximate_radius_for_contact)
315 {
316 contact_radius_particle_one = particle_one.radius;
317 contact_radius_particle_two = particle_two.radius;
318 }
319 else
320 {
321 contact_radius_particle_one =
322 particle_one.shape->local_curvature_radius(
323 contact_point);
324 contact_radius_particle_two =
325 particle_two.shape->local_curvature_radius(
326 contact_point);
327 }
328 Tensor<1, 3> normal_force;
329 Tensor<1, 3> tangential_force;
330 Tensor<1, 3> particle_one_tangential_torque;
331 Tensor<1, 3> particle_two_tangential_torque;
332 Tensor<1, 3> rolling_resistance_torque;
333 Tensor<1, 3> particle_one_velocity_3d =
334 tensor_nd_to_3d(particle_one.velocity);
335 Tensor<1, 3> particle_two_velocity_3d =
336 tensor_nd_to_3d(particle_two.velocity);
337
338 ObjectProperties particle_one_properties;
339 particle_one_properties.object_friction_coefficient =
340 particle_one.friction_coefficient;
341 particle_one_properties.object_mass = particle_one.mass;
342 particle_one_properties.object_poisson_ratio =
343 particle_one.poisson_ratio;
344 particle_one_properties.object_radius =
345 contact_radius_particle_one;
346 particle_one_properties.object_restitution_coefficient =
347 particle_one.restitution_coefficient;
348 particle_one_properties.object_rolling_friction_coefficient =
349 particle_one.rolling_friction_coefficient;
350 particle_one_properties.object_youngs_modulus =
351 particle_one.youngs_modulus;
352 ObjectProperties particle_two_properties;
353 particle_two_properties.object_friction_coefficient =
354 particle_two.friction_coefficient;
355 particle_two_properties.object_mass = particle_two.mass;
356 particle_two_properties.object_poisson_ratio =
357 particle_two.poisson_ratio;
358 particle_two_properties.object_radius =
359 contact_radius_particle_two;
360 particle_two_properties.object_restitution_coefficient =
361 particle_two.restitution_coefficient;
362 particle_two_properties.object_rolling_friction_coefficient =
363 particle_two.rolling_friction_coefficient;
364 particle_two_properties.object_youngs_modulus =
365 particle_two.youngs_modulus;
366
367 calculate_force_model(normal_overlap,
368 contact_info,
369 contact_point_3d,
370 contact_normal,
371 normal_force,
372 tangential_force,
373 rolling_resistance_torque,
374 particle_one.position,
375 particle_one_velocity_3d,
376 particle_one.omega,
377 particle_one_properties,
378 particle_two.position,
379 particle_two_velocity_3d,
380 particle_two.omega,
381 particle_two_properties,
382 dt_dem);
383
384 contact_force[particle_one.particle_id] -=
385 (normal_force + tangential_force);
386 contact_force[particle_two.particle_id] +=
387 (normal_force + tangential_force);
388
389 contact_torque[particle_one.particle_id] =
390 contact_torque[particle_one.particle_id] -
391 particle_one_tangential_torque + rolling_resistance_torque +
392 cross_product_3d((contact_point_3d -
393 point_nd_to_3d(particle_one.position)),
394 -(normal_force + tangential_force));
395 contact_torque[particle_two.particle_id] =
396 contact_torque[particle_two.particle_id] -
397 particle_two_tangential_torque - rolling_resistance_torque +
398 cross_product_3d((contact_point_3d -
399 point_nd_to_3d(particle_two.position)),
400 (normal_force + tangential_force));
401 }
402
403 else
404 {
405 // if the adjacent pair is not in contact anymore
406 for (int d = 0; d < dim; ++d)
407 {
408 contact_info.tangential_displacement[d] = 0.;
409 contact_info.rolling_resistance_spring_torque[d] = 0.;
410 }
411 pp_contact_map[particle_one.particle_id].erase(
412 particle_two.particle_id);
413 }
414 }
415 }
416 }
417}
418
419template <int dim>
420void
422 const double /*dt_dem*/,
423 const double h_max,
424 const double h_min,
425 const double mu,
426 std::vector<Tensor<1, 3>> &lubrication_force,
427 std::vector<Tensor<1, 3>> & /*lubrication_torque*/)
428{
429 using dealii::numbers::PI;
430
431 // loop over all particles to find pair of close particles
432 for (auto &particle_one : dem_particles)
433 {
434 for (auto particle_contact_candidates_id =
435 particles_contact_candidates[particle_one.particle_id].begin();
436 particle_contact_candidates_id !=
437 particles_contact_candidates[particle_one.particle_id].end();
438 ++particle_contact_candidates_id)
439 {
440 const auto &particle_contact_id = *particle_contact_candidates_id;
441 auto &particle_two = dem_particles[particle_contact_id];
442 if (particle_one.particle_id < particle_two.particle_id)
443 {
444 const Point<dim> particle_one_location = particle_one.position;
445 const Point<dim> particle_two_location = particle_two.position;
446 Tensor<1, 3> radial_vector;
447 double radial_velocity;
448 Tensor<1, 3> f_lub;
449
450 // Calculation of normal overlap
451 double gap =
452 particle_one_location.distance(particle_two_location) -
453 (particle_one.radius + particle_two.radius);
454 radial_vector =
455 tensor_nd_to_3d(particle_one.position - particle_two.position);
456 if (gap > 0 and gap < h_max)
457 // This means that the adjacent particles are very close but
458 // not in contact
459 {
460 // Limit the smallest gap calculated
461 if (gap < h_min)
462 {
463 gap = h_min;
464 }
465
466 // Evaluate the force
467 radial_velocity =
468 scalar_product(-radial_vector, particle_one.velocity) +
469 scalar_product(radial_vector, particle_two.velocity);
470 f_lub =
471 3. / 2. * PI * mu *
472 (particle_one.radius * 2 * particle_two.radius * 2 /
473 (particle_one.radius * 2 + particle_two.radius * 2)) *
474 (particle_one.radius * 2 * particle_two.radius * 2 /
475 (particle_one.radius * 2 + particle_two.radius * 2)) /
476 gap * radial_velocity * radial_vector /
477 radial_vector.norm() -
478 3. / 2. * PI * mu *
479 (particle_one.radius * 2 * particle_two.radius * 2 /
480 (particle_one.radius * 2 + particle_two.radius * 2)) *
481 (particle_one.radius * 2 * particle_two.radius * 2 /
482 (particle_one.radius * 2 + particle_two.radius * 2)) /
483 h_max * radial_velocity * radial_vector /
484 radial_vector.norm();
485
486 // A particle can be close to several others: the force of
487 // each pair is added to the force of both particles.
488 lubrication_force[particle_one.particle_id] += f_lub;
489 lubrication_force[particle_two.particle_id] -= f_lub;
490 }
491 }
492 }
493 }
494}
495
496template <int dim>
497void
499 std::vector<IBParticle<dim>> &particles,
500 const DoFHandler<dim> &dof_handler,
501 const Quadrature<dim - 1> &face_quadrature_formula,
502 const Mapping<dim> &mapping)
503{
504 const FESystem<dim, dim> fe = dof_handler.get_fe();
505 for (unsigned int p_i = 0; p_i < particles.size(); ++p_i)
506 {
507 // For each boundary id, the boundary point closest to the particle,
508 // stored with the level set of the particle at this point.
509 std::map<types::boundary_id, std::pair<double, BoundaryCellsInfo>>
510 closest_boundary_points;
511
512 // Find the new cells that are at a boundary and in proximity of the
513 // particle.
514 auto cells_at_boundary = LetheGridTools::find_boundary_cells_in_sphere(
515 dof_handler,
516 particles[p_i].position,
517 particles[p_i].radius * parameters->contact_search_radius_factor);
518
519 // Loop over the cells at the boundary.
520 for (unsigned int i = 0; i < cells_at_boundary.size(); ++i)
521 {
522 // Each boundary cell is processed by the process that owns it, so
523 // that the closest point does not depend on the partition of the
524 // mesh.
525 if (!cells_at_boundary[i]->is_locally_owned())
526 continue;
527
528 unsigned int n_face_q_points = face_quadrature_formula.size();
529 FEFaceValues<dim> fe_face_values(mapping,
530 fe,
531 face_quadrature_formula,
532 update_values |
533 update_quadrature_points |
534 update_normal_vectors);
535 // Loop over the faces of the cell at the boundary.
536 for (int face_id = 0;
537 face_id < int(GeometryInfo<dim>::faces_per_cell);
538 ++face_id)
539 {
540 // Find the face at the boundary
541 if (cells_at_boundary[i]->face(face_id)->at_boundary())
542 {
543 fe_face_values.reinit(cells_at_boundary[i], face_id);
544 // Loop over the quadrature point of the face at the boundary
545 // to store information about the location and normals of the
546 // boundary.
547 for (unsigned int f_q_point = 0; f_q_point < n_face_q_points;
548 ++f_q_point)
549 {
550 Tensor<1, dim> normal_vector =
551 -fe_face_values.normal_vector(f_q_point);
552 BoundaryCellsInfo boundary_information;
553 boundary_information.normal_vector = normal_vector;
554 boundary_information.point_on_boundary =
555 fe_face_values.quadrature_point(f_q_point);
556 boundary_information.boundary_index =
557 cells_at_boundary[i]->face(face_id)->boundary_id();
559 boundary_information.boundary_index))
560 continue;
561
562 const double level_set = particles[p_i].get_levelset(
563 boundary_information.point_on_boundary);
564
565 // Keep the point if it is the first one found on this
566 // boundary or if it is closer than the best one so far.
567 const auto [iterator, inserted] =
568 closest_boundary_points.try_emplace(
569 boundary_information.boundary_index,
570 level_set,
571 boundary_information);
572 if (!inserted && level_set < iterator->second.first)
573 iterator->second = {level_set, boundary_information};
574 }
575 }
576 }
577 }
578
579 // Regroup the closest points found by all the processes and keep, for
580 // each boundary id, the closest one. If two processes find points at the
581 // same distance, the point of the process of lowest rank is kept.
582 const auto all_closest_boundary_points =
583 Utilities::MPI::all_gather(this->mpi_communicator,
584 closest_boundary_points);
585 closest_boundary_points.clear();
586 for (const auto &process_closest_points : all_closest_boundary_points)
587 {
588 for (const auto &[boundary_id, candidate] : process_closest_points)
589 {
590 const auto [iterator, inserted] =
591 closest_boundary_points.try_emplace(boundary_id, candidate);
592 if (!inserted && candidate.first < iterator->second.first)
593 iterator->second = candidate;
594 }
595 }
596
597 boundary_cells[p_i].clear();
598 for (const auto &[boundary_id, candidate] : closest_boundary_points)
599 boundary_cells[p_i][boundary_id] = candidate.second;
600 }
601}
602template <int dim>
603void
605 const double dt_dem,
606 std::vector<Tensor<1, 3>> &contact_force,
607 std::vector<Tensor<1, 3>> &contact_torque)
608{
609 ObjectProperties wall_properties;
610 wall_properties.object_friction_coefficient =
611 parameters->wall_friction_coefficient;
612 wall_properties.object_poisson_ratio = parameters->wall_poisson_ratio;
613 wall_properties.object_restitution_coefficient =
614 parameters->wall_restitution_coefficient;
616 parameters->wall_rolling_friction_coefficient;
617 wall_properties.object_youngs_modulus = parameters->wall_youngs_modulus;
618
619 using dealii::numbers::PI;
620
621 // Loop over the particles
622 for (auto &particle : dem_particles)
623 {
624 if (particle.integrate_motion)
625 {
626 // Defines map with default values.
627 std::map<types::boundary_id, DefaultDBL_MAX> best_dist;
628 std::map<types::boundary_id, BoundaryCellsInfo> best_cells;
629 // Loop over the point and normal identified as
630 // potential contact candidate.
631 for (auto boundary_cell_iter =
632 boundary_cells[particle.particle_id].begin();
633 boundary_cell_iter != boundary_cells[particle.particle_id].end();
634 boundary_cell_iter++)
635 {
636 // Find the best candidate (the closest point) for each
637 // different wall.
638 double dist = particle.get_levelset(
639 boundary_cell_iter->second.point_on_boundary);
640
641 // Check if the distance is smaller than the best distance.
642 // If it is the first time this boundary is encountered, the
643 // distance is compared to the default value of the map, which
644 // is DBL_MAX
645 if (dist <
646 best_dist[boundary_cell_iter->second.boundary_index].value)
647 {
648 best_dist[boundary_cell_iter->second.boundary_index].value =
649 dist;
650 best_cells[boundary_cell_iter->second.boundary_index] =
651 boundary_cell_iter->second;
652 }
653 }
654
655 // Add all the floating walls as contact candidates. Their indices
656 // start from 1M (defined in the definition of:
657 // lowest_floating_wall_indices). This prevents a floating wall
658 // from sharing the same indices as a normal boundary of the
659 // domain in the contact candidates list.
661 {
662 for (unsigned int i = 0;
663 i < floating_walls_parameters->points_on_walls.size();
664 ++i)
665 {
666 if (floating_walls_parameters->time_start[i] < cfd_time &&
667 floating_walls_parameters->time_end[i] > cfd_time)
668 {
669 BoundaryCellsInfo floating_wall_cell_info;
670 floating_wall_cell_info.point_on_boundary =
671 floating_walls_parameters->points_on_walls[i];
672 floating_wall_cell_info.normal_vector =
674 ->floating_walls_normal_vectors[i];
675 floating_wall_cell_info.boundary_index =
677 best_cells[floating_wall_cell_info.boundary_index] =
678 floating_wall_cell_info;
679 }
680 }
681 }
682
683 // Do the particle wall contact calculation with the best
684 // candidate.
685 for (auto best_index_of_face = best_cells.begin();
686 best_index_of_face != best_cells.end();
687 ++best_index_of_face)
688 {
689 auto &boundary_cell = best_index_of_face->second;
690
691 auto boundary_cell_information = boundary_cell;
692 ContactInfo contact_info;
693
694 // Check if there is already information on the contact
695 // between this particle and this boundary contact point. If
696 // not initialize the contact history with 0 values.
697 try
698 {
699 contact_info = pw_contact_map[particle.particle_id]
700 [boundary_cell.boundary_index];
701 }
702 catch (...)
703 {
704 for (int d = 0; d < dim; ++d)
705 {
706 contact_info.tangential_displacement[d] = 0;
707 contact_info.tangential_relative_velocity[d] = 0;
708 }
709
710 contact_info.normal_overlap = 0;
711 contact_info.normal_relative_velocity = 0;
712
713 pw_contact_map[particle.particle_id]
714 [boundary_cell.boundary_index] = contact_info;
715 }
716
717 Tensor<1, 3> normal =
718 tensor_nd_to_3d(boundary_cell_information.normal_vector);
719 auto point_on_boundary =
720 boundary_cell_information.point_on_boundary;
721
722 Point<3> particle_position_3d = point_nd_to_3d(particle.position);
723 Tensor<1, 3> particle_velocity_3d =
724 tensor_nd_to_3d(particle.velocity);
725
726 // Finding the projected vector on the normal vector of the
727 // boundary. Here we have used the private function
728 // find_projection. Using this projected vector, the
729 // particle-wall distance is calculated
730
731 // Create a Rotation matrix from normal to z axis to
732 // initialize the plane for contact with the right
733 // orientation;
734 Tensor<1, 3> rotation_axis;
735 double angle = 0;
736 if constexpr (dim == 2)
737 {
738 rotation_axis[2] = 1;
739 angle = std::atan2(-normal[0], normal[1]);
740 }
741 else
742 {
743 angle =
744 std::acos(scalar_product(Tensor<1, 3>({0, 0, 1}), normal) /
745 normal.norm());
746 if (abs(scalar_product(Tensor<1, 3>({0, 0, 1}), normal)) !=
747 normal.norm())
748 {
749 rotation_axis =
750 cross_product_3d(Tensor<1, 3>({0, 0, 1}), normal);
751 rotation_axis = rotation_axis / rotation_axis.norm();
752 }
753 else
754 {
755 rotation_axis = Tensor<1, 3>({0, 1, 0});
756 }
757 }
758 Tensor<2, 3> rotation_matrix =
759 Physics::Transformations::Rotations::rotation_matrix_3d(
760 rotation_axis, angle);
761 Tensor<1, 3> orientation =
762 particle.shape->rotation_matrix_to_xyz_angles(rotation_matrix);
763
764 std::shared_ptr<Shape<dim>> contact_plane =
765 std::make_shared<Plane<dim>>(point_on_boundary, orientation);
766 contact_plane->set_position(point_on_boundary);
767 contact_plane->set_orientation(orientation);
768
769
770 std::vector<Point<dim>> contact_point_candidate;
771 auto iterator =
772 previous_wall_contact_point[particle.particle_id].find(
773 boundary_cell.boundary_index);
774 if (iterator !=
775 previous_wall_contact_point[particle.particle_id].end())
776 {
777 contact_point_candidate.push_back(iterator->second);
778 }
779 else
780 {
781 contact_point_candidate.push_back(point_on_boundary);
782 }
783 // Use the last contact point as an initial guess if the level
784 // set is smaller than the wall initial guess. Find the normal
785 // overlap
786 auto contact_state =
787 particle.shape->distance_to_shape(*contact_plane,
788 contact_point_candidate);
789 double normal_overlap = -2 * std::get<double>(contact_state);
790 Point<3> contact_point =
791 point_nd_to_3d(std::get<Point<dim>>(contact_state));
792 // The shape distance routine returns the wall-to-particle
793 // normal. Flip it so the normal points from the particle toward
794 // the wall, consistent with the contact model.
795 Tensor<1, 3> contact_normal = -normal;
796
797
798 // Keep the last contact point as an initial guess for the
799 // next contact point.
800 previous_wall_contact_point[particle.particle_id]
801 [boundary_cell.boundary_index] =
802 std::get<Point<dim>>(contact_state);
803
804 if (normal_overlap > 0)
805 {
806 // Evaluates the curvature radius at the
807 // contact point.
808 double contact_radius_particle_one;
809
810 if (parameters->approximate_radius_for_contact)
811 {
812 contact_radius_particle_one = particle.radius;
813 }
814 else
815 {
816 contact_radius_particle_one =
817 particle.shape->local_curvature_radius(
818 std::get<Point<dim>>(contact_state));
819 }
820 // Do the calculation to evaluate the particle wall
821 // contact force.
822 contact_info.normal_overlap = normal_overlap;
823
824 Tensor<1, 3> normal_force;
825 Tensor<1, 3> tangential_force;
826 Tensor<1, 3> tangential_torque;
827 Tensor<1, 3> rolling_resistance_torque;
828 Tensor<1, 3> wall_velocity;
829 Tensor<1, 3> wall_angular_velocity;
830 Point<dim> wall_rotation_axis_point;
831
832 get_wall_motion(boundary_cell.boundary_index,
833 point_on_boundary,
834 wall_velocity,
835 wall_angular_velocity,
836 wall_rotation_axis_point);
837
838 pw_contact_map[particle.particle_id]
839 [boundary_cell.boundary_index]
840 .normal_overlap = normal_overlap;
841 pw_contact_map[particle.particle_id]
842 [boundary_cell.boundary_index]
843 .normal_vector = normal;
844
845 ObjectProperties particle_properties;
846 particle_properties.object_friction_coefficient =
847 particle.friction_coefficient;
848 particle_properties.object_mass = particle.mass;
849 particle_properties.object_poisson_ratio =
850 particle.poisson_ratio;
851 particle_properties.object_radius =
852 contact_radius_particle_one;
853 particle_properties.object_restitution_coefficient =
854 particle.restitution_coefficient;
855 particle_properties.object_rolling_friction_coefficient =
856 particle.rolling_friction_coefficient;
857 particle_properties.object_youngs_modulus =
858 particle.youngs_modulus;
859
860 // Wall mass is 100 times higher than
861 // the particles that contact it.
862 wall_properties.object_mass = particle.mass * 100;
863 // Wall curvature radius is 100 times higher than
864 // the particle that contacts it.
865 wall_properties.object_radius = particle.radius * 100;
866
867 calculate_force_model(normal_overlap,
868 contact_info,
869 contact_point,
870 contact_normal,
871 normal_force,
872 tangential_force,
873 rolling_resistance_torque,
874 particle.position,
875 particle_velocity_3d,
876 particle.omega,
877 particle_properties,
878 wall_rotation_axis_point,
879 wall_velocity,
880 wall_angular_velocity,
881 wall_properties,
882 dt_dem);
883
884 // Updating the force of particles in the particle handler
885 contact_force[particle.particle_id] -=
886 (normal_force + tangential_force);
887 // Updating the torque acting on particles
888 contact_torque[particle.particle_id] +=
889 tangential_torque + rolling_resistance_torque +
890 cross_product_3d((contact_point - particle_position_3d),
891 -(normal_force + tangential_force));
892 }
893 else
894 {
895 // Set to 0 the tangential displacement if the particle is not
896 // in contact with the wall anymore.
897 for (int d = 0; d < dim; ++d)
898 {
899 contact_info.tangential_displacement[d] = 0.;
900 contact_info.rolling_resistance_spring_torque[d] = 0.;
901 }
902 }
903 }
904 }
905 }
906}
907template <int dim>
908void
910 const double /*dt_dem*/,
911 const double h_max,
912 const double h_min,
913 const double mu,
914 std::vector<Tensor<1, 3>> &lubrication_force,
915 std::vector<Tensor<1, 3>> & /*lubrication_torque*/)
916{
917 using dealii::numbers::PI;
918
919 // Loop over the particles
920 for (auto &particle : dem_particles)
921 {
922 if (particle.integrate_motion)
923 {
924 // Defines map with default values.
925 std::map<types::boundary_id, DefaultDBL_MAX> best_dist;
926 std::map<types::boundary_id, BoundaryCellsInfo> best_cells;
927 // For each particle loop over the point and normal identified as
928 // potential contact candidate.
929 for (auto boundary_cell_iter =
930 boundary_cells[particle.particle_id].begin();
931 boundary_cell_iter != boundary_cells[particle.particle_id].end();
932 boundary_cell_iter++)
933 {
934 // Find the best candidate (the closest point) for each
935 // different wall.
936
937 double dist = particle.get_levelset(
938 boundary_cell_iter->second.point_on_boundary);
939
940 // Check if the distance is smaller than the best distance.
941 // If it is the first time this boundary is encountered, the
942 // distance is compared to the default value of the map, which
943 // is DBL_MAX
944 if (dist <
945 best_dist[boundary_cell_iter->second.boundary_index].value)
946 {
947 best_dist[boundary_cell_iter->second.boundary_index].value =
948 dist;
949 best_cells[boundary_cell_iter->second.boundary_index] =
950 boundary_cell_iter->second;
951 }
952 }
953
954 // Add all the floating walls as contact candidates. Their indices
955 // start from 1M (defined in the definition of:
956 // lowest_floating_wall_indices). This prevents a floating wall
957 // from sharing the same indices as a normal boundary of the
958 // domain in the contact candidates list.
960 {
961 for (unsigned int i = 0;
962 i < floating_walls_parameters->points_on_walls.size();
963 ++i)
964 {
965 if (floating_walls_parameters->time_start[i] < cfd_time &&
966 floating_walls_parameters->time_end[i] > cfd_time)
967 {
968 BoundaryCellsInfo floating_wall_cell_info;
969 floating_wall_cell_info.point_on_boundary =
970 floating_walls_parameters->points_on_walls[i];
971 floating_wall_cell_info.normal_vector =
973 ->floating_walls_normal_vectors[i];
974 floating_wall_cell_info.boundary_index =
976 best_cells[floating_wall_cell_info.boundary_index] =
977 floating_wall_cell_info;
978 }
979 }
980 }
981
982 // Do the particle wall contact calculation with the best
983 // candidate.
984 for (auto best_index_of_face = best_cells.begin();
985 best_index_of_face != best_cells.end();
986 ++best_index_of_face)
987 {
988 auto &boundary_cell = best_index_of_face->second;
989
990 auto boundary_cell_information = boundary_cell;
991 Tensor<1, 3> normal =
992 tensor_nd_to_3d(boundary_cell_information.normal_vector);
993 auto point_on_boundary =
994 boundary_cell_information.point_on_boundary;
995 Tensor<1, 3> wall_velocity;
996 Tensor<1, 3> wall_angular_velocity;
997 Point<dim> wall_rotation_axis_point;
998
999 get_wall_motion(boundary_cell.boundary_index,
1000 point_on_boundary,
1001 wall_velocity,
1002 wall_angular_velocity,
1003 wall_rotation_axis_point);
1004 Tensor<1, 3> wall_velocity_at_point =
1005 wall_velocity +
1006 cross_product_3d(wall_angular_velocity,
1007 point_nd_to_3d(point_on_boundary) -
1008 point_nd_to_3d(wall_rotation_axis_point));
1009
1010 // Calculation of gap
1011 Point<3> particle_position_3d = point_nd_to_3d(particle.position);
1012 Point<3> point_on_boundary_3d = point_nd_to_3d(point_on_boundary);
1013
1014 Tensor<1, 3> point_to_particle_vector =
1015 particle_position_3d - point_on_boundary_3d;
1016
1017 // Finding the projected vector on the normal vector of the
1018 // boundary. Here we have used the private function
1019 // find_projection. Using this projected vector, the
1020 // particle-wall distance is calculated.
1021 Tensor<1, 3> projected_vector =
1022 ((point_to_particle_vector * normal) / (normal.norm_square())) *
1023 normal;
1024
1025 double gap = (projected_vector.norm()) - particle.radius;
1026
1027 Tensor<1, 3> radial_vector;
1028 double radial_velocity;
1029 Tensor<1, 3> f_lub;
1030
1031 radial_vector = projected_vector;
1032 if (gap > 0 and gap < h_max)
1033 // This means that the particles is very close to the wall
1034 // but not in contact
1035 {
1036 // Limit the smallest gap calculated
1037 if (gap < h_min)
1038 {
1039 gap = h_min;
1040 }
1041 // Evaluate the force
1042 radial_velocity =
1043 scalar_product(-radial_vector,
1044 particle.velocity - wall_velocity_at_point);
1045 f_lub = 3. / 2. * PI * mu * (particle.radius) *
1046 (particle.radius) / gap * radial_velocity *
1047 radial_vector / radial_vector.norm() -
1048 3. / 2. * PI * mu * (particle.radius) *
1049 (particle.radius) / h_max * radial_velocity *
1050 radial_vector / radial_vector.norm();
1051
1052 // A particle can be close to several walls: the force of
1053 // each wall is added.
1054 lubrication_force[particle.particle_id] += f_lub;
1055 }
1056 }
1057 }
1058 }
1059}
1060
1061
1062template <int dim>
1063void
1065 const double normal_overlap,
1066 ContactInfo &contact_info,
1067 Point<3> &contact_point,
1068 Tensor<1, 3> &contact_normal,
1069 Tensor<1, 3> &normal_force,
1070 Tensor<1, 3> &tangential_force,
1071 Tensor<1, 3> &rolling_resistance_torque,
1072 Point<dim> &particle_one_position,
1073 Tensor<1, 3> &particle_one_velocity,
1074 Tensor<1, 3> &particle_one_omega,
1075 const ObjectProperties particle_one_properties,
1076 Point<dim> &particle_two_position,
1077 Tensor<1, 3> &particle_two_velocity,
1078 Tensor<1, 3> &particle_two_omega,
1079 const ObjectProperties particle_two_properties,
1080 const double dt)
1081{
1082 double effective_youngs_modulus;
1083 double effective_shear_modulus;
1084 double effective_coefficient_of_restitution;
1085 double effective_coefficient_of_friction;
1086 double effective_coefficient_of_rolling_friction;
1087 double model_parameter_beta;
1088
1089 // Define local variables which will be used within the contact calculation
1090 // Namely: normal and tangential contact forces, tangential and rolling
1091 // torques, normal unit vector of the contact and contact relative velocity
1092 // in the normal direction
1093 Tensor<1, 3> normal_unit_vector;
1094 double normal_relative_velocity_value;
1095 Tensor<1, 3> tangential_relative_velocity;
1096
1097 // DEM::PropertiesIndex::type is the first (0) property of particles in the
1098 // DEM solver. For the IB particles, the first property is ID. For force and
1099 // torque calculations, we need pairwise properties (such as effective
1100 // Young's modulus, effective coefficient of restitution, etc.) We rewrite
1101 // these pairwise properties by using the ID of IB particles (using
1102 // DEM::PropertiesIndex::type) and use them in force calculations.
1103
1104 effective_youngs_modulus =
1105 (particle_one_properties.object_youngs_modulus *
1106 particle_two_properties.object_youngs_modulus) /
1107 ((particle_two_properties.object_youngs_modulus *
1108 (1.0 - particle_one_properties.object_poisson_ratio *
1109 particle_one_properties.object_poisson_ratio)) +
1110 (particle_one_properties.object_youngs_modulus *
1111 (1.0 - particle_two_properties.object_poisson_ratio *
1112 particle_two_properties.object_poisson_ratio)) +
1113 DBL_MIN);
1114
1115 effective_shear_modulus =
1116 (particle_one_properties.object_youngs_modulus *
1117 particle_two_properties.object_youngs_modulus) /
1118 (2.0 * ((particle_two_properties.object_youngs_modulus *
1119 (2.0 - particle_one_properties.object_poisson_ratio) *
1120 (1.0 + particle_one_properties.object_poisson_ratio)) +
1121 (particle_one_properties.object_youngs_modulus *
1122 (2.0 - particle_two_properties.object_poisson_ratio) *
1123 (1.0 + particle_two_properties.object_poisson_ratio))) +
1124 DBL_MIN);
1125
1126 effective_coefficient_of_restitution =
1127 harmonic_mean(particle_one_properties.object_restitution_coefficient,
1128 particle_two_properties.object_restitution_coefficient);
1129 effective_coefficient_of_friction =
1130 harmonic_mean(particle_one_properties.object_friction_coefficient,
1131 particle_two_properties.object_friction_coefficient);
1132 effective_coefficient_of_rolling_friction =
1133 harmonic_mean(particle_one_properties.object_rolling_friction_coefficient,
1134 particle_two_properties.object_rolling_friction_coefficient);
1135
1136 const double restitution_coefficient_particle_log =
1137 std::log(effective_coefficient_of_restitution);
1138
1139 model_parameter_beta = restitution_coefficient_particle_log /
1140 sqrt(restitution_coefficient_particle_log *
1141 restitution_coefficient_particle_log +
1142 9.8696);
1143
1144 // Since the normal overlap is already calculated we update
1145 // this element of the container here. The rest of information
1146 // are updated using the following function
1147
1148 ////////////// Contact info ////////////////
1149
1150 // Calculation of the normal unit contact vector
1151 normal_unit_vector = contact_normal;
1152
1153 // Defining relative contact velocity
1154 Tensor<1, 3> contact_relative_velocity;
1155
1156 // Assigning velocities and angular velocities of particles
1157 Tensor<1, 3> velocity_of_particle_one_at_contact_point =
1158 particle_one_velocity +
1159 cross_product_3d(particle_one_omega,
1160 (contact_point - point_nd_to_3d(particle_one_position)));
1161
1162 Tensor<1, 3> velocity_of_particle_two_at_contact_point =
1163 particle_two_velocity +
1164 cross_product_3d(particle_two_omega,
1165 (contact_point - point_nd_to_3d(particle_two_position)));
1166 contact_relative_velocity = (velocity_of_particle_one_at_contact_point -
1167 velocity_of_particle_two_at_contact_point);
1168
1169 // Calculation of normal relative velocity. Note that in the
1170 // following line the product acts as inner product since both
1171 // sides are vectors, while in the second line the product is
1172 // scalar and vector product
1173 normal_relative_velocity_value =
1174 contact_relative_velocity * normal_unit_vector;
1175
1176 // Calculation of tangential relative velocity
1177 // v_rt = v_ij - (v_ij⋅n_ij)*n_ij
1178 tangential_relative_velocity =
1179 contact_relative_velocity -
1180 (normal_relative_velocity_value * normal_unit_vector);
1181
1182 // Calculation of new tangential_displacement, since this value is
1183 // history-dependent it needs the value at previous time step
1184 // This variable is the main reason that we have iterations over
1185 // two different vectors : tangential_displacement of the particles
1186 // which were already in contact needs to be
1187 // modified using its history, while the tangential_displacements of
1188 // new particles are equal to zero
1189 // delta_t_new = delta_t_old + v_rt*dt
1190 contact_info.tangential_relative_velocity.push_back(
1191 tangential_relative_velocity);
1192 contact_info.tangential_displacement += tangential_relative_velocity * dt;
1193
1194 ///////////// Hertz contact force model ////////////////
1195 // Calculation of effective radius and mass
1196 double effective_mass =
1197 (particle_one_properties.object_mass *
1198 particle_two_properties.object_mass) /
1199 (particle_one_properties.object_mass + particle_two_properties.object_mass);
1200 double effective_radius = (particle_one_properties.object_radius *
1201 particle_two_properties.object_radius) /
1202 ((particle_one_properties.object_radius +
1203 particle_two_properties.object_radius));
1204
1205 const double radius_times_overlap_sqrt =
1206 sqrt(effective_radius * normal_overlap);
1207 const double model_parameter_sn =
1208 2 * effective_youngs_modulus * radius_times_overlap_sqrt;
1209
1210 // Calculation of normal and tangential spring and dashpot constants
1211 // using particle properties
1212 double normal_spring_constant = 0.66665 * model_parameter_sn;
1213 double normal_damping_constant =
1214 -1.8257 * model_parameter_beta * sqrt(model_parameter_sn * effective_mass);
1215 double tangential_spring_constant =
1216 8.0 * effective_shear_modulus * radius_times_overlap_sqrt + DBL_MIN;
1217
1218 // Calculation of normal force using spring and dashpot normal forces
1219 normal_force =
1220 ((normal_spring_constant * normal_overlap) * normal_unit_vector) +
1221 ((normal_damping_constant * normal_relative_velocity_value) *
1222 normal_unit_vector);
1223
1224 // Calculation of tangential force using spring and dashpot tangential
1225 // forces. Since we need dashpot tangential force in the gross sliding
1226 // again, we define it as a separate variable
1227 tangential_force =
1228 tangential_spring_constant * contact_info.tangential_displacement;
1229
1230 double coulomb_threshold =
1231 effective_coefficient_of_friction * normal_force.norm();
1232
1233 // Check for gross sliding
1234 if (tangential_force.norm() > coulomb_threshold)
1235 {
1236 // Gross sliding occurs and the tangential displacement and tangential
1237 // force are limited to Coulomb's criterion
1238 tangential_force =
1239 coulomb_threshold *
1240 (tangential_force / (tangential_force.norm() + DBL_MIN));
1241 }
1242
1243 // For calculation of rolling resistance torque, we need to obtain
1244 // omega_ij using rotational velocities of particles one and two
1245 Tensor<1, 3> omega_ij = particle_one_omega - particle_two_omega;
1246 Tensor<1, 3> omega_ij_direction = omega_ij / (omega_ij.norm() + DBL_MIN);
1247
1248 // Calculation of the linear rolling resistance torque
1249 rolling_resistance_torque =
1250 (-effective_coefficient_of_rolling_friction * effective_radius *
1251 normal_force.norm() * omega_ij_direction);
1252}
1253
1254template <int dim>
1255void
1257 const double h_max,
1258 const double h_min,
1259 const double rho,
1260 const double mu)
1261{
1262 // Initialize local containers and physical variables
1263 using dealii::numbers::PI;
1264 double dt_dem = dt / parameters->coupling_frequency;
1265
1266 std::vector<Tensor<1, 3>> contact_force(dem_particles.size());
1267 std::vector<Tensor<1, 3>> contact_wall_force(dem_particles.size());
1268 std::vector<Tensor<1, 3>> contact_torque(dem_particles.size());
1269 std::vector<Tensor<1, 3>> contact_wall_torque(dem_particles.size());
1270 std::vector<Tensor<1, 3>> current_fluid_force(dem_particles.size());
1271 std::vector<Tensor<1, 3>> current_fluid_torque(dem_particles.size());
1272 std::vector<Tensor<1, 3>> lubrication_force(dem_particles.size());
1273 std::vector<Tensor<1, 3>> lubrication_torque(dem_particles.size());
1274 std::vector<Tensor<1, 3>> lubrication_wall_force(dem_particles.size());
1275 std::vector<Tensor<1, 3>> lubrication_wall_torque(dem_particles.size());
1276
1277 std::vector<Tensor<1, 3>> velocity(dem_particles.size());
1278 std::vector<Point<dim>> position(dem_particles.size());
1279
1280 // Local time for the dem step.
1281 double t = 0;
1282 // The gravitational acceleration at the position of each particle.
1283 std::vector<Tensor<1, 3>> g(dem_particles.size());
1284 this->parameters->f_gravity->set_time(cfd_time + dt);
1285 // The gravitational force on the particle.
1286 Tensor<1, 3> gravity;
1287 // Reset the previous particle contact point list
1290
1291 // Initialize the particles
1292 for (unsigned int p_i = 0; p_i < dem_particles.size(); ++p_i)
1293 {
1294 dem_particles[p_i].position = dem_particles[p_i].previous_positions[0];
1295 dem_particles[p_i].velocity = dem_particles[p_i].previous_velocity[0];
1296 dem_particles[p_i].omega = dem_particles[p_i].previous_omega[0];
1297 dem_particles[p_i].orientation =
1298 dem_particles[p_i].previous_orientation[0];
1299 dem_particles[p_i].impulsion = 0;
1300 dem_particles[p_i].omega_impulsion = 0;
1301 dem_particles[p_i].contact_impulsion = 0;
1302 dem_particles[p_i].omega_contact_impulsion = 0;
1303 // Initialized the gravity at the particle position.
1304 g[p_i][0] =
1305 this->parameters->f_gravity->value(dem_particles[p_i].position, 0);
1306 g[p_i][1] =
1307 this->parameters->f_gravity->value(dem_particles[p_i].position, 1);
1308 if (dim == 3)
1309 g[p_i][2] =
1310 this->parameters->f_gravity->value(dem_particles[p_i].position, 2);
1311 dem_particles[p_i].set_position(dem_particles[p_i].position);
1312 dem_particles[p_i].set_orientation(dem_particles[p_i].orientation);
1313 }
1314
1315 // Integrate with the sub_time_step
1316 while (t + 0.5 * dt_dem < dt)
1317 {
1318 // Initialize vector to contain the RK 4 step
1319 std::vector<Tensor<1, 3>> last_velocity;
1320 std::vector<Point<dim>> last_position;
1321 std::vector<Tensor<1, 3>> last_omega;
1322 std::vector<Tensor<2, 3>> last_orientation_matrix;
1323 auto last_pp_contact_info = pp_contact_map;
1324 auto last_pw_contact_info = pw_contact_map;
1325
1326 last_velocity = std::vector<Tensor<1, 3>>(dem_particles.size());
1327 last_position = std::vector<Point<dim>>(dem_particles.size());
1328 last_omega = std::vector<Tensor<1, 3>>(dem_particles.size());
1329 last_orientation_matrix = std::vector<Tensor<2, 3>>(dem_particles.size());
1330
1331 std::vector<std::vector<Tensor<1, 3>>> k_velocity =
1332 std::vector<std::vector<Tensor<1, 3>>>(dem_particles.size(),
1333 std::vector<Tensor<1, 3>>(4));
1334 std::vector<std::vector<Tensor<1, dim>>> k_position =
1335 std::vector<std::vector<Tensor<1, dim>>>(
1336 dem_particles.size(), std::vector<Tensor<1, dim>>(4));
1337 std::vector<std::vector<Tensor<1, 3>>> k_omega =
1338 std::vector<std::vector<Tensor<1, 3>>>(dem_particles.size(),
1339 std::vector<Tensor<1, 3>>(4));
1340 std::vector<std::vector<Tensor<1, 3>>> k_orientation =
1341 std::vector<std::vector<Tensor<1, 3>>>(dem_particles.size(),
1342 std::vector<Tensor<1, 3>>(4));
1343 std::vector<std::vector<Tensor<1, 3>>> k_impulsion =
1344 std::vector<std::vector<Tensor<1, 3>>>(dem_particles.size(),
1345 std::vector<Tensor<1, 3>>(4));
1346 std::vector<std::vector<Tensor<1, 3>>> k_omega_impulsion =
1347 std::vector<std::vector<Tensor<1, 3>>>(dem_particles.size(),
1348 std::vector<Tensor<1, 3>>(4));
1349 std::vector<std::vector<Tensor<1, 3>>> k_contact_impulsion =
1350 std::vector<std::vector<Tensor<1, 3>>>(dem_particles.size(),
1351 std::vector<Tensor<1, 3>>(4));
1352 std::vector<std::vector<Tensor<1, 3>>> k_omega_contact_impulsion =
1353 std::vector<std::vector<Tensor<1, 3>>>(dem_particles.size(),
1354 std::vector<Tensor<1, 3>>(4));
1355
1356 // Solve each of the 4 step of the RK4 method
1357 for (unsigned int step = 0; step < 4; ++step)
1358 {
1359 std::ranges::fill(current_fluid_force, 0);
1360 std::ranges::fill(current_fluid_torque, 0);
1361 std::ranges::fill(contact_torque, 0);
1362 std::ranges::fill(contact_force, 0);
1363 std::ranges::fill(contact_wall_force, 0);
1364 std::ranges::fill(contact_wall_torque, 0);
1365 std::ranges::fill(lubrication_force, 0);
1366 std::ranges::fill(lubrication_torque, 0);
1367 std::ranges::fill(lubrication_wall_force, 0);
1368 std::ranges::fill(lubrication_wall_torque, 0);
1369
1370 // Time step used by the contact models to increment the tangential
1371 // displacement at this stage.
1372 const double contact_dt = (step == 3) ? dt_dem : 0.5 * dt_dem;
1373
1374 // Time, from the start of the sub-step, of the next stage of the RK4
1375 // scheme: the second and third stages are evaluated at the middle of
1376 // the sub-step and the fourth one at its end.
1377 const double next_stage_dt = (step < 2) ? 0.5 * dt_dem : dt_dem;
1378
1379 // Calculate particle-particle and particle-wall contact force
1380
1381 calculate_pp_contact_force(contact_dt, contact_force, contact_torque);
1382 calculate_pw_contact_force(contact_dt,
1383 contact_wall_force,
1384 contact_wall_torque);
1385
1386 if (parameters->enable_lubrication_force)
1387 {
1389 h_max,
1390 h_min,
1391 mu,
1392 lubrication_force,
1393 lubrication_torque);
1395 h_max,
1396 h_min,
1397 mu,
1398 lubrication_wall_force,
1399 lubrication_wall_torque);
1400 }
1401
1402 for (unsigned int p_i = 0; p_i < dem_particles.size(); ++p_i)
1403 {
1404 if (dem_particles[p_i].integrate_motion)
1405 {
1406 if (step == 0)
1407 {
1408 last_velocity[p_i] = dem_particles[p_i].velocity;
1409 last_position[p_i] = dem_particles[p_i].position;
1410 last_omega[p_i] = dem_particles[p_i].omega;
1411 last_orientation_matrix[p_i] =
1412 dem_particles[p_i].rotation_matrix;
1413 }
1414
1415 gravity = g[p_i] * (dem_particles[p_i].mass -
1416 dem_particles[p_i].volume * rho);
1417
1418 // We consider only the force at t+dt so the scheme is
1419 // consistent to a BDFn scheme on the fluid side. If there is
1420 // no contact.
1421 current_fluid_force[p_i] = dem_particles[p_i].fluid_forces;
1422 current_fluid_torque[p_i] = dem_particles[p_i].fluid_torque;
1423
1424 // Store each rk step of the variable we integrate in its
1425 // respective vector.
1426 k_velocity[p_i][step] =
1427 (current_fluid_force[p_i] + contact_force[p_i] +
1428 contact_wall_force[p_i] + gravity +
1429 lubrication_force[p_i] + lubrication_wall_force[p_i]) /
1430 dem_particles[p_i].mass;
1431
1432 for (int d = 0; d < dim; ++d)
1433 {
1434 k_position[p_i][step][d] = dem_particles[p_i].velocity[d];
1435 }
1436 k_impulsion[p_i][step] =
1437 current_fluid_force[p_i] + gravity +
1438 contact_wall_force[p_i] + contact_force[p_i] +
1439 lubrication_force[p_i] + lubrication_wall_force[p_i];
1440
1441 k_contact_impulsion[p_i][step] =
1442 contact_wall_force[p_i] + contact_force[p_i] +
1443 lubrication_force[p_i] + lubrication_wall_force[p_i];
1444
1445 dem_particles[p_i].velocity =
1446 last_velocity[p_i] + k_velocity[p_i][step] * next_stage_dt;
1447
1448 for (int d = 0; d < dim; ++d)
1449 {
1450 dem_particles[p_i].position[d] =
1451 last_position[p_i][d] +
1452 k_position[p_i][step][d] * next_stage_dt;
1453 }
1454 dem_particles[p_i].set_position(dem_particles[p_i].position);
1455
1456 // Calculate torque in particle frame of reference.
1457 Tensor<1, 3> total_torque =
1458 dem_particles[p_i].rotation_matrix *
1459 (current_fluid_torque[p_i] + contact_torque[p_i] +
1460 contact_wall_torque[p_i]);
1461
1462 // Calculate angular acceleration in particle frame
1463 Tensor<1, 3> angular_velocity_in_particle_frame =
1464 dem_particles[p_i].rotation_matrix *
1465 dem_particles[p_i].omega;
1466 Tensor<1, 3> angular_acceleration_in_particle_frame;
1467 angular_acceleration_in_particle_frame[0] =
1468 (total_torque[0] -
1469 (dem_particles[p_i].inertia[2][2] -
1470 dem_particles[p_i].inertia[1][1]) *
1471 angular_velocity_in_particle_frame[2] *
1472 angular_velocity_in_particle_frame[1]) /
1473 dem_particles[p_i].inertia[0][0];
1474 angular_acceleration_in_particle_frame[1] =
1475 (total_torque[1] -
1476 (dem_particles[p_i].inertia[0][0] -
1477 dem_particles[p_i].inertia[2][2]) *
1478 angular_velocity_in_particle_frame[2] *
1479 angular_velocity_in_particle_frame[0]) /
1480 dem_particles[p_i].inertia[1][1];
1481 angular_acceleration_in_particle_frame[2] =
1482 (total_torque[2] -
1483 (dem_particles[p_i].inertia[1][1] -
1484 dem_particles[p_i].inertia[0][0]) *
1485 angular_velocity_in_particle_frame[0] *
1486 angular_velocity_in_particle_frame[1]) /
1487 dem_particles[p_i].inertia[2][2];
1488 // Rotate angular acceleration in world frame
1489 k_omega[p_i][step] =
1490 invert(dem_particles[p_i].rotation_matrix) *
1491 angular_acceleration_in_particle_frame;
1492
1493 // Store the rk4 step of the angular contact impulsion
1494 k_omega_impulsion[p_i][step] = current_fluid_torque[p_i] +
1495 contact_torque[p_i] +
1496 contact_wall_torque[p_i];
1497
1498 k_omega_contact_impulsion[p_i][step] =
1499 contact_torque[p_i] + contact_wall_torque[p_i];
1500 // The derivative of the orientation at this stage is the
1501 // angular velocity of this stage. It must be stored before
1502 // the angular velocity is advanced to the next stage.
1503 k_orientation[p_i][step] = dem_particles[p_i].omega;
1504
1505 // Integrate the relevant state Variable for the next RK step.
1506 dem_particles[p_i].omega =
1507 last_omega[p_i] + k_omega[p_i][step] * next_stage_dt;
1508 Tensor<2, 3> new_rotation_matrix;
1509 if (k_orientation[p_i][step].norm() > 0)
1510 {
1511 new_rotation_matrix =
1512 Physics::Transformations::Rotations::rotation_matrix_3d(
1513 k_orientation[p_i][step] /
1514 k_orientation[p_i][step].norm(),
1515 k_orientation[p_i][step].norm() * next_stage_dt) *
1516 last_orientation_matrix[p_i];
1517 dem_particles[p_i].orientation =
1518 dem_particles[p_i].shape->rotation_matrix_to_xyz_angles(
1519 new_rotation_matrix);
1520 }
1521 // set the orientation which also update the orientation and
1522 // rotation matrix of the shape.
1523 dem_particles[p_i].set_orientation(
1524 dem_particles[p_i].orientation);
1525 }
1526 else
1527 {
1528 if (parameters->load_particles_from_file == false)
1529 {
1530 dem_particles[p_i].f_position->set_time(cfd_time + t +
1531 next_stage_dt);
1532 dem_particles[p_i].f_velocity->set_time(cfd_time + t +
1533 next_stage_dt);
1534 dem_particles[p_i].f_omega->set_time(cfd_time + t +
1535 next_stage_dt);
1536 dem_particles[p_i].f_orientation->set_time(cfd_time + t +
1537 next_stage_dt);
1538
1539 dem_particles[p_i].position[0] =
1540 dem_particles[p_i].f_position->value(
1541 dem_particles[p_i].position, 0);
1542 dem_particles[p_i].position[1] =
1543 dem_particles[p_i].f_position->value(
1544 dem_particles[p_i].position, 1);
1545 dem_particles[p_i].velocity[0] =
1546 dem_particles[p_i].f_velocity->value(
1547 dem_particles[p_i].position, 0);
1548 dem_particles[p_i].velocity[1] =
1549 dem_particles[p_i].f_velocity->value(
1550 dem_particles[p_i].position, 1);
1551 dem_particles[p_i].omega[0] =
1552 dem_particles[p_i].f_omega->value(
1553 dem_particles[p_i].position, 0);
1554 dem_particles[p_i].omega[1] =
1555 dem_particles[p_i].f_omega->value(
1556 dem_particles[p_i].position, 1);
1557 dem_particles[p_i].omega[2] =
1558 dem_particles[p_i].f_omega->value(
1559 dem_particles[p_i].position, 2);
1560 dem_particles[p_i].orientation[0] =
1561 dem_particles[p_i].f_orientation->value(
1562 dem_particles[p_i].position, 0);
1563 dem_particles[p_i].orientation[1] =
1564 dem_particles[p_i].f_orientation->value(
1565 dem_particles[p_i].position, 1);
1566 dem_particles[p_i].orientation[2] =
1567 dem_particles[p_i].f_orientation->value(
1568 dem_particles[p_i].position, 2);
1569 if (dim == 3)
1570 {
1571 dem_particles[p_i].position[2] =
1572 dem_particles[p_i].f_position->value(
1573 dem_particles[p_i].position, 2);
1574 dem_particles[p_i].velocity[2] =
1575 dem_particles[p_i].f_velocity->value(
1576 dem_particles[p_i].position, 2);
1577 }
1578 }
1579 else
1580 {
1581 // The velocity and angular velocity of a particle loaded
1582 // from a file are constant. Its state at the next stage
1583 // is computed from its state at the start of the CFD
1584 // time step.
1585 const double elapsed_time = t + next_stage_dt;
1586 for (int d = 0; d < dim; ++d)
1587 {
1588 dem_particles[p_i].position[d] =
1589 dem_particles[p_i].previous_positions[0][d] +
1590 dem_particles[p_i].velocity[d] * elapsed_time;
1591 }
1592 dem_particles[p_i].orientation =
1593 dem_particles[p_i].previous_orientation[0] +
1594 dem_particles[p_i].omega * elapsed_time;
1595 }
1596 dem_particles[p_i].set_position(dem_particles[p_i].position);
1597 dem_particles[p_i].set_orientation(
1598 dem_particles[p_i].orientation);
1599 }
1600 }
1601 // reset the contact overlap for the next RK step.
1602 for (auto it = pw_contact_map.begin(); it != pw_contact_map.end();
1603 it++)
1604 {
1605 unsigned int particle_id = it->first;
1606 for (auto it2 = it->second.begin(); it2 != it->second.end();
1607 it2++)
1608 {
1609 unsigned int wall_id = it2->first;
1610 auto contact_info = it2->second;
1611 // Check if all 4 of the RK steps are in the contact info. If
1612 // it is not the case, this means this is a new contact, or
1613 // the contact ended. In this case, we simply take the last RK
1614 // step registered as the derivative for the integration.
1615 if (last_pw_contact_info.find(particle_id) !=
1616 last_pw_contact_info.end())
1617 {
1618 auto previous_contact_info_iterator =
1619 last_pw_contact_info.find(particle_id)
1620 ->second.find(wall_id);
1621 if (previous_contact_info_iterator !=
1622 last_pw_contact_info.find(particle_id)->second.end())
1623 {
1624 contact_info.tangential_displacement =
1625 previous_contact_info_iterator->second
1626 .tangential_displacement;
1627 }
1628 else
1629 {
1630 contact_info.tangential_displacement = 0;
1631 }
1632 }
1633 else
1634 {
1635 // one of the map is empty and we try to acces it.
1636 contact_info.tangential_displacement = 0;
1637 }
1638 }
1639 }
1640
1641 for (auto it = pp_contact_map.begin(); it != pp_contact_map.end();
1642 it++)
1643 {
1644 unsigned int particle_one_id = it->first;
1645 for (auto it2 = it->second.begin(); it2 != it->second.end();
1646 it2++)
1647 {
1648 unsigned int particle_two_id = it2->first;
1649 auto contact_info = it2->second;
1650 // Check if all 4 of the RK steps are in the contact info. If
1651 // it is not the case, this means this is a new contact, or
1652 // the contact ended. In this case, we simply take the last RK
1653 // step registered as the derivative for the integration.
1654 if (last_pp_contact_info.find(particle_one_id) !=
1655 last_pp_contact_info.end())
1656 {
1657 auto previous_contact_info_iterator =
1658 last_pp_contact_info.find(particle_one_id)
1659 ->second.find(particle_two_id);
1660 if (previous_contact_info_iterator !=
1661 last_pp_contact_info.find(particle_one_id)
1662 ->second.end())
1663 {
1664 contact_info.tangential_displacement =
1665 previous_contact_info_iterator->second
1666 .tangential_displacement;
1667 }
1668 else
1669 {
1670 contact_info.tangential_displacement = 0;
1671 }
1672 }
1673 else
1674 {
1675 contact_info.tangential_displacement = 0;
1676 }
1677 }
1678 }
1679 }
1680
1681 for (unsigned int p_i = 0; p_i < dem_particles.size(); ++p_i)
1682 {
1683 if (dem_particles[p_i].integrate_motion)
1684 {
1685 // Define the integral by combining each of the RK step.
1686 dem_particles[p_i].velocity =
1687 last_velocity[p_i] +
1688 dt_dem *
1689 (k_velocity[p_i][0] + 2 * k_velocity[p_i][1] +
1690 2 * k_velocity[p_i][2] + k_velocity[p_i][3]) /
1691 6;
1692
1693 for (int d = 0; d < dim; ++d)
1694 {
1695 dem_particles[p_i].position[d] =
1696 last_position[p_i][d] +
1697 dt_dem *
1698 (k_position[p_i][0][d] + 2 * k_position[p_i][1][d] +
1699 2 * k_position[p_i][2][d] + k_position[p_i][3][d]) /
1700 6;
1701 }
1702
1703 dem_particles[p_i].omega =
1704 last_omega[p_i] + dt_dem *
1705 (k_omega[p_i][0] + 2 * k_omega[p_i][1] +
1706 2 * k_omega[p_i][2] + k_omega[p_i][3]) /
1707 6;
1708 Tensor<1, 3> angle_update_vector =
1709 (k_orientation[p_i][0] + 2 * k_orientation[p_i][1] +
1710 2 * k_orientation[p_i][2] + k_orientation[p_i][3]) /
1711 6;
1712 // Update orientation matrix explicitly
1713 Tensor<2, 3> new_rotation_matrix;
1714 if (angle_update_vector.norm() > 0)
1715 {
1716 new_rotation_matrix =
1717 Physics::Transformations::Rotations::rotation_matrix_3d(
1718 angle_update_vector / angle_update_vector.norm(),
1719 angle_update_vector.norm() * dt_dem) *
1720 last_orientation_matrix[p_i];
1721 dem_particles[p_i].orientation =
1722 dem_particles[p_i].shape->rotation_matrix_to_xyz_angles(
1723 new_rotation_matrix);
1724 }
1725
1726 // Integration of the impulsion applied to the particle.
1727 // This is what will be transferred to the CFD to integrate the
1728 // particle.
1729 dem_particles[p_i].impulsion +=
1730 dt_dem *
1731 (k_impulsion[p_i][0] + 2 * k_impulsion[p_i][1] +
1732 2 * k_impulsion[p_i][2] + k_impulsion[p_i][3]) /
1733 6;
1734
1735 dem_particles[p_i].contact_impulsion +=
1736 dt_dem *
1737 (k_contact_impulsion[p_i][0] + 2 * k_contact_impulsion[p_i][1] +
1738 2 * k_contact_impulsion[p_i][2] +
1739 k_contact_impulsion[p_i][3]) /
1740 6;
1741
1742 dem_particles[p_i].omega_impulsion +=
1743 dt_dem *
1744 (k_omega_impulsion[p_i][0] + 2 * k_omega_impulsion[p_i][1] +
1745 2 * k_omega_impulsion[p_i][2] + k_omega_impulsion[p_i][3]) /
1746 6;
1747
1748 dem_particles[p_i].omega_contact_impulsion +=
1749 dt_dem *
1750 (k_omega_contact_impulsion[p_i][0] +
1751 2 * k_omega_contact_impulsion[p_i][1] +
1752 2 * k_omega_contact_impulsion[p_i][2] +
1753 k_omega_contact_impulsion[p_i][3]) /
1754 6;
1755
1756 // update particle position and orientation
1757 dem_particles[p_i].set_position(dem_particles[p_i].position);
1758 dem_particles[p_i].set_orientation(
1759 dem_particles[p_i].orientation);
1760 }
1761 }
1762
1763 // RK4 for the particle wall tangential displacement
1764 for (auto it = pw_contact_map.begin(); it != pw_contact_map.end(); it++)
1765 {
1766 unsigned int particle_id = it->first;
1767 for (auto it2 = it->second.begin(); it2 != it->second.end(); it2++)
1768 {
1769 unsigned int wall_id = it2->first;
1770 auto contact_info = it2->second;
1771 // Check if all 4 of the RK steps are in the contact info. If it
1772 // is not the case, this means this is a new contact, or the
1773 // contact ended. In this case, we simply take the last RK step
1774 // registered as the derivative for the integration.
1775 Tensor<1, 3> previous_tangential_displacement;
1776 if (last_pw_contact_info.find(particle_id) !=
1777 last_pw_contact_info.end())
1778 {
1779 auto previous_contact_info_iterator =
1780 last_pw_contact_info.find(particle_id)
1781 ->second.find(wall_id);
1782 if (previous_contact_info_iterator !=
1783 last_pw_contact_info.find(particle_id)->second.end())
1784 {
1785 previous_tangential_displacement =
1786 previous_contact_info_iterator->second
1787 .tangential_displacement;
1788 }
1789 }
1790 else
1791 {
1792 previous_tangential_displacement = 0;
1793 }
1794 if (contact_info.tangential_relative_velocity.size() == 4)
1795 {
1796 contact_info.tangential_displacement =
1797 previous_tangential_displacement +
1798 dt_dem / 6.0 *
1799 (contact_info.tangential_relative_velocity[0] +
1800 2 * contact_info.tangential_relative_velocity[1] +
1801 2 * contact_info.tangential_relative_velocity[2] +
1802 contact_info.tangential_relative_velocity[3]);
1803 }
1804 else if (contact_info.tangential_relative_velocity.size() > 0)
1805 {
1806 contact_info.tangential_displacement =
1807 previous_tangential_displacement +
1808 dt_dem *
1809 contact_info.tangential_relative_velocity
1810 [contact_info.tangential_relative_velocity.size()];
1811 }
1812 else
1813 {
1814 contact_info.tangential_displacement = 0;
1815 }
1816
1817 // clear the vector for the next set of 4 Rk steps
1818 contact_info.tangential_relative_velocity.clear();
1819 }
1820 }
1821 // Same for particle-particle tangential displacement
1822 for (auto it = pp_contact_map.begin(); it != pp_contact_map.end(); it++)
1823 {
1824 unsigned int particle_one_id = it->first;
1825 for (auto it2 = it->second.begin(); it2 != it->second.end(); it2++)
1826 {
1827 unsigned int particle_two_id = it2->first;
1828 auto contact_info = it2->second;
1829 // Check if all 4 of the RK steps are in the contact info. If it
1830 // is not the case, this means this is a new contact, or the
1831 // contact ended. In this case, we simply take the last RK step
1832 // registered as the derivative for the integration.
1833 Tensor<1, 3> previous_tangential_displacement;
1834 if (last_pp_contact_info.find(particle_one_id) !=
1835 last_pp_contact_info.end())
1836 {
1837 auto previous_contact_info_iterator =
1838 last_pp_contact_info.find(particle_one_id)
1839 ->second.find(particle_two_id);
1840 if (previous_contact_info_iterator !=
1841 last_pp_contact_info.find(particle_one_id)->second.end())
1842 {
1843 previous_tangential_displacement =
1844 previous_contact_info_iterator->second
1845 .tangential_displacement;
1846 }
1847 }
1848 else
1849 {
1850 previous_tangential_displacement = 0;
1851 }
1852 if (contact_info.tangential_relative_velocity.size() == 4)
1853 {
1854 contact_info.tangential_displacement =
1855 previous_tangential_displacement +
1856 dt_dem / 6.0 *
1857 (contact_info.tangential_relative_velocity[0] +
1858 2 * contact_info.tangential_relative_velocity[1] +
1859 2 * contact_info.tangential_relative_velocity[2] +
1860 contact_info.tangential_relative_velocity[3]);
1861 }
1862 else if (contact_info.tangential_relative_velocity.size() > 0)
1863 {
1864 contact_info.tangential_displacement =
1865 previous_tangential_displacement +
1866 dt_dem *
1867 contact_info.tangential_relative_velocity
1868 [contact_info.tangential_relative_velocity.size()];
1869 }
1870 else
1871 {
1872 contact_info.tangential_displacement = 0;
1873 }
1874 // clear the vector for the next set of 4 Rk steps
1875 contact_info.tangential_relative_velocity.clear();
1876 }
1877 }
1878 t += dt_dem;
1879 }
1880}
1881
1882template class IBParticlesDEM<2>;
1883template class IBParticlesDEM<3>;
double harmonic_mean(const double &value_one, const double &value_two)
Define the behavior of a specific particle for the sharp interface IB solver.
Definition ib_particle.h:26
A solver class for the DEM used in conjunction with IB particles and fluid_dynamics_sharp....
bool is_boundary_excluded(const types::boundary_id boundary_id) const
Check whether a boundary should be ignored for Sharp-IB particle wall interactions.
void calculate_pw_contact_force(const double dt_dem, std::vector< Tensor< 1, 3 > > &contact_force, std::vector< Tensor< 1, 3 > > &contact_torque)
Calculates non-linear (Hertzian) particle-wall contact force.
std::map< unsigned int, std::map< unsigned int, Point< dim > > > previous_wall_contact_point
void calculate_pw_lubrication_force(const double dt_dem, const double h_max, const double h_min, const double mu, std::vector< Tensor< 1, 3 > > &lubrication_force, std::vector< Tensor< 1, 3 > > &lubrication_torque)
Calculates particle-wall lubrication force.
void calculate_force_model(const double normal_overlap, ContactInfo &contact_info, Point< 3 > &contact_point, Tensor< 1, 3 > &contact_normal, Tensor< 1, 3 > &normal_force, Tensor< 1, 3 > &tangential_force, Tensor< 1, 3 > &rolling_resistance_torque, Point< dim > &particle_one_position, Tensor< 1, 3 > &particle_one_velocity, Tensor< 1, 3 > &particle_one_omega, const ObjectProperties particle_one_properties, Point< dim > &particle_two_position, Tensor< 1, 3 > &particle_two_velocity, Tensor< 1, 3 > &particle_two_omega, const ObjectProperties particle_two_properties, const double dt)
Calculates non-linear (Hertzian) force between two objects. Take into input the physical properties a...
std::map< unsigned int, std::map< unsigned int, Point< dim > > > previous_particle_particle_contact_point
void calculate_pp_lubrication_force(const double dt_dem, const double h_max, const double h_min, const double mu, std::vector< Tensor< 1, 3 > > &lubrication_force, std::vector< Tensor< 1, 3 > > &lubrication_torque)
Calculates particle-particle lubrication force. The force is based on the formula from Microhydrodyna...
std::map< unsigned int, std::map< unsigned int, ContactInfo > > pp_contact_map
std::shared_ptr< Parameters::Lagrangian::BCDEM > boundary_conditions_parameters
std::vector< std::map< types::boundary_id, BoundaryCellsInfo > > boundary_cells
std::shared_ptr< Parameters::Lagrangian::FloatingWalls< dim > > floating_walls_parameters
std::vector< IBParticle< dim > > dem_particles
void update_contact_candidates()
Updates the contact candidates of all the particles.
void update_particles_boundary_contact(std::vector< IBParticle< dim > > &particles, const DoFHandler< dim > &dof_handler, const Quadrature< dim - 1 > &face_quadrature_formula, const Mapping< dim > &mapping)
Update the boundary cells that are contact candidates for each particle.
void calculate_pp_contact_force(const double dt_dem, std::vector< Tensor< 1, 3 > > &contact_force, std::vector< Tensor< 1, 3 > > &contact_torque)
Calculates non-linear (Hertzian) particle-particle contact force.
std::map< unsigned int, std::map< types::boundary_id, ContactInfo > > pw_contact_map
void initialize(const std::shared_ptr< Parameters::IBParticles< dim > > &p_nsparam, const std::shared_ptr< Parameters::Lagrangian::FloatingWalls< dim > > &floating_walls_parameters, const std::shared_ptr< Parameters::Lagrangian::BCDEM > &boundary_conditions_parameters, const MPI_Comm &mpi_communicator_input, const std::vector< IBParticle< dim > > &particles)
Initialize the IBParticlesDEM object with the parameters, the mpi communicator and the particles.
void get_wall_motion(const types::boundary_id boundary_id, const Point< dim > &point_on_boundary, Tensor< 1, 3 > &wall_velocity, Tensor< 1, 3 > &wall_angular_velocity, Point< dim > &wall_rotation_axis_point) const
Get the DEM wall motion prescribed on a boundary.
std::vector< std::set< unsigned int > > particles_contact_candidates
std::shared_ptr< Parameters::IBParticles< dim > > parameters
void update_particles(const std::vector< IBParticle< dim > > &particles, double time)
Updates the boundary cells that are contact candidates for each of the particles.
void integrate_particles_motion(const double dt, const double h_max, const double h_min, const double rho, const double mu)
Integrates the dynamics of the IB_particle taking into account the contact between particles and betw...
MPI_Comm mpi_communicator
Parameters for floating walls in DEM simulations.
std::vector< typename DoFHandler< dim >::active_cell_iterator > find_boundary_cells_in_sphere(const DoFHandler< dim > &dof_handler, const Point< dim > &center, const double radius)
Function returns all the boundary cells with at least one vertex in a sphere.
Parameter structures for Lagrangian (DEM) particle simulations.
Struct that contains history of the contact between two objects. This is the commonly used constructo...
std::vector< Tensor< 1, 3 > > tangential_relative_velocity
Tensor< 1, 3 > rolling_resistance_spring_torque
Tensor< 1, 3 > tangential_displacement
Struct is used to reduce the number of parameters passed in the function calculate_force_model.
Tensor< 1, 3 > tensor_nd_to_3d(const Tensor< 1, dim > &tensor)
Point< 3 > point_nd_to_3d(const Point< dim > &point)