Loading...
Searching...
No Matches
DirichletBC< T, U > Class Template Reference

`#include <DirichletBC.h>`

## Public Member Functions

template<typename S, typename X> requires (std::is_convertible_v<S, T> || std::is_convertible_v<S, std::span<const T>>) && std::is_convertible_v<std::remove_cvref_t<X>, std::vector<std::int32_t>>
| DirichletBC (const S &g, X &&dofs, std::shared_ptr< const FunctionSpace< U > > V)
| Create a representation of a Dirichlet boundary condition constrained by a scalar- or vector-valued constant.
template<typename X> requires std::is_convertible_v<std::remove_cvref_t<X>, std::vector<std::int32_t>>
| DirichletBC (std::shared_ptr< const Constant< T > > g, X &&dofs, std::shared_ptr< const FunctionSpace< U > > V)
| Create a representation of a Dirichlet boundary condition constrained by a fem::Constant.
template<typename X> requires std::is_convertible_v<std::remove_cvref_t<X>, std::vector<std::int32_t>>
| DirichletBC (std::shared_ptr< const Function< T, U > > g, X &&dofs)
| Create a representation of a Dirichlet boundary condition where the space being constrained is the same as the function that defines the constraint Function, i.e. share the same fem::FunctionSpace.
template<typename X>
| DirichletBC (std::shared_ptr< const Function< T, U > > g, X &&V_g_dofs, std::shared_ptr< const FunctionSpace< U > > V)
| Create a representation of a Dirichlet boundary condition where the space being constrained and the function that defines the constraint values do not share the same fem::FunctionSpace.
| DirichletBC (const DirichletBC &bc)=default
| DirichletBC (DirichletBC &&bc)=default
| ~DirichletBC ()=default
| Destructor.
DirichletBC & | operator= (const DirichletBC &bc)=default
DirichletBC & | operator= (DirichletBC &&bc)=default
| Move assignment operator.
std::shared_ptr< const FunctionSpace< U > > | function_space () const
std::variant< std::shared_ptr< const Function< T, U > >, std::shared_ptr< const Constant< T > > > | value () const
std::pair< std::span< const std::int32_t >, std::int32_t > | dof_indices () const
void | set (std::span< T > x, std::optional< std::span< const T > > x0, T alpha=1) const
| Set entries in an array that are constrained by Dirichlet boundary conditions.
void | mark_dofs (std::span< std::int8_t > markers) const
| Set markers[i] = true if dof i has a boundary condition applied.

## Detailed Description

template<dolfinx::scalar T, std::floating_point U = dolfinx::scalar_value_t<T>>
class dolfinx::fem::DirichletBC< T, U >

Object for setting (strong) Dirichlet boundary conditions

\[u = g \ \text{on} \ G,\]

where \(u\) is the solution to be computed, \(g\) is a function and \(G\) is a sub domain of the mesh.

A DirichletBC is specified by the function \(g\), the function space (trial space) and degrees of freedom to which the boundary condition applies.

## Constructor & Destructor Documentation

## DirichletBC() [1/6]

template<dolfinx::scalar T, std::floating_point U = dolfinx::scalar_value_t<T>>
template<typename S, typename X>
requires (std::is_convertible_v<S, T> || std::is_convertible_v<S, std::span<const T>>) && std::is_convertible_v<std::remove_cvref_t<X>, std::vector<std::int32_t>>

DirichletBC | ( | const S & | g,
|  | X && | dofs,
|  | std::shared_ptr< const FunctionSpace< U > > | V )

inline

Create a representation of a Dirichlet boundary condition constrained by a scalar- or vector-valued constant.

Precondition
  dofs must be sorted.

Parameters

  [in] | g | The boundary condition value (T or convertible to std::span<const T>)
  [in] | dofs | Degree-of-freedom block indices to be constrained. The indices must be sorted.
  [in] | V | The function space to be constrained

Note
  Can be used only with point-evaluation elements.
  The indices in dofs are for blocks, e.g. a block index corresponds to 3 degrees-of-freedom if the dofmap associated with g has block size 3.
  The size of of g must be equal to the block size if V. Use the Function version if this is not the case, e.g. for some mixed spaces.

## DirichletBC() [2/6]

template<dolfinx::scalar T, std::floating_point U = dolfinx::scalar_value_t<T>>
template<typename X>
requires std::is_convertible_v<std::remove_cvref_t<X>, std::vector<std::int32_t>>

DirichletBC | ( | std::shared_ptr< const Constant< T > > | g,
|  | X && | dofs,
|  | std::shared_ptr< const FunctionSpace< U > > | V )

inline

Create a representation of a Dirichlet boundary condition constrained by a fem::Constant.

Precondition
  dofs must be sorted.

Parameters

  [in] | g | The boundary condition value.
  [in] | dofs | Degree-of-freedom block indices to be constrained.
  [in] | V | The function space to be constrained

Note
  Can be used only with point-evaluation elements.
  The indices in dofs are for blocks, e.g. a block index corresponds to 3 degrees-of-freedom if the dofmap associated with g has block size 3.
  The size of of g must be equal to the block size if V. Use the Function version if this is not the case, e.g. for some mixed spaces.

## DirichletBC() [3/6]

template<dolfinx::scalar T, std::floating_point U = dolfinx::scalar_value_t<T>>
template<typename X>
requires std::is_convertible_v<std::remove_cvref_t<X>, std::vector<std::int32_t>>

DirichletBC | ( | std::shared_ptr< const Function< T, U > > | g,
|  | X && | dofs )

inline

Create a representation of a Dirichlet boundary condition where the space being constrained is the same as the function that defines the constraint Function, i.e. share the same fem::FunctionSpace.

Precondition
  dofs must be sorted.

Parameters

  [in] | g | The boundary condition value.
  [in] | dofs | Degree-of-freedom block indices to be constrained.

Note
  The indices in dofs are for blocks, e.g. a block index corresponds to 3 degrees-of-freedom if the dofmap associated with g has block size 3.

## DirichletBC() [4/6]

template<dolfinx::scalar T, std::floating_point U = dolfinx::scalar_value_t<T>>
template<typename X>

DirichletBC | ( | std::shared_ptr< const Function< T, U > > | g,
|  | X && | V_g_dofs,
|  | std::shared_ptr< const FunctionSpace< U > > | V )

inline

Create a representation of a Dirichlet boundary condition where the space being constrained and the function that defines the constraint values do not share the same fem::FunctionSpace.

A typical example is when applying a constraint on a subspace. The (sub)space and the constrain function must have the same finite element.

Precondition
  The two degree-of-freedom arrays in V_g_dofs must be sorted by the indices in the first array.

Parameters

  [in] | g | The boundary condition value
  [in] | V_g_dofs | Two arrays of degree-of-freedom indices (std::array<std::vector<std::int32_t>, 2>). First array are indices in the space where boundary condition is applied (V), second array are indices in the space of the boundary condition value function g. The dof indices are unrolled, i.e. are not by dof block.
  [in] | V | The function (sub)space on which the boundary condition is applied

Note
  The indices in dofs are unrolled and not for blocks.

## DirichletBC() [5/6]

template<dolfinx::scalar T, std::floating_point U = dolfinx::scalar_value_t<T>>

DirichletBC | ( | const DirichletBC< T, U > & | bc | ) |

default

Copy constructor

Parameters

  [in] | bc | The object to be copied

## DirichletBC() [6/6]

template<dolfinx::scalar T, std::floating_point U = dolfinx::scalar_value_t<T>>

DirichletBC | ( | DirichletBC< T, U > && | bc | ) |

default

Move constructor

Parameters

  [in] | bc | The object to be moved

## Member Function Documentation

## dof_indices()

template<dolfinx::scalar T, std::floating_point U = dolfinx::scalar_value_t<T>>

std::pair< std::span< const std::int32_t >, std::int32_t > dof_indices | ( |  | ) | const

inline

Access dof indices (local indices, unrolled), including ghosts, to which a Dirichlet condition is applied, and the index to the first non-owned (ghost) index. The array of indices is sorted.

Returns
  Sorted array of dof indices (unrolled) and index to the first entry in the dof index array that is not owned. Entries dofs[:pos] are owned and entries dofs[pos:] are ghosts.

## function_space()

template<dolfinx::scalar T, std::floating_point U = dolfinx::scalar_value_t<T>>

std::shared_ptr< const FunctionSpace< U > > function_space | ( |  | ) | const

inline

The function space to which boundary conditions are applied

Returns
  The function space

## mark_dofs()

template<dolfinx::scalar T, std::floating_point U = dolfinx::scalar_value_t<T>>

void mark_dofs | ( | std::span< std::int8_t > | markers | ) | const

inline

Set markers[i] = true if dof i has a boundary condition applied.

Value of markers[i] is not changed otherwise.

Parameters

  [in,out] | markers | Entry makers[i] is set to true if dof i in V0 had a boundary condition applied, i.e. dofs which are fixed by a boundary condition. Other entries in markers are left unchanged.

## operator=()

template<dolfinx::scalar T, std::floating_point U = dolfinx::scalar_value_t<T>>

DirichletBC & operator= | ( | const DirichletBC< T, U > & | bc | ) |

default

Assignment operator

Parameters

  [in] | bc | Another DirichletBC object

## set()

template<dolfinx::scalar T, std::floating_point U = dolfinx::scalar_value_t<T>>

void set | ( | std::span< T > | x,
|  | std::optional< std::span< const T > > | x0,
|  | T | alpha = 1 ) const

inline

Set entries in an array that are constrained by Dirichlet boundary conditions.

Entries in x that are constrained by a Dirichlet boundary conditions are set to alpha * (x_bc - x0), where x_bc is the (interpolated) boundary condition value.

For elements with point-wise evaluated degrees-of-freedom, e.g. Lagrange elements, x_bc is the value of the boundary condition at the degree-of-freedom. For elements with moment degrees-of-freedom, x_bc is the value of the boundary condition interpolated into the finite element space.

If x includes ghosted entries (entries available on the calling rank but owned by another rank), ghosted entries constrained by a Dirichlet condition will also be set.

Parameters

  [in,out] | x | Array to modify for Dirichlet boundary conditions.
  [in] | x0 | Optional array used in computing the value to set. If not provided it is treated as zero.
  [in] | alpha | Scaling to apply.

## value()

template<dolfinx::scalar T, std::floating_point U = dolfinx::scalar_value_t<T>>

std::variant< std::shared_ptr< const Function< T, U > >, std::shared_ptr< const Constant< T > > > value | ( |  | ) | const

inline

Return boundary value function g

Returns
  The boundary values Function

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

- /build/fenics-dolfinx-PdyzCE/fenics-dolfinx-0.10.0.post5/cpp/dolfinx/fem/assemble_vector_impl.h
- /build/fenics-dolfinx-PdyzCE/fenics-dolfinx-0.10.0.post5/cpp/dolfinx/fem/DirichletBC.h