Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use n_frames #15

Merged
merged 9 commits into from
Mar 6, 2021
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
19 changes: 12 additions & 7 deletions ansys/mapdl/reader/rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,11 +759,11 @@ def animate_nodal_solution(self, rnum, comp='norm',
node_components=None,
element_components=None,
sel_type_all=True, add_text=True,
displacement_factor=0.1, nangles=100,
displacement_factor=0.1, n_frames=100,
loop=True, movie_filename=None,
**kwargs):
"""Animate nodal solution. Assumes nodal solution is a
displacement array from a modal solution.
displacement array from a modal or static solution.

rnum : int or list
Cumulative result number with zero based indexing, or a
Expand Down Expand Up @@ -793,7 +793,7 @@ def animate_nodal_solution(self, rnum, comp='norm',
displacement_factor : float, optional
Increases or decreases displacement by a factor.

nangles : int, optional
n_frames : int, optional
Number of "frames" between each full cycle.

loop : bool, optional
Expand Down Expand Up @@ -824,6 +824,11 @@ def animate_nodal_solution(self, rnum, comp='norm',

>>> rst.animate_nodal_solution(0, movie_filename='disp.mp4')
"""
if 'nangles' in kwargs:
n_frames = kwargs.pop('nangles')
warnings.warn('The ``nangles`` kwarg is depreciated and ``n_frames`` '
'should be used instead.')

scalars = None
if comp:
_, disp = self.nodal_solution(rnum)
Expand Down Expand Up @@ -861,7 +866,7 @@ def animate_nodal_solution(self, rnum, comp='norm',
node_components=node_components,
element_components=element_components,
sel_type_all=sel_type_all,
nangles=nangles,
n_frames=n_frames,
displacement_factor=displacement_factor,
movie_filename=movie_filename,
loop=loop, **kwargs)
Expand Down Expand Up @@ -2407,7 +2412,7 @@ def cs_4x4(self, cs_cord, as_vtk_matrix=False):

def _plot_point_scalars(self, scalars, rnum=None, grid=None,
show_displacement=False, displacement_factor=1,
add_text=True, animate=False, nangles=100,
add_text=True, animate=False, n_frames=100,
overlay_wireframe=False, node_components=None,
element_components=None,
sel_type_all=True, movie_filename=None,
Expand Down Expand Up @@ -2587,10 +2592,10 @@ def q_callback():
plotter.add_key_event("q", q_callback)

first_loop = True
cached_normals = [None for _ in range(nangles)]
cached_normals = [None for _ in range(n_frames)]
while self._animating:

for j, angle in enumerate(np.linspace(0, np.pi*2, nangles + 1)[:-1]):
for j, angle in enumerate(np.linspace(0, np.pi*2, n_frames + 1)[:-1]):
mag_adj = np.sin(angle)
if scalars is not None:
copied_mesh.active_scalars[:] = scalars*mag_adj
Expand Down
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ def mapdl(request):
EXEC_FILE = get_ansys_bin(rver)
break

return launch_mapdl(EXEC_FILE, override=True, cleanup_on_exit=cleanup)
return launch_mapdl(EXEC_FILE, override=True, cleanup_on_exit=cleanup,
additional_switches='-smp')


@pytest.fixture(scope='function')
Expand Down
1 change: 1 addition & 0 deletions tests/test_binary_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ def test_file_close(tmpdir):
shutil.copy(examples.rstfile, tmpfile)
rst = pymapdl_reader.read_binary(tmpfile)
nnum, stress = rst.nodal_stress(0)
del rst
os.remove(tmpfile) # tests file has been correctly closed


Expand Down
9 changes: 8 additions & 1 deletion tests/test_dist_rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ def test_not_a_dis_rst(tmpdir):

@skip_no_ansys
def test_not_all_found(thermal_solution, mapdl, tmpdir):
if not mapdl._distributed:
return
filename = os.path.join(mapdl.directory, 'file0.rth')

tmp_file = os.path.join(mapdl.directory, 'tmp0.rth')
shutil.copy(filename, tmp_file)
with pytest.raises(FileNotFoundError):
Expand All @@ -93,6 +94,9 @@ def test_not_all_found(thermal_solution, mapdl, tmpdir):

@skip_no_ansys
def test_temperature(thermal_solution, mapdl, tmpdir):
if not mapdl._distributed:
return

ans_temp = mapdl.post_processing.nodal_temperature
dist_rst = pymapdl_reader.read_binary(os.path.join(mapdl.directory, 'file0.rth'))

Expand All @@ -109,6 +113,9 @@ def test_temperature(thermal_solution, mapdl, tmpdir):

@skip_no_ansys
def test_plot_temperature(thermal_solution, mapdl):
if not mapdl._distributed:
return

dist_rst = pymapdl_reader.read_binary(os.path.join(mapdl.directory, 'file0.rth'))
cpos = dist_rst.plot_nodal_temperature(0)
assert isinstance(cpos, CameraPosition)
Expand Down