Skip to content

Commit

Permalink
Merge branch 'main' into feat/supporting-slurm-manager
Browse files Browse the repository at this point in the history
  • Loading branch information
german committed Mar 18, 2024
2 parents 7033bd4 + b5a9fae commit 29a82d6
Show file tree
Hide file tree
Showing 76 changed files with 420 additions and 170 deletions.
6 changes: 3 additions & 3 deletions .devcontainer/codespaces-dev/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions .devcontainer/codespaces-docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
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
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
Expand Down
6 changes: 3 additions & 3 deletions .devcontainer/devcontainer-local/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down Expand Up @@ -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 }}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
14 changes: 7 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,34 +68,34 @@ 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",
]
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",
"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",
Expand Down
39 changes: 31 additions & 8 deletions src/ansys/mapdl/core/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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 "
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -1763,6 +1781,8 @@ def launch_mapdl(
log_apdl,
use_vtk,
start_parm,
start_instance,
version,
)

port, actual_run_location, process = launch_grpc(
Expand Down Expand Up @@ -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_ = {}
Expand All @@ -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_
14 changes: 14 additions & 0 deletions src/ansys/mapdl/core/mapdl_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/mapdl/core/mapdl_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
54 changes: 48 additions & 6 deletions src/ansys/mapdl/core/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# SOFTWARE.

"""Plotting helper for MAPDL using pyvista"""
from collections import OrderedDict
from typing import Any, Optional
from warnings import warn

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -740,7 +745,7 @@ def general_plotter(
+------------+--------------------------------------+
| THERMAL | ["TEMP", "HEAT"] |
+------------+--------------------------------------+
| ELECTRICAL | ["VOLT", "CHRGS", "AMPS"] |
| ELECTRICAL | ["VOLT", "CHRG", "AMPS"] |
+------------+--------------------------------------+
Examples
Expand Down Expand Up @@ -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:
Expand All @@ -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.")
Expand Down Expand Up @@ -1005,6 +1014,7 @@ def bc_nodes_plotter(
# line_width=3,
name=name_,
label=name_,
opacity=0.50,
)

if plot_bc_labels:
Expand All @@ -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
Expand Down
Loading

0 comments on commit 29a82d6

Please sign in to comment.