/* Copyright 2020 Remi Lehe * * This file is part of WarpX. * * License: BSD-3-Clause-LBNL */ #include "FiniteDifferenceSolver.H" #include "Utils/WarpXAlgorithmSelection.H" #ifndef WARPX_DIM_RZ # include "FiniteDifferenceAlgorithms/CartesianCKCAlgorithm.H" # include "FiniteDifferenceAlgorithms/CartesianNodalAlgorithm.H" # include "FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H" #else # include "FiniteDifferenceAlgorithms/CylindricalYeeAlgorithm.H" #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace amrex; /** * \brief Update the F field, over one timestep */ void FiniteDifferenceSolver::ComputeDivE ( const std::array,3>& Efield, amrex::MultiFab& divEfield ) { // Select algorithm (The choice of algorithm is a runtime option, // but we compile code for each algorithm, using templates) #ifdef WARPX_DIM_RZ if (m_fdtd_algo == MaxwellSolverAlgo::Yee){ ComputeDivECylindrical ( Efield, divEfield ); #else if (m_do_nodal) { ComputeDivECartesian ( Efield, divEfield ); } else if (m_fdtd_algo == MaxwellSolverAlgo::Yee) { ComputeDivECartesian ( Efield, divEfield ); } else if (m_fdtd_algo == MaxwellSolverAlgo::CKC) { ComputeDivECartesian ( Efield, divEfield ); #endif } else { amrex::Abort("ComputeDivE: Unknown algorithm"); } } #ifndef WARPX_DIM_RZ template void FiniteDifferenceSolver::ComputeDivECartesian ( const std::array,3>& Efield, amrex::MultiFab& divEfield ) { // Loop through the grids, and over the tiles within each grid #ifdef AMREX_USE_OMP #pragma omp parallel if (amrex::Gpu::notInLaunchRegion()) #endif for ( MFIter mfi(divEfield, TilingIfNotGPU()); mfi.isValid(); ++mfi ) { // Extract field data for this grid/tile Array4 const& divE = divEfield.array(mfi); Array4 const& Ex = Efield[0]->array(mfi); Array4 const& Ey = Efield[1]->array(mfi); Array4 const& Ez = Efield[2]->array(mfi); // 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(); Real const * const AMREX_RESTRICT coefs_y = m_stencil_coefs_y.dataPtr(); int const n_coefs_y = m_stencil_coefs_y.size(); Real const * const AMREX_RESTRICT coefs_z = m_stencil_coefs_z.dataPtr(); int const n_coefs_z = m_stencil_coefs_z.size(); // Extract tileboxes for which to loop Box const& tdive = mfi.tilebox(divEfield.ixType().toIntVect()); // Loop over the cells and update the fields amrex::ParallelFor(tdive, [=] AMREX_GPU_DEVICE (int i, int j, int k){ divE(i, j, k) = T_Algo::DownwardDx(Ex, coefs_x, n_coefs_x, i, j, k) + T_Algo::DownwardDy(Ey, coefs_y, n_coefs_y, i, j, k) + T_Algo::DownwardDz(Ez, coefs_z, n_coefs_z, i, j, k); } ); } } #else // corresponds to ifndef WARPX_DIM_RZ template void FiniteDifferenceSolver::ComputeDivECylindrical ( const std::array,3>& Efield, amrex::MultiFab& divEfield ) { // Loop through the grids, and over the tiles within each grid #ifdef AMREX_USE_OMP #pragma omp parallel if (amrex::Gpu::notInLaunchRegion()) #endif for ( MFIter mfi(divEfield, TilingIfNotGPU()); mfi.isValid(); ++mfi ) { // Extract field data for this grid/tile Array4 divE = divEfield.array(mfi); Array4 const& Er = Efield[0]->array(mfi); Array4 const& Et = Efield[1]->array(mfi); Array4 const& Ez = Efield[2]->array(mfi); // Extract stencil coefficients Real const * const AMREX_RESTRICT coefs_r = m_stencil_coefs_r.dataPtr(); int const n_coefs_r = m_stencil_coefs_r.size(); Real const * const AMREX_RESTRICT coefs_z = m_stencil_coefs_z.dataPtr(); int const n_coefs_z = m_stencil_coefs_z.size(); // Extract cylindrical specific parameters Real const dr = m_dr; int const nmodes = m_nmodes; Real const rmin = m_rmin; // Extract tileboxes for which to loop Box const& tdive = mfi.tilebox(divEfield.ixType().toIntVect()); // Loop over the cells and update the fields amrex::ParallelFor(tdive, [=] AMREX_GPU_DEVICE (int i, int j, int /*k*/){ Real const r = rmin + i*dr; // r on a nodal grid (F is nodal in r) if (r != 0) { // Off-axis, regular equations divE(i, j, 0, 0) = T_Algo::DownwardDrr_over_r(Er, r, dr, coefs_r, n_coefs_r, i, j, 0, 0) + T_Algo::DownwardDz(Ez, coefs_z, n_coefs_z, i, j, 0, 0); for (int m=1 ; m2019-10-24add a new regression test for momentum conserving field gatherGravatar Weiqun Zhang 1-0/+16 2019-10-24cleanup and commentGravatar Weiqun Zhang 3-5/+3 2019-10-24update algo.field_gathering in new inputs files. standard is now an invalid ↵Gravatar Weiqun Zhang 6-6/+6 option. 2019-10-24Add initial value (false) for test_quantum_syncGravatar Luca Fedeli 1-1/+1 2019-10-23minor cleaningGravatar Maxence Thevenet 1-3/+1 2019-10-23cleaningGravatar Maxence Thevenet 1-4/+3 2019-10-23fix performance tests on SummitGravatar Maxence Thevenet 4-16/+18 2019-10-23save performance h5 files, and move handling to perf_logs repoGravatar MaxThevenet 1-36/+19 2019-10-23remove unused constantGravatar Luca Fedeli 1-2/+1 2019-10-22new tests comply with rules in this PRGravatar MaxThevenet 2-1/+1 2019-10-22write path + filename if wrong filenameGravatar MaxThevenet 1-1/+1 2019-10-21Made modifications based on suggestions from PR review. 1.Added the override ↵Gravatar RevathiJambunathan 1-6/+6 qualifies for functions in the derived class. 2. Clarified that particles are selectively copied from tmp to reduced diag buffer if they are within the user-defined subdomain. 2019-10-20not faster with make -j4. Reversing to make -j2 for TravisCO testsGravatar MaxThevenet 1-1/+1 2019-10-20try compiling with -j 4 on TravisCI (hyperthreading?)Gravatar MaxThevenet 1-1/+1 2019-10-20unused arguments in 2d LPA testGravatar MaxThevenet 1-2/+0 2019-10-20missed one qed option in input fileGravatar MaxThevenet 1-2/+2 2019-10-20back with QED options on for QED testGravatar MaxThevenet 2-4/+4 2019-10-20minor fix: forgot to pass patch limits for LaserAccelerationMRGravatar MaxThevenet 1-1/+1 2019-10-20clone regression_testing from ECP-WarpXGravatar MaxThevenet 1-1/+1 2019-10-20remove another unused parameterGravatar MaxThevenet 2-3/+1 2019-10-18remove unused variables from qed testsGravatar MaxThevenet 2-14/+7 2019-10-18re-order options in WarpX-tests.ini for consistencyGravatar MaxThevenet 1-2/+2 2019-10-18oops, clipped some text while fixing conflictsGravatar MaxThevenet 1-0/+4 2019-10-18remove unused variables from 2D examplesGravatar MaxThevenet 7-35/+9 2019-10-18oops remove file added by errorGravatar MaxThevenet 1-664/+0 2019-10-18add option to crash if unused parmparse variablesGravatar MaxThevenet 2-24/+701 2019-10-18Add Higuera pusher into Langmuir test input.rtGravatar Yin-YinjianZhao 1-0/+1 2019-10-18Modified according to MaxThevenet's commentsGravatar Yin-YinjianZhao 6-8/+13 2019-10-18remove electrostatic example as long as WarpX electrostatic does not compileGravatar MaxThevenet 2-84/+0 2019-10-18add newlnes at the end of WarpX-tests.iniGravatar MaxThevenet 1-0/+1 2019-10-18do not check double newline in WarpX-tests.iniGravatar MaxThevenet 1-3/+3 2019-10-18Add automatic testsGravatar Yin-YinjianZhao 3-0/+86 2019-10-18typo in plasma acceleration testGravatar MaxThevenet 1-3/+3 2019-10-18forgot a few input filesGravatar MaxThevenet 3-20/+29 2019-10-18add test for all input files in Examples/ to WarpX-tests.iniGravatar MaxThevenet 20-726/+237 2019-10-18add comments in bash scriptGravatar MaxThevenet 1-7/+5 2019-10-18change test on grep so that it works on MacOS and LinuxGravatar MaxThevenet 1-3/+5 2019-10-18remove print statementsGravatar MaxThevenet 2-139/+0 2019-10-18try other syntax to avoid errorGravatar MaxThevenet 1-1/+4 2019-10-17add exitGravatar MaxThevenet 2-0/+4 2019-10-17trailing whitespaceGravatar MaxThevenet 1-2/+2 2019-10-17check if all input files in Examples/ are testGravatar MaxThevenet 2-0/+39 2019-10-17rename input file for consistencyGravatar MaxThevenet 1-0/+0