DiFfRG
Loading...
Searching...
No Matches
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 Components = typename Model_::Components
 
- Public Types inherited from DiFfRG::AbstractAssembler< Vector< double >, SparseMatrix< double >, 0 >
using NumberType
 

Public Member Functions

 Assembler (Model &model, const JSONValue &json)
 
virtual void reinit_vector (VectorType &vec) const override
 Reinitialize an arbitrary vector so that it has the correct size and structure.
 
virtual IndexSet get_differential_indices () const override
 Obtain the dofs which contain time derivatives.
 
virtual void attach_data_output (DataOutput< dim, VectorType > &data_out, const VectorType &solution, const VectorType &variables, const VectorType &dt_solution=VectorType(), const VectorType &residual=VectorType())
 Attach any data output to the DataOutput object provided. This can be used to extract additional data from the solution and write it to the output file. This includes both derivatives and other spatial functions, as well as single values that can be appended to the .csv file.
 
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 (DataOutput< 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
 
void log (const std::string logger) const
 
double average_time_residual_assembly ()
 
uint num_residuals () const
 
double average_time_jacobian_assembly ()
 
uint num_jacobians () const
 
- Public Member Functions inherited from DiFfRG::AbstractAssembler< Vector< double >, SparseMatrix< double >, 0 >
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

Modelmodel
 
uint threads
 
SparsityPattern sparsity_pattern_mass
 
SparsityPattern sparsity_pattern_jacobian
 
SparseMatrix< NumberTypemass_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

◆ 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 JSONValue & json )
inline

Member Function Documentation

◆ attach_data_output()

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

Attach any data output to the DataOutput object provided. This can be used to extract additional data from the solution and write it to the output file. This includes both derivatives and other spatial functions, as well as single values that can be appended to the .csv file.

Parameters
data_outThe DataOutput object to attach the data to
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 ( )
inline

◆ average_time_residual_assembly()

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

◆ 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

◆ log()

template<typename Model_ >
void DiFfRG::Variables::Assembler< Model_ >::log ( const std::string logger) const
inline

◆ 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 ( DataOutput< 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_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 >.

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

◆ threads

template<typename Model_ >
uint DiFfRG::Variables::Assembler< Model_ >::threads
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: