Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG](https://kee
- Fix ignored env passing to cli ([#465](https://github.com/ansys/pymechanical/pull/465)
- Fix private appdata environment variables and folder layout ([#474](https://github.com/ansys/pymechanical/pull/474))
- Fix hanging embedding tests ([#498](https://github.com/ansys/pymechanical/pull/498))
- Fix ansys-mechanical finding path ([#516](https://github.com/ansys/pymechanical/pull/516))

### Changed

Expand Down
7 changes: 2 additions & 5 deletions doc/source/api/helper.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. _launcher_api:
.. _ref_launcher_api:

Helper functions
================
Expand All @@ -10,8 +10,5 @@ These methods provide helper functions for launching Mechanical, closing Mechani
:toctree: _autosummary


change_default_mechanical_path
close_all_local_instances
find_mechanical
launch_mechanical

close_all_local_instances
29 changes: 7 additions & 22 deletions doc/source/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,6 @@ API reference
=============
This section describes PyMechanical classes, functions, and attributes.

=================
Helper functions
=================
This section describes helper functions for launching and closing Mechanical instances.

======================
Local Mechanical pool
======================
This section describes how to work with a local pool of Mechanical instances.

========
Logging
========
This section describes how to use the logger to log messages.

===========
Mechanical
===========
This section describes the methods in the
:class:`Mechanical <ansys.mechanical.core.mechanical.Mechanical>` class for working
with a Mechanical gRPC server.


.. toctree::
:maxdepth: 2
Expand All @@ -37,3 +15,10 @@ with a Mechanical gRPC server.
logging
mechanical
path

.. toctree::
- :ref:`ref_launcher_api`
- :ref:`ref_pool_api`
- :ref:`ref_logger_api`
- :ref:`ref_mechanical_api`
- :ref:`ref_ansys_tools_path_api`
2 changes: 2 additions & 0 deletions doc/source/api/logging.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. _ref_logger_api:

Logging
=======
To make the logging of events consistent, PyMechanical has a specific
Expand Down
6 changes: 4 additions & 2 deletions doc/source/api/mechanical.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
Mechanical
==========

Mechanical class-specific methods and attributes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This section describes the methods for working with a Mechanical gRPC server using the following class:
:class:`Mechanical <ansys.mechanical.core.mechanical.Mechanical>`


.. currentmodule:: ansys.mechanical.core

.. autoclass:: ansys.mechanical.core.mechanical.Mechanical
Expand Down
2 changes: 1 addition & 1 deletion doc/source/api/path.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. _ansys_tools_path_api:
.. _ref_ansys_tools_path_api:

Ansys path tools
================
Expand Down
14 changes: 12 additions & 2 deletions doc/source/api/pool.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
.. _ref_pool_api:

Local Mechanical pool
Local Mechanical Pool
=====================

This section describes how to work with a local pool of Mechanical instances.

.. currentmodule:: ansys.mechanical.core

LocalMechanicalPool Class
-------------------------

:class:`~ansys.mechanical.core.pool.LocalMechanicalPool` provides functionality for working with a local pool of Mechanical instances.

.. autoclass:: ansys.mechanical.core.pool.LocalMechanicalPool

.. autosummary::
:toctree: _autosummary

pool.LocalMechanicalPool
pool.LocalMechanicalPool

34 changes: 34 additions & 0 deletions doc/source/getting_started/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,42 @@ in the preceding example.

Verify your installation
------------------------

The way that you verify your installation depends on whether you want to run
Mechanical using a remote session or an embedded instance.
Before running either, you must first verify that you can find
the installed version of Mechanical using the ``ansys.tools.path`` package.
This package is required to use PyMechanical.

.. code:: pycon

>>> from ansys.tools.path import find_mechanical
>>> find_mechanical()

or

>>> find_mechanical(version=231) # for specific version

('C:/Program Files/ANSYS Inc/v231/aisol/bin/winx64/AnsysWBU.exe', 23.1) # windows
('/usr/ansys_inc/v231/aisol/.workbench', 23.1) # Linux

If you install Ansys in a directory other than the default or typical location,
you can save this directory path using the ``save_mechanical_path`` function. Then use
``get_mechanical_path`` and ``version_from_path`` functions to verify the path and version.
For more details, refer to the :ref:`ref_ansys_tools_path_api`.

.. code:: pycon

>>> from ansys.tools.path import save_mechanical_path, find_mechanical
>>> save_mechanical_path("home/username/ansys_inc/v231/aisol/.workbench")
>>> path = get_mechanical_path()
>>> print(path)

/home/username/ansys_inc/v242/aisol/.workbench

>>> version = version_from_path("mechanical", path)

242

Verify a remote session
^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
17 changes: 10 additions & 7 deletions docker/make_container.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ install the minimal files by using:
sh /path-to-mechanical-installer \
-install_dir /path-to-install-mechanical/ \
-nochecks -mechapdl -silent
# example
# sh /home/username/download/linx/INSTALL \
# -install_dir /install/ansys_inc/ \
# -nochecks -mechapdl -silent

Use ``sudo`` if you do not have write permissions in the installation directory.
The ``-mechapdl`` command installs Mechanical.

Take note of where you are installing Ansys because the
Expand All @@ -84,23 +89,21 @@ which you should modify to adapt it to your needs.
export ANS_VERSION=${ANS_MAJOR_VERSION}${ANS_MINOR_VERSION}

export TAG=mechanical:${ANS_MAJOR_VERSION}.${ANS_MINOR_VERSION}
# example: if Mechanical v231 is installed under
# /install/ansys_inc/v231
# example: if Mechanical v231 is installed under /install/ansys_inc/v231

# use /install for path_to_mechanical_installation
export MECHANICAL_INSTALL_LOCATION=/path_to_mechanical_installation/

# example: if pymechanical is cloned under
# /some_location/pymechanical
# example: if pymechanical is cloned under /some_location/pymechanical
# use /some_location for path-to-pymechanical
export PYMECHANICAL_LOCATION=/path-to-pymechanical

# Create working directory
cd ${MECHANICAL_INSTALL_LOCATION}

# Copy the Docker files
#
cp ${PYMECHANICAL_LOCATION}/pymechanical/docker/{ANS_VERSION}/Dockerfile .
cp ${PYMECHANICAL_LOCATION}/pymechanical/docker/{ANS_VERSION}/.dockerignore .
cp ${PYMECHANICAL_LOCATION}/pymechanical/docker/${ANS_VERSION}/Dockerfile .
cp ${PYMECHANICAL_LOCATION}/pymechanical/docker/${ANS_VERSION}/.dockerignore .

# Build Docker image
sudo docker build -t $TAG --build-arg VERSION=$ANS_VERSION .
Expand Down
7 changes: 6 additions & 1 deletion src/ansys/mechanical/core/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,12 @@ def cli(
raise Exception("Cannot open in server mode with an input script.")

if not revision:
exe, version = atp.find_mechanical()
exe = atp.get_mechanical_path() # check for saved mechanical path
if exe:
version = atp.version_from_path("mechanical", exe)
else:
exe, version = atp.find_mechanical()
version = int(version * 10)
else:
exe, version = atp.find_mechanical(version=revision)

Expand Down