diff --git a/Source/ERF.H b/Source/ERF.H index 2533b0ffe..9f3f71d28 100644 --- a/Source/ERF.H +++ b/Source/ERF.H @@ -862,6 +862,7 @@ private: // plotfile prefix and frequency std::string plot_file_1 {"plt_1_"}; std::string plot_file_2 {"plt_2_"}; + bool m_expand_plotvars_to_unif_rr = false; int m_plot_int_1 = -1; int m_plot_int_2 = -1; amrex::Real m_plot_per_1 = -1.0; diff --git a/Source/ERF.cpp b/Source/ERF.cpp index b433ab704..332b068c6 100644 --- a/Source/ERF.cpp +++ b/Source/ERF.cpp @@ -1503,6 +1503,8 @@ ERF::ReadParameters () pp.query("plot_per_1", m_plot_per_1); pp.query("plot_per_2", m_plot_per_2); + pp.query("expand_plotvars_to_unif_rr",m_expand_plotvars_to_unif_rr); + if ( (m_plot_int_1 > 0 && m_plot_per_1 > 0) || (m_plot_int_2 > 0 && m_plot_per_2 > 0.) ) { Abort("Must choose only one of plot_int or plot_per"); diff --git a/Source/IO/ERF_Plotfile.cpp b/Source/IO/ERF_Plotfile.cpp index f3bd61633..5bdcf5831 100644 --- a/Source/IO/ERF_Plotfile.cpp +++ b/Source/IO/ERF_Plotfile.cpp @@ -1359,6 +1359,7 @@ ERF::WritePlotFile (int which, Vector plot_var_names) } #endif + // Single level if (finest_level == 0) { if (plotfile_type == "amrex") { @@ -1399,16 +1400,17 @@ ERF::WritePlotFile (int which, Vector plot_var_names) Abort("Dont know this plot_filetype"); } - } else { // multilevel + } else { // Multilevel if (plotfile_type == "amrex") { - // NOTE: this assumes that -- at least -- there is refinement in the x-direction - // Otherwise the logic will be wrong int lev0 = 0; - int desired_ratio = ref_ratio[lev0][0]; - if (ref_ratio[lev0][2] == 1) { + int desired_ratio = std::max(std::max(ref_ratio[lev0][0],ref_ratio[lev0][1]),ref_ratio[lev0][2]); + bool any_ratio_one = ( ( (ref_ratio[lev0][0] == 0) || (ref_ratio[lev0][1] == 0) ) || + (ref_ratio[lev0][2] == 0) ); + if (any_ratio_one == 1 && m_expand_plotvars_to_unif_rr) + { Vector r2(finest_level); Vector g2(finest_level+1); Vector mf2(finest_level+1); @@ -1423,12 +1425,15 @@ ERF::WritePlotFile (int which, Vector plot_var_names) {Geom()[lev0].isPeriodic(0),Geom()[lev0].isPeriodic(1),Geom()[lev0].isPeriodic(2)}; g2[lev0].define(Geom()[lev0].Domain(),&(Geom()[lev0].ProbDomain()),0,periodicity.data()); - r2[0] = IntVect(1,desired_ratio, desired_ratio); + r2[0] = IntVect(desired_ratio/ref_ratio[lev0][0], + desired_ratio/ref_ratio[lev0][1], + desired_ratio/ref_ratio[lev0][2]); + for (int lev = 1; lev <= finest_level; ++lev) { if (lev > 1) { - r2[lev-1][0] = 1; - r2[lev-1][1] *= desired_ratio / ref_ratio[lev0][1]; - r2[lev-1][2] *= desired_ratio / ref_ratio[lev0][2]; + r2[lev-1][0] *= desired_ratio / ref_ratio[lev-1][0]; + r2[lev-1][1] *= desired_ratio / ref_ratio[lev-1][1]; + r2[lev-1][2] *= desired_ratio / ref_ratio[lev-1][2]; } mf2[lev].define(refine(grids[lev],r2[lev-1]), dmap[lev], ncomp_mf, 0); @@ -1469,7 +1474,7 @@ ERF::WritePlotFile (int which, Vector plot_var_names) g2, t_new[0], istep, rr); } - } else if (ref_ratio[0][2] != 1) { + } else { if (solverChoice.use_terrain) { WriteMultiLevelPlotfileWithTerrain(plotfilename, finest_level+1, GetVecOfConstPtrs(mf),