PRISMS-PF Manual
Loading...
Searching...
No Matches
MFOperator< dim, degree, number > Class Template Reference

This class exists to evaluate a single user-defined operator for the matrix-free implementation of some PDE. More...

#include <mf_operator.h>

Inheritance diagram for MFOperator< dim, degree, number >:
[legend]
Collaboration diagram for MFOperator< dim, degree, number >:
[legend]

Public Types

using ScalarValue = dealii::VectorizedArray< number >
 
using VectorValue = dealii::Tensor< 1, dim, ScalarValue >
 
using Operator = void(PDEOperatorBase< dim, degree, number >::*)(FieldContainer< dim, degree, number > &, const SimulationTimer &, unsigned int) const
 
template<TensorRank Rank>
using Value = std::conditional_t< Rank==TensorRank::Scalar, ScalarValue, dealii::Tensor< int(Rank), dim, ScalarValue > >
 

Public Member Functions

template<TensorRank Rank>
Value< Rankidentity ()
 
template<TensorRank Rank>
Value< Rankzero ()
 
 MFOperator (const PDEOperatorBase< dim, degree, number > &operator_owner, Operator oper, const std::vector< FieldAttributes > &_field_attributes, const SolutionIndexer< dim, number > &_solution_indexer, unsigned int _relative_level, DependencyMap _dependency_map, const SimulationTimer &_sim_timer)
 Constructor.
 
void initialize (const GroupSolutionHandler< dim, number > &dst_solution)
 Initialize.
 
void compute_operator (BlockVector< number > &dst, const BlockVector< number > &src=BlockVector< number >()) const
 Calls cell_loop on function that calls user-defined operator.
 
void set_scaling_diagonal (bool scale, const std::vector< const SolutionVector< number > * > &diagonal)
 Set scaling diagonal.
 
dealii::types::global_dof_index m () const
 Return the number of DoFs.
 
number el (const unsigned int &row, const unsigned int &col) const
 Return the value of the matrix entry. This function is only valid when row == col and when the diagonal is initialized. Additionally, this is only used so that we may compile. Trying to use this function will throw an error.
 
void clear ()
 Release all memory and return to state like having called the default constructor.
 
const MatrixFree< dim, number > * get_matrix_free () const
 Set constrained entries to one.
 
const std::shared_ptr< dealii::DiagonalMatrix< SolutionVector< number > > > & get_matrix_diagonal_inverse () const
 Get read access to the inverse diagonal of this operator.
 
void vmult (BlockVector< number > &dst, const BlockVector< number > &src) const
 Matrix-vector multiplication.
 
void Tvmult (BlockVector< number > &dst, const BlockVector< number > &src) const
 Transpose matrix-vector multiplication.
 

Private Member Functions

void compute_local_operator (const MatrixFree< dim, number > &_data, BlockVector< number > &dst, const BlockVector< number > &src, const std::pair< unsigned int, unsigned int > &cell_range) const
 Calls user-defined operator.
 

Private Attributes

std::vector< FieldAttributesfield_attributes
 The attribute list of the relevant variables.
 
SolveGroup solve_group
 The group being solved.
 
const PDEOperatorBase< dim, degree, number > * pde_operator
 PDE operator object (owning class instance of pde_op) for user defined PDEs.
 
Operator pde_op
 The actual PDE operator function ptr (eg. compute_rhs) for user defined PDEs.
 
const SolutionIndexer< dim, number > * solution_indexer
 Read-access to fields.
 
unsigned int relative_level
 Level so that correct fields are read from indexer.
 
DependencyMap dependency_map
 Which fields should be available to the solve.
 
const SimulationTimersim_timer
 Simulation timer.
 
std::vector< const SolutionVector< number > * > scaling_diagonal
 Result of operator gets scaled by this (invm for explicit fields)
 
bool scale_by_diagonal = false
 Whether or not to scale after operator result.
 
std::vector< unsigned intfield_to_block_index
 Mapping from field index to block index (only for dst).
 
const MatrixFree< dim, number > * data
 Matrix-free object.
 
std::vector< std::vector< unsigned int > > edge_constrained_indices
 Indices of DoFs on edge in case the operator is used in GMG context.
 
std::shared_ptr< dealii::DiagonalMatrix< SolutionVector< number > > > diagonal_entries
 The diagonal matrix.
 
std::shared_ptr< dealii::DiagonalMatrix< SolutionVector< number > > > inverse_diagonal_entries
 The inverse diagonal matrix.
 

Detailed Description

template<unsigned int dim, unsigned int degree, typename number>
class MFOperator< dim, degree, number >

This class exists to evaluate a single user-defined operator for the matrix-free implementation of some PDE.

Note
Information such as the pde operator are passed in at construction/initialization rather than being passed in during function calls because in certain contexts (eg. GMG,) the operator gets called by a dealii function, rather than by prismspf, so it needs to act as a standalone operator.
Template Parameters
dimThe number of dimensions in the problem.
degreeThe polynomial degree of the shape functions.
numberDatatype to use for LinearAlgebra::distributed::Vector<number>. Either double or float.

Member Typedef Documentation

◆ Operator

template<unsigned int dim, unsigned int degree, typename number >
using MFOperator< dim, degree, number >::Operator = void (PDEOperatorBase<dim, degree, number>::*)( FieldContainer<dim, degree, number> &, const SimulationTimer &, unsigned int ) const

◆ ScalarValue

template<unsigned int dim, unsigned int degree, typename number >
using MFOperator< dim, degree, number >::ScalarValue = dealii::VectorizedArray<number>

◆ Value

template<unsigned int dim, unsigned int degree, typename number >
template<TensorRank Rank>
using MFOperator< dim, degree, number >::Value = std::conditional_t<Rank == TensorRank::Scalar, ScalarValue, dealii::Tensor<int(Rank), dim, ScalarValue> >

◆ VectorValue

template<unsigned int dim, unsigned int degree, typename number >
using MFOperator< dim, degree, number >::VectorValue = dealii::Tensor<1, dim, ScalarValue>

Constructor & Destructor Documentation

◆ MFOperator()

template<unsigned int dim, unsigned int degree, typename number >
MFOperator< dim, degree, number >::MFOperator ( const PDEOperatorBase< dim, degree, number > &  operator_owner,
Operator  oper,
const std::vector< FieldAttributes > &  _field_attributes,
const SolutionIndexer< dim, number > &  _solution_indexer,
unsigned int  _relative_level,
DependencyMap  _dependency_map,
const SimulationTimer _sim_timer 
)
inlineexplicit

Constructor.

Note
It might be better to provide a SolveContext object instead of individual components

Member Function Documentation

◆ clear()

template<unsigned int dim, unsigned int degree, typename number >
void MFOperator< dim, degree, number >::clear ( )

Release all memory and return to state like having called the default constructor.

◆ compute_local_operator()

template<unsigned int dim, unsigned int degree, typename number >
void MFOperator< dim, degree, number >::compute_local_operator ( const MatrixFree< dim, number > &  _data,
BlockVector< number > &  dst,
const BlockVector< number > &  src,
const std::pair< unsigned int, unsigned int > &  cell_range 
) const
private

Calls user-defined operator.

Note
requires dst is not ghosted

◆ compute_operator()

template<unsigned int dim, unsigned int degree, typename number >
PRISMS_PF_BEGIN_NAMESPACE void MFOperator< dim, degree, number >::compute_operator ( BlockVector< number > &  dst,
const BlockVector< number > &  src = BlockVector<number>() 
) const

Calls cell_loop on function that calls user-defined operator.

Note
requires dst is not ghosted

◆ el()

template<unsigned int dim, unsigned int degree, typename number >
number MFOperator< dim, degree, number >::el ( const unsigned int row,
const unsigned int col 
) const

Return the value of the matrix entry. This function is only valid when row == col and when the diagonal is initialized. Additionally, this is only used so that we may compile. Trying to use this function will throw an error.

◆ get_matrix_diagonal_inverse()

template<unsigned int dim, unsigned int degree, typename number >
const std::shared_ptr< dealii::DiagonalMatrix< SolutionVector< number > > > & MFOperator< dim, degree, number >::get_matrix_diagonal_inverse ( ) const

Get read access to the inverse diagonal of this operator.

◆ get_matrix_free()

template<unsigned int dim, unsigned int degree, typename number >
const MatrixFree< dim, number > * MFOperator< dim, degree, number >::get_matrix_free ( ) const

Set constrained entries to one.

Get read access to the MatrixFree<dim, number> object stored with this operator.

◆ identity()

template<unsigned int dim, unsigned int degree, typename number >
template<TensorRank Rank>
Value< Rank > MFOperator< dim, degree, number >::identity ( )
inline

◆ initialize()

template<unsigned int dim, unsigned int degree, typename number >
void MFOperator< dim, degree, number >::initialize ( const GroupSolutionHandler< dim, number > &  dst_solution)
inline

Initialize.

Note
This will look stylistically strange. We pass in the solution handler for the fields being solved here, but we don't actually use any of the field data from it. This is because the purpose of this MFOperator class is to provide an operator with the signature vmult(VectorType &dst, const VectorType &src). Because we are using block vectors, for the MFOperator to work, it needs to have access to the index mapping in addition to the matrix_free object. Both are stored in the solution handler.

Additionally, we modify dependency_map to include an entry for every field being solved. This is to avoid a troublesome problem downstream in FieldContainer, where we only want to initialize FEEvals for what is needed. (There could be a better way of handling this, but this is the least complicated for now.)

◆ m()

template<unsigned int dim, unsigned int degree, typename number >
dealii::types::global_dof_index MFOperator< dim, degree, number >::m ( ) const

Return the number of DoFs.

◆ set_scaling_diagonal()

template<unsigned int dim, unsigned int degree, typename number >
void MFOperator< dim, degree, number >::set_scaling_diagonal ( bool  scale,
const std::vector< const SolutionVector< number > * > &  diagonal 
)
inline

Set scaling diagonal.

◆ Tvmult()

template<unsigned int dim, unsigned int degree, typename number >
void MFOperator< dim, degree, number >::Tvmult ( BlockVector< number > &  dst,
const BlockVector< number > &  src 
) const

Transpose matrix-vector multiplication.

◆ vmult()

template<unsigned int dim, unsigned int degree, typename number >
void MFOperator< dim, degree, number >::vmult ( BlockVector< number > &  dst,
const BlockVector< number > &  src 
) const

Matrix-vector multiplication.

Note
requires dst is not ghosted

◆ zero()

template<unsigned int dim, unsigned int degree, typename number >
template<TensorRank Rank>
Value< Rank > MFOperator< dim, degree, number >::zero ( )
inline

Member Data Documentation

◆ data

template<unsigned int dim, unsigned int degree, typename number >
const MatrixFree<dim, number>* MFOperator< dim, degree, number >::data
private

Matrix-free object.

◆ dependency_map

template<unsigned int dim, unsigned int degree, typename number >
DependencyMap MFOperator< dim, degree, number >::dependency_map
private

Which fields should be available to the solve.

◆ diagonal_entries

template<unsigned int dim, unsigned int degree, typename number >
std::shared_ptr<dealii::DiagonalMatrix<SolutionVector<number> > > MFOperator< dim, degree, number >::diagonal_entries
private

The diagonal matrix.

◆ edge_constrained_indices

template<unsigned int dim, unsigned int degree, typename number >
std::vector<std::vector<unsigned int> > MFOperator< dim, degree, number >::edge_constrained_indices
private

Indices of DoFs on edge in case the operator is used in GMG context.

◆ field_attributes

template<unsigned int dim, unsigned int degree, typename number >
std::vector<FieldAttributes> MFOperator< dim, degree, number >::field_attributes
private

The attribute list of the relevant variables.

◆ field_to_block_index

template<unsigned int dim, unsigned int degree, typename number >
std::vector<unsigned int> MFOperator< dim, degree, number >::field_to_block_index
private

Mapping from field index to block index (only for dst).

◆ inverse_diagonal_entries

template<unsigned int dim, unsigned int degree, typename number >
std::shared_ptr<dealii::DiagonalMatrix<SolutionVector<number> > > MFOperator< dim, degree, number >::inverse_diagonal_entries
private

The inverse diagonal matrix.

◆ pde_op

template<unsigned int dim, unsigned int degree, typename number >
Operator MFOperator< dim, degree, number >::pde_op
private

The actual PDE operator function ptr (eg. compute_rhs) for user defined PDEs.

◆ pde_operator

template<unsigned int dim, unsigned int degree, typename number >
const PDEOperatorBase<dim, degree, number>* MFOperator< dim, degree, number >::pde_operator
private

PDE operator object (owning class instance of pde_op) for user defined PDEs.

◆ relative_level

template<unsigned int dim, unsigned int degree, typename number >
unsigned int MFOperator< dim, degree, number >::relative_level
private

Level so that correct fields are read from indexer.

◆ scale_by_diagonal

template<unsigned int dim, unsigned int degree, typename number >
bool MFOperator< dim, degree, number >::scale_by_diagonal = false
private

Whether or not to scale after operator result.

◆ scaling_diagonal

template<unsigned int dim, unsigned int degree, typename number >
std::vector<const SolutionVector<number> *> MFOperator< dim, degree, number >::scaling_diagonal
private

Result of operator gets scaled by this (invm for explicit fields)

◆ sim_timer

template<unsigned int dim, unsigned int degree, typename number >
const SimulationTimer* MFOperator< dim, degree, number >::sim_timer
private

Simulation timer.

◆ solution_indexer

template<unsigned int dim, unsigned int degree, typename number >
const SolutionIndexer<dim, number>* MFOperator< dim, degree, number >::solution_indexer
private

Read-access to fields.

◆ solve_group

template<unsigned int dim, unsigned int degree, typename number >
SolveGroup MFOperator< dim, degree, number >::solve_group
private

The group being solved.


The documentation for this class was generated from the following files: