ansys.mapdl.core.pool.LocalMapdlPool

class ansys.mapdl.core.pool.LocalMapdlPool(n_instances, wait=True, run_location=None, port=50052, progress_bar=True, restart_failed=True, remove_temp_files=True, **kwargs)

Create a pool of MAPDL instances.

Note

Requires MAPDL 2020 R2 or later.

Parameters
n_instanceint

Number of instances to create.

restart_failedbool, optional

Restarts failed instances. Defaults to True.

waitbool, optional

Wait for pool to be initialized. Otherwise, pool will start in the background and all resources may not be available instantly.

run_locationstr, optional

Base directory to create additional directories for each MAPDL instance. Defaults to a temporary working directory.

starting_portint, optional

Starting port for the MAPDL instances. Defaults to 50052.

progress_barbool, optional

Show a progress bar when starting the pool. Defaults to True. Will not be shown when wait=False

restart_failedbool, optional

Restarts any failed instances in the pool.

remove_temp_filesbool, optional

Removes all temporary files on exit. Default True.

**kwargsAdditional Keyword Arguments

See help(ansys.mapdl.launcher.launch_mapdl) for a complete listing of all additional keyword arguments.

Examples

Simply create a pool of 10 instances to run in the temporary directory.

>>> from ansys.mapdl import LocalMapdlPool
>>> pool = mapdl.LocalMapdlPool(10)
Creating Pool: 100%|########| 10/10 [00:01<00:00,  1.43it/s]

Create several instances with 1 CPU each running at the current directory within their own isolated directories.

>>> import os
>>> my_path = os.getcmd()
>>> pool = mapdl.LocalMapdlPool(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/win64/ANSYS212.exe'
>>> pool = mapdl.LocalMapdlPool(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 = mapdl.LocalMapdlPool(10, exec_file=exec_file)
Creating Pool: 100%|########| 10/10 [00:01<00:00,  1.43it/s]

Methods

LocalMapdlPool.exit([block])

Close out all instances in the pool.

LocalMapdlPool.map(func[, iterable, ...])

Run a function for each instance of mapdl within the pool

LocalMapdlPool.next_available([return_index])

Wait until an instance of mapdl is available and return that instance.

LocalMapdlPool.run_batch(files[, ...])

Run a batch of input files on the pool.