Skip to content

Commit

Permalink
Merge pull request #173 from AMReX-FHD/plotfile_deltaY
Browse files Browse the repository at this point in the history
add ability to write deltaY to plotfile in compressible_stag
  • Loading branch information
ajnonaka authored Dec 5, 2024
2 parents d61978a + 9f1ccd2 commit 96e467f
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src_common/ComputeAverages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,12 @@ void WriteHorizontalAverage(const MultiFab& mf_in, const int& dir, const int& in

void WriteHorizontalAverageToMF(const MultiFab& mf_in, MultiFab& mf_out,
const int& dir, const int& incomp,
const int& ncomp)
const int& ncomp, int outcomp)
{
if (outcomp == -1) {
outcomp = incomp; // default outcomp is incomp unless specified
}

// number of points in the averaging direction
int npts = n_cells[dir];

Expand Down Expand Up @@ -166,7 +170,7 @@ void WriteHorizontalAverageToMF(const MultiFab& mf_in, MultiFab& mf_out,
const Array4<Real> mf = mf_out.array(mfi);

for (auto n=0; n<ncomp; ++n) {
comp = incomp+n;
comp = outcomp+n;
for (auto k = lo.z; k <= hi.z; ++k) {
for (auto j = lo.y; j <= hi.y; ++j) {
for (auto i = lo.x; i <= hi.x; ++i) {
Expand Down
2 changes: 1 addition & 1 deletion src_common/common_functions.H
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void WriteHorizontalAverage(const MultiFab& mf_in, const int& dir, const int& in

void WriteHorizontalAverageToMF(const MultiFab& mf_in, MultiFab& mf_out,
const int& dir, const int& incomp,
const int& ncomp);
const int& ncomp, int outcomp=-1);

void ComputeVerticalAverage(const MultiFab & mf, MultiFab & mf_flat, const Geometry & geom,
const int& dir, const int& incomp, const int& ncomp,
Expand Down
3 changes: 3 additions & 0 deletions src_common/common_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ int common::plot_means;
int common::plot_vars;
int common::plot_covars;
int common::plot_cross;
int common::plot_deltaY_dir;
int common::particle_motion;

AMREX_GPU_MANAGED amrex::Real common::turb_a;
Expand Down Expand Up @@ -608,6 +609,7 @@ void InitializeCommonNamespace() {
plot_vars = 0;
plot_covars = 0;
plot_cross = 0;
plot_deltaY_dir = -1;
particle_motion = 0;

// turblent forcing parameters
Expand Down Expand Up @@ -1135,6 +1137,7 @@ void InitializeCommonNamespace() {
pp.query("plot_vars",plot_vars);
pp.query("plot_covars",plot_covars);
pp.query("plot_cross",plot_cross);
pp.query("plot_deltaY_dir",plot_deltaY_dir);
pp.query("particle_motion",particle_motion);
pp.query("turb_a",turb_a);
pp.query("turb_b",turb_b);
Expand Down
1 change: 1 addition & 0 deletions src_common/common_namespace.H
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ namespace common {
extern int plot_vars;
extern int plot_covars;
extern int plot_cross;
extern int plot_deltaY_dir;
extern int particle_motion;

// parameters for turbulent forcing example
Expand Down
24 changes: 23 additions & 1 deletion src_compressible_stag/writePlotFileStag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ void WritePlotFileStag(int step,

if (nspec_surfcov>0) nplot += nspec_surfcov*6;
}


if (plot_deltaY_dir != -1) {
nplot += nspecies;
}

amrex::BoxArray ba = cuMeans.boxArray();
amrex::DistributionMapping dmap = cuMeans.DistributionMap();

Expand Down Expand Up @@ -257,6 +261,16 @@ void WritePlotFileStag(int step,
}
}

if (plot_deltaY_dir != -1) {
MultiFab Ybar(ba, dmap, nspecies, 0);
// Yk is component 6: in prim
WriteHorizontalAverageToMF(prim,Ybar,plot_deltaY_dir,6,nspecies,0);
Ybar.mult(-1.);
amrex::MultiFab::Add(Ybar,prim,6,0,nspecies,0);
amrex::MultiFab::Copy(plotfile,Ybar,0,cnt,nspecies,0);
cnt+= nspecies;
}

// Set variable names
cnt = 0;

Expand Down Expand Up @@ -445,6 +459,14 @@ void WritePlotFileStag(int step,

}

if (plot_deltaY_dir != 1) {
x = "deltaYk_";
for (i=0; i<nspecies; i++) {
varNames[cnt] = x;
varNames[cnt++] += 48+i;
}
}

AMREX_ASSERT(cnt==nplot);

// write a plotfile
Expand Down

0 comments on commit 96e467f

Please sign in to comment.