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 ==
"ubar" ) {varnames_2d_u.push_back(plot_name); ncomp_mf_2d_u++;}
45 if (plot_name ==
"sustr") {varnames_2d_u.push_back(plot_name); ncomp_mf_2d_u++;}
46 if (plot_name ==
"bustr") {varnames_2d_u.push_back(plot_name); ncomp_mf_2d_u++;}
47 if (plot_name ==
"vbar" ) {varnames_2d_v.push_back(plot_name); ncomp_mf_2d_v++;}
48 if (plot_name ==
"svstr") {varnames_2d_v.push_back(plot_name); ncomp_mf_2d_v++;}
49 if (plot_name ==
"bvstr") {varnames_2d_v.push_back(plot_name); ncomp_mf_2d_v++;}
55 for (
int lev = 0; lev <= finest_level; ++lev) {
62 for (
int lev = 0; lev <= finest_level; ++lev) {
67 Vector<MultiFab> plotMF(finest_level+1);
68 for (
int lev = 0; lev <= finest_level; ++lev) {
69 plotMF[lev].define(grids[lev], dmap[lev], ncomp_mf_3d, ngrow_vars);
70 plotMF[lev].setVal(1.234e20);
74 Vector<MultiFab> mf_2d_rho(finest_level+1);
75 Vector<MultiFab> mf_2d_u(finest_level+1);
76 Vector<MultiFab> mf_2d_v(finest_level+1);
77 for (
int lev = 0; lev <= finest_level; ++lev) {
78 BoxArray ba(grids[lev]);
79 BoxList bl2d = ba.boxList();
80 for (
auto& b : bl2d) {
83 BoxArray ba2d(std::move(bl2d));
84 mf_2d_rho[lev].define(ba2d, dmap[lev], ncomp_mf_2d_rho, IntVect(0,0,0));
85 mf_2d_u[lev].define(ba2d, dmap[lev], ncomp_mf_2d_u , IntVect(0,0,0));
86 mf_2d_v[lev].define(ba2d, dmap[lev], ncomp_mf_2d_v , IntVect(0,0,0));
90 Vector<MultiFab> mf_nd(finest_level+1);
91 for (
int lev = 0; lev <= finest_level; ++lev) {
92 BoxArray nodal_grids(grids[lev]); nodal_grids.surroundingNodes();
93 mf_nd[lev].define(nodal_grids, dmap[lev], AMREX_SPACEDIM, 0);
94 mf_nd[lev].setVal(0.);
98 Vector<MultiFab> mf_u(finest_level+1);
99 Vector<MultiFab> mf_v(finest_level+1);
100 Vector<MultiFab> mf_w(finest_level+1);
102 for (
int lev = 0; lev <= finest_level; ++lev) {
103 BoxArray grid_stag_u(grids[lev]); grid_stag_u.surroundingNodes(0);
104 BoxArray grid_stag_v(grids[lev]); grid_stag_v.surroundingNodes(1);
105 BoxArray grid_stag_w(grids[lev]); grid_stag_w.surroundingNodes(2);
106 mf_u[lev].define(grid_stag_u, dmap[lev], 1, 0);
107 mf_v[lev].define(grid_stag_v, dmap[lev], 1, 0);
108 mf_w[lev].define(grid_stag_w, dmap[lev], 1, 0);
109 MultiFab::Copy(mf_u[lev],*
xvel_new[lev],0,0,1,0);
110 MultiFab::Copy(mf_v[lev],*
yvel_new[lev],0,0,1,0);
111 MultiFab::Copy(mf_w[lev],*
zvel_new[lev],0,0,1,0);
116 Vector<MultiFab> mf_cc_vel(finest_level+1);
123 for (
int lev = 0; lev <= finest_level; ++lev) {
124 mf_cc_vel[lev].define(grids[lev], dmap[lev], AMREX_SPACEDIM, IntVect(1,1,0));
125 mf_cc_vel[lev].setVal(0.0_rt);
126 average_face_to_cellcenter(mf_cc_vel[lev],0,
128 mf_cc_vel[lev].FillBoundary(geom[lev].periodicity());
132 amrex::Interpolater* mapper = &cell_cons_interp;
134 for (
int lev = 1; lev <= finest_level; ++lev) {
135 Vector<MultiFab*> fmf = {&(mf_cc_vel[lev]), &(mf_cc_vel[lev])};
136 Vector<Real> ftime = {
t_new[lev],
t_new[lev]};
137 Vector<MultiFab*> cmf = {&mf_cc_vel[lev-1], &mf_cc_vel[lev-1]};
138 Vector<Real> ctime = {
t_new[lev],
t_new[lev]};
141 amrex::FillPatchTwoLevels(mf_cc_vel[lev], mf_cc_vel[lev].nGrowVect(), IntVect(0,0,0),
142 t_new[lev], cmf, ctime, fmf, ftime,
143 0, 0, mf_cc_vel[lev].nComp(), geom[lev-1], geom[lev],
150 for (
auto plot_name : varnames_2d_rho)
152 if (plot_name ==
"zeta" ) {
153 for (
int lev = 0; lev <= finest_level; ++lev) { MultiFab::Copy(mf_2d_rho[lev],*
vec_Zt_avg1[lev],0,icomp_rho,1,0); }
156 if (plot_name ==
"h" ) {
157 for (
int lev = 0; lev <= finest_level; ++lev) { MultiFab::Copy(mf_2d_rho[lev],*
vec_h[lev],0,icomp_rho,1,0); }
163 for (
auto plot_name : varnames_2d_u)
165 if (plot_name ==
"ubar" ) {
166 for (
int lev = 0; lev <= finest_level; ++lev) {
167 MultiFab::Copy(mf_2d_u[lev],*
vec_DU_avg1[lev],0,icomp_u,1,0);
171 if (plot_name ==
"sustr" ) {
172 for (
int lev = 0; lev <= finest_level; ++lev) { MultiFab::Copy(mf_2d_u[lev],*
vec_sustr[lev],0,icomp_u,1,0); }
175 if (plot_name ==
"bustr" ) {
176 for (
int lev = 0; lev <= finest_level; ++lev) { MultiFab::Copy(mf_2d_u[lev],*
vec_bustr[lev],0,icomp_u,1,0); }
182 for (
auto plot_name : varnames_2d_v)
184 if (plot_name ==
"vbar" ) {
185 for (
int lev = 0; lev <= finest_level; ++lev) { MultiFab::Copy(mf_2d_v[lev],*
vec_DV_avg1[lev],0,icomp_v,1,0); }
188 if (plot_name ==
"svstr" ) {
189 for (
int lev = 0; lev <= finest_level; ++lev) { MultiFab::Copy(mf_2d_v[lev],*
vec_svstr[lev],0,icomp_v,1,0); }
192 if (plot_name ==
"bvstr" ) {
193 for (
int lev = 0; lev <= finest_level; ++lev) { MultiFab::Copy(mf_2d_v[lev],*
vec_bvstr[lev],0,icomp_v,1,0); }
198 for (
int lev = 0; lev <= finest_level; ++lev)
204 for (
int i = 0; i <
NCONS; ++i) {
207 amrex::Abort(
"Found while writing output: Cons (salt, temp, or tracer, etc) contains nan or inf");
209 MultiFab::Copy(plotMF[lev],*
cons_new[lev],i,mf_comp,1,ngrow_vars);
216 if (mf_cc_vel[lev].contains_nan(0,1) || mf_cc_vel[lev].contains_inf(0,1)) {
217 amrex::Abort(
"Found while writing output: u velocity contains nan or inf");
219 MultiFab::Copy(plotMF[lev], mf_cc_vel[lev], 0, mf_comp, 1, 0);
223 if (mf_cc_vel[lev].contains_nan(1,1) || mf_cc_vel[lev].contains_inf(1,1)) {
224 amrex::Abort(
"Found while writing output: v velocity contains nan or inf");
226 MultiFab::Copy(plotMF[lev], mf_cc_vel[lev], 1, mf_comp, 1, 0);
230 if (mf_cc_vel[lev].contains_nan(2,1) || mf_cc_vel[lev].contains_inf(2,1)) {
231 amrex::Abort(
"Found while writing output: z velocity contains nan or inf");
233 MultiFab::Copy(plotMF[lev], mf_cc_vel[lev], 2, mf_comp, 1, 0);
238 auto calculate_derived = [&](
const std::string& der_name,
242 MultiFab dmf(plotMF[lev], make_alias, mf_comp, 1);
244#pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
246 for (MFIter mfi(dmf, TilingIfNotGPU()); mfi.isValid(); ++mfi)
248 const Box& bx = mfi.tilebox();
249 auto& dfab = dmf[mfi];
251 if (der_name ==
"vorticity") {
252 auto const& sfab = mf_cc_vel[lev][mfi];
253 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);
255 auto const& sfab = (*
cons_new[lev])[mfi];
256 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);
268 Real dx = Geom()[lev].CellSizeArray()[0];
269 Real dy = Geom()[lev].CellSizeArray()[1];
276 MultiFab dmf(plotMF[lev], make_alias, mf_comp, AMREX_SPACEDIM);
278#pragma omp parallel if (Gpu::notInLaunchRegion())
280 for (MFIter mfi(dmf, TilingIfNotGPU()); mfi.isValid(); ++mfi) {
281 const Box& bx = mfi.tilebox();
282 const Array4<Real> loc_arr = dmf.array(mfi);
283 const Array4<Real const> zp_arr =
vec_z_phys_nd[lev]->const_array(mfi);
285 ParallelFor(bx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) {
286 loc_arr(i,j,k,0) = (i+0.5_rt) * dx;
287 loc_arr(i,j,k,1) = (j+0.5_rt) * dy;
288 loc_arr(i,j,k,2) = 0.125_rt * (zp_arr(i,j ,k ) + zp_arr(i+1,j ,k ) +
289 zp_arr(i,j+1,k ) + zp_arr(i+1,j+1,k ) +
290 zp_arr(i,j ,k+1) + zp_arr(i+1,j ,k+1) +
291 zp_arr(i,j+1,k+1) + zp_arr(i+1,j+1,k+1) );
294 mf_comp += AMREX_SPACEDIM;
297#ifdef REMORA_USE_PARTICLES
298 const auto& particles_namelist( particleData.getNames() );
299 for (ParticlesNamesVector::size_type i = 0; i < particles_namelist.size(); i++) {
302 MultiFab temp_dat(plotMF[lev].boxArray(), plotMF[lev].DistributionMap(), 1, 0);
304 particleData[particles_namelist[i]]->Increment(temp_dat, lev);
305 MultiFab::Copy(plotMF[lev], temp_dat, 0, mf_comp, 1, 0);
310 Vector<std::string> particle_mesh_plot_names(0);
311 particleData.GetMeshPlotVarNames( particle_mesh_plot_names );
312 for (
int i = 0; i < particle_mesh_plot_names.size(); i++) {
313 std::string plot_var_name(particle_mesh_plot_names[i]);
315 MultiFab temp_dat(plotMF[lev].boxArray(), plotMF[lev].DistributionMap(), 1, 1);
317 particleData.GetMeshPlotVar(plot_var_name, temp_dat, lev);
318 MultiFab::Copy(plotMF[lev], temp_dat, 0, mf_comp, 1, 0);
325 Real dz = Geom()[lev].CellSizeArray()[2];
326 int N = Geom()[lev].Domain().size()[2];
329#pragma omp parallel if (Gpu::notInLaunchRegion())
331 for (MFIter mfi(mf_nd[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi)
333 const Box& bx = mfi.tilebox();
334 Array4<Real> mf_arr = mf_nd[lev].array(mfi);
335 ParallelFor(bx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) {
336 mf_arr(i,j,k,2) = mf_arr(i,j,k,2) + (N-k) * dz;
348 if (finest_level == 0)
351 amrex::Print() <<
"Writing plotfile " << plotfilename <<
"\n";
353 GetVecOfConstPtrs(plotMF),
354 GetVecOfConstPtrs(mf_nd),
355 GetVecOfConstPtrs(mf_u),
356 GetVecOfConstPtrs(mf_v),
357 GetVecOfConstPtrs(mf_w),
358 GetVecOfConstPtrs(mf_2d_rho),
359 GetVecOfConstPtrs(mf_2d_u),
360 GetVecOfConstPtrs(mf_2d_v),
361 varnames_3d, varnames_2d_rho,
362 varnames_2d_u, varnames_2d_v,
367#ifdef REMORA_USE_PARTICLES
368 particleData.Checkpoint(plotfilename);
371#ifdef REMORA_USE_HDF5
373 amrex::Print() <<
"Writing plotfile " << plotfilename+
"d01.h5" <<
"\n";
374 WriteMultiLevelPlotfileHDF5(plotfilename, finest_level+1,
375 GetVecOfConstPtrs(plotMF),
383 amrex::Print() <<
"Writing plotfile " << plotfilename <<
"\n";
385 [[maybe_unused]]
int desired_ratio = std::max(std::max(ref_ratio[lev0][0],ref_ratio[lev0][1]),ref_ratio[lev0][2]);
386 bool any_ratio_one = ( ( (ref_ratio[lev0][0] == 1) || (ref_ratio[lev0][1] == 1) ) ||
387 (ref_ratio[lev0][2] == 1) );
388 for (
int lev = 1; lev < finest_level; lev++) {
389 any_ratio_one = any_ratio_one ||
390 ( ( (ref_ratio[lev][0] == 1) || (ref_ratio[lev][1] == 1) ) ||
391 (ref_ratio[lev][2] == 1) );
394 Vector<IntVect> r2(finest_level);
395 Vector<Geometry> g2(finest_level+1);
396 Vector<MultiFab> mf2(finest_level+1);
398 mf2[0].define(grids[0], dmap[0], ncomp_mf_3d, 0);
401 MultiFab::Copy(mf2[0],plotMF[0],0,0,plotMF[0].nComp(),0);
404 Array<int,AMREX_SPACEDIM> periodicity =
405 {Geom()[0].isPeriodic(0),Geom()[0].isPeriodic(1),Geom()[0].isPeriodic(2)};
406 g2[0].define(Geom()[0].Domain(),&(Geom()[0].ProbDomain()),0,periodicity.data());
408 r2[0] = IntVect(1,1,ref_ratio[0][0]);
409 for (
int lev = 1; lev <= finest_level; ++lev) {
413 r2[lev-1][2] = r2[lev-2][2] * ref_ratio[lev-1][0];
416 mf2[lev].define(refine(grids[lev],r2[lev-1]), dmap[lev], ncomp_mf_3d, 0);
419 Box d2(Geom()[lev].Domain());
420 d2.refine(r2[lev-1]);
422 g2[lev].define(d2,&(Geom()[lev].ProbDomain()),0,periodicity.data());
427 amrex::Vector<amrex::BCRec> null_dom_bcs;
428 null_dom_bcs.resize(mf2[0].nComp());
429 for (
int n = 0; n < mf2[0].nComp(); n++) {
430 for (
int dir = 0; dir < AMREX_SPACEDIM; dir++) {
437 for (
int lev = 1; lev <= finest_level; ++lev) {
438 Interpolater* mapper_c = &pc_interp;
439 InterpFromCoarseLevel(mf2[lev],
t_new[lev], plotMF[lev],
440 0, 0, mf2[lev].nComp(),
443 r2[lev-1], mapper_c, null_dom_bcs, 0);
447 Vector<IntVect> rr(finest_level);
448 for (
int lev = 0; lev < finest_level; ++lev) {
449 rr[lev] = IntVect(ref_ratio[lev][0],ref_ratio[lev][1],ref_ratio[lev][0]);
453 GetVecOfConstPtrs(mf2),
454 GetVecOfConstPtrs(mf_nd),
455 GetVecOfConstPtrs(mf_u),
456 GetVecOfConstPtrs(mf_v),
457 GetVecOfConstPtrs(mf_w),
458 GetVecOfConstPtrs(mf_2d_rho),
459 GetVecOfConstPtrs(mf_2d_u),
460 GetVecOfConstPtrs(mf_2d_v),
461 varnames_3d, varnames_2d_rho,
462 varnames_2d_u, varnames_2d_v,
467#ifdef REMORA_USE_PARTICLES
468 particleData.Checkpoint(plotfilename);
472 GetVecOfConstPtrs(plotMF),
473 GetVecOfConstPtrs(mf_nd),
474 GetVecOfConstPtrs(mf_u),
475 GetVecOfConstPtrs(mf_v),
476 GetVecOfConstPtrs(mf_w),
477 GetVecOfConstPtrs(mf_2d_rho),
478 GetVecOfConstPtrs(mf_2d_u),
479 GetVecOfConstPtrs(mf_2d_v),
480 varnames_3d, varnames_2d_rho,
481 varnames_2d_u, varnames_2d_v,
485#ifdef REMORA_USE_PARTICLES
486 particleData.Checkpoint(plotfilename);
491 for (
int lev = 0; lev <= finest_level; ++lev) {
496#ifdef REMORA_USE_NETCDF
500 AMREX_ASSERT(finest_level == 0);
502 plotMF[0].FillBoundary(geom[lev].periodicity());
528 const Vector<const MultiFab*>& mf,
529 const Vector<const MultiFab*>& mf_nd,
530 const Vector<const MultiFab*>& mf_u,
531 const Vector<const MultiFab*>& mf_v,
532 const Vector<const MultiFab*>& mf_w,
533 const Vector<const MultiFab*>& mf_2d_rho,
534 const Vector<const MultiFab*>& mf_2d_u,
535 const Vector<const MultiFab*>& mf_2d_v,
536 const Vector<std::string>& varnames_3d,
537 const Vector<std::string>& varnames_2d_rho,
538 const Vector<std::string>& varnames_2d_u,
539 const Vector<std::string>& varnames_2d_v,
540 const Vector<Geometry>& my_geom,
542 const Vector<int>& level_steps,
543 const Vector<IntVect>& rr,
544 const std::string &versionName,
545 const std::string &levelPrefix,
546 const std::string &mfPrefix,
547 const Vector<std::string>& extra_dirs)
const
549 BL_PROFILE(
"WriteMultiLevelPlotfileWithBathymetry()");
551 AMREX_ASSERT(nlevels <= mf.size());
552 AMREX_ASSERT(nlevels <= ref_ratio.size()+1);
553 AMREX_ASSERT(nlevels <= level_steps.size());
555 AMREX_ASSERT(mf[0]->nComp() == varnames_3d.size());
557 bool callBarrier(
false);
558 PreBuildDirectorHierarchy(plotfilename, levelPrefix, nlevels, callBarrier);
559 if (!extra_dirs.empty()) {
560 for (
const auto& d : extra_dirs) {
561 const std::string ed = plotfilename+
"/"+d;
562 PreBuildDirectorHierarchy(ed, levelPrefix, nlevels, callBarrier);
565 ParallelDescriptor::Barrier();
567 if (ParallelDescriptor::MyProc() == ParallelDescriptor::NProcs()-1) {
568 Vector<BoxArray> boxArrays(nlevels);
569 for(
int level(0); level < boxArrays.size(); ++level) {
570 boxArrays[level] = mf[level]->boxArray();
574 VisMF::IO_Buffer io_buffer(VisMF::IO_Buffer_Size);
575 std::string HeaderFileName(plotfilename +
"/Header");
576 std::ofstream HeaderFile;
577 HeaderFile.rdbuf()->pubsetbuf(io_buffer.dataPtr(), io_buffer.size());
578 HeaderFile.open(HeaderFileName.c_str(), std::ofstream::out |
579 std::ofstream::trunc |
580 std::ofstream::binary);
581 if( ! HeaderFile.good()) FileOpenFailed(HeaderFileName);
583 varnames_2d_rho, varnames_2d_u, varnames_2d_v,
584 my_geom, time, level_steps, rr, versionName,
585 levelPrefix, mfPrefix);
588 if (AsyncOut::UseAsyncOut()) {
589 AsyncOut::Submit(std::move(f));
595 std::string mf_nodal_prefix =
"Nu_nd";
596 std::string mf_uface_prefix =
"UFace";
597 std::string mf_vface_prefix =
"VFace";
598 std::string mf_wface_prefix =
"WFace";
599 std::string mf_2d_rho_prefix =
"rho2d";
600 std::string mf_2d_u_prefix =
"u2d";
601 std::string mf_2d_v_prefix =
"v2d";
603 for (
int level = 0; level <= finest_level; ++level)
605 if (AsyncOut::UseAsyncOut()) {
606 VisMF::AsyncWrite(*mf[level],
607 MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mfPrefix),
609 VisMF::AsyncWrite(*mf_nd[level],
610 MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_nodal_prefix),
613 VisMF::AsyncWrite(*mf_u[level],
614 MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_uface_prefix),
616 VisMF::AsyncWrite(*mf_v[level],
617 MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_vface_prefix),
619 VisMF::AsyncWrite(*mf_w[level],
620 MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_wface_prefix),
623 if (mf_2d_rho[level]->nComp() > 0) {
624 VisMF::AsyncWrite(*mf_2d_rho[level],
625 MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_2d_rho_prefix),
628 if (mf_2d_u[level]->nComp() > 0) {
629 VisMF::AsyncWrite(*mf_2d_u[level],
630 MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_2d_u_prefix),
633 if (mf_2d_v[level]->nComp() > 0) {
634 VisMF::AsyncWrite(*mf_2d_v[level],
635 MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_2d_v_prefix),
639 const MultiFab* data;
640 std::unique_ptr<MultiFab> mf_tmp;
641 if (mf[level]->nGrowVect() != 0) {
642 mf_tmp = std::make_unique<MultiFab>(mf[level]->boxArray(),
643 mf[level]->DistributionMap(),
644 mf[level]->nComp(), 0, MFInfo(),
645 mf[level]->Factory());
646 MultiFab::Copy(*mf_tmp, *mf[level], 0, 0, mf[level]->nComp(), 0);
651 VisMF::Write(*data , MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mfPrefix));
652 VisMF::Write(*mf_nd[level], MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_nodal_prefix));
654 VisMF::Write(*mf_u[level], MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_uface_prefix));
655 VisMF::Write(*mf_v[level], MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_vface_prefix));
656 VisMF::Write(*mf_w[level], MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_wface_prefix));
658 if (mf_2d_rho[level]->nComp() > 0) {
659 VisMF::Write(*mf_2d_rho[level], MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_2d_rho_prefix));
661 if (mf_2d_u[level]->nComp() > 0) {
662 VisMF::Write(*mf_2d_u[level], MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_2d_u_prefix));
664 if (mf_2d_v[level]->nComp() > 0) {
665 VisMF::Write(*mf_2d_v[level], MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_2d_v_prefix));
687 [[maybe_unused]]
int nlevels,
688 const Vector<BoxArray> &bArray,
689 const Vector<std::string> &varnames_3d,
690 const Vector<std::string> &varnames_2d_rho,
691 const Vector<std::string> &varnames_2d_u,
692 const Vector<std::string> &varnames_2d_v,
693 const Vector<Geometry>& my_geom,
695 const Vector<int> &level_steps,
696 const Vector<IntVect>& my_ref_ratio,
697 const std::string &versionName,
698 const std::string &levelPrefix,
699 const std::string &mfPrefix)
const
701 AMREX_ASSERT(nlevels <= bArray.size());
702 AMREX_ASSERT(nlevels <= ref_ratio.size()+1);
703 AMREX_ASSERT(nlevels <= level_steps.size());
705 int num_extra_mfs = 1;
710 HeaderFile.precision(17);
713 HeaderFile << versionName <<
'\n';
715 HeaderFile << varnames_3d.size() <<
'\n';
717 for (
int ivar = 0; ivar < varnames_3d.size(); ++ivar) {
718 HeaderFile << varnames_3d[ivar] <<
"\n";
720 HeaderFile << AMREX_SPACEDIM <<
'\n';
721 HeaderFile << time <<
'\n';
722 HeaderFile << finest_level <<
'\n';
723 for (
int i = 0; i < AMREX_SPACEDIM; ++i) {
724 HeaderFile << my_geom[0].ProbLo(i) <<
' ';
727 for (
int i = 0; i < AMREX_SPACEDIM; ++i) {
728 HeaderFile << my_geom[0].ProbHi(i) <<
' ';
731 for (
int i = 0; i < finest_level; ++i) {
732 HeaderFile << my_ref_ratio[i][0] <<
' ';
735 for (
int i = 0; i <= finest_level; ++i) {
736 HeaderFile << my_geom[i].Domain() <<
' ';
739 for (
int i = 0; i <= finest_level; ++i) {
740 HeaderFile << level_steps[i] <<
' ';
743 for (
int i = 0; i <= finest_level; ++i) {
744 for (
int k = 0; k < AMREX_SPACEDIM; ++k) {
745 HeaderFile << my_geom[i].CellSize()[k] <<
' ';
749 HeaderFile << (int) my_geom[0].
Coord() <<
'\n';
752 for (
int level = 0; level <= finest_level; ++level) {
753 HeaderFile << level <<
' ' << bArray[level].size() <<
' ' << time <<
'\n';
754 HeaderFile << level_steps[level] <<
'\n';
756 const IntVect& domain_lo = my_geom[level].Domain().smallEnd();
757 for (
int i = 0; i < bArray[level].size(); ++i)
762 const Box& b = shift(bArray[level][i], -domain_lo);
763 RealBox loc = RealBox(b, my_geom[level].CellSize(), my_geom[level].ProbLo());
764 for (
int n = 0; n < AMREX_SPACEDIM; ++n) {
765 HeaderFile << loc.lo(n) <<
' ' << loc.hi(n) <<
'\n';
769 HeaderFile << MultiFabHeaderPath(level, levelPrefix, mfPrefix) <<
'\n';
771 HeaderFile << num_extra_mfs <<
"\n";
772 HeaderFile <<
"3" <<
"\n";
773 HeaderFile <<
"amrexvec_nu_x" <<
"\n";
774 HeaderFile <<
"amrexvec_nu_y" <<
"\n";
775 HeaderFile <<
"amrexvec_nu_z" <<
"\n";
776 std::string mf_nodal_prefix =
"Nu_nd";
777 for (
int level = 0; level <= finest_level; ++level) {
778 HeaderFile << MultiFabHeaderPath(level, levelPrefix, mf_nodal_prefix) <<
'\n';
781 HeaderFile <<
"1" <<
"\n";
782 HeaderFile <<
"u_vel" <<
"\n";
783 std::string mf_uface_prefix =
"UFace";
784 for (
int level = 0; level <= finest_level; ++level) {
785 HeaderFile << MultiFabHeaderPath(level, levelPrefix, mf_uface_prefix) <<
'\n';
787 HeaderFile <<
"1" <<
"\n";
788 HeaderFile <<
"v_vel" <<
"\n";
789 std::string mf_vface_prefix =
"VFace";
790 for (
int level = 0; level <= finest_level; ++level) {
791 HeaderFile << MultiFabHeaderPath(level, levelPrefix, mf_vface_prefix) <<
'\n';
793 HeaderFile <<
"1" <<
"\n";
794 HeaderFile <<
"w_vel" <<
"\n";
795 std::string mf_wface_prefix =
"WFace";
796 for (
int level = 0; level <= finest_level; ++level) {
797 HeaderFile << MultiFabHeaderPath(level, levelPrefix, mf_wface_prefix) <<
'\n';
801 if (varnames_2d_rho.size() > 0) {
802 HeaderFile << varnames_2d_rho.size() <<
"\n";
803 for (
int ivar = 0; ivar < varnames_2d_rho.size(); ++ivar) {
804 HeaderFile << varnames_2d_rho[ivar] <<
"\n";
806 std::string mf_2d_rho_prefix =
"rho2d";
807 for (
int level = 0; level <= finest_level; ++level) {
808 HeaderFile << MultiFabHeaderPath(level, levelPrefix, mf_2d_rho_prefix) <<
"\n";
812 if (varnames_2d_u.size() > 0) {
813 HeaderFile << varnames_2d_u.size() <<
"\n";
814 for (
int ivar = 0; ivar < varnames_2d_u.size(); ++ivar) {
815 HeaderFile << varnames_2d_u[ivar] <<
"\n";
817 std::string mf_2d_u_prefix =
"u2d";
818 for (
int level = 0; level <= finest_level; ++level) {
819 HeaderFile << MultiFabHeaderPath(level, levelPrefix, mf_2d_u_prefix) <<
"\n";
823 if (varnames_2d_v.size() > 0) {
824 HeaderFile << varnames_2d_v.size() <<
"\n";
825 for (
int ivar = 0; ivar < varnames_2d_v.size(); ++ivar) {
826 HeaderFile << varnames_2d_v[ivar] <<
"\n";
828 std::string mf_2d_v_prefix =
"v2d";
829 for (
int level = 0; level <= finest_level; ++level) {
830 HeaderFile << MultiFabHeaderPath(level, levelPrefix, mf_2d_v_prefix) <<
"\n";