case.run(): allowing concurrent cases? #347
Answered
by
gerlero
TessellateDataScience
asked this question in
Q&A
|
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). |
Answered by
gerlero
Apr 7, 2025
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()) |
1 reply
Answer selected by
TessellateDataScience
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@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: