Note: this is documentation for an old release. View the latest documentation at docs.fenicsproject.org/dolfinx/v0.9.0/cpp/doxygen/d9/dc0/fem_2utils_8h.html
DOLFINx  0.5.1
DOLFINx C++ interface
Classes | Namespaces | Functions
utils.h File Reference

Functions supporting finite element method operations. More...

Go to the source code of this file.

Namespaces

 dolfinx::common
 Miscellaneous classes, functions and types.
 
 dolfinx::mesh
 Mesh data structures and algorithms on meshes.
 
 dolfinx::fem
 Finite element method functionality.
 

Functions

template<typename T >
std::vector< std::vector< std::array< std::shared_ptr< const FunctionSpace >, 2 > > > extract_function_spaces (const std::vector< std::vector< const Form< T > * >> &a)
 Extract test (0) and trial (1) function spaces pairs for each bilinear form for a rectangular array of forms. More...
 
la::SparsityPattern create_sparsity_pattern (const mesh::Topology &topology, const std::array< std::reference_wrapper< const DofMap >, 2 > &dofmaps, const std::set< IntegralType > &integrals)
 Create a sparsity pattern for a given form. More...
 
template<typename T >
la::SparsityPattern create_sparsity_pattern (const Form< T > &a)
 Create a sparsity pattern for a given form. More...
 
ElementDofLayout create_element_dof_layout (const ufcx_dofmap &dofmap, const mesh::CellType cell_type, const std::vector< int > &parent_map={})
 Create an ElementDofLayout from a ufcx_dofmap.
 
DofMap create_dofmap (MPI_Comm comm, const ElementDofLayout &layout, mesh::Topology &topology, const std::function< std::vector< int >(const graph::AdjacencyList< std::int32_t > &)> &reorder_fn, const FiniteElement &element)
 Create a dof map on mesh. More...
 
std::vector< std::string > get_coefficient_names (const ufcx_form &ufcx_form)
 Get the name of each coefficient in a UFC form. More...
 
std::vector< std::string > get_constant_names (const ufcx_form &ufcx_form)
 Get the name of each constant in a UFC form. More...
 
template<typename T >
Form< T > create_form (const ufcx_form &ufcx_form, const std::vector< std::shared_ptr< const FunctionSpace >> &spaces, const std::vector< std::shared_ptr< const Function< T >>> &coefficients, const std::vector< std::shared_ptr< const Constant< T >>> &constants, const std::map< IntegralType, const mesh::MeshTags< int > * > &subdomains, const std::shared_ptr< const mesh::Mesh > &mesh=nullptr)
 Create a Form from UFC input. More...
 
template<typename T >
Form< T > create_form (const ufcx_form &ufcx_form, const std::vector< std::shared_ptr< const FunctionSpace >> &spaces, const std::map< std::string, std::shared_ptr< const Function< T >>> &coefficients, const std::map< std::string, std::shared_ptr< const Constant< T >>> &constants, const std::map< IntegralType, const mesh::MeshTags< int > * > &subdomains, const std::shared_ptr< const mesh::Mesh > &mesh=nullptr)
 Create a Form from UFC input. More...
 
template<typename T >
Form< T > create_form (ufcx_form *(*fptr)(), const std::vector< std::shared_ptr< const FunctionSpace >> &spaces, const std::map< std::string, std::shared_ptr< const Function< T >>> &coefficients, const std::map< std::string, std::shared_ptr< const Constant< T >>> &constants, const std::map< IntegralType, const mesh::MeshTags< int > * > &subdomains, const std::shared_ptr< const mesh::Mesh > &mesh=nullptr)
 Create a Form using a factory function that returns a pointer to a ufcx_form. More...
 
FunctionSpace create_functionspace (const std::shared_ptr< mesh::Mesh > &mesh, const basix::FiniteElement &e, int bs, const std::function< std::vector< int >(const graph::AdjacencyList< std::int32_t > &)> &reorder_fn=nullptr)
 Create a FunctionSpace from a Basix element. More...
 
FunctionSpace create_functionspace (ufcx_function_space *(*fptr)(const char *), const std::string &function_name, const std::shared_ptr< mesh::Mesh > &mesh, const std::function< std::vector< int >(const graph::AdjacencyList< std::int32_t > &)> &reorder_fn=nullptr)
 Create a FunctionSpace from UFC data. More...
 
template<typename T , typename Functor >
void pack_coefficient_entity (const std::span< T > &c, int cstride, const Function< T > &u, const std::span< const std::uint32_t > &cell_info, const std::span< const std::int32_t > &entities, std::size_t estride, Functor fetch_cells, std::int32_t offset)
 Pack a single coefficient for a set of active entities. More...
 
template<typename T >
std::pair< std::vector< T >, int > allocate_coefficient_storage (const Form< T > &form, IntegralType integral_type, int id)
 Allocate storage for coefficients of a pair (integral_type, id) from a fem::Form form. More...
 
template<typename T >
std::map< std::pair< IntegralType, int >, std::pair< std::vector< T >, int > > allocate_coefficient_storage (const Form< T > &form)
 Allocate memory for packed coefficients of a Form. More...
 
template<typename T >
void pack_coefficients (const Form< T > &form, IntegralType integral_type, int id, const std::span< T > &c, int cstride)
 Pack coefficients of a Form for a given integral type and domain id. More...
 
template<typename T >
Expression< T > create_expression (const ufcx_expression &expression, const std::vector< std::shared_ptr< const Function< T >>> &coefficients, const std::vector< std::shared_ptr< const Constant< T >>> &constants, const std::shared_ptr< const mesh::Mesh > &mesh=nullptr, const std::shared_ptr< const FunctionSpace > &argument_function_space=nullptr)
 Create Expression from UFC.
 
template<typename T >
Expression< T > create_expression (const ufcx_expression &expression, const std::map< std::string, std::shared_ptr< const Function< T >>> &coefficients, const std::map< std::string, std::shared_ptr< const Constant< T >>> &constants, const std::shared_ptr< const mesh::Mesh > &mesh=nullptr, const std::shared_ptr< const FunctionSpace > &argument_function_space=nullptr)
 Create Expression from UFC input (with named coefficients and constants)
 
template<typename T >
void pack_coefficients (const Form< T > &form, std::map< std::pair< IntegralType, int >, std::pair< std::vector< T >, int >> &coeffs)
 Pack coefficients of a Form. More...
 
template<typename T >
std::pair< std::vector< T >, int > pack_coefficients (const Expression< T > &u, const std::span< const std::int32_t > &cells)
 Pack coefficients of a Expression u for a give list of active cells. More...
 
template<typename U >
std::vector< typename U::scalar_type > pack_constants (const U &u)
 Pack constants of u of generic type U ready for assembly. More...
 

Detailed Description

Functions supporting finite element method operations.

Function Documentation

◆ pack_coefficient_entity()

void dolfinx::fem::impl::pack_coefficient_entity ( const std::span< T > &  c,
int  cstride,
const Function< T > &  u,
const std::span< const std::uint32_t > &  cell_info,
const std::span< const std::int32_t > &  entities,
std::size_t  estride,
Functor  fetch_cells,
std::int32_t  offset 
)

Pack a single coefficient for a set of active entities.

Parameters
[out]cThe coefficient to be packed
[in]cstrideThe total number of coefficient values to pack for each entity
[in]uThe function to extract data from
[in]cell_infoArray of bytes describing which transformation has to be applied on the cell to map it to the reference element
[in]entitiesThe set of active entities
[in]estrideThe stride for each entity in active entities.
[in]fetch_cellsFunction that fetches the cell index for an entity in active_entities (signature: std::function<std::int32_t(E::value_type)>)
[in]offsetThe offset for c