Assembler< Model_ > Class Template Reference#

DiFfRG: DiFfRG::Variables::Assembler< Model_ > Class Template Reference
DiFfRG
Discretization Framework for functional Renormalization Group flows
DiFfRG::Variables::Assembler< Model_ > Class Template Reference

The basic assembler that can be used for any standard CG scheme with flux and source. More...

#include <variables.hh>

Inheritance diagram for DiFfRG::Variables::Assembler< Model_ >:
DiFfRG::AbstractAssembler< Vector< double >, SparseMatrix< double >, 0 >

Public Types

using Model = Model_
 
using NumberType = double
 
using VectorType = Vector<double>
 
using SparseMatrixType = SparseMatrix<double>
 
using Components = typename Model_::Components
 
- Public Types inherited from DiFfRG::AbstractAssembler< Vector< double >, SparseMatrix< double >, 0 >
using NumberType
 

Public Member Functions

 Assembler (Model &model, const ConfigTree &)
 
virtual void reinit_vector (VectorType &vec) const override
 Reinitialize an arbitrary vector so that it has the correct size and structure.
 
virtual void reinit_matrix (SparseMatrixType &matrix) const override
 Reinitialize a matrix to the jacobian's sparsity pattern.
 
virtual MPI_Comm get_communicator () const override
 The communicator this assembler's linear algebra lives on.
 
virtual void reinit_solution_view (SolutionView< VectorType > &view) const override
 Establish the layout of a fully-replicated read-only view of the solution.
 
virtual IndexSet get_differential_indices () const override
 Obtain the dofs which contain time derivatives.
 
virtual void attach_data_output (OutputFrame< dim, VectorType > &data_out, const VectorType &solution, const VectorType &variables, const VectorType &dt_solution=VectorType(), const VectorType &residual=VectorType()) override
 Contribute the assembler's fields and model readouts to one scoped output frame.
 
virtual void reinit () override
 Reinitialize the assembler. This is necessary if the mesh has changed, e.g. after a mesh refinement.
 
virtual void set_time (double t) override
 Set the current time. The assembler should usually just forward this to the numerical model.
 
virtual const SparsityPattern & get_sparsity_pattern_jacobian () const override
 Obtain the sparsity pattern of the jacobian matrix.
 
virtual const SparseMatrix< NumberType > & get_mass_matrix () const override
 Obtain the mass matrix.
 
virtual void residual_variables (VectorType &residual, const VectorType &variables, const VectorType &) override
 When coupling the spatial discretization to additional variables, this function should calculate the residual for the additional variables.
 
virtual void jacobian_variables (FullMatrix< NumberType > &jacobian, const VectorType &variables, const VectorType &) override
 
void readouts (OutputFrame< dim, VectorType > &data_out, const VectorType &, const VectorType &variables) const
 
virtual void mass (VectorType &, const VectorType &, const VectorType &, NumberType) override
 
virtual void residual (VectorType &, const VectorType &, NumberType, const VectorType &, NumberType, const VectorType &variables=VectorType()) override
 
virtual void jacobian_mass (SparseMatrix< NumberType > &, const VectorType &, const VectorType &, NumberType, NumberType) override
 
virtual void jacobian (SparseMatrix< NumberType > &, const VectorType &, NumberType, const VectorType &, NumberType, NumberType, const VectorType &variables=VectorType()) override
 
SummaryEvent summary () const override
 
double average_time_residual_assembly () const
 
uint num_residuals () const
 
double average_time_jacobian_assembly () const
 
uint num_jacobians () const
 
- Public Member Functions inherited from DiFfRG::AbstractAssembler< Vector< double >, SparseMatrix< double >, 0 >
virtual void attach_data_output (DataOutput< dim, Vector< double > > &, const Vector< double > &, const Vector< double > &=Vector< double >(), const Vector< double > &=Vector< double >(), const Vector< double > &=Vector< double >())=delete
 
virtual void jacobian_variables (FullMatrix< NumberType > &jacobian, const Vector< double > &variables, const Vector< double > &spatial_solution)
 When coupling the spatial discretization to additional variables, this function should calculate the jacobian for the additional variables.
 
void mass (Vector< double > &mass, const Vector< double > &solution_global, NumberType weight)
 Calculates the mass \(m_i(u)\) for an ODE.
 
virtual void mass (Vector< double > &mass, const Vector< double > &solution_global, const Vector< double > &solution_global_dot, NumberType weight)=0
 Calculates the mass \(m(u, \partial_t u)\) for a DAE.
 
void residual (Vector< double > &residual, const Vector< double > &solution_global, NumberType weight, NumberType weight_mass, const Vector< double > &variables=Vector< double >())
 Calculates the residual for an ODE.
 
virtual void residual (Vector< double > &residual, const Vector< double > &solution_global, NumberType weight, const Vector< double > &solution_global_dot, NumberType weight_mass, const Vector< double > &variables=Vector< double >())=0
 Calculates the residual for a DAE.
 
void jacobian_mass (SparseMatrix< double > &jacobian, const Vector< double > &solution_global, NumberType mass_weight=1.)
 Calculates the jacobian of the mass function for an ODE.
 
virtual void jacobian_mass (SparseMatrix< double > &jacobian, const Vector< double > &solution_global, const Vector< double > &solution_global_dot, NumberType alpha=1., NumberType beta=1.)=0
 Calculates the jacobian of the mass function for a DAE.
 
void jacobian (SparseMatrix< double > &jacobian, const Vector< double > &solution_global, NumberType weight, NumberType mass_weight, const Vector< double > &variables=Vector< double >())
 Calculates the jacobian of the residual function for an ODE.
 
virtual void jacobian (SparseMatrix< double > &jacobian, const Vector< double > &solution_global, NumberType weight, const Vector< double > &solution_global_dot, NumberType alpha, NumberType beta, const Vector< double > &variables=Vector< double >())=0
 Calculates the jacobian of the residual function for a DAE.
 

Static Public Attributes

static constexpr uint dim = 0
 

Private Attributes

Model & model
 
SparsityPattern sparsity_pattern_mass
 
SparsityPattern sparsity_pattern_jacobian
 
SparseMatrix< NumberType > mass_matrix
 
std::vector< double > timings_residual
 
std::vector< double > timings_jacobian
 

Static Private Attributes

static constexpr int nothing = 0
 

Detailed Description

template<typename Model_>
class DiFfRG::Variables::Assembler< Model_ >

The basic assembler that can be used for any standard CG scheme with flux and source.

Template Parameters
ModelThe model class which contains the physical equations.

Member Typedef Documentation

◆ Components

template<typename Model_ >
using DiFfRG::Variables::Assembler< Model_ >::Components = typename Model_::Components

◆ Model

template<typename Model_ >
using DiFfRG::Variables::Assembler< Model_ >::Model = Model_

◆ NumberType

template<typename Model_ >
using DiFfRG::Variables::Assembler< Model_ >::NumberType = double

◆ SparseMatrixType

template<typename Model_ >
using DiFfRG::Variables::Assembler< Model_ >::SparseMatrixType = SparseMatrix<double>

◆ VectorType

template<typename Model_ >
using DiFfRG::Variables::Assembler< Model_ >::VectorType = Vector<double>

Constructor & Destructor Documentation

◆ Assembler()

template<typename Model_ >
DiFfRG::Variables::Assembler< Model_ >::Assembler ( Model & model,
const ConfigTree &  )
inline

This assembler has no FE space at all (dim == 0) and never runs a mesh_loop, so it needs neither an assembly schedule nor a report port; the config is unused.

Member Function Documentation

◆ attach_data_output()

template<typename Model_ >
virtual void DiFfRG::Variables::Assembler< Model_ >::attach_data_output ( OutputFrame< dim, VectorType > & data_out,
const VectorType & solution,
const VectorType & variables,
const VectorType & dt_solution = VectorType(),
const VectorType & residual = VectorType() )
inlineoverridevirtual

Contribute the assembler's fields and model readouts to one scoped output frame.

Parameters
data_outThe current output frame
solutionThe spatial solution vector
variablesThe additional variables vector

Implements DiFfRG::AbstractAssembler< Vector< double >, SparseMatrix< double >, 0 >.

◆ average_time_jacobian_assembly()

template<typename Model_ >
double DiFfRG::Variables::Assembler< Model_ >::average_time_jacobian_assembly ( ) const
inline

◆ average_time_residual_assembly()

template<typename Model_ >
double DiFfRG::Variables::Assembler< Model_ >::average_time_residual_assembly ( ) const
inline

◆ get_communicator()

template<typename Model_ >
virtual MPI_Comm DiFfRG::Variables::Assembler< Model_ >::get_communicator ( ) const
inlineoverridevirtual

The communicator this assembler's linear algebra lives on.

MPI_COMM_SELF for a serial discretization, so callers never branch on the build type.

Implements DiFfRG::AbstractAssembler< Vector< double >, SparseMatrix< double >, 0 >.

◆ get_differential_indices()

template<typename Model_ >
virtual IndexSet DiFfRG::Variables::Assembler< Model_ >::get_differential_indices ( ) const
inlineoverridevirtual

Obtain the dofs which contain time derivatives.

Returns
IndexSet The indices of the dofs which contain time derivatives

Implements DiFfRG::AbstractAssembler< Vector< double >, SparseMatrix< double >, 0 >.

◆ get_mass_matrix()

template<typename Model_ >
virtual const SparseMatrix< NumberType > & DiFfRG::Variables::Assembler< Model_ >::get_mass_matrix ( ) const
inlineoverridevirtual

Obtain the mass matrix.

Returns
const SparseMatrixType& The mass matrix

Implements DiFfRG::AbstractAssembler< Vector< double >, SparseMatrix< double >, 0 >.

◆ get_sparsity_pattern_jacobian()

template<typename Model_ >
virtual const SparsityPattern & DiFfRG::Variables::Assembler< Model_ >::get_sparsity_pattern_jacobian ( ) const
inlineoverridevirtual

Obtain the sparsity pattern of the jacobian matrix.

Returns
const SparsityPattern<VectorType>& The sparsity pattern of the jacobian matrix

Implements DiFfRG::AbstractAssembler< Vector< double >, SparseMatrix< double >, 0 >.

◆ jacobian()

template<typename Model_ >
virtual void DiFfRG::Variables::Assembler< Model_ >::jacobian ( SparseMatrix< NumberType > & ,
const VectorType & ,
NumberType ,
const VectorType & ,
NumberType ,
NumberType ,
const VectorType & variables = VectorType() )
inlineoverridevirtual

◆ jacobian_mass()

template<typename Model_ >
virtual void DiFfRG::Variables::Assembler< Model_ >::jacobian_mass ( SparseMatrix< NumberType > & ,
const VectorType & ,
const VectorType & ,
NumberType ,
NumberType  )
inlineoverridevirtual

◆ jacobian_variables()

template<typename Model_ >
virtual void DiFfRG::Variables::Assembler< Model_ >::jacobian_variables ( FullMatrix< NumberType > & jacobian,
const VectorType & variables,
const VectorType &  )
inlineoverridevirtual

◆ mass()

template<typename Model_ >
virtual void DiFfRG::Variables::Assembler< Model_ >::mass ( VectorType & ,
const VectorType & ,
const VectorType & ,
NumberType  )
inlineoverridevirtual

◆ num_jacobians()

template<typename Model_ >
uint DiFfRG::Variables::Assembler< Model_ >::num_jacobians ( ) const
inline

◆ num_residuals()

template<typename Model_ >
uint DiFfRG::Variables::Assembler< Model_ >::num_residuals ( ) const
inline

◆ readouts()

template<typename Model_ >
void DiFfRG::Variables::Assembler< Model_ >::readouts ( OutputFrame< dim, VectorType > & data_out,
const VectorType & ,
const VectorType & variables ) const
inline

◆ reinit()

template<typename Model_ >
virtual void DiFfRG::Variables::Assembler< Model_ >::reinit ( )
inlineoverridevirtual

Reinitialize the assembler. This is necessary if the mesh has changed, e.g. after a mesh refinement.

Implements DiFfRG::AbstractAssembler< Vector< double >, SparseMatrix< double >, 0 >.

◆ reinit_matrix()

template<typename Model_ >
virtual void DiFfRG::Variables::Assembler< Model_ >::reinit_matrix ( SparseMatrixType & matrix) const
inlineoverridevirtual

Reinitialize a matrix to the jacobian's sparsity pattern.

The counterpart of reinit_vector, and it exists for the same reason: callers must not build the object themselves. SparseMatrixType m(get_sparsity_pattern_jacobian()) is fine for a serial matrix and impossible for a distributed one, which needs the owned row set and a communicator as well – neither of which a timestepper has any business knowing. Routing this through the assembler keeps the timesteppers policy-agnostic.

Implements DiFfRG::AbstractAssembler< Vector< double >, SparseMatrix< double >, 0 >.

◆ reinit_solution_view()

template<typename Model_ >
virtual void DiFfRG::Variables::Assembler< Model_ >::reinit_solution_view ( SolutionView< VectorType > & view) const
inlineoverridevirtual

Establish the layout of a fully-replicated read-only view of the solution.

Output, the EoM search and the potential solves all read arbitrary global dof indices, which a vector holding only this rank's rows cannot answer. Refreshing one of these before handing it to them keeps all of that code unchanged. See SolutionView.

Implements DiFfRG::AbstractAssembler< Vector< double >, SparseMatrix< double >, 0 >.

◆ reinit_vector()

template<typename Model_ >
virtual void DiFfRG::Variables::Assembler< Model_ >::reinit_vector ( VectorType & vector) const
inlineoverridevirtual

Reinitialize an arbitrary vector so that it has the correct size and structure.

Parameters
vectorThe vector to be reinitialized

Implements DiFfRG::AbstractAssembler< Vector< double >, SparseMatrix< double >, 0 >.

◆ residual()

template<typename Model_ >
virtual void DiFfRG::Variables::Assembler< Model_ >::residual ( VectorType & ,
const VectorType & ,
NumberType ,
const VectorType & ,
NumberType ,
const VectorType & variables = VectorType() )
inlineoverridevirtual

◆ residual_variables()

template<typename Model_ >
virtual void DiFfRG::Variables::Assembler< Model_ >::residual_variables ( VectorType & residual,
const VectorType & variables,
const VectorType & spatial_solution )
inlineoverridevirtual

When coupling the spatial discretization to additional variables, this function should calculate the residual for the additional variables.

Parameters
residualThe residual vector of the additional variables
variablesThe current additional variables vector
spatial_solutionThe spatial solution vector, which is needed for the calculation of the residual

Reimplemented from DiFfRG::AbstractAssembler< Vector< double >, SparseMatrix< double >, 0 >.

◆ set_time()

template<typename Model_ >
virtual void DiFfRG::Variables::Assembler< Model_ >::set_time ( double t)
inlineoverridevirtual

Set the current time. The assembler should usually just forward this to the numerical model.

Parameters
tThe current time

Implements DiFfRG::AbstractAssembler< Vector< double >, SparseMatrix< double >, 0 >.

◆ summary()

template<typename Model_ >
SummaryEvent DiFfRG::Variables::Assembler< Model_ >::summary ( ) const
inlineoverridevirtual

Return aggregate assembly statistics for the run summary.

Reimplemented from DiFfRG::AbstractAssembler< Vector< double >, SparseMatrix< double >, 0 >.

Member Data Documentation

◆ dim

template<typename Model_ >
uint DiFfRG::Variables::Assembler< Model_ >::dim = 0
staticconstexpr

◆ mass_matrix

template<typename Model_ >
SparseMatrix<NumberType> DiFfRG::Variables::Assembler< Model_ >::mass_matrix
private

◆ model

template<typename Model_ >
Model& DiFfRG::Variables::Assembler< Model_ >::model
private

◆ nothing

template<typename Model_ >
int DiFfRG::Variables::Assembler< Model_ >::nothing = 0
staticconstexprprivate

◆ sparsity_pattern_jacobian

template<typename Model_ >
SparsityPattern DiFfRG::Variables::Assembler< Model_ >::sparsity_pattern_jacobian
private

◆ sparsity_pattern_mass

template<typename Model_ >
SparsityPattern DiFfRG::Variables::Assembler< Model_ >::sparsity_pattern_mass
private

◆ timings_jacobian

template<typename Model_ >
std::vector<double> DiFfRG::Variables::Assembler< Model_ >::timings_jacobian
private

◆ timings_residual

template<typename Model_ >
std::vector<double> DiFfRG::Variables::Assembler< Model_ >::timings_residual
private

The documentation for this class was generated from the following file:
  • /home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/discretization/variables/assembler/variables.hh