diff --git a/doc/source/api/pool.rst b/doc/source/api/pool.rst index 583b85a6ab..b9134852d7 100644 --- a/doc/source/api/pool.rst +++ b/doc/source/api/pool.rst @@ -8,4 +8,4 @@ Local MAPDL pool .. autosummary:: :toctree: _autosummary - pool.LocalMapdlPool + pool.MapdlPool diff --git a/doc/source/user_guide/pool.rst b/doc/source/user_guide/pool.rst index d8e045acca..e520ba1b3c 100644 --- a/doc/source/user_guide/pool.rst +++ b/doc/source/user_guide/pool.rst @@ -3,7 +3,7 @@ Create a pool of MAPDL instances ================================ -PyMAPDL contains the :class:`LocalMapdlPool ` +PyMAPDL contains the :class:`MapdlPool ` class to simplify creating multiple local instances of the :class:`Mapdl ` class for batch processing. This can be used for the batch processing of a @@ -14,8 +14,8 @@ This code creates a pool: .. code:: pycon - >>> from ansys.mapdl.core import LocalMapdlPool - >>> pool = LocalMapdlPool(10) + >>> from ansys.mapdl.core import MapdlPool + >>> pool = MapdlPool(10) 'MAPDL Pool with 10 active instances' >>> pool.exit(block=True) @@ -27,7 +27,7 @@ at the current directory within their own isolated directories: >>> import os >>> my_path = os.getcmd() - >>> pool = LocalMapdlPool(10, nproc=1, run_location=my_path) + >>> pool = MapdlPool(10, nproc=1, run_location=my_path) Creating Pool: 100%|########| 10/10 [00:01<00:00, 1.43it/s] You can access each individual MAPDL instance with this code: @@ -46,7 +46,7 @@ Run a set of input files ------------------------ You can use the pool to run a set of pre-generated input files using the -:func:`run_batch ` method. For +:func:`run_batch ` method. For example, this code would run the first set of 20 verification files: .. code:: pycon @@ -63,7 +63,7 @@ Run a user function You can use the pool to run a custom user function on each MAPDL instance over a set of inputs. As in the example for the -:func:`run_batch ` function, +:func:`run_batch ` function, the following code uses a set of verification files. However, it implements it as a function and outputs the final routine instead of the text output from MAPDL. @@ -103,7 +103,7 @@ Close the PyMAPDL pool ---------------------- You can close the PyMAPDL pool with the -:meth:`pool.exit() ` command. +:meth:`pool.exit() ` command. .. code:: pycon diff --git a/src/ansys/mapdl/core/__init__.py b/src/ansys/mapdl/core/__init__.py index c041fb0962..aadc1dce2b 100644 --- a/src/ansys/mapdl/core/__init__.py +++ b/src/ansys/mapdl/core/__init__.py @@ -120,7 +120,7 @@ from ansys.mapdl.core.mapdl_grpc import MapdlGrpc as Mapdl from ansys.mapdl.core.misc import Information, Report, _check_has_ansys -from ansys.mapdl.core.pool import LocalMapdlPool +from ansys.mapdl.core.pool import MapdlPool from ansys.mapdl.core.theme import MapdlTheme, _apply_default_theme _HAS_ANSYS = _check_has_ansys() diff --git a/src/ansys/mapdl/core/pool.py b/src/ansys/mapdl/core/pool.py index a8741c418c..b3f29ae45d 100755 --- a/src/ansys/mapdl/core/pool.py +++ b/src/ansys/mapdl/core/pool.py @@ -71,7 +71,7 @@ def available_ports(n_ports: int, starting_port: int = MAPDL_DEFAULT_PORT) -> Li return ports -class LocalMapdlPool: +class MapdlPool: """Create a pool of MAPDL instances. .. note:: @@ -133,8 +133,8 @@ class LocalMapdlPool: Simply create a pool of 10 instances to run in the temporary directory. - >>> from ansys.mapdl.core import LocalMapdlPool - >>> pool = LocalMapdlPool(10) + >>> from ansys.mapdl.core import MapdlPool + >>> pool = MapdlPool(10) Creating Pool: 100%|########| 10/10 [00:01<00:00, 1.43it/s] Create several instances with 1 CPU each running at the current @@ -142,19 +142,19 @@ class LocalMapdlPool: >>> import os >>> my_path = os.getcmd() - >>> pool = LocalMapdlPool(10, nproc=1, run_location=my_path) + >>> pool = MapdlPool(10, nproc=1, run_location=my_path) Creating Pool: 100%|########| 10/10 [00:01<00:00, 1.43it/s] Create a pool while specifying the MAPDL executable in Windows. >>> exec_file = 'C:/Program Files/ANSYS Inc/v212/ansys/bin/winx64/ANSYS212.exe' - >>> pool = LocalMapdlPool(10, exec_file=exec_file) + >>> pool = MapdlPool(10, exec_file=exec_file) Creating Pool: 100%|########| 10/10 [00:01<00:00, 1.43it/s] Create a pool while specifying the MAPDL executable in Linux. >>> exec_file = '/ansys_inc/v211/ansys/bin/ansys211' - >>> pool = LocalMapdlPool(10, exec_file=exec_file) + >>> pool = MapdlPool(10, exec_file=exec_file) Creating Pool: 100%|########| 10/10 [00:01<00:00, 1.43it/s] """ @@ -230,7 +230,7 @@ def __init__( # Checking version if _HAS_ATP: if version_from_path("mapdl", exec_file) < 211: - raise VersionError("LocalMapdlPool requires MAPDL 2021R1 or later.") + raise VersionError("MapdlPool requires MAPDL 2021R1 or later.") self._exec_file = exec_file diff --git a/tests/test_pool.py b/tests/test_pool.py index daa178bc60..25b8e100c7 100644 --- a/tests/test_pool.py +++ b/tests/test_pool.py @@ -37,7 +37,7 @@ else: EXEC_FILE = os.environ.get("PYMAPDL_MAPDL_EXEC") -from ansys.mapdl.core import LocalMapdlPool, examples +from ansys.mapdl.core import MapdlPool, examples from ansys.mapdl.core.errors import VersionError from conftest import QUICK_LAUNCH_SWITCHES, requires @@ -72,7 +72,7 @@ def pool(tmpdir_factory): if ON_LOCAL: - mapdl_pool = LocalMapdlPool( + mapdl_pool = MapdlPool( 2, license_server_check=False, run_location=run_path, @@ -85,7 +85,7 @@ def pool(tmpdir_factory): else: port2 = os.environ.get("PYMAPDL_PORT2", 50057) - mapdl_pool = LocalMapdlPool( + mapdl_pool = MapdlPool( 2, license_server_check=False, start_instance=False, @@ -117,7 +117,7 @@ def pool(tmpdir_factory): @skip_requires_194 def test_invalid_exec(): with pytest.raises(VersionError): - LocalMapdlPool( + MapdlPool( 4, nproc=NPROC, exec_file="/usr/ansys_inc/v194/ansys/bin/mapdl", @@ -268,7 +268,7 @@ def test_directory_names_default(pool): @requires("local") @skip_if_ignore_pool def test_directory_names_custom_string(tmpdir): - pool = LocalMapdlPool( + pool = MapdlPool( 2, exec_file=EXEC_FILE, run_location=tmpdir, @@ -296,7 +296,7 @@ def myfun(i): else: return "Other_instance" - pool = LocalMapdlPool( + pool = MapdlPool( 3, exec_file=EXEC_FILE, nproc=NPROC, @@ -315,7 +315,7 @@ def myfun(i): def test_num_instances(): with pytest.raises(ValueError, match="least 1 instance"): - pool = LocalMapdlPool( + pool = MapdlPool( 0, exec_file=EXEC_FILE, nproc=NPROC, @@ -325,7 +325,7 @@ def test_num_instances(): @skip_if_ignore_pool def test_only_one_instance(): - pool = LocalMapdlPool( + pool = MapdlPool( 1, exec_file=EXEC_FILE, nproc=NPROC,