How can I solve transient problems in parallel?

My apologies for a simple question here. I am a relatively new user of FEniCS, and very inexperienced with parallel computing.

I have built a FEniCS script to solve a formulation of poroelasticity. My question is: can I call my script, which contains a time-loop, in parallel using the usual:

mpirun -n # python fenics_script.py

A good example of this would be the Navier Stokes example ft07_navier_stokes_channel.py. Can I simply run that example problem in parallel without editing?

My intuition says that for-loops require additional consideration when running in parallel (i.e. additional MPI commands); however, I don’t know the true answer to that. There are several other posts about FEniCS in parallel, but none that describe parallel runs with a transient problem. I want to be sure that when calling my script containing a time loop, I am not simply running each command within the loop separately on each processor.

Thank you for any help you can provide!

1 Like

Hi Ryan,

Quick answer: Yes
Long answer: Running in parallel performs domain decomposition on each process, so that each time you call solve, this runs in parallel. That is the part in which the processes communicate, and the rest is performed independently. I have solved time-dependent problems exactly as you mention and had no problems.
If something is not working, maybe post a minimal working example to see what’s happening.

Best reagrds,
Nico

1 Like

Thank you for your reply, Nico. It’s much appreciated!

I don’t have any specific issues with my code at this point. My question was more preemptive.

To clarify you answer: within a time loop, each processor will run each command individually (such as updating the time variable); however, when it comes to the solve command, the processors somehow know to perform that in parallel without any additional lines of code in the script. Is that correct?

I assume the other FEniCS specific functions (e.g. assembly) run in parallel this same way (assuming the function has been developed for parallel usage)?

In addition to my time loop, I have another for-loop which handles a Picard iteration. I imagine this part of my script would require additional consideration to run correctly in parallel (i.e. sharing variables amongst processors).

Thanks again!

No modifications should be required in your code in any case, this is handled internally using MPI; no process will go asynchronous with a call to a dolfin function (which supports parallellism of course, but all the important ones do).