DOLFINx 0.12.0.0
DOLFINx C++
Loading...
Searching...
No Matches
pack.h File Reference

Functions supporting the packing of coefficient data. More...

#include "Constant.h"
#include "DofMap.h"
#include "FiniteElement.h"
#include "Form.h"
#include "Function.h"
#include "FunctionSpace.h"
#include "traits.h"
#include <array>
#include <basix/mdspan.hpp>
#include <concepts>
#include <dolfinx/mesh/Topology.h>
#include <format>
#include <ranges>
#include <span>
#include <stdexcept>
#include <type_traits>
#include <vector>
Include dependency graph for pack.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::fem
 Finite element method functionality.

Functions

template<int _bs, dolfinx::scalar T>
void pack_impl (std::span< T > coeffs, std::int32_t cell, int bs, std::span< const T > v, std::span< const std::uint32_t > cell_info, const DofMap &dofmap, auto transform)
 Gather a single coefficient's degrees-of-freedom for a single cell and apply its DOF transformation.
template<dolfinx::scalar T, std::floating_point U>
void pack_coefficient_entity (std::span< T > c, int cstride, const Function< T, U > &u, std::span< const std::uint32_t > cell_info, auto cells, std::int32_t offset)
 Pack a single coefficient for a set of active entities.
template<dolfinx::scalar T, std::floating_point U>
std::pair< std::vector< T >, int > allocate_coefficient_storage (const Form< T, U > &form, IntegralType integral_type, int idx)
 Allocate storage for coefficients of a pair (integral_type, idx) from a Form.
template<dolfinx::scalar T, std::floating_point U>
std::map< std::pair< IntegralType, int >, std::pair< std::vector< T >, int > > allocate_coefficient_storage (const Form< T, U > &form)
 Allocate memory for packed coefficients of a Form.
template<dolfinx::scalar T, std::floating_point U>
void pack_coefficients (const Form< T, U > &form, std::map< std::pair< IntegralType, int >, std::pair< std::vector< T >, int > > &coeffs)
 Pack coefficients of a Form.
template<dolfinx::scalar T, std::floating_point U>
std::vector< std::int32_t > extract_coefficient_cells_from_entities (const fem::Function< T, U > &coeff, const mesh::Mesh< U > &mesh, fem::MDSpan2 auto entities, std::optional< std::reference_wrapper< const dolfinx::mesh::EntityMap > > entity_map)
 Given a Function and a related mesh and its integration entities, extract the cell indices of the coefficient mesh.
template<dolfinx::scalar T, std::floating_point U>
void pack_coefficients (const std::vector< std::reference_wrapper< const Function< T, U > > > &coeffs, const mesh::Mesh< U > &mesh, fem::MDSpan2 auto entities, const std::vector< std::reference_wrapper< const dolfinx::mesh::EntityMap > > &entity_maps, std::span< const int > offsets, std::span< T > c)
 Pack coefficient data over a list of cells or facets.
template<typename T>
std::vector< T > pack_constants (const std::vector< std::reference_wrapper< const fem::Constant< T > > > &c)
 Pack constants of an Expression or Form into a single array ready for assembly.
template<typename U>
requires std::convertible_to< U, fem::Expression<typename std::decay_t<U>::scalar_type, typename std::decay_t<U>::geometry_type>>
or std::convertible_to< U, fem::Form<typename std::decay_t<U>::scalar_type, typename std::decay_t<U>::geometry_type>>
std::vector< typename U::scalar_type > pack_constants (const U &u)
 Pack constants of an Expression or Form into a single array ready for assembly.

Detailed Description

Functions supporting the packing of coefficient data.

Function Documentation

◆ pack_coefficient_entity()

template<dolfinx::scalar T, std::floating_point U>
void pack_coefficient_entity ( std::span< T > c,
int cstride,
const Function< T, U > & u,
std::span< const std::uint32_t > cell_info,
auto cells,
std::int32_t offset )

Pack a single coefficient for a set of active entities.

Template Parameters
TScalar type of the coefficient.
UFloating point type of the mesh geometry.
Parameters
[out]cCoefficient storage to pack into, shape (cells.extent(0), cstride), flattened row-major.
[in]cstrideRow length of c, i.e. the total number of coefficient values packed per entity across all coefficients sharing c (not just u's own space_dim values).
[in]uFunction to extract coefficient data from.
[in]cell_infoCell permutation information, indexed by cell (see get_cell_orientation_info).
[in]cellsCell index for each active entity. A negative entry marks an entity absent from u's mesh (e.g. the far side of an interface), and is skipped.
[in]offsetOffset of u's data within each row of c.

◆ pack_impl()

template<int _bs, dolfinx::scalar T>
void pack_impl ( std::span< T > coeffs,
std::int32_t cell,
int bs,
std::span< const T > v,
std::span< const std::uint32_t > cell_info,
const DofMap & dofmap,
auto transform )

Gather a single coefficient's degrees-of-freedom for a single cell and apply its DOF transformation.

Template Parameters
_bsBlock size known at compile time (1, 2, or 3), or -1 to use the runtime block size bs (allows the compiler to specialize and unroll the inner loop for the common block sizes). If _bs >= 0, it must equal bs.
Parameters
[out]coeffsDestination for this cell's packed values.
[in]cellCell to gather DOF values for.
[in]bsRuntime block size of dofmap.
[in]vFunction values to gather from, indexed by process-local DOF (see DofMap::cell_dofs).
[in]cell_infoCell permutation data (see get_cell_orientation_info), passed through to transform.
[in]dofmapDofmap used to look up cell's DOFs.
[in]transformDOF transformation applied to coeffs after gathering (see FiniteElement::dof_transformation_fn).