Note: this is documentation for an old release. View the latest documentation at docs.fenicsproject.org/v0.1.0/v0.9.0/cpp
DOLFINx  0.1.0
DOLFINx C++ interface
Public Member Functions | Public Attributes | List of all members
dolfinx::fem::Function< T > Class Template Reference

This class represents a function \( u_h \) in a finite element function space \( V_h \), given by. More...

#include <Function.h>

Public Member Functions

 Function (std::shared_ptr< const FunctionSpace > V)
 Create function on given function space. More...
 
 Function (std::shared_ptr< const FunctionSpace > V, std::shared_ptr< la::Vector< T >> x)
 Create function on given function space with a given vector. More...
 
 Function (const Function &v)=delete
 
 Function (Function &&v)
 Move constructor.
 
virtual ~Function ()
 Destructor.
 
Functionoperator= (Function &&v) noexcept
 Move assignment.
 
Functionoperator= (const Function &v)=delete
 
Function sub (int i) const
 Extract subfunction (view into the Function) More...
 
Function collapse () const
 Collapse a subfunction (view into the Function) to a stand-alone Function. More...
 
std::shared_ptr< const FunctionSpacefunction_space () const
 Return shared pointer to function space. More...
 
Vec vector () const
 Return vector of expansion coefficients as a PETSc Vec. Throws an exception if a PETSc Vec cannot be created due to a type mismatch. More...
 
std::shared_ptr< const la::Vector< T > > x () const
 Underlying vector.
 
std::shared_ptr< la::Vector< T > > x ()
 Underlying vector.
 
void interpolate (const Function< T > &v)
 Interpolate a Function (on possibly non-matching meshes) More...
 
void interpolate (const std::function< xt::xarray< T >(const xt::xtensor< double, 2 > &)> &f)
 Interpolate an expression. More...
 
void eval (const xt::xtensor< double, 2 > &x, const xtl::span< const std::int32_t > &cells, xt::xtensor< T, 2 > &u) const
 Evaluate the Function at points. More...
 
xt::xtensor< T, 2 > compute_point_values () const
 Compute values at all mesh 'nodes'. More...
 
std::size_t id () const
 ID.
 

Public Attributes

std::string name = "u"
 Name.
 

Detailed Description

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

This class represents a function \( u_h \) in a finite element function space \( V_h \), given by.

\[ u_h = \sum_{i=1}^{n} U_i \phi_i \]

where \( \{\phi_i\}_{i=1}^{n} \) is a basis for \( V_h \), and \( U \) is a vector of expansion coefficients for \( u_h \).

Constructor & Destructor Documentation

◆ Function() [1/2]

template<typename T >
dolfinx::fem::Function< T >::Function ( std::shared_ptr< const FunctionSpace V)
inlineexplicit

Create function on given function space.

Parameters
[in]VThe function space

◆ Function() [2/2]

template<typename T >
dolfinx::fem::Function< T >::Function ( std::shared_ptr< const FunctionSpace V,
std::shared_ptr< la::Vector< T >>  x 
)
inline

Create function on given function space with a given vector.

Warning: This constructor is intended for internal library use only

Parameters
[in]VThe function space
[in]xThe vector

Member Function Documentation

◆ collapse()

template<typename T >
Function dolfinx::fem::Function< T >::collapse ( ) const
inline

Collapse a subfunction (view into the Function) to a stand-alone Function.

Returns
New collapsed Function

◆ compute_point_values()

template<typename T >
xt::xtensor<T, 2> dolfinx::fem::Function< T >::compute_point_values ( ) const
inline

Compute values at all mesh 'nodes'.

Returns
The values at all geometric points

◆ eval()

template<typename T >
void dolfinx::fem::Function< T >::eval ( const xt::xtensor< double, 2 > &  x,
const xtl::span< const std::int32_t > &  cells,
xt::xtensor< T, 2 > &  u 
) const
inline

Evaluate the Function at points.

Parameters
[in]xThe coordinates of the points. It has shape (num_points, 3).
[in]cellsAn array of cell indices. cells[i] is the index of the cell that contains the point x(i). Negative cell indices can be passed, and the corresponding point will be ignored.
[in,out]uThe values at the points. Values are not computed for points with a negative cell index. This argument must be passed with the correct size.

◆ function_space()

template<typename T >
std::shared_ptr<const FunctionSpace> dolfinx::fem::Function< T >::function_space ( ) const
inline

Return shared pointer to function space.

Returns
The function space

◆ interpolate() [1/2]

template<typename T >
void dolfinx::fem::Function< T >::interpolate ( const Function< T > &  v)
inline

Interpolate a Function (on possibly non-matching meshes)

Parameters
[in]vThe function to be interpolated.

◆ interpolate() [2/2]

template<typename T >
void dolfinx::fem::Function< T >::interpolate ( const std::function< xt::xarray< T >(const xt::xtensor< double, 2 > &)> &  f)
inline

Interpolate an expression.

Parameters
[in]fThe expression to be interpolated

◆ sub()

template<typename T >
Function dolfinx::fem::Function< T >::sub ( int  i) const
inline

Extract subfunction (view into the Function)

Parameters
[in]iIndex of subfunction
Returns
The subfunction

◆ vector()

template<typename T >
Vec dolfinx::fem::Function< T >::vector ( ) const
inline

Return vector of expansion coefficients as a PETSc Vec. Throws an exception if a PETSc Vec cannot be created due to a type mismatch.

Returns
The vector of expansion coefficients

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