Skip to content

Commit

Permalink
merge with main; bump to v0.63.1
Browse files Browse the repository at this point in the history
  • Loading branch information
akaszynski committed Aug 3, 2022
2 parents f0808d4 + 2a6259f commit 69fe928
Show file tree
Hide file tree
Showing 16 changed files with 156 additions and 63 deletions.
17 changes: 13 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ jobs:
application_id: ${{ secrets.BOT_APPLICATION_ID }}
application_private_key: ${{ secrets.BOT_APPLICATION_PRIVATE_KEY }}

- name: Get tag
id: tag
uses: dawidd6/action-get-tag@v1
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
with:
# Optionally strip `v` prefix
strip_v: false

- name: Setup Python
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -221,13 +229,14 @@ jobs:

- name: Deploy
if: github.event_name == 'push' && contains(github.ref, 'refs/tags')
uses: JamesIves/github-pages-deploy-action@4.1.4
uses: JamesIves/github-pages-deploy-action@v4.4.0
with:
repository-name: pyansys/pymapdl-docs
token: ${{ steps.get_workflow_token.outputs.token }}
BRANCH: gh-pages
FOLDER: doc/build/html
CLEAN: true
branch: gh-pages
folder: doc/build/html
clean: true
tag: ${{steps.tag.outputs.tag}}

- name: Build PDF Documentation
working-directory: doc
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/nightly-doc-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ jobs:
xvfb-run make -C doc html
- name: Deploy
uses: JamesIves/github-pages-deploy-action@4.1.4
uses: JamesIves/github-pages-deploy-action@v4.4.0
with:
repository-name: pyansys/pymapdl-dev-docs
token: ${{ steps.get_workflow_token.outputs.token }}
BRANCH: gh-pages
FOLDER: doc/build/html
CLEAN: true
branch: gh-pages
folder: doc/build/html
clean: true

- name: Notify if fail
uses: skitionek/notify-microsoft-teams@master
Expand Down
3 changes: 1 addition & 2 deletions doc/source/api/helper.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ or automating other tasks.

.. autosummary::
:toctree: _autosummary


launch_mapdl
convert_apdl_block
Expand All @@ -18,4 +17,4 @@ or automating other tasks.
change_default_ansys_path
find_ansys
close_all_local_instances

save_ansys_path
11 changes: 5 additions & 6 deletions examples/00-mapdl-examples/cyclic_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,16 +267,15 @@ def gen_sector(mapdl, sectors):
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Note how the harmonic indices of these modes goes up to 10, or N/2 where N is
# the number of sectors.
#

print("C. Index Harmonic Index")
for i, hindex in zip(range(result.n_results), result.harmonic_indices):
print(f"{i:3d} {hindex:3d}")


###############################################################################
# Plot Nodal First Bend for Nodal Diameter 2
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Plot First Bend for Nodal Diameter 2
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Note how you can clearly see two nodal lines for this mode shape since it's
# nodal diameter 2.

Expand All @@ -286,10 +285,10 @@ def gen_sector(mapdl, sectors):


###############################################################################
# Animate Nodal First Bend for Nodal Diameter 2
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Animate First Bend for Nodal Diameter 2
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Let's end this example by animating mode 12, which corresponds to first bend
# 2nd nodal diameter for this example.
# for the 2nd nodal diameter of this example model.

_ = result.animate_nodal_displacement(
12,
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ build-backend = "flit_core.buildapi"
[project]
# Check https://flit.readthedocs.io/en/latest/pyproject_toml.html for all available sections
name = "ansys-mapdl-core"
version = "0.63.0"
description = "A Python wrapper for Ansys mapdl core"
version = "0.63.1"
description = "A Python wrapper for Ansys MAPDL."
readme = "README.rst"
requires-python = ">=3.7"
license = {file = "LICENSE"}
Expand Down Expand Up @@ -44,7 +44,7 @@ classifiers = [
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10", # requires custom VTK wheels
"Programming Language :: Python :: 3.10",
]

[tool.flit.module]
Expand Down
8 changes: 4 additions & 4 deletions requirements/requirements_docs.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Sphinx==5.0.2
Sphinx==5.1.1
ansys-mapdl-reader==0.51.14
ansys-sphinx-theme==0.4.2
grpcio==1.43.0
imageio-ffmpeg==0.4.7
imageio==2.19.5
imageio==2.21.0
jupyter_sphinx==0.4.0
jupyterlab>=3.2.8
matplotlib==3.5.2
Expand All @@ -13,11 +13,11 @@ plotly==5.9.0
pypandoc==1.8.1
pytest-sphinx==0.4.0
pythreejs==2.3.0
pyvista==0.35.2
pyvista==0.36.1
sphinx-autobuild==2021.3.14
sphinx-autodoc-typehints==1.18.3
sphinx-copybutton==0.5.0
sphinx-gallery==0.10.1
sphinx-gallery==0.11.0
sphinx-notfound-page==0.8.3
sphinxcontrib-websupport==1.2.4
sphinxemoji==0.2.0
Expand Down
4 changes: 2 additions & 2 deletions requirements/requirements_tests.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
autopep8==1.6.0
matplotlib==3.5.2
scipy==1.8.1
scipy==1.9.0
pandas==1.4.3
pytest==7.1.2
pytest-cov==3.0.0
pyvista==0.35.2
pyvista==0.36.1
pyansys-tools-report==0.2.2
vtk==9.0.3
1 change: 1 addition & 0 deletions src/ansys/mapdl/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
find_ansys,
get_ansys_path,
launch_mapdl,
save_ansys_path,
)
from ansys.mapdl.core.mapdl_grpc import MapdlGrpc as Mapdl
from ansys.mapdl.core.misc import Information, Report, _check_has_ansys
Expand Down
6 changes: 6 additions & 0 deletions src/ansys/mapdl/core/database/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ def start(self, timeout=10):
--------
>>> mapdl.db.start()
"""
if self._mapdl._server_version != (0, 4, 1): # pragma: no cover
from ansys.mapdl.core.errors import MapdlVersionError

raise MapdlVersionError(
"This version of MAPDL is not compatible with 'database' module."
)

# only start if not already running
is_running = self.active
Expand Down
8 changes: 8 additions & 0 deletions src/ansys/mapdl/core/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,11 @@ class MapdlInfo(MapdlException):

def __init__(self, msg=""):
MapdlException.__init__(self, msg)


class MapdlVersionError(MapdlException):

"""Incompatible MAPDL version"""

def __init__(self, msg=""):
MapdlException.__init__(self, msg)
31 changes: 20 additions & 11 deletions src/ansys/mapdl/core/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,11 +773,12 @@ def change_default_ansys_path(exe_loc):


def save_ansys_path(exe_loc=None): # pragma: no cover
"""Find ANSYS path or query user.
"""Find MAPDL's path or query user.
If no ``exe_loc`` argument is supplied, this function attempt
to obtain the MAPDL executable from (and in order):
- The default ansys paths (i.e. 'C:/Program Files/Ansys Inc/vXXX/ansys/bin/ansysXXX')
- The default ansys paths (i.e. ``'C:/Program Files/Ansys Inc/vXXX/ansys/bin/ansysXXX'``)
- The configuration file
- User input
Expand All @@ -787,7 +788,7 @@ def save_ansys_path(exe_loc=None): # pragma: no cover
Parameters
----------
exe_loc : str, optional
Path of the MAPDL executable ('ansysXXX'), by default None
Path of the MAPDL executable ('ansysXXX'), by default ``None``.
Returns
-------
Expand All @@ -804,15 +805,15 @@ def save_ansys_path(exe_loc=None): # pragma: no cover
>>> import appdirs
>>> import os
>>> print(os.path.join(appdirs.user_data_dir("ansys_mapdl_core"), "config.txt"))
C:/Users/gayuso/AppData/Local/ansys_mapdl_core/ansys_mapdl_core/config.txt
C:/Users/user/AppData/Local/ansys_mapdl_core/ansys_mapdl_core/config.txt
Examples
--------
You can change the default ``exe_loc`` either by modifying the mentioned
``config.txt`` file or by executing this function:
``config.txt`` file or by executing:
.. code:: python
>>> from ansys.mapdl.core.launcher import save_ansys_path
>>> save_ansys_path('/new/path/to/executable')
>>> from ansys.mapdl.core import save_ansys_path
>>> save_ansys_path('/new/path/to/executable')
"""
if exe_loc is None:
Expand Down Expand Up @@ -982,6 +983,7 @@ def launch_mapdl(
ip=None,
clear_on_connect=True,
log_apdl=None,
remove_temp_files=False,
verbose_mapdl=False,
license_server_check=True,
license_type=None,
Expand Down Expand Up @@ -1095,7 +1097,11 @@ def launch_mapdl(
``log_apdl='pymapdl_log.txt'``). By default this is disabled.
remove_temp_files : bool, optional
Removes temporary files on exit. Default ``False``.
When ``run_location`` is ``None``, this launcher creates a new MAPDL
working directory within the user temporary directory, obtainable with
``tempfile.gettempdir()``. When this parameter is
``True``, this directory will be deleted when MAPDL is exited. Default
``False``.
verbose_mapdl : bool, optional
Enable printing of all output when launching and running
Expand Down Expand Up @@ -1385,6 +1391,9 @@ def launch_mapdl(
else:
if not os.path.isdir(run_location):
raise FileNotFoundError(f'"{run_location}" is not a valid directory')
if remove_temp_files:
LOG.info("`run_location` set. Disabling the removal of temporary files.")
remove_temp_files = False

# verify no lock file and the mode is valid
check_lock_file(run_location, jobname, override)
Expand Down Expand Up @@ -1516,7 +1525,7 @@ def launch_mapdl(
cleanup_on_exit=cleanup_on_exit,
loglevel=loglevel,
set_no_abort=set_no_abort,
remove_temp_files=kwargs.pop("remove_temp_files", False),
remove_temp_files=remove_temp_files,
log_apdl=log_apdl,
**start_parm,
)
Expand Down
42 changes: 25 additions & 17 deletions src/ansys/mapdl/core/mapdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,27 +811,26 @@ def _generate_iges(self):
return filename

def open_gui(self, include_result=None, inplace=None): # pragma: no cover
"""Saves existing database and opens up the APDL GUI.
"""Save the existing database and open it up in the MAPDL GUI.
Parameters
----------
include_result : bool, optional
Allow the result file to be post processed in the GUI.
It is ignored if 'inplace' is ``True``.
By default, it is ``True``.
Allow the result file to be post processed in the GUI. It is
ignored if ``inplace`` is ``True``. By default, ``True``.
inplace : bool, optional
Open the GUI on the current working directory, instead of create
a new temporary directory and copy the results files over there.
If ``True``, it ignores 'include_result' kwarg.
By default, it is ``False``.
Open the GUI on the current MAPDL working directory, instead of
creating a new temporary directory and coping the results files
over there. If ``True``, ignores ``include_result`` parameter. By
default, this ``False``.
Examples
--------
>>> from ansys.mapdl.core import launch_mapdl
>>> mapdl = launch_mapdl()
Create a square area using keypoints
Create a square area using keypoints.
>>> mapdl.prep7()
>>> mapdl.k(1, 0, 0, 0)
Expand All @@ -844,11 +843,11 @@ def open_gui(self, include_result=None, inplace=None): # pragma: no cover
>>> mapdl.l(4, 1)
>>> mapdl.al(1, 2, 3, 4)
Open up the gui
Open up the gui.
>>> mapdl.open_gui()
Resume where you left off
Resume where you left off.
>>> mapdl.et(1, 'MESH200', 6)
>>> mapdl.amesh('all')
Expand All @@ -859,7 +858,7 @@ def open_gui(self, include_result=None, inplace=None): # pragma: no cover

if not self._local:
raise RuntimeError(
"``open_gui`` can only be called from a local " "MAPDL instance"
"``open_gui`` can only be called from a local MAPDL instance."
)

if inplace and include_result:
Expand Down Expand Up @@ -891,7 +890,7 @@ def open_gui(self, include_result=None, inplace=None): # pragma: no cover
rmtree(run_dir)
os.mkdir(run_dir)

database_file = os.path.join(run_dir, "%s.db" % name)
database_file = os.path.join(run_dir, f"{name}.db")
if os.path.isfile(database_file) and not inplace:
os.remove(database_file)

Expand All @@ -903,6 +902,13 @@ def open_gui(self, include_result=None, inplace=None): # pragma: no cover
# finish, save and exit the server
self.finish(mute=True)
self.save(database_file, mute=True)

# Exit and do not remove the temporary directory. This is backwards
# compatible with CONSOLE and CORBA modes.
remove_tmp = False
if hasattr(self, "_remove_tmp"):
remove_tmp = self._remove_tmp
self._remove_tmp = False
self.exit()

# copy result file to temp directory
Expand All @@ -913,7 +919,7 @@ def open_gui(self, include_result=None, inplace=None): # pragma: no cover
copyfile(resultfile, tmp_resultfile)

# write temporary input file
start_file = os.path.join(run_dir, "start%s.ans" % version)
start_file = os.path.join(run_dir, f"start{version}.ans")
with open(start_file, "w") as f:
f.write("RESUME\n")

Expand All @@ -931,8 +937,8 @@ def open_gui(self, include_result=None, inplace=None): # pragma: no cover

if inplace:
warn(
"MAPDL GUI is opened using 'inplace' kwarg."
f"Hence the changes you do will overwrite the files in {run_dir}."
"MAPDL GUI has been opened using 'inplace' kwarg. "
f"The changes you make will overwrite the files in {run_dir}."
)

call(
Expand All @@ -951,7 +957,9 @@ def open_gui(self, include_result=None, inplace=None): # pragma: no cover
# reattach to a new session and reload database
self._launch(self._start_parm)
self.resume(database_file, mute=True)
self.save()

# restore remove tmp state
self._remove_tmp = remove_tmp

def _cache_routine(self):
"""Cache the current routine."""
Expand Down
Loading

0 comments on commit 69fe928

Please sign in to comment.