Skip to content

Commit

Permalink
Merge branch 'main' into feat/common-plotter
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejandroFernandezLuces authored Jul 15, 2024
2 parents d08506a + 2df6130 commit db760f8
Show file tree
Hide file tree
Showing 17 changed files with 386 additions and 188 deletions.
4 changes: 4 additions & 0 deletions .ci/build_matrix.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

# **** REMEMBER *****
# Remember to update the env var ``LATEST_VERSION`` in ci.yml
#

# List of versions
versions=(
# if added more "latest", change "$LATEST"
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ env:
PACKAGE_NAME: 'ansys-mapdl-core'
PACKAGE_NAMESPACE: 'ansys.mapdl.core'
DOCUMENTATION_CNAME: 'mapdl.docs.pyansys.com'
LATEST_VERSION: "242"
MAPDL_IMAGE_VERSION_DOCS_BUILD: v24.2-ubuntu-student
MEILISEARCH_API_KEY: ${{ secrets.MEILISEARCH_API_KEY }}
MEILISEARCH_PUBLIC_API_KEY: ${{ secrets.MEILISEARCH_PUBLIC_API_KEY }}
PYANSYS_OFF_SCREEN: True
DPF_START_SERVER: False
DPF_PORT: 21004
MAPDL_PACKAGE: ghcr.io/ansys/mapdl
MAPDL_IMAGE_VERSION_DOCS_BUILD: v24.1-ubuntu-student
ON_CI: True
PYTEST_ARGUMENTS: '-vvv -ra --durations=10 --maxfail=3 --reruns 3 --reruns-delay 4 --cov=ansys.mapdl.core --cov-report=html'

Expand Down Expand Up @@ -807,7 +808,7 @@ jobs:
# executable path with the env var: PYMAPDL_MAPDL_EXEC.
if [[ "${{ matrix.mapdl-version }}" == *"latest-ubuntu"* ]] ; then
version="242"
version=${{ env.LATEST_VERSION }}
else
version=$(echo "${{ matrix.mapdl-version }}" | head -c 5 | tail -c 4 | tr -d '.')
fi;
Expand Down
1 change: 1 addition & 0 deletions doc/changelog.d/3226.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix: missing arguments on ``OCDATA`` command
1 change: 1 addition & 0 deletions doc/changelog.d/3261.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build: bump zipp from 3.17.0 to 3.19.1 in /doc/source/examples/extended_examples/hpc
1 change: 1 addition & 0 deletions doc/changelog.d/3266.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix: pool issues
2 changes: 1 addition & 1 deletion doc/source/examples/extended_examples/hpc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ tabulate==0.9.0
tqdm==4.66.3
urllib3==2.2.2
vtk==9.3.0
zipp==3.17.0
zipp==3.19.1
65 changes: 41 additions & 24 deletions src/ansys/mapdl/core/_commands/solution/ocean.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,27 @@


class Ocean:
def ocdata(self, val1="", val2="", val3="", val14="", **kwargs):
def ocdata(
self,
val1: str = "",
val2: str = "",
val3: str = "",
val4: str = "",
val5: str = "",
val6: str = "",
val7: str = "",
val8: str = "",
val9: str = "",
val10: str = "",
val11: str = "",
val12: str = "",
val13: str = "",
val14: str = "",
**kwargs,
):
"""Defines an ocean load using non-table data.
APDL Command: OCDATA
APDL Command: ``OCDATA``
Parameters
----------
Expand All @@ -34,14 +51,14 @@ def ocdata(self, val1="", val2="", val3="", val14="", **kwargs):
Notes
-----
The OCDATA command specifies non-table data that defines the ocean
The ``OCDATA`` command specifies non-table data that defines the ocean
load, such as the depth of the ocean to the mud line, the ratio of
added mass over added mass for a circular cross section, or the wave
type to apply. The terms VAL1, VAL2, etc. are specialized according to
the input set required for the given ocean load.
The program interprets the data input via the OCDATA command within the
context of the most recently issued OCTYPE command.
The program interprets the data input via the ``OCDATA`` command within the
context of the most recently issued ``OCTYPE`` command.
Input values in the order indicated.
Expand All @@ -52,19 +69,19 @@ def ocdata(self, val1="", val2="", val3="", val14="", **kwargs):
For a better understanding of how to set up a basic ocean type, see
Figure: 5:: Basic Ocean Data Type Components .
DEPTH -- The depth of the ocean (that is, the distance between the mean
``DEPTH`` -- The depth of the ocean (that is, the distance between the mean
sea level and the mud line). The water surface is assumed to be level
in the XY plane, with Z being positive upwards. This value is required
and must be positive.
MATOC -- The material number of the ocean. This value is required and
``MATOC`` -- The material number of the ocean. This value is required and
is used to input the required density. It is also used to input the
viscosity if the Reynolds number is used (OCTABLE).
viscosity if the Reynolds number is used (``OCTABLE``).
KFLOOD -- The inside-outside fluid-interaction key:
``KFLOOD`` -- The inside-outside fluid-interaction key:
For beam subtype CTUBE and HREC used with BEAM188 or BEAM189 and ocean
loading, KFLOOD is always set to 1.
For beam subtype ``CTUBE`` and ``HREC`` used with BEAM188 or BEAM189 and ocean
loading, ``KFLOOD`` is always set to 1.
Cay -- The ratio of added mass of the external fluid over the mass of
the fluid displaced by the element cross section in the y direction
Expand All @@ -73,7 +90,7 @@ def ocdata(self, val1="", val2="", val3="", val14="", **kwargs):
element moves in the element y direction during a dynamic analysis.
If no value is specified, and the coefficient of inertia CMy is not
specified (OCTABLE), both values default to 0.0.
specified (``OCTABLE``), both values default to 0.0.
If no value is specified, but CMy is specified, this value defaults to
Cay = CMy - 1.0.
Expand All @@ -90,7 +107,7 @@ def ocdata(self, val1="", val2="", val3="", val14="", **kwargs):
Cay.
If no value is specified, and the coefficient of inertia CMz is not
specified (OCTABLE), both values default to 0.0.
specified (``OCTABLE``), both values default to 0.0.
If no value is specified, but CMz is specified, this value defaults to
Cay = CMz - 1.0.
Expand All @@ -115,31 +132,31 @@ def ocdata(self, val1="", val2="", val3="", val14="", **kwargs):
Two example cases for Zmsl are:
A structure with its origin on the sea floor (Zmsl = DEPTH).
A structure with its origin on the sea floor (Zmsl = ``DEPTH``).
A tidal change (tc) above the mean sea level (Zmsl = tc, and DEPTH
becomes DEPTH + tc)
A tidal change (tc) above the mean sea level (Zmsl = tc, and ``DEPTH``
becomes ``DEPTH`` + tc)
Ktable -- The dependency of VAL1 on the OCTABLE command:
Ktable -- The dependency of VAL1 on the ``OCTABLE`` command:
KWAVE -- The incident wave type:
``KWAVE`` -- The incident wave type:
THETA -- Angle of the wave direction θ from the global Cartesian X axis
``THETA`` -- Angle of the wave direction θ from the global Cartesian X axis
toward the global Cartesian Y axis (in degrees).
WAVELOC (valid when KWAVE = 0 through 3, and 101+) -- The wave location
``WAVELOC`` (valid when ``KWAVE`` = 0 through 3, and 101+) -- The wave location
type:
SPECTRUM (valid when KWAVE = 5 through 7) -- The wave spectrum type:
``SPECTRUM`` (valid when ``KWAVE`` = 5 through 7) -- The wave spectrum type:
KCRC -- The wave-current interaction key.
``KCRC`` -- The wave-current interaction key.
Adjustments to the current profile are available via the KCRC constant
Adjustments to the current profile are available via the ``KCRC`` constant
of the water motion table. Typically, these options are used only when
the wave amplitude is large relative to the water depth, such that
significant wave-current interaction exists.
"""
command = f"OCDATA,{val1},{val2},{val3},{val14}"
command = f"OCDATA,{val1},{val2},{val3},{val4},{val5},{val6},{val7},{val8},{val9},{val10},{val11},{val12},{val13},{val14}"
return self.run(command, **kwargs)

def ocdelete(self, datatype="", zonename="", **kwargs):
Expand Down
30 changes: 21 additions & 9 deletions src/ansys/mapdl/core/cli/list_instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,35 @@ def list_instances(instances, long, cmd, location):
mapdl_instances = []

def is_valid_process(proc):
valid_status = proc.status in [psutil.STATUS_RUNNING, psutil.STATUS_IDLE]
valid_status = proc.status() in [
psutil.STATUS_RUNNING,
psutil.STATUS_IDLE,
psutil.STATUS_SLEEPING,
]
valid_ansys_process = ("ansys" in proc.name().lower()) or (
"mapdl" in proc.name().lower()
)
# Early exit to avoid checking 'cmdline' of a protected process (raises psutil.AccessDenied)
if not valid_ansys_process:
return False

grpc_is_active = "-grpc" in proc.cmdline()
return valid_status and valid_ansys_process and grpc_is_active

for proc in psutil.process_iter():
# Check if the process is running and not suspended
if is_valid_process(proc):
# Checking the number of children we infer if the process is the main process,
# or one of the main process thread.
if len(proc.children(recursive=True)) < 2:
proc.ansys_instance = False
else:
proc.ansys_instance = True
mapdl_instances.append(proc)
try:
if is_valid_process(proc):
# Checking the number of children we infer if the process is the main process,
# or one of the main process thread.
if len(proc.children(recursive=True)) < 2:
proc.ansys_instance = False
else:
proc.ansys_instance = True
mapdl_instances.append(proc)

except (psutil.NoSuchProcess, psutil.ZombieProcess) as e:
continue

# printing
table = []
Expand Down
44 changes: 22 additions & 22 deletions src/ansys/mapdl/core/cli/stop.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@
import click


def is_ansys_process(proc):
return (
"ansys" in proc.name().lower() or "mapdl" in proc.name().lower()
) and "-grpc" in proc.cmdline()


@click.command(
short_help="Stop MAPDL instances.",
help="""This command stop MAPDL instances running on a given port or with a given process id (PID).
Expand Down Expand Up @@ -58,6 +52,8 @@ def is_ansys_process(proc):
def stop(port, pid, all):
import psutil

from ansys.mapdl.core.launcher import is_ansys_process

PROCESS_OK_STATUS = [
# List of all process status, comment out the ones that means that
# process is not OK.
Expand All @@ -84,28 +80,32 @@ def stop(port, pid, all):
if port or all:
killed_ = False
for proc in psutil.process_iter():
if (
psutil.pid_exists(proc.pid)
and proc.status() in PROCESS_OK_STATUS
and is_ansys_process(proc)
):
# Killing "all"
if all:
try:
proc.kill()
killed_ = True
except psutil.NoSuchProcess:
pass

else:
# Killing by ports
if str(port) in proc.cmdline():
try:
if (
psutil.pid_exists(proc.pid)
and proc.status() in PROCESS_OK_STATUS
and is_ansys_process(proc)
):
# Killing "all"
if all:
try:
proc.kill()
killed_ = True
except psutil.NoSuchProcess:
pass

else:
# Killing by ports
if str(port) in proc.cmdline():
try:
proc.kill()
killed_ = True
except psutil.NoSuchProcess:
pass

except psutil.NoSuchProcess:
continue

if all:
str_ = ""
else:
Expand Down
3 changes: 3 additions & 0 deletions src/ansys/mapdl/core/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ def get_process_at_port(port) -> Optional[psutil.Process]:
) # just to check if we can access the
except psutil.AccessDenied:
continue
except psutil.NoSuchProcess:
# process already died
continue

for conns in connections:
if conns.laddr.port == port:
Expand Down
7 changes: 5 additions & 2 deletions src/ansys/mapdl/core/mapdl_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1059,9 +1059,12 @@ def _remove_temp_dir_on_exit(self, path=None):
"""
if self.remove_temp_dir_on_exit and self._local:
path = path or self.directory
from pathlib import Path

path = str(Path(path or self.directory))
tmp_dir = tempfile.gettempdir()
ans_temp_dir = os.path.join(tmp_dir, "ansys_")
ans_temp_dir = str(Path(os.path.join(tmp_dir, "ansys_")))

if path.startswith(ans_temp_dir):
self._log.debug("Removing the MAPDL temporary directory %s", path)
shutil.rmtree(path, ignore_errors=True)
Expand Down
Loading

0 comments on commit db760f8

Please sign in to comment.