diff --git a/.devcontainer/codespaces-dev/requirements.txt b/.devcontainer/codespaces-dev/requirements.txt index fa86460fcc..c01ce8f592 100644 --- a/.devcontainer/codespaces-dev/requirements.txt +++ b/.devcontainer/codespaces-dev/requirements.txt @@ -4,11 +4,11 @@ matplotlib==3.8.3 scipy==1.12.0 pandas==2.2.1 pyiges[full]==0.3.1 -pytest==8.0.2 +pytest==8.1.1 pytest-cov==4.1.0 -pyvista==0.43.3 +pyvista==0.43.4 pyansys-tools-report==0.7.0 vtk==9.3.0 -pytest-rerunfailures==13.0 +pytest-rerunfailures==14.0 pytest-pyvista==0.1.9 pytest-timeout==2.3.1 \ No newline at end of file diff --git a/.devcontainer/codespaces-docs/requirements.txt b/.devcontainer/codespaces-docs/requirements.txt index 509a120214..48bc9db155 100644 --- a/.devcontainer/codespaces-docs/requirements.txt +++ b/.devcontainer/codespaces-docs/requirements.txt @@ -1,8 +1,8 @@ sphinx==7.2.6 ansys-dpf-core==0.10.1 ansys-mapdl-reader==0.53.0 -ansys-sphinx-theme==0.14.0 -grpcio==1.62.0 +ansys-sphinx-theme==0.14.1 +grpcio==1.62.1 imageio-ffmpeg==0.4.9 imageio==2.34.0 jupyter_sphinx==0.5.3 @@ -10,12 +10,12 @@ jupyterlab>=3.2.8 matplotlib==3.8.3 numpydoc==1.6.0 pandas==2.2.1 -plotly==5.19.0 +plotly==5.20.0 pyiges[full]==0.3.1 pypandoc==1.13 pytest-sphinx==0.6.0 pythreejs==2.4.2 -pyvista[trame]==0.43.3 +pyvista[trame]==0.43.4 sphinx-autobuild==2024.2.4 sphinx-autodoc-typehints==1.25.2 sphinx-copybutton==0.5.2 diff --git a/.devcontainer/devcontainer-local/requirements.txt b/.devcontainer/devcontainer-local/requirements.txt index fa86460fcc..c01ce8f592 100644 --- a/.devcontainer/devcontainer-local/requirements.txt +++ b/.devcontainer/devcontainer-local/requirements.txt @@ -4,11 +4,11 @@ matplotlib==3.8.3 scipy==1.12.0 pandas==2.2.1 pyiges[full]==0.3.1 -pytest==8.0.2 +pytest==8.1.1 pytest-cov==4.1.0 -pyvista==0.43.3 +pyvista==0.43.4 pyansys-tools-report==0.7.0 vtk==9.3.0 -pytest-rerunfailures==13.0 +pytest-rerunfailures==14.0 pytest-pyvista==0.1.9 pytest-timeout==2.3.1 \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 55540afddb..f2cf711e97 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -424,6 +424,7 @@ jobs: - uses: codecov/codecov-action@v4 name: "Upload coverage to Codecov" with: + token: ${{ secrets.CODECOV_TOKEN }} # required name: centos-${{ matrix.mapdl-version }}-remote.xml flags: centos,remote,${{ matrix.mapdl-version }} @@ -587,6 +588,7 @@ jobs: - uses: codecov/codecov-action@v4 name: "Upload coverage to Codecov" with: + token: ${{ secrets.CODECOV_TOKEN }} # required root_dir: ${{ github.workspace }} name: ${{ matrix.mapdl-image }}-local.xml flags: ubuntu,local,${{ matrix.mapdl-image }} @@ -677,6 +679,7 @@ jobs: - uses: codecov/codecov-action@v4 name: "Upload coverage to Codecov" with: + token: ${{ secrets.CODECOV_TOKEN }} # required root_dir: ${{ github.workspace }} name: ${{ matrix.mapdl-image }}-minimal.xml flags: ubuntu,local,${{ matrix.mapdl-image }},minimal @@ -748,6 +751,7 @@ jobs: - uses: codecov/codecov-action@v4 name: "Upload coverage to Codecov" with: + token: ${{ secrets.CODECOV_TOKEN }} # required name: windows-v22.2.0-local.xml flags: windows,local,v22.2.0 diff --git a/pyproject.toml b/pyproject.toml index ddc9a67319..849493fdd6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,12 +68,12 @@ tests = [ "scipy==1.12.0", "pandas==2.2.1", "pyiges[full]==0.3.1", - "pytest==8.0.2", + "pytest==8.1.1", "pytest-cov==4.1.0", - "pyvista==0.43.3", + "pyvista==0.43.4", "pyansys-tools-report==0.7.0", "vtk==9.3.0", - "pytest-rerunfailures==13.0", + "pytest-rerunfailures==14.0", "pytest-pyvista==0.1.9", "pytest-memprof<0.3.0", ] @@ -81,8 +81,8 @@ doc = [ "sphinx==7.2.6", "ansys-dpf-core==0.10.1", "ansys-mapdl-reader==0.53.0", - "ansys-sphinx-theme==0.14.0", - "grpcio==1.62.0", + "ansys-sphinx-theme==0.14.1", + "grpcio==1.62.1", "imageio-ffmpeg==0.4.9", "imageio==2.34.0", "jupyter_sphinx==0.5.3", @@ -90,12 +90,12 @@ doc = [ "matplotlib==3.8.3", "numpydoc==1.6.0", "pandas==2.2.1", - "plotly==5.19.0", + "plotly==5.20.0", "pyiges[full]==0.3.1", "pypandoc==1.13", "pytest-sphinx==0.6.0", "pythreejs==2.4.2", - "pyvista[trame]==0.43.3", + "pyvista[trame]==0.43.4", "sphinx-autobuild==2024.2.4", "sphinx-autodoc-typehints==1.25.2", "sphinx-copybutton==0.5.2", diff --git a/src/ansys/mapdl/core/launcher.py b/src/ansys/mapdl/core/launcher.py index ffff4b2174..fd091ae04e 100644 --- a/src/ansys/mapdl/core/launcher.py +++ b/src/ansys/mapdl/core/launcher.py @@ -806,6 +806,10 @@ def get_start_instance(start_instance: bool = True): if "PYMAPDL_START_INSTANCE" in os.environ and os.environ["PYMAPDL_START_INSTANCE"]: # It should not be empty start_instance = os.environ["PYMAPDL_START_INSTANCE"] + else: + LOG.debug( + f"PYMAPDL_START_INSTANCE is unset. Using default value {start_instance}." + ) if isinstance(start_instance, str): start_instance = start_instance.lower().strip() @@ -819,9 +823,6 @@ def get_start_instance(start_instance: bool = True): return start_instance == "true" elif isinstance(start_instance, bool): - LOG.debug( - f"PYMAPDL_START_INSTANCE is unset, using default value {start_instance}" - ) return start_instance elif start_instance is None: @@ -1567,8 +1568,8 @@ def launch_mapdl( version = _verify_version(version) # return a int version or none # Getting "start_instance" using "True" as default. - start_instance = get_start_instance(True) - LOG.debug("Using 'start_instance' equal to %s", start_instance) + start_instance = get_start_instance(start_instance=start_instance) + LOG.debug("Using 'start_instance' equal to %s.", start_instance) if start_instance: # special handling when building the gallery outside of CI. This @@ -1613,6 +1614,23 @@ def launch_mapdl( if pymapdl.BUILDING_GALLERY: # pragma: no cover LOG.debug("Building gallery.") + if _debug_no_launch: + return pack_parameters( + port, + ip, + add_env_vars, + replace_env_vars, + cleanup_on_exit, + loglevel, + set_no_abort, + remove_temp_dir_on_exit, + log_apdl, + use_vtk, + start_parm, + start_instance, + version, + ) + mapdl = MapdlGrpc( ip=ip, port=port, @@ -1638,7 +1656,7 @@ def launch_mapdl( LOG.debug("Using default executable.") # Load cached path - exec_file = get_ansys_path(version=version) + exec_file = get_ansys_path(version=version) if not _debug_no_launch else "" if exec_file is None: raise FileNotFoundError( "Invalid exec_file path or cannot load cached " @@ -1679,7 +1697,7 @@ def launch_mapdl( # verify no lock file and the mode is valid check_lock_file(run_location, jobname, override) - if _HAS_ATP: + if _HAS_ATP and not _debug_no_launch: mode = check_mode(mode, version_from_path("mapdl", exec_file)) LOG.debug("Using mode %s", mode) else: @@ -1763,6 +1781,8 @@ def launch_mapdl( log_apdl, use_vtk, start_parm, + start_instance, + version, ) port, actual_run_location, process = launch_grpc( @@ -2211,6 +2231,8 @@ def pack_parameters( log_apdl, use_vtk, start_parm, + start_instance, + version, ): # pack all the arguments in a dict for debugging purposes dict_ = {} @@ -2225,5 +2247,6 @@ def pack_parameters( dict_["log_apdl"] = log_apdl dict_["use_vtk"] = use_vtk dict_["start_parm"] = start_parm - + dict_["start_instance"] = start_instance + dict_["version"] = version return dict_ diff --git a/src/ansys/mapdl/core/mapdl_core.py b/src/ansys/mapdl/core/mapdl_core.py index 8be542c836..126264f68f 100644 --- a/src/ansys/mapdl/core/mapdl_core.py +++ b/src/ansys/mapdl/core/mapdl_core.py @@ -2696,6 +2696,20 @@ def _raise_errors(self, text): text += base_error_msg raise ComponentNoData(text) + if "is not part of the currently active set." in flat_text: + text += base_error_msg + raise MapdlCommandIgnoredError(text) + + if "No nodes defined." in flat_text: + text += base_error_msg + raise MapdlCommandIgnoredError(text) + + if "For element type = " in flat_text and "is invalid." in flat_text: + if "is normal behavior when a CDB file is used." in flat_text: + warn(text) + else: + raise MapdlCommandIgnoredError(text) + # flag errors if "*** ERROR ***" in flat_text: self._raise_output_errors(text) diff --git a/src/ansys/mapdl/core/mapdl_grpc.py b/src/ansys/mapdl/core/mapdl_grpc.py index 440aabfb41..3a7e3bf0f6 100644 --- a/src/ansys/mapdl/core/mapdl_grpc.py +++ b/src/ansys/mapdl/core/mapdl_grpc.py @@ -1084,7 +1084,7 @@ def _kill_server(self): pass if ( - self._version >= 24.2 + self._version and self._version >= 24.2 ): # We can't use the non-cached version because of recursion error. # self.run("/EXIT,NOSAVE,,,,,SERVER") self._ctrl("EXIT") diff --git a/src/ansys/mapdl/core/plotting.py b/src/ansys/mapdl/core/plotting.py index de50516827..f55fc71817 100644 --- a/src/ansys/mapdl/core/plotting.py +++ b/src/ansys/mapdl/core/plotting.py @@ -21,6 +21,7 @@ # SOFTWARE. """Plotting helper for MAPDL using pyvista""" +from collections import OrderedDict from typing import Any, Optional from warnings import warn @@ -48,16 +49,20 @@ "FY", "FZ", "AMPS", - "CHRGS", + "CHRG", # "FLUX", "CSGZ", ] # TODO: Add moments MX, MY, MZ FIELDS = { "MECHANICAL": ["UX", "UY", "UZ", "FX", "FY", "FZ"], "THERMAL": ["TEMP", "HEAT"], - "ELECTRICAL": ["VOLT", "CHRGS", "AMPS"], + "ELECTRICAL": ["VOLT", "CHRG", "AMPS"], } +FIELDS_ORDERED_LABELS = FIELDS["MECHANICAL"].copy() +FIELDS_ORDERED_LABELS.extend(FIELDS["THERMAL"]) +FIELDS_ORDERED_LABELS.extend(FIELDS["ELECTRICAL"]) + # All boundary conditions: BCS = BC_D.copy() @@ -663,7 +668,7 @@ def general_plotter( * **'electrical'** To plot the following electrical boundary conditions: - 'VOLT', 'CHRGS', and 'AMPS'. + 'VOLT', 'CHRG', and 'AMPS'. Defaults to all the allowed boundary conditions present in the responses of :func:`ansys.mapdl.core.Mapdl.dlist` @@ -740,7 +745,7 @@ def general_plotter( +------------+--------------------------------------+ | THERMAL | ["TEMP", "HEAT"] | +------------+--------------------------------------+ - | ELECTRICAL | ["VOLT", "CHRGS", "AMPS"] | + | ELECTRICAL | ["VOLT", "CHRG", "AMPS"] | +------------+--------------------------------------+ Examples @@ -898,6 +903,9 @@ def bc_plotter( else: bc_labels = _bc_labels_default(mapdl) + if not bc_labels: + return pl + if bc_target: bc_target = _bc_target_checker(bc_target) else: @@ -914,10 +922,11 @@ def bc_plotter( bc_glyph_size = get_bounding_box(mapdl.mesh.nodes) bc_glyph_size = bc_glyph_size[bc_glyph_size != 0] + ratio = 0.075 # Because a glyph of 1 is too big. if bc_glyph_size.size != 0: - bc_glyph_size = bc_glyph_size.mean() * 0.75 / 10 + bc_glyph_size = bc_glyph_size.mean() * ratio else: # Case were there is only one node - bc_glyph_size = 1 + bc_glyph_size = ratio if not isinstance(bc_glyph_size, (int, float)): raise ValueError("The 'bc_glyph_size' parameter can be only an int or float.") @@ -1005,6 +1014,7 @@ def bc_nodes_plotter( # line_width=3, name=name_, label=name_, + opacity=0.50, ) if plot_bc_labels: @@ -1029,9 +1039,41 @@ def bc_nodes_plotter( pcloud["labels"], shape_opacity=0.25, font_size=bc_labels_font_size, + # There is a conflict here. See + # To do not hide the labels, even when the underlying nodes + # are hidden, we set "always_visible" + always_visible=True, + show_points=False, # to not have node duplicity ) if plot_bc_legend: + # Reorder labels to keep a consistent order + sorted_dict = OrderedDict() + labels_ = pl.renderer._labels.copy() + + # sorting the keys + for symbol in FIELDS_ORDERED_LABELS: + for key, value in labels_.items(): + # taking advantage and overriding the legend glyph with + # something it can be seen properly in the legend + label_ = value[1] + if "U" in label_: + value = [BC_plot_settings("UY")["glyph"], label_, value[2]] + elif "F" in label_: + value = [BC_plot_settings("FX")["glyph"], label_, value[2]] + else: + value = [BC_plot_settings(label_)["glyph"], label_, value[2]] + + if symbol == value[1]: + sorted_dict[key] = value + + # moving the not added labels (just in case) + for key, value in labels_.items(): + if label_ not in FIELDS_ORDERED_LABELS: + sorted_dict[key] = value + + # overwriting labels + pl.renderer._labels = sorted_dict pl.add_legend(bcolor=None) return pl diff --git a/src/ansys/mapdl/core/plotting_defaults.py b/src/ansys/mapdl/core/plotting_defaults.py index 59b2a8812b..0d723b7652 100644 --- a/src/ansys/mapdl/core/plotting_defaults.py +++ b/src/ansys/mapdl/core/plotting_defaults.py @@ -21,10 +21,48 @@ # SOFTWARE. import pyvista as pv - -# Symbols for constrains +from pyvista.core import _vtk_core as _vtk +from pyvista.core.utilities import translate +from pyvista.core.utilities.helpers import wrap +from pyvista.core.utilities.misc import no_new_attr + +# I dont want to have to fix a very recent lower bound for pyvista. +# Hence I'm copying what I need from there. +# copied from pyvista source code: +# https://github.com/pyvista/pyvista/blob/35396c2e7645a6b57ad30d25ac1893f2141aab95/pyvista/core/utilities/geometric_sources.py#L2254 + + +@no_new_attr +class ArrowSource(_vtk.vtkArrowSource): + def __init__( + self, + tip_length=0.25, + tip_radius=0.1, + tip_resolution=20, + shaft_radius=0.05, + shaft_resolution=20, + ): + """Initialize source.""" + self.SetTipLength(tip_length) + self.SetTipRadius(tip_radius) + self.SetTipResolution(tip_resolution) + self.SetShaftResolution(shaft_resolution) + self.SetShaftRadius(shaft_radius) + + @property + def output(self): + """Get the output data object for a port on this algorithm. + + Returns + ------- + pyvista.PolyData + Plane mesh. + """ + self.Update() + return wrap(self.GetOutput()) +# Symbols for constrains class DefaultSymbol: # Class to store the symbols because of https://github.com/ansys/pymapdl/issues/2872 # To solve that issue, we avoid having to load the pyvista attributes when the module is load. @@ -41,109 +79,83 @@ def __call__(self, name): return getattr(self, name) def _set_configuration(self): - # Setting the - self.TEMP = { - "color": "orange", - "glyph": pv.Sphere(center=(0, 0, 0), radius=0.5), - } + self._point = pv.Sphere(center=(0, 0, 0), radius=0.5) + self._cube = pv.Cube(center=(0, 0, 0), x_length=1, y_length=1, z_length=1) + + def _basic_arrow( + start=(0.0, 0.0, 0.0), + direction=(1.0, 0.0, 0.0), + tip_length=0.5, + tip_radius=0.25, + tip_resolution=20, + shaft_radius=0.05, + shaft_resolution=20, + invert=True, + ): + arrow = ArrowSource( + tip_length=tip_length, + tip_radius=tip_radius, + tip_resolution=tip_resolution, + shaft_radius=shaft_radius, + shaft_resolution=shaft_resolution, + ) + arrow.SetInvert(invert) + surf = arrow.output - self.HEAT = { - "color": "red", - "glyph": pv.Arrow( - start=(-1, 0, 0), - direction=(1, 0, 0), - tip_length=1, - tip_radius=0.5, - scale=1.0, - ), - } + translate(surf, start, direction) + return surf - self.UX = { - "color": "red", - "glyph": pv.Arrow( - start=(0, -1, 0), - direction=(0, 1, 0), - tip_length=1, - tip_radius=0.5, - scale=1.0, - ), - } + def _arrow(*args, **kwargs): + return _basic_arrow(*args, **kwargs) - self.UY = { - "color": "green", - "glyph": pv.Arrow( - start=(0, 0, -1), - direction=(0, 0, 1), + def _cone(start=(0, 0, 0), direction=None): + return _basic_arrow( + start=start, + direction=direction, tip_length=1, tip_radius=0.5, - scale=1.0, - ), - } + ) - self.UZ = { - "color": "blue", - "glyph": pv.Arrow( - start=(-1, 0, 0), - direction=(1, 0, 0), - tip_length=0.5, - tip_radius=0.25, - scale=1.0, - ), + self.TEMP = { + "color": "orange", + "glyph": self._point, } - self.VOLT = { - "color": "yellow", - "glyph": pv.Arrow( - start=(0, -1, 0), - direction=(0, 1, 0), - tip_length=0.5, - tip_radius=0.25, - scale=1.0, - ), - } + self.HEAT = {"color": "red", "glyph": self._cube} - self.FX = { - "color": "red", - "glyph": pv.Arrow( - start=(0, 0, -1), - direction=(0, 0, 1), - tip_length=0.5, - tip_radius=0.25, - scale=1.0, - ), - } + self.UX = {"color": "red", "glyph": _cone(direction=(-1, 0, 0))} + self.UY = {"color": "green", "glyph": _cone(direction=(0, -1, 0))} + self.UZ = {"color": "blue", "glyph": _cone(direction=(0, 0, -1))} - def get_VOLT(): - model_a = pv.Cylinder( - center=(0, 0, 0), direction=(1, 0, 0), radius=0.2, height=2 - ).triangulate() + self.FX = {"color": "red", "glyph": _arrow(direction=(-1, 0, 0))} + self.FY = {"color": "green", "glyph": _arrow(direction=(0, -1, 0))} + self.FZ = {"color": "blue", "glyph": _arrow(direction=(0, 0, -1))} - model_b = pv.Cylinder( - center=(0, 0, 0), direction=(0, 1, 0), radius=0.2, height=2 - ).triangulate() + self.VOLT = {"color": "yellow", "glyph": self.cross_cylinders_3d()} - model_c = pv.Cylinder( - center=(0, 0, 0), direction=(0, 0, 1), radius=0.2, height=2 - ).triangulate() + self.AMPS = {"color": "red", "glyph": self.cross_cylinders_3d()} + self.CHRG = {"color": "red", "glyph": self.cross_cylinders_3d()} - result = model_a.merge(model_b).triangulate() - result = result.merge(model_c) + @staticmethod + def cross_cylinders_3d(): + model_a = pv.Cylinder( + center=(0, 0, 0), direction=(1, 0, 0), radius=0.2, height=1.5 + ).triangulate() - result.rotate_z(45.0, inplace=True) - result.rotate_vector( - vector=(1, -1, 0), angle=-45, point=(0, 0, 0), inplace=True - ) + model_b = pv.Cylinder( + center=(0, 0, 0), direction=(0, 1, 0), radius=0.2, height=1.5 + ).triangulate() - return result + model_c = pv.Cylinder( + center=(0, 0, 0), direction=(0, 0, 1), radius=0.2, height=1.5 + ).triangulate() - self.FY = {"color": "green", "glyph": get_VOLT()} + result = model_a.merge(model_b).triangulate() + result = result.merge(model_c) - self.FZ = { - "color": "blue", - "glyph": pv.Cube( - center=(0, 0, 0), x_length=1.0, y_length=1.0, z_length=1.0 - ), - } + result.rotate_z(45.0, inplace=True) + result.rotate_vector( + vector=(1, -1, 0), angle=-45, point=(0, 0, 0), inplace=True + ) - self.AMPS = {"color": "grey", "glyph": get_VOLT()} - self.CHRGS = {"color": "grey", "glyph": get_VOLT()} + return result diff --git a/src/ansys/mapdl/core/theme.py b/src/ansys/mapdl/core/theme.py index 77798ee18c..fcb775d719 100644 --- a/src/ansys/mapdl/core/theme.py +++ b/src/ansys/mapdl/core/theme.py @@ -48,15 +48,11 @@ else: # older versions from pyvista.themes import DefaultTheme as Theme - base_class = Theme - else: # pragma: no cover - class myEmptyClass: + class Theme: pass - base_class = myEmptyClass - MAPDL_colorbar = ( np.array( @@ -88,15 +84,8 @@ def get_ansys_colors(N=9): return np.array([PyMAPDL_cmap(i) for i in range(N)]) -class MapdlTheme(base_class): - """PyMAPDL-specific theme for pyvista. - - Theme includes the following defaults: - - - ``'jet'`` (rainbow) colormap - - Interactive plots - - ``'Courier'`` for the font family - - ``'PyMAPDL'`` as the plot title +class MapdlTheme(Theme): + """PyMAPDL-specific theme for Pyvista. Examples -------- @@ -131,14 +120,15 @@ def __init__(self): if _HAS_MATPLOTLIB: self.cmap = PyMAPDL_cmap - self.font.size = 18 - self.font.title_size = 18 - self.font.label_size = 18 - self.font.color = "black" + self.font.size = 18 + self.font.title_size = 18 + self.font.label_size = 18 + self.font.color = "black" + self.font.family = "arial" - self.axes.x_color = "tomato" - self.axes.y_color = "seagreen" - self.axes.z_color = "blue" + self.axes.x_color = "tomato" + self.axes.y_color = "seagreen" + self.axes.z_color = "blue" self.show_edges = False self.color = "lightblue" diff --git a/tests/.image_cache/bc_plot_options[False-False-False].png b/tests/.image_cache/bc_plot_options[False-False-False].png index 5b66f01aa2..8387e03497 100644 Binary files a/tests/.image_cache/bc_plot_options[False-False-False].png and b/tests/.image_cache/bc_plot_options[False-False-False].png differ diff --git a/tests/.image_cache/bc_plot_options[False-False-True].png b/tests/.image_cache/bc_plot_options[False-False-True].png index 5b66f01aa2..8387e03497 100644 Binary files a/tests/.image_cache/bc_plot_options[False-False-True].png and b/tests/.image_cache/bc_plot_options[False-False-True].png differ diff --git a/tests/.image_cache/bc_plot_options[False-True-False].png b/tests/.image_cache/bc_plot_options[False-True-False].png index 1333a065b6..1691ec9d84 100644 Binary files a/tests/.image_cache/bc_plot_options[False-True-False].png and b/tests/.image_cache/bc_plot_options[False-True-False].png differ diff --git a/tests/.image_cache/bc_plot_options[False-True-True].png b/tests/.image_cache/bc_plot_options[False-True-True].png index 1333a065b6..1691ec9d84 100644 Binary files a/tests/.image_cache/bc_plot_options[False-True-True].png and b/tests/.image_cache/bc_plot_options[False-True-True].png differ diff --git a/tests/.image_cache/bc_plot_options[True-False-False].png b/tests/.image_cache/bc_plot_options[True-False-False].png index 6f74c1bf81..98c91f05ff 100644 Binary files a/tests/.image_cache/bc_plot_options[True-False-False].png and b/tests/.image_cache/bc_plot_options[True-False-False].png differ diff --git a/tests/.image_cache/bc_plot_options[True-False-True].png b/tests/.image_cache/bc_plot_options[True-False-True].png index 6f74c1bf81..98c91f05ff 100644 Binary files a/tests/.image_cache/bc_plot_options[True-False-True].png and b/tests/.image_cache/bc_plot_options[True-False-True].png differ diff --git a/tests/.image_cache/bc_plot_options[True-True-False].png b/tests/.image_cache/bc_plot_options[True-True-False].png index b46f964b34..a79cd718d3 100644 Binary files a/tests/.image_cache/bc_plot_options[True-True-False].png and b/tests/.image_cache/bc_plot_options[True-True-False].png differ diff --git a/tests/.image_cache/bc_plot_options[True-True-True].png b/tests/.image_cache/bc_plot_options[True-True-True].png index b46f964b34..a79cd718d3 100644 Binary files a/tests/.image_cache/bc_plot_options[True-True-True].png and b/tests/.image_cache/bc_plot_options[True-True-True].png differ diff --git a/tests/.image_cache/bc_plot_options_fields[loads0-field0].png b/tests/.image_cache/bc_plot_options_fields[loads0-field0].png new file mode 100644 index 0000000000..b9337aede2 Binary files /dev/null and b/tests/.image_cache/bc_plot_options_fields[loads0-field0].png differ diff --git a/tests/.image_cache/bc_plot_options_fields[loads0-field1].png b/tests/.image_cache/bc_plot_options_fields[loads0-field1].png new file mode 100644 index 0000000000..e8f590a8be Binary files /dev/null and b/tests/.image_cache/bc_plot_options_fields[loads0-field1].png differ diff --git a/tests/.image_cache/bc_plot_options_fields[loads0-field2].png b/tests/.image_cache/bc_plot_options_fields[loads0-field2].png new file mode 100644 index 0000000000..f3139d4c6c Binary files /dev/null and b/tests/.image_cache/bc_plot_options_fields[loads0-field2].png differ diff --git a/tests/.image_cache/bc_plot_options_fields[loads0-field3].png b/tests/.image_cache/bc_plot_options_fields[loads0-field3].png new file mode 100644 index 0000000000..f723a74556 Binary files /dev/null and b/tests/.image_cache/bc_plot_options_fields[loads0-field3].png differ diff --git a/tests/.image_cache/bc_plot_options_fields[loads0-field4].png b/tests/.image_cache/bc_plot_options_fields[loads0-field4].png new file mode 100644 index 0000000000..9becf8b784 Binary files /dev/null and b/tests/.image_cache/bc_plot_options_fields[loads0-field4].png differ diff --git a/tests/.image_cache/bc_plot_options_fields[loads0-field5].png b/tests/.image_cache/bc_plot_options_fields[loads0-field5].png new file mode 100644 index 0000000000..c7b476c1e6 Binary files /dev/null and b/tests/.image_cache/bc_plot_options_fields[loads0-field5].png differ diff --git a/tests/.image_cache/bc_plot_options_fields[loads1-field0].png b/tests/.image_cache/bc_plot_options_fields[loads1-field0].png new file mode 100644 index 0000000000..b82b5199db Binary files /dev/null and b/tests/.image_cache/bc_plot_options_fields[loads1-field0].png differ diff --git a/tests/.image_cache/bc_plot_options_fields[loads1-field1].png b/tests/.image_cache/bc_plot_options_fields[loads1-field1].png new file mode 100644 index 0000000000..d57460385c Binary files /dev/null and b/tests/.image_cache/bc_plot_options_fields[loads1-field1].png differ diff --git a/tests/.image_cache/bc_plot_options_fields[loads1-field2].png b/tests/.image_cache/bc_plot_options_fields[loads1-field2].png new file mode 100644 index 0000000000..b484f198af Binary files /dev/null and b/tests/.image_cache/bc_plot_options_fields[loads1-field2].png differ diff --git a/tests/.image_cache/bc_plot_options_fields[loads1-field3].png b/tests/.image_cache/bc_plot_options_fields[loads1-field3].png new file mode 100644 index 0000000000..d7f1f551d1 Binary files /dev/null and b/tests/.image_cache/bc_plot_options_fields[loads1-field3].png differ diff --git a/tests/.image_cache/bc_plot_options_fields[loads1-field4].png b/tests/.image_cache/bc_plot_options_fields[loads1-field4].png new file mode 100644 index 0000000000..b2fecca7fb Binary files /dev/null and b/tests/.image_cache/bc_plot_options_fields[loads1-field4].png differ diff --git a/tests/.image_cache/bc_plot_options_fields[loads1-field5].png b/tests/.image_cache/bc_plot_options_fields[loads1-field5].png new file mode 100644 index 0000000000..057b57c611 Binary files /dev/null and b/tests/.image_cache/bc_plot_options_fields[loads1-field5].png differ diff --git a/tests/.image_cache/bc_plot_options_fields[loads2-field0].png b/tests/.image_cache/bc_plot_options_fields[loads2-field0].png new file mode 100644 index 0000000000..6773e21342 Binary files /dev/null and b/tests/.image_cache/bc_plot_options_fields[loads2-field0].png differ diff --git a/tests/.image_cache/bc_plot_options_fields[loads2-field1].png b/tests/.image_cache/bc_plot_options_fields[loads2-field1].png new file mode 100644 index 0000000000..d57460385c Binary files /dev/null and b/tests/.image_cache/bc_plot_options_fields[loads2-field1].png differ diff --git a/tests/.image_cache/bc_plot_options_fields[loads2-field2].png b/tests/.image_cache/bc_plot_options_fields[loads2-field2].png new file mode 100644 index 0000000000..b484f198af Binary files /dev/null and b/tests/.image_cache/bc_plot_options_fields[loads2-field2].png differ diff --git a/tests/.image_cache/bc_plot_options_fields[loads2-field3].png b/tests/.image_cache/bc_plot_options_fields[loads2-field3].png new file mode 100644 index 0000000000..88347bb411 Binary files /dev/null and b/tests/.image_cache/bc_plot_options_fields[loads2-field3].png differ diff --git a/tests/.image_cache/bc_plot_options_fields[loads2-field4].png b/tests/.image_cache/bc_plot_options_fields[loads2-field4].png new file mode 100644 index 0000000000..b2fecca7fb Binary files /dev/null and b/tests/.image_cache/bc_plot_options_fields[loads2-field4].png differ diff --git a/tests/.image_cache/bc_plot_options_fields[loads2-field5].png b/tests/.image_cache/bc_plot_options_fields[loads2-field5].png new file mode 100644 index 0000000000..057b57c611 Binary files /dev/null and b/tests/.image_cache/bc_plot_options_fields[loads2-field5].png differ diff --git a/tests/.image_cache/bc_plot_options_fields[loads3-field0].png b/tests/.image_cache/bc_plot_options_fields[loads3-field0].png new file mode 100644 index 0000000000..53513a247b Binary files /dev/null and b/tests/.image_cache/bc_plot_options_fields[loads3-field0].png differ diff --git a/tests/.image_cache/bc_plot_options_fields[loads3-field1].png b/tests/.image_cache/bc_plot_options_fields[loads3-field1].png new file mode 100644 index 0000000000..d57460385c Binary files /dev/null and b/tests/.image_cache/bc_plot_options_fields[loads3-field1].png differ diff --git a/tests/.image_cache/bc_plot_options_fields[loads3-field2].png b/tests/.image_cache/bc_plot_options_fields[loads3-field2].png new file mode 100644 index 0000000000..b484f198af Binary files /dev/null and b/tests/.image_cache/bc_plot_options_fields[loads3-field2].png differ diff --git a/tests/.image_cache/bc_plot_options_fields[loads3-field3].png b/tests/.image_cache/bc_plot_options_fields[loads3-field3].png new file mode 100644 index 0000000000..eab817c123 Binary files /dev/null and b/tests/.image_cache/bc_plot_options_fields[loads3-field3].png differ diff --git a/tests/.image_cache/bc_plot_options_fields[loads3-field4].png b/tests/.image_cache/bc_plot_options_fields[loads3-field4].png new file mode 100644 index 0000000000..b2fecca7fb Binary files /dev/null and b/tests/.image_cache/bc_plot_options_fields[loads3-field4].png differ diff --git a/tests/.image_cache/bc_plot_options_fields[loads3-field5].png b/tests/.image_cache/bc_plot_options_fields[loads3-field5].png new file mode 100644 index 0000000000..057b57c611 Binary files /dev/null and b/tests/.image_cache/bc_plot_options_fields[loads3-field5].png differ diff --git a/tests/.image_cache/single_glyph[0-CHRG].png b/tests/.image_cache/single_glyph[0-CHRG].png new file mode 100644 index 0000000000..f43b7c9c75 Binary files /dev/null and b/tests/.image_cache/single_glyph[0-CHRG].png differ diff --git a/tests/.image_cache/single_glyph[0-FX].png b/tests/.image_cache/single_glyph[0-FX].png new file mode 100644 index 0000000000..5db283d5cf Binary files /dev/null and b/tests/.image_cache/single_glyph[0-FX].png differ diff --git a/tests/.image_cache/single_glyph[0-FY].png b/tests/.image_cache/single_glyph[0-FY].png new file mode 100644 index 0000000000..be42003b13 Binary files /dev/null and b/tests/.image_cache/single_glyph[0-FY].png differ diff --git a/tests/.image_cache/single_glyph[0-FZ].png b/tests/.image_cache/single_glyph[0-FZ].png new file mode 100644 index 0000000000..0785039a90 Binary files /dev/null and b/tests/.image_cache/single_glyph[0-FZ].png differ diff --git a/tests/.image_cache/single_glyph[0-HEAT].png b/tests/.image_cache/single_glyph[0-HEAT].png new file mode 100644 index 0000000000..efa2004eda Binary files /dev/null and b/tests/.image_cache/single_glyph[0-HEAT].png differ diff --git a/tests/.image_cache/single_glyph[0-TEMP].png b/tests/.image_cache/single_glyph[0-TEMP].png new file mode 100644 index 0000000000..9203b1ceec Binary files /dev/null and b/tests/.image_cache/single_glyph[0-TEMP].png differ diff --git a/tests/.image_cache/single_glyph[0-UX].png b/tests/.image_cache/single_glyph[0-UX].png new file mode 100644 index 0000000000..6ff4c997cc Binary files /dev/null and b/tests/.image_cache/single_glyph[0-UX].png differ diff --git a/tests/.image_cache/single_glyph[0-UY].png b/tests/.image_cache/single_glyph[0-UY].png new file mode 100644 index 0000000000..8091d39f97 Binary files /dev/null and b/tests/.image_cache/single_glyph[0-UY].png differ diff --git a/tests/.image_cache/single_glyph[0-UZ].png b/tests/.image_cache/single_glyph[0-UZ].png new file mode 100644 index 0000000000..7a7bdf1fdc Binary files /dev/null and b/tests/.image_cache/single_glyph[0-UZ].png differ diff --git a/tests/.image_cache/single_glyph[0-VOLT].png b/tests/.image_cache/single_glyph[0-VOLT].png new file mode 100644 index 0000000000..442065721d Binary files /dev/null and b/tests/.image_cache/single_glyph[0-VOLT].png differ diff --git a/tests/.image_cache/single_glyph[50-CHRG].png b/tests/.image_cache/single_glyph[50-CHRG].png new file mode 100644 index 0000000000..8ae8019cfb Binary files /dev/null and b/tests/.image_cache/single_glyph[50-CHRG].png differ diff --git a/tests/.image_cache/single_glyph[50-FX].png b/tests/.image_cache/single_glyph[50-FX].png new file mode 100644 index 0000000000..da14cb0de0 Binary files /dev/null and b/tests/.image_cache/single_glyph[50-FX].png differ diff --git a/tests/.image_cache/single_glyph[50-FY].png b/tests/.image_cache/single_glyph[50-FY].png new file mode 100644 index 0000000000..d971b33384 Binary files /dev/null and b/tests/.image_cache/single_glyph[50-FY].png differ diff --git a/tests/.image_cache/single_glyph[50-FZ].png b/tests/.image_cache/single_glyph[50-FZ].png new file mode 100644 index 0000000000..2756a06002 Binary files /dev/null and b/tests/.image_cache/single_glyph[50-FZ].png differ diff --git a/tests/.image_cache/single_glyph[50-HEAT].png b/tests/.image_cache/single_glyph[50-HEAT].png new file mode 100644 index 0000000000..f790aa62af Binary files /dev/null and b/tests/.image_cache/single_glyph[50-HEAT].png differ diff --git a/tests/.image_cache/single_glyph[50-TEMP].png b/tests/.image_cache/single_glyph[50-TEMP].png new file mode 100644 index 0000000000..8710eec33b Binary files /dev/null and b/tests/.image_cache/single_glyph[50-TEMP].png differ diff --git a/tests/.image_cache/single_glyph[50-UX].png b/tests/.image_cache/single_glyph[50-UX].png new file mode 100644 index 0000000000..a12c16ce5f Binary files /dev/null and b/tests/.image_cache/single_glyph[50-UX].png differ diff --git a/tests/.image_cache/single_glyph[50-UY].png b/tests/.image_cache/single_glyph[50-UY].png new file mode 100644 index 0000000000..54012e50b8 Binary files /dev/null and b/tests/.image_cache/single_glyph[50-UY].png differ diff --git a/tests/.image_cache/single_glyph[50-UZ].png b/tests/.image_cache/single_glyph[50-UZ].png new file mode 100644 index 0000000000..142a11e8aa Binary files /dev/null and b/tests/.image_cache/single_glyph[50-UZ].png differ diff --git a/tests/.image_cache/single_glyph[50-VOLT].png b/tests/.image_cache/single_glyph[50-VOLT].png new file mode 100644 index 0000000000..308001fa59 Binary files /dev/null and b/tests/.image_cache/single_glyph[50-VOLT].png differ diff --git a/tests/.image_cache/single_glyph[500-CHRG].png b/tests/.image_cache/single_glyph[500-CHRG].png new file mode 100644 index 0000000000..ecb69c6c3f Binary files /dev/null and b/tests/.image_cache/single_glyph[500-CHRG].png differ diff --git a/tests/.image_cache/single_glyph[500-FX].png b/tests/.image_cache/single_glyph[500-FX].png new file mode 100644 index 0000000000..9e7936cd24 Binary files /dev/null and b/tests/.image_cache/single_glyph[500-FX].png differ diff --git a/tests/.image_cache/single_glyph[500-FY].png b/tests/.image_cache/single_glyph[500-FY].png new file mode 100644 index 0000000000..e057eef39a Binary files /dev/null and b/tests/.image_cache/single_glyph[500-FY].png differ diff --git a/tests/.image_cache/single_glyph[500-FZ].png b/tests/.image_cache/single_glyph[500-FZ].png new file mode 100644 index 0000000000..f66d99ef62 Binary files /dev/null and b/tests/.image_cache/single_glyph[500-FZ].png differ diff --git a/tests/.image_cache/single_glyph[500-HEAT].png b/tests/.image_cache/single_glyph[500-HEAT].png new file mode 100644 index 0000000000..4670cd8049 Binary files /dev/null and b/tests/.image_cache/single_glyph[500-HEAT].png differ diff --git a/tests/.image_cache/single_glyph[500-TEMP].png b/tests/.image_cache/single_glyph[500-TEMP].png new file mode 100644 index 0000000000..eabc2cc6b5 Binary files /dev/null and b/tests/.image_cache/single_glyph[500-TEMP].png differ diff --git a/tests/.image_cache/single_glyph[500-UX].png b/tests/.image_cache/single_glyph[500-UX].png new file mode 100644 index 0000000000..e394516df9 Binary files /dev/null and b/tests/.image_cache/single_glyph[500-UX].png differ diff --git a/tests/.image_cache/single_glyph[500-UY].png b/tests/.image_cache/single_glyph[500-UY].png new file mode 100644 index 0000000000..0c09f188da Binary files /dev/null and b/tests/.image_cache/single_glyph[500-UY].png differ diff --git a/tests/.image_cache/single_glyph[500-UZ].png b/tests/.image_cache/single_glyph[500-UZ].png new file mode 100644 index 0000000000..5c4ad4f8a9 Binary files /dev/null and b/tests/.image_cache/single_glyph[500-UZ].png differ diff --git a/tests/.image_cache/single_glyph[500-VOLT].png b/tests/.image_cache/single_glyph[500-VOLT].png new file mode 100644 index 0000000000..c885e5216d Binary files /dev/null and b/tests/.image_cache/single_glyph[500-VOLT].png differ diff --git a/tests/test_launcher.py b/tests/test_launcher.py index 977d07fb4c..d2f06a0eb1 100644 --- a/tests/test_launcher.py +++ b/tests/test_launcher.py @@ -459,7 +459,7 @@ def test_version(mapdl): additional_switches=QUICK_LAUNCH_SWITCHES, _debug_no_launch=True, ) - assert str(version) in launching_arg["start_parm"]["exec_file"] + assert str(version) in str(launching_arg["version"]) @requires("local") @@ -745,3 +745,11 @@ def test_get_start_instance_envvar(monkeypatch, start_instance, context): assert get_start_instance(start_instance) else: assert not get_start_instance(start_instance) + + +@pytest.mark.parametrize("start_instance", [True, False]) +def test_launcher_start_instance(monkeypatch, start_instance): + if "PYMAPDL_START_INSTANCE" in os.environ: + monkeypatch.delenv("PYMAPDL_START_INSTANCE") + options = launch_mapdl(start_instance=start_instance, _debug_no_launch=True) + assert start_instance == options["start_instance"] diff --git a/tests/test_mapdl.py b/tests/test_mapdl.py index 6a75655f68..f013bfd04c 100644 --- a/tests/test_mapdl.py +++ b/tests/test_mapdl.py @@ -2408,3 +2408,28 @@ def test_screenshot(mapdl, make_block, tmpdir): os.remove(file_name) mapdl.file_type_for_plots = previous_device + + +def test_force_command_ignored_not_active_set(mapdl, cleared): + mapdl.prep7() + mapdl.et("", 227) + mapdl.keyopt(1, 1) # Thermal-Piezoelectric + mapdl.n(1, 0, 0, 0) + + with pytest.raises(MapdlCommandIgnoredError): + mapdl.f(1, "CHRG", 10) + + +def test_force_command_when_no_nodes(mapdl, cleared): + mapdl.prep7() + mapdl.et(1, 189) + with pytest.raises(MapdlCommandIgnoredError, match="No nodes defined"): + mapdl.f(1, "CHRG", 0) + + +def test_not_correct_et_element(mapdl): + mapdl.clear() + mapdl.prep7() + mapdl.et(1, 227) + with pytest.warns(UserWarning, match="is normal behavior when a CDB file is used"): + mapdl.keyopt(1, 222) diff --git a/tests/test_plotting.py b/tests/test_plotting.py index 3ec1cdbafc..c388ae1368 100644 --- a/tests/test_plotting.py +++ b/tests/test_plotting.py @@ -36,34 +36,83 @@ from ansys.mapdl.core.errors import ComponentDoesNotExits from ansys.mapdl.core.plotting import general_plotter +FORCE_LABELS = [["FX", "FY", "FZ"], ["HEAT"], ["CHRG"]] +DISPL_LABELS = [["UX", "UY", "UZ"], ["TEMP"], ["VOLT"]] +ALL_LABELS = FORCE_LABELS.copy() +ALL_LABELS.extend(DISPL_LABELS) + @pytest.fixture -def bc_example(mapdl, make_block): +def boundary_conditions_example(mapdl): + mapdl.clear() mapdl.prep7() + mapdl.et("", 189) + + mapdl.n(1, 0, 0, 0) + mapdl.n(2, 1, 0, 0) + mapdl.n(3, 2, 0, 0) + mapdl.n(4, 0, 0, 1) + mapdl.n(5, 1, 0, 1) + mapdl.n(6, 2, 0, 1) mapdl.nsel("s", "node", "", 1) mapdl.f("all", "FX", 0) + mapdl.nsel("s", "node", "", 2) mapdl.f("all", "FY", 0) + mapdl.nsel("s", "node", "", 3) mapdl.f("all", "FZ", 0) - mapdl.nsel("s", "node", "", 2) - mapdl.f("all", "FX", 100) - mapdl.f("all", "FY", 200) - mapdl.f("all", "FZ", 100) - - mapdl.nsel("s", "node", "", 3) + mapdl.nsel("s", "node", "", 4) mapdl.d("all", "UX", 0) + mapdl.nsel("s", "node", "", 5) mapdl.d("all", "UY", 0) + mapdl.nsel("s", "node", "", 6) mapdl.d("all", "UZ", 0) - mapdl.nsel("s", "node", "", 4) - mapdl.d("all", "UX", 1) - mapdl.d("all", "UY", 2) - mapdl.d("all", "UZ", 3) + mapdl.n(7, 0, 1, 0) + mapdl.n(8, 1, 1, 0) + mapdl.n(9, 2, 1, 0) + mapdl.n(10, 0, 2, 0) + mapdl.n(11, 1, 2, 0) + mapdl.n(12, 2, 2, 0) + + mapdl.nsel("s", "node", "", 7) + mapdl.f("all", "FX", 10) + mapdl.nsel("s", "node", "", 8) + mapdl.f("all", "FY", 20) + mapdl.nsel("s", "node", "", 9) + mapdl.f("all", "FZ", 30) + + mapdl.nsel("s", "node", "", 10) + mapdl.d("all", "UX", 20) + mapdl.nsel("s", "node", "", 11) + mapdl.d("all", "UY", 20) + mapdl.nsel("s", "node", "", 12) + mapdl.d("all", "UZ", 20) mapdl.nsel("all") +@pytest.fixture +def block_example_coupled(mapdl): + mapdl.clear() + mapdl.prep7() + + mapdl.et(1, 226) + mapdl.keyopt(1, 1, 1011) # Thermal-Piezoelectric + + # Disp + # UX, UY, UZ, + # TEMP, VOLT + + # Force + # FX, FY, FZ, + # HEAT, CHRG + mapdl.n(1, 0, 0, 0) + mapdl.n(2, 1, 0, 0) + mapdl.n(3, 2, 0, 0) + + def test_plot_empty_mesh(mapdl, cleared): with pytest.warns(UserWarning): mapdl.nplot(vtk=True) @@ -212,20 +261,59 @@ def test_eplot_savefig(mapdl, make_block, tmpdir): assert os.path.isfile(filename) +@pytest.mark.parametrize( + "field", ["UX", "UY", "UZ", "FX", "FY", "FZ", "TEMP", "HEAT", "VOLT", "CHRG"] +) +@pytest.mark.parametrize("magnitude", [0, 50, 500]) +def test_single_glyph(mapdl, field, magnitude, verify_image_cache): + mapdl.clear() + mapdl.prep7() + mapdl.et(1, 226) + mapdl.keyopt(1, 1, 1011) # Thermal-Piezoelectric + mapdl.n(1, 0, 0, 0) + + if field in [x for group in DISPL_LABELS for x in group]: + func = getattr(mapdl, "d") + else: + func = getattr(mapdl, "f") + + func(1, field, magnitude) + + if magnitude > 0: + mapdl.n(2, 1, 0, 0) + func(2, field, magnitude * 2) + + if magnitude > 50: + mapdl.n(3, 2, 0, 0) + func(3, field, magnitude * 10) + + mapdl.allsel() + + p = mapdl.nplot( + plot_bc=True, + # point_size=max(magnitude, 10), + # render_points_as_spheres=True, + plot_bc_legend=True, + plot_bc_labels=True, + title="", + ) + + @pytest.mark.parametrize("return_plotter", [True, False]) @pytest.mark.parametrize("plot_bc_legend", [True, False]) @pytest.mark.parametrize("plot_bc_labels", [True, False]) def test_bc_plot_options( mapdl, - bc_example, + boundary_conditions_example, verify_image_cache, return_plotter, plot_bc_legend, plot_bc_labels, + bc_labels_font_size=50, ): - if plot_bc_legend: - # The legend generates highly variance than other tests - # But it seems not always. + + if plot_bc_legend or plot_bc_labels: + # The legend and labels generate highly variance than other tests verify_image_cache.high_variance_test = True p = mapdl.nplot( @@ -233,6 +321,7 @@ def test_bc_plot_options( plot_bc=True, plot_bc_legend=plot_bc_legend, plot_bc_labels=plot_bc_labels, + title="", ) if return_plotter: @@ -242,6 +331,33 @@ def test_bc_plot_options( assert p is None +@pytest.mark.parametrize("field", ALL_LABELS) +@pytest.mark.parametrize( + "loads", [[0, 0, 0], [10, 10, 10], [10, 20, 30], [10, 100, 1000]] +) +def test_bc_plot_options_fields( + mapdl, block_example_coupled, verify_image_cache, field, loads +): + mapdl.prep7() + for i in range(len(field)): + mapdl.nsel("s", "node", "", i + 1) + if field[i] in [x for group in FORCE_LABELS for x in group]: + mapdl.f("all", field[i], loads[i]) + else: + mapdl.d("all", field[i], loads[i]) + + mapdl.nsel("s", "node", "", 1, 3) + + p = mapdl.nplot( + plot_bc=True, + plot_bc_legend=True, + plot_bc_labels=True, + title="", + ) + + assert p is None + + @pytest.mark.parametrize( "bc_labels", # Added second part of the argument to avoid image cache name clashing. # See https://github.com/pyvista/pytest-pyvista/issues/93 @@ -255,12 +371,13 @@ def test_bc_plot_options( ["CSGZ", "Magnetic forces"], ], ) -def test_bc_plot_bc_labels(mapdl, bc_example, bc_labels): +def test_bc_plot_bc_labels(mapdl, boundary_conditions_example, bc_labels): p = mapdl.nplot( return_plotter=True, plot_bc=True, plot_bc_labels=True, bc_labels=bc_labels[0], + title="", ) assert isinstance(p, Plotter), bc_labels[1] p.show() # plotting for catching @@ -273,13 +390,14 @@ def test_bc_plot_bc_labels(mapdl, bc_example, bc_labels): ["UX", "error"], ], ) -def test_bc_plot_bc_labels_error(mapdl, bc_example, bc_labels): +def test_bc_plot_bc_labels_error(mapdl, boundary_conditions_example, bc_labels): with pytest.raises(ValueError): mapdl.nplot( return_plotter=True, plot_bc=True, plot_bc_labels=True, bc_labels=bc_labels, + title="", ) @@ -290,12 +408,13 @@ def test_bc_plot_bc_labels_error(mapdl, bc_example, bc_labels): ["NOdes", "Mixed case"], ], ) -def test_bc_plot_bc_target(mapdl, bc_example, bc_target): +def test_bc_plot_bc_target(mapdl, boundary_conditions_example, bc_target): p = mapdl.nplot( return_plotter=True, plot_bc=True, plot_bc_labels=True, bc_target=bc_target[0], + title="", ) assert isinstance(p, Plotter), bc_target[1] p.show() # plotting for catching @@ -310,13 +429,14 @@ def test_bc_plot_bc_target(mapdl, bc_example, bc_target): {"error": "Not accepting dicts"}, ], ) -def test_bc_plot_bc_target_error(mapdl, bc_example, bc_target): +def test_bc_plot_bc_target_error(mapdl, boundary_conditions_example, bc_target): with pytest.raises(ValueError): mapdl.nplot( return_plotter=True, plot_bc=True, plot_bc_labels=True, bc_target=bc_target, + title="", ) @@ -327,23 +447,31 @@ def test_bc_no_mapdl(mapdl): ) # mapdl should be an argument if plotting BC -def test_bc_only_one_node(mapdl, bc_example): +def test_bc_only_one_node(mapdl, boundary_conditions_example): mapdl.nsel("s", "node", "", 1) - mapdl.nplot(plot_bc=True) + mapdl.nplot( + plot_bc=True, + title="", + ) -def test_bc_glyph(mapdl, bc_example): +def test_bc_glyph(mapdl, boundary_conditions_example): mapdl.nplot(plot_bc=True, bc_glyph_size=19) with pytest.raises(ValueError): - mapdl.nplot(plot_bc=True, bc_glyph_size="big") + mapdl.nplot( + plot_bc=True, + bc_glyph_size="big", + title="", + ) -def test_bc_bc_labels(mapdl, bc_example, verify_image_cache): +def test_bc_bc_labels(mapdl, boundary_conditions_example, verify_image_cache): """Test values for 'bc_labels' keyword argument.""" verify_image_cache.skip = True # skipping image verification mapdl.nplot(plot_bc=True, bc_labels="UX") mapdl.nplot(plot_bc=True, bc_labels=["Ux", "uy", "VOLT"]) + with pytest.raises(ValueError): mapdl.nplot(plot_bc=True, bc_labels=["big"]) @@ -354,11 +482,15 @@ def test_bc_bc_labels(mapdl, bc_example, verify_image_cache): mapdl.nplot(plot_bc=True, bc_labels=["UX", {"not": "valid"}]) -def test_all_same_values(mapdl, bc_example): +def test_all_same_values(mapdl, boundary_conditions_example): """Test the BC glyph size when all the BC have same magnitude.""" mapdl.nsel("all") mapdl.f("all", "FX", 0) - mapdl.nplot(plot_bc=True, bc_labels="FX") + mapdl.nplot( + plot_bc=True, + bc_labels="FX", + title="", + ) @pytest.mark.parametrize(