Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
find_contact_detection_step.cc
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2020-2026 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
6
7using namespace dealii;
8
9template <int dim, typename PropertiesIndex>
10void
12 Particles::ParticleHandler<dim> &particle_handler,
13 const double dt,
14 const double smallest_contact_search_criterion,
15 MPI_Comm &mpi_communicator,
16 std::vector<double> &displacement,
17 const bool parallel_update)
18{
19 // Get the action manager
20 auto *action_manager = DEMActionManager::get_action_manager();
21 // If something else has already triggered contact search,
22 // no need to do it again
23 if (action_manager->check_contact_search())
24 return;
25
26 double max_displacement = 0.;
27 bool contact_detection_step = false;
28
29 // Updating displacement
30 for (auto &particle : particle_handler)
31 {
32 auto particle_properties = particle.get_properties();
33 auto &particle_displacement = displacement[particle.get_local_index()];
34
35 // Finding displacement of each particle during last step
36 particle_displacement +=
37 dt * sqrt(particle_properties[PropertiesIndex::v_x] *
38 particle_properties[PropertiesIndex::v_x] +
39 particle_properties[PropertiesIndex::v_y] *
40 particle_properties[PropertiesIndex::v_y] +
41 particle_properties[PropertiesIndex::v_z] *
42 particle_properties[PropertiesIndex::v_z]);
43
44 // Updating maximum displacement of particles
45 max_displacement = std::max(max_displacement, particle_displacement);
46 }
47
48 // If the maximum displacement of particles exceeds criterion, this step
49 // is a contact detection step
50 contact_detection_step = max_displacement > smallest_contact_search_criterion;
51
52 // Broadcasting contact detection step value to other processors
53 if (parallel_update)
54 {
55 contact_detection_step =
56 Utilities::MPI::logical_or(contact_detection_step, mpi_communicator);
57 if (contact_detection_step)
58 action_manager->contact_detection_step();
59 }
60}
61
62template void
64 Particles::ParticleHandler<2> &particle_handler,
65 const double dt,
66 const double smallest_contact_search_criterion,
67 MPI_Comm &mpi_communicator,
68 std::vector<double> &displacement,
69 const bool parallel_update);
70
71template void
73 Particles::ParticleHandler<3> &particle_handler,
74 const double dt,
75 const double smallest_contact_search_criterion,
76 MPI_Comm &mpi_communicator,
77 std::vector<double> &displacement,
78 const bool parallel_update);
79
80template void
82 Particles::ParticleHandler<2> &particle_handler,
83 const double dt,
84 const double smallest_contact_search_criterion,
85 MPI_Comm &mpi_communicator,
86 std::vector<double> &displacement,
87 const bool parallel_update);
88
89template void
91 Particles::ParticleHandler<3> &particle_handler,
92 const double dt,
93 const double smallest_contact_search_criterion,
94 MPI_Comm &mpi_communicator,
95 std::vector<double> &displacement,
96 const bool parallel_update);
97
98template void
100 Particles::ParticleHandler<2> &particle_handler,
101 const double dt,
102 const double smallest_contact_search_criterion,
103 MPI_Comm &mpi_communicator,
104 std::vector<double> &displacement,
105 const bool parallel_update);
106
107template void
110 Particles::ParticleHandler<2> &particle_handler,
111 const double dt,
112 const double smallest_contact_search_criterion,
113 MPI_Comm &mpi_communicator,
114 std::vector<double> &displacement,
115 const bool parallel_update);
116
117template void
119 Particles::ParticleHandler<3> &particle_handler,
120 const double dt,
121 const double smallest_contact_search_criterion,
122 MPI_Comm &mpi_communicator,
123 std::vector<double> &displacement,
124 const bool parallel_update);
125
126template void
129 Particles::ParticleHandler<3> &particle_handler,
130 const double dt,
131 const double smallest_contact_search_criterion,
132 MPI_Comm &mpi_communicator,
133 std::vector<double> &displacement,
134 const bool parallel_update);
135
136
137template <int dim>
138void
140 const double smallest_contact_search_criterion,
141 std::vector<std::shared_ptr<SerialSolid<dim - 1, dim>>> solids)
142{
143 // Get the action manager
144 auto *action_manager = DEMActionManager::get_action_manager();
145
146 // If there is no solid object, no need to do anything
147 if (!action_manager->check_solid_objects_enabled())
148 return;
149
150 bool floating_mesh_requires_map = false;
151
152 for (unsigned int i_solid = 0; i_solid < solids.size(); ++i_solid)
153 {
154 double displacement =
155 solids[i_solid]->get_max_displacement_since_mapped();
156 floating_mesh_requires_map =
157 floating_mesh_requires_map ||
158 displacement > smallest_contact_search_criterion;
159 }
160
161 if (floating_mesh_requires_map)
162 action_manager->solid_objects_search_step();
163}
164
165template void
167 const double smallest_contact_search_criterion,
168 std::vector<std::shared_ptr<SerialSolid<1, 2>>> solids);
169
170template void
172 const double smallest_contact_search_criterion,
173 std::vector<std::shared_ptr<SerialSolid<2, 3>>> solids);
static DEMActionManager * get_action_manager()
Getter of the unique instance of the DEMActionManager.
template void find_particle_contact_detection_step< 2, DEM::CFDDEMProperties::PropertiesIndex >(Particles::ParticleHandler< 2 > &particle_handler, const double dt, const double smallest_contact_search_criterion, MPI_Comm &mpi_communicator, std::vector< double > &displacement, const bool parallel_update)
template void find_particle_contact_detection_step< 3, DEM::CFDDEMProperties::PropertiesIndex >(Particles::ParticleHandler< 3 > &particle_handler, const double dt, const double smallest_contact_search_criterion, MPI_Comm &mpi_communicator, std::vector< double > &displacement, const bool parallel_update)
template void find_floating_mesh_mapping_step< 3 >(const double smallest_contact_search_criterion, std::vector< std::shared_ptr< SerialSolid< 2, 3 > > > solids)
template void find_particle_contact_detection_step< 3, DEM::DEMProperties::PropertiesIndex >(Particles::ParticleHandler< 3 > &particle_handler, const double dt, const double smallest_contact_search_criterion, MPI_Comm &mpi_communicator, std::vector< double > &displacement, const bool parallel_update)
template void find_particle_contact_detection_step< 3, DEM::DEMMPProperties::PropertiesIndex >(Particles::ParticleHandler< 3 > &particle_handler, const double dt, const double smallest_contact_search_criterion, MPI_Comm &mpi_communicator, std::vector< double > &displacement, const bool parallel_update)
template void find_particle_contact_detection_step< 2, DEM::DEMMPProperties::PropertiesIndex >(Particles::ParticleHandler< 2 > &particle_handler, const double dt, const double smallest_contact_search_criterion, MPI_Comm &mpi_communicator, std::vector< double > &displacement, const bool parallel_update)
void find_particle_contact_detection_step(Particles::ParticleHandler< dim > &particle_handler, const double dt, const double smallest_contact_search_criterion, MPI_Comm &mpi_communicator, std::vector< double > &displacement, const bool parallel_update)
Find steps for dynamic contact search for particle-particle contacts.
template void find_floating_mesh_mapping_step< 2 >(const double smallest_contact_search_criterion, std::vector< std::shared_ptr< SerialSolid< 1, 2 > > > solids)
template void find_particle_contact_detection_step< 2, DEM::DEMProperties::PropertiesIndex >(Particles::ParticleHandler< 2 > &particle_handler, const double dt, const double smallest_contact_search_criterion, MPI_Comm &mpi_communicator, std::vector< double > &displacement, const bool parallel_update)
void find_floating_mesh_mapping_step(const double smallest_contact_search_criterion, std::vector< std::shared_ptr< SerialSolid< dim - 1, dim > > > solids)
Find steps for dynamic contact search in particle-floating mesh contacts.
void find_particle_contact_detection_step(Particles::ParticleHandler< dim > &particle_handler, const double dt, const double smallest_contact_search_criterion, MPI_Comm &mpi_communicator, std::vector< double > &displacement, const bool parallel_update=true)
Find steps for dynamic contact search for particle-particle contacts.
PropertiesIndex
Particle property indices for CFD-DEM multiphysics simulations.