Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
auxiliary_physics.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2021-2026 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
4#ifndef lethe_auxiliary_physics_h
5#define lethe_auxiliary_physics_h
6
8#include <core/parameters.h>
10
12
13#include <deal.II/numerics/data_out.h>
14
15/**
16 * Au auxiliary physics is defined as a physics that is solved on top of
17 * a core physics, the latter being the Navier-Stokes equations.
18 * Auxiliary physics are simpler physics around which the entire simulation
19 * process does not need to be tailored. Examples of auxiliary physics are
20 * temperature and concentration. Generally, the auxiliary physics does not
21 * affect the core physics. For example, temperature is advected by the fluid
22 * flow, but buoyancy effects are not taken into account.
23 *
24 * The auxiliary physics are managed by the multiphysics interface of Lethe.
25 *
26 * This base class is used to establish all of the routines that an auxiliary
27 * physics must be able to provide to the Multiphysics interface. These elements
28 * are then called at specific moments of a simulation.
29 *
30 * Auxiliary physics are templated by the dimension of the problem and the
31 * vector type that is used to manage their data.
32 *
33 *
34 * Current limitations:
35 *
36 * - Auxiliary physics are currently expected to be used in conjunction with a
37 * flow solver which can provide a velocity field.
38 * - Support for feedback from the auxiliary physics to the core physics is
39 * there but presently not used anywhere
40 * - Support for interaction between auxiliary physics is supported but has not
41 * been tested
42 **/
43template <int dim, typename VectorType>
44class AuxiliaryPhysics : public PhysicsSolver<VectorType>
45{
46public:
47 /**
48 * @brief AuxiliaryPhysics - Base constructor for Auxiliary physics.
49 * This constructor builds an auxiliary physics which solves a non-linear
50 * problem. Consequently, the auxiliary physics must assemble its
51 * right-hand-side and matrix in the residual form. This means that the
52 * solution is reached when |R(u)|=0 where R is the residual vector and u the
53 * solution.
54 *
55 * @param[in] non_linear_solver_parameters Parameters for the non-linear
56 * solvers that drives the solution of the non-linear physics.
57 */
59 const Parameters::NonLinearSolver non_linear_solver_parameters)
60 : PhysicsSolver<VectorType>(non_linear_solver_parameters)
61 {}
62
63 /**
64 * @brief AuxiliaryPhysics - Base constructor for Auxiliary physics.
65 * This constructor builds an auxiliary physics which solves a linear
66 * problem. Consequently, the auxiliary physics must assemble its
67 * right-hand-side and matrix in the form Au=b.
68 */
72
73 /**
74 * @brief AuxiliaryPhysics - Base destructor. At the present
75 * moment this is an interface with nothing.
76 */
77 virtual ~AuxiliaryPhysics() = default;
78
79 /**
80 * @brief Gather and return vector of output structs that are particular to some applications.
81 *
82 * @return Vector of OutputStructs that will be used to write the output results as VTU files.
83 */
84 virtual std::vector<OutputStruct<dim, VectorType>>
86 {
87 return std::vector<OutputStruct<dim, VectorType>>();
88 };
89
90 /**
91 * @brief Carry out the operations required to finish a simulation correctly.
92 */
93 virtual void
95
96 /**
97 * @brief Carry out the operations required to rearrange the values of the
98 * previous solution at the end of a time step
99 */
100 virtual void
102
103 /**
104 * @brief Carry out modifications on the auxiliary physic solution.
105 * To be defined for some physics only (eg. free surface, see cls.h).
106 */
107 virtual void
109
110 /**
111 * @brief Update non zero constraints if the boundary is time-dependent
112 */
113 virtual void
115
116 /**
117 * @brief Provide the dof handler associated with an auxiliary physics
118 * TODO : delete as the auxiliary physics are supposed to pass their
119 * dof_handler to the multiphysics_interface directly
120 */
121 virtual const DoFHandler<dim> &
123
124 /**
125 * @brief Postprocess the auxiliary physics results. Post-processing this case implies
126 * the calculation of all derived quantities using the solution vector of the
127 * physics. It does not concern the output of the solution using the
128 * DataOutObject, which is accomplished through the attach_solution_to_output
129 * function
130 */
131 virtual void
132 postprocess(bool first_iteration) = 0;
133
134 /**
135 * @brief Output the per iteration wallclock times.
136 */
137 virtual void
139
140 /**
141 * @brief pre_mesh_adaption Prepares the auxiliary physics variables for a
142 * mesh refinement/coarsening
143 */
144 virtual void
146
147 /**
148 * @brief post_mesh_adaption Interpolates the auxiliary physics variables to the new mesh
149 */
150 virtual void
152
153 /**
154 * @brief Prepares auxiliary physics to write checkpoint
155 */
156 virtual void
158
159 /**
160 * @brief Set solution vector of Auxiliary Physics using checkpoint
161 */
162 virtual void
164
165 /**
166 * @brief Returns a vector of references to TableHandler objects that needs to
167 * be serialized/deserialized for a given AuxiliaryPhysics solver.
168 *
169 * @return Structure containing the TableHandler objects and their corresponding file names.
170 */
171 virtual std::vector<OutputStructTableHandler>
173
174 /**
175 * @brief Compute the Kelly error estimator used to refine mesh on a auxiliary physic parameter.
176 *
177 * @param[in] ivar The current element of the map
178 * simulation_parameters.mesh_adaptation.variables
179 *
180 * @param[in,out] estimated_error_per_cell The deal.II vector of
181 * estimated_error_per_cell
182 */
183 virtual void
185 const std::pair<const Variable, Parameters::MultipleAdaptationParameters>
186 &ivar,
187 dealii::Vector<float> &estimated_error_per_cell) = 0;
188
189
190 /**
191 * @brief Sets-up the DofHandler and the degree of freedom associated with the physics.
192 */
193 virtual void
195
196 /**
197 * @brief Sets-up the initial conditions associated with the physics. Generally, physics
198 * only support imposing nodal values, but some physics additionally support
199 * the use of L2 projection or steady-state solutions.
200 */
201 virtual void
203
204 /**
205 * @brief Set up preconditioner. Not used for the auxiliary physics but
206 * needed for the compilation of the non-linear solver.
207 */
208 void
210
211 /**
212 * @brief Manage if this auxiliary physics should be solved at the current iteration. By default, auxiliary physics are solved at every iteration.
213 */
214 virtual bool
216 {
217 return true;
218 }
219};
220
221
222
223#endif
virtual void percolate_time_vectors()=0
Carry out the operations required to rearrange the values of the previous solution at the end of a ti...
virtual void post_mesh_adaptation()=0
post_mesh_adaption Interpolates the auxiliary physics variables to the new mesh
virtual void setup_dofs()=0
Sets-up the DofHandler and the degree of freedom associated with the physics.
virtual std::vector< OutputStruct< dim, VectorType > > gather_output_hook()
Gather and return vector of output structs that are particular to some applications.
virtual void compute_error_estimate(const std::pair< const Variable, Parameters::MultipleAdaptationParameters > &ivar, dealii::Vector< float > &estimated_error_per_cell)=0
Compute the Kelly error estimator used to refine mesh on a auxiliary physic parameter.
virtual void postprocess(bool first_iteration)=0
Postprocess the auxiliary physics results. Post-processing this case implies the calculation of all d...
void setup_preconditioner() override
Set up preconditioner. Not used for the auxiliary physics but needed for the compilation of the non-l...
virtual std::vector< OutputStructTableHandler > gather_tables()=0
Returns a vector of references to TableHandler objects that needs to be serialized/deserialized for a...
virtual void output_per_iteration_timer()=0
Output the per iteration wallclock times.
virtual void update_boundary_conditions()
Update non zero constraints if the boundary is time-dependent.
virtual void finish_simulation()=0
Carry out the operations required to finish a simulation correctly.
virtual void write_checkpoint()=0
Prepares auxiliary physics to write checkpoint.
virtual bool should_solve_auxiliary_physics()
Manage if this auxiliary physics should be solved at the current iteration. By default,...
virtual void read_checkpoint()=0
Set solution vector of Auxiliary Physics using checkpoint.
virtual ~AuxiliaryPhysics()=default
AuxiliaryPhysics - Base destructor. At the present moment this is an interface with nothing.
virtual void modify_solution()
Carry out modifications on the auxiliary physic solution. To be defined for some physics only (eg....
virtual void pre_mesh_adaptation()=0
pre_mesh_adaption Prepares the auxiliary physics variables for a mesh refinement/coarsening
virtual void set_initial_conditions()=0
Sets-up the initial conditions associated with the physics. Generally, physics only support imposing ...
virtual const DoFHandler< dim > & get_dof_handler()=0
Provide the dof handler associated with an auxiliary physics TODO : delete as the auxiliary physics a...
AuxiliaryPhysics()
AuxiliaryPhysics - Base constructor for Auxiliary physics. This constructor builds an auxiliary physi...
AuxiliaryPhysics(const Parameters::NonLinearSolver non_linear_solver_parameters)
AuxiliaryPhysics - Base constructor for Auxiliary physics. This constructor builds an auxiliary physi...
PhysicsSolver(const Parameters::NonLinearSolver non_linear_solver_parameters)
Constructor for the non-linear physics.
NonLinearSolver - Parameter that controls the solution of the non-linear problems.
GlobalVectorType VectorType