8 #ifndef WARPX_DIAGNOSTICS_REDUCEDDIAGS_RAWBFIELDREDUCTION_H_
9 #define WARPX_DIAGNOSTICS_REDUCEDDIAGS_RAWBFIELDREDUCTION_H_
16 #include <AMReX_Config.H>
34 #include <type_traits>
65 #if (AMREX_SPACEDIM==1)
70 #elif (AMREX_SPACEDIM==2)
90 template<
typename ReduceOp>
93 using namespace amrex::literals;
96 const auto nLevel = 1;
101 for (
int lev = 0; lev < nLevel; ++lev) {
106 constexpr
int index_Bx = 0;
107 constexpr
int index_By = 1;
108 constexpr
int index_Bz = 2;
120 using ReduceTuple =
typename decltype(reduceBx_data)::Type;
127 #pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
131 const amrex::Box& tx = mfi.tilebox(Bx_nodalType);
132 const amrex::Box& ty = mfi.tilebox(By_nodalType);
133 const amrex::Box& tz = mfi.tilebox(Bz_nodalType);
144 const auto& Bx_arr = Bx[mfi].
array();
145 const auto& By_arr = By[mfi].
array();
146 const auto& Bz_arr = Bz[mfi].
array();
148 reduceBx_op.
eval(tx, reduceBx_data,
152 amrex::Real fac_x = (1._rt - Bx_nodalType[0]) *
dx[0] * 0.5_rt;
153 amrex::Real
x =
i *
dx[0] + real_box.
lo(0) + fac_x;
154 #if (AMREX_SPACEDIM==1)
155 amrex::Real
y = 0._rt;
156 amrex::Real
z = 0._rt;
157 #elif (AMREX_SPACEDIM==2)
158 amrex::Real
y = 0._rt;
159 amrex::Real fac_z = (1._rt - Bx_nodalType[1]) *
dx[1] * 0.5_rt;
160 amrex::Real
z = j *
dx[1] + real_box.
lo(1) + fac_z;
162 amrex::Real fac_y = (1._rt - Bx_nodalType[1]) *
dx[1] * 0.5_rt;
163 amrex::Real
y = j *
dx[1] + real_box.
lo(1) + fac_y;
164 amrex::Real fac_z = (1._rt - Bx_nodalType[2]) *
dx[2] * 0.5_rt;
165 amrex::Real
z = k *
dx[2] + real_box.
lo(2) + fac_z;
170 amrex::Real weight = 1.0;
171 if (
i == lx[0] ||
i == hx[0]) {
174 return weight*reduction_function_parser(
x,
y,
z)*Bx_arr(
i,j,k);
176 reduceBy_op.
eval(ty, reduceBy_data,
180 amrex::Real fac_x = (1._rt - By_nodalType[0]) *
dx[0] * 0.5_rt;
181 amrex::Real
x =
i *
dx[0] + real_box.
lo(0) + fac_x;
182 #if (AMREX_SPACEDIM==1)
183 amrex::Real
y = 0._rt;
184 amrex::Real
z = 0._rt;
185 #elif (AMREX_SPACEDIM==2)
186 amrex::Real
y = 0._rt;
187 amrex::Real fac_z = (1._rt - By_nodalType[1]) *
dx[1] * 0.5_rt;
188 amrex::Real
z = j *
dx[1] + real_box.
lo(1) + fac_z;
190 amrex::Real fac_y = (1._rt - By_nodalType[1]) *
dx[1] * 0.5_rt;
191 amrex::Real
y = j *
dx[1] + real_box.
lo(1) + fac_y;
192 amrex::Real fac_z = (1._rt - By_nodalType[2]) *
dx[2] * 0.5_rt;
193 amrex::Real
z = k *
dx[2] + real_box.
lo(2) + fac_z;
198 amrex::Real weight = 1.0;
199 if (j == ly[1] || j == hy[1]) {
202 return weight*reduction_function_parser(
x,
y,
z)*By_arr(
i,j,k);
204 reduceBz_op.
eval(tz, reduceBz_data,
208 amrex::Real fac_x = (1._rt - Bz_nodalType[0]) *
dx[0] * 0.5_rt;
209 amrex::Real
x =
i *
dx[0] + real_box.
lo(0) + fac_x;
210 #if (AMREX_SPACEDIM==1)
211 amrex::Real
y = 0._rt;
212 amrex::Real
z = 0._rt;
213 #elif (AMREX_SPACEDIM==2)
214 amrex::Real
y = 0._rt;
215 amrex::Real fac_z = (1._rt - Bz_nodalType[1]) *
dx[1] * 0.5_rt;
216 amrex::Real
z = j *
dx[1] + real_box.
lo(1) + fac_z;
218 amrex::Real fac_y = (1._rt - Bz_nodalType[1]) *
dx[1] * 0.5_rt;
219 amrex::Real
y = j *
dx[1] + real_box.
lo(1) + fac_y;
220 amrex::Real fac_z = (1._rt - Bz_nodalType[2]) *
dx[2] * 0.5_rt;
221 amrex::Real
z = k *
dx[2] + real_box.
lo(2) + fac_z;
226 amrex::Real weight = 1.0;
227 if (k == lz[2] || k == hz[2]) {
230 return weight*reduction_function_parser(
x,
y,
z)*Bz_arr(
i,j,k);
234 amrex::Real reducedBx_value = amrex::get<0>(reduceBx_data.
value());
235 amrex::Real reducedBy_value = amrex::get<0>(reduceBy_data.
value());
236 amrex::Real reducedBz_value = amrex::get<0>(reduceBz_data.
value());
259 if (integral_type == 0) {
261 #if (AMREX_SPACEDIM==1)
262 amrex::Real length =
dx[0];
263 reducedBx_value *= length;
264 reducedBy_value *= length;
265 reducedBz_value *= length;
266 #elif (AMREX_SPACEDIM==2)
267 amrex::Real area =
dx[0]*
dx[1];
268 reducedBx_value *= area;
269 reducedBy_value *= area;
270 reducedBz_value *= area;
272 amrex::Real volume =
dx[0]*
dx[1]*
dx[2];
273 reducedBx_value *= volume;
274 reducedBy_value *= volume;
275 reducedBz_value *= volume;
278 #if (AMREX_SPACEDIM==1)
279 amrex::Real point = surface_normal[0]*1.0;
281 reducedBy_value *= point;
282 reducedBz_value *= point;
283 #elif (AMREX_SPACEDIM==2)
284 amrex::Real length = surface_normal[0]*
dx[1] + surface_normal[1]*
dx[0];
286 reducedBy_value *= length;
289 amrex::Real area = surface_normal[0]*
dx[1]*
dx[2] + surface_normal[1]*
dx[2]*
dx[0] + surface_normal[2]*
dx[0]*
dx[1];
296 m_data[index_Bx] = reducedBx_value;
297 m_data[index_By] = reducedBy_value;
298 m_data[index_Bz] = reducedBz_value;
Definition: RawBFieldReduction.H:38
void ComputeRawBFieldReduction()
Definition: RawBFieldReduction.H:91
std::unique_ptr< amrex::Parser > m_parser
Definition: RawBFieldReduction.H:59
int m_surface_normal[3]
Definition: RawBFieldReduction.H:77
static constexpr int m_nvars
Definition: RawBFieldReduction.H:58
RawBFieldReduction(std::string rd_name)
Definition: RawBFieldReduction.cpp:26
int m_reduction_type
Definition: RawBFieldReduction.H:62
int m_integral_type
Definition: RawBFieldReduction.H:64
virtual void ComputeDiags(int step) override final
Definition: RawBFieldReduction.cpp:122
std::vector< amrex::Real > m_scaling_factor
Definition: RawBFieldReduction.H:79
Definition: ReducedDiags.H:24
std::vector< amrex::Real > m_data
output data
Definition: ReducedDiags.H:46
static WarpX & GetInstance()
Definition: WarpX.cpp:309
AMREX_GPU_HOST_DEVICE const IntVectND< dim > & smallEnd() const &noexcept
AMREX_GPU_HOST_DEVICE const IntVectND< dim > & bigEnd() const &noexcept
GpuArray< Real, AMREX_SPACEDIM > CellSizeArray() const noexcept
IndexType ixType() const noexcept
Array4< typename FabArray< FAB >::value_type const > array(const MFIter &mfi) const noexcept
const RealBox & ProbDomain() const noexcept
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< dim > toIntVect() const noexcept
AMREX_GPU_HOST_DEVICE const Real * lo() const &noexcept
std::enable_if_t< IsFabArray< MF >::value > eval(MF const &mf, IntVect const &nghost, D &reduce_data, F &&f)
def y
Definition: Excitation_Flag_Generator.py:76
def x
Formats datastring to remove "+" at the end of the string #####.
Definition: Excitation_Flag_Generator.py:75
def z
Definition: Excitation_Flag_Generator.py:77
void ReduceRealMin(Vector< std::reference_wrapper< Real > > const &)
void ReduceRealSum(Vector< std::reference_wrapper< Real > > const &)
void ReduceRealMax(Vector< std::reference_wrapper< Real > > const &)
i
Definition: check_interp_points_and_weights.py:174
int dx
Definition: stencil.py:436
value
Definition: updateAMReX.py:141
Definition: NCIGodfreyTables.H:14