mesh-adaptation / goalie

Goal-oriented error estimation and mesh adaptation for finite element problems solved using Firedrake
Other
1 stars 1 forks source link

Use subprocess to adapt in serial #96

Closed jwallwork23 closed 3 months ago

jwallwork23 commented 7 months ago

ParMmg doesn't support parallel adaptation in 2D. However, solving 2Ds PDEs in parallel is a standard activity of Firedrake. We should use Python subprocess to enable serial adaptation during a parallel run.

jwallwork23 commented 7 months ago

https://docs.python.org/3/library/subprocess.html

ddundo commented 7 months ago

Small comment here with my experience, maybe irrelevant. I would adapt in serial by doing something like this in the adaptor function:

if COMM_WORLD.rank == 0:
      arguments = f'--input temp_chk.h5 --output {output_fpath} --iteration {iteration}'.split()
      subprocess.run(["mpirun", "-n", "1", "python", "adapt_script.py"] + arguments)
COMM_WORLD.barrier()

So I would have a separate script for adaptation that I would run in serial. If I did not do this, and I adapted under the if COMM_WORLD.rank == 0 statement (and not in a separate script that I would call using subprocess), it would be extremely slow.

You recommended that I check the flame graph, but I gave up on using parallel so I never did it - but I can if we encounter this again / you think it's useful.

jwallwork23 commented 7 months ago

Thanks very much @ddundo, this is really useful info!

jwallwork23 commented 7 months ago

After some discussion, we are currently thinking this should actually happen on the Animate side. See https://github.com/pyroteus/animate/issues/71.