Skip to content

Commit

Permalink
Plot w/ vector distortion support for multi-level terrain. (#1179)
Browse files Browse the repository at this point in the history
  • Loading branch information
AMLattanzi authored Jul 21, 2023
1 parent 5b900d4 commit 8c426cf
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Exec/RegTests/DynamicRefinement/inputs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@ erf.hi_scal2.value_greater = 10.

amr.n_error_buf = 4
erf.regrid_int = 2
erf.cf_width = 4
erf.cf_set_width = 1
erf.cf_width = 0 # Internal relaxation
erf.cf_set_width = 0 # Internal Dirichlet

48 changes: 31 additions & 17 deletions Source/IO/Plotfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,20 @@ ERF::WritePlotFile (int which, Vector<std::string> plot_var_names)
#endif
}

// Fill terrain distortion MF
if (solverChoice.use_terrain) {
for (int lev(0); lev <= finest_level; ++lev) {
MultiFab::Copy(mf_nd[lev],*z_phys_nd[lev],0,2,1,0);
Real dz = Geom()[lev].CellSizeArray()[2];
for (MFIter mfi(mf_nd[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi) {
const Box& bx = mfi.tilebox();
Array4< Real> mf_arr = mf_nd[lev].array(mfi);
ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) {
mf_arr(i,j,k,2) -= k * dz;
});
}
}
}

std::string plotfilename;
if (which == 1)
Expand All @@ -771,27 +785,16 @@ ERF::WritePlotFile (int which, Vector<std::string> plot_var_names)
if (plotfile_type == "amrex") {
amrex::Print() << "Writing plotfile " << plotfilename << "\n";
if (solverChoice.use_terrain) {
// We started with mf_nd holding 0 in every component; here we fill only the offset in z
int lev = 0;
MultiFab::Copy(mf_nd[lev],*z_phys_nd[lev],0,2,1,0);
Real dz = Geom()[lev].CellSizeArray()[2];
for (MFIter mfi(mf_nd[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi) {
const Box& bx = mfi.tilebox();
Array4< Real> mf_arr = mf_nd[lev].array(mfi);
ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) {
mf_arr(i,j,k,2) -= k * dz;
});
}
WriteMultiLevelPlotfileWithTerrain(plotfilename, finest_level+1,
GetVecOfConstPtrs(mf),
GetVecOfConstPtrs(mf_nd),
varnames,
t_new[0], istep);
} else {
WriteMultiLevelPlotfile(plotfilename, finest_level+1,
GetVecOfConstPtrs(mf),
varnames,
Geom(), t_new[0], istep, refRatio());
GetVecOfConstPtrs(mf),
varnames,
Geom(), t_new[0], istep, refRatio());
}
writeJobInfo(plotfilename);
#ifdef ERF_USE_HDF5
Expand Down Expand Up @@ -864,8 +867,19 @@ ERF::WritePlotFile (int which, Vector<std::string> plot_var_names)
rr[lev] = IntVect(ref_ratio[lev][0],ref_ratio[lev][1],ref_ratio[lev][0]);
}

WriteMultiLevelPlotfile(plotfilename, finest_level+1, GetVecOfConstPtrs(mf2), varnames,
g2, t_new[0], istep, rr);
amrex::Print() << "Writing plotfile " << plotfilename << "\n";
if (solverChoice.use_terrain) {
WriteMultiLevelPlotfileWithTerrain(plotfilename, finest_level+1,
GetVecOfConstPtrs(mf),
GetVecOfConstPtrs(mf_nd),
varnames,
t_new[0], istep);
} else {
WriteMultiLevelPlotfile(plotfilename, finest_level+1,
GetVecOfConstPtrs(mf2), varnames,
g2, t_new[0], istep, rr);
}

writeJobInfo(plotfilename);
#ifdef ERF_USE_NETCDF
} else if (plotfile_type == "netcdf" || plotfile_type == "NetCDF") {
Expand Down Expand Up @@ -958,7 +972,7 @@ ERF::WriteMultiLevelPlotfileWithTerrain (const std::string& plotfilename, int nl
} else {
data = mf[level];
}
VisMF::Write(*data , MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mfPrefix));
VisMF::Write(*data , MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mfPrefix));
VisMF::Write(*mf_nd[level], MultiFabFileFullPrefix(level, plotfilename, levelPrefix, mf_nodal_prefix));
}
}
Expand Down

0 comments on commit 8c426cf

Please sign in to comment.