18 Vector<std::string> varnames_3d;
21 Vector<std::string> varnames_2d;
24 Vector<std::string> varnames_2d_rho;
25 Vector<std::string> varnames_2d_u;
26 Vector<std::string> varnames_2d_v;
28 const int ncomp_mf_3d = varnames_3d.size();
29 const auto ngrow_vars = IntVect(
NGROW-1,
NGROW-1,0);
32 int ncomp_mf_2d_rho = 0;
33 int ncomp_mf_2d_u = 0;
34 int ncomp_mf_2d_v = 0;
37 for (
auto plot_name : varnames_2d) {
39 if (plot_name ==
"zeta" ) {varnames_2d_rho.push_back(plot_name); ncomp_mf_2d_rho++;}
40 if (plot_name ==
"h" ) {varnames_2d_rho.push_back(plot_name); ncomp_mf_2d_rho++;}
41 if (plot_name ==
"ubar" ) {varnames_2d_u.push_back(plot_name); ncomp_mf_2d_u++;}
42 if (plot_name ==
"sustr") {varnames_2d_u.push_back(plot_name); ncomp_mf_2d_u++;}
43 if (plot_name ==
"bustr") {varnames_2d_u.push_back(plot_name); ncomp_mf_2d_u++;}
44 if (plot_name ==
"vbar" ) {varnames_2d_v.push_back(plot_name); ncomp_mf_2d_v++;}
45 if (plot_name ==
"svstr") {varnames_2d_v.push_back(plot_name); ncomp_mf_2d_v++;}
46 if (plot_name ==
"bvstr") {varnames_2d_v.push_back(plot_name); ncomp_mf_2d_v++;}
52 for (
int lev = 0; lev <= finest_level; ++lev) {
59 Real fill_value = 0.0_rt;
60 for (
int lev = 0; lev <= finest_level; ++lev) {
65 Vector<MultiFab> mf(finest_level+1);
66 for (
int lev = 0; lev <= finest_level; ++lev) {
67 mf[lev].define(grids[lev], dmap[lev], ncomp_mf_3d, ngrow_vars);
71 Vector<MultiFab> mf_2d_rho(finest_level+1);
72 Vector<MultiFab> mf_2d_u(finest_level+1);
73 Vector<MultiFab> mf_2d_v(finest_level+1);
74 for (
int lev = 0; lev <= finest_level; ++lev) {
75 BoxArray ba(grids[lev]);
76 BoxList bl2d = ba.boxList();
77 for (
auto& b : bl2d) {
80 BoxArray ba2d(std::move(bl2d));
81 mf_2d_rho[lev].define(ba2d, dmap[lev], ncomp_mf_2d_rho, ngrow_vars);
82 mf_2d_u[lev].define(ba2d, dmap[lev], ncomp_mf_2d_u , ngrow_vars);
83 mf_2d_v[lev].define(ba2d, dmap[lev], ncomp_mf_2d_v , ngrow_vars);
87 Vector<MultiFab> mf_nd(finest_level+1);
88 for (
int lev = 0; lev <= finest_level; ++lev) {
89 BoxArray nodal_grids(grids[lev]); nodal_grids.surroundingNodes();
90 mf_nd[lev].define(nodal_grids, dmap[lev], AMREX_SPACEDIM, 0);
91 mf_nd[lev].setVal(0.);
95 Vector<MultiFab> mf_u(finest_level+1);
96 Vector<MultiFab> mf_v(finest_level+1);
97 Vector<MultiFab> mf_w(finest_level+1);
99 for (
int lev = 0; lev <= finest_level; ++lev) {
100 BoxArray grid_stag_u(grids[lev]); grid_stag_u.surroundingNodes(0);
101 BoxArray grid_stag_v(grids[lev]); grid_stag_v.surroundingNodes(1);
102 BoxArray grid_stag_w(grids[lev]); grid_stag_w.surroundingNodes(2);
103 mf_u[lev].define(grid_stag_u, dmap[lev], 1, 0);
104 mf_v[lev].define(grid_stag_v, dmap[lev], 1, 0);
105 mf_w[lev].define(grid_stag_w, dmap[lev], 1, 0);
106 MultiFab::Copy(mf_u[lev],*
xvel_new[lev],0,0,1,0);
107 MultiFab::Copy(mf_v[lev],*
yvel_new[lev],0,0,1,0);
108 MultiFab::Copy(mf_w[lev],*
zvel_new[lev],0,0,1,0);
113 Vector<MultiFab> mf_cc_vel(finest_level+1);
120 for (
int lev = 0; lev <= finest_level; ++lev) {
121 mf_cc_vel[lev].define(grids[lev], dmap[lev], AMREX_SPACEDIM, IntVect(1,1,0));
122 mf_cc_vel[lev].setVal(0.0_rt);
123 average_face_to_cellcenter(mf_cc_vel[lev],0,
125 mf_cc_vel[lev].FillBoundary(geom[lev].periodicity());
129 amrex::Interpolater* mapper = &cell_cons_interp;
131 for (
int lev = 1; lev <= finest_level; ++lev) {
132 Vector<MultiFab*> fmf = {&(mf_cc_vel[lev]), &(mf_cc_vel[lev])};
133 Vector<Real> ftime = {
t_new[lev],
t_new[lev]};
134 Vector<MultiFab*> cmf = {&mf_cc_vel[lev-1], &mf_cc_vel[lev-1]};
135 Vector<Real> ctime = {
t_new[lev],
t_new[lev]};
138 amrex::FillPatchTwoLevels(mf_cc_vel[lev], mf_cc_vel[lev].nGrowVect(), IntVect(0,0,0),
139 t_new[lev], cmf, ctime, fmf, ftime,
140 0, 0, mf_cc_vel[lev].nComp(), geom[lev-1], geom[lev],
147 for (
auto plot_name : varnames_2d_rho)
149 if (plot_name ==
"zeta" ) {
150 for (
int lev = 0; lev <= finest_level; ++lev) { MultiFab::Copy(mf_2d_rho[lev],*
vec_Zt_avg1[lev],0,icomp_rho,1,0); icomp_rho++;}
152 if (plot_name ==
"h" ) {
153 for (
int lev = 0; lev <= finest_level; ++lev) { MultiFab::Copy(mf_2d_rho[lev],*
vec_h[lev],0,icomp_rho,1,0); icomp_rho++;}
158 for (
auto plot_name : varnames_2d_u)
160 if (plot_name ==
"ubar" ) {
161 for (
int lev = 0; lev <= finest_level; ++lev) { MultiFab::Copy(mf_2d_u[lev],*
vec_DU_avg1[lev],0,icomp_u,1,0); icomp_u++;}
163 if (plot_name ==
"sustr" ) {
164 for (
int lev = 0; lev <= finest_level; ++lev) { MultiFab::Copy(mf_2d_u[lev],*
vec_sustr[lev],0,icomp_u,1,0); icomp_u++;}
166 if (plot_name ==
"bustr" ) {
167 for (
int lev = 0; lev <= finest_level; ++lev) { MultiFab::Copy(mf_2d_u[lev],*
vec_bustr[lev],0,icomp_u,1,0); icomp_u++;}
172 for (
auto plot_name : varnames_2d_v)
174 if (plot_name ==
"vbar" ) {
175 for (
int lev = 0; lev <= finest_level; ++lev) { MultiFab::Copy(mf_2d_v[lev],*
vec_DV_avg1[lev],0,icomp_v,1,0); icomp_v++;}
177 if (plot_name ==
"svstr" ) {
178 for (
int lev = 0; lev <= finest_level; ++lev) { MultiFab::Copy(mf_2d_v[lev],*
vec_svstr[lev],0,icomp_v,1,0); icomp_v++;}
180 if (plot_name ==
"bvstr" ) {
181 for (
int lev = 0; lev <= finest_level; ++lev) { MultiFab::Copy(mf_2d_v[lev],*
vec_bvstr[lev],0,icomp_v,1,0); icomp_v++;}
185 for (
int lev = 0; lev <= finest_level; ++lev)
191 for (
int i = 0; i <
NCONS; ++i) {
194 amrex::Abort(
"Found while writing output: Cons (salt, temp, or scalar, etc) contains nan or inf");
196 MultiFab::Copy(mf[lev],*
cons_new[lev],i,mf_comp,1,ngrow_vars);
203 if (mf_cc_vel[lev].contains_nan(0,1) || mf_cc_vel[lev].contains_inf(0,1)) {
204 amrex::Abort(
"Found while writing output: u velocity contains nan or inf");
206 MultiFab::Copy(mf[lev], mf_cc_vel[lev], 0, mf_comp, 1, 0);
210 if (mf_cc_vel[lev].contains_nan(1,1) || mf_cc_vel[lev].contains_inf(1,1)) {
211 amrex::Abort(
"Found while writing output: v velocity contains nan or inf");
213 MultiFab::Copy(mf[lev], mf_cc_vel[lev], 1, mf_comp, 1, 0);
217 if (mf_cc_vel[lev].contains_nan(2,1) || mf_cc_vel[lev].contains_inf(2,1)) {
218 amrex::Abort(
"Found while writing output: z velocity contains nan or inf");
220 MultiFab::Copy(mf[lev], mf_cc_vel[lev], 2, mf_comp, 1, 0);
225 auto calculate_derived = [&](
const std::string& der_name,
229 MultiFab dmf(mf[lev], make_alias, mf_comp, 1);
231#pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
233 for (MFIter mfi(dmf, TilingIfNotGPU()); mfi.isValid(); ++mfi)
235 const Box& bx = mfi.tilebox();
236 auto& dfab = dmf[mfi];
238 if (der_name ==
"vorticity") {
239 auto const& sfab = mf_cc_vel[lev][mfi];
240 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);
242 auto const& sfab = (*
cons_new[lev])[mfi];
243 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 Real dx = Geom()[lev].CellSizeArray()[0];
256 Real dy = Geom()[lev].CellSizeArray()[1];
263 MultiFab dmf(mf[lev], make_alias, mf_comp, AMREX_SPACEDIM);
265#pragma omp parallel if (Gpu::notInLaunchRegion())
267 for (MFIter mfi(dmf, TilingIfNotGPU()); mfi.isValid(); ++mfi) {
268 const Box& bx = mfi.tilebox();
269 const Array4<Real> loc_arr = dmf.array(mfi);
270 const Array4<Real const> zp_arr =
vec_z_phys_nd[lev]->const_array(mfi);
272 ParallelFor(bx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) {
273 loc_arr(i,j,k,0) = (i+0.5_rt) * dx;
274 loc_arr(i,j,k,1) = (j+0.5_rt) * dy;
275 loc_arr(i,j,k,2) = 0.125_rt * (zp_arr(i,j ,k ) + zp_arr(i+1,j ,k ) +
276 zp_arr(i,j+1,k ) + zp_arr(i+1,j+1,k ) +
277 zp_arr(i,j ,k+1) + zp_arr(i+1,j ,k+1) +
278 zp_arr(i,j+1,k+1) + zp_arr(i+1,j+1,k+1) );
281 mf_comp += AMREX_SPACEDIM;
284#ifdef REMORA_USE_PARTICLES
285 const auto& particles_namelist( particleData.getNames() );
286 for (ParticlesNamesVector::size_type i = 0; i < particles_namelist.size(); i++) {
288 MultiFab temp_dat(mf[lev].boxArray(), mf[lev].DistributionMap(), 1, 0);
290 particleData[particles_namelist[i]]->Increment(temp_dat, lev);
291 MultiFab::Copy(mf[lev], temp_dat, 0, mf_comp, 1, 0);
296 Vector<std::string> particle_mesh_plot_names(0);
297 particleData.GetMeshPlotVarNames( particle_mesh_plot_names );
298 for (
int i = 0; i < particle_mesh_plot_names.size(); i++) {
299 std::string plot_var_name(particle_mesh_plot_names[i]);
301 MultiFab temp_dat(mf[lev].boxArray(), mf[lev].DistributionMap(), 1, 1);
303 particleData.GetMeshPlotVar(plot_var_name, temp_dat, lev);
304 MultiFab::Copy(mf[lev], temp_dat, 0, mf_comp, 1, 0);
311 Real dz = Geom()[lev].CellSizeArray()[2];
312 int N = Geom()[lev].Domain().size()[2];
315#pragma omp parallel if (Gpu::notInLaunchRegion())
317 for (MFIter mfi(mf_nd[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi)
319 const Box& bx = mfi.tilebox();
320 Array4<Real> mf_arr = mf_nd[lev].array(mfi);
321 ParallelFor(bx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) {
322 mf_arr(i,j,k,2) = mf_arr(i,j,k,2) + (N-k) * dz;
330 if (finest_level == 0)
333 amrex::Print() <<
"Writing plotfile " << plotfilename <<
"\n";
335 GetVecOfConstPtrs(mf),
336 GetVecOfConstPtrs(mf_nd),
337 GetVecOfConstPtrs(mf_u),
338 GetVecOfConstPtrs(mf_v),
339 GetVecOfConstPtrs(mf_w),
340 GetVecOfConstPtrs(mf_2d_rho),
341 GetVecOfConstPtrs(mf_2d_u),
342 GetVecOfConstPtrs(mf_2d_v),
343 varnames_3d, varnames_2d_rho,
344 varnames_2d_u, varnames_2d_v,
349#ifdef REMORA_USE_PARTICLES
350 particleData.Checkpoint(plotfilename);
353#ifdef REMORA_USE_HDF5
355 amrex::Print() <<
"Writing plotfile " << plotfilename+
"d01.h5" <<
"\n";
356 WriteMultiLevelPlotfileHDF5(plotfilename, finest_level+1,
357 GetVecOfConstPtrs(mf),
362 amrex::Abort(
"User specified unknown plot_filetype");
367 amrex::Print() <<
"Writing plotfile " << plotfilename <<
"\n";
369 [[maybe_unused]]
int desired_ratio = std::max(std::max(ref_ratio[lev0][0],ref_ratio[lev0][1]),ref_ratio[lev0][2]);
370 bool any_ratio_one = ( ( (ref_ratio[lev0][0] == 1) || (ref_ratio[lev0][1] == 1) ) ||
371 (ref_ratio[lev0][2] == 1) );
372 for (
int lev = 1; lev < finest_level; lev++) {
373 any_ratio_one = any_ratio_one ||
374 ( ( (ref_ratio[lev][0] == 1) || (ref_ratio[lev][1] == 1) ) ||
375 (ref_ratio[lev][2] == 1) );
378 Vector<IntVect> r2(finest_level);
379 Vector<Geometry> g2(finest_level+1);
380 Vector<MultiFab> mf2(finest_level+1);
382 mf2[0].define(grids[0], dmap[0], ncomp_mf_3d, 0);
385 MultiFab::Copy(mf2[0],mf[0],0,0,mf[0].nComp(),0);
388 Array<int,AMREX_SPACEDIM> periodicity =
389 {Geom()[0].isPeriodic(0),Geom()[0].isPeriodic(1),Geom()[0].isPeriodic(2)};
390 g2[0].define(Geom()[0].Domain(),&(Geom()[0].ProbDomain()),0,periodicity.data());
392 r2[0] = IntVect(1,1,ref_ratio[0][0]);
393 for (
int lev = 1; lev <= finest_level; ++lev) {
397 r2[lev-1][2] = r2[lev-2][2] * ref_ratio[lev-1][0];
400 mf2[lev].define(refine(grids[lev],r2[lev-1]), dmap[lev], ncomp_mf_3d, 0);
403 Box d2(Geom()[lev].Domain());
404 d2.refine(r2[lev-1]);
406 g2[lev].define(d2,&(Geom()[lev].ProbDomain()),0,periodicity.data());
411 amrex::Vector<amrex::BCRec> null_dom_bcs;
412 null_dom_bcs.resize(mf2[0].nComp());
413 for (
int n = 0; n < mf2[0].nComp(); n++) {
414 for (
int dir = 0; dir < AMREX_SPACEDIM; dir++) {
421 for (
int lev = 1; lev <= finest_level; ++lev) {
422 Interpolater* mapper_c = &pc_interp;
423 InterpFromCoarseLevel(mf2[lev],
t_new[lev], mf[lev],
424 0, 0, mf2[lev].nComp(),
427 r2[lev-1], mapper_c, null_dom_bcs, 0);
431 Vector<IntVect> rr(finest_level);
432 for (
int lev = 0; lev < finest_level; ++lev) {
433 rr[lev] = IntVect(ref_ratio[lev][0],ref_ratio[lev][1],ref_ratio[lev][0]);
437 GetVecOfConstPtrs(mf2),
438 GetVecOfConstPtrs(mf_nd),
439 GetVecOfConstPtrs(mf_u),
440 GetVecOfConstPtrs(mf_v),
441 GetVecOfConstPtrs(mf_w),
442 GetVecOfConstPtrs(mf_2d_rho),
443 GetVecOfConstPtrs(mf_2d_u),
444 GetVecOfConstPtrs(mf_2d_v),
445 varnames_3d, varnames_2d_rho,
446 varnames_2d_u, varnames_2d_v,
451#ifdef REMORA_USE_PARTICLES
452 particleData.Checkpoint(plotfilename);
456 GetVecOfConstPtrs(mf),
457 GetVecOfConstPtrs(mf_nd),
458 GetVecOfConstPtrs(mf_u),
459 GetVecOfConstPtrs(mf_v),
460 GetVecOfConstPtrs(mf_w),
461 GetVecOfConstPtrs(mf_2d_rho),
462 GetVecOfConstPtrs(mf_2d_u),
463 GetVecOfConstPtrs(mf_2d_v),
464 varnames_3d, varnames_2d_rho,
465 varnames_2d_u, varnames_2d_v,
469#ifdef REMORA_USE_PARTICLES
470 particleData.Checkpoint(plotfilename);
475 for (
int lev = 0; lev <= finest_level; ++lev) {
500 const Vector<const MultiFab*>& mf,
501 const Vector<const MultiFab*>& mf_nd,
502 const Vector<const MultiFab*>& mf_u,
503 const Vector<const MultiFab*>& mf_v,
504 const Vector<const MultiFab*>& mf_w,
505 const Vector<const MultiFab*>& mf_2d_rho,
506 const Vector<const MultiFab*>& mf_2d_u,
507 const Vector<const MultiFab*>& mf_2d_v,
508 const Vector<std::string>& varnames_3d,
509 const Vector<std::string>& varnames_2d_rho,
510 const Vector<std::string>& varnames_2d_u,
511 const Vector<std::string>& varnames_2d_v,
512 const Vector<Geometry>& my_geom,
514 const Vector<int>& level_steps,
515 const Vector<IntVect>& rr,
516 const std::string &versionName,
517 const std::string &levelPrefix,
518 const std::string &mfPrefix,
519 const Vector<std::string>& extra_dirs)
const
521 BL_PROFILE(
"WriteMultiLevelPlotfileWithBathymetry()");
523 BL_ASSERT(nlevels <= mf.size());
524 BL_ASSERT(nlevels <= ref_ratio.size()+1);
525 BL_ASSERT(nlevels <= level_steps.size());
527 BL_ASSERT(mf[0]->nComp() == varnames_3d.size());
529 bool callBarrier(
false);
530 PreBuildDirectorHierarchy(plotfilename, levelPrefix, nlevels, callBarrier);
531 if (!extra_dirs.empty()) {
532 for (
const auto& d : extra_dirs) {
533 const std::string ed = plotfilename+
"/"+d;
534 PreBuildDirectorHierarchy(ed, levelPrefix, nlevels, callBarrier);
537 ParallelDescriptor::Barrier();
539 if (ParallelDescriptor::MyProc() == ParallelDescriptor::NProcs()-1) {
540 Vector<BoxArray> boxArrays(nlevels);
541 for(
int level(0); level < boxArrays.size(); ++level) {
542 boxArrays[level] = mf[level]->boxArray();
546 VisMF::IO_Buffer io_buffer(VisMF::IO_Buffer_Size);
547 std::string HeaderFileName(plotfilename +
"/Header");
548 std::ofstream HeaderFile;
549 HeaderFile.rdbuf()->pubsetbuf(io_buffer.dataPtr(), io_buffer.size());
550 HeaderFile.open(HeaderFileName.c_str(), std::ofstream::out |
551 std::ofstream::trunc |
552 std::ofstream::binary);
553 if( ! HeaderFile.good()) FileOpenFailed(HeaderFileName);
555 varnames_2d_rho, varnames_2d_u, varnames_2d_v,
556 my_geom, time, level_steps, rr, versionName,
557 levelPrefix, mfPrefix);
560 if (AsyncOut::UseAsyncOut()) {
561 AsyncOut::Submit(std::move(f));
567 std::string mf_nodal_prefix =
"Nu_nd";
568 std::string mf_uface_prefix =
"UFace";
569 std::string mf_vface_prefix =
"VFace";
570 std::string mf_wface_prefix =
"WFace";
571 std::string mf_2d_rho_prefix =
"rho2d";
572 std::string mf_2d_u_prefix =
"u2d";
573 std::string mf_2d_v_prefix =
"v2d";
575 for (
int level = 0; level <= finest_level; ++level)
577 if (AsyncOut::UseAsyncOut()) {
578 VisMF::AsyncWrite(*mf[level],
579 MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mfPrefix),
581 VisMF::AsyncWrite(*mf_nd[level],
582 MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_nodal_prefix),
585 VisMF::AsyncWrite(*mf_u[level],
586 MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_uface_prefix),
588 VisMF::AsyncWrite(*mf_v[level],
589 MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_vface_prefix),
591 VisMF::AsyncWrite(*mf_w[level],
592 MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_wface_prefix),
595 if (mf_2d_rho[level]->nComp() > 0) {
596 VisMF::AsyncWrite(*mf_2d_rho[level],
597 MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_2d_rho_prefix),
600 if (mf_2d_u[level]->nComp() > 0) {
601 VisMF::AsyncWrite(*mf_2d_u[level],
602 MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_2d_u_prefix),
605 if (mf_2d_v[level]->nComp() > 0) {
606 VisMF::AsyncWrite(*mf_2d_v[level],
607 MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_2d_v_prefix),
611 const MultiFab* data;
612 std::unique_ptr<MultiFab> mf_tmp;
613 if (mf[level]->nGrowVect() != 0) {
614 mf_tmp = std::make_unique<MultiFab>(mf[level]->boxArray(),
615 mf[level]->DistributionMap(),
616 mf[level]->nComp(), 0, MFInfo(),
617 mf[level]->Factory());
618 MultiFab::Copy(*mf_tmp, *mf[level], 0, 0, mf[level]->nComp(), 0);
623 VisMF::Write(*data , MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mfPrefix));
624 VisMF::Write(*mf_nd[level], MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_nodal_prefix));
626 VisMF::Write(*mf_u[level], MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_uface_prefix));
627 VisMF::Write(*mf_v[level], MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_vface_prefix));
628 VisMF::Write(*mf_w[level], MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_wface_prefix));
630 if (mf_2d_rho[level]->nComp() > 0) {
631 VisMF::Write(*mf_2d_rho[level], MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_2d_rho_prefix));
633 if (mf_2d_u[level]->nComp() > 0) {
634 VisMF::Write(*mf_2d_u[level], MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_2d_u_prefix));
636 if (mf_2d_v[level]->nComp() > 0) {
637 VisMF::Write(*mf_2d_v[level], MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_2d_v_prefix));
659 [[maybe_unused]]
int nlevels,
660 const Vector<BoxArray> &bArray,
661 const Vector<std::string> &varnames_3d,
662 const Vector<std::string> &varnames_2d_rho,
663 const Vector<std::string> &varnames_2d_u,
664 const Vector<std::string> &varnames_2d_v,
665 const Vector<Geometry>& my_geom,
667 const Vector<int> &level_steps,
668 const Vector<IntVect>& my_ref_ratio,
669 const std::string &versionName,
670 const std::string &levelPrefix,
671 const std::string &mfPrefix)
const
673 BL_ASSERT(nlevels <= bArray.size());
674 BL_ASSERT(nlevels <= ref_ratio.size()+1);
675 BL_ASSERT(nlevels <= level_steps.size());
677 int num_extra_mfs = 1;
682 HeaderFile.precision(17);
685 HeaderFile << versionName <<
'\n';
687 HeaderFile << varnames_3d.size() <<
'\n';
689 for (
int ivar = 0; ivar < varnames_3d.size(); ++ivar) {
690 HeaderFile << varnames_3d[ivar] <<
"\n";
692 HeaderFile << AMREX_SPACEDIM <<
'\n';
693 HeaderFile << time <<
'\n';
694 HeaderFile << finest_level <<
'\n';
695 for (
int i = 0; i < AMREX_SPACEDIM; ++i) {
696 HeaderFile << my_geom[0].ProbLo(i) <<
' ';
699 for (
int i = 0; i < AMREX_SPACEDIM; ++i) {
700 HeaderFile << my_geom[0].ProbHi(i) <<
' ';
703 for (
int i = 0; i < finest_level; ++i) {
704 HeaderFile << my_ref_ratio[i][0] <<
' ';
707 for (
int i = 0; i <= finest_level; ++i) {
708 HeaderFile << my_geom[i].Domain() <<
' ';
711 for (
int i = 0; i <= finest_level; ++i) {
712 HeaderFile << level_steps[i] <<
' ';
715 for (
int i = 0; i <= finest_level; ++i) {
716 for (
int k = 0; k < AMREX_SPACEDIM; ++k) {
717 HeaderFile << my_geom[i].CellSize()[k] <<
' ';
721 HeaderFile << (int) my_geom[0].
Coord() <<
'\n';
724 for (
int level = 0; level <= finest_level; ++level) {
725 HeaderFile << level <<
' ' << bArray[level].size() <<
' ' << time <<
'\n';
726 HeaderFile << level_steps[level] <<
'\n';
728 const IntVect& domain_lo = my_geom[level].Domain().smallEnd();
729 for (
int i = 0; i < bArray[level].size(); ++i)
734 const Box& b = shift(bArray[level][i], -domain_lo);
735 RealBox loc = RealBox(b, my_geom[level].CellSize(), my_geom[level].ProbLo());
736 for (
int n = 0; n < AMREX_SPACEDIM; ++n) {
737 HeaderFile << loc.lo(n) <<
' ' << loc.hi(n) <<
'\n';
741 HeaderFile << MultiFabHeaderPath(level, levelPrefix, mfPrefix) <<
'\n';
743 HeaderFile << num_extra_mfs <<
"\n";
744 HeaderFile <<
"3" <<
"\n";
745 HeaderFile <<
"amrexvec_nu_x" <<
"\n";
746 HeaderFile <<
"amrexvec_nu_y" <<
"\n";
747 HeaderFile <<
"amrexvec_nu_z" <<
"\n";
748 std::string mf_nodal_prefix =
"Nu_nd";
749 for (
int level = 0; level <= finest_level; ++level) {
750 HeaderFile << MultiFabHeaderPath(level, levelPrefix, mf_nodal_prefix) <<
'\n';
753 HeaderFile <<
"1" <<
"\n";
754 HeaderFile <<
"u_vel" <<
"\n";
755 std::string mf_uface_prefix =
"UFace";
756 for (
int level = 0; level <= finest_level; ++level) {
757 HeaderFile << MultiFabHeaderPath(level, levelPrefix, mf_uface_prefix) <<
'\n';
759 HeaderFile <<
"1" <<
"\n";
760 HeaderFile <<
"v_vel" <<
"\n";
761 std::string mf_vface_prefix =
"VFace";
762 for (
int level = 0; level <= finest_level; ++level) {
763 HeaderFile << MultiFabHeaderPath(level, levelPrefix, mf_vface_prefix) <<
'\n';
765 HeaderFile <<
"1" <<
"\n";
766 HeaderFile <<
"w_vel" <<
"\n";
767 std::string mf_wface_prefix =
"WFace";
768 for (
int level = 0; level <= finest_level; ++level) {
769 HeaderFile << MultiFabHeaderPath(level, levelPrefix, mf_wface_prefix) <<
'\n';
773 if (varnames_2d_rho.size() > 0) {
774 HeaderFile << varnames_2d_rho.size() <<
"\n";
775 for (
int ivar = 0; ivar < varnames_2d_rho.size(); ++ivar) {
776 HeaderFile << varnames_2d_rho[ivar] <<
"\n";
778 std::string mf_2d_rho_prefix =
"rho2d";
779 for (
int level = 0; level <= finest_level; ++level) {
780 HeaderFile << MultiFabHeaderPath(level, levelPrefix, mf_2d_rho_prefix) <<
"\n";
784 if (varnames_2d_u.size() > 0) {
785 HeaderFile << varnames_2d_u.size() <<
"\n";
786 for (
int ivar = 0; ivar < varnames_2d_u.size(); ++ivar) {
787 HeaderFile << varnames_2d_u[ivar] <<
"\n";
789 std::string mf_2d_u_prefix =
"u2d";
790 for (
int level = 0; level <= finest_level; ++level) {
791 HeaderFile << MultiFabHeaderPath(level, levelPrefix, mf_2d_u_prefix) <<
"\n";
795 if (varnames_2d_v.size() > 0) {
796 HeaderFile << varnames_2d_v.size() <<
"\n";
797 for (
int ivar = 0; ivar < varnames_2d_v.size(); ++ivar) {
798 HeaderFile << varnames_2d_v[ivar] <<
"\n";
800 std::string mf_2d_v_prefix =
"v2d";
801 for (
int level = 0; level <= finest_level; ++level) {
802 HeaderFile << MultiFabHeaderPath(level, levelPrefix, mf_2d_v_prefix) <<
"\n";