Skip to content

Commit

Permalink
Merge branch 'main' into feat/moving-mapdl-functions-to-class-files
Browse files Browse the repository at this point in the history
  • Loading branch information
germa89 committed Nov 23, 2023
2 parents 387df9e + 9cc780c commit 105a045
Show file tree
Hide file tree
Showing 61 changed files with 2,045 additions and 1,238 deletions.
14 changes: 0 additions & 14 deletions .ci/run_vms.py

This file was deleted.

4 changes: 4 additions & 0 deletions .ci/start_mapdl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ docker run \
-p $PYMAPDL_DB_PORT:50055 \
--shm-size=1gb \
-e I_MPI_SHM_LMT=shm \
-e P_SCHEMA=/ansys_inc/ansys/ac4/schema \
--oom-kill-disable \
--memory=6656MB \
--memory-swap=16896MB \
$MAPDL_IMAGE \
-$DISTRIBUTED_MODE -np 2 > log.txt &
grep -q 'Server listening on' <(timeout 60 tail -f log.txt)
4 changes: 4 additions & 0 deletions .ci/start_mapdl_ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ docker run \
-p $PYMAPDL_DB_PORT:50055 \
--shm-size=1gb \
-e I_MPI_SHM_LMT=shm \
-e P_SCHEMA=/ansys_inc/v222/ansys/ac4/schema \
-w /jobs \
-u=0:0 \
--oom-kill-disable \
--memory=6656MB \
--memory-swap=16896MB \
$MAPDL_IMAGE /ansys_inc/v222/ansys/bin/mapdl -grpc -dir /jobs -$DISTRIBUTED_MODE -np 2 > log.txt &
grep -q 'Server listening on' <(timeout 60 tail -f log.txt)
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ body:
- '3.9'
- '3.10'
- '3.11'
- '3.12'
validations:
required: false

Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ body:
- '3.9'
- '3.10'
- '3.11'
- '3.12'
validations:
required: true

Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
# Only perform wheelhouse builds for macOS when releasing
should-release:
- ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags') }}
Expand Down Expand Up @@ -470,13 +470,15 @@ jobs:
commit_long_sha: ${{ steps.attatch-to-pr.outputs.commit_long_sha }}
container:
image: ghcr.io/ansys/mapdl:v22.2-ubuntu
options: "-u=0:0 --entrypoint /bin/bash"
options: -u=0:0 --oom-kill-disable --memory=6656MB --memory-swap=16896MB --shm-size=1gb --entrypoint /bin/bash
credentials:
username: ${{ secrets.GH_USERNAME }}
password: ${{ secrets.GITHUB_TOKEN }}
env:
ON_LOCAL: true
ON_UBUNTU: true
P_SCHEMA: "/ansys_inc/v222/ansys/ac4/schema"
PYTEST_TIMEOUT: 120 # seconds. Limit the duration for each unit test

steps:
- name: "Install Git and checkout project"
Expand All @@ -501,7 +503,7 @@ jobs:
- name: "Install OS packages"
run: |
apt update
apt install -y libgl1-mesa-glx xvfb
apt install -y libgl1-mesa-glx xvfb libgomp1
- name: "Test virtual framebuffer"
run: |
Expand Down Expand Up @@ -595,7 +597,7 @@ jobs:
timeout-minutes: 55
container:
image: ghcr.io/ansys/mapdl:v22.2-ubuntu
options: "-u=0:0 --entrypoint /bin/bash"
options: -u=0:0 --oom-kill-disable --memory=6656MB --memory-swap=16896MB --shm-size=1gb --entrypoint /bin/bash
credentials:
username: ${{ secrets.GH_USERNAME }}
password: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -627,12 +629,11 @@ jobs:
python -m pip install . --no-deps
python -m pip install -r minimum_requirements.txt
python -c "from ansys.mapdl import core as pymapdl; print('Import successfull')"
- name: "Running some verification manual examples"
- name: "Installing missing package"
run: |
unset PYMAPDL_START_INSTANCE
export ANSYSLMD_LICENSE_FILE=1055@${{ secrets.LICENSE_SERVER }}
python .ci/run_vms.py
sudo apt-get update
sudo apt-get install -y libgomp1
- name: "Unit testing requirements installation"
run: |
Expand All @@ -644,7 +645,6 @@ jobs:
export ANSYSLMD_LICENSE_FILE=1055@${{ secrets.LICENSE_SERVER }}
pytest -k "not test_dpf" \
${{ env.PYTEST_ARGUMENTS }} \
--skip-regression-check \
--cov-report=xml:ubuntu-v22.2.0-local-minimal.xml
- uses: codecov/codecov-action@v3
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/docker_clean_untagged.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Docker images - Cleanup
on:
workflow_dispatch:
schedule: # UTC at 0200
- cron: "0 2 * * *"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: write
packages: write

jobs:
cleanup:
name: Cleaning unnecessary packages
runs-on: ubuntu-latest
env:
PACKAGE_DELETION_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:

- name: "Perform versions cleanup - except certain tags"
uses: ansys/actions/hk-package-clean-untagged@v4
with:
package-name: 'mapdl'
token: ${{ secrets.GITHUB_TOKEN }}
allow-last-days: 5
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repos:
)
- repo: https://github.com/psf/black
rev: 23.10.1 # IF VERSION CHANGES --> MODIFY "blacken-docs" MANUALLY AS WELL!!
rev: 23.11.0 # IF VERSION CHANGES --> MODIFY "blacken-docs" MANUALLY AS WELL!!
hooks:
- id: black
args:
Expand All @@ -31,7 +31,7 @@ repos:
rev: 1.16.0
hooks:
- id: blacken-docs
additional_dependencies: [black==23.10.1]
additional_dependencies: [black==23.11.0]

- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
Expand Down Expand Up @@ -60,6 +60,6 @@ repos:

# this validates our github workflow files
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.0
rev: 0.27.1
hooks:
- id: check-github-workflows
7 changes: 7 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Repository codeowners
#
# Reference: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners

/.ci/ @ansys/pymapdl-maintainers
/.github/ @ansys/pymapdl-maintainers
pyproject.toml @ansys/pymapdl-maintainers
8 changes: 5 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ a useful tool for all users. As such, we welcome and encourage any
questions or submissions to this repository.


For contributing to this project, please refer to the [PyAnsys Developer's Guide].
Further information about contributing to PyMAPDL can be found in [Contributing](https://mapdl.docs.pyansys.com/version/stable/getting_started/contribution.html).
Information about contributing to PyMAPDL can be found in
[Contributing](https://mapdl.docs.pyansys.com/version/stable/getting_started/contribution.html).

For further information about contributing to PyAnsys projects,
refer to the [PyAnsys Developer's Guide](https://dev.docs.pyansys.com/).

[PyAnsys Developer's Guide]: https://dev.docs.pyansys.com/
166 changes: 4 additions & 162 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ PyMAPDL

Overview
--------

The PyMAPDL project supports Pythonic access to MAPDL to be able to
communicate with the MAPDL process directly from Python. The latest
``ansys-mapdl-core`` package enables a more comprehensive interface with
Expand Down Expand Up @@ -68,6 +69,9 @@ You can also `view <https://cheatsheets.docs.pyansys.com/pymapdl_cheat_sheet.png
PyMAPDL cheat sheet. This one-page reference provides syntax rules and commands
for using PyMAPDL.

For troubleshooting, visit
`Troubleshooting PyMAPDL <https://mapdl.docs.pyansys.com/version/stable/user_guide/troubleshoot.html#troubleshooting-pymapdl>`_

On the `PyMAPDL Issues <https://github.com/ansys/pymapdl/issues>`_ page,
you can create issues to report bugs and request new features. On the `PyMAPDL Discussions
<https://github.com/ansys/pymapdl/discussions>`_ page or the `Discussions <https://discuss.ansys.com/>`_
Expand Down Expand Up @@ -102,168 +106,6 @@ split up into the following projects and modules:
For more information on each project, visit their GitHub pages.


Installation
------------
The ``ansys-mapdl-core`` package currently supports Python 3.8 through
Python 3.11 on Windows, Mac OS, and Linux.

Install the latest release from `PyPi
<https://pypi.org/project/ansys-mapdl-core/>`_ with:

.. code:: console
pip install ansys-mapdl-core
If you are planning to use PyMAPDL together with `Jupyter lab <https://jupyter.org/>`_,
you can install both in one step:

.. code:: console
pip install 'ansys-mapdl-core[jupyter]'
Alternatively, install the latest from `PyMAPDL GitHub
<https://github.com/ansys/pymapdl/issues>`_ via:

.. code:: console
pip install git+https://github.com/ansys/pymapdl.git
For a local "development" version, install with (requires pip >= 22.0):

.. code:: console
git clone https://github.com/ansys/pymapdl.git
cd pymapdl
pip install -e .
Offline installation
~~~~~~~~~~~~~~~~~~~~
If you lack an internet connection on your install machine, the recommended way
of installing PyMAPDL is downloading the wheelhouse archive from the `Releases
Page <https://github.com/ansys/pymapdl/releases>`_ for your corresponding
machine architecture.

Each wheelhouse archive contains all the python wheels necessary to install
PyMAPDL from scratch on Windows and Linux for Python 3.8 and 3.11. You can install
this on an isolated system with a fresh python or on a virtual environment.

For example, on Linux Ubuntu with Python 3.10, unzip it and install it with the following:

.. code:: console
unzip ansys-mapdl-core-v0.65.0-wheelhouse-ubuntu-latest-3.10.zip
wheelhouse
pip install ansys-mapdl-core -f wheelhouse --no-index --upgrade --ignore-installed
If you're on Windows with Python 3.10, unzip manually to a ``wheelhouse`` directory and
install using the same command as above.

Consider installing using a `virtual environment
<https://docs.python.org/3/library/venv.html>`_.


Dependencies
------------
You must have a local licenced copy of Ansys to run MAPDL prior and
including 2021R1. If you have the latest version of 2021R1 you do
not need MAPDL installed locally and can connect to a remote instance.


Getting started
---------------

Launch MAPDL locally
~~~~~~~~~~~~~~~~~~~~
You can launch MAPDL locally directly from Python using ``launch_mapdl``:

.. code:: python
from ansys.mapdl.core import launch_mapdl
mapdl = launch_mapdl()
This automatically searches for the latest local version of MAPDL,
launches it as a background process, and immediately connects to it.
You can then start sending python commands to MAPDL.


Launching manually or connecting to a remote instance
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you want to connect to a session of MAPDL on a remote computer
(either locally the LAN or through the internet), first ensure you
have MAPDL started in gRPC server mode. This example assumes that you
are launching an instance locally from Windows, but it can be easily
adapted to run from Linux, or the LAN provided the necessary ports are
open. This example specifies the port with ``-port 50052``, but this
option can be left out if you plan on using the default port 50052.

.. code:: pwsh-session
start "MAPDL" "%ANSYS211_DIR%\bin\winx64\ANSYS211.exe" -port 50052 -grpc
Next, connect to the instance of MAPDL from python with:

.. code:: pycon
>>> from ansys.mapdl.core import Mapdl
>>> ip = "127.0.0.1"
>>> mapdl = Mapdl(ip=ip, port=50052, start_instance=False)
>>> print(mapdl)
A successful connection returns:

.. code:: output
Product: ANSYS Mechanical Enterprise
MAPDL Version: RELEASE 2020 R2 BUILD 20.2TEST UPDATE 20200601
ansys.mapdl.core Version: 0.57.0
Should you want to connect to this instance of MAPDL from a remote
computer, you substitute ``ip=`` with the LAN or WAN address of the
computer you wish to connect to. Depending on your network settings,
you may have to open local ports or enable port redirection across the
WAN.


Basic usage
~~~~~~~~~~~
You run MAPDL commands via:

.. code:: python
mapdl.run("/PREP7")
Nearly all the built-in MAPDL commands have an associated pythonic
method mapped to it. For example, `/PREP7` is:

.. code:: python
mapdl.prep7()
There are also non-mapdl commands such as ``mapdl.eplot`` which plot
elements using ``vtk`` and ``pyvista`` rather than relying on MAPDL's
graphics server. Another is ``mapdl.vget``, which leverages gRPC to
rapidly exchange binary arrays from MAPDL to Python rather than
relying on file IO to exchange data.

Additionally, there are the ``post_processing``, ``geometry``, and
``mesh`` properties, which you can use to perform remote (or local)
post processing without result file exchange, display geometry
properties, or view mesh statistics. Additionally, there's the
``parameters`` property which shows the active MAPDL parameters, and
you can use to send or receive arrays between MAPDL and Python.

For more information, see the full documentation at `PyMAPDL Documentation
<https://mapdl.docs.pyansys.com>`_.

Citing this module
-------------------
If you use ``PyMAPDL`` for research and would like to cite the module
Expand Down
Loading

0 comments on commit 105a045

Please sign in to comment.