:py:mod:`FELiCS.Equation.Boundary` ================================== .. py:module:: FELiCS.Equation.Boundary Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: FELiCS.Equation.Boundary.BoundaryHandler FELiCS.Equation.Boundary.BoundaryType FELiCS.Equation.Boundary.BoundaryCondition FELiCS.Equation.Boundary.Custom FELiCS.Equation.Boundary.ZeroDirichlet FELiCS.Equation.Boundary.Wall FELiCS.Equation.Boundary.Symmetry Attributes ~~~~~~~~~~ .. autoapisummary:: FELiCS.Equation.Boundary.logger .. py:data:: logger .. py:class:: 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** :param variables: Each tuple contains the name of a state variable and its components (e.g., [("u", ["x", "y"])]). :type variables: :py:class:`list` of :py:class:`tuples` :param mesh: The FELiCS mesh object, which can access the boundary tags of the given mesh. :type mesh: :py:class:`FELiCS.SpaceDisc.FELiCSMesh` :param BCsFilePath: Path to the JSON file containing boundary condition specifications. :type BCsFilePath: :py:class:`str` :ivar facet_tags: Facet tags from the mesh that identify the boundary regions. :vartype facet_tags: :py:class:`dolfinx.mesh.meshtags` :ivar IDs: List of boundary IDs found in the mesh. :vartype IDs: :py:class:`numpy.ndarray` :ivar variables: Stored list of the state variables. :vartype variables: :py:class:`list` of :py:class:`tuples` :ivar boundaryList: List of boundary condition objects created from the boundary JSON file. :vartype boundaryList: :py:class:`list` .. admonition:: Notes Raises a `ValueError` if: - The boundary ID in the file does not exist in the mesh. - The boundary condition name is invalid. .. py:method:: getListOfBoundaries() Return the list of all boundary condition objects. :returns: List of boundary condition objects associated with each mesh boundary. :rtype: :py:class:`list` .. py:method:: 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. :param functionSpace: The function space on which the boundary conditions are applied. :type functionSpace: :py:class:`dolfinx.fem.functionspace` :returns: List of DirichletBC objects from dolfinx.fem.dirichletbc. :rtype: :py:class:`list` .. admonition:: Notes This function supports mixed function spaces and variables with multiple components. Logs a debug message each time a boundary condition is added. .. py:method:: getListOfNonlinearBoundaries() Placeholder for returning nonlinear boundary condition objects. .. warning:: This method is not implemented yet. .. py:method:: getListOfNonlinearDirichletBCsForDolfinx() Placeholder for returning nonlinear DirichletBCs for Dolfinx. .. warning:: This method is not implemented yet. .. py:class:: BoundaryType(*args, **kwds) Bases: :py:obj:`enum.Enum` Enum for different types of boundary conditions. :ivar NONE: No boundary condition. :vartype NONE: :py:class:`int` :ivar DIRICHLET: Dirichlet boundary condition. :vartype DIRICHLET: :py:class:`int` :ivar NEUMANN: Neumann boundary condition (currently equivalent to NONE). :vartype NEUMANN: :py:class:`int` .. warning:: The NEUMANN type currently has no distinct behavior; this will change in future updates. .. py:attribute:: NONE :value: 0 .. py:attribute:: DIRICHLET :value: 1 .. py:attribute:: NEUMANN :value: 2 .. py:class:: 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** :param boundaryID: Identifier for the boundary, specified in the mesh file. :type boundaryID: :py:class:`int` :param boundaryInfo: Dictionary with boundary specifications from the boundaries-JSON file. :type boundaryInfo: :py:class:`dict` :param boundaryHandler: Reference to the BoundaryHandler object by which it is created. :type boundaryHandler: :py:class:`BoundaryHandler` :ivar ID: Boundary ID. :vartype ID: :py:class:`int` :ivar name: Name of boundary condition. One of: 'custom', 'wall', 'symmetry', 'zeroDerichlet', 'none'. :vartype name: :py:class:`str` :ivar info: Boundary configuration details from the boundaries-JSON file. :vartype info: :py:class:`dict` :ivar bH: Reference to the BoundaryHandler object by which it is created. :vartype bH: :py:class:`BoundaryHandler` :ivar types: Boundary condition types for each variable/component, all entries are attributes of the BoundaryType enum. :vartype types: :py:class:`list` of :py:class:`lists` :ivar values: Boundary values for each variable/component. :vartype values: :py:class:`list` of :py:class:`lists` .. py:class:: Custom(boundaryID, boundaryInfo, boundaryHandler) Bases: :py:obj:`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** :param boundaryID: Identifier for the boundary, specified in the mesh file. :type boundaryID: :py:class:`int` :param boundaryInfo: Dictionary with boundary specifications from the boundaries-JSON file. :type boundaryInfo: :py:class:`dict` :param boundaryHandler: Reference to the BoundaryHandler object by which it is created. :type boundaryHandler: :py:class:`BoundaryHandler` .. admonition:: Notes Assumes valid keys and values exist under "specifics". Errors may occur if structure or content is invalid (to be implemented). .. py:class:: ZeroDirichlet(boundaryID, boundaryInfo, boundaryHandler) Bases: :py:obj:`BoundaryCondition` Homogeneous Dirichlet condition for all variables. Sets all variable components to have Dirichlet type with zero value. **Initialize the ZeroDirichlet object** :param boundaryID: Identifier for the boundary, specified in the mesh file. :type boundaryID: :py:class:`int` :param boundaryInfo: Dictionary with boundary specifications from the boundaries-JSON file. :type boundaryInfo: :py:class:`dict` :param boundaryHandler: Reference to the BoundaryHandler object by which it is created. :type boundaryHandler: :py:class:`BoundaryHandler` .. py:class:: Wall(boundaryID, boundaryInfo, boundaryHandler) Bases: :py:obj:`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** :param boundaryID: Identifier for the boundary, specified in the mesh file. :type boundaryID: :py:class:`int` :param boundaryInfo: Dictionary with boundary specifications from the boundaries-JSON file. :type boundaryInfo: :py:class:`dict` :param boundaryHandler: Reference to the BoundaryHandler object by which it is created. :type boundaryHandler: :py:class:`BoundaryHandler` .. admonition:: Notes Only handles velocity conditions for now. .. py:class:: Symmetry(boundaryID, boundaryInfo, boundaryHandler) Bases: :py:obj:`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** :param boundaryID: Identifier for the boundary, specified in the mesh file. :type boundaryID: :py:class:`int` :param boundaryInfo: Dictionary with boundary specifications from the boundaries-JSON file. :type boundaryInfo: :py:class:`dict` :param boundaryHandler: Reference to the BoundaryHandler object by which it is created. :type boundaryHandler: :py:class:`BoundaryHandler` .. admonition:: Notes Performs stricter checks than the 'Custom' class to ensure boundary conditions conform to symmetry constraints.