aboutsummaryrefslogtreecommitdiff
path: root/Source/Diagnostics/ComputeDiagFunctors/JFunctor.cpp
diff options
context:
space:
mode:
authorGravatar Roelof Groenewald <40245517+roelof-groenewald@users.noreply.github.com> 2023-08-20 14:26:37 -0700
committerGravatar GitHub <noreply@github.com> 2023-08-20 14:26:37 -0700
commit5b74a61c631102a1c121a3668d0c02098c259b9b (patch)
tree818d73a3b4b75cf191b51e0bdb581b145d63b0eb /Source/Diagnostics/ComputeDiagFunctors/JFunctor.cpp
parent9ce0b9c2cbd8f4881347a3f0d5a6cbf04c7a7919 (diff)
downloadWarpX-5b74a61c631102a1c121a3668d0c02098c259b9b.tar.gz
WarpX-5b74a61c631102a1c121a3668d0c02098c259b9b.tar.zst
WarpX-5b74a61c631102a1c121a3668d0c02098c259b9b.zip
Include `J` in diagnostic output when an electromagnetic solver is not used (#4116)
* include current density in diagnostic output even if an electromagnetic solver is not used * do not redeposit current for the magnetostatic solver * update CI benchmarks for tests that previously did not register current density * fix remaining failing CI test * Apply suggestions from code review Co-authored-by: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> * do not output current density in collision tests * update `JFunctor` constructor doc-string * code cleanup - reduce code duplication * specify `Ex Ey Ez Bx By Bz` fields to plot for collision CI tests * specify `Er Et Ez Br Bt Bz` as output for rz collision test * rename `InterpolateToDst` to `InterpolateMFForDiag` * only deposit current density once per diagnostic output (if not already deposited) * write deposited current for all directions into `current_fp` during diagnostic step deposition * use `amrex::make_alias` to directly deposit current density into `warpx.current_fp` during diagnostic step deposition * add class variable `solver_deposits_current` to `FullDiagnostics` so that there is only one place where the determination is made whether current should be deposited during diagnostic output * correct logic to determine `m_solver_deposits_current` --------- Co-authored-by: Edoardo Zoni <59625522+EZoni@users.noreply.github.com>
Diffstat (limited to 'Source/Diagnostics/ComputeDiagFunctors/JFunctor.cpp')
-rw-r--r--Source/Diagnostics/ComputeDiagFunctors/JFunctor.cpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/Source/Diagnostics/ComputeDiagFunctors/JFunctor.cpp b/Source/Diagnostics/ComputeDiagFunctors/JFunctor.cpp
new file mode 100644
index 000000000..4663a5e1a
--- /dev/null
+++ b/Source/Diagnostics/ComputeDiagFunctors/JFunctor.cpp
@@ -0,0 +1,59 @@
+/* This file is part of WarpX.
+ *
+ * Authors: Roelof Groenewald
+ * License: BSD-3-Clause-LBNL
+ */
+
+#include "JFunctor.H"
+
+#include "Particles/MultiParticleContainer.H"
+#include "WarpX.H"
+
+#include <AMReX.H>
+#include <AMReX_IntVect.H>
+#include <AMReX_MultiFab.H>
+
+JFunctor::JFunctor (const int dir, int lev,
+ amrex::IntVect crse_ratio,
+ bool convertRZmodes2cartesian,
+ bool deposit_current, int ncomp)
+ : ComputeDiagFunctor(ncomp, crse_ratio), m_dir(dir), m_lev(lev),
+ m_convertRZmodes2cartesian(convertRZmodes2cartesian),
+ m_deposit_current(deposit_current)
+{ }
+
+void
+JFunctor::operator() (amrex::MultiFab& mf_dst, int dcomp, const int /*i_buffer*/) const
+{
+ auto& warpx = WarpX::GetInstance();
+ /** pointer to source multifab (can be multi-component) */
+ amrex::MultiFab* m_mf_src = warpx.get_pointer_current_fp(m_lev, m_dir);
+
+ // Deposit current if no solver or the electrostatic solver is being used
+ if (m_deposit_current)
+ {
+ // allocate temporary multifab to deposit current density into
+ amrex::Vector<std::array< std::unique_ptr<amrex::MultiFab>, 3 > > current_fp_temp;
+ current_fp_temp.resize(1);
+
+ auto& current_fp_x = warpx.getcurrent_fp(m_lev,0);
+ current_fp_temp[0][0] = std::make_unique<amrex::MultiFab>(
+ current_fp_x, amrex::make_alias, 0, current_fp_x.nComp()
+ );
+
+ auto& current_fp_y = warpx.getcurrent_fp(m_lev,1);
+ current_fp_temp[0][1] = std::make_unique<amrex::MultiFab>(
+ current_fp_y, amrex::make_alias, 0, current_fp_y.nComp()
+ );
+ auto& current_fp_z = warpx.getcurrent_fp(m_lev,2);
+ current_fp_temp[0][2] = std::make_unique<amrex::MultiFab>(
+ current_fp_z, amrex::make_alias, 0, current_fp_z.nComp()
+ );
+
+ auto& mypc = warpx.GetPartContainer();
+ mypc.DepositCurrent(current_fp_temp, warpx.getdt(m_lev), 0.0);
+ }
+
+ InterpolateMFForDiag(mf_dst, *m_mf_src, dcomp, warpx.DistributionMap(m_lev),
+ m_convertRZmodes2cartesian);
+}