SERiF v0.0.1a
Stellar Evolution and Rotation in Four Dimensions
Loading...
Searching...
No Matches
serif::discretization::backend::mfem::TensorBasis Class Referencefinal

A class that represents a tensor basis for a finite element. This class is used to evaluate the basis functions and their derivatives at a set of reference points. More...

#include <tensor_basis.hpp>

Collaboration diagram for serif::discretization::backend::mfem::TensorBasis:
[legend]

Classes

struct  Product
 A struct that represents a product of one-dimensional basis functions. More...
 

Public Member Functions

int points () const noexcept
 Get the number of quadrature points in the Cartesian rule.
 
int dofs () const noexcept
 Get the number of degrees of freedom in the tensor basis.
 
int components () const noexcept
 Get the number of canonical output components per point in the tensor basis.
 
void apply (const ::mfem::Vector &input, ::mfem::Vector &output, TensorWorkspace &workspace, const bool transpose=false) const
 Evaluate canonical samples, or their coordinate transpose, with caller-owned scratch.
 
void apply_many (const ::mfem::Vector &input, ::mfem::Vector &output, const int lanes, TensorWorkspace &workspace, const bool transpose=false) const
 apply() for several coefficient vectors at once, stored lane-interleaved (entry i of lane j at i * lanes + j).
 

Static Public Member Functions

static std::shared_ptr< const TensorBasis > make (const ::mfem::FiniteElement &element, const ::mfem::IntegrationRule &rule, const ReferenceOperation operation, const int copies, const ElementReconstruction *reconstruction=nullptr)
 Return no tensor plan unless its factorization agrees with MFEM's canonical basis.
 

Private Member Functions

bool agrees_with (const ::mfem::FiniteElement &element, const ::mfem::IntegrationRule &rule, const ReferenceOperation operation, const ElementReconstruction *reconstruction) const
 Verify signed ordering and every requested basis entry before enabling the fast path.
 

Static Private Member Functions

static void contract_axis (const ::mfem::DenseMatrix &factor, const int axis, const std::array< int, 3 > &shape, const ::mfem::Vector &input, ::mfem::Vector &output, const bool transpose, const int lanes=1)
 

Private Attributes

int m_points {0}
 The number of quadrature points in the Cartesian rule.
 
int m_dofs {0}
 The number of degrees of freedom in the tensor basis.
 
int m_components {0}
 The number of canonical output components per point in the tensor basis.
 
std::vector< Product > m_products
 The products of one-dimensional basis functions for each axis. (TOOD: consider if this should be a heap allocated vector of it this could be put on the stack somehow)
 

Detailed Description

A class that represents a tensor basis for a finite element. This class is used to evaluate the basis functions and their derivatives at a set of reference points.

Member Function Documentation

◆ agrees_with()

bool serif::discretization::backend::mfem::TensorBasis::agrees_with ( const ::mfem::FiniteElement & element,
const ::mfem::IntegrationRule & rule,
const ReferenceOperation operation,
const ElementReconstruction * reconstruction ) const
inlinenodiscardprivate

Verify signed ordering and every requested basis entry before enabling the fast path.

Verify that the signed ordering and every requested basis entry agrees with MFEM's canonical basis.

Parameters
elementThe finite element to verify against.
ruleThe integration rule to use for evaluating the basis functions.
operationThe reference operation to apply (e.g., value, gradient).
Returns
True if the tensor basis agrees with MFEM's canonical basis, false otherwise.

◆ apply()

void serif::discretization::backend::mfem::TensorBasis::apply ( const ::mfem::Vector & input,
::mfem::Vector & output,
TensorWorkspace & workspace,
const bool transpose = false ) const
inline

Evaluate canonical samples, or their coordinate transpose, with caller-owned scratch.

Apply the tensor basis to an input vector and store the results in an output vector. This function performs the tensor contraction of the input vector with the tensor basis.

Parameters
inputThe input vector to be contracted with the tensor basis.
outputThe output vector to store the result of the contraction. (Owned by the caller)
workspaceThe workspace to use for the contraction. (Owned by the caller)
transposeWhether to transpose the contraction (default is false).
Precondition
The input vector must have a size equal to the number of degrees of freedom in the tensor basis if transpose is false, or equal to the number of points times the number of components if transpose is true.
The output vector must be constructed
Postcondition
The output vector will have a size equal to the number of points times the number of components if transpose is false, or equal to the number of degrees of freedom in the tensor basis if transpose is true.
The output vector will contain the result of the tensor contraction of the input vector with the tensor basis.

◆ apply_many()

void serif::discretization::backend::mfem::TensorBasis::apply_many ( const ::mfem::Vector & input,
::mfem::Vector & output,
const int lanes,
TensorWorkspace & workspace,
const bool transpose = false ) const
inline

apply() for several coefficient vectors at once, stored lane-interleaved (entry i of lane j at i * lanes + j).

Note
The lanes form the fastest tensor index, so every lane is contracted with exactly the operations and summation order apply() uses for it alone; only the loops are shared.

◆ components()

int serif::discretization::backend::mfem::TensorBasis::components ( ) const
inlinenodiscardnoexcept

Get the number of canonical output components per point in the tensor basis.

Returns
The number of canonical output components per point in the tensor basis.

◆ contract_axis()

static void serif::discretization::backend::mfem::TensorBasis::contract_axis ( const ::mfem::DenseMatrix & factor,
const int axis,
const std::array< int, 3 > & shape,
const ::mfem::Vector & input,
::mfem::Vector & output,
const bool transpose,
const int lanes = 1 )
inlinestaticprivate

@breif apply one factor along one tensor axis, teh other two indices will remain unchanged

Parameters
factorThe one-dimensional basis function to apply along the specified axis.
axisThe axis along which to apply the factor (0, 1, or 2).
shapeThe shape of the input tensor (number of points along each axis).
inputThe input vector to be contracted with the factor.
outputThe output vector to store the result of the contraction.
transposeWhether to transpose the factor matrix before applying it.
lanesNumber of interleaved independent tensors (the fastest index); 1 for a single tensor.
Precondition
The input vector must have a size equal to the product of the dimensions specified in the shape array.
Postcondition
The output vector will have a size equal to the product of the dimensions specified in the next array.
The output vector will contain the result of the contraction of the input vector with the factor along the specified axis.

◆ dofs()

int serif::discretization::backend::mfem::TensorBasis::dofs ( ) const
inlinenodiscardnoexcept

Get the number of degrees of freedom in the tensor basis.

Returns
The number of degrees of freedom in the tensor basis.

◆ make()

static std::shared_ptr< const TensorBasis > serif::discretization::backend::mfem::TensorBasis::make ( const ::mfem::FiniteElement & element,
const ::mfem::IntegrationRule & rule,
const ReferenceOperation operation,
const int copies,
const ElementReconstruction * reconstruction = nullptr )
inlinestaticnodiscard

Return no tensor plan unless its factorization agrees with MFEM's canonical basis.

Make a tensor basis for a given finite element, integration rule, reference operation, and number of copies. This function returns a shared pointer to a TensorBasis object that can be used to do efficient evaluation of the basis functions and their derivatives at reference points.

Parameters
elementThe finite element for which to construct the tensor basis.
ruleThe integration rule to use for evaluating the basis functions.
operationThe reference operation to apply (e.g., value, gradient).
copiesThe number of copies of the basis functions.
Returns
A shared pointer to a TensorBasis object if the tensor basis can be constructed, or an empty shared pointer if it cannot.

◆ points()

int serif::discretization::backend::mfem::TensorBasis::points ( ) const
inlinenodiscardnoexcept

Get the number of quadrature points in the Cartesian rule.

Returns
The number of quadrature points in the Cartesian rule.

Member Data Documentation

◆ m_components

int serif::discretization::backend::mfem::TensorBasis::m_components {0}
private

The number of canonical output components per point in the tensor basis.

◆ m_dofs

int serif::discretization::backend::mfem::TensorBasis::m_dofs {0}
private

The number of degrees of freedom in the tensor basis.

◆ m_points

int serif::discretization::backend::mfem::TensorBasis::m_points {0}
private

The number of quadrature points in the Cartesian rule.

◆ m_products

std::vector<Product> serif::discretization::backend::mfem::TensorBasis::m_products
private

The products of one-dimensional basis functions for each axis. (TOOD: consider if this should be a heap allocated vector of it this could be put on the stack somehow)


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