diff --git a/CHANGELOG.md b/CHANGELOG.md index d5eb5d212..bb9dacb03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/doc/source/api/helper.rst b/doc/source/api/helper.rst index 850d0732f..110b085f7 100644 --- a/doc/source/api/helper.rst +++ b/doc/source/api/helper.rst @@ -1,4 +1,4 @@ -.. _launcher_api: +.. _ref_launcher_api: Helper functions ================ @@ -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 \ No newline at end of file diff --git a/doc/source/api/index.rst b/doc/source/api/index.rst index 8860c31ca..ea0ac7a26 100644 --- a/doc/source/api/index.rst +++ b/doc/source/api/index.rst @@ -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 ` class for working -with a Mechanical gRPC server. - .. toctree:: :maxdepth: 2 @@ -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` \ No newline at end of file diff --git a/doc/source/api/logging.rst b/doc/source/api/logging.rst index 27a9ced3b..3d7a9a4be 100644 --- a/doc/source/api/logging.rst +++ b/doc/source/api/logging.rst @@ -1,3 +1,5 @@ +.. _ref_logger_api: + Logging ======= To make the logging of events consistent, PyMechanical has a specific diff --git a/doc/source/api/mechanical.rst b/doc/source/api/mechanical.rst index 4a7554c0a..01d2097e5 100644 --- a/doc/source/api/mechanical.rst +++ b/doc/source/api/mechanical.rst @@ -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 ` + + .. currentmodule:: ansys.mechanical.core .. autoclass:: ansys.mechanical.core.mechanical.Mechanical diff --git a/doc/source/api/path.rst b/doc/source/api/path.rst index e31a0ef58..6537ba963 100644 --- a/doc/source/api/path.rst +++ b/doc/source/api/path.rst @@ -1,4 +1,4 @@ -.. _ansys_tools_path_api: +.. _ref_ansys_tools_path_api: Ansys path tools ================ diff --git a/doc/source/api/pool.rst b/doc/source/api/pool.rst index 8b11a9012..f6ab40584 100644 --- a/doc/source/api/pool.rst +++ b/doc/source/api/pool.rst @@ -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 \ No newline at end of file + pool.LocalMechanicalPool + diff --git a/doc/source/getting_started/index.rst b/doc/source/getting_started/index.rst index 5f439eb97..c20f3a8bf 100644 --- a/doc/source/getting_started/index.rst +++ b/doc/source/getting_started/index.rst @@ -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 ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/docker/make_container.rst b/docker/make_container.rst index ebe5f852a..5df6d9f11 100644 --- a/docker/make_container.rst +++ b/docker/make_container.rst @@ -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 @@ -84,13 +89,12 @@ 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 @@ -98,9 +102,8 @@ which you should modify to adapt it to your needs. 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 . diff --git a/src/ansys/mechanical/core/run.py b/src/ansys/mechanical/core/run.py index c761cd2fb..616d2a02d 100644 --- a/src/ansys/mechanical/core/run.py +++ b/src/ansys/mechanical/core/run.py @@ -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)