Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 109 additions & 12 deletions ansys/mapdl/reader/cyclic_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ def plot_nodal_thermal_strain(self, rnum,
sel_type_all=True,
add_text=True,
overlay_wireframe=False,
treat_nan_as_zero=True,
**kwargs):
"""Plot nodal thermal strain.

Expand Down Expand Up @@ -688,6 +689,10 @@ def plot_nodal_thermal_strain(self, rnum,
If node_components is specified, plots those elements
containing all nodes of the component. Default ``True``.

treat_nan_as_zero : bool, optional
Treat NAN values (i.e. stresses at midside nodes) as zero
when plotting.

Returns
-------
cpos : list
Expand All @@ -701,7 +706,9 @@ def plot_nodal_thermal_strain(self, rnum,

"""
if not full_rotor:
return super().plot_nodal_thermal_strain(rnum, **kwargs)
return super().plot_nodal_thermal_strain(rnum,
treat_nan_as_zero=treat_nan_as_zero,
**kwargs)

idx = check_comp(THERMAL_STRAIN_TYPES, comp)
_, strain = self.nodal_thermal_strain(rnum, phase, False, True)
Expand All @@ -718,7 +725,10 @@ def plot_nodal_thermal_strain(self, rnum,
kwargs['element_components'] = element_components
kwargs['sel_type_all'] = sel_type_all
kwargs['phase'] = phase
return self._plot_cyclic_point_scalars(scalars, rnum, **kwargs)
return self._plot_cyclic_point_scalars(scalars,
rnum,
treat_nan_as_zero=treat_nan_as_zero,
**kwargs)

def nodal_elastic_strain(self, rnum, phase=0, as_complex=False,
full_rotor=False):
Expand Down Expand Up @@ -782,6 +792,7 @@ def plot_nodal_elastic_strain(self, rnum,
sel_type_all=True,
add_text=True,
overlay_wireframe=False,
treat_nan_as_zero=True,
**kwargs):
"""Plot nodal elastic strain.

Expand Down Expand Up @@ -827,14 +838,18 @@ def plot_nodal_elastic_strain(self, rnum,
If node_components is specified, plots those elements
containing all nodes of the component. Default ``True``.

treat_nan_as_zero : bool, optional
Treat NAN values (i.e. stresses at midside nodes) as zero
when plotting.

Returns
-------
cpos : list
Camera position from vtk render window.

Examples
--------
Plot nodal elastic strain for an academic rotor
Plot nodal elastic strain for an academic rotor.

>>> result.plot_nodal_elastic_strain(0, 'X')

Expand All @@ -854,7 +869,10 @@ def plot_nodal_elastic_strain(self, rnum,
kwargs['element_components'] = element_components
kwargs['sel_type_all'] = sel_type_all
kwargs['phase'] = phase
return self._plot_cyclic_point_scalars(scalars, rnum, **kwargs)
return self._plot_cyclic_point_scalars(scalars,
rnum,
treat_nan_as_zero=treat_nan_as_zero,
**kwargs)

def nodal_plastic_strain(self, rnum, phase=0, as_complex=False,
full_rotor=False):
Expand Down Expand Up @@ -918,6 +936,7 @@ def plot_nodal_plastic_strain(self, rnum,
sel_type_all=True,
add_text=True,
overlay_wireframe=False,
treat_nan_as_zero=True,
**kwargs):
"""Plot nodal plastic strain.

Expand Down Expand Up @@ -963,6 +982,10 @@ def plot_nodal_plastic_strain(self, rnum,
If node_components is specified, plots those elements
containing all nodes of the component. Default ``True``.

treat_nan_as_zero : bool, optional
Treat NAN values (i.e. stresses at midside nodes) as zero
when plotting.

Returns
-------
cpos : list
Expand Down Expand Up @@ -990,7 +1013,10 @@ def plot_nodal_plastic_strain(self, rnum,
kwargs['element_components'] = element_components
kwargs['sel_type_all'] = sel_type_all
kwargs['phase'] = phase
return self._plot_cyclic_point_scalars(scalars, rnum, **kwargs)
return self._plot_cyclic_point_scalars(scalars,
rnum,
treat_nan_as_zero=treat_nan_as_zero,
**kwargs)

def principal_nodal_stress(self, rnum, phase=0, as_complex=False,
full_rotor=False):
Expand Down Expand Up @@ -1072,6 +1098,7 @@ def plot_nodal_solution(self, rnum, comp='norm',
overlay_wireframe=False,
add_text=True,
sel_type_all=True,
treat_nan_as_zero=True,
**kwargs):
"""Plot the nodal solution (generally displacement).

Expand Down Expand Up @@ -1108,11 +1135,21 @@ def plot_nodal_solution(self, rnum, comp='norm',
If node_components is specified, plots those elements
containing all nodes of the component. Default ``True``.

treat_nan_as_zero : bool, optional
Treat NAN values (i.e. stresses at midside nodes) as zero
when plotting.

Returns
-------
cpos : list
Camera position from vtk render window.

Examples
--------
Plot the displacement of the first cyclic result.

>>> result.plot_nodal_solution(0)

"""

# Load result from file
Expand All @@ -1124,6 +1161,7 @@ def plot_nodal_solution(self, rnum, comp='norm',
node_components=node_components,
element_components=element_components,
sel_type_all=sel_type_all,
treat_nan_as_zero=treat_nan_as_zero,
**kwargs)

rnum = self.parse_step_substep(rnum)
Expand Down Expand Up @@ -1156,7 +1194,10 @@ def plot_nodal_solution(self, rnum, comp='norm',
kwargs['element_components'] = element_components
kwargs['sel_type_all'] = sel_type_all
kwargs['phase'] = phase
return self._plot_cyclic_point_scalars(scalars, rnum, **kwargs)
return self._plot_cyclic_point_scalars(scalars,
rnum,
treat_nan_as_zero=treat_nan_as_zero,
**kwargs)

def plot_nodal_stress(self, rnum,
comp=None,
Expand All @@ -1168,7 +1209,9 @@ def plot_nodal_stress(self, rnum,
element_components=None,
overlay_wireframe=False,
add_text=True,
sel_type_all=True, **kwargs):
sel_type_all=True,
treat_nan_as_zero=True,
**kwargs):
"""Plot nodal stress of a given component

Parameters
Expand Down Expand Up @@ -1213,19 +1256,31 @@ def plot_nodal_stress(self, rnum,
If node_components is specified, plots those elements
containing all nodes of the component. Default ``True``.

treat_nan_as_zero : bool, optional
Treat NAN values (i.e. stresses at midside nodes) as zero
when plotting.

Returns
-------
cpos : list
Camera position from vtk render window.

Examples
--------
Plot the ``"Z"`` nodal stress of the first cyclic result.

>>> result.plot_nodal_stress(0, comp="Z")

"""
if not full_rotor:
super().plot_nodal_stress(rnum, comp,
show_displacement,
displacement_factor,
node_components,
element_components,
sel_type_all, **kwargs)
sel_type_all,
treat_nan_as_zero=treat_nan_as_zero,
**kwargs)

idx = check_comp(STRESS_TYPES, comp)
_, stress = self.nodal_stress(rnum, phase, False, full_rotor=True)
Expand All @@ -1243,7 +1298,10 @@ def plot_nodal_stress(self, rnum,
kwargs['element_components'] = element_components
kwargs['sel_type_all'] = sel_type_all
kwargs['phase'] = phase
return self._plot_cyclic_point_scalars(scalars, rnum, **kwargs)
return self._plot_cyclic_point_scalars(scalars,
rnum,
treat_nan_as_zero=treat_nan_as_zero,
**kwargs)

def plot_principal_nodal_stress(self, rnum,
comp=None,
Expand All @@ -1256,6 +1314,7 @@ def plot_principal_nodal_stress(self, rnum,
sel_type_all=True,
add_text=True,
overlay_wireframe=False,
treat_nan_as_zero=True,
**kwargs):
"""Plot the nodal principal stress.

Expand Down Expand Up @@ -1294,6 +1353,10 @@ def plot_principal_nodal_stress(self, rnum,
If node_components is specified, plots those elements
containing all nodes of the component. Default ``True``.

treat_nan_as_zero : bool, optional
Treat NAN values (i.e. stresses at midside nodes) as zero
when plotting.

kwargs : keyword arguments
Additional keyword arguments. See ``help(pyvista.plot)``

Expand All @@ -1302,14 +1365,22 @@ def plot_principal_nodal_stress(self, rnum,
cpos : list
VTK camera position.

Examples
--------
Plot the von Mises stress of the first cyclic result.

>>> result.plot_principal_nodal_stress(0, comp='SEQV')

"""
if not full_rotor:
return super().plot_principal_nodal_stress(rnum, comp,
show_displacement,
displacement_factor,
node_components,
element_components,
sel_type_all, **kwargs)
sel_type_all,
treat_nan_as_zero=treat_nan_as_zero,
**kwargs)

# get the correct component of the principal stress for the rotor
idx = check_comp(PRINCIPAL_STRESS_TYPES, comp)
Expand All @@ -1328,7 +1399,10 @@ def plot_principal_nodal_stress(self, rnum,
kwargs['element_components'] = element_components
kwargs['sel_type_all'] = sel_type_all
kwargs['phase'] = phase
self._plot_cyclic_point_scalars(scalars, rnum, **kwargs)
self._plot_cyclic_point_scalars(scalars,
rnum,
treat_nan_as_zero=treat_nan_as_zero,
**kwargs)

def nodal_temperature(self, rnum, full_rotor=False):
"""Retrieves the temperature for each node in the solution.
Expand Down Expand Up @@ -1381,6 +1455,7 @@ def plot_nodal_temperature(self, rnum,
add_text=True,
element_components=None,
sel_type_all=True,
treat_nan_as_zero=True,
**kwargs):
"""Plot the nodal temperature.

Expand Down Expand Up @@ -1411,11 +1486,21 @@ def plot_nodal_temperature(self, rnum,
If node_components is specified, plots those elements
containing all nodes of the component. Default ``True``.

treat_nan_as_zero : bool, optional
Treat NAN values (i.e. stresses at midside nodes) as zero
when plotting.

Returns
-------
cpos : list
Camera position from vtk render window.

Examples
--------
Plot the nodal temperature of a rotor for the first result.

>>> result.plot_nodal_temperature(0)

"""
# Load result from file
if not full_rotor:
Expand All @@ -1425,6 +1510,7 @@ def plot_nodal_temperature(self, rnum,
node_components=node_components,
element_components=element_components,
sel_type_all=sel_type_all,
treat_nan_as_zero=treat_nan_as_zero,
**kwargs)

_, temp = self.nodal_temperature(rnum, True)
Expand All @@ -1439,7 +1525,10 @@ def plot_nodal_temperature(self, rnum,
kwargs['element_components'] = element_components
kwargs['sel_type_all'] = sel_type_all
kwargs['phase'] = phase
return self._plot_cyclic_point_scalars(temp, rnum, **kwargs)
return self._plot_cyclic_point_scalars(temp,
rnum,
treat_nan_as_zero=treat_nan_as_zero,
**kwargs)

def animate_nodal_solution(self, rnum, comp='norm',
displacement_factor=0.1,
Expand Down Expand Up @@ -1654,6 +1743,7 @@ def _plot_cyclic_point_scalars(self, scalars, rnum,
element_components=None,
sel_type_all=True,
phase=None,
treat_nan_as_zero=True,
**kwargs):
"""Plot point scalars on active mesh.

Expand Down Expand Up @@ -1682,6 +1772,10 @@ def _plot_cyclic_point_scalars(self, scalars, rnum,
add_text : bool, optional
Adds information about the result when rnum is given.

treat_nan_as_zero : bool, optional
Treat NAN values (i.e. stresses at midside nodes) as zero
when plotting.

kwargs : keyword arguments
Additional keyword arguments. See ``help(pyvista.plot)``

Expand All @@ -1704,6 +1798,9 @@ def _plot_cyclic_point_scalars(self, scalars, rnum,
if scalars is not None:
scalars = scalars[:, ind]

if treat_nan_as_zero and scalars is not None:
scalars[np.isnan(scalars)] = 0

# must be removed before add_mesh **kwargs
window_size = kwargs.pop('window_size', None)
full_screen = kwargs.pop('full_screen', False)
Expand Down
Loading