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