MeshMat (class)

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

class MeshMat(cell=-1, node=-1, _is_renum=False, label=None, dimension=2, init_dict=None, init_str=None)[source]

Bases: pyleecan.Classes.Mesh.Mesh

Gather the mesh storage format

VERSION = 1
get_node(indices=None)

Return a matrix of nodes coordinates.

Parameters
  • self (Mesh) – an Mesh object

  • indices (list) – Indices of the targeted nodes. If None, return all.

  • is_indice (bool) – Option to return the nodes indices (useful for unsorted

Returns

  • coordinates (ndarray) – nodes coordinates

  • indices (ndarray) – nodes indices

get_node_indice(coordinates=None)

Return a matrix of nodes coordinates.

Parameters
  • self (Mesh) – an Mesh object

  • indices (list) – Indices of the targeted nodes. If None, return all.

  • is_indice (bool) – Option to return the nodes indices (useful for unsorted

Returns

  • coordinates (ndarray) – nodes coordinates

  • indices (ndarray) – nodes indices

get_cell(indices=None)

Return the connectivity for one selected element

Parameters
  • self (MeshMat) – an MeshMat object

  • indices (list) – list of indice. If None, return all.

Returns

cells – Dict of connectivities

Return type

dict

get_mesh_pv(path='D:/GitHub/pyleecan/pyleecan/Results/temp.vtk', indices=None)

Return the pyvista mesh object (or submesh).

Parameters
  • self (MeshMat) – a MeshMat object

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

Returns

mesh – a pyvista UnstructuredGrid object

Return type

pyvista.core.pointset.UnstructuredGrid

get_cell_area(indices=None)

Return the area of the cells on the outer surface. #TODO address multiple cell type issue, i.e. distracted indices :param self: a MeshMat object :type self: MeshMat :param indices: list of the points to extract (optional) :type indices: list

Returns

areas – Area of the cells

Return type

ndarray

get_vertice(indices=None)

Return a connectivity matrix where the nodes indices are replaced by their coordinates.

Parameters
  • self (MeshMat) – an MeshMat object

  • cell_type (str) – a key corresponding to an element type

  • group (ndarray) – One or several group numbers to be returned

Returns

vertice – Selected vertices

Return type

ndarray

get_node2cell(node_indice)

Return all cell indices of cells containing a node.

Parameters
  • self (MeshMat) – an MeshMat object

  • node_indice (int) – a node indice

Returns

node_to_cell – Indices of cells containing the node

Return type

ndarray

add_cell(node_indices, cell_type)

Add a new cell defined by node indices and cell type.

Parameters
  • self (MeshMat) – an Mesh object

  • node_indices (ndarray) – a ndarray of points indices

  • cell_type (str) – Define the type of cell.

Returns

new_ind – indice of the newly created cell. None if the cell already exists.

Return type

int

renum()

Restart point indices from 0, and update connectivity. Indices of cells stay the same.

Parameters

self (MeshMat) – an Mesh object

find_cell(points, nb_pt, normal_t=None)

Return the cells containing the target point(s)

Parameters
  • self (MeshMat) – an MeshMat object

  • points (ndarray) – coordinates of the target point(s)

  • nb_pt (int) – number of target points

Returns

cell_list – A list of of selected cells

Return type

list

interface(other_mesh)

Define a MeshMat object corresponding to the exact intersection between two meshes (nodes must be in both meshes).

Parameters
  • self (MeshMat) – a Mesh object

  • other_mesh (Mesh) –

    an other Mesh object

    Returns

  • -------

clear_node()

Remove non-used nodes based on cells connectivity.

Parameters

self (MeshMat) – an Mesh object

clear_cell()

Remove non-used cells based on node indices.

Parameters

self (MeshMat) – an Mesh object

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

as_dict(**kwargs)[source]

Convert this object in a json serializable dict (can be use in __init__). Optional keyword input parameter is for internal use only and may prevent json serializability.

property cell

Storing connectivity

Type

{CellMat}

property node

Storing nodes

Type

NodeMat