Skip to content

Commit

Permalink
Add Python docs
Browse files Browse the repository at this point in the history
  • Loading branch information
garth-wells committed Sep 26, 2024
1 parent 6917e6e commit 5d4d806
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
13 changes: 7 additions & 6 deletions cpp/dolfinx/fem/DirichletBC.h
Original file line number Diff line number Diff line change
Expand Up @@ -473,21 +473,22 @@ class DirichletBC
/// @brief Set entries in an array that are constrained by Dirichlet
/// boundary conditions.
///
/// Entries in the array `x` that are constrained by a Dirichlet
/// boundary conditions are set to `alpha * (x_bc - x0)`, where `x_bc`
/// is the boundary condition value.
/// 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 element, `x_bc` is the value of the boundary condition at
/// the degree-of-freedom. For elements with moment
/// 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.
///
/// @param[in,out] x The array to modify.
/// @param[in,out] x Array to modify for Dirichlet boundary
/// conditions.
/// @param[in] x0 Optional array used in computing the value to set.
/// If not provided it is treated as zero.
/// @param[in] alpha Scaling to apply.
Expand Down
29 changes: 20 additions & 9 deletions python/dolfinx/fem/bcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,31 @@ def function_space(self) -> dolfinx.fem.FunctionSpace:
return self._cpp_object.function_space

def set(
self, b: npt.NDArray, x0: typing.Optional[npt.NDArray[np.int32]] = None, alpha: float = 1
self, x: npt.NDArray, x0: typing.Optional[npt.NDArray[np.int32]] = None, alpha: float = 1
) -> None:
"""Insert boundary condition values into vector.
"""Set entries in an array that are constrained by Dirichlet boundary conditions.
Only local (owned) entries are set, hence communication after
calling this function is not required unless ghost entries need to
be updated to the boundary condition value.
Entries in an array ``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.
Args:
b:
x0:
alpha:
x: Array to modify for Dirichlet boundary conditions.
x0: Optional array used in computing the value to set. If
not provided it is treated as zero.
alpha: Scaling factor.
"""
self._cpp_object.set(b, x0, alpha)
self._cpp_object.set(x, x0, alpha)

def dof_indices(self) -> tuple[npt.NDArray[np.int32], int]:
"""Access dof indices `(local indices, unrolled)`, including ghosts, to
Expand Down

0 comments on commit 5d4d806

Please sign in to comment.