Skip to content

Domain

Domain Module

This module provides functionality to represent the domain for the problem.

Classes: Domain: Represents the domain for the problem.

Domain

Class representing the domain for the problem.

This class reads the mesh from a GMSH file and locates physical groups.

Attributes:

Name Type Description
mesh Mesh

The mesh representing the domain.

cell_tags ndarray

Array containing cell tags.

facet_tags ndarray

Array containing facet tags.

boundary_facets dict

Dictionary containing boundary facets grouped by physical group name.

Source code in src/fragma/domain.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
class Domain:
    """
    Class representing the domain for the problem.

    This class reads the mesh from a GMSH file and locates physical groups.

    Attributes
    ----------
    mesh : dolfinx.Mesh
        The mesh representing the domain.
    cell_tags : numpy.ndarray
        Array containing cell tags.
    facet_tags : numpy.ndarray
        Array containing facet tags.
    boundary_facets : dict
        Dictionary containing boundary facets grouped by physical group name.
    """

    def __init__(self, mesh_pars, dim):
        """
        Initialize the Domain.

        Parameters
        ----------
        mesh_pars : dict
            Dictionary containing parameters for the mesh.
        dim : int
            Dimension of the problem.
        """
        print("\n████ READING THE MESH")
        # Read the mesh from GMSH
        print("Mesh reading output:")
        msh_file = mesh_pars["msh_file"]
        self.mesh_data = io.gmsh.read_from_msh(msh_file, MPI.COMM_WORLD, gdim=dim)
        self.mesh = self.mesh_data.mesh
        self.cell_tags = self.mesh_data.cell_tags
        self.facet_tags = self.mesh_data.facet_tags
        # Locate the physical groups
        self.__locate_physical_groups(mesh_pars["physical_groups"])

    def __locate_physical_groups(self, facets_tags_values):
        """
        Locate physical groups in the mesh.

        Parameters
        ----------
        facets_tags_values : dict
            Dictionary containing facet tags and their corresponding values.
        """
        # Get the facets indices
        self.boundary_facets = {
            facet_name: self.facet_tags.indices[self.facet_tags.values == facet_value]
            for facet_name, facet_value in facets_tags_values.items()
        }

__init__(mesh_pars, dim)

Initialize the Domain.

Parameters:

Name Type Description Default
mesh_pars dict

Dictionary containing parameters for the mesh.

required
dim int

Dimension of the problem.

required
Source code in src/fragma/domain.py
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
def __init__(self, mesh_pars, dim):
    """
    Initialize the Domain.

    Parameters
    ----------
    mesh_pars : dict
        Dictionary containing parameters for the mesh.
    dim : int
        Dimension of the problem.
    """
    print("\n████ READING THE MESH")
    # Read the mesh from GMSH
    print("Mesh reading output:")
    msh_file = mesh_pars["msh_file"]
    self.mesh_data = io.gmsh.read_from_msh(msh_file, MPI.COMM_WORLD, gdim=dim)
    self.mesh = self.mesh_data.mesh
    self.cell_tags = self.mesh_data.cell_tags
    self.facet_tags = self.mesh_data.facet_tags
    # Locate the physical groups
    self.__locate_physical_groups(mesh_pars["physical_groups"])

__locate_physical_groups(facets_tags_values)

Locate physical groups in the mesh.

Parameters:

Name Type Description Default
facets_tags_values dict

Dictionary containing facet tags and their corresponding values.

required
Source code in src/fragma/domain.py
56
57
58
59
60
61
62
63
64
65
66
67
68
69
def __locate_physical_groups(self, facets_tags_values):
    """
    Locate physical groups in the mesh.

    Parameters
    ----------
    facets_tags_values : dict
        Dictionary containing facet tags and their corresponding values.
    """
    # Get the facets indices
    self.boundary_facets = {
        facet_name: self.facet_tags.indices[self.facet_tags.values == facet_value]
        for facet_name, facet_value in facets_tags_values.items()
    }