bluemira.mesh.meshing ===================== .. py:module:: bluemira.mesh.meshing .. autoapi-nested-parse:: Core functionality for the bluemira mesh module. Attributes ---------- .. autoapisummary:: bluemira.mesh.meshing.SUPPORTED_GEOS Classes ------- .. autoapisummary:: bluemira.mesh.meshing.DefaultMeshOptions bluemira.mesh.meshing.MeshTags bluemira.mesh.meshing.MeshTagsNC bluemira.mesh.meshing.GEOS bluemira.mesh.meshing.MeshOptions bluemira.mesh.meshing.Meshable bluemira.mesh.meshing._GmshEnum bluemira.mesh.meshing.GmshFileType bluemira.mesh.meshing.MshFileExtensionType bluemira.mesh.meshing.Mesh bluemira.mesh.meshing._FreeCADGmsh Functions --------- .. autoapisummary:: bluemira.mesh.meshing.get_default_options bluemira.mesh.meshing._add_points Module Contents --------------- .. py:class:: DefaultMeshOptions Default mesh options .. py:attribute:: lcar :type: float | None :value: None .. py:attribute:: physical_group :type: float | None :value: None .. py:class:: MeshTags Bases: :py:obj:`enum.IntEnum` .. autoapi-inheritance-diagram:: bluemira.mesh.meshing.MeshTags :parts: 1 :private-bases: Mesh tags and dimensions .. py:attribute:: POINTS :value: 0 .. py:attribute:: CNTRPOINTS :value: 0 .. py:attribute:: CURVE :value: 1 .. py:attribute:: SURFACE :value: 2 .. py:attribute:: CURVELOOP :value: -1 .. py:class:: MeshTagsNC Bases: :py:obj:`enum.IntEnum` .. autoapi-inheritance-diagram:: bluemira.mesh.meshing.MeshTagsNC :parts: 1 :private-bases: Mesh tags and dimensions CURVELOOP is not in this class. All entries are equal to the equivalent entry in MeshTags .. py:attribute:: POINTS .. py:attribute:: CNTRPOINTS .. py:attribute:: CURVE .. py:attribute:: SURFACE .. py:class:: GEOS Bases: :py:obj:`enum.IntEnum` .. autoapi-inheritance-diagram:: bluemira.mesh.meshing.GEOS :parts: 1 :private-bases: Supported geometry types and thier dimesions .. py:attribute:: BluemiraWire :value: 1 .. py:attribute:: BluemiraFace :value: 2 .. py:attribute:: BluemiraShell :value: 2 .. py:attribute:: BluemiraCompound :value: 2 .. py:data:: SUPPORTED_GEOS :value: ('BluemiraWire', 'BluemiraFace', 'BluemiraShell', 'BluemiraCompound') .. py:function:: get_default_options() -> DefaultMeshOptions :returns: The default display options. .. py:class:: MeshOptions(**kwargs) The options that are available for meshing objects. .. py:attribute:: _options .. py:property:: lcar :type: float | None Mesh size of points. .. py:property:: physical_group :type: float | None Definition of physical groups. .. py:method:: as_dict() -> dict[str, float | None] :returns: The instance as a dictionary. .. py:method:: modify(**kwargs) Function to override meshing options. .. py:method:: __repr__() -> str :returns: Representation string of the DisplayOptions. .. py:class:: Meshable Mixin class to make a class meshable .. py:attribute:: _mesh_options .. py:property:: mesh_options :type: MeshOptions The options that will be used to mesh the object. .. py:class:: _GmshEnum(*args, **kwds) Bases: :py:obj:`enum.Enum` .. autoapi-inheritance-diagram:: bluemira.mesh.meshing._GmshEnum :parts: 1 :private-bases: Create a collection of name/value pairs. Example enumeration: >>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3 Access them by: - attribute access: >>> Color.RED - value lookup: >>> Color(1) - name lookup: >>> Color['RED'] Enumerations can be iterated over, and know how many members they have: >>> len(Color) 3 >>> list(Color) [, , ] Methods can be added to enumerations, and members can have their own attributes -- see the documentation for details. .. py:attribute:: SHELL :value: 'BluemiraShell' .. py:attribute:: COMPOUND :value: 'BluemiraCompound' .. py:class:: GmshFileType(*args, **kwds) Bases: :py:obj:`enum.Enum` .. autoapi-inheritance-diagram:: bluemira.mesh.meshing.GmshFileType :parts: 1 :private-bases: Gmsh file output types .. py:attribute:: DEFAULT .. py:attribute:: GMSH .. py:class:: MshFileExtensionType(*args, **kwds) Bases: :py:obj:`enum.Enum` .. autoapi-inheritance-diagram:: bluemira.mesh.meshing.MshFileExtensionType :parts: 1 :private-bases: Gmsh file extensions .. py:attribute:: GEO :value: '.geo' .. py:attribute:: GEO_UNROLLED :value: '.geo_unrolled' .. py:attribute:: MSH :value: '.msh' .. py:attribute:: XDMF :value: '.xdmf' .. py:attribute:: H5 :value: '.h5' .. py:attribute:: ini :value: '.ini' .. py:method:: _missing_(value) :classmethod: Called when value does not match any enum member. :raises ValueError: Unsupported mesh file extension .. py:class:: Mesh(modelname: str = 'Mesh', terminal: int = 0, meshfile: str | list[str] | None = None, logfile: str = 'gmsh.log') A class for supporting the creation of meshes and writing out those meshes to files. .. py:attribute:: modelname :value: 'Mesh' .. py:attribute:: terminal :value: 0 .. py:property:: meshfile :type: list[str] The path(s) to the file(s) containing the meshes. .. py:attribute:: logfile :value: 'gmsh.log' .. py:method:: _check_meshfile(meshfile: str | list) -> list[str] :staticmethod: Check the mesh file input. :returns: The meshfile list :raises ValueError: Meshfile list is empty :raises TypeError: Meshfile must be a string or list of strings .. py:method:: __call__(comp: bluemira.base.components.Component | Meshable, dim: int = 2) Generate the mesh and save it to file. :returns: The serialised shape :raises TypeError: Objects not meshable .. py:method:: __mesh_obj(obj, dim: int) -> dict[str, Any] Function to mesh the object. :returns: The serialised shape :raises ValueError: Meshing not implemented for geometry type .. py:method:: __convert_item_to_gmsh(buffer: dict, dim: int) .. py:method:: _apply_physical_group(buffer: dict) Function to apply physical groups .. py:method:: _apply_mesh_size(buffer: dict) Function to apply mesh size. .. py:method:: __create_dict_for_mesh_size(buffer: dict) -> list[tuple[str, float]] Function to create the correct dictionary format for the application of the mesh size. :returns: list of lcar point tuples .. py:method:: __apply_fragment(buffer: dict, dim: collections.abc.Iterable[int] = (2, 1, 0), all_ent=None, tools: list | None = None, *, remove_object: bool = True, remove_tool: bool = True) Apply the boolean fragment operation. .. py:method:: _check_intersections(gmsh_dict: dict) :staticmethod: Check intersection and add the necessary vertexes to the gmsh dict. .. py:method:: __iterate_gmsh_dict(buffer: dict, function: collections.abc.Callable, *args) Supporting function to iterate over a gmsh dict. .. py:method:: __buffer_loop(buffer: dict, type_check: str, *, raise_error=False) :staticmethod: .. py:method:: __convert_wire_to_gmsh(buffer: dict, dim: int) Converts a wire to gmsh. If dim is not equal to 1, wire is not meshed. .. py:method:: __convert_face_to_gmsh(buffer: dict, dim: int) Converts a face to gmsh. .. py:method:: __convert_compound_shell_to_gmsh(buffer: dict, dim: int, converter: _GmshEnum) Converts a shell to gmsh. .. py:method:: get_gmsh_dict(buffer: dict, file_format: str | GmshFileType = GmshFileType.DEFAULT) -> dict[MeshTags, list] :returns: the gmsh dict in a default (only tags) or gmsh (tuple(dim, tag)) format. :raises ValueError: No object to mesh .. py:class:: _FreeCADGmsh .. py:method:: _initialise_mesh(terminal: int = 1, modelname: str = 'Mesh') :staticmethod: .. py:method:: _save_mesh(meshfile: str = 'Mesh.geo_unrolled') :staticmethod: .. py:method:: _finalise_mesh(logfile: str = 'gmsh.log') :staticmethod: .. py:method:: _generate_mesh(mesh_dim: int = 3) :staticmethod: .. py:method:: create_gmsh_curve(buffer: dict) -> dict :staticmethod: Function to create gmsh curve from a dictionary (buffer). :returns: gmsh dictionary of curve .. py:method:: _fragment(dim: int | collections.abc.Iterable[int] = (2, 1, 0), all_ent: list[int] | None = None, tools: list | None = None, *, remove_object: bool = True, remove_tool: bool = True) -> tuple[list[int], list[tuple], list[list[tuple]]] :staticmethod: .. py:method:: _map_mesh_dict(mesh_dict: dict, all_ent, oov: list | None = None) -> dict :staticmethod: .. py:method:: set_mesh_size(dim_tags, size) :staticmethod: .. py:method:: add_physical_group(dim, tags, name: str | None = None) :staticmethod: .. py:method:: _set_mesh_size(dim_tags, size) :staticmethod: .. py:method:: _get_boundary(dimtags, *, combined=False, recursive=False) :staticmethod: .. py:function:: _add_points(*point: collections.abc.Iterable) -> list Add gmsh model points :returns: List of points added to occ model