23 std::string file, std::string func,
int line,
24 const amrex::MultiFab &a_mf, std::string desc,
25 amrex::Box domain,
int )
36 std::ostringstream messagestream;
37 std::string filesan = file;
39 messagestream << filesan <<
"_" << func <<
"_" << line << desc;
40 std::string key = messagestream.str();
49 messagestream <<
"_" << cntr;
51 std::string name = messagestream.str();
52 std::vector<std::string> allnames;
54 for (
auto & othername : allnames)
56 if (name != othername)
58 name,
" but some other process is trying to read ",
62 amrex::BoxArray ba = a_mf.boxArray();
63 amrex::DistributionMapping dm = a_mf.DistributionMap();
65 int ncomp = a_mf.nComp();
66 if (domain != amrex::Box::TheUnitBox())
68 for (
auto &b : ba.boxList()) b = b.grow(2) & domain;
71 amrex::MultiFab mf(ba,dm,ncomp,nghost);
72 amrex::MultiFab::Copy(mf,a_mf,0,0,ncomp,0);
73 if (amrex::ParallelDescriptor::NProcs() == 1)
77 std::filesystem::create_directory(
"checks");
78 amrex::VisMF::Write(mf,
"checks/" + name);
84 amrex::MultiFab mftmp;
85 amrex::VisMF::Read(mftmp,
"checks/" + name);
86 if (ba != mftmp.boxArray())
94 amrex::MultiFab mforig(ba,mf.distributionMap,ncomp,nghost);
95 amrex::VisMF::Read(mforig,
"checks/" + name);
97 amrex::MultiFab mfdiff(ba, mf.distributionMap, ncomp, nghost);
98 amrex::MultiFab::Copy(mfdiff, mf,0,0,ncomp,nghost);
99 amrex::MultiFab::Subtract(mfdiff,mforig,0,0,ncomp,nghost);
100 mfdiff.abs(0,ncomp,nghost);
102 for (
int n = 0 ; n < ncomp; n++)
105 auto argmax = mfdiff.maxIndex(n,nghost);
108 amrex::ParallelDescriptor::Barrier();
110 amrex::ParallelDescriptor::Barrier();
113 amrex::ParallelDescriptor::Barrier();
115 amrex::ParallelDescriptor::Barrier();
118 amrex::ParallelDescriptor::Barrier();
120 amrex::ParallelDescriptor::Barrier();
123 messagestream <<
"_diff";
124 amrex::VisMF::Write(mfdiff,messagestream.str());