MeshSolution (class)

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

class MeshSolution(label='', mesh=-1, is_same_mesh=True, solution=-1, group=None, dimension=2, path=None, init_dict=None, init_str=None)[source]

Bases: pyleecan.Classes._frozen.FrozenClass

Abstract class to associate a mesh with one or several solutions

VERSION = 1
get_mesh(label=None, index=None)

Return the mesh corresponding to label or an index.

Parameters
  • self (MeshSolution) – an MeshSolution object

  • label (str) – a label

  • index (int) – an index

Returns

mesh – a Mesh object

Return type

Mesh

get_solution(label=None, index=None)

Return the solution corresponding to label or an index.

Parameters
  • self (MeshSolution) – an MeshSolution object

  • label (str) – a label

  • index (int) – an index

Returns

solution – a Solution object

Return type

Solution

get_field(*args_list, label=None, index=None, indices=None, is_rthetaz=False, is_pol2cart=False, is_radial=False, is_normal=False, is_rms=False, is_center=False, is_surf=False, is_squeeze=True)

Return the solution corresponding to label or an index.

Parameters
  • self (MeshSolution) – an MeshSolution object

  • *args_list (list of strings) – List of axes requested by the user, their units and values (optional)

  • label (str) – a label

  • index (int) – an index

  • indices (list) – list of indices to extract from mesh and field

  • is_rthetaz (bool) – cylindrical coordinates

  • is_radial (bool) – radial component only

  • is_normal (bool) – normal component only (on nodes or centers)

  • is_rms (bool) – rms over surface sum((F.n)**2 dS)/S

  • is_center (bool) – field at cell centers

  • is_surf (bool) – field over outer surface

  • is_squeeze (bool) – squeeze the output result

Returns

result – field

Return type

ndarray

get_group(group_names)

Return all attributes of a MeshSolution object with only the cells, nodes and corresponding solutions of the group.

selfMeshSolution

an MeshSolution object

group_name[str]

list of the name of the group(s) (e.g. [“stator”])

meshsol_grp: MeshSolution

a new MeshSolution object which is subpart of self

get_mesh_field_pv(*args, label=None, index=None, indices=None, is_surf=False, is_radial=False, is_center=False, field_name=None, itimefreq=0)

Return the mesh and field adapted to pyvista plots.

Parameters
  • self (MeshSolution) – an MeshSolution object

  • *args (list of strings) – List of axes requested by the user, their units and values (optional)

  • label (str) – a label

  • index (int) – an index

  • indices (list) – list of indices

  • is_radial (bool) – radial component only

  • is_center (bool) – field at cell centers

  • field_name (str) – label of the field to return

  • itimefreq (int) – if the field depends has a time/freqs axis, return the timefreq-th slice.

Returns

  • mesh_pv (vtk.vtkPointSet) – a pyvista mesh object

  • field (ndarray) – an extracted field

  • field_name (str) – name of the extracted field (useful if not specified as input)

plot_mesh(label=None, index=None, indices=None, save_path=None, group_names=None, node_label=None, is_show_axes=False, is_show_fig=True)

Plot the mesh using pyvista plotter.

Parameters
  • self (MeshSolution) – a MeshSolution object

  • label (str) – a label

  • index (int) – an index

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

  • is_show_fig (bool) – To call show at the end of the method

plot_contour(*args, label=None, index=None, indices=None, is_surf=False, is_radial=False, is_center=False, clim=None, field_name=None, group_names=None, save_path=None, itimefreq=0, is_show_fig=True)

Plot the contour of a field on a mesh using pyvista plotter.

Parameters
  • self (MeshSolution) – a MeshSolution object

  • *args (list of strings) – List of axes requested by the user, their units and values (optional)

  • label (str) – a label

  • index (int) – an index

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

  • is_surf (bool) – field over outer surface

  • is_radial (bool) – radial component only

  • is_center (bool) – field at cell-centers

  • clim (list) – a list of 2 elements for the limits of the colorbar

  • field_name (str) – title of the field to display on plot

  • group_names (list) – a list of str corresponding to group name(s)

  • save_path (str) – path to save the figure

  • is_show_fig (bool) – To call show at the end of the method

plot_deflection(*args, label=None, index=None, indices=None, clim=None, factor=None, field_name=None, group_names=None, save_path=None, title='', win_title=None, is_surf=True, is_show_fig=True)

Plot the operational deflection shape using pyvista plotter.

Parameters
  • self (MeshSolution) – a MeshSolution object

  • label (str) – a label

  • index (int) – an index

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

  • clim (list) – a list of 2 elements for the limits of the colorbar

  • factor (float) – factor to multiply vector field

  • field_name (str) – title of the field to display on plot

  • is_show_fig (bool) – To call show at the end of the method

plot_deflection_animated(*args, label=None, index=None, indices=None, clim=None, factor=None, field_name=None, is_time=False, gif_name='animation.gif', gif_path='./', title='', group_names=None)

Create the gif of the animated operational deflection shape.

Parameters
  • self (MeshSolution) – a MeshSolution object

  • label (str) – a label

  • index (int) – an index

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

  • clim (list) – a list of 2 elements for the limits of the colorbar

  • factor (float) – factor to multiply vector field

  • field_name (str) – title of the field to display on plot

  • gif_name (str) – name of the gif file (should end with .gif)

  • gif_path (str) – path where gif will be saved

  • group_names ([str]) – plot is restricted to the group(s) corresponding to this list of group names.

plot_glyph(*args, label=None, index=None, indices=None, clim=None, factor=None, field_name=None, save_path=None, is_point_arrow=False, group_names=None, is_show_fig=True)

Plot the vector field as a glyph (or quiver) over the mesh.

Parameters
  • self (MeshSolution) – a MeshSolution object

  • *args (list of strings) – List of axes requested by the user, their units and values (optional)

  • label (str) – a label

  • index (int) – an index

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

  • clim (list) – a list of 2 elements for the limits of the colorbar

  • factor (float) – factor to multiply vector field

  • field_name (str) – title of the field to display on plot

  • save_path (str) – path to save the plot into an image

  • is_point_arrow (bool) – to plot a nodal field (point-wise solution required)

  • group_names ([str]) – plot is restricted to the group(s) corresponding to this list of group names.

plot_glyph_animated(*args, label=None, index=None, indices=None, clim=None, factor=None, field_name=None, is_time=False, is_point_arrow=False, gif_name='animation.gif', gif_path='./', title='', group_names=None)

Plot the vector field as a glyph (or quiver) over the mesh.

Parameters
  • self (MeshSolution) – a MeshSolution object

  • label (str) – a label

  • index (int) – an index

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

  • clim (list) – a list of 2 elements for the limits of the colorbar

  • factor (float) – factor to multiply vector field

  • field_name (str) – title of the field to display on plot

  • save_path (str) – path to save the plot into an image

  • is_point_arrow (bool) – to plot a nodal field (point-wise solution required)

  • group_names ([str]) – plot is restricted to the group(s) corresponding to this list of group names.

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

Permute coordinates of Mesh Solution in place

Parameters
  • self (MeshSolution) – a MeshSolution object

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

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 label

(Optional) Descriptive name of the mesh

Type

str

property mesh

A list of Mesh objects.

Type

[Mesh]

property is_same_mesh

1 if the mesh is the same at each step (time, mode etc.)

Type

bool

property solution

A list of Solution objects

Type

[Solution]

property group

Dict sorted by groups name with list of cells indices.

Type

dict

property dimension

Dimension of the physical problem

Type

int

Min

1

Max

3

property path

Path where the MeshSolution is stored as a file

Type

str