MeshVTK (class)

Method code available at https://github.com/Eomys/pyleecan/tree/master/pyleecan/Methods/Mesh/MeshVTK

class MeshVTK(mesh=None, is_pyvista_mesh=False, format='vtk', path=None, name='mesh', surf=None, is_vtk_surf=False, surf_path='', surf_name='', node_normals=None, label=None, dimension=2, init_dict=None, init_str=None)[source]

Bases: pyleecan.Classes.Mesh.Mesh

Gather the mesh storage format

VERSION = 1
get_mesh_pv(indices=None)

Return the pyvista mesh object (or submesh).

Parameters
  • self (MeshVTK) – a MeshVTK object

  • indices (list) – list of the points to extract (optional)

Returns

mesh – a pyvista UnstructuredGrid object

Return type

pyvista.core.pointset.UnstructuredGrid

get_node(indices=None)

Return the array of the nodes coordinates.

Parameters
  • self (MeshVTK) – a MeshVTK object

  • indices (list) – list of the nodes to extract (optional)

Returns

nodes – Points coordinates

Return type

ndarray

get_cell(indices=None)

Return the cells (connectivities).

Parameters
  • self (MeshVTK) – a MeshVTK object

  • indices (list) – list of the points to extract (optional)

Returns

cells – List of cell groups (type + array)

Return type

list

get_normals(indices=None, loc='center')

Return the array of the normals coordinates.

Parameters
  • self (MeshVTK) – a MeshVTK object

  • indices (list) – list of the points to extract (optional)

  • loc (str) – localization of the normals (“center” or “point”)

Returns

normals – Normals coordinates

Return type

ndarray

get_surf(indices=None)

Return the surf object if it was already extracted, or extracts it from the mesh.

Parameters
  • self (MeshVTK) – a MeshVTK object

  • indices (list) – list of the points to extract (optional)

Returns

surf – a pyvista polydata object

Return type

pyvista.core.pointset.PolyData

get_cell_area(indices=None)

Return the area of the cells on the outer surface.

Parameters
  • self (MeshVTK) – a MeshVTK object

  • indices (list) – list of the points to extract (optional)

Returns

areas – Area of the cells

Return type

ndarray

convert(meshtype, scale)

Convert this object to another type of Mesh object.

Parameters
  • self (MeshVTK) – a MeshVTK object

  • meshtype (str) – a type of Mesh object

  • scale (float) –

    scale factor

    Returns

  • -------

  • new_mesh (Mesh) – a Mesh object

as_dict()

Convert this object in a json seriable dict (can be use in __init__)

perm_coord(perm_coord_list=[0, 1, 2], path_meshVTK=None)

Returns the current MeshVTK object with permuted coordinates

Parameters
  • self (MeshVTK) – a MeshVTK object

  • perm_coord_list (list) – list of the coordinates to be permuted

  • path_meshVTK (str) – full path to the MeshVTK file

Returns

mesh – The MeshVTK object with permuted coordinates

Return type

MeshVTK

get_path(name=None, file_format='vtk')

return the path to the file to save the mesh

Parameters
  • self (MeshVTK) – MeshVTK Object

  • name (str) – Name of the file to use (None: use self.name)

  • file_format (str) – extension of the file to use

Returns

path – Full path to the mesh file

Return type

str

save(save_path='', is_folder=False)

Save the object to the save_path

Parameters
  • self – A pyleecan object

  • save_path (str) – path to the folder to save the object

  • is_folder (bool) – to split the object in different files: separate simulation machine and materials

copy(**kwargs)

Return a copy of the class

get_logger()

Get the object logger or its parent’s one

Parameters

obj – A pyleecan object

Returns

logger – Pyleecan object dedicated logger

Return type

logging.Logger

compare(other, name='self')[source]

Compare two objects and return list of differences

property mesh

Pyvista object of the mesh (optional)

Type

vtk.vtkPointSet

property is_pyvista_mesh

Store the pyvista object

Type

bool

property format

Format in which the mesh is stored

Type

str

property path

Path where the mesh is stored

Type

str

property name

Name of the mesh file

Type

str

property surf

Pyvista object of the outer surface

Type

pyvista.core.pointset.PolyData

property is_vtk_surf

Save the surface mesh in a vtk file

Type

bool

property surf_path

Path where the outer surface is stored

Type

str

property surf_name

Name of the outer surface file

Type

str

property node_normals

Array of normals to nodes (cell vertices)

Type

ndarray