/home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/discretization/common/abstract_assembler.hh Source File#

DiFfRG: /home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/discretization/common/abstract_assembler.hh Source File
DiFfRG
Discretization Framework for functional Renormalization Group flows
abstract_assembler.hh
Go to the documentation of this file.
1#pragma once
2
3// DiFfRG
8
9namespace DiFfRG
10{
11 using namespace dealii;
12
13 template <unsigned int dim, typename VectorType> class DataOutput;
14
15 namespace internal
16 {
17 template <typename... Args> constexpr void validate_readout_helper_arity()
18 {
19 static_assert(sizeof...(Args) == 3,
20 "The readout helper now requires a stable readout ID: helper(id, EoM, outputter)");
21 }
22
23 } // namespace internal
24
53 template <typename VectorType, typename SparseMatrixType, uint dim> class AbstractAssembler
54 {
55 public:
57
59 virtual SummaryEvent summary() const { return {}; }
60
68 virtual void attach_data_output(OutputFrame<dim, VectorType> &data_out, const VectorType &solution,
69 const VectorType &variables = VectorType(),
70 const VectorType &dt_solution = VectorType(),
71 const VectorType &residual = VectorType()) = 0;
72
73 [[deprecated("Override attach_data_output(OutputFrame<dim, VectorType>&, ...) instead")]] virtual void
74 attach_data_output(DataOutput<dim, VectorType> &, const VectorType &, const VectorType & = VectorType(),
75 const VectorType & = VectorType(), const VectorType & = VectorType()) = delete;
76
81 virtual void reinit() = 0;
82
88 virtual void set_time(double t) = 0;
89
96
102 virtual IndexSet get_differential_indices() const = 0;
103
109 virtual void reinit_vector(VectorType &vector) const = 0;
110
120 virtual void reinit_matrix(SparseMatrixType &matrix) const = 0;
121
127 virtual MPI_Comm get_communicator() const = 0;
128
136 virtual void reinit_solution_view(SolutionView<VectorType> &view) const = 0;
137
143 virtual const SparseMatrixType &get_mass_matrix() const = 0;
144
149
158 virtual void residual_variables([[maybe_unused]] VectorType &residual, [[maybe_unused]] const VectorType &variables,
159 [[maybe_unused]] const VectorType &spatial_solution)
160 {
161 throw std::runtime_error("residual_variables() is not implemented by this assembler");
162 };
163
172 virtual void jacobian_variables([[maybe_unused]] FullMatrix<NumberType> &jacobian,
173 [[maybe_unused]] const VectorType &variables,
174 [[maybe_unused]] const VectorType &spatial_solution)
175 {
176 throw std::runtime_error("jacobian_variables() is not implemented by this assembler");
177 };
178
188 void mass(VectorType &mass, const VectorType &solution_global, NumberType weight)
189 {
190 this->mass(mass, solution_global, solution_global, weight);
191 }
192
203 virtual void mass(VectorType &mass, const VectorType &solution_global, const VectorType &solution_global_dot,
204 NumberType weight) = 0;
205
224 void residual(VectorType &residual, const VectorType &solution_global, NumberType weight, NumberType weight_mass,
225 const VectorType &variables = VectorType())
226 {
227 this->residual(residual, solution_global, weight, solution_global, weight_mass, variables);
228 }
229
249 virtual void residual(VectorType &residual, const VectorType &solution_global, NumberType weight,
250 const VectorType &solution_global_dot, NumberType weight_mass,
251 const VectorType &variables = VectorType()) = 0;
252
265 void jacobian_mass(SparseMatrixType &jacobian, const VectorType &solution_global, NumberType mass_weight = 1.)
266 {
267 this->jacobian_mass(jacobian, solution_global, solution_global, mass_weight, 0.);
268 }
269
285 virtual void jacobian_mass(SparseMatrixType &jacobian, const VectorType &solution_global,
286 const VectorType &solution_global_dot, NumberType alpha = 1., NumberType beta = 1.) = 0;
287
298 void jacobian(SparseMatrixType &jacobian, const VectorType &solution_global, NumberType weight,
299 NumberType mass_weight, const VectorType &variables = VectorType())
300 {
301 this->jacobian(jacobian, solution_global, weight, solution_global, mass_weight, mass_weight, variables);
302 }
303
314 virtual void jacobian(SparseMatrixType &jacobian, const VectorType &solution_global, NumberType weight,
315 const VectorType &solution_global_dot, NumberType alpha, NumberType beta,
316 const VectorType &variables = VectorType()) = 0;
318 };
319} // namespace DiFfRG
This is the general assembler interface for any kind of discretization. An assembler is responsible f...
Definition abstract_assembler.hh:54
void mass(VectorType &mass, const VectorType &solution_global, NumberType weight)
Calculates the mass for an ODE.
Definition abstract_assembler.hh:188
virtual SummaryEvent summary() const
Definition abstract_assembler.hh:59
virtual void jacobian_variables(FullMatrix< NumberType > &jacobian, const VectorType &variables, const VectorType &spatial_solution)
When coupling the spatial discretization to additional variables, this function should calculate the ...
Definition abstract_assembler.hh:172
void jacobian_mass(SparseMatrixType &jacobian, const VectorType &solution_global, NumberType mass_weight=1.)
Calculates the jacobian of the mass function for an ODE.
Definition abstract_assembler.hh:265
virtual void reinit_vector(VectorType &vector) const =0
Reinitialize an arbitrary vector so that it has the correct size and structure.
void jacobian(SparseMatrixType &jacobian, const VectorType &solution_global, NumberType weight, NumberType mass_weight, const VectorType &variables=VectorType())
Calculates the jacobian of the residual function for an ODE.
Definition abstract_assembler.hh:298
virtual void jacobian_mass(SparseMatrixType &jacobian, const VectorType &solution_global, const VectorType &solution_global_dot, NumberType alpha=1., NumberType beta=1.)=0
Calculates the jacobian of the mass function for a DAE.
virtual void mass(VectorType &mass, const VectorType &solution_global, const VectorType &solution_global_dot, NumberType weight)=0
Calculates the mass for a DAE.
virtual MPI_Comm get_communicator() const =0
The communicator this assembler's linear algebra lives on.
typename get_type::NumberType< VectorType > NumberType
Definition abstract_assembler.hh:56
virtual void reinit_matrix(SparseMatrixType &matrix) const =0
Reinitialize a matrix to the jacobian's sparsity pattern.
void residual(VectorType &residual, const VectorType &solution_global, NumberType weight, NumberType weight_mass, const VectorType &variables=VectorType())
Calculates the residual for an ODE.
Definition abstract_assembler.hh:224
virtual void attach_data_output(DataOutput< dim, VectorType > &, const VectorType &, const VectorType &=VectorType(), const VectorType &=VectorType(), const VectorType &=VectorType())=delete
virtual void residual_variables(VectorType &residual, const VectorType &variables, const VectorType &spatial_solution)
When coupling the spatial discretization to additional variables, this function should calculate the ...
Definition abstract_assembler.hh:158
virtual IndexSet get_differential_indices() const =0
Obtain the dofs which contain time derivatives.
virtual void jacobian(SparseMatrixType &jacobian, const VectorType &solution_global, NumberType weight, const VectorType &solution_global_dot, NumberType alpha, NumberType beta, const VectorType &variables=VectorType())=0
Calculates the jacobian of the residual function for a DAE.
virtual void attach_data_output(OutputFrame< dim, VectorType > &data_out, const VectorType &solution, const VectorType &variables=VectorType(), const VectorType &dt_solution=VectorType(), const VectorType &residual=VectorType())=0
Contribute the assembler's fields and model readouts to one scoped output frame.
virtual void reinit_solution_view(SolutionView< VectorType > &view) const =0
Establish the layout of a fully-replicated read-only view of the solution.
virtual void residual(VectorType &residual, const VectorType &solution_global, NumberType weight, const VectorType &solution_global_dot, NumberType weight_mass, const VectorType &variables=VectorType())=0
Calculates the residual for a DAE.
virtual void set_time(double t)=0
Set the current time. The assembler should usually just forward this to the numerical model.
virtual const SparseMatrixType & get_mass_matrix() const =0
Obtain the mass matrix.
virtual const get_type::SparsityPattern< SparseMatrixType > & get_sparsity_pattern_jacobian() const =0
Obtain the sparsity pattern of the jacobian matrix.
virtual void reinit()=0
Reinitialize the assembler. This is necessary if the mesh has changed, e.g. after a mesh refinement.
Definition data_output.hh:19
Definition output_session.hh:42
A read-only, fully-replicated view of the solution.
Definition solution_view.hh:48
All compile-time knowledge about which linear algebra types DiFfRG uses.
typename internal::_NumberType< VectorType >::value NumberType
Definition linear_algebra.hh:152
typename internal::_SparsityPattern< SparseMatrixType >::value SparsityPattern
Definition linear_algebra.hh:155
constexpr void validate_readout_helper_arity()
Definition abstract_assembler.hh:17
Definition complex_math.hh:10
Definition run_reporter.hh:73