Skip to content

Commit

Permalink
remove logic to subtract J_ext from plasma current in JdispFunctor
Browse files Browse the repository at this point in the history
  • Loading branch information
roelof-groenewald committed Sep 19, 2024
1 parent 383d9f3 commit 134f1e2
Showing 1 changed file with 6 additions and 48 deletions.
54 changes: 6 additions & 48 deletions Source/Diagnostics/ComputeDiagFunctors/JdispFunctor.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
/* This file is part of Warpx.
/* Copyright 2023-2024 The WarpX Community
*
* This file is part of WarpX.
*
* Authors: Avigdor Veksler (TAE Technologies)
*
* Authors: Avigdor Veksler
* License: BSD-3-Clause-LBNL
*/
*/
#include "JdispFunctor.H"

#include "WarpX.H"
Expand Down Expand Up @@ -61,51 +64,6 @@ JdispFunctor::operator() (amrex::MultiFab& mf_dst, int dcomp, const int /*i_buff
-1, *mf_j, 0, 0, 1, Jdisp.nGrowVect()
);

if (hybrid_pic_model) {
// Subtract the interpolated j_external value from j_displacement.
/** pointer to external currents (Jext) multifab */
amrex::MultiFab* mf_j_external = hybrid_pic_model->get_pointer_current_fp_external(m_lev, m_dir);

// Index type required for interpolating Jext from their respective
// staggering (nodal) to the Jx_displacement, Jy_displacement, Jz_displacement
// locations. The staggering of J_displacement is the same as the
// staggering for J, so we use J_stag as the interpolation map.
// For interp to work below, the indices of the undefined dimensions
// must match. We set them as (1,1,1).
amrex::GpuArray<int, 3> Jext_IndexType = {1, 1, 1};
amrex::GpuArray<int, 3> J_IndexType = {1, 1, 1};
amrex::IntVect Jext_stag = mf_j_external->ixType().toIntVect();
amrex::IntVect J_stag = mf_j->ixType().toIntVect();

// Index types for the dimensions simulated are overwritten.
for ( int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
Jext_IndexType[idim] = Jext_stag[idim];
J_IndexType[idim] = J_stag[idim];
}

// Parameters for `interp` that maps from Jext to J.
// The "coarsening is just 1 i.e. no coarsening"
amrex::GpuArray<int, 3> const& coarsen = {1, 1, 1};

// Loop through the grids, and over the tiles within each grid to
// subtract the interpolated Jext from J_displacement.
#ifdef AMREX_USE_OMP
#pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
#endif
for ( MFIter mfi(Jdisp, TilingIfNotGPU()); mfi.isValid(); ++mfi ) {

Array4<Real> const& Jdisp_arr = Jdisp.array(mfi);
Array4<Real const> const& Jext = mf_j_external->const_array(mfi);

// Loop over cells and update the Jdisp MultiFab
amrex::ParallelFor(mfi.tilebox(), [=] AMREX_GPU_DEVICE (int i, int j, int k){
// Interpolate Jext to the staggering of J
auto const jext_interp = ablastr::coarsen::sample::Interp(Jext, Jext_IndexType, J_IndexType, coarsen, i, j, k, 0);
Jdisp_arr(i, j, k, 0) -= jext_interp;
});
}
}

InterpolateMFForDiag(mf_dst, Jdisp, dcomp, warpx.DistributionMap(m_lev),
m_convertRZmodes2cartesian);
}

0 comments on commit 134f1e2

Please sign in to comment.