18#ifndef REMORA_USE_NETCDF
19 amrex::ignore_unused(istep_for_plot);
21 Vector<std::string> varnames_3d;
24 Vector<std::string> varnames_2d;
27 Vector<std::string> varnames_2d_rho;
28 Vector<std::string> varnames_2d_u;
29 Vector<std::string> varnames_2d_v;
31 const int ncomp_mf_3d = varnames_3d.size();
32 const auto ngrow_vars = IntVect(
NGROW-1,
NGROW-1,0);
35 int ncomp_mf_2d_rho = 0;
36 int ncomp_mf_2d_u = 0;
37 int ncomp_mf_2d_v = 0;
40 for (
auto plot_name : varnames_2d) {
42 if (plot_name ==
"zeta" ) {varnames_2d_rho.push_back(plot_name); ncomp_mf_2d_rho++;}
43 if (plot_name ==
"h" ) {varnames_2d_rho.push_back(plot_name); ncomp_mf_2d_rho++;}
44 if (plot_name ==
"f" ) {varnames_2d_rho.push_back(plot_name); ncomp_mf_2d_rho++;}
45 if (plot_name ==
"visc2") {varnames_2d_rho.push_back(plot_name); ncomp_mf_2d_rho++;}
46 for (
int n = 0; n <
ncons; ++n) {
47 const std::string diff2_name = std::string(
"diff2_") +
cons_names[n];
48 if (plot_name == diff2_name) {
49 varnames_2d_rho.push_back(plot_name);
53 if (plot_name ==
"ubar" ) {varnames_2d_u.push_back(plot_name); ncomp_mf_2d_u++;}
54 if (plot_name ==
"sustr") {varnames_2d_u.push_back(plot_name); ncomp_mf_2d_u++;}
55 if (plot_name ==
"bustr") {varnames_2d_u.push_back(plot_name); ncomp_mf_2d_u++;}
56 if (plot_name ==
"vbar" ) {varnames_2d_v.push_back(plot_name); ncomp_mf_2d_v++;}
57 if (plot_name ==
"svstr") {varnames_2d_v.push_back(plot_name); ncomp_mf_2d_v++;}
58 if (plot_name ==
"bvstr") {varnames_2d_v.push_back(plot_name); ncomp_mf_2d_v++;}
64 for (
int lev = 0; lev <= finest_level; ++lev) {
73 for (
int lev = 0; lev <= finest_level; ++lev) {
78 Vector<MultiFab> plotMF(finest_level+1);
79 for (
int lev = 0; lev <= finest_level; ++lev) {
80 plotMF[lev].define(grids[lev], dmap[lev], ncomp_mf_3d, ngrow_vars);
81 plotMF[lev].setVal(1.234e20);
85 Vector<MultiFab> mf_2d_rho(finest_level+1);
86 Vector<MultiFab> mf_2d_u(finest_level+1);
87 Vector<MultiFab> mf_2d_v(finest_level+1);
88 for (
int lev = 0; lev <= finest_level; ++lev) {
89 BoxArray ba(grids[lev]);
90 BoxList bl2d = ba.boxList();
91 for (
auto& b : bl2d) {
94 BoxArray ba2d(std::move(bl2d));
95 mf_2d_rho[lev].define(ba2d, dmap[lev], ncomp_mf_2d_rho, IntVect(0,0,0));
96 mf_2d_u[lev].define(ba2d, dmap[lev], ncomp_mf_2d_u , IntVect(0,0,0));
97 mf_2d_v[lev].define(ba2d, dmap[lev], ncomp_mf_2d_v , IntVect(0,0,0));
102 Vector<MultiFab> mf_nd(finest_level+1);
103 for (
int lev = 0; lev <= finest_level; ++lev) {
104 BoxArray nodal_grids(grids[lev]); nodal_grids.surroundingNodes();
105 mf_nd[lev].define(nodal_grids, dmap[lev], AMREX_SPACEDIM, 0);
106 mf_nd[lev].setVal(0.);
110 Vector<MultiFab> mf_u(finest_level+1);
111 Vector<MultiFab> mf_v(finest_level+1);
112 Vector<MultiFab> mf_w(finest_level+1);
114 for (
int lev = 0; lev <= finest_level; ++lev) {
115 BoxArray grid_stag_u(grids[lev]); grid_stag_u.surroundingNodes(0);
116 BoxArray grid_stag_v(grids[lev]); grid_stag_v.surroundingNodes(1);
117 BoxArray grid_stag_w(grids[lev]); grid_stag_w.surroundingNodes(2);
118 mf_u[lev].define(grid_stag_u, dmap[lev], 1, 0);
119 mf_v[lev].define(grid_stag_v, dmap[lev], 1, 0);
120 mf_w[lev].define(grid_stag_w, dmap[lev], 1, 0);
121 MultiFab::Copy(mf_u[lev],*
xvel_new[lev],0,0,1,0);
122 MultiFab::Copy(mf_v[lev],*
yvel_new[lev],0,0,1,0);
123 MultiFab::Copy(mf_w[lev],*
zvel_new[lev],0,0,1,0);
128 Vector<MultiFab> mf_cc_vel(finest_level+1);
135 for (
int lev = 0; lev <= finest_level; ++lev) {
136 mf_cc_vel[lev].define(grids[lev], dmap[lev], AMREX_SPACEDIM, IntVect(1,1,0));
137 mf_cc_vel[lev].setVal(0.0_rt);
138 average_face_to_cellcenter(mf_cc_vel[lev],0,
140 mf_cc_vel[lev].FillBoundary(geom[lev].periodicity());
144 amrex::Interpolater* mapper = &cell_cons_interp;
146 for (
int lev = 1; lev <= finest_level; ++lev) {
147 Vector<MultiFab*> fmf = {&(mf_cc_vel[lev]), &(mf_cc_vel[lev])};
148 Vector<Real> ftime = {
t_new[lev],
t_new[lev]};
149 Vector<MultiFab*> cmf = {&mf_cc_vel[lev-1], &mf_cc_vel[lev-1]};
150 Vector<Real> ctime = {
t_new[lev],
t_new[lev]};
153 amrex::FillPatchTwoLevels(mf_cc_vel[lev], mf_cc_vel[lev].nGrowVect(), IntVect(0,0,0),
154 t_new[lev], cmf, ctime, fmf, ftime,
155 0, 0, mf_cc_vel[lev].nComp(), geom[lev-1], geom[lev],
162 for (
auto plot_name : varnames_2d_rho)
164 if (plot_name ==
"zeta" ) {
165 for (
int lev = 0; lev <= finest_level; ++lev) { MultiFab::Copy(mf_2d_rho[lev],*
vec_Zt_avg1[lev],0,icomp_rho,1,0); }
168 if (plot_name ==
"h" ) {
169 for (
int lev = 0; lev <= finest_level; ++lev) { MultiFab::Copy(mf_2d_rho[lev],*
vec_h[lev],0,icomp_rho,1,0); }
172 if (plot_name ==
"f" ) {
173 for (
int lev = 0; lev <= finest_level; ++lev) { MultiFab::Copy(mf_2d_rho[lev],*
vec_fcor[lev],0,icomp_rho,1,0); }
176 if (plot_name ==
"visc2" ) {
177 for (
int lev = 0; lev <= finest_level; ++lev) {
179 amrex::Abort(
"Found while writing output: visc2 contains nan or inf");
181 for (MFIter mfi(mf_2d_rho[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi) {
182 const Box& bx = mfi.validbox();
183 const int K = mfi.index();
184 auto dst = mf_2d_rho[lev].array(mfi, icomp_rho);
186 ParallelFor(makeSlab(bx,2,0), [=] AMREX_GPU_DEVICE (
int i,
int j,
int)
noexcept {
187 dst(i,j,0) = src(i,j,0);
193 for (
int n = 0; n <
ncons; ++n) {
194 const std::string diff2_name = std::string(
"diff2_") +
cons_names[n];
195 if (plot_name == diff2_name) {
196 for (
int lev = 0; lev <= finest_level; ++lev) {
197 for (MFIter mfi(mf_2d_rho[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi) {
198 const Box& bx = mfi.validbox();
199 const int K = mfi.index();
200 auto dst = mf_2d_rho[lev].array(mfi, icomp_rho);
201 auto src =
vec_diff2[lev]->const_array(K);
202 ParallelFor(makeSlab(bx,2,0), [=] AMREX_GPU_DEVICE (
int i,
int j,
int)
noexcept {
203 dst(i,j,0) = src(i,j,0,n);
213 for (
auto plot_name : varnames_2d_u)
215 if (plot_name ==
"ubar" ) {
216 for (
int lev = 0; lev <= finest_level; ++lev) {
217 MultiFab::Copy(mf_2d_u[lev],*
vec_DU_avg1[lev],0,icomp_u,1,0);
221 if (plot_name ==
"sustr" ) {
222 for (
int lev = 0; lev <= finest_level; ++lev) { MultiFab::Copy(mf_2d_u[lev],*
vec_sustr[lev],0,icomp_u,1,0); }
225 if (plot_name ==
"bustr" ) {
226 for (
int lev = 0; lev <= finest_level; ++lev) { MultiFab::Copy(mf_2d_u[lev],*
vec_bustr[lev],0,icomp_u,1,0); }
232 for (
auto plot_name : varnames_2d_v)
234 if (plot_name ==
"vbar" ) {
235 for (
int lev = 0; lev <= finest_level; ++lev) { MultiFab::Copy(mf_2d_v[lev],*
vec_DV_avg1[lev],0,icomp_v,1,0); }
238 if (plot_name ==
"svstr" ) {
239 for (
int lev = 0; lev <= finest_level; ++lev) { MultiFab::Copy(mf_2d_v[lev],*
vec_svstr[lev],0,icomp_v,1,0); }
242 if (plot_name ==
"bvstr" ) {
243 for (
int lev = 0; lev <= finest_level; ++lev) { MultiFab::Copy(mf_2d_v[lev],*
vec_bvstr[lev],0,icomp_v,1,0); }
248 for (
int lev = 0; lev <= finest_level; ++lev)
254 for (
int i = 0; i <
ncons; ++i) {
257 amrex::Abort(
"Found while writing output: Cons (salt, temp, or tracer, etc) contains nan or inf");
259 MultiFab::Copy(plotMF[lev],*
cons_new[lev],i,mf_comp,1,ngrow_vars);
266 if (mf_cc_vel[lev].contains_nan(0,1) || mf_cc_vel[lev].contains_inf(0,1)) {
267 amrex::Abort(
"Found while writing output: u velocity contains nan or inf");
269 MultiFab::Copy(plotMF[lev], mf_cc_vel[lev], 0, mf_comp, 1, 0);
273 if (mf_cc_vel[lev].contains_nan(1,1) || mf_cc_vel[lev].contains_inf(1,1)) {
274 amrex::Abort(
"Found while writing output: v velocity contains nan or inf");
276 MultiFab::Copy(plotMF[lev], mf_cc_vel[lev], 1, mf_comp, 1, 0);
280 if (mf_cc_vel[lev].contains_nan(2,1) || mf_cc_vel[lev].contains_inf(2,1)) {
281 amrex::Abort(
"Found while writing output: z velocity contains nan or inf");
283 MultiFab::Copy(plotMF[lev], mf_cc_vel[lev], 2, mf_comp, 1, 0);
288 auto calculate_derived = [&](
const std::string& der_name,
292 MultiFab dmf(plotMF[lev], make_alias, mf_comp, 1);
294#pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
296 for (MFIter mfi(dmf, TilingIfNotGPU()); mfi.isValid(); ++mfi)
298 const Box& bx = mfi.tilebox();
299 auto& dfab = dmf[mfi];
301 if (der_name ==
"vorticity") {
302 auto const& sfab = mf_cc_vel[lev][mfi];
303 der_function(bx, dfab, 0, 1, sfab,
vec_pm[lev]->const_array(mfi),
vec_pn[lev]->const_array(mfi),
vec_mskr[lev]->const_array(mfi), Geom(lev),
t_new[0],
nullptr, lev);
305 auto const& sfab = (*
cons_new[lev])[mfi];
306 der_function(bx, dfab, 0, 1, sfab,
vec_pm[lev]->const_array(mfi),
vec_pn[lev]->const_array(mfi),
vec_mskr[lev]->const_array(mfi), Geom(lev),
t_new[0],
nullptr, lev);
318 Real dx = Geom()[lev].CellSizeArray()[0];
319 Real dy = Geom()[lev].CellSizeArray()[1];
326 MultiFab dmf(plotMF[lev], make_alias, mf_comp, AMREX_SPACEDIM);
328#pragma omp parallel if (Gpu::notInLaunchRegion())
330 for (MFIter mfi(dmf, TilingIfNotGPU()); mfi.isValid(); ++mfi) {
331 const Box& bx = mfi.tilebox();
332 const Array4<Real> loc_arr = dmf.array(mfi);
333 const Array4<Real const> zp_arr =
vec_z_phys_nd[lev]->const_array(mfi);
335 ParallelFor(bx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) {
336 loc_arr(i,j,k,0) = (i+0.5_rt) * dx;
337 loc_arr(i,j,k,1) = (j+0.5_rt) * dy;
338 loc_arr(i,j,k,2) = 0.125_rt * (zp_arr(i,j ,k ) + zp_arr(i+1,j ,k ) +
339 zp_arr(i,j+1,k ) + zp_arr(i+1,j+1,k ) +
340 zp_arr(i,j ,k+1) + zp_arr(i+1,j ,k+1) +
341 zp_arr(i,j+1,k+1) + zp_arr(i+1,j+1,k+1) );
344 mf_comp += AMREX_SPACEDIM;
347#ifdef REMORA_USE_PARTICLES
348 const auto& particles_namelist( particleData.getNames() );
349 for (ParticlesNamesVector::size_type i = 0; i < particles_namelist.size(); i++) {
352 MultiFab temp_dat(plotMF[lev].boxArray(), plotMF[lev].DistributionMap(), 1, 0);
354 particleData[particles_namelist[i]]->Increment(temp_dat, lev);
355 MultiFab::Copy(plotMF[lev], temp_dat, 0, mf_comp, 1, 0);
360 Vector<std::string> particle_mesh_plot_names(0);
361 particleData.GetMeshPlotVarNames( particle_mesh_plot_names );
362 for (
int i = 0; i < particle_mesh_plot_names.size(); i++) {
363 std::string plot_var_name(particle_mesh_plot_names[i]);
365 MultiFab temp_dat(plotMF[lev].boxArray(), plotMF[lev].DistributionMap(), 1, 1);
367 particleData.GetMeshPlotVar(plot_var_name, temp_dat, lev);
368 MultiFab::Copy(plotMF[lev], temp_dat, 0, mf_comp, 1, 0);
375 Real dz = Geom()[lev].CellSizeArray()[2];
376 int N = Geom()[lev].Domain().size()[2];
379#pragma omp parallel if (Gpu::notInLaunchRegion())
381 for (MFIter mfi(mf_nd[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi)
383 const Box& bx = mfi.tilebox();
384 Array4<Real> mf_arr = mf_nd[lev].array(mfi);
385 ParallelFor(bx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) {
386 mf_arr(i,j,k,2) = mf_arr(i,j,k,2) + (N-k) * dz;
396 if (finest_level == 0)
399 amrex::Print() <<
"Writing plotfile " << plotfilename <<
"\n";
401 GetVecOfConstPtrs(plotMF),
402 GetVecOfConstPtrs(mf_nd),
403 GetVecOfConstPtrs(mf_u),
404 GetVecOfConstPtrs(mf_v),
405 GetVecOfConstPtrs(mf_w),
406 GetVecOfConstPtrs(mf_2d_rho),
407 GetVecOfConstPtrs(mf_2d_u),
408 GetVecOfConstPtrs(mf_2d_v),
409 varnames_3d, varnames_2d_rho,
410 varnames_2d_u, varnames_2d_v,
415#ifdef REMORA_USE_PARTICLES
416 particleData.Checkpoint(plotfilename);
423 amrex::Print() <<
"Writing plotfile " << plotfilename <<
"\n";
425 [[maybe_unused]]
int desired_ratio = std::max(std::max(ref_ratio[lev0][0],ref_ratio[lev0][1]),ref_ratio[lev0][2]);
426 bool any_ratio_one = ( ( (ref_ratio[lev0][0] == 1) || (ref_ratio[lev0][1] == 1) ) ||
427 (ref_ratio[lev0][2] == 1) );
428 for (
int lev = 1; lev < finest_level; lev++) {
429 any_ratio_one = any_ratio_one ||
430 ( ( (ref_ratio[lev][0] == 1) || (ref_ratio[lev][1] == 1) ) ||
431 (ref_ratio[lev][2] == 1) );
434 Vector<IntVect> r2(finest_level);
435 Vector<Geometry> g2(finest_level+1);
436 Vector<MultiFab> mf2(finest_level+1);
438 mf2[0].define(grids[0], dmap[0], ncomp_mf_3d, 0);
441 MultiFab::Copy(mf2[0],plotMF[0],0,0,plotMF[0].nComp(),0);
444 Array<int,AMREX_SPACEDIM> periodicity =
445 {Geom()[0].isPeriodic(0),Geom()[0].isPeriodic(1),Geom()[0].isPeriodic(2)};
446 g2[0].define(Geom()[0].Domain(),&(Geom()[0].ProbDomain()),0,periodicity.data());
448 r2[0] = IntVect(1,1,ref_ratio[0][0]);
449 for (
int lev = 1; lev <= finest_level; ++lev) {
453 r2[lev-1][2] = r2[lev-2][2] * ref_ratio[lev-1][0];
456 mf2[lev].define(refine(grids[lev],r2[lev-1]), dmap[lev], ncomp_mf_3d, 0);
459 Box d2(Geom()[lev].Domain());
460 d2.refine(r2[lev-1]);
462 g2[lev].define(d2,&(Geom()[lev].ProbDomain()),0,periodicity.data());
467 amrex::Vector<amrex::BCRec> null_dom_bcs;
468 null_dom_bcs.resize(mf2[0].nComp());
469 for (
int n = 0; n < mf2[0].nComp(); n++) {
470 for (
int dir = 0; dir < AMREX_SPACEDIM; dir++) {
477 for (
int lev = 1; lev <= finest_level; ++lev) {
478 Interpolater* mapper_c = &pc_interp;
479 InterpFromCoarseLevel(mf2[lev],
t_new[lev], plotMF[lev],
480 0, 0, mf2[lev].nComp(),
483 r2[lev-1], mapper_c, null_dom_bcs, 0);
487 Vector<IntVect> rr(finest_level);
488 for (
int lev = 0; lev < finest_level; ++lev) {
489 rr[lev] = IntVect(ref_ratio[lev][0],ref_ratio[lev][1],ref_ratio[lev][0]);
493 GetVecOfConstPtrs(mf2),
494 GetVecOfConstPtrs(mf_nd),
495 GetVecOfConstPtrs(mf_u),
496 GetVecOfConstPtrs(mf_v),
497 GetVecOfConstPtrs(mf_w),
498 GetVecOfConstPtrs(mf_2d_rho),
499 GetVecOfConstPtrs(mf_2d_u),
500 GetVecOfConstPtrs(mf_2d_v),
501 varnames_3d, varnames_2d_rho,
502 varnames_2d_u, varnames_2d_v,
507#ifdef REMORA_USE_PARTICLES
508 particleData.Checkpoint(plotfilename);
512 GetVecOfConstPtrs(plotMF),
513 GetVecOfConstPtrs(mf_nd),
514 GetVecOfConstPtrs(mf_u),
515 GetVecOfConstPtrs(mf_v),
516 GetVecOfConstPtrs(mf_w),
517 GetVecOfConstPtrs(mf_2d_rho),
518 GetVecOfConstPtrs(mf_2d_u),
519 GetVecOfConstPtrs(mf_2d_v),
520 varnames_3d, varnames_2d_rho,
521 varnames_2d_u, varnames_2d_v,
525#ifdef REMORA_USE_PARTICLES
526 particleData.Checkpoint(plotfilename);
531 for (
int lev = 0; lev <= finest_level; ++lev) {
536#ifdef REMORA_USE_NETCDF
540 AMREX_ASSERT(finest_level == 0);
542 plotMF[0].FillBoundary(geom[lev].periodicity());
568 const Vector<const MultiFab*>& mf,
569 const Vector<const MultiFab*>& mf_nd,
570 const Vector<const MultiFab*>& mf_u,
571 const Vector<const MultiFab*>& mf_v,
572 const Vector<const MultiFab*>& mf_w,
573 const Vector<const MultiFab*>& mf_2d_rho,
574 const Vector<const MultiFab*>& mf_2d_u,
575 const Vector<const MultiFab*>& mf_2d_v,
576 const Vector<std::string>& varnames_3d,
577 const Vector<std::string>& varnames_2d_rho,
578 const Vector<std::string>& varnames_2d_u,
579 const Vector<std::string>& varnames_2d_v,
580 const Vector<Geometry>& my_geom,
582 const Vector<int>& level_steps,
583 const Vector<IntVect>& rr,
584 const std::string &versionName,
585 const std::string &levelPrefix,
586 const std::string &mfPrefix,
587 const Vector<std::string>& extra_dirs)
const
589 BL_PROFILE(
"WriteMultiLevelPlotfileWithBathymetry()");
591 AMREX_ASSERT(nlevels <= mf.size());
592 AMREX_ASSERT(nlevels <= ref_ratio.size()+1);
593 AMREX_ASSERT(nlevels <= level_steps.size());
595 AMREX_ASSERT(mf[0]->nComp() == varnames_3d.size());
597 bool callBarrier(
false);
598 PreBuildDirectorHierarchy(plotfilename, levelPrefix, nlevels, callBarrier);
599 if (!extra_dirs.empty()) {
600 for (
const auto& d : extra_dirs) {
601 const std::string ed = plotfilename+
"/"+d;
602 PreBuildDirectorHierarchy(ed, levelPrefix, nlevels, callBarrier);
605 ParallelDescriptor::Barrier();
607 if (ParallelDescriptor::MyProc() == ParallelDescriptor::NProcs()-1) {
608 Vector<BoxArray> boxArrays(nlevels);
609 for(
int level(0); level < boxArrays.size(); ++level) {
610 boxArrays[level] = mf[level]->boxArray();
614 VisMF::IO_Buffer io_buffer(VisMF::IO_Buffer_Size);
615 std::string HeaderFileName(plotfilename +
"/Header");
616 std::ofstream HeaderFile;
617 HeaderFile.rdbuf()->pubsetbuf(io_buffer.dataPtr(), io_buffer.size());
618 HeaderFile.open(HeaderFileName.c_str(), std::ofstream::out |
619 std::ofstream::trunc |
620 std::ofstream::binary);
621 if( ! HeaderFile.good()) FileOpenFailed(HeaderFileName);
623 varnames_2d_rho, varnames_2d_u, varnames_2d_v,
624 my_geom, time, level_steps, rr, versionName,
625 levelPrefix, mfPrefix);
628 if (AsyncOut::UseAsyncOut()) {
629 AsyncOut::Submit(std::move(f));
635 std::string mf_nodal_prefix =
"Nu_nd";
636 std::string mf_uface_prefix =
"UFace";
637 std::string mf_vface_prefix =
"VFace";
638 std::string mf_wface_prefix =
"WFace";
639 std::string mf_2d_rho_prefix =
"rho2d";
640 std::string mf_2d_u_prefix =
"u2d";
641 std::string mf_2d_v_prefix =
"v2d";
643 for (
int level = 0; level <= finest_level; ++level)
645 if (AsyncOut::UseAsyncOut()) {
646 VisMF::AsyncWrite(*mf[level],
647 MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mfPrefix),
649 VisMF::AsyncWrite(*mf_nd[level],
650 MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_nodal_prefix),
653 VisMF::AsyncWrite(*mf_u[level],
654 MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_uface_prefix),
656 VisMF::AsyncWrite(*mf_v[level],
657 MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_vface_prefix),
659 VisMF::AsyncWrite(*mf_w[level],
660 MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_wface_prefix),
663 if (mf_2d_rho[level]->nComp() > 0) {
664 VisMF::AsyncWrite(*mf_2d_rho[level],
665 MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_2d_rho_prefix),
668 if (mf_2d_u[level]->nComp() > 0) {
669 VisMF::AsyncWrite(*mf_2d_u[level],
670 MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_2d_u_prefix),
673 if (mf_2d_v[level]->nComp() > 0) {
674 VisMF::AsyncWrite(*mf_2d_v[level],
675 MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_2d_v_prefix),
679 const MultiFab* data;
680 std::unique_ptr<MultiFab> mf_tmp;
681 if (mf[level]->nGrowVect() != 0) {
682 mf_tmp = std::make_unique<MultiFab>(mf[level]->boxArray(),
683 mf[level]->DistributionMap(),
684 mf[level]->nComp(), 0, MFInfo(),
685 mf[level]->Factory());
686 MultiFab::Copy(*mf_tmp, *mf[level], 0, 0, mf[level]->nComp(), 0);
691 VisMF::Write(*data , MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mfPrefix));
692 VisMF::Write(*mf_nd[level], MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_nodal_prefix));
694 VisMF::Write(*mf_u[level], MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_uface_prefix));
695 VisMF::Write(*mf_v[level], MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_vface_prefix));
696 VisMF::Write(*mf_w[level], MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_wface_prefix));
698 if (mf_2d_rho[level]->nComp() > 0) {
699 VisMF::Write(*mf_2d_rho[level], MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_2d_rho_prefix));
701 if (mf_2d_u[level]->nComp() > 0) {
702 VisMF::Write(*mf_2d_u[level], MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_2d_u_prefix));
704 if (mf_2d_v[level]->nComp() > 0) {
705 VisMF::Write(*mf_2d_v[level], MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_2d_v_prefix));
727 [[maybe_unused]]
int nlevels,
728 const Vector<BoxArray> &bArray,
729 const Vector<std::string> &varnames_3d,
730 const Vector<std::string> &varnames_2d_rho,
731 const Vector<std::string> &varnames_2d_u,
732 const Vector<std::string> &varnames_2d_v,
733 const Vector<Geometry>& my_geom,
735 const Vector<int> &level_steps,
736 const Vector<IntVect>& my_ref_ratio,
737 const std::string &versionName,
738 const std::string &levelPrefix,
739 const std::string &mfPrefix)
const
741 AMREX_ASSERT(nlevels <= bArray.size());
742 AMREX_ASSERT(nlevels <= ref_ratio.size()+1);
743 AMREX_ASSERT(nlevels <= level_steps.size());
745 int num_extra_mfs = 1;
750 HeaderFile.precision(17);
753 HeaderFile << versionName <<
'\n';
755 HeaderFile << varnames_3d.size() <<
'\n';
757 for (
int ivar = 0; ivar < varnames_3d.size(); ++ivar) {
758 HeaderFile << varnames_3d[ivar] <<
"\n";
760 HeaderFile << AMREX_SPACEDIM <<
'\n';
761 HeaderFile << time <<
'\n';
762 HeaderFile << finest_level <<
'\n';
763 for (
int i = 0; i < AMREX_SPACEDIM; ++i) {
764 HeaderFile << my_geom[0].ProbLo(i) <<
' ';
767 for (
int i = 0; i < AMREX_SPACEDIM; ++i) {
768 HeaderFile << my_geom[0].ProbHi(i) <<
' ';
771 for (
int i = 0; i < finest_level; ++i) {
772 HeaderFile << my_ref_ratio[i][0] <<
' ';
775 for (
int i = 0; i <= finest_level; ++i) {
776 HeaderFile << my_geom[i].Domain() <<
' ';
779 for (
int i = 0; i <= finest_level; ++i) {
780 HeaderFile << level_steps[i] <<
' ';
783 for (
int i = 0; i <= finest_level; ++i) {
784 for (
int k = 0; k < AMREX_SPACEDIM; ++k) {
785 HeaderFile << my_geom[i].CellSize()[k] <<
' ';
789 HeaderFile << (int) my_geom[0].
Coord() <<
'\n';
792 for (
int level = 0; level <= finest_level; ++level) {
793 HeaderFile << level <<
' ' << bArray[level].size() <<
' ' << time <<
'\n';
794 HeaderFile << level_steps[level] <<
'\n';
796 const IntVect& domain_lo = my_geom[level].Domain().smallEnd();
797 for (
int i = 0; i < bArray[level].size(); ++i)
802 const Box& b = shift(bArray[level][i], -domain_lo);
803 RealBox loc = RealBox(b, my_geom[level].CellSize(), my_geom[level].ProbLo());
804 for (
int n = 0; n < AMREX_SPACEDIM; ++n) {
805 HeaderFile << loc.lo(n) <<
' ' << loc.hi(n) <<
'\n';
809 HeaderFile << MultiFabHeaderPath(level, levelPrefix, mfPrefix) <<
'\n';
811 HeaderFile << num_extra_mfs <<
"\n";
812 HeaderFile <<
"3" <<
"\n";
813 HeaderFile <<
"amrexvec_nu_x" <<
"\n";
814 HeaderFile <<
"amrexvec_nu_y" <<
"\n";
815 HeaderFile <<
"amrexvec_nu_z" <<
"\n";
816 std::string mf_nodal_prefix =
"Nu_nd";
817 for (
int level = 0; level <= finest_level; ++level) {
818 HeaderFile << MultiFabHeaderPath(level, levelPrefix, mf_nodal_prefix) <<
'\n';
821 HeaderFile <<
"1" <<
"\n";
822 HeaderFile <<
"u_vel" <<
"\n";
823 std::string mf_uface_prefix =
"UFace";
824 for (
int level = 0; level <= finest_level; ++level) {
825 HeaderFile << MultiFabHeaderPath(level, levelPrefix, mf_uface_prefix) <<
'\n';
827 HeaderFile <<
"1" <<
"\n";
828 HeaderFile <<
"v_vel" <<
"\n";
829 std::string mf_vface_prefix =
"VFace";
830 for (
int level = 0; level <= finest_level; ++level) {
831 HeaderFile << MultiFabHeaderPath(level, levelPrefix, mf_vface_prefix) <<
'\n';
833 HeaderFile <<
"1" <<
"\n";
834 HeaderFile <<
"w_vel" <<
"\n";
835 std::string mf_wface_prefix =
"WFace";
836 for (
int level = 0; level <= finest_level; ++level) {
837 HeaderFile << MultiFabHeaderPath(level, levelPrefix, mf_wface_prefix) <<
'\n';
841 if (varnames_2d_rho.size() > 0) {
842 HeaderFile << varnames_2d_rho.size() <<
"\n";
843 for (
int ivar = 0; ivar < varnames_2d_rho.size(); ++ivar) {
844 HeaderFile << varnames_2d_rho[ivar] <<
"\n";
846 std::string mf_2d_rho_prefix =
"rho2d";
847 for (
int level = 0; level <= finest_level; ++level) {
848 HeaderFile << MultiFabHeaderPath(level, levelPrefix, mf_2d_rho_prefix) <<
"\n";
852 if (varnames_2d_u.size() > 0) {
853 HeaderFile << varnames_2d_u.size() <<
"\n";
854 for (
int ivar = 0; ivar < varnames_2d_u.size(); ++ivar) {
855 HeaderFile << varnames_2d_u[ivar] <<
"\n";
857 std::string mf_2d_u_prefix =
"u2d";
858 for (
int level = 0; level <= finest_level; ++level) {
859 HeaderFile << MultiFabHeaderPath(level, levelPrefix, mf_2d_u_prefix) <<
"\n";
863 if (varnames_2d_v.size() > 0) {
864 HeaderFile << varnames_2d_v.size() <<
"\n";
865 for (
int ivar = 0; ivar < varnames_2d_v.size(); ++ivar) {
866 HeaderFile << varnames_2d_v[ivar] <<
"\n";
868 std::string mf_2d_v_prefix =
"v2d";
869 for (
int level = 0; level <= finest_level; ++level) {
870 HeaderFile << MultiFabHeaderPath(level, levelPrefix, mf_2d_v_prefix) <<
"\n";