FEMAssembler< Discretization_, Model_ > Class Template Reference#

DiFfRG: DiFfRG::FEMAssembler< Discretization_, Model_ > Class Template Reference
DiFfRG
Discretization Framework for functional Renormalization Group flows

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

#include <common.hh>

Inheritance diagram for DiFfRG::FEMAssembler< Discretization_, Model_ >:
DiFfRG::AbstractAssembler< Discretization_::VectorType, Discretization_::SparseMatrixType, Discretization_::dim > DiFfRG::CG::Assembler< Discretization_, Model_ > DiFfRG::DG::Assembler< Discretization_, Model_ > DiFfRG::dDG::Assembler< Discretization_, Model_ >

Classes

struct  PointEvaluation
 The FE solution and the reconstructed raw potential at one point. More...
 

Public Types

using Discretization = Discretization_
 
using Model = Model_
 
using NumberType = typename Discretization::NumberType
 
using VectorType = typename Discretization::VectorType
 
using SparseMatrixType = typename Discretization::SparseMatrixType
 
using Components = typename Discretization::Components
 
- Public Types inherited from DiFfRG::AbstractAssembler< Discretization_::VectorType, Discretization_::SparseMatrixType, Discretization_::dim >
using NumberType
 

Public Member Functions

 FEMAssembler (Discretization &discretization, Model &model, const ConfigTree &config)
 
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
 
const auto & get_discretization () const
 
auto & get_discretization ()
 
virtual void reinit () override
 Reinitialize the assembler. This is necessary if the mesh has changed, e.g. after a mesh refinement.
 
virtual void rebuild_jacobian_sparsity ()=0
 
virtual void set_time (double t) override
 Set the current time. The assembler should usually just forward this to the numerical model.
 
virtual void refinement_indicator (Vector< double > &, const VectorType &)=0
 
virtual void residual_variables (VectorType &residual, const VectorType &variables, const VectorType &spatial_solution) override
 
virtual void jacobian_variables (FullMatrix< NumberType > &jacobian, const VectorType &variables, const VectorType &spatial_solution) override
 
template<typename RawPotential >
auto evaluate_at (const Point< dim > &x, const typename DoFHandler< dim >::cell_iterator &cell, const VectorType &solution_global, const RawPotential &raw_potential) const
 Evaluate the FE solution and the raw potential at x, which lies in cell.
 
auto extractor_raw_potential (const VectorType &solution_global) const
 The raw potential for the extractors, or an inert placeholder if the model does not read it.
 
void readouts (OutputFrame< dim, VectorType > &data_out, const VectorType &solution_global, const VectorType &variables) const
 
std::pair< Point< dim >, typename DoFHandler< dim >::cell_iterator > resolve_extractor_point (const Point< dim > &EoM_point, const typename DoFHandler< dim >::cell_iterator &EoM_cell_, const VectorType &solution_global) const
 Where the model wants its extractors evaluated, and the cell holding that point.
 
void extract (std::array< NumberType, Components::count_extractors()> &data, const VectorType &solution_global, const VectorType &variables, bool search_EoM, bool set_EoM, bool postprocess) const
 
bool jacobian_extractors (FullMatrix< NumberType > &extractor_jacobian, const VectorType &solution_global, const VectorType &variables)
 
double average_time_variable_residual_assembly ()
 
uint num_variable_residuals () const
 
double average_time_variable_jacobian_assembly ()
 
uint num_variable_jacobians () const
 
- Public Member Functions inherited from DiFfRG::AbstractAssembler< Discretization_::VectorType, Discretization_::SparseMatrixType, Discretization_::dim >
virtual SummaryEvent summary () const
 
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 attach_data_output (DataOutput< dim, VectorType > &, const VectorType &, const VectorType &=VectorType(), const VectorType &=VectorType(), const VectorType &=VectorType())=delete
 
virtual const get_type::SparsityPattern< SparseMatrixType > & get_sparsity_pattern_jacobian () const=0
 Obtain the sparsity pattern of the jacobian matrix.
 
virtual void reinit_vector (VectorType &vector) const=0
 Reinitialize an arbitrary vector so that it has the correct size and structure.
 
virtual void reinit_matrix (SparseMatrixType &matrix) const=0
 Reinitialize a matrix to the jacobian's sparsity pattern.
 
virtual MPI_Comm get_communicator () const=0
 The communicator this assembler's linear algebra lives on.
 
virtual void reinit_solution_view (SolutionView< VectorType > &view) const=0
 Establish the layout of a fully-replicated read-only view of the solution.
 
virtual const SparseMatrixType & get_mass_matrix () const=0
 Obtain the mass matrix.
 
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 residual for the additional variables.
 
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 jacobian for the additional variables.
 
void mass (VectorType &mass, const VectorType &solution_global, NumberType weight)
 Calculates the mass \(m_i(u)\) for an ODE.
 
virtual void mass (VectorType &mass, const VectorType &solution_global, const VectorType &solution_global_dot, NumberType weight)=0
 Calculates the mass \(m(u, \partial_t u)\) for a DAE.
 
void residual (VectorType &residual, const VectorType &solution_global, NumberType weight, NumberType weight_mass, const VectorType &variables=VectorType())
 Calculates the residual for an ODE.
 
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.
 
void jacobian_mass (SparseMatrixType &jacobian, const VectorType &solution_global, NumberType mass_weight=1.)
 Calculates the jacobian of the mass function for an ODE.
 
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.
 
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.
 
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.
 

Static Public Attributes

static constexpr uint dim = Discretization::dim
 

Protected Member Functions

AssemblySchedule schedule_for (const double cost_ns) const
 The mesh_loop schedule for a loop whose cell worker costs cost_ns nanoseconds.
 
void update_assembly_schedules ()
 Re-count the cells the schedules are sized from.
 

Static Protected Member Functions

template<typename... T>
static constexpr auto v_tie (T &&...t)
 
template<typename... T>
static constexpr auto e_tie (T &&...t)
 

Protected Attributes

Discretization & discretization
 
Model & model
 
ReportPort report_port
 
const FiniteElement< dim > & fe
 
const DoFHandler< dim > & dof_handler
 
const Mapping< dim > & mapping
 
uint n_owned_cells = 0
 Cells this rank assembles. Refreshed in reinit(); the per-loop schedules are sized from it.
 
const AssemblyScheduleOverrides schedule_overrides
 
DoFHandler< dim >::cell_iterator EoM_cell
 
DoFHandler< dim >::cell_iterator old_EoM_cell
 
const Config::EoMConfig EoM_config
 
Point< dim > EoM
 
std::optional< Point< dim > > EoM_minimum_guess
 
DiFfRG::internal::PotentialSystemCache< dim, NumberType > potential_cache
 Mesh-dependent half of the potential reconstructions, built once and reused; see PotentialSystemCache.
 
DoFHandler< dim >::cell_iterator old_extractor_cell
 Where the extractors are evaluated. Equal to EoM unless the model defines extractor_point.
 
FullMatrix< NumberType > extractor_jacobian
 
FullMatrix< NumberType > extractor_jacobian_u
 
FullMatrix< NumberType > extractor_jacobian_du
 
FullMatrix< NumberType > extractor_jacobian_ddu
 
std::vector< types::global_dof_index > extractor_dof_indices
 
std::vector< double > timings_variable_residual
 
std::vector< double > timings_variable_jacobian
 

Static Protected Attributes

static constexpr int nothing = 0
 

Detailed Description

template<typename Discretization_, typename Model_>
class DiFfRG::FEMAssembler< Discretization_, 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 Discretization_ , typename Model_ >
using DiFfRG::FEMAssembler< Discretization_, Model_ >::Components = typename Discretization::Components

◆ Discretization

template<typename Discretization_ , typename Model_ >
using DiFfRG::FEMAssembler< Discretization_, Model_ >::Discretization = Discretization_

◆ Model

template<typename Discretization_ , typename Model_ >
using DiFfRG::FEMAssembler< Discretization_, Model_ >::Model = Model_

◆ NumberType

template<typename Discretization_ , typename Model_ >
using DiFfRG::FEMAssembler< Discretization_, Model_ >::NumberType = typename Discretization::NumberType

◆ SparseMatrixType

template<typename Discretization_ , typename Model_ >
using DiFfRG::FEMAssembler< Discretization_, Model_ >::SparseMatrixType = typename Discretization::SparseMatrixType

◆ VectorType

template<typename Discretization_ , typename Model_ >
using DiFfRG::FEMAssembler< Discretization_, Model_ >::VectorType = typename Discretization::VectorType

Constructor & Destructor Documentation

◆ FEMAssembler()

template<typename Discretization_ , typename Model_ >
DiFfRG::FEMAssembler< Discretization_, Model_ >::FEMAssembler ( Discretization & discretization,
Model & model,
const ConfigTree & config )
inline

Member Function Documentation

◆ attach_data_output()

template<typename Discretization_ , typename Model_ >
virtual void DiFfRG::FEMAssembler< Discretization_, 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

◆ average_time_variable_jacobian_assembly()

template<typename Discretization_ , typename Model_ >
double DiFfRG::FEMAssembler< Discretization_, Model_ >::average_time_variable_jacobian_assembly ( )
inline

◆ average_time_variable_residual_assembly()

template<typename Discretization_ , typename Model_ >
double DiFfRG::FEMAssembler< Discretization_, Model_ >::average_time_variable_residual_assembly ( )
inline

◆ e_tie()

template<typename Discretization_ , typename Model_ >
template<typename... T>
static constexpr auto DiFfRG::FEMAssembler< Discretization_, Model_ >::e_tie ( T &&... t)
inlinestaticconstexprprotected

◆ evaluate_at()

template<typename Discretization_ , typename Model_ >
template<typename RawPotential >
auto DiFfRG::FEMAssembler< Discretization_, Model_ >::evaluate_at ( const Point< dim > & x,
const typename DoFHandler< dim >::cell_iterator & cell,
const VectorType & solution_global,
const RawPotential & raw_potential ) const
inline

Evaluate the FE solution and the raw potential at x, which lies in cell.

◆ extract()

template<typename Discretization_ , typename Model_ >
void DiFfRG::FEMAssembler< Discretization_, Model_ >::extract ( std::array< NumberType, Components::count_extractors()> & data,
const VectorType & solution_global,
const VectorType & variables,
bool search_EoM,
bool set_EoM,
bool postprocess ) const
inline

◆ extractor_raw_potential()

template<typename Discretization_ , typename Model_ >
auto DiFfRG::FEMAssembler< Discretization_, Model_ >::extractor_raw_potential ( const VectorType & solution_global) const
inline

The raw potential for the extractors, or an inert placeholder if the model does not read it.

Reconstructing it is a direct solve over the whole mesh, and extract() runs on every residual and every jacobian – so a model that never touches the potential slots should say so and skip it.

◆ get_differential_indices()

template<typename Discretization_ , typename Model_ >
virtual IndexSet DiFfRG::FEMAssembler< Discretization_, 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< Discretization_::VectorType, Discretization_::SparseMatrixType, Discretization_::dim >.

◆ get_discretization() [1/2]

template<typename Discretization_ , typename Model_ >
auto & DiFfRG::FEMAssembler< Discretization_, Model_ >::get_discretization ( )
inline

◆ get_discretization() [2/2]

template<typename Discretization_ , typename Model_ >
const auto & DiFfRG::FEMAssembler< Discretization_, Model_ >::get_discretization ( ) const
inline

◆ jacobian_extractors()

template<typename Discretization_ , typename Model_ >
bool DiFfRG::FEMAssembler< Discretization_, Model_ >::jacobian_extractors ( FullMatrix< NumberType > & extractor_jacobian,
const VectorType & solution_global,
const VectorType & variables )
inline

◆ jacobian_variables()

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

◆ num_variable_jacobians()

template<typename Discretization_ , typename Model_ >
uint DiFfRG::FEMAssembler< Discretization_, Model_ >::num_variable_jacobians ( ) const
inline

◆ num_variable_residuals()

template<typename Discretization_ , typename Model_ >
uint DiFfRG::FEMAssembler< Discretization_, Model_ >::num_variable_residuals ( ) const
inline

◆ readouts()

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

◆ rebuild_jacobian_sparsity()

template<typename Discretization_ , typename Model_ >
virtual void DiFfRG::FEMAssembler< Discretization_, Model_ >::rebuild_jacobian_sparsity ( )
pure virtual

◆ refinement_indicator()

template<typename Discretization_ , typename Model_ >
virtual void DiFfRG::FEMAssembler< Discretization_, Model_ >::refinement_indicator ( Vector< double > & ,
const VectorType &  )
pure virtual

◆ reinit()

template<typename Discretization_ , typename Model_ >
virtual void DiFfRG::FEMAssembler< Discretization_, Model_ >::reinit ( )
inlineoverridevirtual

◆ residual_variables()

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

◆ resolve_extractor_point()

template<typename Discretization_ , typename Model_ >
std::pair< Point< dim >, typename DoFHandler< dim >::cell_iterator > DiFfRG::FEMAssembler< Discretization_, Model_ >::resolve_extractor_point ( const Point< dim > & EoM_point,
const typename DoFHandler< dim >::cell_iterator & EoM_cell_,
const VectorType & solution_global ) const
inline

Where the model wants its extractors evaluated, and the cell holding that point.

The EoM itself when the model does not define extractor_point – and then this costs nothing, because building the SolutionSample is inside the if constexpr.

◆ schedule_for()

template<typename Discretization_ , typename Model_ >
AssemblySchedule DiFfRG::FEMAssembler< Discretization_, Model_ >::schedule_for ( const double cost_ns) const
inlineprotected

The mesh_loop schedule for a loop whose cell worker costs cost_ns nanoseconds.

Pure arithmetic on the cached cell count, so it is called per loop rather than stored per cost: the loops do not fall into two classes, and anything between the reference points in namespace assembly_cost gets its own schedule instead of being rounded to one of them.

◆ set_time()

template<typename Discretization_ , typename Model_ >
virtual void DiFfRG::FEMAssembler< Discretization_, 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< Discretization_::VectorType, Discretization_::SparseMatrixType, Discretization_::dim >.

◆ update_assembly_schedules()

template<typename Discretization_ , typename Model_ >
void DiFfRG::FEMAssembler< Discretization_, Model_ >::update_assembly_schedules ( )
inlineprotected

Re-count the cells the schedules are sized from.

Called from reinit(), because h-adaptivity moves the cell count. Logs only on a change, so an adaptive run does not narrate every refinement.

◆ v_tie()

template<typename Discretization_ , typename Model_ >
template<typename... T>
static constexpr auto DiFfRG::FEMAssembler< Discretization_, Model_ >::v_tie ( T &&... t)
inlinestaticconstexprprotected

Member Data Documentation

◆ dim

template<typename Discretization_ , typename Model_ >
uint DiFfRG::FEMAssembler< Discretization_, Model_ >::dim = Discretization::dim
staticconstexpr

◆ discretization

template<typename Discretization_ , typename Model_ >
Discretization& DiFfRG::FEMAssembler< Discretization_, Model_ >::discretization
protected

◆ dof_handler

template<typename Discretization_ , typename Model_ >
const DoFHandler<dim>& DiFfRG::FEMAssembler< Discretization_, Model_ >::dof_handler
protected

◆ EoM

template<typename Discretization_ , typename Model_ >
Point<dim> DiFfRG::FEMAssembler< Discretization_, Model_ >::EoM
mutableprotected

◆ EoM_cell

template<typename Discretization_ , typename Model_ >
DoFHandler<dim>::cell_iterator DiFfRG::FEMAssembler< Discretization_, Model_ >::EoM_cell
mutableprotected

◆ EoM_config

template<typename Discretization_ , typename Model_ >
const Config::EoMConfig DiFfRG::FEMAssembler< Discretization_, Model_ >::EoM_config
protected

◆ EoM_minimum_guess

template<typename Discretization_ , typename Model_ >
std::optional<Point<dim> > DiFfRG::FEMAssembler< Discretization_, Model_ >::EoM_minimum_guess
mutableprotected

◆ extractor_dof_indices

template<typename Discretization_ , typename Model_ >
std::vector<types::global_dof_index> DiFfRG::FEMAssembler< Discretization_, Model_ >::extractor_dof_indices
protected

◆ extractor_jacobian

template<typename Discretization_ , typename Model_ >
FullMatrix<NumberType> DiFfRG::FEMAssembler< Discretization_, Model_ >::extractor_jacobian
protected

◆ extractor_jacobian_ddu

template<typename Discretization_ , typename Model_ >
FullMatrix<NumberType> DiFfRG::FEMAssembler< Discretization_, Model_ >::extractor_jacobian_ddu
protected

◆ extractor_jacobian_du

template<typename Discretization_ , typename Model_ >
FullMatrix<NumberType> DiFfRG::FEMAssembler< Discretization_, Model_ >::extractor_jacobian_du
protected

◆ extractor_jacobian_u

template<typename Discretization_ , typename Model_ >
FullMatrix<NumberType> DiFfRG::FEMAssembler< Discretization_, Model_ >::extractor_jacobian_u
protected

◆ fe

template<typename Discretization_ , typename Model_ >
const FiniteElement<dim>& DiFfRG::FEMAssembler< Discretization_, Model_ >::fe
protected

◆ mapping

template<typename Discretization_ , typename Model_ >
const Mapping<dim>& DiFfRG::FEMAssembler< Discretization_, Model_ >::mapping
protected

◆ model

template<typename Discretization_ , typename Model_ >
Model& DiFfRG::FEMAssembler< Discretization_, Model_ >::model
protected

◆ n_owned_cells

template<typename Discretization_ , typename Model_ >
uint DiFfRG::FEMAssembler< Discretization_, Model_ >::n_owned_cells = 0
protected

Cells this rank assembles. Refreshed in reinit(); the per-loop schedules are sized from it.

◆ nothing

template<typename Discretization_ , typename Model_ >
int DiFfRG::FEMAssembler< Discretization_, Model_ >::nothing = 0
staticconstexprprotected

◆ old_EoM_cell

template<typename Discretization_ , typename Model_ >
DoFHandler<dim>::cell_iterator DiFfRG::FEMAssembler< Discretization_, Model_ >::old_EoM_cell
protected

◆ old_extractor_cell

template<typename Discretization_ , typename Model_ >
DoFHandler<dim>::cell_iterator DiFfRG::FEMAssembler< Discretization_, Model_ >::old_extractor_cell
protected

Where the extractors are evaluated. Equal to EoM unless the model defines extractor_point.

◆ potential_cache

template<typename Discretization_ , typename Model_ >
DiFfRG::internal::PotentialSystemCache<dim, NumberType> DiFfRG::FEMAssembler< Discretization_, Model_ >::potential_cache
mutableprotected

Mesh-dependent half of the potential reconstructions, built once and reused; see PotentialSystemCache.

◆ report_port

template<typename Discretization_ , typename Model_ >
ReportPort DiFfRG::FEMAssembler< Discretization_, Model_ >::report_port
protected

◆ schedule_overrides

template<typename Discretization_ , typename Model_ >
const AssemblyScheduleOverrides DiFfRG::FEMAssembler< Discretization_, Model_ >::schedule_overrides
protected

◆ timings_variable_jacobian

template<typename Discretization_ , typename Model_ >
std::vector<double> DiFfRG::FEMAssembler< Discretization_, Model_ >::timings_variable_jacobian
protected

◆ timings_variable_residual

template<typename Discretization_ , typename Model_ >
std::vector<double> DiFfRG::FEMAssembler< Discretization_, Model_ >::timings_variable_residual
protected

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