Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
solid_objects_parameters.h
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
4/**
5 * @file solid_objects_parameters.h
6 * @brief Parameter classes for solid objects used in Nitsche immersed boundary
7 * and DEM simulations.
8 *
9 * This file defines the parameter structures for configuring solid objects
10 * within Lethe simulations. It provides three levels of solid object
11 * management:
12 * - NitscheObject: individual solid for the Nitsche immersed boundary method.
13 * - Nitsche: container managing multiple NitscheObject instances.
14 * - RigidSolidObject: individual rigid solid for DEM simulations.
15 * - DEMSolidObjects: container managing multiple RigidSolidObject instances
16 * as surfaces and volumes.
17 */
18
19#ifndef lethe_solid_objects_parameters_h
20#define lethe_solid_objects_parameters_h
21
22#include <core/parameters.h>
23#include <core/utilities.h>
24
25#include <deal.II/base/parameter_handler.h>
26#include <deal.II/base/parsed_function.h>
27
28using namespace dealii;
29
30namespace Parameters
31{
32 /**
33 * @brief Thermal boundary condition type applied on a solid object surface.
34 */
36 {
37 /// No heat flux through the solid boundary.
39 /// Fixed temperature imposed on the solid boundary.
41 };
42
43 /**
44 * @brief Parameters for a single solid object used with the Nitsche immersed
45 * boundary method.
46 *
47 * This class stores all the parameters needed to define and control an
48 * individual Nitsche solid, including its mesh, velocity, temperature,
49 * penalization coefficients, particle motion settings, and force/torque
50 * calculation options.
51 *
52 * @tparam dim Number of spatial dimensions.
53 */
54 template <int dim, int spacedim = dim>
56 {
57 public:
59 : solid_velocity(spacedim)
60 {}
61
62 /**
63 * @brief Declare the parameters in the parameter handler.
64 *
65 * @param[in,out] prm The parameter handler object.
66 * @param[in] id Index of the solid object.
67 */
68 void
69 declare_parameters(ParameterHandler &prm, unsigned int id);
70
71 /**
72 * @brief Parse the parameters from the parameter handler.
73 *
74 * @param[in] prm The parameter handler object.
75 * @param[in] id Index of the solid object.
76 */
77 void
78 parse_parameters(ParameterHandler &prm, unsigned int id);
79
80 /// Mesh parameters for the solid object.
82
83 /// Number of quadrature points per 1D cell used to represent the solid.
85
86 /// Velocity function imposed on the solid.
87 Functions::ParsedFunction<spacedim> solid_velocity;
88
89 /// Temperature function imposed on the solid boundary.
90 Functions::ParsedFunction<spacedim> solid_temperature;
91
92 /// Enable the motion of Nitsche particles.
94
95 /// Enable heat boundary condition on the immersed boundary.
97
98 /// Penalization parameter for the Nitsche method (momentum equation).
99 double beta;
100
101 /// Penalization parameter for the Nitsche method (heat equation).
102 double beta_heat;
103
104 /// Number of sub-iterations for particle motion integration.
106
107 /// Stop the simulation if Nitsche particles are lost.
109
110 /// Center of rotation used for torque calculation.
111 Point<spacedim> center_of_rotation;
112
113 /// Enable calculation of forces on the solid.
115
116 /// Enable calculation of torques on the solid.
118
119 /// File name prefix for the force output.
120 std::string force_output_name;
121
122 /// File name prefix for the torque output.
124 };
125
126 template <int dim, int spacedim>
127 void
129 unsigned int id)
130 {
131 prm.enter_subsection("nitsche solid " + Utilities::int_to_string(id, 1));
132 {
133 solid_mesh.declare_parameters(prm);
134
135 prm.enter_subsection("solid velocity");
136 solid_velocity.declare_parameters(prm, dim);
137 prm.leave_subsection();
138
139
140
141 prm.enter_subsection("solid temperature");
142 solid_temperature.declare_parameters(prm);
143 prm.leave_subsection();
144
145 prm.declare_entry("enable particles motion",
146 "false",
147 Patterns::Bool(),
148 "Condition on the motion of particles");
149 prm.declare_entry(
150 "enable heat boundary condition",
151 "false",
152 Patterns::Bool(),
153 "controls if a heat boundary condition is imposed on the Nitsche immersed boundary");
154
155 prm.declare_entry("beta",
156 "10",
157 Patterns::Double(),
158 "Penalization term for Nitsche method");
159 prm.declare_entry(
160 "beta heat",
161 "10",
162 Patterns::Double(),
163 "Penalization term for Nitsche method applied to the heat equation");
164
165 prm.declare_entry(
166 "particles sub iterations",
167 "1",
168 Patterns::Integer(),
169 "Number of sub iterations for the motion of the particles. This parameter"
170 "enables the uses of a higher CFL condition for the Nitsche solver while preventing the loss of particles");
171
172 prm.declare_entry(
173 "stop if particles lost",
174 "true",
175 Patterns::Bool(),
176 "Enable stopping the simulation if Nitsche particles have been lost");
177
178 prm.declare_entry(
179 "number quadrature points",
180 "2",
181 Patterns::Integer(),
182 "Number of Nitsche (quadrature) points to insert in a 1D cell. The number of"
183 "inserted points will be higher for higher dimensions. Increasing this"
184 "number will lead to a higher points density inside the solid.");
185
186 std::string default_rotation = (spacedim == 2) ? "0., 0." : "0., 0., 0.";
187 prm.declare_entry("center of rotation",
188 default_rotation,
189 Patterns::List(Patterns::Double()),
190 "Solid object center of rotation");
191
192
193 prm.declare_entry("calculate force on solid",
194 "false",
195 Patterns::Bool(),
196 "Enable calculation of forces on solid");
197 prm.declare_entry("calculate torque on solid",
198 "false",
199 Patterns::Bool(),
200 "Enable calculation of torques on solid");
201 prm.declare_entry("solid force name",
202 "force_solid",
203 Patterns::FileName(),
204 "File output solid force prefix");
205 prm.declare_entry("solid torque name",
206 "torque_solid",
207 Patterns::FileName(),
208 "File output solid torque prefix");
209 }
210 prm.leave_subsection();
211 }
212
213 template <int dim, int spacedim>
214 void
216 unsigned int id)
217 {
218 prm.enter_subsection("nitsche solid " + Utilities::int_to_string(id, 1));
219 {
220 solid_mesh.parse_parameters(prm);
221 prm.enter_subsection("solid velocity");
222 solid_velocity.parse_parameters(prm);
223 prm.leave_subsection();
224
225 prm.enter_subsection("solid temperature");
226 solid_temperature.parse_parameters(prm);
227 prm.leave_subsection();
228
229 enable_particles_motion = prm.get_bool("enable particles motion");
230 enable_heat_bc = prm.get_bool("enable heat boundary condition");
231 beta = prm.get_double("beta");
232 beta_heat = prm.get_double("beta heat");
233 particles_sub_iterations = prm.get_integer("particles sub iterations");
234 stop_particles_lost = prm.get_bool("stop if particles lost");
235 number_quadrature_points = prm.get_integer("number quadrature points");
236
237 const std::vector<double> temp =
238 convert_string_to_vector<double>(prm, "center of rotation");
239
240 AssertThrow(temp.size() == spacedim,
241 ExcMessage("Invalid center of rotation. This should be a " +
242 Utilities::int_to_string(spacedim) +
243 " dimensional point."));
244
245 for (int i = 0; i < spacedim; ++i)
246 {
247 center_of_rotation[i] = temp.at(i);
248 }
249
250 calculate_force_on_solid = prm.get_bool("calculate force on solid");
251 calculate_torque_on_solid = prm.get_bool("calculate torque on solid");
252 force_output_name = prm.get("solid force name");
253 torque_output_name = prm.get("solid torque name");
254 }
255 prm.leave_subsection();
256 }
257
258 /**
259 * @brief Container class managing multiple Nitsche solid objects.
260 *
261 * This class holds a collection of NitscheObject instances and provides
262 * parameter declaration and parsing for the Nitsche immersed boundary method
263 * section of the parameter file.
264 *
265 * @tparam dim Number of spatial dimensions.
266 */
267 template <int dim>
269 {
270 public:
271 Nitsche() = default;
272
273 /**
274 * @brief Declare the parameters in the parameter handler.
275 *
276 * @param[in,out] prm The parameter handler object.
277 */
278 void
279 declare_parameters(ParameterHandler &prm);
280
281 /**
282 * @brief Parse the parameters from the parameter handler.
283 *
284 * @param[in] prm The parameter handler object.
285 */
286 void
287 parse_parameters(ParameterHandler &prm);
288
289 /// Verbosity level for force/torque output.
291
292 /// Collection of Nitsche solid objects.
293 std::vector<std::shared_ptr<NitscheObject<dim>>> nitsche_solids;
294
295 /// Number of active Nitsche solid objects.
296 unsigned int number_solids;
297
298 /// Maximum number of Nitsche solid objects allowed.
299 static const unsigned int max_nitsche_solids = 10;
300 };
301
302 template <int dim>
303 void
304 Nitsche<dim>::declare_parameters(ParameterHandler &prm)
305 {
307
308 prm.enter_subsection("nitsche");
309 {
311 prm,
312 "verbosity",
314 "State whether the force on the solid should be printed.",
317
318 prm.declare_entry("number of solids",
319 "0",
320 Patterns::Integer(),
321 "Number of solid object");
322
323 for (unsigned int i_solid = 0; i_solid < max_nitsche_solids; ++i_solid)
324 {
325 nitsche_solids[i_solid] = std::make_shared<NitscheObject<dim>>();
326 nitsche_solids[i_solid]->declare_parameters(prm, i_solid);
327 }
328 }
329 prm.leave_subsection();
330 }
331
332 template <int dim>
333 void
334 Nitsche<dim>::parse_parameters(ParameterHandler &prm)
335 {
336 prm.enter_subsection("nitsche");
337 {
338 verbosity = string_to_enum<Verbosity>(prm.get("verbosity"),
340 "verbosity");
341
342 number_solids = prm.get_integer("number of solids");
344
345 for (unsigned int i_solid = 0; i_solid < number_solids; ++i_solid)
346 nitsche_solids[i_solid]->parse_parameters(prm, i_solid);
347 }
348 prm.leave_subsection();
349 }
350
351
352 /**
353 * @brief Parameters for a single rigid solid object used in DEM simulations.
354 *
355 * This class stores the mesh, motion, temperature, and output parameters for
356 * a rigid solid. The velocity fields are stored as
357 * std::shared_ptr<Function<dim>> so that any function type can be used
358 * (e.g., ParsedFunction for parameter-file input or ConstantFunction for
359 * unit tests).
360 *
361 * @tparam dim Number of spatial dimensions.
362 */
363 template <int dim, int spacedim = dim>
365 {
366 public:
367 RigidSolidObject() = default;
368
369 /**
370 * @brief Declare the parameters in the parameter handler.
371 *
372 * @param[in,out] prm The parameter handler object.
373 * @param[in] id Index of the solid object.
374 */
375 void
376 declare_parameters(ParameterHandler &prm, unsigned int id);
377
378 /**
379 * @brief Parse the parameters from the parameter handler.
380 *
381 * @param[in] prm The parameter handler object.
382 * @param[in] id Index of the solid object.
383 */
384 void
385 parse_parameters(ParameterHandler &prm, unsigned int id);
386
387 /// Mesh parameters for the solid object.
389
390 /// Controls the generation of output files for this solid.
392
393 /// Translational velocity function of the solid object.
394 std::shared_ptr<Function<spacedim>> translational_velocity;
395
396 /// Angular velocity function of the solid object.
397 std::shared_ptr<Function<spacedim>> angular_velocity;
398
399 /// Center of rotation used to locate and rotate the solid object.
400 Point<spacedim> center_of_rotation;
401
402 /// Temperature function for the solid object boundary.
403 std::shared_ptr<Function<spacedim>> solid_temperature;
404
405 /// Type of thermal boundary condition applied on the solid surface.
407 };
408
409
410 template <int dim, int spacedim>
411 void
413 unsigned int id)
414 {
415 // Use ParsedFunction<dim> during parameter declaration. We need to do this
416 // to use the declare_parameters function, which is not possible with
417 // std::make_shared<Function<dim>> type. Please refer to the comment before
418 // the translational_velocity and angular_velocity attributes declaration.
419 auto translational_velocity_parsed =
420 std::make_shared<Functions::ParsedFunction<spacedim>>(spacedim);
421 auto angular_velocity_parsed =
422 std::make_shared<Functions::ParsedFunction<spacedim>>(spacedim);
423 auto solid_temperature_parsed =
424 std::make_shared<Functions::ParsedFunction<spacedim>>(1);
425
426 prm.enter_subsection("solid object " + Utilities::int_to_string(id, 1));
427 {
428 solid_mesh.declare_parameters(prm);
429
430 prm.enter_subsection("translational velocity");
431 translational_velocity_parsed->declare_parameters(prm, spacedim);
432 prm.leave_subsection();
433
434 prm.enter_subsection("angular velocity");
435 angular_velocity_parsed->declare_parameters(prm, 3);
436 prm.leave_subsection();
437
438 std::string default_rotation = (spacedim == 2) ? "0., 0." : "0., 0., 0.";
439 prm.declare_entry("center of rotation",
440 default_rotation,
441 Patterns::List(Patterns::Double()),
442 "Solid object center of rotation");
443
445 "thermal boundary type",
447 "Choosing thermal boundary type.");
448
449 // Isothermal boundary
450 prm.enter_subsection("temperature");
451 solid_temperature_parsed->declare_parameters(prm, 1);
452 prm.leave_subsection();
453
454 prm.declare_entry("output solid object",
455 "true",
456 Patterns::Bool(),
457 "Controls the generation of output files");
458 }
459 prm.leave_subsection();
460
461 // Cast to std::shared_ptr<Function<dim>> after parameter declaration.
462 translational_velocity = translational_velocity_parsed;
463 angular_velocity = angular_velocity_parsed;
464 solid_temperature = solid_temperature_parsed;
465 }
466
467 template <int dim, int spacedim>
468 void
470 unsigned int id)
471 {
472 // Use ParsedFunction<dim> during parameter declaration. We need to do this
473 // to use the parse_parameters function, which is not possible with
474 // std::make_shared<Function<dim>> type. Please refer to the comment before
475 // the translational_velocity and angular_velocity attributes declaration.
476 auto translational_velocity_parsed =
477 std::make_shared<Functions::ParsedFunction<spacedim>>(spacedim);
478 auto angular_velocity_parsed =
479 std::make_shared<Functions::ParsedFunction<spacedim>>(spacedim);
480 auto solid_temperature_parsed =
481 std::make_shared<Functions::ParsedFunction<spacedim>>(1);
482
483 prm.enter_subsection("solid object " + Utilities::int_to_string(id, 1));
484 {
485 solid_mesh.parse_parameters(prm);
486 prm.enter_subsection("translational velocity");
487 translational_velocity_parsed->parse_parameters(prm);
488 prm.leave_subsection();
489
490 prm.enter_subsection("angular velocity");
491 angular_velocity_parsed->parse_parameters(prm);
492 prm.leave_subsection();
493
494 const std::vector<double> temp =
495 convert_string_to_vector<double>(prm, "center of rotation");
496
497 AssertThrow(temp.size() == spacedim,
498 ExcMessage("Invalid center of rotation. This should be a " +
499 Utilities::int_to_string(spacedim) +
500 " dimensional point."));
501
502 for (int i = 0; i < spacedim; ++i)
503 {
504 center_of_rotation[i] = temp.at(i);
505 }
506
507 output_bool = prm.get_bool("output solid object");
508
510 prm.get("thermal boundary type"));
511
512 // Isothermal boundary
513 prm.enter_subsection("temperature");
514 solid_temperature_parsed->parse_parameters(prm);
515 prm.leave_subsection();
516 }
517 prm.leave_subsection();
518 translational_velocity = translational_velocity_parsed;
519 angular_velocity = angular_velocity_parsed;
520 solid_temperature = solid_temperature_parsed;
521 }
522
523
524 /**
525 * @brief Container class managing rigid solid objects for DEM simulations.
526 *
527 * This class holds two collections of RigidSolidObject instances:
528 * solid surfaces (2D boundaries) and solid volumes (3D bodies). It provides
529 * parameter declaration and parsing for the "solid objects" section of the
530 * parameter file.
531 *
532 * @tparam dim Number of spatial dimensions.
533 */
534 template <int dim>
536 {
537 public:
538 DEMSolidObjects() = default;
539
540 /**
541 * @brief Declare the parameters in the parameter handler.
542 *
543 * @param[in,out] prm The parameter handler object.
544 */
545 void
546 declare_parameters(ParameterHandler &prm);
547
548 /**
549 * @brief Parse the parameters from the parameter handler.
550 *
551 * @param[in] prm The parameter handler object.
552 */
553 void
554 parse_parameters(ParameterHandler &prm);
555
556 /// Verbosity level for force/torque output.
558
559 /// Collection of rigid solid surface objects.
560 std::vector<std::shared_ptr<RigidSolidObject<dim - 1, dim>>> solid_surfaces;
561
562 /// Collection of rigid solid volume objects.
563 std::vector<std::shared_ptr<RigidSolidObject<dim, dim>>> solid_volumes;
564
565 /// Number of active solid surface objects.
567
568 /// Number of active solid volume objects.
570
571 /// Maximum number of solid objects allowed.
572 static const unsigned int max_number_of_solids = 50;
573 };
574
575 template <int dim>
576 void
578 {
583
584 prm.enter_subsection("solid objects");
585 {
586 prm.enter_subsection("solid surfaces");
587 {
588 prm.declare_entry("number of solids",
589 "0",
590 Patterns::Integer(),
591 "Number of solid surfaces");
592
593 for (unsigned int i_solid = 0; i_solid < max_number_of_solids;
594 ++i_solid)
595 {
596 solid_surfaces[i_solid] =
597 std::make_shared<RigidSolidObject<dim - 1, dim>>();
598 solid_surfaces[i_solid]->declare_parameters(prm, i_solid);
599 }
600 }
601 prm.leave_subsection();
602
603 prm.enter_subsection("solid volumes");
604 {
605 prm.declare_entry("number of solids",
606 "0",
607 Patterns::Integer(),
608 "Number of solid volumes");
609
610 for (unsigned int i_solid = 0; i_solid < max_number_of_solids;
611 ++i_solid)
612 {
613 solid_volumes[i_solid] =
614 std::make_shared<RigidSolidObject<dim, dim>>();
615 solid_volumes[i_solid]->declare_parameters(prm, i_solid);
616 }
617 }
618 prm.leave_subsection();
619 }
620 prm.leave_subsection();
621 }
622
623 template <int dim>
624 void
626 {
627 prm.enter_subsection("solid objects");
628 {
629 prm.enter_subsection("solid surfaces");
630 {
631 number_solid_surfaces = prm.get_integer("number of solids");
632 for (unsigned int i_solid = 0; i_solid < number_solid_surfaces;
633 ++i_solid)
634 {
635 solid_surfaces[i_solid]->parse_parameters(prm, i_solid);
636 }
637 }
638 prm.leave_subsection();
639
640 prm.enter_subsection("solid volumes");
641 {
642 number_solid_volumes = prm.get_integer("number of solids");
643 for (unsigned int i_solid = 0; i_solid < number_solid_volumes;
644 ++i_solid)
645 {
646 solid_volumes[i_solid]->parse_parameters(prm, i_solid);
647 }
648 }
649 prm.leave_subsection();
650 }
651 prm.leave_subsection();
652 }
653} // namespace Parameters
654
655#endif
void declare_parameters(ParameterHandler &prm)
Declare the parameters in the parameter handler.
unsigned int number_solid_volumes
Number of active solid volume objects.
unsigned int number_solid_surfaces
Number of active solid surface objects.
std::vector< std::shared_ptr< RigidSolidObject< dim - 1, dim > > > solid_surfaces
Collection of rigid solid surface objects.
std::vector< std::shared_ptr< RigidSolidObject< dim, dim > > > solid_volumes
Collection of rigid solid volume objects.
Verbosity verbosity
Verbosity level for force/torque output.
static const unsigned int max_number_of_solids
Maximum number of solid objects allowed.
void parse_parameters(ParameterHandler &prm)
Parse the parameters from the parameter handler.
Mesh - Parameters that control mesh reading and mesh generation.
double beta_heat
Penalization parameter for the Nitsche method (heat equation).
void declare_parameters(ParameterHandler &prm, unsigned int id)
Declare the parameters in the parameter handler.
Parameters::Mesh< dim, spacedim > solid_mesh
Mesh parameters for the solid object.
bool calculate_force_on_solid
Enable calculation of forces on the solid.
bool stop_particles_lost
Stop the simulation if Nitsche particles are lost.
bool enable_particles_motion
Enable the motion of Nitsche particles.
bool calculate_torque_on_solid
Enable calculation of torques on the solid.
double beta
Penalization parameter for the Nitsche method (momentum equation).
bool enable_heat_bc
Enable heat boundary condition on the immersed boundary.
unsigned int number_quadrature_points
Number of quadrature points per 1D cell used to represent the solid.
std::string torque_output_name
File name prefix for the torque output.
Functions::ParsedFunction< spacedim > solid_temperature
Temperature function imposed on the solid boundary.
unsigned int particles_sub_iterations
Number of sub-iterations for particle motion integration.
std::string force_output_name
File name prefix for the force output.
Point< spacedim > center_of_rotation
Center of rotation used for torque calculation.
void parse_parameters(ParameterHandler &prm, unsigned int id)
Parse the parameters from the parameter handler.
Functions::ParsedFunction< spacedim > solid_velocity
Velocity function imposed on the solid.
void parse_parameters(ParameterHandler &prm)
Parse the parameters from the parameter handler.
unsigned int number_solids
Number of active Nitsche solid objects.
Verbosity verbosity
Verbosity level for force/torque output.
static const unsigned int max_nitsche_solids
Maximum number of Nitsche solid objects allowed.
void declare_parameters(ParameterHandler &prm)
Declare the parameters in the parameter handler.
std::vector< std::shared_ptr< NitscheObject< dim > > > nitsche_solids
Collection of Nitsche solid objects.
Parameters for a single rigid solid object used in DEM simulations.
Point< spacedim > center_of_rotation
Center of rotation used to locate and rotate the solid object.
bool output_bool
Controls the generation of output files for this solid.
SolidObjectThermalBoundaryType thermal_boundary_type
Type of thermal boundary condition applied on the solid surface.
std::shared_ptr< Function< spacedim > > solid_temperature
Temperature function for the solid object boundary.
Parameters::Mesh< dim, spacedim > solid_mesh
Mesh parameters for the solid object.
std::shared_ptr< Function< spacedim > > angular_velocity
Angular velocity function of the solid object.
void declare_parameters(ParameterHandler &prm, unsigned int id)
Declare the parameters in the parameter handler.
void parse_parameters(ParameterHandler &prm, unsigned int id)
Parse the parameters from the parameter handler.
std::shared_ptr< Function< spacedim > > translational_velocity
Translational velocity function of the solid object.
std::vector< T > convert_string_to_vector(const ParameterHandler &prm, const std::string &entry_string)
Return the vector of size N of entry @entry_string. If the entry is specified in the ....
Definition utilities.h:1330
EnumType string_to_enum(const std::string &name)
Return the enumerator whose identifier is name, e.g. to parse the value of a parameter entry into its...
Definition utilities.h:734
void declare_enum_entry(ParameterHandler &prm, const std::string &entry_name, const EnumType default_value, const std::string &description, const DeprecatedEnumNames< EnumType > &deprecated_names={}, const std::vector< EnumType > &allowed_values={})
Declare a parameter entry whose value is an enumerator. The default value, the accepted values and th...
Definition utilities.h:888
const std::vector< Verbosity > & quiet_or_verbose()
Return the verbosity levels accepted by the parameters which do not support Verbosity::extra_verbose.
SolidObjectThermalBoundaryType
Thermal boundary condition type applied on a solid object surface.
@ isothermal
Fixed temperature imposed on the solid boundary.
@ adiabatic
No heat flux through the solid boundary.
const DeprecatedEnumNames< Verbosity > & deprecated_verbosity_names()
Return the deprecated strings of the parameters parsed into a Verbosity, which remain accepted in par...