FELiCS.Equation.Boundary#

Module Contents#

Classes#

BoundaryHandler

Boundary condition manager.

BoundaryType

Enum for different types of boundary conditions.

BoundaryCondition

Generic boundary condition class.

Custom

Custom boundary condition with user-defined specifications.

ZeroDirichlet

Homogeneous Dirichlet condition for all variables.

Wall

Wall boundary condition enforcing zero velocity.

Symmetry

Symmetry boundary condition for specified variables.

Attributes#

FELiCS.Equation.Boundary.logger#
class FELiCS.Equation.Boundary.BoundaryHandler(variables, mesh, BCsFilePath)#

Boundary condition manager.

Handles the construction of boundary condition objects for each boundary that is defined in the mesh file via a “tag” and specified in a boundaries - JSON file.

Initialize the BoundaryHandler object

Parameters:
  • variables (list of tuples) – Each tuple contains the name of a state variable and its components (e.g., [(“u”, [“x”, “y”])]).

  • mesh (FELiCS.SpaceDisc.FELiCSMesh) – The FELiCS mesh object, which can access the boundary tags of the given mesh.

  • BCsFilePath (str) – Path to the JSON file containing boundary condition specifications.

Variables:
  • facet_tags (dolfinx.mesh.meshtags) – Facet tags from the mesh that identify the boundary regions.

  • IDs (numpy.ndarray) – List of boundary IDs found in the mesh.

  • variables (list of tuples) – Stored list of the state variables.

  • boundaryList (list) – List of boundary condition objects created from the boundary JSON file.

Notes

Raises a ValueError if: - The boundary ID in the file does not exist in the mesh. - The boundary condition name is invalid.

getListOfBoundaries()#

Return the list of all boundary condition objects.

Returns:

List of boundary condition objects associated with each mesh boundary.

Return type:

list

getListOfDirichletBCsForDolfinx(functionSpace)#

Constructs the list of Dirichlet boundary conditions for Dolfinx.

Loops through each variable and boundary, and extracts Dirichlet boundary conditions for scalar and vector components as required.

Parameters:

functionSpace (dolfinx.fem.functionspace) – The function space on which the boundary conditions are applied.

Returns:

List of DirichletBC objects from dolfinx.fem.dirichletbc.

Return type:

list

Notes

This function supports mixed function spaces and variables with multiple components. Logs a debug message each time a boundary condition is added.

getListOfNonlinearBoundaries()#

Placeholder for returning nonlinear boundary condition objects.

Warning

This method is not implemented yet.

getListOfNonlinearDirichletBCsForDolfinx()#

Placeholder for returning nonlinear DirichletBCs for Dolfinx.

Warning

This method is not implemented yet.

class FELiCS.Equation.Boundary.BoundaryType(*args, **kwds)#

Bases: enum.Enum

Enum for different types of boundary conditions.

Variables:
  • NONE (int) – No boundary condition.

  • DIRICHLET (int) – Dirichlet boundary condition.

  • NEUMANN (int) – Neumann boundary condition (currently equivalent to NONE).

Warning

The NEUMANN type currently has no distinct behavior; this will change in future updates.

NONE = 0#
DIRICHLET = 1#
NEUMANN = 2#
class FELiCS.Equation.Boundary.BoundaryCondition(boundaryID, boundaryInfo, boundaryHandler)#

Generic boundary condition class.

Serves both as the base class for all boundary conditions and as the ‘none’ type condition when no boundary constraints are imposed.

Initialize the BoundaryCondition object

Parameters:
  • boundaryID (int) – Identifier for the boundary, specified in the mesh file.

  • boundaryInfo (dict) – Dictionary with boundary specifications from the boundaries-JSON file.

  • boundaryHandler (BoundaryHandler) – Reference to the BoundaryHandler object by which it is created.

Variables:
  • ID (int) – Boundary ID.

  • name (str) – Name of boundary condition. One of: ‘custom’, ‘wall’, ‘symmetry’, ‘zeroDerichlet’, ‘none’.

  • info (dict) – Boundary configuration details from the boundaries-JSON file.

  • bH (BoundaryHandler) – Reference to the BoundaryHandler object by which it is created.

  • types (list of lists) – Boundary condition types for each variable/component, all entries are attributes of the BoundaryType enum.

  • values (list of lists) – Boundary values for each variable/component.

class FELiCS.Equation.Boundary.Custom(boundaryID, boundaryInfo, boundaryHandler)#

Bases: BoundaryCondition

Custom boundary condition with user-defined specifications.

Interprets the “specifics” field in the boundary JSON file to assign boundary conditions to individual variable components.

Initialize the Custom object

Parameters:
  • boundaryID (int) – Identifier for the boundary, specified in the mesh file.

  • boundaryInfo (dict) – Dictionary with boundary specifications from the boundaries-JSON file.

  • boundaryHandler (BoundaryHandler) – Reference to the BoundaryHandler object by which it is created.

Notes

Assumes valid keys and values exist under “specifics”. Errors may occur if structure or content is invalid (to be implemented).

class FELiCS.Equation.Boundary.ZeroDirichlet(boundaryID, boundaryInfo, boundaryHandler)#

Bases: BoundaryCondition

Homogeneous Dirichlet condition for all variables.

Sets all variable components to have Dirichlet type with zero value.

Initialize the ZeroDirichlet object

Parameters:
  • boundaryID (int) – Identifier for the boundary, specified in the mesh file.

  • boundaryInfo (dict) – Dictionary with boundary specifications from the boundaries-JSON file.

  • boundaryHandler (BoundaryHandler) – Reference to the BoundaryHandler object by which it is created.

class FELiCS.Equation.Boundary.Wall(boundaryID, boundaryInfo, boundaryHandler)#

Bases: BoundaryCondition

Wall boundary condition enforcing zero velocity.

Applies Dirichlet(0) for all components of velocity-type variables (e.g., “u” or “rhou”). All other variables are left unconstrained.

Initialize the Wall object

Parameters:
  • boundaryID (int) – Identifier for the boundary, specified in the mesh file.

  • boundaryInfo (dict) – Dictionary with boundary specifications from the boundaries-JSON file.

  • boundaryHandler (BoundaryHandler) – Reference to the BoundaryHandler object by which it is created.

Notes

Only handles velocity conditions for now.

class FELiCS.Equation.Boundary.Symmetry(boundaryID, boundaryInfo, boundaryHandler)#

Bases: BoundaryCondition

Symmetry boundary condition for specified variables.

Uses the “specifics” field from the JSON file and checks if: - only ‘dirichlet’ or ‘neumann’ types appear - only zero-valued conditions appear - all variables are defined.

Initialize the Symmetry object

Parameters:
  • boundaryID (int) – Identifier for the boundary, specified in the mesh file.

  • boundaryInfo (dict) – Dictionary with boundary specifications from the boundaries-JSON file.

  • boundaryHandler (BoundaryHandler) – Reference to the BoundaryHandler object by which it is created.

Notes

Performs stricter checks than the ‘Custom’ class to ensure boundary conditions conform to symmetry constraints.