MeshSolution (class)

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

class MeshSolution(label=None, mesh=-1, is_same_mesh=True, solution=-1, group=None, dimension=2, 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

  • group (list) – list of indices of part(s) of the mesh

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(label=None, index=None, indices=None, is_rthetaz=False, is_radial=False, is_normal=False, is_rms=False, is_center=False, is_surf=False, args=None)

Return the solution corresponding to label or an index.

Parameters
  • self (MeshSolution) – an MeshSolution object

  • 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

Returns

result – field

Return type

ndarray

plot_mesh(label=None, index=None, indices=None, save_path=None, group_names=None, 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(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, itime=0, is_show_fig=True)

Plot the contour of a field on a 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_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

  • itime (int) – index of the time step to be plotted

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

plot_deflection(label=None, index=None, indices=None, clim=None, factor=None, field_name=None, ifreq=0, save_path=None)

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

  • ifreq (int) – index of the frequency to use for plot (if exists)

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

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

plot_glyph(label=None, index=None, indices=None, clim=None, factor=None, field_name=None, ifreq=0, save_path=None, is_point_arrow=False, 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

  • ifreq (int) – index of the frequency to use for plot (if exists)

  • 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.

get_group(group_names)

Return all attributes of a MeshSolution object with only the cells, points and corresponding solutions of the group. Solutions are converted as SolutionMat.

selfMeshSolution

an MeshSolution object

group_namestr

the name of the group (e.g. “stator”)

grp_cells: dict

a dict sorted by cell type containing connectivity of the group

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()

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

as_dict()[source]

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

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 cells indices.

Type

{ndarray}

property dimension

Dimension of the physical problem

Type

int

Min

1

Max

3