From 2200d9e34f16dae242bf0d4b6f7a335373d9e2b0 Mon Sep 17 00:00:00 2001 From: Lorenzo Giacomel Date: Mon, 22 Nov 2021 19:14:11 +0100 Subject: [PATCH 1/7] Aborting if particle_shape!=1 with EB --- Source/WarpX.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index f923c912138..5d2f0944962 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -959,6 +959,12 @@ WarpX::ReadParameters () noy = particle_shape; noz = particle_shape; } +#ifdef AMREX_USE_EB + if (particle_shape != 1) + { + amrex::Abort("\nalgo.particle_shape can only be 1 with embedded boundaries"); + } +#endif } if ((maxLevel() > 0) && (particle_shape > 1) && (do_pml_j_damping == 1)) From 3b867cc2e4db2a5221018a6a328c2b40041d85d0 Mon Sep 17 00:00:00 2001 From: Lorenzo Giacomel Date: Mon, 22 Nov 2021 21:11:05 +0100 Subject: [PATCH 2/7] Throw warning instead of aborting --- Source/WarpX.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index 5d2f0944962..ef74331083e 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -960,9 +960,11 @@ WarpX::ReadParameters () noz = particle_shape; } #ifdef AMREX_USE_EB - if (particle_shape != 1) + if (particle_shape > 1) { - amrex::Abort("\nalgo.particle_shape can only be 1 with embedded boundaries"); + this->RecordWarning("Particles", + "when algo.particle_shape > 1, numerical artifacts will be present when\n" + "particles are close to embedded boundaries"); } #endif } From 8faaab757198f3f8fd53da2e27cbdcf9b8492033 Mon Sep 17 00:00:00 2001 From: Lorenzo Giacomel Date: Tue, 23 Nov 2021 10:04:28 +0100 Subject: [PATCH 3/7] Checking at runtime if EB is initialized --- Source/Initialization/WarpXInitData.cpp | 11 +++++++++++ Source/WarpX.cpp | 8 -------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Source/Initialization/WarpXInitData.cpp b/Source/Initialization/WarpXInitData.cpp index f92fe80aaa2..c3ba14d2d98 100644 --- a/Source/Initialization/WarpXInitData.cpp +++ b/Source/Initialization/WarpXInitData.cpp @@ -865,6 +865,17 @@ void WarpX::CheckGuardCells(amrex::MultiFab const& mf) void WarpX::InitializeEBGridData(int lev) { if(lev==maxLevel()) { + + //Throw a warning if EB is on and particle_shape > 1 + bool flag_eb_on = not fieldEBFactory(lev).isAllRegular(); + + if ((nox > 1 or noy > 1 or noz > 1) and flag_eb_on) + { + this->RecordWarning("Particles", + "when algo.particle_shape > 1, numerical artifacts will be present when\n" + "particles are close to embedded boundaries"); + } + if (WarpX::maxwell_solver_id == MaxwellSolverAlgo::Yee || WarpX::maxwell_solver_id == MaxwellSolverAlgo::CKC || WarpX::maxwell_solver_id == MaxwellSolverAlgo::ECT) { diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index ef74331083e..f923c912138 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -959,14 +959,6 @@ WarpX::ReadParameters () noy = particle_shape; noz = particle_shape; } -#ifdef AMREX_USE_EB - if (particle_shape > 1) - { - this->RecordWarning("Particles", - "when algo.particle_shape > 1, numerical artifacts will be present when\n" - "particles are close to embedded boundaries"); - } -#endif } if ((maxLevel() > 0) && (particle_shape > 1) && (do_pml_j_damping == 1)) From 865e9f86d6117fd23c9578243818aede8df27197 Mon Sep 17 00:00:00 2001 From: Lorenzo Giacomel Date: Tue, 23 Nov 2021 11:49:44 +0100 Subject: [PATCH 4/7] Added missing preprocessor directive --- Source/Initialization/WarpXInitData.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Initialization/WarpXInitData.cpp b/Source/Initialization/WarpXInitData.cpp index c3ba14d2d98..ea6dd8590ed 100644 --- a/Source/Initialization/WarpXInitData.cpp +++ b/Source/Initialization/WarpXInitData.cpp @@ -864,6 +864,7 @@ void WarpX::CheckGuardCells(amrex::MultiFab const& mf) void WarpX::InitializeEBGridData(int lev) { +#ifdef AMREX_USE_EB if(lev==maxLevel()) { //Throw a warning if EB is on and particle_shape > 1 @@ -911,4 +912,5 @@ void WarpX::InitializeEBGridData(int lev) ComputeDistanceToEB(); } +#endif } From 6fd84d8f8de1f1498fedd61a356332b6400cd048 Mon Sep 17 00:00:00 2001 From: Lorenzo Giacomel Date: Tue, 23 Nov 2021 14:07:13 +0100 Subject: [PATCH 5/7] Ignoring an unused variable --- Source/Initialization/WarpXInitData.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Initialization/WarpXInitData.cpp b/Source/Initialization/WarpXInitData.cpp index ea6dd8590ed..c8d20e9d3a3 100644 --- a/Source/Initialization/WarpXInitData.cpp +++ b/Source/Initialization/WarpXInitData.cpp @@ -912,5 +912,7 @@ void WarpX::InitializeEBGridData(int lev) ComputeDistanceToEB(); } +#elif + amrex::ignore_unused(lev); #endif } From 50e2ec3ff3b6b5155a6ea223726f1c842dfdeffc Mon Sep 17 00:00:00 2001 From: Lorenzo Giacomel Date: Tue, 23 Nov 2021 14:26:57 +0100 Subject: [PATCH 6/7] Fix typo --- Source/Initialization/WarpXInitData.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Initialization/WarpXInitData.cpp b/Source/Initialization/WarpXInitData.cpp index c8d20e9d3a3..978c14c596e 100644 --- a/Source/Initialization/WarpXInitData.cpp +++ b/Source/Initialization/WarpXInitData.cpp @@ -912,7 +912,7 @@ void WarpX::InitializeEBGridData(int lev) ComputeDistanceToEB(); } -#elif +#else amrex::ignore_unused(lev); #endif } From 0dfa7aadc176bddfd622cb6300c0864c24f8c97f Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Wed, 24 Nov 2021 08:30:13 -0800 Subject: [PATCH 7/7] Improve style --- Source/Initialization/WarpXInitData.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Initialization/WarpXInitData.cpp b/Source/Initialization/WarpXInitData.cpp index 978c14c596e..603718f3112 100644 --- a/Source/Initialization/WarpXInitData.cpp +++ b/Source/Initialization/WarpXInitData.cpp @@ -862,12 +862,12 @@ void WarpX::CheckGuardCells(amrex::MultiFab const& mf) } } -void WarpX::InitializeEBGridData(int lev) +void WarpX::InitializeEBGridData (int lev) { #ifdef AMREX_USE_EB - if(lev==maxLevel()) { + if (lev == maxLevel()) { - //Throw a warning if EB is on and particle_shape > 1 + // Throw a warning if EB is on and particle_shape > 1 bool flag_eb_on = not fieldEBFactory(lev).isAllRegular(); if ((nox > 1 or noy > 1 or noz > 1) and flag_eb_on)