From ca67ae0700d1f56e7921da9283d42184149cb15b Mon Sep 17 00:00:00 2001 From: Lorenzo Giacomel <47607756+lgiacome@users.noreply.github.com> Date: Thu, 13 Jan 2022 20:05:19 +0100 Subject: Fixing staircased EM solver (#2739) * Fixing the staircase consistency * Removed the face_areas multifabs everywhere they're not needed * Bug fix * More fixes * Another fix * Another fix * Initialize areas anyways for the initialization * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: lgiacome Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .../FieldSolver/FiniteDifferenceSolver/EvolveB.cpp | 39 ++++++++-------------- 1 file changed, 13 insertions(+), 26 deletions(-) (limited to 'Source/FieldSolver/FiniteDifferenceSolver/EvolveB.cpp') diff --git a/Source/FieldSolver/FiniteDifferenceSolver/EvolveB.cpp b/Source/FieldSolver/FiniteDifferenceSolver/EvolveB.cpp index bfdb46863..9de1e8f8b 100644 --- a/Source/FieldSolver/FiniteDifferenceSolver/EvolveB.cpp +++ b/Source/FieldSolver/FiniteDifferenceSolver/EvolveB.cpp @@ -68,17 +68,21 @@ void FiniteDifferenceSolver::EvolveB ( ignore_unused(Gfield, face_areas); EvolveBCylindrical ( Bfield, Efield, lev, dt ); #else + if(m_do_nodal or m_fdtd_algo != MaxwellSolverAlgo::ECT){ + amrex::ignore_unused(face_areas); + } + if (m_do_nodal) { - EvolveBCartesian ( Bfield, Efield, Gfield, face_areas, lev, dt ); + EvolveBCartesian ( Bfield, Efield, Gfield, lev, dt ); } else if (m_fdtd_algo == MaxwellSolverAlgo::Yee) { - EvolveBCartesian ( Bfield, Efield, Gfield, face_areas, lev, dt ); + EvolveBCartesian ( Bfield, Efield, Gfield, lev, dt ); } else if (m_fdtd_algo == MaxwellSolverAlgo::CKC) { - EvolveBCartesian ( Bfield, Efield, Gfield, face_areas, lev, dt ); + EvolveBCartesian ( Bfield, Efield, Gfield, lev, dt ); #ifdef AMREX_USE_EB } else if (m_fdtd_algo == MaxwellSolverAlgo::ECT) { @@ -99,13 +103,8 @@ void FiniteDifferenceSolver::EvolveBCartesian ( std::array< std::unique_ptr, 3 >& Bfield, std::array< std::unique_ptr, 3 > const& Efield, std::unique_ptr const& Gfield, - std::array< std::unique_ptr, 3 > const& face_areas, int lev, amrex::Real const dt ) { -#ifndef AMREX_USE_EB - amrex::ignore_unused(face_areas); -#endif - amrex::LayoutData* cost = WarpX::getCosts(lev); // Loop through the grids, and over the tiles within each grid @@ -127,12 +126,6 @@ void FiniteDifferenceSolver::EvolveBCartesian ( Array4 const& Ey = Efield[1]->array(mfi); Array4 const& Ez = Efield[2]->array(mfi); -#ifdef AMREX_USE_EB - amrex::Array4 const& Sx = face_areas[0]->array(mfi); - amrex::Array4 const& Sy = face_areas[1]->array(mfi); - amrex::Array4 const& Sz = face_areas[2]->array(mfi); -#endif - // Extract stencil coefficients Real const * const AMREX_RESTRICT coefs_x = m_stencil_coefs_x.dataPtr(); int const n_coefs_x = m_stencil_coefs_x.size(); @@ -150,30 +143,24 @@ void FiniteDifferenceSolver::EvolveBCartesian ( amrex::ParallelFor(tbx, tby, tbz, [=] AMREX_GPU_DEVICE (int i, int j, int k){ -#ifdef AMREX_USE_EB - // Skip field push if this cell is fully covered by embedded boundaries - if (Sx(i, j, k) <= 0) return; -#endif + Bx(i, j, k) += dt * T_Algo::UpwardDz(Ey, coefs_z, n_coefs_z, i, j, k) - dt * T_Algo::UpwardDy(Ez, coefs_y, n_coefs_y, i, j, k); + }, [=] AMREX_GPU_DEVICE (int i, int j, int k){ -#ifdef AMREX_USE_EB - // Skip field push if this cell is fully covered by embedded boundaries - if (Sy(i, j, k) <= 0) return; -#endif + By(i, j, k) += dt * T_Algo::UpwardDx(Ez, coefs_x, n_coefs_x, i, j, k) - dt * T_Algo::UpwardDz(Ex, coefs_z, n_coefs_z, i, j, k); + }, [=] AMREX_GPU_DEVICE (int i, int j, int k){ -#ifdef AMREX_USE_EB - // Skip field push if this cell is fully covered by embedded boundaries - if (Sz(i, j, k) <= 0) return; -#endif + Bz(i, j, k) += dt * T_Algo::UpwardDy(Ex, coefs_y, n_coefs_y, i, j, k) - dt * T_Algo::UpwardDx(Ey, coefs_x, n_coefs_x, i, j, k); + } ); -- cgit v1.2.3