AMReX-Codes / amrex

AMReX: Software Framework for Block Structured AMR
https://amrex-codes.github.io/amrex
Other
530 stars 343 forks source link

How to Create MultiFabs Only in the Root Process When Running a Program with Multiple CPUs? #4092

Open ztdepztdep opened 3 weeks ago

ztdepztdep commented 3 weeks ago

I am planning to run my program with 8 CPUs, and I need to create MultiFabs only in the root process. Could you please help me with this?

WeiqunZhang commented 3 weeks ago
BoxArray ba(......);
int nprocs = ParallelDescriptor::NProcs();
int root = 0;
DistributionMapping dm(Vector<int>(nprocs,root));
MultiFab mf(ba, dm, ......);

Note that if MPI communication is not needed, FArrayBox might also serve the purpose.