porepy.params.bc module

Classes representing of boundary conditions.

The classes identify faces of a grid which have Dirichlet, Neumann and Robin type boundary conditions. There is one class for scalar problems and one for nd-vectors.

class AbstractBoundaryCondition[source]

Bases: ABC

This is an abstract class that include the shared functionality of the boundary conditions

copy()[source]

Create a deep copy of the boundary condition.

Returns

A deep copy of self. All attributes will also be copied.

Return type

AbstractBoundaryCondition

internal_to_dirichlet(sd)[source]

Change the boundary condition to Dirichlet on all internal faces.

Useful for mixed-dimensional deformation problems, where the interface variable is displacement, corresponding to a Dirichlet condition on the internal faces.

Parameters

sd (Grid) – Subdomain grid on which self is defined.

Return type

None

is_dir: ndarray

Element i is true if face i has been assigned a Dirichlet condition.

is_neu: ndarray

Element i is true if face i has been assigned a Neumann condition.

class BoundaryCondition(sd, faces=None, cond=None)[source]

Bases: AbstractBoundaryCondition

Class to store information on boundary conditions for problems of a single variable.

The BCs are specified by face number, and can have type Dirichlet, Neumann or Robin. For details on default values etc. see constructor.

Parameters
  • sd (pp.Grid) –

  • faces (Optional[np.ndarray]) –

  • cond (Optional[Union[list[str], str]]) –

num_faces

Number of faces in the grid of the subdomain

Type

int

dim

Dimension of the boundary. One less than the dimension of the subdomain.

Type

int

is_neu

Element i is true if face i has been assigned a Neumann condition. Tacitly assumes that the face is on the boundary. Should be false for internal faces, as well as Dirichlet faces.

Type

np.ndarray boolean, size sd.num_faces

is_dir

Element i is true if face i has been assigned a Dirichlet condition.

Type

np.ndarray, boolean, size sd.num_faces

is_rob

Element i is true if face i has been assigned a Robin condition.

Type

np.ndarray, boolean, size sd.num_faces

is_dir: ndarray

Element i is true if face i has been assigned a Dirichlet condition.

is_neu: ndarray

Element i is true if face i has been assigned a Neumann condition.

class BoundaryConditionVectorial(sd, faces=None, cond=None)[source]

Bases: AbstractBoundaryCondition

Class to store information on boundary conditions for problems with vector variables (e.g. momentum conservation).

The BCs are specified by face number and assigned to the single component, and can have type Dirichlet, Neumann or Robin.

The Robin condition is defined by

sigma*n + alpha * u = G

where alpha is defined by the attribute self.robin_weight

The boundary conditions are applied in the basis given by the attribute self.basis (defaults to the coordinate system). The basis is defined face-wise, and the boundary condition should be given in the coordinates of these bases.

For description of attributes, parameters and constructors, refer to the above class BoundaryCondition.

NOTE: sd.dim > 1 for the procedure to make sense

Parameters
  • sd (pp.Grid) –

  • faces (Optional[np.ndarray]) –

  • cond (Optional[Union[List[str], str]]) –

num_faces

Number of faces in the grid of the subdomain.

Type

int

dim

Dimension of the boundary. One less than the dimension of the subdomain.

Type

int

is_neu

Element i is true if face i has been assigned a Neumann condition. Tacitly assumes that the face is on the boundary. Should be false for internal faces, as well as Dirichlet faces.

Type

np.ndarray boolean, size sd.dim x sd.num_faces

is_dir

Element i is true if face i has been assigned a Dirichlet condition.

Type

np.ndarray, boolean, size sd.dim x sd.num_faces

is_rob

Element i is true if face i has been assigned a Robin condition.

Type

np.ndarray, boolean, size sd.dim x sd.num_faces

set_bc(faces, cond)[source]

Define a single boundary condition.

Parameters
  • faces (np.ndarray, optional) – Boolean array determining which face is considered.

  • cond (str or list of str, optional) – Boundary condition type

Raises
  • ValueError if faces are a boolean array with size not matching the number of faces.

  • ValueError if internal faces are marked

  • ValueError if the numbers of boundary condition types and faces are not matching

  • ValueError if another keyword is used as for the boundary condition type than – “dir”, “neu” or “rob”

Return type

None

is_dir: ndarray

Element i is true if face i has been assigned a Dirichlet condition.

is_neu: ndarray

Element i is true if face i has been assigned a Neumann condition.

face_on_side(sd, side, tol=1e-8)[source]

Find faces on specified sides of a subdomain.

It is assumed that the grid forms a box in 2d or 3d.

The faces are specified by one of two type of keywords: (xmin / west), (xmax / east), (ymin / south), (ymax / north), (zmin, bottom), (zmax / top).

Parameters
  • sd (pp.Grid) – Subdomain for which we want to find faces.

  • side (str, or list of str) – Sides for which we want to find the boundary faces.

  • tol (float) – Geometric tolerance for deciding whether a face lays on the boundary. Defaults to 1e-8.

Returns

Outer list has one element per element in side (same

ordering). Arrays contain global indices of faces laying on that side.

Return type

list of arrays

Raises

ValueError if not supported keyword is used to identify a boundary part