Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
solid_base.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#ifndef lethe_solid_base_h
5#define lethe_solid_base_h
6
7#include <core/parameters.h>
9#include <core/vector.h>
10
11#include <deal.II/base/function.h>
12
13#include <deal.II/distributed/tria_base.h>
14
15#include <deal.II/dofs/dof_handler.h>
16
17#include <deal.II/fe/mapping_fe.h>
18
19#include <deal.II/lac/trilinos_vector.h>
20
21#include <deal.II/particles/particle_handler.h>
22
23using namespace dealii;
24
25/**
26 * A base class that generates a particle handler for the solid
27 *
28 * @tparam dim An integer that denotes the dimension of the space in which
29 * the flow is solved
30 * @tparam spacedim An integer that denotes the dimension of the space occupied
31 * by the embedded solid
32 *
33 * @author Carole-Anne Daunais, Valerie Bibeau, 2020
34 */
35
36template <int dim, int spacedim = dim>
38{
39public:
40 // Member functions
43 const std::shared_ptr<parallel::DistributedTriangulationBase<spacedim>>
45 const std::shared_ptr<Mapping<spacedim>> &fluid_mapping);
46
47 /**
48 * @brief Manages solid triangulation and particles setup
49 */
50 void
52
53 /**
54 * @brief Generates a solid triangulation from a dealii or gmsh mesh
55 */
56 void
57 setup_triangulation(const bool restart);
58
59 /**
60 * @brief Sets-up particles with particle handler, in the fluid triangulation domain that holds the particles of the solid
61 * according to a specific quadrature
62 */
63 void
65
66 /**
67 * @brief Creates a particle handler in the fluid triangulation domain
68 */
69 void
71
72 /**
73 * @brief Sets-up particles with particle handler, in the fluid triangulation domain that holds the particles of the solid
74 * according to a specific quadrature
75 */
76 void
78
79 /**
80 * @brief Loads a solid triangulation from a restart file
81 */
82 void
83 load_triangulation(const std::string &filename_tria);
84
85 /**
86 * @brief Loads a particle handler in the fluid triangulation domain that holds the particles of the solid
87 * according to a specific quadrature, and sets up dofs
88 */
89 void
90 load_particles(const std::string &filename_part);
91
92 /**
93 * @return the reference to the std::shared_ptr of a Particles::ParticleHandler<spacedim> that contains the solid particle handler
94 */
95 std::shared_ptr<Particles::ParticleHandler<spacedim>> &
97
98 /**
99 * @return shared_ptr of the solid triangulation
100 */
101 std::shared_ptr<parallel::DistributedTriangulationBase<dim, spacedim>>
103
104 /**
105 * @return the reference to the solid dof handler
106 */
107 DoFHandler<dim, spacedim> &
109
110 /**
111 * @return the reference to the displacement dof handler
112 */
113 DoFHandler<dim, spacedim> &
115
116 /**
117 * @return the reference to the displacement vector
118 */
121
122 /**
123 * @return Function<spacedim> of the solid velocity
124 */
125 Function<spacedim> *
127
128 Function<spacedim> *
130
131 /**
132 * @brief Updates particle positions in solid_particle_handler by integrating velocity using an explicit Runge-Kutta 4 method.
133 *
134 * @param time_step The time_step value for this iteration
135 *
136 * @param initial_time The initial time (time t) of the timestep. This is used to
137 * set the time of the velocity function.
138 */
139 void
140 integrate_velocity(double time_step, double initial_time);
141
142 /**
143 * @brief Moves the vertices of the solid triangulation. This function
144 * uses an Runge-Kutta 4 explicit time integrator to displace the vertices
145 * of the solid triangulation and stores the displacement in an array
146 * in order to allow correct checkpointing of the triangulation.
147 * See
148 https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods
149 for more details
150 *
151 * @param time_step The time_step value for this iteration
152 *
153 * @param initial_time The initial time (time t) of the timestep. This is used to
154 * set the time of the velocity function.
155 */
156 void
157 move_solid_triangulation(double time_step, double initial_time);
158
159 /**
160 * @brief Moves the dofs of the solid_triangulation by using the displacement vector.
161 * This is only use to move the solid triangulation at the correct location
162 * when the simulation is restarted.
163 */
164 void
166
167 /**
168 * @brief prints the positions of the particles
169 */
170 void
172
173 /**
174 * @brief Rotates the grid by a given angle around an axis
175 *
176 * @param angle The angle (in rad) with which the grid is rotated
177 *
178 * @param axis The axis over which the grid is rotated.
179 *
180 */
181 void
182 rotate_grid(const double angle, const Tensor<1, spacedim> &axis);
183
184 /**
185 * @brief Translate the grid. In spacedim=2, the third component is ignore
186 *
187 * @param translate The vector with which the solid is translated.
188 */
189 void
190 translate_grid(const Tensor<1, spacedim> &translate);
191
192 /**
193 * @brief Updates the time in the function used to describe the solid temperature
194 */
195 void
196 update_temperature_time(double time);
197
198 /**
199 * @brief read solid base triangulation checkpoint
200 */
201 void
202 read_checkpoint(const std::string &prefix_name);
203
204 /**
205 * @brief write solid base triangulation checkpoint
206 */
207 void
208 write_checkpoint(const std::string &prefix_name);
209
210
211private:
214 // Member variables
216 const unsigned int n_mpi_processes;
217 const unsigned int this_mpi_process;
218
219 std::shared_ptr<parallel::DistributedTriangulationBase<dim, spacedim>>
221 std::shared_ptr<parallel::DistributedTriangulationBase<spacedim>> fluid_tria;
222 DoFHandler<dim, spacedim> solid_dh;
223 std::shared_ptr<Particles::ParticleHandler<spacedim>> solid_particle_handler;
224
225 std::shared_ptr<FiniteElement<dim, spacedim>> fe;
226
227 std::shared_ptr<Mapping<dim, spacedim>> solid_mapping;
228 std::shared_ptr<Mapping<spacedim>> fluid_mapping;
229 std::shared_ptr<Quadrature<dim>> quadrature;
230
231
232 DoFHandler<dim, spacedim> displacement_dh;
233 std::shared_ptr<FESystem<dim, spacedim>> displacement_fe;
236
237
238 std::shared_ptr<Parameters::NitscheObject<spacedim>> &param;
239
240 Function<spacedim> *velocity;
241 Function<spacedim> *temperature;
242
244};
245
246#endif
Parameters for a single solid object used with the Nitsche immersed boundary method.
std::shared_ptr< Particles::ParticleHandler< spacedim > > & get_solid_particle_handler()
DoFHandler< dim, spacedim > solid_dh
Definition solid_base.h:222
DoFHandler< dim, spacedim > & get_solid_dof_handler()
std::shared_ptr< parallel::DistributedTriangulationBase< dim, spacedim > > solid_tria
Definition solid_base.h:220
void load_particles(const std::string &filename_part)
Loads a particle handler in the fluid triangulation domain that holds the particles of the solid acco...
DoFHandler< dim, spacedim > & get_displacement_dof_handler()
void move_solid_triangulation(double time_step, double initial_time)
Moves the vertices of the solid triangulation. This function uses an Runge-Kutta 4 explicit time inte...
void translate_grid(const Tensor< 1, spacedim > &translate)
Translate the grid. In spacedim=2, the third component is ignore.
const unsigned int this_mpi_process
Definition solid_base.h:217
void update_temperature_time(double time)
Updates the time in the function used to describe the solid temperature.
void load_triangulation(const std::string &filename_tria)
Loads a solid triangulation from a restart file.
std::shared_ptr< Quadrature< dim > > quadrature
Definition solid_base.h:229
void setup_triangulation(const bool restart)
Generates a solid triangulation from a dealii or gmsh mesh.
const unsigned int n_mpi_processes
Definition solid_base.h:216
GlobalVectorType displacement
Definition solid_base.h:234
GlobalVectorType & get_displacement_vector()
std::shared_ptr< Mapping< spacedim > > fluid_mapping
Definition solid_base.h:228
Function< spacedim > * temperature
Definition solid_base.h:241
void initial_setup()
Manages solid triangulation and particles setup.
Definition solid_base.cc:97
std::shared_ptr< Particles::ParticleHandler< spacedim > > solid_particle_handler
Definition solid_base.h:223
std::shared_ptr< Parameters::NitscheObject< spacedim > > & param
Definition solid_base.h:238
void move_solid_triangulation_with_displacement()
Moves the dofs of the solid_triangulation by using the displacement vector. This is only use to move ...
DoFHandler< dim, spacedim > displacement_dh
Definition solid_base.h:232
std::shared_ptr< parallel::DistributedTriangulationBase< spacedim > > fluid_tria
Definition solid_base.h:221
SolidBase(std::shared_ptr< Parameters::NitscheObject< spacedim > > &param, const std::shared_ptr< parallel::DistributedTriangulationBase< spacedim > > &fluid_tria, const std::shared_ptr< Mapping< spacedim > > &fluid_mapping)
Definition solid_base.cc:38
GlobalVectorType displacement_relevant
Definition solid_base.h:235
IndexSet locally_owned_dofs
Definition solid_base.h:212
std::shared_ptr< parallel::DistributedTriangulationBase< dim, spacedim > > get_solid_triangulation()
Function< spacedim > * get_solid_velocity()
void read_checkpoint(const std::string &prefix_name)
read solid base triangulation checkpoint
void setup_displacement()
Sets-up particles with particle handler, in the fluid triangulation domain that holds the particles o...
std::shared_ptr< FiniteElement< dim, spacedim > > fe
Definition solid_base.h:225
MPI_Comm mpi_communicator
Definition solid_base.h:215
std::shared_ptr< Mapping< dim, spacedim > > solid_mapping
Definition solid_base.h:227
Function< spacedim > * get_solid_temperature()
IndexSet locally_relevant_dofs
Definition solid_base.h:213
std::shared_ptr< FESystem< dim, spacedim > > displacement_fe
Definition solid_base.h:233
void setup_particles()
Sets-up particles with particle handler, in the fluid triangulation domain that holds the particles o...
Function< spacedim > * velocity
Definition solid_base.h:240
void write_checkpoint(const std::string &prefix_name)
write solid base triangulation checkpoint
void setup_particles_handler()
Creates a particle handler in the fluid triangulation domain.
unsigned int initial_number_of_particles
Definition solid_base.h:243
void integrate_velocity(double time_step, double initial_time)
Updates particle positions in solid_particle_handler by integrating velocity using an explicit Runge-...
void print_particle_positions()
prints the positions of the particles
void rotate_grid(const double angle, const Tensor< 1, spacedim > &axis)
Rotates the grid by a given angle around an axis.
Parameter classes for solid objects used in Nitsche immersed boundary and DEM simulations.
dealii::TrilinosWrappers::MPI::Vector GlobalVectorType
Definition vector.h:17