case.run(): allowing concurrent cases? #347
-
|
Hey Gabriel, wondering if there's an easy way to allow numerous cases to be run at the same time? I have a server with many cores that I wish to utilise fully (e.g. running 2 cases each using 10 cores over the 20-core server). |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
@TessellateDataScience I think the easiest would be to use With Very basically it can look something like this: import asyncio
from foamlib import AsyncFoamCase
cases = [AsyncFoamCase(path1), AsyncFoamCase(path2), …]
async def run_all():
await asyncio.gather(*(case.run() for case in cases))
asyncio.run(run_all()) |
Beta Was this translation helpful? Give feedback.
@TessellateDataScience I think the easiest would be to use
AsyncFoamCase, which uses asyncio to be able to run multiple cases in parallel.With
AsyncFoamCase, you can launch as many cases as you have, and it will run as many of them concurrently as it can without oversubscribing the available CPUs.Very basically it can look something like this: