From 616080ee5659803fedcce4e23a3caadaa1f69faf Mon Sep 17 00:00:00 2001 From: Remi Lehe Date: Mon, 27 May 2019 22:26:07 -0700 Subject: Start algorithm selection --- Source/Utils/WarpXAlgorithmSelection.H | 57 ++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Source/Utils/WarpXAlgorithmSelection.H (limited to 'Source/Utils/WarpXAlgorithmSelection.H') diff --git a/Source/Utils/WarpXAlgorithmSelection.H b/Source/Utils/WarpXAlgorithmSelection.H new file mode 100644 index 000000000..3a892b92c --- /dev/null +++ b/Source/Utils/WarpXAlgorithmSelection.H @@ -0,0 +1,57 @@ +#ifndef UTILS_WARPXALGORITHMSELECTION_H_ +#define UTILS_WARPXALGORITHMSELECTION_H_ + +#include +#include + +struct MaxwellSolverAlgo { + // These numbers corresponds to the algorithm code in WarpX's + // `warpx_push_bvec` and `warpx_push_evec_f` + enum { + Yee = 0, + CKC = 1 + }; +}; + +struct ParticlePusherAlgo { + // These numbers correspond to the algorithm code in WarpX's + // `warpx_particle_pusher` + enum { + Boris = 0, + Vay = 1 + }; +}; + +struct CurrentDepositionAlgo { + enum { + // These numbers corresponds to the algorithm code in PICSAR's + // `depose_jxjyjz_generic` and `depose_jxjyjz_generic_2d` + Direct = 3, + DirectVectorized = 2, + EsirkepovNonOptimized = 1, + Esirkepov = 0 + }; +}; + +struct ChargeDepositionAlgo { + // These numbers corresponds to the algorithm code in WarpX's + // `warpx_charge_deposition` function + enum { + Vectorized = 0, + Standard = 1 + }; +}; + +struct GatheringAlgo { + // These numbers corresponds to the algorithm code in PICSAR's + // `geteb3d_energy_conserving_generic` function + enum { + Vectorized = 0, + Standard = 1 + }; +}; + +int +GetAlgorithmInteger( amrex::ParmParse& pp, std::string pp_search_key ); + +#endif // UTILS_WARPXALGORITHMSELECTION_H_ -- cgit v1.2.3 From 31f0aadd209fe4bb227380b31eb264b5ab79cb5f Mon Sep 17 00:00:00 2001 From: Remi Lehe Date: Wed, 29 May 2019 08:13:21 -0700 Subject: Fix bugs --- Source/FortranInterface/WarpX_picsar.F90 | 4 +--- Source/Utils/WarpXAlgorithmSelection.H | 2 +- Source/Utils/WarpXAlgorithmSelection.cpp | 15 +++++++++------ Source/WarpX.cpp | 13 +++++++------ 4 files changed, 18 insertions(+), 16 deletions(-) (limited to 'Source/Utils/WarpXAlgorithmSelection.H') diff --git a/Source/FortranInterface/WarpX_picsar.F90 b/Source/FortranInterface/WarpX_picsar.F90 index ddffc61ea..12d541b08 100644 --- a/Source/FortranInterface/WarpX_picsar.F90 +++ b/Source/FortranInterface/WarpX_picsar.F90 @@ -218,12 +218,10 @@ subroutine warpx_charge_deposition(rho,np,xp,yp,zp,w,q,xmin,ymin,zmin,dx,dy,dz,n IF ((nox.eq.1).and.(noy.eq.1).and.(noz.eq.1)) THEN CALL depose_rho_vecHVv2_1_1_1(rho,np,xp,yp,zp,w,q,xmin,ymin,zmin,dx,dy,dz,nx,ny,nz,& nxguard,nyguard,nzguard,lvect) + ELSE IF ((nox.eq.2).and.(noy.eq.2).and.(noz.eq.2)) THEN CALL depose_rho_vecHVv2_2_2_2(rho,np,xp,yp,zp,w,q,xmin,ymin,zmin,dx,dy,dz,nx,ny,nz,& nxguard,nyguard,nzguard,lvect) - ELSE IF ((nox.eq.3).and.(noy.eq.3).and.(noz.eq.3)) THEN - CALL depose_rho_vecHVv2_3_3_3(rho,np,xp,yp,zp,w,q,xmin,ymin,zmin,dx,dy,dz,nx,ny,nz,& - nxguard,nyguard,nzguard,lvect) ELSE CALL pxr_depose_rho_n(rho,np,xp,yp,zp,w,q,xmin,ymin,zmin,dx,dy,dz,nx,ny,nz,& diff --git a/Source/Utils/WarpXAlgorithmSelection.H b/Source/Utils/WarpXAlgorithmSelection.H index 3a892b92c..3fb23698a 100644 --- a/Source/Utils/WarpXAlgorithmSelection.H +++ b/Source/Utils/WarpXAlgorithmSelection.H @@ -52,6 +52,6 @@ struct GatheringAlgo { }; int -GetAlgorithmInteger( amrex::ParmParse& pp, std::string pp_search_key ); +GetAlgorithmInteger( amrex::ParmParse& pp, const char* pp_search_key ); #endif // UTILS_WARPXALGORITHMSELECTION_H_ diff --git a/Source/Utils/WarpXAlgorithmSelection.cpp b/Source/Utils/WarpXAlgorithmSelection.cpp index 7e868b745..a8081cdcb 100644 --- a/Source/Utils/WarpXAlgorithmSelection.cpp +++ b/Source/Utils/WarpXAlgorithmSelection.cpp @@ -5,7 +5,7 @@ const std::map maxwell_solver_algo_to_int = { {"yee", MaxwellSolverAlgo::Yee }, -#if (defined AMREX_USE_GPU) // Only available on CPU +#ifndef AMREX_USE_GPU // Only available on CPU {"ckc", MaxwellSolverAlgo::CKC }, #endif {"default", MaxwellSolverAlgo::Yee } @@ -20,7 +20,7 @@ const std::map particle_pusher_algo_to_int = { const std::map current_deposition_algo_to_int = { {"esirkepov", CurrentDepositionAlgo::Esirkepov }, {"direct", CurrentDepositionAlgo::Direct }, -#if (defined AMREX_USE_GPU)&&(AMREX_SPACEDIM == 3) // Only available on CPU and 3D +#if (!defined AMREX_USE_GPU)&&(AMREX_SPACEDIM == 3) // Only available on CPU and 3D {"direct-vectorized", CurrentDepositionAlgo::DirectVectorized }, #endif {"default", CurrentDepositionAlgo::Esirkepov } @@ -28,7 +28,7 @@ const std::map current_deposition_algo_to_int = { const std::map charge_deposition_algo_to_int = { {"standard", ChargeDepositionAlgo::Standard }, -#if (defined AMREX_USE_GPU)&&(AMREX_SPACEDIM == 3) // Only available on CPU and 3D +#if (!defined AMREX_USE_GPU)&&(AMREX_SPACEDIM == 3) // Only available on CPU and 3D {"vectorized", ChargeDepositionAlgo::Vectorized }, {"default", ChargeDepositionAlgo::Vectorized } #else @@ -40,6 +40,9 @@ const std::map gathering_algo_to_int = { {"standard", GatheringAlgo::Standard }, #ifndef AMREX_USE_GPU // Only available on CPU {"vectorized", GatheringAlgo::Vectorized }, + {"default", GatheringAlgo::Vectorized } +#else + {"default", GatheringAlgo::Standard } #endif }; @@ -70,11 +73,11 @@ GetAlgorithmInteger( amrex::ParmParse& pp, const char* pp_search_key ){ if (algo_to_int.count(algo) == 0){ // Not a valid key ; print error message std::string pp_search_string = pp_search_key; - std::string error_message = "Invalid string for algo." - + pp_search_string + ": " + algo + ". The valid values are: "; + std::string error_message = "Invalid string for algo." + pp_search_string + + ": " + algo + ".\nThe valid values are:\n"; for ( const auto &valid_pair : algo_to_int ) { if (valid_pair.first != "default"){ - error_message += valid_pair.first + " "; + error_message += " - " + valid_pair.first + "\n"; } } amrex::Abort(error_message); diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index 3d7f7dcc5..c51df1d74 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #ifdef BL_USE_SENSEI_INSITU #include @@ -118,7 +119,7 @@ WarpX::ResetInstance () { delete m_instance; m_instance = nullptr; -} +} WarpX::WarpX () { @@ -276,10 +277,10 @@ WarpX::ReadParameters () ReadBoostedFrameParameters(gamma_boost, beta_boost, boost_direction); - // pp.query returns 1 if argument zmax_plasma_to_compute_max_step is + // pp.query returns 1 if argument zmax_plasma_to_compute_max_step is // specified by the user, 0 otherwise. - do_compute_max_step_from_zmax = - pp.query("zmax_plasma_to_compute_max_step", + do_compute_max_step_from_zmax = + pp.query("zmax_plasma_to_compute_max_step", zmax_plasma_to_compute_max_step); pp.queryarr("B_external", B_external); @@ -318,7 +319,7 @@ WarpX::ReadParameters () "gamma_boost must be > 1 to use the boosted frame diagnostic."); pp.query("lab_data_directory", lab_data_directory); - + std::string s; pp.get("boost_direction", s); AMREX_ALWAYS_ASSERT_WITH_MESSAGE( (s == "z" || s == "Z"), @@ -477,7 +478,7 @@ WarpX::ReadParameters () { ParmParse pp("algo"); - pp.query("current_deposition", current_deposition_algo); + current_deposition_algo = GetAlgorithmInteger(pp, "current_deposition"); pp.query("charge_deposition", charge_deposition_algo); pp.query("field_gathering", field_gathering_algo); pp.query("particle_pusher", particle_pusher_algo); -- cgit v1.2.3