Note: this is documentation for an old release. View the latest documentation at docs.fenicsproject.org/dolfinx/v0.9.0/cpp/doxygen/d2/db9/classdolfinx_1_1fem_1_1Expression.html
DOLFINx  0.5.1
DOLFINx C++ interface
Classes | Public Types | Public Member Functions | List of all members
Expression< T > Class Template Reference

Represents a mathematical expression evaluated at a pre-defined set of points on the reference cell. This class closely follows the concept of a UFC Expression. More...

#include <Expression.h>

Public Types

using scalar_type = T
 Scalar type (T)
 

Public Member Functions

 Expression (const std::vector< std::shared_ptr< const Function< T >>> &coefficients, const std::vector< std::shared_ptr< const Constant< T >>> &constants, std::span< const double > X, std::array< std::size_t, 2 > Xshape, const std::function< void(T *, const T *, const T *, const scalar_value_type_t *, const int *, const uint8_t *)> fn, const std::vector< int > &value_shape, const std::shared_ptr< const mesh::Mesh > &mesh=nullptr, const std::shared_ptr< const FunctionSpace > argument_function_space=nullptr)
 Create an Expression. More...
 
 Expression (Expression &&form)=default
 Move constructor.
 
virtual ~Expression ()=default
 Destructor.
 
std::shared_ptr< const FunctionSpaceargument_function_space () const
 Get argument function space. More...
 
const std::vector< std::shared_ptr< const Function< T > > > & coefficients () const
 Get coefficients. More...
 
const std::vector< std::shared_ptr< const Constant< T > > > & constants () const
 Get constants. More...
 
std::vector< int > coefficient_offsets () const
 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.
 
template<typename U >
void eval (const std::span< const std::int32_t > &cells, U &values) const
 Evaluate the expression on cells. More...
 
const std::function< void(T *, const T *, const T *, const scalar_value_type_t *, const int *, const uint8_t *)> & get_tabulate_expression () const
 Get function for tabulate_expression. More...
 
std::shared_ptr< const mesh::Meshmesh () const
 Get mesh. More...
 
int value_size () const
 Get value size. More...
 
const std::vector< int > & value_shape () const
 Get value shape. More...
 
std::pair< std::vector< double >, std::array< std::size_t, 2 > > X () const
 Evaluation points on the reference cell. More...
 

Detailed Description

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

Represents a mathematical expression evaluated at a pre-defined set of points on the reference cell. This class closely follows the concept of a UFC Expression.

This functionality can be used to evaluate a gradient of a Function at quadrature points in all cells. This evaluated gradient can then be used as input in to a non-FEniCS function that calculates a material constitutive model.

Constructor & Destructor Documentation

◆ Expression()

Expression ( const std::vector< std::shared_ptr< const Function< T >>> &  coefficients,
const std::vector< std::shared_ptr< const Constant< T >>> &  constants,
std::span< const double >  X,
std::array< std::size_t, 2 >  Xshape,
const std::function< void(T *, const T *, const T *, const scalar_value_type_t *, const int *, const uint8_t *)>  fn,
const std::vector< int > &  value_shape,
const std::shared_ptr< const mesh::Mesh > &  mesh = nullptr,
const std::shared_ptr< const FunctionSpace argument_function_space = nullptr 
)
inline

Create an Expression.

Note
Users should prefer the create_expression factory functions
Parameters
[in]coefficientsCoefficients in the Expression
[in]constantsConstants in the Expression
[in]mesh
[in]Xpoints on reference cell, shape=(number of points, tdim) and storage is row-major.
[in]XshapeShape of X.
[in]fnfunction for tabulating expression
[in]value_shapeshape of expression evaluated at single point
[in]argument_function_spaceFunction space for Argument

Member Function Documentation

◆ argument_function_space()

std::shared_ptr<const FunctionSpace> argument_function_space ( ) const
inline

Get argument function space.

Returns
The argument function space, nullptr if there is no argument.

◆ coefficients()

const std::vector<std::shared_ptr<const Function<T> > >& coefficients ( ) const
inline

Get coefficients.

Returns
Vector of attached coefficients

◆ constants()

const std::vector<std::shared_ptr<const Constant<T> > >& constants ( ) const
inline

Get 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.

◆ eval()

void eval ( const std::span< const std::int32_t > &  cells,
U &  values 
) const
inline

Evaluate the expression on cells.

Parameters
[in]cellsCells on which to evaluate the Expression
[out]valuesA 2D array to store the result. Caller is responsible for correct sizing which should be (num_cells, num_points * value_size * num_all_argument_dofs columns).

◆ get_tabulate_expression()

const std::function<void(T*, const T*, const T*, const scalar_value_type_t*, const int*, const uint8_t*)>& get_tabulate_expression ( ) const
inline

Get function for tabulate_expression.

Returns
fn Function to tabulate expression.

◆ mesh()

std::shared_ptr<const mesh::Mesh> mesh ( ) const
inline

Get mesh.

Returns
The mesh

◆ value_shape()

const std::vector<int>& value_shape ( ) const
inline

Get value shape.

Returns
value shape

◆ value_size()

int value_size ( ) const
inline

Get value size.

Returns
value_size

◆ X()

std::pair<std::vector<double>, std::array<std::size_t, 2> > X ( ) const
inline

Evaluation points on the reference cell.

Returns
Evaluation points

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