Muscat.Containers.MeshCreationTools module

CheckIntegrity(GUI: bool = False) str[source]
CheckIntegrity_Create0DElementContainerForEveryPoint(GUI: False) str[source]
CheckIntegrity_CreateCube(GUI: bool = False) str[source]
CheckIntegrity_CreateDisk(GUI: False) str[source]
CheckIntegrity_CreateEdgeMesh(GUI: bool = False) str[source]
CheckIntegrity_CreateMeshFromCellsDict(GUI: bool = False) str[source]
CheckIntegrity_CreateMeshOfTriangles(GUI: False) str[source]
CheckIntegrity_CreateSquare(GUI: bool = False) str[source]
CheckIntegrity_CreateUniformMeshOfBars(GUI: bool = False) str[source]
CheckIntegrity_MeshToSimplex(GUI: bool = False) str[source]
CheckIntegrity_MirrorMesh(GUI: False) str[source]
CheckIntegrity_QuadToLin(GUI: False) str[source]
CheckIntegrity_SubDivideMesh(GUI: False) str[source]
CheckIntegrity_ToQuadraticMesh(GUI: bool = False) str[source]
Create0DElementContainerForEveryPoint(mesh: Mesh) ElementsContainer[source]

Create a ElementContainer with 0D elements based on the point of the mesh The user is responsible to put this ElementContainer back to a mesh (using merge for example) the Nodal tags are transferred to the new 0D elements the originalIds is constructed based on the nodes (range(nb Nodes))

Parameters:

mesh (Mesh) – the input mesh

Returns:

An ElementsContainer with the new 0D elements

Return type:

ElementsContainer

CreateCube(dimensions: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] = [2, 2, 2], origin: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] = [-1.0, -1.0, -1.0], spacing: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] = [1.0, 1.0, 1.0], ofTetras: bool = False) Mesh[source]

Create a Mesh of a cube

Parameters:
  • dimensions (ArrayLike, optional) – Number of point in every direction, by default [2,2,2]

  • origin (ArrayLike, optional) – origin of the lowest point, by default [-1.0,-1.0,-1.0]

  • spacing (ArrayLike, optional) – size in the 3 direction of every element, by default [1.,1.,1.]

  • ofTetras (bool, optional) – if False: mesh of hexahedrons if True: mesh of tetrahedrons by default False

Returns:

A mesh of the cube

Return type:

Mesh

CreateDisk(nr: int64 = 10, nTheta: int64 = 10, r0: float64 = 0.5, r1: float64 = 1.0, theta0: float64 = 0, theta1: float64 = 1.5707963267948966, ofTriangles: bool = False) Mesh[source]

Function to create a disk section

Parameters:
  • nr (MuscatIndex, optional) – number of points in the radial direction, by default 10

  • nTheta (MuscatIndex, optional) – number of point in the angular direction, by default 10

  • r0 (MuscatFloat, optional) – internal radius, by default 0.5

  • r1 (MuscatFloat, optional) – external radius, by default 1.

  • theta0 (MuscatFloat, optional) – start angle, by default 0

  • theta1 (MuscatFloat, optional) – end angle, by default np.pi/2

  • ofTriangles (bool, optional) – if false, quand are used for the mesh , by default False if true, triangles are used for the mesh

Returns:

An Mesh of a disk sector

Return type:

Mesh

CreateEdgeMesh(mesh: Mesh, ef: ElementFilter | None = None) Mesh[source]

Create a new mesh from the incoming mesh composed only by the edges off all the elements (Bar_2) all element tags are lost.

Parameters:
  • mesh (Mesh) – input mesh

  • ef (Optional[ElementFilter], optional) – element Filter to select the elements to work on, by default None

Returns:

A mesh composed only with Bar_2

Return type:

Mesh

Raises:

RuntimeError – In the case the faces of the current elements are not Bar_2

CreateMeshFromCellsDict(points: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], cellsDict: Dict[str, _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]], pointFields: Dict[str, _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]] | None = None, cellFields: Dict[str, _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]] | None = None, cellFieldInDictOrder: bool = True) Mesh[source]

Function to create a Mesh from points and a dict of element Data is converted of the native format (MuscatFloat, MuscatIndex) if needed

Parameters:
  • points (ArrayLike) – Nodes coordinates of size [nb_points x [2 or3]]

  • cellsDict (dict[str,ArrayLike]) – A dict with (key= elementType, value=connectivity), connectivity start from 0 pointing to the node indices

  • pointFields (dict[str,ArrayLike], optional) – fields at nodes each fields must be of size [nb_points, nb_components], by default None

  • cellFields (dict[str,ArrayLike], optional) – fields at elements each fields must be of size [total_number_of_elements, nb_components], by default None _description_, by default None

  • cellFieldInDictOrder (bool, by default True) – if True the cell fields are interpreted in the cells_dict insertion order (insertion order is preserved in python) if False the cell field are interpreted in the canonic Muscat (“alphanumeric”) order.

Returns:

A Mesh with the field inside

Return type:

Mesh

CreateMeshOf(points: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], connectivity: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], elemName: ElementType) Mesh[source]

Helper function to create a mesh of homogeneous elements.

Parameters:
  • points (ArrayLike) – The positions of the point (nb Points,3)

  • connectivity (ArrayLike) – The connectivity of the elements (nb of elements, number of point per element)

  • elemName (str, optional) – the name of the elements to create. , by default None

Returns:

A instance of Mesh with the given point and elements

Return type:

Mesh

CreateMeshOfTriangles(points: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], triangles: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) Mesh[source]

Create a Unstructured mesh using only points and the connectivity matrix for the triangles.

Parameters:
  • points (ArrayLike) – The positions of the point (nb Points,3)

  • triangles (ArrayLike) – The connectivity of the triangles (nb Triangles, 3)

Returns:

A instance of Mesh with the triangles

Return type:

Mesh

CreateSquare(dimensions: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] = [2, 2], origin: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] = [-1.0, -1.0], spacing: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] = [1.0, 1.0], ofTriangles: bool = False) Mesh[source]

Create a mesh of a square

Parameters:
  • dimensions (ArrayLike, optional) – Number of points in every direction, by default [2,2]

  • origin (ArrayLike, optional) – origin of the mesh , by default [-1.0,-1.0]

  • spacing (ArrayLike, optional) – x and y size of every element, by default [1.,1.]

  • ofTriangles (bool, optional) – , by default False

Returns:

_description_

Return type:

Mesh

CreateUniformMeshOfBars(startPoint: float64 | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], stopPoint: float64 | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], nbPoints: int64 = 50, secondOrder: bool = False) Mesh[source]

Create a uniform mesh of bars. In the case the starPoint and stopPoint are scalar the nodes of the mesh are 3D (with zeros for the other columns) The user can give a list with only one component to generate nodes with only 1 coordinate 0D elements are created at the start and stop points with tags “L”, “H” nodal tags are created at the start and stop points with tags “L”, “H”

Parameters:
  • startPoint (Union[MuscatFloat,ArrayLike]) – Start point of the linear mesh

  • stopPoint (Union[MuscatFloat,ArrayLike]) – Stop point of the linear mesh

  • nbPoints (MuscatIndex, optional) – Number of point in the mesh, by default 50

  • secondOrder (bool, optional) – if true second order bars are generated. In this case the number of points (nbPoints) must be odd

Returns:

the mesh in Mesh format

Return type:

Mesh

Raises:

RuntimeError – if the startPoint and stopPoint are not compatible

MeshToSimplex(mesh: Mesh, inPlace=True) Mesh[source]

(EXPERIMENTAL) Convert mesh to only tetrahedron/triangle/bars/points

Warning!!! This function is dangerous, we don’t check the compatibility at each interface between the elements.

Parameters:
  • mesh (Mesh) – A mesh

  • inPlace (bool, optional, by default True) –

Returns:

A mesh composed only by simplex (this is the mesh inplace is True)

Return type:

Mesh

MirrorMesh(inmesh: Mesh, x: float64 | None = None, y: float64 | None = None, z: float64 | None = None) Mesh[source]

Compute a new symmetric mesh from the inmesh All element of inMesh are copied to the output The user is responsible to call RemoveDoubles to eliminate the possible double nodes on the symmetry plane

Parameters:
  • inmesh (Mesh) – input mesh

  • x (Optional[MuscatFloat], optional) – the position of the yz plane to build the symmetric part, if Non, no symmetry to the plane yz , by default None

  • y (Optional[MuscatFloat], optional) – the position of the xz plane to build the symmetric part, if Non, no symmetry to the plane xz , by default None

  • z (Optional[MuscatFloat], optional) – the position of the xy plane to build the symmetric part, if Non, no symmetry to the plane xy _description_, by default None

Returns:

the output mesh

Return type:

Mesh

QuadToLin(inputMesh: Mesh, divideQuadElements: bool = True, linearizedMiddlePoints: bool = False) Mesh[source]
Convert a quadratic mesh to a linear mesh

Nodes fields and element fields are lost.

Parameters:
  • inputMesh (Mesh) – the input mesh

  • divideQuadElements (bool, optional) – if the quadratic element must be divided, by default True

  • linearizedMiddlePoints (bool, optional) – if the middle point of the quadratic element must line in the segment formed by the extreme values , by default False

Returns:

a linear mesh

Return type:

Mesh

SubDivideMesh(mesh: Mesh, level: int64 = 1) Mesh[source]

Subdivide a mesh

Parameters:
  • mesh (Mesh) – The input mesh

  • level (MuscatIndex, optional) – Number of times the mesh must be divided, by default 1

Returns:

A new mesh divided level times

Return type:

Mesh

ToQuadraticMesh(inputMesh: Mesh) Mesh[source]

Function to convert any linear mesh to a quadratic mesh. Nodes fields and element fields are lost.

Parameters:

inputMesh (Mesh) – the in put mesh

Returns:

A mesh composed only by quadratic elements

Return type:

Mesh