:py:mod:`FELiCS.SpaceDisc.FELiCSMesh` ===================================== .. py:module:: FELiCS.SpaceDisc.FELiCSMesh Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: FELiCS.SpaceDisc.FELiCSMesh.FELiCSMesh FELiCS.SpaceDisc.FELiCSMesh.ExportMesh Attributes ~~~~~~~~~~ .. autoapisummary:: FELiCS.SpaceDisc.FELiCSMesh.comm FELiCS.SpaceDisc.FELiCSMesh.logger .. py:data:: comm .. py:data:: logger .. py:class:: FELiCSMesh(coordinateSystemName, meshFileName=None, gdim=None, m=0, inputMesh=None) Wrapper class for the DOLFINx mesh, with support for custom coordinate systems and FELiCS-specific utilities. This class allows loading and saving of mesh data, extraction of cell and coordinate information, and computation of connectivity for use in FEM simulations. It supports both Cartesian and Cylindrical coordinate systems and provides functionality to convert and export mesh data in a FELiCS HDF5-based format. **Initialize the FELiCSMesh object** :param coordinateSystemName: Name of the coordinate system (``"Cartesian"`` or ``"Cylindrical"``). :type coordinateSystemName: :py:class:`str` :param meshFileName: Path to the Gmsh mesh file to load. Ignored if ``inputMesh`` is given. :type meshFileName: :py:class:`str`, *optional* :param gdim: Geometric dimension of the mesh. If ``None`` and a mesh file is read, it is inferred from the Gmsh model. :type gdim: :py:class:`int`, *optional* :param m: Spectral wave number used in the associated :class:`CoordinateSystem`. If nonzero, the logical dimension ``dim`` is set to ``gdim + 1``. :type m: :py:class:`int`, *optional* :param inputMesh: Existing DOLFINx mesh object to wrap instead of reading from a file. In this case, ``meshFileName`` and Gmsh are not used. :type inputMesh: :py:class:`dolfinx.mesh.Mesh`, *optional* :ivar dolfinxMesh: The wrapped DOLFINx mesh object. :vartype dolfinxMesh: :py:class:`dolfinx.mesh.Mesh` :ivar facet_tags: Boundary facet tags parsed from the Gmsh model when a mesh file is read. Not set when the mesh is provided via ``inputMesh``. :vartype facet_tags: :py:class:`dolfinx.mesh.MeshTags` or :py:obj:`None` :ivar gdim: Geometric dimension of the mesh. :vartype gdim: :py:class:`int` :ivar dim: Logical dimension of the system, including a possible spectral dimension (``dim == gdim`` if ``m == 0``). :vartype dim: :py:class:`int` :ivar coordinateSystemName: Name of the selected coordinate system. :vartype coordinateSystemName: :py:class:`str` :ivar coordinateSystem: Tensor-based coordinate system initialized for the mesh. :vartype coordinateSystem: :py:class:`CoordinateSystem` :ivar meshCells: Array containing the cell connectivity in FELiCS ordering; populated by :meth:`calcConnectivity`. :vartype meshCells: :py:class:`numpy.ndarray` .. py:property:: exportMesh Lazy-loaded refined export mesh for exporting simulation results. On first access, a uniformly refined P1 mesh is created from this instance and wrapped in an :class:`ExportMesh`. Subsequent accesses return the cached export mesh. :returns: An :class:`ExportMesh` instance associated with this base mesh. :rtype: :py:class:`ExportMesh` .. py:property:: coordinateSystem Coordinate system object associated with the mesh. :returns: Tensor-based coordinate system initialized for the mesh. :rtype: :py:class:`CoordinateSystem` .. py:property:: axisNames Names of the axes in the coordinate system. These include both spectral and mesh dimensions. Currently implemented systems are: - Cartesian: ['x', 'y', 'z'] - Cylindrical: ['x', 'r', 't'] :returns: List of coordinate names (e.g., ['x', 'y', 'z']). :rtype: :py:class:`list` of :py:class:`str` .. py:property:: meshAxisNames Names of the axes in the mesh's coordinate system. Currently implemented systems are: - Cartesian: ['x', 'y', 'z'] - Cylindrical: ['x', 'r', 't'] :returns: List of coordinate names (e.g., ['x', 'y', 'z']). :rtype: :py:class:`list` of :py:class:`str` .. py:method:: setTrueDimension(dim) Set the true dimension of the system, updating the coordinate system. This must be called if a spectral dimension is included, in which case the true dimension is higher than the geometrical dimension of the mesh. :param dim: True dimension of the system, including a possible spectral dimension. :type dim: :py:class:`int` .. py:method:: saveInFELiCSFormat(filename) Save the refined (export) mesh in the FELiCS HDF5-based format. The method uses the lazily constructed :attr:`exportMesh` to obtain a refined P1 mesh, then writes its vertex coordinates and triangular cell connectivity to an HDF5 file. :param filename: Path to the output HDF5 file where the mesh will be saved. :type filename: :py:class:`str` .. py:method:: calcConnectivity() Compute and update the internal mesh cell connectivity array. The connectivity is extracted from the DOLFINx topology and stored in :attr:`meshCells` as an ``(n_cells, n_vertices_per_cell)`` array. .. py:method:: cells() Returns the cell connectivity array of the mesh. :returns: Array of mesh cells with vertex indices. :rtype: :py:class:`numpy.ndarray` .. py:method:: coordinates() Retrieves the vertex coordinates of the mesh. :returns: Array of vertex coordinates, truncated to the mesh's geometric dimension. :rtype: :py:class:`numpy.ndarray` .. py:method:: getBCInfo() Retrieve boundary condition tags and corresponding boundary facets. :returns: * :py:class:`numpy.ndarray` -- Unique boundary condition IDs. * :py:class:`dolfinx.mesh.MeshTags` -- Mesh tags object representing the boundary facets. .. py:class:: ExportMesh(base_mesh: FELiCSMesh) Bases: :py:obj:`FELiCSMesh` Refined export mesh built from a base :class:`FELiCSMesh`. This subclass creates a uniformly refined P1 mesh from an existing :class:`FELiCSMesh` instance. It is primarily used for exporting simulation results on a finer mesh than the one used for computation.