aboutsummaryrefslogtreecommitdiff
path: root/Source/FieldSolver/FiniteDifferenceSolver/EvolveB.cpp
diff options
context:
space:
mode:
authorGravatar Lorenzo Giacomel <47607756+lgiacome@users.noreply.github.com> 2021-11-12 22:02:03 +0100
committerGravatar GitHub <noreply@github.com> 2021-11-12 13:02:03 -0800
commit5e1b4f4f694396df21b32f09bbccc74235bf861a (patch)
treea0fa926de2a0bfb822a35e719be37c31ff2f8519 /Source/FieldSolver/FiniteDifferenceSolver/EvolveB.cpp
parent8edeb87183ee672548db7741a5625883499317ab (diff)
downloadWarpX-5e1b4f4f694396df21b32f09bbccc74235bf861a.tar.gz
WarpX-5e1b4f4f694396df21b32f09bbccc74235bf861a.tar.zst
WarpX-5e1b4f4f694396df21b32f09bbccc74235bf861a.zip
2D EM solver with EB (#2401)
* adding the FieldProbe * adding missing file * updating makefile * fixing host-device problem * Revert "fixing host-device problem" This reverts commit 801e6fc47f19cfc42ec46e5ef1a18dcf86be3e5a. * fixing host-device problem * making some variables const * adding a few comments * Adding the FieldProbe to the documentation * making the probe mpi-safe * added field probe to reduced diag test * added field probe to reduced diag analysis * using cell-centered fields in probe diag * removed a few typos * Interpolating to the point instead oof cell center * bug fix * improved a comment * updated documentation * Undone an outdated change * improving some variable names * improving the box extraction * making the interpolation order an input parameter * fix a typo * setting the field values to zero if the point is not in the domain * skipping the communication if probe proc is IO prcessor * Fixed typo in documentation Co-authored-by: Neïl Zaim <49716072+NeilZaim@users.noreply.github.com> * Updating an header * Added a comment on the probe position * tidying up the analysis script * fixed a comment * removing an unused include * improving the parsing of parameters * fixing some comments * making some variables const * changed some ParticleReal into Real * using better tags in MPI communication * Making field probe work in 2D * making a variable const * initializing y_probe only in 3D * tidying up a line which is common to 2D and 3D * making a variable constexpr * adding a _rt * checking that the probe location is in one of the processors * removing a useless if condition * Fixing the initialization in 2D * Avoiding scrape particles in 2D (it segfaults) * Adding a test for 2D EB * Fixed the areas initialization * Initializing to zero some multifabs * Modified the ECT solver to make it work in 2D * Modified the cell extensions to make them work in 2D * Improved 2D cube test * Added 2D rotated cube test * Adding the 2d analysis script and CI * Removed an unused import from the analysis script * Ignoring some unused variables * Fixing the number of dimensions in the 2d test * Added missing analysis for ECT * Enabled again 2d particles scraping * Fixing the test_name with the general logic * Fixing the test_name with the general logic * Removed some commented code * Modified several preprocessor directives to check consistency EB-dimension * Added missing semicolons * Fixed a preprocessor directivew * Fix typo: WARPX_DIM_XZ * Improving some comments Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja> * Adding some more consistency checks * Adding some more consistency checks * Fixed a typo Co-authored-by: Neïl Zaim <49716072+NeilZaim@users.noreply.github.com> Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
Diffstat (limited to 'Source/FieldSolver/FiniteDifferenceSolver/EvolveB.cpp')
-rw-r--r--Source/FieldSolver/FiniteDifferenceSolver/EvolveB.cpp43
1 files changed, 40 insertions, 3 deletions
diff --git a/Source/FieldSolver/FiniteDifferenceSolver/EvolveB.cpp b/Source/FieldSolver/FiniteDifferenceSolver/EvolveB.cpp
index f115ca8e5..bfdb46863 100644
--- a/Source/FieldSolver/FiniteDifferenceSolver/EvolveB.cpp
+++ b/Source/FieldSolver/FiniteDifferenceSolver/EvolveB.cpp
@@ -216,6 +216,11 @@ void FiniteDifferenceSolver::EvolveRhoCartesianECT (
std::array< std::unique_ptr<amrex::MultiFab>, 3 > const& face_areas,
std::array< std::unique_ptr<amrex::MultiFab>, 3 >& ECTRhofield, const int lev ) {
#ifdef AMREX_USE_EB
+
+#if !(defined(WARPX_DIM_3D) || defined(WARPX_DIM_XZ))
+ amrex::Abort("EvolveRhoCartesianECT: Embedded Boundaries are only implemented in 2D3V and 3D3V");
+#endif
+
amrex::LayoutData<amrex::Real>* cost = WarpX::getCosts(lev);
// Loop through the grids, and over the tiles within each grid
@@ -252,25 +257,33 @@ void FiniteDifferenceSolver::EvolveRhoCartesianECT (
[=] AMREX_GPU_DEVICE(int i, int j, int k) {
if (Sx(i, j, k) <= 0) return;
+#ifndef WARPX_DIM_XZ
Rhox(i, j, k) = (Ey(i, j, k) * ly(i, j, k) - Ey(i, j, k + 1) * ly(i, j, k + 1) +
Ez(i, j + 1, k) * lz(i, j + 1, k) - Ez(i, j, k) * lz(i, j, k)) / Sx(i, j, k);
-
+#endif
},
[=] AMREX_GPU_DEVICE(int i, int j, int k) {
if (Sy(i, j, k) <= 0) return;
+#ifdef WARPX_DIM_XZ
+ Rhoy(i, j, k) = (Ez(i, j, k) * lz(i, j, k) - Ez(i + 1, j, k) * lz(i + 1, j, k) +
+ Ex(i, j + 1, k) * lx(i, j + 1, k) - Ex(i, j, k) * lx(i, j, k)) / Sy(i, j, k);
+#elif defined(WARPX_DIM_3D)
Rhoy(i, j, k) = (Ez(i, j, k) * lz(i, j, k) - Ez(i + 1, j, k) * lz(i + 1, j, k) +
Ex(i, j, k + 1) * lx(i, j, k + 1) - Ex(i, j, k) * lx(i, j, k)) / Sy(i, j, k);
-
+#else
+ amrex::Abort("EvolveRhoCartesianECT: Embedded Boundaries are only implemented in 2D3V and 3D3V");
+#endif
},
[=] AMREX_GPU_DEVICE(int i, int j, int k) {
if (Sz(i, j, k) <= 0) return;
+#ifndef WARPX_DIM_XZ
Rhoz(i, j, k) = (Ex(i, j, k) * lx(i, j, k) - Ex(i, j + 1, k) * lx(i, j + 1, k) +
Ey(i + 1, j, k) * ly(i + 1, j, k) - Ey(i, j, k) * ly(i, j, k)) / Sz(i, j, k);
-
+#endif
}
);
@@ -280,6 +293,9 @@ void FiniteDifferenceSolver::EvolveRhoCartesianECT (
wt = amrex::second() - wt;
amrex::HostDevice::Atomic::Add( &(*cost)[mfi.index()], wt);
}
+#ifdef WARPX_DIM_XZ
+ amrex::ignore_unused(Ey, Rhox, Rhoz, ly);
+#endif
}
#else
amrex::ignore_unused(Efield, edge_lengths, face_areas, ECTRhofield, lev);
@@ -296,6 +312,11 @@ void FiniteDifferenceSolver::EvolveBCartesianECT (
std::array< std::unique_ptr<amrex::LayoutData<FaceInfoBox> >, 3 >& borrowing,
const int lev, amrex::Real const dt ) {
#ifdef AMREX_USE_EB
+
+#if !(defined(WARPX_DIM_3D) || defined(WARPX_DIM_XZ))
+ amrex::Abort("EvolveBCartesianECT: Embedded Boundaries are only implemented in 2D3V and 3D3V");
+#endif
+
amrex::LayoutData<amrex::Real> *cost = WarpX::getCosts(lev);
Venl[0]->setVal(0.);
@@ -355,9 +376,17 @@ void FiniteDifferenceSolver::EvolveBCartesianECT (
jp = j + vec(0);
kp = k + vec(1);
}else if(idim == 1){
+#ifdef WARPX_DIM_XZ
+ ip = i + vec(0);
+ jp = j + vec(1);
+ kp = k;
+#elif defined(WARPX_DIM_3D)
ip = i + vec(0);
jp = j;
kp = k + vec(1);
+#else
+ amrex::Abort("EvolveBCartesianECT: Embedded Boundaries are only implemented in 2D3V and 3D3V");
+#endif
}else{
ip = i + vec(0);
jp = j + vec(1);
@@ -379,9 +408,17 @@ void FiniteDifferenceSolver::EvolveBCartesianECT (
jp = j + vec(0);
kp = k + vec(1);
}else if(idim == 1){
+#ifdef WARPX_DIM_XZ
+ ip = i + vec(0);
+ jp = j + vec(1);
+ kp = k;
+#elif defined(WARPX_DIM_3D)
ip = i + vec(0);
jp = j;
kp = k + vec(1);
+#else
+ amrex::Abort("EvolveBCartesianECT: Embedded Boundaries are only implemented in 2D3V and 3D3V");
+#endif
}else{
ip = i + vec(0);
jp = j + vec(1);