diff options
author | 2022-03-08 18:38:25 +0100 | |
---|---|---|
committer | 2022-03-08 09:38:25 -0800 | |
commit | 0a64c2b8a42d766e5a893fcab2d4573b33cca74f (patch) | |
tree | 16f5979ff152251fc443f2e5ee67f929d6534228 /Source/Particles/MultiParticleContainer.cpp | |
parent | 7425721ccced342615c054ea8147fbdc484d6620 (diff) | |
download | WarpX-0a64c2b8a42d766e5a893fcab2d4573b33cca74f.tar.gz WarpX-0a64c2b8a42d766e5a893fcab2d4573b33cca74f.tar.zst WarpX-0a64c2b8a42d766e5a893fcab2d4573b33cca74f.zip |
Make error and info messages visually uniform (#2939)
* initial work to add msg formatter
* wip
* replace AMREX_ALWAYS_ASSERT_WITH_MESSAGE with WarpX equivalent
Diffstat (limited to 'Source/Particles/MultiParticleContainer.cpp')
-rw-r--r-- | Source/Particles/MultiParticleContainer.cpp | 75 |
1 files changed, 40 insertions, 35 deletions
diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index 973cfb8bf..e571de877 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -230,7 +230,7 @@ MultiParticleContainer::ReadParameters () if (m_E_ext_particle_s == "repeated_plasma_lens" || m_B_ext_particle_s == "repeated_plasma_lens") { getWithParser(pp_particles, "repeated_plasma_lens_period", m_repeated_plasma_lens_period); - AMREX_ALWAYS_ASSERT_WITH_MESSAGE(m_repeated_plasma_lens_period > 0._rt, + WARPX_ALWAYS_ASSERT_WITH_MESSAGE(m_repeated_plasma_lens_period > 0._rt, "The period of the repeated plasma lens must be greater than zero"); getArrWithParser(pp_particles, "repeated_plasma_lens_starts", h_repeated_plasma_lens_starts); getArrWithParser(pp_particles, "repeated_plasma_lens_lengths", h_repeated_plasma_lens_lengths); @@ -279,11 +279,10 @@ MultiParticleContainer::ReadParameters () pp_particles.queryarr("deposit_on_main_grid", tmp); for (auto const& name : tmp) { auto it = std::find(species_names.begin(), species_names.end(), name); - WarpXUtilMsg::AlwaysAssert( + WARPX_ALWAYS_ASSERT_WITH_MESSAGE( it != species_names.end(), - "ERROR: species '" + name - + "' in particles.deposit_on_main_grid must be part of particles.species_names" - ); + "species '" + name + + "' in particles.deposit_on_main_grid must be part of particles.species_names"); int i = std::distance(species_names.begin(), it); m_deposit_on_main_grid[i] = true; } @@ -293,11 +292,10 @@ MultiParticleContainer::ReadParameters () pp_particles.queryarr("gather_from_main_grid", tmp_gather); for (auto const& name : tmp_gather) { auto it = std::find(species_names.begin(), species_names.end(), name); - WarpXUtilMsg::AlwaysAssert( + WARPX_ALWAYS_ASSERT_WITH_MESSAGE( it != species_names.end(), - "ERROR: species '" + name - + "' in particles.gather_from_main_grid must be part of particles.species_names" - ); + "species '" + name + + "' in particles.gather_from_main_grid must be part of particles.species_names"); int i = std::distance(species_names.begin(), it); m_gather_from_main_grid.at(i) = true; } @@ -310,11 +308,10 @@ MultiParticleContainer::ReadParameters () if (!rigid_injected_species.empty()) { for (auto const& name : rigid_injected_species) { auto it = std::find(species_names.begin(), species_names.end(), name); - WarpXUtilMsg::AlwaysAssert( + WARPX_ALWAYS_ASSERT_WITH_MESSAGE( it != species_names.end(), - "ERROR: species '" + name - + "' in particles.rigid_injected_species must be part of particles.species_names" - ); + "species '" + name + + "' in particles.rigid_injected_species must be part of particles.species_names"); int i = std::distance(species_names.begin(), it); species_types[i] = PCTypes::RigidInjected; } @@ -325,11 +322,10 @@ MultiParticleContainer::ReadParameters () if (!photon_species.empty()) { for (auto const& name : photon_species) { auto it = std::find(species_names.begin(), species_names.end(), name); - WarpXUtilMsg::AlwaysAssert( + WARPX_ALWAYS_ASSERT_WITH_MESSAGE( it != species_names.end(), - "ERROR: species '" + name - + "' in particles.photon_species must be part of particles.species_names" - ); + "species '" + name + + "' in particles.photon_species must be part of particles.species_names"); int i = std::distance(species_names.begin(), it); species_types[i] = PCTypes::Photon; } @@ -338,11 +334,11 @@ MultiParticleContainer::ReadParameters () } pp_particles.query("use_fdtd_nci_corr", WarpX::use_fdtd_nci_corr); #ifdef WARPX_DIM_RZ - AMREX_ALWAYS_ASSERT_WITH_MESSAGE(WarpX::use_fdtd_nci_corr==0, + WARPX_ALWAYS_ASSERT_WITH_MESSAGE(WarpX::use_fdtd_nci_corr==0, "ERROR: use_fdtd_nci_corr is not supported in RZ"); #endif #ifdef WARPX_DIM_1D_Z - AMREX_ALWAYS_ASSERT_WITH_MESSAGE(WarpX::use_fdtd_nci_corr==0, + WARPX_ALWAYS_ASSERT_WITH_MESSAGE(WarpX::use_fdtd_nci_corr==0, "ERROR: use_fdtd_nci_corr is not supported in 1D"); #endif @@ -376,6 +372,17 @@ MultiParticleContainer::ReadParameters () } } +WarpXParticleContainer& +MultiParticleContainer::GetParticleContainerFromName (const std::string& name) const +{ + auto it = std::find(species_names.begin(), species_names.end(), name); + WARPX_ALWAYS_ASSERT_WITH_MESSAGE( + it != species_names.end(), + "unknown species name"); + int i = std::distance(species_names.begin(), it); + return *allcontainers[i]; +} + void MultiParticleContainer::AllocData () { @@ -837,11 +844,10 @@ MultiParticleContainer::getSpeciesID (std::string product_str) const } } - WarpXUtilMsg::AlwaysAssert( + WARPX_ALWAYS_ASSERT_WITH_MESSAGE( found != 0, - "ERROR: could not find the ID of product species '" - + product_str + "'" + ". Wrong name?" - ); + "could not find the ID of product species '" + + product_str + "'" + ". Wrong name?"); return i_product; } @@ -864,11 +870,10 @@ MultiParticleContainer::SetDoBackTransformedParticles (std::string species_name, pc->SetDoBackTransformedParticles(do_back_transformed_particles); } } - WarpXUtilMsg::AlwaysAssert( + WARPX_ALWAYS_ASSERT_WITH_MESSAGE( found != 0, "ERROR: could not find the ID of product species '" - + species_name + "'" + ". Wrong name?" - ); + + species_name + "'" + ". Wrong name?"); } void @@ -959,7 +964,7 @@ void MultiParticleContainer::CheckIonizationProductSpecies() { for (int i=0; i < static_cast<int>(species_names.size()); i++){ if (allcontainers[i]->do_field_ionization){ - AMREX_ALWAYS_ASSERT_WITH_MESSAGE( + WARPX_ALWAYS_ASSERT_WITH_MESSAGE( i != allcontainers[i]->ionization_product, "ERROR: ionization product cannot be the same species"); } @@ -1303,14 +1308,14 @@ MultiParticleContainer::doQEDSchwinger () auto & warpx = WarpX::GetInstance(); - AMREX_ALWAYS_ASSERT_WITH_MESSAGE(warpx.do_nodal || + WARPX_ALWAYS_ASSERT_WITH_MESSAGE(warpx.do_nodal || warpx.field_gathering_algo == GatheringAlgo::MomentumConserving, "ERROR: Schwinger process only implemented for warpx.do_nodal = 1" "or algo.field_gathering = momentum-conserving"); constexpr int level_0 = 0; - AMREX_ALWAYS_ASSERT_WITH_MESSAGE(warpx.maxLevel() == level_0, + WARPX_ALWAYS_ASSERT_WITH_MESSAGE(warpx.maxLevel() == level_0, "ERROR: Schwinger process not implemented with mesh refinement"); #ifdef WARPX_DIM_RZ @@ -1645,15 +1650,15 @@ void MultiParticleContainer::CheckQEDProductSpecies() for (int i=0; i<nspecies; i++){ const auto& pc = allcontainers[i]; if (pc->has_breit_wheeler()){ - AMREX_ALWAYS_ASSERT_WITH_MESSAGE( + WARPX_ALWAYS_ASSERT_WITH_MESSAGE( i != pc->m_qed_breit_wheeler_ele_product, "ERROR: Breit Wheeler product cannot be the same species"); - AMREX_ALWAYS_ASSERT_WITH_MESSAGE( + WARPX_ALWAYS_ASSERT_WITH_MESSAGE( i != pc->m_qed_breit_wheeler_pos_product, "ERROR: Breit Wheeler product cannot be the same species"); - AMREX_ALWAYS_ASSERT_WITH_MESSAGE( + WARPX_ALWAYS_ASSERT_WITH_MESSAGE( allcontainers[pc->m_qed_breit_wheeler_ele_product]-> AmIA<PhysicalSpecies::electron>() && @@ -1663,11 +1668,11 @@ void MultiParticleContainer::CheckQEDProductSpecies() } if(pc->has_quantum_sync()){ - AMREX_ALWAYS_ASSERT_WITH_MESSAGE( + WARPX_ALWAYS_ASSERT_WITH_MESSAGE( i != pc->m_qed_quantum_sync_phot_product, "ERROR: Quantum Synchrotron product cannot be the same species"); - AMREX_ALWAYS_ASSERT_WITH_MESSAGE( + WARPX_ALWAYS_ASSERT_WITH_MESSAGE( allcontainers[pc->m_qed_quantum_sync_phot_product]-> AmIA<PhysicalSpecies::photon>(), "ERROR: Quantum Synchrotron product species is of wrong type"); @@ -1675,7 +1680,7 @@ void MultiParticleContainer::CheckQEDProductSpecies() } if (m_do_qed_schwinger) { - AMREX_ALWAYS_ASSERT_WITH_MESSAGE( + WARPX_ALWAYS_ASSERT_WITH_MESSAGE( allcontainers[m_qed_schwinger_ele_product]-> AmIA<PhysicalSpecies::electron>() && |