Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
continuum_solid_dynamics.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2026 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
4/**
5 * @file continuum_solid_dynamics.h
6 * @brief Auxiliary physics for the solid phase of the Euler-Euler (two-fluid)
7 * model.
8 *
9 * The solid phase is treated as an interpenetrating continuum. Its unknowns
10 * are the solid velocity (dim components) and the solid volume fraction
11 * (1 component), discretized together in a single FESystem. The fluid phase
12 * is solved by the existing volume-averaged Navier-Stokes (VANS) solver.
13 *
14 * In this first version, the class only provides the infrastructure (degrees
15 * of freedom, solution vectors, output, mesh adaptation, checkpointing and
16 * registration in the MultiphysicsInterface). The governing equations are not
17 * assembled yet, so should_solve_auxiliary_physics() returns false.
18 */
19
20#ifndef lethe_continuum_solid_dynamics_h
21#define lethe_continuum_solid_dynamics_h
22
23#include <core/multiphysics.h>
24#include <core/output_struct.h>
25#include <core/parameters.h>
27#include <core/vector.h>
28
32
33#include <deal.II/base/exceptions.h>
34#include <deal.II/base/index_set.h>
35#include <deal.II/base/quadrature.h>
36#include <deal.II/base/timer.h>
37
38#include <deal.II/distributed/tria_base.h>
39
40#include <deal.II/dofs/dof_handler.h>
41
42#include <deal.II/fe/fe.h>
43#include <deal.II/fe/fe_values_extractors.h>
44#include <deal.II/fe/mapping.h>
45
46#include <deal.II/lac/affine_constraints.h>
47#include <deal.II/lac/trilinos_sparse_matrix.h>
48
49#include <deal.II/numerics/solution_transfer.h>
50
51#include <memory>
52#include <vector>
53
54/**
55 * @brief Exception thrown when the solid phase is enabled with a fluid
56 * dynamics solver that does not solve the volume-averaged Navier-Stokes
57 * equations.
58 */
60 ContinuumSolidDynamicsWithoutVANSError,
61 "The \"continuum solid dynamics\" physics (Euler-Euler model) is enabled, but the fluid "
62 "dynamics solver does not solve the volume-averaged Navier-Stokes (VANS) "
63 "equations. The solid phase can only be used with a VANS solver.");
64
65/**
66 * @brief Solid phase of the Euler-Euler model, solved as an auxiliary physics
67 * coupled to the VANS fluid dynamics solver.
68 *
69 * Component layout of the FESystem: components [0, dim) hold the solid
70 * velocity and component dim holds the solid volume fraction.
71 *
72 * @tparam dim Number of spatial dimensions.
73 */
74template <int dim>
75class ContinuumSolidDynamics : public AuxiliaryPhysics<dim, GlobalVectorType>
76{
77public:
78 /**
79 * @brief Constructor of the solid phase physics.
80 *
81 * @param[in] multiphysics_interface Multiphysics interface through which the
82 * solid phase exchanges fields with the other physics.
83 * @param[in] p_simulation_parameters Simulation parameters.
84 * @param[in] p_triangulation Distributed triangulation shared by all physics.
85 * @param[in] p_simulation_control Simulation control (time stepping).
86 */
88 MultiphysicsInterface<dim> *multiphysics_interface,
89 const SimulationParameters<dim> &p_simulation_parameters,
90 const std::shared_ptr<parallel::DistributedTriangulationBase<dim>>
91 &p_triangulation,
92 const std::shared_ptr<SimulationControl> &p_simulation_control);
93
94 /**
95 * @brief Gather the solid velocity and solid volume fraction for output.
96 *
97 * @return Vector of output structures holding the solid phase solution.
98 */
99 std::vector<OutputStruct<dim, GlobalVectorType>>
100 gather_output_hook() override;
101
102 /**
103 * @brief Finish the simulation (print timers).
104 */
105 void
106 finish_simulation() override;
107
108 /**
109 * @brief Shift the solution history for the BDF time-stepping schemes.
110 */
111 void
112 percolate_time_vectors() override;
113
114 /**
115 * @brief Post-process the solid phase solution. Nothing is computed yet.
116 *
117 * @param[in] first_iteration Whether this is the first iteration.
118 */
119 void
120 postprocess(bool first_iteration) override;
121
122 /**
123 * @brief Print the timer summary at each iteration.
124 */
125 void
127
128 /**
129 * @brief Prepare the solution vectors for mesh refinement/coarsening.
130 */
131 void
132 pre_mesh_adaptation() override;
133
134 /**
135 * @brief Interpolate the solution vectors onto the adapted mesh.
136 */
137 void
138 post_mesh_adaptation() override;
139
140 /**
141 * @brief Compute the error estimate used for mesh adaptation. Not supported
142 * yet for the solid phase.
143 *
144 * @param[in] ivar Variable and adaptation parameters.
145 * @param[out] estimated_error_per_cell Estimated error per cell.
146 */
147 void
149 const std::pair<const Variable, Parameters::MultipleAdaptationParameters>
150 &ivar,
151 dealii::Vector<float> &estimated_error_per_cell) override;
152
153 /**
154 * @brief Serialize the present and previous solutions for restart.
155 */
156 void
157 write_checkpoint() override;
158
159 /**
160 * @brief Deserialize the present and previous solutions for restart.
161 */
162 void
163 read_checkpoint() override;
164
165 /**
166 * @brief Gather the post-processing tables to serialize. None yet.
167 *
168 * @return Empty vector of table handlers.
169 */
170 std::vector<OutputStructTableHandler>
171 gather_tables() override;
172
173 /**
174 * @brief Distribute the DoFs, allocate the vectors and matrix, and register
175 * the solid phase fields in the multiphysics interface.
176 */
177 void
178 setup_dofs() override;
179
180 /**
181 * @brief Set the initial conditions. Fields are set to zero for now.
182 */
183 void
184 set_initial_conditions() override;
185
186 /**
187 * @brief Solve the linear system. Not implemented yet.
188 */
189 void
190 solve_linear_system() override;
191
192 /**
193 * @brief Indicate whether the solid phase should be solved. Returns false
194 * until the governing equations are implemented.
195 *
196 * @return false.
197 */
198 bool
200 {
201 return false;
202 }
203
204 /**
205 * @brief Get the DoFHandler of the solid phase.
206 *
207 * @return Reference to the DoFHandler.
208 */
209 const DoFHandler<dim> &
211 {
212 return *dof_handler;
213 }
214
215 /**
216 * @brief Get the evaluation point.
217 *
218 * @return Reference to the evaluation point vector.
219 */
222 {
223 return evaluation_point;
224 }
225
226 /**
227 * @brief Get the local (non-ghosted) evaluation point.
228 *
229 * @return Reference to the local evaluation point vector.
230 */
233 {
235 }
236
237 /**
238 * @brief Get the Newton update.
239 *
240 * @return Reference to the Newton update vector.
241 */
244 {
245 return newton_update;
246 }
247
248 /**
249 * @brief Get the present solution.
250 *
251 * @return Reference to the present solution vector.
252 */
255 {
256 return *present_solution;
257 }
258
259 /**
260 * @brief Get the system right-hand side.
261 *
262 * @return Reference to the right-hand side vector.
263 */
265 get_system_rhs() override
266 {
267 return system_rhs;
268 }
269
270 /**
271 * @brief Get the non-zero constraints.
272 *
273 * @return Reference to the non-zero constraints.
274 */
275 AffineConstraints<double> &
277 {
278 return nonzero_constraints;
279 }
280
281 /**
282 * @brief Print the norms of the Newton update.
283 */
284 void
286
287 /**
288 * @brief Get the metric used to rescale the residual.
289 *
290 * @return Square root of the domain volume if residual rescaling is
291 * enabled, 1 otherwise.
292 */
293 double
294 get_residual_rescale_metric() const override;
295
296private:
297 /**
298 * @brief Assemble the system matrix. Not implemented yet.
299 */
300 void
301 assemble_system_matrix() override;
302
303 /**
304 * @brief Assemble the system right-hand side. Not implemented yet.
305 */
306 void
307 assemble_system_rhs() override;
308
309 /**
310 * @brief Define the constraints (hanging nodes only for now).
311 */
312 void
314
315 /// Multiphysics interface used to exchange fields with other physics
317
318 /// Timer of the solid phase physics
319 TimerOutput computing_timer;
320
321 /// Simulation parameters
323
324 /// Triangulation shared by all physics
325 std::shared_ptr<parallel::DistributedTriangulationBase<dim>> triangulation;
326
327 /// Simulation control
328 std::shared_ptr<SimulationControl> simulation_control;
329
330 /// DoFHandler of the solid phase
331 std::shared_ptr<DoFHandler<dim>> dof_handler;
332
333 /// FESystem: dim velocity components + 1 volume fraction component
334 std::shared_ptr<FiniteElement<dim>> fe;
335
336 /// Mapping, cell and face quadratures
337 std::shared_ptr<Mapping<dim>> mapping;
338 std::shared_ptr<Quadrature<dim>> cell_quadrature;
339 std::shared_ptr<Quadrature<dim - 1>> face_quadrature;
340
341 /// Extractors of the solid velocity and solid volume fraction
342 const FEValuesExtractors::Vector solid_velocity_extractor;
343 const FEValuesExtractors::Scalar solid_volume_fraction_extractor;
344
345 /// Locally owned and locally relevant DoFs
348
349 /// Solution and solver vectors
353 std::shared_ptr<GlobalVectorType> present_solution;
355 AffineConstraints<double> nonzero_constraints;
356 AffineConstraints<double> zero_constraints;
357 TrilinosWrappers::SparseMatrix system_matrix;
358
359 /// Previous solutions for the BDF time-stepping schemes
360 std::shared_ptr<std::vector<GlobalVectorType>> previous_solutions;
361
362 /// Solution transfer for mesh adaptation and checkpointing
363 std::shared_ptr<SolutionTransfer<dim, GlobalVectorType>> solution_transfer;
364 std::vector<SolutionTransfer<dim, GlobalVectorType>>
366};
367
368#endif
AuxiliaryPhysics(const Parameters::NonLinearSolver non_linear_solver_parameters)
std::shared_ptr< SimulationControl > simulation_control
Simulation control.
std::shared_ptr< SolutionTransfer< dim, GlobalVectorType > > solution_transfer
Solution transfer for mesh adaptation and checkpointing.
std::shared_ptr< DoFHandler< dim > > dof_handler
DoFHandler of the solid phase.
std::vector< SolutionTransfer< dim, GlobalVectorType > > previous_solutions_transfer
void compute_error_estimate(const std::pair< const Variable, Parameters::MultipleAdaptationParameters > &ivar, dealii::Vector< float > &estimated_error_per_cell) override
Compute the error estimate used for mesh adaptation. Not supported yet for the solid phase.
AffineConstraints< double > & get_nonzero_constraints() override
Get the non-zero constraints.
TimerOutput computing_timer
Timer of the solid phase physics.
void solve_linear_system() override
Solve the linear system. Not implemented yet.
GlobalVectorType & get_evaluation_point() override
Get the evaluation point.
void assemble_system_rhs() override
Assemble the system right-hand side. Not implemented yet.
GlobalVectorType & get_local_evaluation_point() override
Get the local (non-ghosted) evaluation point.
const SimulationParameters< dim > & simulation_parameters
Simulation parameters.
std::shared_ptr< FiniteElement< dim > > fe
FESystem: dim velocity components + 1 volume fraction component.
const DoFHandler< dim > & get_dof_handler() override
Get the DoFHandler of the solid phase.
TrilinosWrappers::SparseMatrix system_matrix
std::vector< OutputStructTableHandler > gather_tables() override
Gather the post-processing tables to serialize. None yet.
void pre_mesh_adaptation() override
Prepare the solution vectors for mesh refinement/coarsening.
std::vector< OutputStruct< dim, GlobalVectorType > > gather_output_hook() override
Gather the solid velocity and solid volume fraction for output.
ContinuumSolidDynamics(MultiphysicsInterface< dim > *multiphysics_interface, const SimulationParameters< dim > &p_simulation_parameters, const std::shared_ptr< parallel::DistributedTriangulationBase< dim > > &p_triangulation, const std::shared_ptr< SimulationControl > &p_simulation_control)
Constructor of the solid phase physics.
std::shared_ptr< parallel::DistributedTriangulationBase< dim > > triangulation
Triangulation shared by all physics.
void set_initial_conditions() override
Set the initial conditions. Fields are set to zero for now.
std::shared_ptr< std::vector< GlobalVectorType > > previous_solutions
Previous solutions for the BDF time-stepping schemes.
double get_residual_rescale_metric() const override
Get the metric used to rescale the residual.
void write_checkpoint() override
Serialize the present and previous solutions for restart.
void percolate_time_vectors() override
Shift the solution history for the BDF time-stepping schemes.
std::shared_ptr< Quadrature< dim - 1 > > face_quadrature
AffineConstraints< double > zero_constraints
void setup_dofs() override
Distribute the DoFs, allocate the vectors and matrix, and register the solid phase fields in the mult...
const FEValuesExtractors::Scalar solid_volume_fraction_extractor
void post_mesh_adaptation() override
Interpolate the solution vectors onto the adapted mesh.
std::shared_ptr< GlobalVectorType > present_solution
bool should_solve_auxiliary_physics() override
Indicate whether the solid phase should be solved. Returns false until the governing equations are im...
void read_checkpoint() override
Deserialize the present and previous solutions for restart.
IndexSet locally_owned_dofs
Locally owned and locally relevant DoFs.
std::shared_ptr< Quadrature< dim > > cell_quadrature
void finish_simulation() override
Finish the simulation (print timers).
const FEValuesExtractors::Vector solid_velocity_extractor
Extractors of the solid velocity and solid volume fraction.
GlobalVectorType & get_newton_update() override
Get the Newton update.
GlobalVectorType evaluation_point
Solution and solver vectors.
AffineConstraints< double > nonzero_constraints
void define_constraints()
Define the constraints (hanging nodes only for now).
GlobalVectorType & get_present_solution() override
Get the present solution.
std::shared_ptr< Mapping< dim > > mapping
Mapping, cell and face quadratures.
void postprocess(bool first_iteration) override
Post-process the solid phase solution. Nothing is computed yet.
void output_per_iteration_timer() override
Print the timer summary at each iteration.
void output_newton_update_norms() override
Print the norms of the Newton update.
GlobalVectorType & get_system_rhs() override
Get the system right-hand side.
MultiphysicsInterface< dim > * multiphysics
Multiphysics interface used to exchange fields with other physics.
void assemble_system_matrix() override
Assemble the system matrix. Not implemented yet.
DeclExceptionMsg(ContinuumSolidDynamicsWithoutVANSError, "The \"continuum solid dynamics\" physics (Euler-Euler model) is enabled, but the fluid " "dynamics solver does not solve the volume-averaged Navier-Stokes (VANS) " "equations. The solid phase can only be used with a VANS solver.")
Exception thrown when the solid phase is enabled with a fluid dynamics solver that does not solve the...
Identifiers for multiphysics modules and their solution fields.
Simulation control classes for managing time-stepping and iteration control in Lethe.
dealii::TrilinosWrappers::MPI::Vector GlobalVectorType
Definition vector.h:17