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

Functions supporting assembly of a finite element fem::Form. More...

#include "FunctionSpace.h"
#include "assemble_matrix_impl.h"
#include "assemble_scalar_impl.h"
#include "assemble_vector_impl.h"
#include "pack.h"
#include "traits.h"
#include <algorithm>
#include <array>
#include <basix/mdspan.hpp>
#include <cstddef>
#include <cstdint>
#include <dolfinx/common/IndexMap.h>
#include <dolfinx/common/log.h>
#include <dolfinx/common/sort.h>
#include <dolfinx/common/types.h>
#include <dolfinx/la/utils.h>
#include <dolfinx/mesh/EntityMap.h>
#include <format>
#include <functional>
#include <map>
#include <memory>
#include <optional>
#include <ranges>
#include <span>
#include <stdexcept>
#include <utility>
#include <vector>
Include dependency graph for assembler.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<dolfinx::scalar T>
std::map< std::pair< IntegralType, int >, std::pair< std::span< const T >, int > > make_coefficients_span (const std::map< std::pair< IntegralType, int >, std::pair< std::vector< T >, int > > &coeffs)
 Create a map of std::spans from a map of std::vectors.
template<dolfinx::scalar T, std::floating_point U>
T assemble_scalar (const Form< T, U > &M, std::span< const T > constants, const std::map< std::pair< IntegralType, int >, std::pair< std::span< const T >, int > > &coefficients)
 Assemble functional into scalar.
template<dolfinx::scalar T, std::floating_point U>
T assemble_scalar (const Form< T, U > &M)
 Assemble functional into scalar.
template<typename V, std::floating_point U, dolfinx::scalar T = typename std::remove_cvref_t<V>::value_type>
requires std::is_same_v<typename std::remove_cvref_t<V>::value_type, T>
void assemble_vector (V &&b, const Form< T, U > &L, std::span< const T > constants, const std::map< std::pair< IntegralType, int >, std::pair< std::span< const T >, int > > &coefficients)
 Assemble linear form into a vector.
template<typename V, std::floating_point U, dolfinx::scalar T = typename std::remove_cvref_t<V>::value_type>
requires std::is_same_v<typename std::remove_cvref_t<V>::value_type, T>
void assemble_vector (V &&b, const Form< T, U > &L)
 Assemble linear form into a vector.
template<dolfinx::scalar T, std::floating_point U>
std::vector< std::int8_t > bc_dof_markers (const FunctionSpace< U > &V, const std::vector< std::reference_wrapper< const DirichletBC< T, U > > > &bcs)
 Mark the dofs of V (owned and ghost, unrolled) constrained by the boundary conditions in bcs that are defined on V or a subspace of it.
template<dolfinx::scalar T, std::floating_point U>
std::array< std::span< const std::int8_t >, 2 > bc_dof_markers_pair (const Form< T, U > &a, const std::vector< std::reference_wrapper< const DirichletBC< T, U > > > &bcs, std::array< std::vector< std::int8_t >, 2 > &storage)
 Mark the dofs of the test and trial spaces of a that the boundary conditions in bcs constrain.
template<dolfinx::scalar T, std::floating_point U>
std::pair< std::vector< std::vector< std::int8_t > >, std::vector< std::vector< T > > > bc_lifting_data (const std::vector< std::optional< std::reference_wrapper< const Form< T, U > > > > &a, const std::vector< std::vector< std::reference_wrapper< const DirichletBC< T, U > > > > &bcs1)
 Constrained dof markers and boundary condition values on the trial space of each form in a, as used by apply_lifting().
template<typename V, std::floating_point U = scalar_value_t<typename std::remove_cvref_t<V>::value_type>, dolfinx::scalar T = typename std::remove_cvref_t<V>::value_type>
requires std::is_same_v<typename std::remove_cvref_t<V>::value_type, T>
void apply_lifting (V &&b, const std::vector< std::optional< std::reference_wrapper< const Form< T, U > > > > &a, const std::vector< std::span< const T > > &constants, const std::vector< std::map< std::pair< IntegralType, int >, std::pair< std::span< const T >, int > > > &coeffs, const std::vector< std::span< const std::int8_t > > &bc_markers1, const std::vector< std::span< const T > > &bc_values1, const std::vector< std::span< const T > > &x0, T alpha)
 Modify the right-hand side vector to account for constraints (Dirichlet boundary condition constraints), with the constrained dofs and their values given as arrays.
template<typename V, std::floating_point U = scalar_value_t<typename std::remove_cvref_t<V>::value_type>, dolfinx::scalar T = typename std::remove_cvref_t<V>::value_type>
requires std::is_same_v<typename std::remove_cvref_t<V>::value_type, T>
void apply_lifting (V &&b, const std::vector< std::optional< std::reference_wrapper< const Form< T, U > > > > &a, const std::vector< std::span< const T > > &constants, const std::vector< std::map< std::pair< IntegralType, int >, std::pair< std::span< const T >, int > > > &coeffs, const std::vector< std::vector< std::reference_wrapper< const DirichletBC< T, U > > > > &bcs1, const std::vector< std::span< const T > > &x0, T alpha)
 Modify the right-hand side vector to account for constraints (Dirichlet boundary condition constraints). This modification is known as 'lifting'.
template<typename V, std::floating_point U = scalar_value_t<typename std::remove_cvref_t<V>::value_type>, dolfinx::scalar T = typename std::remove_cvref_t<V>::value_type>
requires std::is_same_v<typename std::remove_cvref_t<V>::value_type, T>
void apply_lifting (V &&b, const std::vector< std::optional< std::reference_wrapper< const Form< T, U > > > > &a, const std::vector< std::vector< std::reference_wrapper< const DirichletBC< T, U > > > > &bcs1, const std::vector< std::span< const T > > &x0, T alpha)
 Modify the right-hand side vector to account for constraints (Dirichlet boundary conditions constraints). This modification is known as 'lifting'.
template<dolfinx::scalar T, std::floating_point U>
void assemble_matrix (la::MatSet< T > auto mat_add, const Form< T, U > &a, std::span< const T > constants, const std::map< std::pair< IntegralType, int >, std::pair< std::span< const T >, int > > &coefficients, std::span< const std::int8_t > dof_marker0, std::span< const std::int8_t > dof_marker1)
 Assemble bilinear form into a matrix. Matrix must already be initialised. Does not zero or finalise the matrix.
template<dolfinx::scalar T, std::floating_point U>
void assemble_matrix (auto mat_add, const Form< T, U > &a, const std::vector< std::reference_wrapper< const DirichletBC< T, U > > > &bcs)
 Assemble bilinear form into a matrix.
template<dolfinx::scalar T, std::floating_point U>
void assemble_matrix (auto mat_add, const Form< T, U > &a, std::span< const std::int8_t > dof_marker0, std::span< const std::int8_t > dof_marker1)
 Assemble bilinear form into a matrix. Matrix must already be initialised. Does not zero or finalise the matrix.
template<dolfinx::scalar T, std::floating_point U>
void set_diagonal (auto set_fn, const FunctionSpace< U > &V, const std::vector< std::reference_wrapper< const DirichletBC< T, U > > > &bcs, T diagonal=T(1))
 Set a value on the diagonal of the locally owned rows that a Dirichlet boundary condition constrains.

Detailed Description

Functions supporting assembly of a finite element fem::Form.

Function Documentation

◆ bc_dof_markers()

template<dolfinx::scalar T, std::floating_point U>
std::vector< std::int8_t > bc_dof_markers ( const FunctionSpace< U > & V,
const std::vector< std::reference_wrapper< const DirichletBC< T, U > > > & bcs )

Mark the dofs of V (owned and ghost, unrolled) constrained by the boundary conditions in bcs that are defined on V or a subspace of it.

Returns
Dof markers, or an empty array if no boundary condition applies.

◆ bc_dof_markers_pair()

template<dolfinx::scalar T, std::floating_point U>
std::array< std::span< const std::int8_t >, 2 > bc_dof_markers_pair ( const Form< T, U > & a,
const std::vector< std::reference_wrapper< const DirichletBC< T, U > > > & bcs,
std::array< std::vector< std::int8_t >, 2 > & storage )

Mark the dofs of the test and trial spaces of a that the boundary conditions in bcs constrain.

Markers depend only on the space, so a form whose test and trial spaces are the same marks its dofs once and shares the array between its rows and its columns. The two returned spans are then the same array rather than equal copies.

Parameters
[in]aBilinear form whose spaces are marked.
[in]bcsBoundary conditions. Only those defined on a space or a subspace of it mark that space.
[out]storageBacking storage for the returned spans, which are views into it and are valid for as long as it is.
Returns
Markers on the test space, indexing the rows, and on the trial space, indexing the columns.

◆ bc_lifting_data()

template<dolfinx::scalar T, std::floating_point U>
std::pair< std::vector< std::vector< std::int8_t > >, std::vector< std::vector< T > > > bc_lifting_data ( const std::vector< std::optional< std::reference_wrapper< const Form< T, U > > > > & a,
const std::vector< std::vector< std::reference_wrapper< const DirichletBC< T, U > > > > & bcs1 )

Constrained dof markers and boundary condition values on the trial space of each form in a, as used by apply_lifting().

Returns
Markers and values for each block j, both empty if a[j] is null or bcs1[j] is empty.