Skip to content

Commit

Permalink
Merge develop and update code
Browse files Browse the repository at this point in the history
  • Loading branch information
PProfizi committed Aug 30, 2023
1 parent bec18d9 commit d05ec19
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/ansys/dpf/core/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from ansys.dpf import core
from ansys.dpf.core.common import locations, DefinitionLabels
from ansys.dpf.core.common import shell_layers as eshell_layers
from ansys.dpf.core.helpers.streamlines import _sort_supported_kwargs
from ansys.dpf.core.helpers.utils import _sort_supported_kwargs
from ansys.dpf.core import errors as dpf_errors
from ansys.dpf.core.nodes import Node, Nodes

Expand Down Expand Up @@ -363,16 +363,16 @@ def add_volume(
location = field.location
if location == locations.nodal:
mesh_location = meshed_region.nodes
elif location == locations.elemental:
mesh_location = meshed_region.elements
else:
raise ValueError("Only elemental or nodal location are supported for plotting.")
raise ValueError("Only nodal location is supported for volume rendering.")

Check warning on line 367 in src/ansys/dpf/core/plotter.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/dpf/core/plotter.py#L367

Added line #L367 was not covered by tests

component_count = field.component_count
if component_count > 1:
overall_data = np.full((len(mesh_location), component_count), np.nan)
else:
overall_data = np.full(len(mesh_location), np.nan)
raise ValueError(

Check warning on line 371 in src/ansys/dpf/core/plotter.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/dpf/core/plotter.py#L371

Added line #L371 was not covered by tests
"Only scalar fields with one component are supported for volume rendering."
)

overall_data = np.full(len(mesh_location), np.nan)
ind, mask = mesh_location.map_scoping(field.scoping)
overall_data[ind] = field.data[mask]

Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
ACCEPTABLE_FAILURE_RATE = 0

core.settings.disable_off_screen_rendering()
os.environ["PYVISTA_OFF_SCREEN"] = "true"
# os.environ["PYVISTA_OFF_SCREEN"] = "true"
core.settings.bypass_pv_opengl_osmesa_crash()
os.environ["MPLBACKEND"] = "Agg"
# currently running dpf on docker. Used for testing on CI
Expand Down
14 changes: 14 additions & 0 deletions tests/test_plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,3 +751,17 @@ def test_plot_polyhedron():

# Plot the MeshedRegion
mesh.plot()


@pytest.mark.skipif(not HAS_PYVISTA, reason="This test requires pyvista")
def test_plotter_add_volume(allkindofcomplexity):
model = Model(allkindofcomplexity)
mesh = model.metadata.meshed_region
stress = model.results.stress.on_location(location=dpf.core.locations.nodal)()
norm_op = dpf.core.operators.math.norm_fc(fields_container=stress.outputs.fields_container)
fc = norm_op.outputs.fields_container()
f = fc[0]
print(f)
plotter = DpfPlotter()
plotter.add_volume(field=f, meshed_region=mesh)
plotter.show_figure()

0 comments on commit d05ec19

Please sign in to comment.