DOLFINx 0.10.0.0
DOLFINx C++ interface
Loading...
Searching...
No Matches
utils.h File Reference

Functions supporting finite element method operations. More...

#include "Constant.h"
#include "CoordinateElement.h"
#include "DofMap.h"
#include "ElementDofLayout.h"
#include "Expression.h"
#include "Form.h"
#include "Function.h"
#include "FunctionSpace.h"
#include "sparsitybuild.h"
#include <algorithm>
#include <array>
#include <concepts>
#include <dolfinx/common/types.h>
#include <dolfinx/la/SparsityPattern.h>
#include <dolfinx/mesh/Topology.h>
#include <dolfinx/mesh/cell_types.h>
#include <dolfinx/mesh/utils.h>
#include <functional>
#include <memory>
#include <optional>
#include <set>
#include <span>
#include <stdexcept>
#include <string>
#include <tuple>
#include <type_traits>
#include <ufcx.h>
#include <utility>
#include <vector>
Include dependency graph for utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  dolfinx
 Top-level namespace.
 
namespace  dolfinx::common
 Miscellaneous classes, functions and types.
 
namespace  dolfinx::fem
 Finite element method functionality.
 

Functions

template<int num_cells>
std::array< std::int32_t, 2 *num_cells > get_cell_facet_pairs (std::int32_t f, std::span< const std::int32_t > cells, const graph::AdjacencyList< std::int32_t > &c_to_f)
 
std::vector< std::int32_t > compute_integration_domains (IntegralType integral_type, const mesh::Topology &topology, std::span< const std::int32_t > entities)
 Given an integral type and a set of entities, computes and return data for the entities that should be integrated over.
 
template<dolfinx::scalar T, std::floating_point U>
std::vector< std::vector< std::array< std::shared_ptr< const FunctionSpace< U > >, 2 > > > extract_function_spaces (const std::vector< std::vector< const Form< T, U > * > > &a)
 Extract test (0) and trial (1) function spaces pairs for each bilinear form for a rectangular array of forms.
 
template<dolfinx::scalar T, std::floating_point U>
la::SparsityPattern create_sparsity_pattern (const Form< T, U > &a)
 Create a sparsity pattern for a given form.
 
template<dolfinx::scalar T, std::floating_point U>
void build_sparsity_pattern (la::SparsityPattern &pattern, const Form< T, U > &a)
 Build a sparsity pattern for a given form.
 
template<std::floating_point T>
ElementDofLayout create_element_dof_layout (const fem::FiniteElement< T > &element, const std::vector< int > &parent_map={})
 Create an ElementDofLayout from a FiniteElement.
 
DofMap create_dofmap (MPI_Comm comm, const ElementDofLayout &layout, mesh::Topology &topology, std::function< void(std::span< std::int32_t >, std::uint32_t)> permute_inv, std::function< std::vector< int >(const graph::AdjacencyList< std::int32_t > &)> reorder_fn)
 Create a dof map on mesh.
 
std::vector< DofMapcreate_dofmaps (MPI_Comm comm, const std::vector< ElementDofLayout > &layouts, mesh::Topology &topology, std::function< void(std::span< std::int32_t >, std::uint32_t)> permute_inv, std::function< std::vector< int >(const graph::AdjacencyList< std::int32_t > &)> reorder_fn)
 Create a set of dofmaps on a given topology.
 
std::vector< std::string > get_coefficient_names (const ufcx_form &ufcx_form)
 
std::vector< std::string > get_constant_names (const ufcx_form &ufcx_form)
 Get the name of each constant in a UFC form.
 
template<dolfinx::scalar T, std::floating_point U = scalar_value_t<T>>
Form< T, U > create_form_factory (const std::vector< std::reference_wrapper< const ufcx_form > > &ufcx_forms, const std::vector< std::shared_ptr< const FunctionSpace< U > > > &spaces, const std::vector< std::shared_ptr< const Function< T, U > > > &coefficients, const std::vector< std::shared_ptr< const Constant< T > > > &constants, const std::map< IntegralType, std::vector< std::pair< std::int32_t, std::span< const std::int32_t > > > > &subdomains, 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 Form from UFCx input with coefficients and constants passed in the required order.
 
template<dolfinx::scalar T, std::floating_point U = scalar_value_t<T>>
Form< T, U > create_form (const ufcx_form &ufcx_form, const std::vector< std::shared_ptr< const FunctionSpace< U > > > &spaces, const std::map< std::string, std::shared_ptr< const Function< T, U > > > &coefficients, const std::map< std::string, std::shared_ptr< const Constant< T > > > &constants, const std::map< IntegralType, std::vector< std::pair< std::int32_t, std::span< const std::int32_t > > > > &subdomains, 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 Form from UFC input with coefficients and constants resolved by name.
 
template<dolfinx::scalar T, std::floating_point U = scalar_value_t<T>>
Form< T, U > create_form (ufcx_form *(*fptr)(), const std::vector< std::shared_ptr< const FunctionSpace< U > > > &spaces, const std::map< std::string, std::shared_ptr< const Function< T, U > > > &coefficients, const std::map< std::string, std::shared_ptr< const Constant< T > > > &constants, const std::map< IntegralType, std::vector< std::pair< std::int32_t, std::span< const std::int32_t > > > > &subdomains, 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 Form using a factory function that returns a pointer to a ufcx_form.
 
template<std::floating_point T>
FunctionSpace< T > create_functionspace (std::shared_ptr< mesh::Mesh< T > > mesh, std::shared_ptr< const fem::FiniteElement< T > > e, std::function< std::vector< int >(const graph::AdjacencyList< std::int32_t > &)> reorder_fn=nullptr)
 NEW Create a function space from a fem::FiniteElement.
 
template<dolfinx::scalar T, std::floating_point U = scalar_value_t<T>>
Expression< T, U > create_expression (const ufcx_expression &e, const std::vector< std::shared_ptr< const Function< T, U > > > &coefficients, const std::vector< std::shared_ptr< const Constant< T > > > &constants, std::shared_ptr< const FunctionSpace< U > > argument_space=nullptr)
 Create Expression from UFC.
 
template<dolfinx::scalar T, std::floating_point U = scalar_value_t<T>>
Expression< T, U > create_expression (const ufcx_expression &e, const std::map< std::string, std::shared_ptr< const Function< T, U > > > &coefficients, const std::map< std::string, std::shared_ptr< const Constant< T > > > &constants, std::shared_ptr< const FunctionSpace< U > > argument_space=nullptr)
 Create Expression from UFC input (with named coefficients and constants).
 

Detailed Description

Functions supporting finite element method operations.

Function Documentation

◆ get_cell_facet_pairs()

template<int num_cells>
std::array< std::int32_t, 2 *num_cells > get_cell_facet_pairs ( std::int32_t f,
std::span< const std::int32_t > cells,
const graph::AdjacencyList< std::int32_t > & c_to_f )

Helper function to get an array of of (cell, local_facet) pairs corresponding to a given facet index.

Parameters
[in]fFacet index
[in]cellsList of cells incident to the facet
[in]c_to_fCell to facet connectivity
Returns
Vector of (cell, local_facet) pairs