aboutsummaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/Diagnostics/ReducedDiags/FieldReduction.H34
-rw-r--r--Source/Diagnostics/ReducedDiags/FieldReduction.cpp18
2 files changed, 47 insertions, 5 deletions
diff --git a/Source/Diagnostics/ReducedDiags/FieldReduction.H b/Source/Diagnostics/ReducedDiags/FieldReduction.H
index 46fcfc295..c4c81c016 100644
--- a/Source/Diagnostics/ReducedDiags/FieldReduction.H
+++ b/Source/Diagnostics/ReducedDiags/FieldReduction.H
@@ -60,10 +60,16 @@ public:
*/
virtual void ComputeDiags(int step) override final;
+ /**
+ * This function queries deprecated input parameters and aborts
+ * the run if one of them is specified.
+ */
+ void BackwardCompatibility();
+
private:
/// Parser to read expression to be reduced from the input file.
- /// 9 elements are x, y, z, Ex, Ey, Ez, Bx, By, Bz
- static constexpr int m_nvars = 9;
+ /// 12 elements are x, y, z, Ex, Ey, Ez, Bx, By, Bz, jx, jy, jz
+ static constexpr int m_nvars = 12;
std::unique_ptr<amrex::Parser> m_parser;
// Type of reduction (e.g. Maximum, Minimum or Sum)
@@ -99,6 +105,10 @@ public:
const amrex::MultiFab & Bx = warpx.getBfield(lev,0);
const amrex::MultiFab & By = warpx.getBfield(lev,1);
const amrex::MultiFab & Bz = warpx.getBfield(lev,2);
+ const amrex::MultiFab & jx = warpx.getcurrent_fp(lev,0);
+ const amrex::MultiFab & jy = warpx.getcurrent_fp(lev,1);
+ const amrex::MultiFab & jz = warpx.getcurrent_fp(lev,2);
+
// General preparation of interpolation and reduction operations
const amrex::GpuArray<int,3> cellCenteredtype{0,0,0};
@@ -118,6 +128,9 @@ public:
auto Bxtype = amrex::GpuArray<int,3>{0,0,0};
auto Bytype = amrex::GpuArray<int,3>{0,0,0};
auto Bztype = amrex::GpuArray<int,3>{0,0,0};
+ auto jxtype = amrex::GpuArray<int,3>{0,0,0};
+ auto jytype = amrex::GpuArray<int,3>{0,0,0};
+ auto jztype = amrex::GpuArray<int,3>{0,0,0};
for (int i = 0; i < AMREX_SPACEDIM; ++i){
Extype[i] = Ex.ixType()[i];
Eytype[i] = Ey.ixType()[i];
@@ -125,6 +138,10 @@ public:
Bxtype[i] = Bx.ixType()[i];
Bytype[i] = By.ixType()[i];
Bztype[i] = Bz.ixType()[i];
+ jxtype[i] = jx.ixType()[i];
+ jytype[i] = jy.ixType()[i];
+ jztype[i] = jz.ixType()[i];
+
}
// get parser
@@ -145,6 +162,9 @@ public:
const auto& arrBx = Bx[mfi].array();
const auto& arrBy = By[mfi].array();
const auto& arrBz = Bz[mfi].array();
+ const auto& arrjx = jx[mfi].array();
+ const auto& arrjy = jy[mfi].array();
+ const auto& arrjz = jz[mfi].array();
reduce_op.eval(box, reduce_data,
[=] AMREX_GPU_DEVICE (int i, int j, int k) -> ReduceTuple
@@ -176,8 +196,16 @@ public:
reduction_coarsening_ratio, i, j, k, reduction_comp);
const amrex::Real Bz_interp = ablastr::coarsen::sample::Interp(arrBz, Bztype, cellCenteredtype,
reduction_coarsening_ratio, i, j, k, reduction_comp);
+ const amrex::Real jx_interp = ablastr::coarsen::sample::Interp(arrjx, jxtype, cellCenteredtype,
+ reduction_coarsening_ratio, i, j, k, reduction_comp);
+ const amrex::Real jy_interp = ablastr::coarsen::sample::Interp(arrjy, jytype, cellCenteredtype,
+ reduction_coarsening_ratio, i, j, k, reduction_comp);
+ const amrex::Real jz_interp = ablastr::coarsen::sample::Interp(arrjz, jztype, cellCenteredtype,
+ reduction_coarsening_ratio, i, j, k, reduction_comp);
+
return reduction_function_parser(x, y, z, Ex_interp, Ey_interp, Ez_interp,
- Bx_interp, By_interp, Bz_interp);
+ Bx_interp, By_interp, Bz_interp,
+ jx_interp, jy_interp, jz_interp);
});
}
diff --git a/Source/Diagnostics/ReducedDiags/FieldReduction.cpp b/Source/Diagnostics/ReducedDiags/FieldReduction.cpp
index f4b521c10..32c8c9653 100644
--- a/Source/Diagnostics/ReducedDiags/FieldReduction.cpp
+++ b/Source/Diagnostics/ReducedDiags/FieldReduction.cpp
@@ -44,14 +44,16 @@ FieldReduction::FieldReduction (std::string rd_name)
// resize data array
m_data.resize(noutputs, 0.0_rt);
+ BackwardCompatibility();
+
const amrex::ParmParse pp_rd_name(rd_name);
// read reduced function with parser
std::string parser_string = "";
- utils::parser::Store_parserString(pp_rd_name,"reduced_function(x,y,z,Ex,Ey,Ez,Bx,By,Bz)",
+ utils::parser::Store_parserString(pp_rd_name,"reduced_function(x,y,z,Ex,Ey,Ez,Bx,By,Bz,jx,jy,jz)",
parser_string);
m_parser = std::make_unique<amrex::Parser>(
- utils::parser::makeParser(parser_string,{"x","y","z","Ex","Ey","Ez","Bx","By","Bz"}));
+ utils::parser::makeParser(parser_string,{"x","y","z","Ex","Ey","Ez","Bx","By","Bz","jx","jy","jz"}));
// Replace all newlines and possible following whitespaces with a single whitespace. This
// should avoid weird formatting when the string is written in the header of the output file.
@@ -85,6 +87,18 @@ FieldReduction::FieldReduction (std::string rd_name)
}
// end constructor
+void FieldReduction::BackwardCompatibility ()
+{
+ amrex::ParmParse pp_rd_name(m_rd_name);
+ std::vector<std::string> backward_strings;
+ WARPX_ALWAYS_ASSERT_WITH_MESSAGE(
+ !pp_rd_name.queryarr("reduced_function(x,y,z,Ex,Ey,Ez,Bx,By,Bz)", backward_strings),
+ "<reduced_diag_name>.reduced_function(x,y,z,Ex,Ey,Ez,Bx,By,Bz) is no longer a valid option. "
+ "Please use the renamed option <reduced_diag_name>.reduced_function(x,y,z,Ex,Ey,Ez,Bx,By,Bz,jx,jy,jz) instead."
+ );
+}
+
+
// function that does an arbitrary reduction of the electromagnetic fields
void FieldReduction::ComputeDiags (int step)
{