Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Apr 30, 2024
1 parent 9e404d4 commit 0224d9f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions doc/source/user_guide/pool.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,12 @@ This context manager is particularly interesting when using it with threads.
from ansys.mapdl.core import MapdlPool
from threading import Thread
loads = [1E6, 2E6, 3E6]
loads = [1e6, 2e6, 3e6]
solutions = {each_load: None for each_load in loads}
pool = MapdlPool(2)
def calculate_model(mapdl, load):
mapdl.prep7()
mapdl.et(1, "SOLID5")
Expand Down Expand Up @@ -160,17 +161,19 @@ This context manager is particularly interesting when using it with threads.
mapdl.nsel("S", "LOC", "Z", 30)
solutions[load] = mapdl.post_processing.nodal_displacement("X").max()
def threaded_function(load):
with pool.next() as mapdl:
value = calculate_model(mapdl, load)
if __name__ == "__main__":
threads = []
for load in loads:
t = Thread(target = threaded_function, args = [load])
t = Thread(target=threaded_function, args=[load])
t.start()
threads.append(t)
for thread in threads:
thread.join()
Expand All @@ -194,7 +197,7 @@ you need to manage the :meth:`Mapdl.locked <ansys.mapdl.core.mapdl._MapdlCore.lo
# More code...
# ...
#
mapdl.locked = False # Important for the instance to be seen as available.
mapdl.locked = False # Important for the instance to be seen as available.
Close the PyMAPDL pool
Expand Down

0 comments on commit 0224d9f

Please sign in to comment.