DOLFINx 0.8.0
DOLFINx C++ interface
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | List of all members
Form< T, U > Class Template Reference

A representation of finite element variational forms. More...

#include <Form.h>

Public Types

using scalar_type = T
 Scalar type.
 

Public Member Functions

template<typename X >
requires std::is_convertible_v< std::remove_cvref_t<X>, std::map<IntegralType, std::vector<integral_data<T, U>>>>
 Form (const std::vector< std::shared_ptr< const FunctionSpace< U > > > &V, X &&integrals, const std::vector< std::shared_ptr< const Function< scalar_type, U > > > &coefficients, const std::vector< std::shared_ptr< const Constant< scalar_type > > > &constants, bool needs_facet_permutations, const std::map< std::shared_ptr< const mesh::Mesh< U > >, std::span< const std::int32_t > > &entity_maps, std::shared_ptr< const mesh::Mesh< U > > mesh=nullptr)
 Create a finite element form.
 
 Form (const Form &form)=delete
 Copy constructor.
 
 Form (Form &&form)=default
 Move constructor.
 
virtual ~Form ()=default
 Destructor.
 
int rank () const
 Rank of the form.
 
std::shared_ptr< const mesh::Mesh< U > > mesh () const
 Extract common mesh for the form.
 
const std::vector< std::shared_ptr< const FunctionSpace< U > > > & function_spaces () const
 Function spaces for all arguments.
 
std::set< IntegralTypeintegral_types () const
 Get types of integrals in the form.
 
int num_integrals (IntegralType type) const
 Number of integrals on given domain type.
 
std::vector< int > integral_ids (IntegralType type) const
 Get the IDs for integrals (kernels) for given integral type.
 
std::span< const std::int32_t > domain (IntegralType type, int i) const
 Get the list of mesh entity indices for the ith integral (kernel) of a given type.
 
std::vector< std::int32_t > domain (IntegralType type, int i, const mesh::Mesh< U > &mesh) const
 Compute the list of entity indices in mesh for the ith integral (kernel) of a given type (i.e. cell, exterior facet, or interior facet).
 
const std::vector< std::shared_ptr< const Function< T, U > > > & coefficients () const
 Access coefficients.
 
bool needs_facet_permutations () const
 Get bool indicating whether permutation data needs to be passed into these integrals.
 
std::vector< int > coefficient_offsets () const
 Offset for each coefficient expansion array on a cell.
 
const std::vector< std::shared_ptr< const Constant< T > > > & constants () const
 Access constants.
 

Public Attributes

std::function< void(T *, const T *, const T *, const U *, const int *, const uint8_t *) kernel )(IntegralType type, int i) const
 Get the kernel function for integral i on given domain type.
 

Detailed Description

template<dolfinx::scalar T, std::floating_point U = dolfinx::scalar_value_type_t<T>>
class dolfinx::fem::Form< T, U >

A representation of finite element variational forms.

A note on the order of trial and test spaces: FEniCS numbers argument spaces starting with the leading dimension of the corresponding tensor (matrix). In other words, the test space is numbered 0 and the trial space is numbered 1. However, in order to have a notation that agrees with most existing finite element literature, in particular

\[ a = a(u, v) \]

the spaces are numbered from right to left

\[ a: V_1 \times V_0 \rightarrow \mathbb{R} \]

This is reflected in the ordering of the spaces that should be supplied to generated subclasses. In particular, when a bilinear form is initialized, it should be initialized as a(V_1, V_0) = ..., where V_1 is the trial space and V_0 is the test space. However, when a form is initialized by a list of argument spaces (the variable function_spaces in the constructors below), the list of spaces should start with space number 0 (the test space) and then space number 1 (the trial space).

Template Parameters
TScalar type in the form.
UFloat (real) type used for the finite element and geometry.
KernElement kernel.

Constructor & Destructor Documentation

◆ Form()

template<dolfinx::scalar T, std::floating_point U = dolfinx::scalar_value_type_t<T>>
template<typename X >
requires std::is_convertible_v< std::remove_cvref_t<X>, std::map<IntegralType, std::vector<integral_data<T, U>>>>
Form ( const std::vector< std::shared_ptr< const FunctionSpace< U > > > & V,
X && integrals,
const std::vector< std::shared_ptr< const Function< scalar_type, U > > > & coefficients,
const std::vector< std::shared_ptr< const Constant< scalar_type > > > & constants,
bool needs_facet_permutations,
const std::map< std::shared_ptr< const mesh::Mesh< U > >, std::span< const std::int32_t > > & entity_maps,
std::shared_ptr< const mesh::Mesh< U > > mesh = nullptr )
inline

Create a finite element form.

Note
User applications will normally call a factory function rather using this interface directly.
Parameters
[in]VFunction spaces for the form arguments.
[in]integralsThe integrals in the form. For each integral type, there is a list of integral data.
[in]coefficientsCoefficients in the form.
[in]constantsConstants in the form.
[in]needs_facet_permutationsSet to true is any of the integration kernels require cell permutation data.
[in]entity_mapsIf any trial functions, test functions, or coefficients in the form are not defined over the same mesh as the integration domain, entity_maps must be supplied. For each key (a mesh, different to the integration domain mesh) a map should be provided relating the entities in the integration domain mesh to the entities in the key mesh e.g. for a pair (msh, emap) in entity_maps, emap[i] is the entity in msh corresponding to entity i in the integration domain mesh.
[in]meshMesh of the domain. This is required when there are no argument functions from which the mesh can be extracted, e.g. for functionals.
Note
For the single domain case, pass an empty entity_maps.
Precondition
The integral data in integrals must be sorted by domain (domain id).

Member Function Documentation

◆ coefficient_offsets()

template<dolfinx::scalar T, std::floating_point U = dolfinx::scalar_value_type_t<T>>
std::vector< int > coefficient_offsets ( ) const
inline

Offset for each coefficient expansion array on a cell.

Used to pack data for multiple coefficients in a flat array. The last entry is the size required to store all coefficients.

◆ domain() [1/2]

template<dolfinx::scalar T, std::floating_point U = dolfinx::scalar_value_type_t<T>>
std::span< const std::int32_t > domain ( IntegralType type,
int i ) const
inline

Get the list of mesh entity indices for the ith integral (kernel) of a given type.

For IntegralType::cell, returns a list of cell indices.

For IntegralType::exterior_facet, returns a list of (cell_index, local_facet_index) pairs. Data is flattened with row-major layout, shape=(num_facets, 2).

For IntegralType::interior_facet, returns list of tuples of the form (cell_index_0, local_facet_index_0, cell_index_1, local_facet_index_1). Data is flattened with row-major layout, shape=(num_facets, 4).

Parameters
[in]typeIntegral domain type.
[in]iIntegral ID, i.e. (sub)domain index.
Returns
List of active entities for the given integral (kernel).

◆ domain() [2/2]

template<dolfinx::scalar T, std::floating_point U = dolfinx::scalar_value_type_t<T>>
std::vector< std::int32_t > domain ( IntegralType type,
int i,
const mesh::Mesh< U > & mesh ) const
inline

Compute the list of entity indices in mesh for the ith integral (kernel) of a given type (i.e. cell, exterior facet, or interior facet).

Parameters
typeIntegral type.
iIntegral ID, i.e. the (sub)domain index.
meshThe mesh the entities are numbered with respect to.
Returns
List of active entities in mesh for the given integral.

◆ function_spaces()

template<dolfinx::scalar T, std::floating_point U = dolfinx::scalar_value_type_t<T>>
const std::vector< std::shared_ptr< const FunctionSpace< U > > > & function_spaces ( ) const
inline

Function spaces for all arguments.

Returns
Function spaces.

◆ integral_ids()

template<dolfinx::scalar T, std::floating_point U = dolfinx::scalar_value_type_t<T>>
std::vector< int > integral_ids ( IntegralType type) const
inline

Get the IDs for integrals (kernels) for given integral type.

The IDs correspond to the domain IDs which the integrals are defined for in the form. ID=-1 is the default integral over the whole domain.

Parameters
[in]typeIntegral type.
Returns
List of IDs for given integral type.

◆ integral_types()

template<dolfinx::scalar T, std::floating_point U = dolfinx::scalar_value_type_t<T>>
std::set< IntegralType > integral_types ( ) const
inline

Get types of integrals in the form.

Returns
Integrals types.

◆ mesh()

template<dolfinx::scalar T, std::floating_point U = dolfinx::scalar_value_type_t<T>>
std::shared_ptr< const mesh::Mesh< U > > mesh ( ) const
inline

Extract common mesh for the form.

Returns
The mesh.

◆ needs_facet_permutations()

template<dolfinx::scalar T, std::floating_point U = dolfinx::scalar_value_type_t<T>>
bool needs_facet_permutations ( ) const
inline

Get bool indicating whether permutation data needs to be passed into these integrals.

Returns
True if cell permutation data is required

◆ num_integrals()

template<dolfinx::scalar T, std::floating_point U = dolfinx::scalar_value_type_t<T>>
int num_integrals ( IntegralType type) const
inline

Number of integrals on given domain type.

Parameters
[in]typeIntegral type.
Returns
Number of integrals.

◆ rank()

template<dolfinx::scalar T, std::floating_point U = dolfinx::scalar_value_type_t<T>>
int rank ( ) const
inline

Rank of the form.

bilinear form = 2, linear form = 1, functional = 0, etc.

Returns
The rank of the form

Member Data Documentation

◆ kernel

template<dolfinx::scalar T, std::floating_point U = dolfinx::scalar_value_type_t<T>>
std::function< void(T *, const T *, const T *, const U *, const int *, const uint8_t *) kernel) (IntegralType type, int i) const
inline

Get the kernel function for integral i on given domain type.

Parameters
[in]typeIntegral type
[in]iDomain identifier (index)
Returns
Function to call for tabulate_tensor

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