DOLFIN-X
DOLFIN-X C++ interface
Public Member Functions | List of all members
dolfinx::fem::Form< T > Class Template Reference

Class for variational forms. More...

#include <Form.h>

Public Member Functions

 Form (const std::vector< std::shared_ptr< const function::FunctionSpace >> &function_spaces, const FormIntegrals< T > &integrals, const FormCoefficients< T > &coefficients, const std::vector< std::pair< std::string, std::shared_ptr< const function::Constant< T >>>> constants)
 Create form. More...
 
 Form (const std::vector< std::shared_ptr< const function::FunctionSpace >> &function_spaces, bool need_mesh_permutation_data)
 
 Form (const Form &form)=delete
 Copy constructor.
 
 Form (Form &&form)=default
 Move constructor.
 
virtual ~Form ()=default
 Destructor.
 
int rank () const
 Rank of the form (bilinear form = 2, linear form = 1, functional = 0, etc) More...
 
void set_coefficients (const std::map< std::string, std::shared_ptr< const function::Function< T >>> &coefficients)
 Set coefficient with given name. More...
 
void set_constants (const std::map< std::string, std::shared_ptr< const function::Constant< T >>> &constants)
 Set constants based on their names. Names of the constants must agree with their names in UFL file.
 
bool all_constants_set () const
 Check if all constants associated with the form have been set. More...
 
std::set< std::string > get_unset_constants () const
 Return names of any constants that have not been set. More...
 
void set_mesh (const std::shared_ptr< const mesh::Mesh > &mesh)
 
std::shared_ptr< const mesh::Meshmesh () const
 Extract common mesh from form. More...
 
std::shared_ptr< const function::FunctionSpacefunction_space (int i) const
 Return function space for given argument. More...
 
std::vector< std::shared_ptr< const function::FunctionSpace > > function_spaces () const
 Return function spaces for all arguments. More...
 
void set_tabulate_tensor (IntegralType type, int i, const std::function< void(T *, const T *, const T *, const double *, const int *, const std::uint8_t *, const std::uint32_t)> &fn)
 Register the function for 'tabulate_tensor' for cell integral i.
 
FormCoefficients< T > & coefficients ()
 Access coefficients.
 
const FormCoefficients< T > & coefficients () const
 Access coefficients.
 
const FormIntegrals< T > & integrals () const
 Access form integrals.
 
std::vector< std::pair< std::string, std::shared_ptr< const function::Constant< T > > > > & constants ()
 Access constants. More...
 
const std::vector< std::pair< std::string, std::shared_ptr< const function::Constant< T > > > > & constants () const
 Access constants. More...
 

Detailed Description

template<typename T>
class dolfinx::fem::Form< T >

Class for 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).

Constructor & Destructor Documentation

◆ Form() [1/2]

template<typename T >
dolfinx::fem::Form< T >::Form ( const std::vector< std::shared_ptr< const function::FunctionSpace >> &  function_spaces,
const FormIntegrals< T > &  integrals,
const FormCoefficients< T > &  coefficients,
const std::vector< std::pair< std::string, std::shared_ptr< const function::Constant< T >>>>  constants 
)
inline

Create form.

Parameters
[in]function_spacesFunction Spaces
[in]integrals
[in]coefficients
[in]constantsVector of pairs (name, constant). The index in the vector is the position of the constant in the original (nonsimplified) form.

◆ Form() [2/2]

template<typename T >
dolfinx::fem::Form< T >::Form ( const std::vector< std::shared_ptr< const function::FunctionSpace >> &  function_spaces,
bool  need_mesh_permutation_data 
)
inline
Warning
Experimental

Create form (no UFC integrals). Integrals can be attached later using FormIntegrals::set_cell_tabulate_tensor.

Parameters
[in]function_spacesVector of function spaces
[in]need_mesh_permutation_dataSet to true if mesh entity permutation data is required

Member Function Documentation

◆ all_constants_set()

template<typename T >
bool dolfinx::fem::Form< T >::all_constants_set ( ) const
inline

Check if all constants associated with the form have been set.

Returns
True if all Form constants have been set

◆ constants() [1/2]

template<typename T >
std::vector< std::pair<std::string, std::shared_ptr<const function::Constant<T> > > >& dolfinx::fem::Form< T >::constants ( )
inline

Access constants.

Returns
Vector of attached constants with their names. Names are used to set constants in user's c++ code. Index in the vector is the position of the constant in the original (nonsimplified) form.

◆ constants() [2/2]

template<typename T >
const std::vector< std::pair<std::string, std::shared_ptr<const function::Constant<T> > > >& dolfinx::fem::Form< T >::constants ( ) const
inline

Access constants.

Returns
Vector of attached constants with their names. Names are used to set constants in user's c++ code. Index in the vector is the position of the constant in the original (nonsimplified) form.

◆ function_space()

template<typename T >
std::shared_ptr<const function::FunctionSpace> dolfinx::fem::Form< T >::function_space ( int  i) const
inline

Return function space for given argument.

Parameters
[in]iIndex of the argument
Returns
Function space

◆ function_spaces()

template<typename T >
std::vector<std::shared_ptr<const function::FunctionSpace> > dolfinx::fem::Form< T >::function_spaces ( ) const
inline

Return function spaces for all arguments.

Returns
Function spaces

◆ get_unset_constants()

template<typename T >
std::set<std::string> dolfinx::fem::Form< T >::get_unset_constants ( ) const
inline

Return names of any constants that have not been set.

Returns
Names of unset constants

◆ mesh()

template<typename T >
std::shared_ptr<const mesh::Mesh> dolfinx::fem::Form< T >::mesh ( ) const
inline

Extract common mesh from form.

Returns
The mesh

◆ rank()

template<typename T >
int dolfinx::fem::Form< T >::rank ( ) const
inline

Rank of the form (bilinear form = 2, linear form = 1, functional = 0, etc)

Returns
The rank of the form

◆ set_coefficients()

template<typename T >
void dolfinx::fem::Form< T >::set_coefficients ( const std::map< std::string, std::shared_ptr< const function::Function< T >>> &  coefficients)
inline

Set coefficient with given name.

Parameters
[in]coefficientsMap from coefficient name to the coefficient

◆ set_mesh()

template<typename T >
void dolfinx::fem::Form< T >::set_mesh ( const std::shared_ptr< const mesh::Mesh > &  mesh)
inline
Todo:
Remove this function and make sure the mesh can be set via the constructor

Set mesh, necessary for functionals when there are no function spaces

Parameters
[in]meshThe mesh

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