Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
dem_action_manager.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2024-2026 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
4#ifndef lethe_dem_action_manager_h
5#define lethe_dem_action_manager_h
6
7/**
8 * @brief Manage the actions to be performed in the DEM solver and on the DEM
9 * part of the coupling CFD-DEM solver.
10 *
11 * Any event that needs some following actions is handled by the action
12 * manager. The event communicates to the action manager that it happened and
13 * the action manager will change the trigger flags to the actions to be taken.
14 * When this action is about to be performed, it checks with the action manager
15 * if it should be triggered.
16 * Many events can trigger the same actions, but when the action is about to
17 * be performed, it only checks if it has to be performed, not what event have
18 * happened.
19 *
20 * If you implement a new feature that needs resetting or contact search after
21 * (or other actions), you should add a new "step" function to the action
22 * manager that will set the trigger to the action to be performed.
23 * If you implement new actions, you should add a new trigger flag and a new
24 * check function to the action manager. Obviously, you should also have to
25 * initialize the trigger in the constructor, and reset it in the reset
26 * function called after a DEM iteration.
27 * If the action depends on a enabling of a feature, you should add a new
28 * function to set the enabled flag.
29 */
31{
32public:
33 /**
34 * @brief Copy constructor as a delete function to make sure it can not be
35 * copied. It will never be used.
36 *
37 * @param copy The object to be copied
38 */
39 DEMActionManager(const DEMActionManager &copy) = delete;
40
41 /**
42 * @brief Copy constructor as a delete function to make sure it can not be
43 * assigned. It will never be used.
44 *
45 * @param copy The object to be copied
46 */
48 operator=(const DEMActionManager &copy) = delete;
49
50 /**
51 * @brief Getter of the unique instance of the DEMActionManager.
52 */
53 static DEMActionManager *
55
56 /**
57 * @brief Reset all triggers to false.
58 * TODO: modify the handling of the contact search at counter = 1 because of
59 * the resetting of the mobility status.
60 */
61 inline void
63 {
64 // First mobility status identification of the CFD time step (from the
65 // velocity computed at the first DEM time step (counter = 0) of the CFD
66 // time step) The contact search is executed to make sure the mobility
67 // status of the cell matches the particles that are in.
75 }
76
77 /**
78 * @brief Flag that there are periodic boundary in the simulation.
79 */
80 inline void
85
86 /**
87 * @brief Check if the periodic boundaries are enabled to perform some actions
88 * that are not handled by triggers of the action manager.
89 *
90 * @return True if the periodic boundaries are enabled.
91 */
92 inline bool
97
98 /**
99 * @brief Flag that there are solid objects in the simulation. Already trigger
100 * a solid object search in the background map.
101 */
102 inline void
104 {
105 this->solid_objects_enabled = true;
106
107 // Allowing the first contact search of solid objects
109 }
110
111 /**
112 * @brief Check if the solid objects are enabled to perform some actions
113 * that are not handled by triggers of the action manager.
114 *
115 * @return True if the solid objects are enabled.
116 */
117 inline bool
122
123 /**
124 * @brief Flag that the ASC is enabled and trigger a
125 * mobility status reset to initialize the containers.
126 */
127 inline void
129 {
130 this->sparse_contacts_enabled = true;
131
132 // Allowing the full broad search without mobility status at first iteration
134 }
135
136
137 /**
138 * @brief Disables the ASC.
139 */
140 inline void
142 {
143 this->sparse_contacts_enabled = false;
144
145 // Allowing the full broad search without mobility status at first iteration
147 }
148
149 /**
150 * @brief Check if the sparse contacts is enabled to perform some actions
151 * that are not handled by triggers of the action manager.
152 *
153 * @return True if the sparse contacts is enabled.
154 */
155 inline bool
160
161 /**
162 * @brief Flag that the grid will motion in the simulation.
163 */
164 inline void
166 {
167 this->grid_motion_enabled = true;
168 }
169
170 /**
171 * @brief Check if the solid objects are enabled to perform some actions
172 * that are not handled by triggers of the action manager.
173 *
174 * @return True if the solid objects are enabled.
175 */
176 inline bool
181
182 /**
183 * @brief Set triggers for actions to be performed in the current time step
184 * because the simulation starts from restart files (previously called
185 * checkpoint step).
186 *
187 * It triggers the reading of checkpoints, the contact search,
188 * clearing the contact structures, the solid object mapping (if enabled), and
189 * the update of the sparse contacts cells (if enabled).
190 */
191 inline void
201
202 /**
203 * @brief Set triggers for actions to be performed in the current iteration
204 * because it is a load balancing step.
205 *
206 * It triggers:
207 * - load balancing: the used method has determined that the load needs to be
208 * balanced
209 * - contact search: cells and particles will not be on the same processor,
210 * so all the contact search needs to be performed.
211 * - clearing the tangential displacement: the tangential displacement history
212 * of the particles pairs (or particle-wall) are lost when particles are
213 * handled by another processor. For consistency reasons, all the tangential
214 * displacement history is reset for all particles.
215 * - resizing the containers: the containers need to be resized to the new
216 * number of local particles.
217 * - solid object search (if enabled): the solid objects need to be mapped to
218 * the rebalanced cells.
219 * - update the sparse contacts cells (if enabled): the sparse contacts cells
220 * need to be updated since they only
221 * contain local and ghost cells.
222 */
223 inline void
234
235 /**
236 * @brief Set trigger for the contact search to be performed in the current
237 * time step because of a particle insertion step.
238 *
239 * It triggers:
240 * - contact search: since there are new particles in the simulation, contact
241 * search needs to be performed for all particles.
242 */
243 inline void
248
249 /**
250 * @brief Set trigger for the contact search to be performed in the current
251 * time step because of a contact detection step.
252 *
253 * It triggers:
254 * - contact search: might be from a selected frequency for the contact search
255 * (frequent method) or from the displacement evaluation
256 * (dynamic)
257 */
258 inline void
263
264 /**
265 * @brief Set triggers for actions to be performed in the current time step
266 * because of a solid object search step.
267 *
268 * It triggers the solid object search and the contact search.
269 */
270 inline void
276
277 /**
278 * @brief Set trigger that the mobility status need to be reset to mobile at
279 * the first DEM time step if the sparse contacts are enabled.
280 *
281 * It trigger:
282 * - mobility status reset: all the mobility status of the cells need to be
283 * mobile since the velocity of the particles are
284 * not yet computed and the status can not be
285 * evaluated. In the case of CFD-DEM, we force the
286 * full computation of the particles at the first DEM
287 * time step since hydrodynamic forces, which have
288 * just been calculated, may change the behavior of
289 * particles.
290 */
291 inline void
293 {
294 // Only triggered if the sparse contacts are enabled
296 }
297
298 /**
299 * @brief Set trigger for the contact search to be performed at the last DEM
300 * iteration of the CFD iteration.
301 *
302 * It triggers:
303 * - contact search: the contact search is performed in order to call the
304 * sorting of particles in cells and for the update of the
305 * particle reference locations prior of the void fraction
306 * calculation.
307 */
308 inline void
313
314 /**
315 * @brief Check if checkpoint needs to be read.
316 */
317 inline bool
322
323 /**
324 * @brief Check if the repartitioning (load balancing) needs to be performed.
325 */
326 inline bool
328 {
330 }
331
332 /**
333 * @brief Check if the contact search needs to be performed.
334 */
335 inline bool
340
341 /**
342 * @brief Check if the sparse contacts cells need to be updated.
343 */
344 inline bool
349
350 /**
351 * @brief Check if the solid object has to be searched.
352 */
353 inline bool
358
359 /**
360 * @brief Check if the tangential displacement history needs to be cleared.
361 */
362 inline bool
367
368 /**
369 * @brief Check if the containers need to be resized.
370 */
371 inline bool
376
377 /**
378 * @brief Check if the mobility status need to be reset to mobile.
379 */
380 inline bool
385
386 /**
387 * @brief Check if the default broad search functions should be used. It
388 * depends if adaptive sparse contacts is enabled, if so, it is a step where
389 * the mobility status are reset.
390 */
391 inline bool
396
397private:
398 /**
399 * @brief Constructor of the DEMActionManager.
400 */
415
416 /**
417 * @brief Pointer to the unique of the DEMActionManager.
418 */
420
421 /**
422 * @brief Flag for periodic boundaries in the simulation.
423 */
425
426 /**
427 * @brief Flag for solid objects in the simulation.
428 */
430
431 /**
432 * @brief Flag for the enabling of the sparse contacts.
433 */
435
436 /**
437 * @brief Flag for motion of grid in the simulation.
438 */
440
441 /**
442 * @brief Flag of the trigger for reading the checkpoint.
443 */
445
446 /**
447 * @brief Flag of the trigger for load balancing execution.
448 */
450
451 /**
452 * @brief Flag of the trigger for clearing the tangential displacement history.
453 */
455
456 /**
457 * @brief Flag of the trigger for resize the vector dependant of the local
458 * particles.
459 */
461
462 /**
463 * @brief Flag of the trigger for the contact search.
464 */
466
467 /**
468 * @brief Flag of the trigger for the solid object search, mapping the solid
469 * with the background triangulation.
470 */
472
473 /**
474 * @brief Flag of the trigger for the update of the sparse contacts cells.
475 */
477
478 /**
479 * @brief Flag of the trigger for the mobility status reset to mobile status.
480 */
482};
483#endif
bool check_load_balance() const
Check if the repartitioning (load balancing) needs to be performed.
bool solid_object_search_trigger
Flag of the trigger for the solid object search, mapping the solid with the background triangulation.
void last_dem_of_cfddem_iteration_step()
Set trigger for the contact search to be performed at the last DEM iteration of the CFD iteration.
bool periodic_boundaries_enabled
Flag for periodic boundaries in the simulation.
bool check_resize_containers()
Check if the containers need to be resized.
bool use_default_broad_search_functions()
Check if the default broad search functions should be used. It depends if adaptive sparse contacts is...
bool check_sparse_contacts_enabled()
Check if the sparse contacts is enabled to perform some actions that are not handled by triggers of t...
bool grid_motion_enabled
Flag for motion of grid in the simulation.
bool check_contact_search()
Check if the contact search needs to be performed.
bool check_clear_tangential_displacement()
Check if the tangential displacement history needs to be cleared.
bool check_solid_objects_enabled()
Check if the solid objects are enabled to perform some actions that are not handled by triggers of th...
bool load_balance_trigger
Flag of the trigger for load balancing execution.
bool mobility_status_reset_trigger
Flag of the trigger for the mobility status reset to mobile status.
void first_dem_of_cfddem_iteration_step()
Set trigger that the mobility status need to be reset to mobile at the first DEM time step if the spa...
void set_sparse_contacts_disabled()
Disables the ASC.
bool sparse_contacts_enabled
Flag for the enabling of the sparse contacts.
bool check_grid_motion_enabled()
Check if the solid objects are enabled to perform some actions that are not handled by triggers of th...
bool check_periodic_boundaries_enabled()
Check if the periodic boundaries are enabled to perform some actions that are not handled by triggers...
void particle_insertion_step()
Set trigger for the contact search to be performed in the current time step because of a particle ins...
static DEMActionManager * get_action_manager()
Getter of the unique instance of the DEMActionManager.
DEMActionManager(const DEMActionManager &copy)=delete
Copy constructor as a delete function to make sure it can not be copied. It will never be used.
void reset_triggers()
Reset all triggers to false. TODO: modify the handling of the contact search at counter = 1 because o...
void contact_detection_step()
Set trigger for the contact search to be performed in the current time step because of a contact dete...
void load_balance_step()
Set triggers for actions to be performed in the current iteration because it is a load balancing step...
bool check_restart_simulation()
Check if checkpoint needs to be read.
void set_solid_objects_enabled()
Flag that there are solid objects in the simulation. Already trigger a solid object search in the bac...
bool resize_containers_trigger
Flag of the trigger for resize the vector dependant of the local particles.
bool sparse_contacts_cells_update_trigger
Flag of the trigger for the update of the sparse contacts cells.
void set_sparse_contacts_enabled()
Flag that the ASC is enabled and trigger a mobility status reset to initialize the containers.
void set_grid_motion_enabled()
Flag that the grid will motion in the simulation.
void set_periodic_boundaries_enabled()
Flag that there are periodic boundary in the simulation.
static DEMActionManager * instance
Pointer to the unique of the DEMActionManager.
void solid_objects_search_step()
Set triggers for actions to be performed in the current time step because of a solid object search st...
void restart_simulation()
Set triggers for actions to be performed in the current time step because the simulation starts from ...
bool read_checkpoint_trigger
Flag of the trigger for reading the checkpoint.
bool solid_objects_enabled
Flag for solid objects in the simulation.
DEMActionManager & operator=(const DEMActionManager &copy)=delete
Copy constructor as a delete function to make sure it can not be assigned. It will never be used.
bool contact_search_trigger
Flag of the trigger for the contact search.
bool clear_tangential_displacement_trigger
Flag of the trigger for clearing the tangential displacement history.
bool check_update_sparse_contacts_cells()
Check if the sparse contacts cells need to be updated.
DEMActionManager()
Constructor of the DEMActionManager.
bool check_mobility_status_reset()
Check if the mobility status need to be reset to mobile.
bool check_solid_object_search()
Check if the solid object has to be searched.