From 8d890d18ad4cabd4dc434a14d1925f2e1e8f48ab Mon Sep 17 00:00:00 2001 From: MaxThevenet Date: Thu, 25 Apr 2019 17:39:00 -0700 Subject: add capability to have multiple antennas --- Source/Particles/MultiParticleContainer.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'Source/Particles/MultiParticleContainer.cpp') diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index 1b644b543..81a908179 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -14,7 +14,7 @@ MultiParticleContainer::MultiParticleContainer (AmrCore* amr_core) { ReadParameters(); - int n = WarpX::use_laser ? nspecies+1 : nspecies; + int n = nspecies + nlasers; allcontainers.resize(n); for (int i = 0; i < nspecies; ++i) { if (species_types[i] == PCTypes::Physical) { @@ -25,9 +25,11 @@ MultiParticleContainer::MultiParticleContainer (AmrCore* amr_core) } allcontainers[i]->deposit_on_main_grid = deposit_on_main_grid[i]; } - if (WarpX::use_laser) { - allcontainers[n-1].reset(new LaserParticleContainer(amr_core,n-1)); + + for (int i = nspecies; i < nspecies+nlasers; ++i) { + allcontainers[i].reset(new LaserParticleContainer(amr_core,n-1, lasers_names[i])); } + pc_tmp.reset(new PhysicalParticleContainer(amr_core)); } @@ -37,7 +39,7 @@ MultiParticleContainer::ReadParameters () static bool initialized = false; if (!initialized) { - ParmParse pp("particles"); + ParmParse pp("particles"); pp.query("nspecies", nspecies); BL_ASSERT(nspecies >= 0); @@ -70,8 +72,18 @@ MultiParticleContainer::ReadParameters () } } } + pp.query("use_fdtd_nci_corr", WarpX::use_fdtd_nci_corr); pp.query("l_lower_order_in_v", WarpX::l_lower_order_in_v); + + ParmParse ppl("lasers"); + ppl.query("nlasers", nlasers); + BL_ASSERT(nlasers >= 0); + if (nlasers > 0) { + ppl.getarr("lasers_names", lasers_names); + BL_ASSERT(lasers.size() == nlasers); + } + initialized = true; } } -- cgit v1.2.3 From a8b2f0c88434f08955399ca6dfdbc551979717f2 Mon Sep 17 00:00:00 2001 From: MaxThevenet Date: Thu, 25 Apr 2019 18:14:36 -0700 Subject: minor fixes --- Source/Particles/MultiParticleContainer.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'Source/Particles/MultiParticleContainer.cpp') diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index 81a908179..0a8eae8d4 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -14,8 +14,7 @@ MultiParticleContainer::MultiParticleContainer (AmrCore* amr_core) { ReadParameters(); - int n = nspecies + nlasers; - allcontainers.resize(n); + allcontainers.resize(nspecies + nlasers); for (int i = 0; i < nspecies; ++i) { if (species_types[i] == PCTypes::Physical) { allcontainers[i].reset(new PhysicalParticleContainer(amr_core, i, species_names[i])); @@ -25,9 +24,9 @@ MultiParticleContainer::MultiParticleContainer (AmrCore* amr_core) } allcontainers[i]->deposit_on_main_grid = deposit_on_main_grid[i]; } - + for (int i = nspecies; i < nspecies+nlasers; ++i) { - allcontainers[i].reset(new LaserParticleContainer(amr_core,n-1, lasers_names[i])); + allcontainers[i].reset(new LaserParticleContainer(amr_core,i, lasers_names[i-nspecies])); } pc_tmp.reset(new PhysicalParticleContainer(amr_core)); @@ -81,7 +80,7 @@ MultiParticleContainer::ReadParameters () BL_ASSERT(nlasers >= 0); if (nlasers > 0) { ppl.getarr("lasers_names", lasers_names); - BL_ASSERT(lasers.size() == nlasers); + BL_ASSERT(lasers_names.size() == nlasers); } initialized = true; -- cgit v1.2.3 From 8da49069958472c566f8ab1eedf17976b3a78b0f Mon Sep 17 00:00:00 2001 From: MaxThevenet Date: Fri, 26 Apr 2019 07:41:14 -0700 Subject: change ParmParse param from lasers to antennas --- Source/Particles/MultiParticleContainer.H | 4 ++-- Source/Particles/MultiParticleContainer.cpp | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'Source/Particles/MultiParticleContainer.cpp') diff --git a/Source/Particles/MultiParticleContainer.H b/Source/Particles/MultiParticleContainer.H index f3fd522a9..1f8a1b728 100644 --- a/Source/Particles/MultiParticleContainer.H +++ b/Source/Particles/MultiParticleContainer.H @@ -192,7 +192,7 @@ protected: std::vector species_names; - std::vector lasers_names; + std::vector antennas_names; std::vector deposit_on_main_grid; @@ -208,7 +208,7 @@ private: void ReadParameters (); // runtime parameters - int nlasers = 0; + int nantennas = 0; int nspecies = 1; // physical particles only. nspecies+nlasers == allcontainers.size(). }; #endif /*WARPX_ParticleContainer_H_*/ diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index 0a8eae8d4..e42fbb9db 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -14,7 +14,7 @@ MultiParticleContainer::MultiParticleContainer (AmrCore* amr_core) { ReadParameters(); - allcontainers.resize(nspecies + nlasers); + allcontainers.resize(nspecies + nantennas); for (int i = 0; i < nspecies; ++i) { if (species_types[i] == PCTypes::Physical) { allcontainers[i].reset(new PhysicalParticleContainer(amr_core, i, species_names[i])); @@ -25,8 +25,8 @@ MultiParticleContainer::MultiParticleContainer (AmrCore* amr_core) allcontainers[i]->deposit_on_main_grid = deposit_on_main_grid[i]; } - for (int i = nspecies; i < nspecies+nlasers; ++i) { - allcontainers[i].reset(new LaserParticleContainer(amr_core,i, lasers_names[i-nspecies])); + for (int i = nspecies; i < nspecies+nantennas; ++i) { + allcontainers[i].reset(new LaserParticleContainer(amr_core,i, antennas_names[i-nspecies])); } pc_tmp.reset(new PhysicalParticleContainer(amr_core)); @@ -75,12 +75,12 @@ MultiParticleContainer::ReadParameters () pp.query("use_fdtd_nci_corr", WarpX::use_fdtd_nci_corr); pp.query("l_lower_order_in_v", WarpX::l_lower_order_in_v); - ParmParse ppl("lasers"); - ppl.query("nlasers", nlasers); - BL_ASSERT(nlasers >= 0); - if (nlasers > 0) { - ppl.getarr("lasers_names", lasers_names); - BL_ASSERT(lasers_names.size() == nlasers); + ParmParse ppl("antennas"); + ppl.query("nantennas", nantennas); + BL_ASSERT(nantennas >= 0); + if (nantennas > 0) { + ppl.getarr("names", antennas_names); + BL_ASSERT(antennas_names.size() == nantennas); } initialized = true; -- cgit v1.2.3 From e743c0dc397e65a4823b947fb11c0c96f3d8c3e8 Mon Sep 17 00:00:00 2001 From: MaxThevenet Date: Fri, 26 Apr 2019 09:22:48 -0700 Subject: use laser instead of antenna --- Examples/Modules/boosted_diags/inputs.2d | 24 +++++++++---------- Examples/Modules/boosted_diags/inputs.3d | 24 +++++++++---------- Examples/Modules/laser_injection/inputs | 24 +++++++++---------- Examples/Modules/laser_injection/inputs.2d.rt | 24 +++++++++---------- Examples/Modules/laser_injection/inputs.rt | 24 +++++++++---------- .../laser_acceleration/inputs.2d | 4 ++-- .../laser_acceleration/inputs.3d | 24 +++++++++---------- .../Physics_applications/plasma_mirror/inputs.2d | 24 +++++++++---------- Examples/Tests/Larmor/inputs | 2 +- Examples/Tests/Larmor/inputs.ml | 2 +- Examples/Tests/PML/inputs2d | 24 +++++++++---------- Examples/Tests/gpu_test/inputs | 24 +++++++++---------- Examples/Tests/laser_on_fine/inputs | 28 +++++++++++----------- Examples/Tests/laser_on_fine/inputs.2d | 28 +++++++++++----------- Examples/Tests/self_force_test/inputs | 2 +- Source/Particles/MultiParticleContainer.H | 4 ++-- Source/Particles/MultiParticleContainer.cpp | 18 +++++++------- 17 files changed, 152 insertions(+), 152 deletions(-) (limited to 'Source/Particles/MultiParticleContainer.cpp') diff --git a/Examples/Modules/boosted_diags/inputs.2d b/Examples/Modules/boosted_diags/inputs.2d index 9178169dd..6315d34cb 100644 --- a/Examples/Modules/boosted_diags/inputs.2d +++ b/Examples/Modules/boosted_diags/inputs.2d @@ -87,15 +87,15 @@ ions.density = 1. ions.momentum_distribution_type = "constant" # Laser -antennas.nantennas = 1 -antennas.names = laser -laser.profile = Gaussian -laser.position = 0. 0. -1.e-6 # This point is on the laser plane -laser.direction = 0. 0. 1. # The plane normal direction -laser.polarization = 1. 0. 0. # The main polarization vector -laser.e_max = 8.e12 # Maximum amplitude of the laser field (in V/m) -laser.profile_waist = 5.e-5 # The waist of the laser (in meters) -laser.profile_duration = 16.7e-15 # The duration of the laser (in seconds) -laser.profile_t_peak = 33.4e-15 # The time at which the laser reaches its peak (in seconds) -laser.profile_focal_distance = 0.e-6 # Focal distance from the antenna (in meters) -laser.wavelength = 0.8e-6 # The wavelength of the laser (in meters) +lasers.nlasers = 1 +lasers.names = laser1 +laser1.profile = Gaussian +laser1.position = 0. 0. -1.e-6 # This point is on the laser plane +laser1.direction = 0. 0. 1. # The plane normal direction +laser1.polarization = 1. 0. 0. # The main polarization vector +laser1.e_max = 8.e12 # Maximum amplitude of the laser field (in V/m) +laser1.profile_waist = 5.e-5 # The waist of the laser (in meters) +laser1.profile_duration = 16.7e-15 # The duration of the laser (in seconds) +laser1.profile_t_peak = 33.4e-15 # The time at which the laser reaches its peak (in seconds) +laser1.profile_focal_distance = 0.e-6 # Focal distance from the antenna (in meters) +laser1.wavelength = 0.8e-6 # The wavelength of the laser (in meters) diff --git a/Examples/Modules/boosted_diags/inputs.3d b/Examples/Modules/boosted_diags/inputs.3d index 9178169dd..6315d34cb 100644 --- a/Examples/Modules/boosted_diags/inputs.3d +++ b/Examples/Modules/boosted_diags/inputs.3d @@ -87,15 +87,15 @@ ions.density = 1. ions.momentum_distribution_type = "constant" # Laser -antennas.nantennas = 1 -antennas.names = laser -laser.profile = Gaussian -laser.position = 0. 0. -1.e-6 # This point is on the laser plane -laser.direction = 0. 0. 1. # The plane normal direction -laser.polarization = 1. 0. 0. # The main polarization vector -laser.e_max = 8.e12 # Maximum amplitude of the laser field (in V/m) -laser.profile_waist = 5.e-5 # The waist of the laser (in meters) -laser.profile_duration = 16.7e-15 # The duration of the laser (in seconds) -laser.profile_t_peak = 33.4e-15 # The time at which the laser reaches its peak (in seconds) -laser.profile_focal_distance = 0.e-6 # Focal distance from the antenna (in meters) -laser.wavelength = 0.8e-6 # The wavelength of the laser (in meters) +lasers.nlasers = 1 +lasers.names = laser1 +laser1.profile = Gaussian +laser1.position = 0. 0. -1.e-6 # This point is on the laser plane +laser1.direction = 0. 0. 1. # The plane normal direction +laser1.polarization = 1. 0. 0. # The main polarization vector +laser1.e_max = 8.e12 # Maximum amplitude of the laser field (in V/m) +laser1.profile_waist = 5.e-5 # The waist of the laser (in meters) +laser1.profile_duration = 16.7e-15 # The duration of the laser (in seconds) +laser1.profile_t_peak = 33.4e-15 # The time at which the laser reaches its peak (in seconds) +laser1.profile_focal_distance = 0.e-6 # Focal distance from the antenna (in meters) +laser1.wavelength = 0.8e-6 # The wavelength of the laser (in meters) diff --git a/Examples/Modules/laser_injection/inputs b/Examples/Modules/laser_injection/inputs index 1b3cd49a3..4186f2682 100644 --- a/Examples/Modules/laser_injection/inputs +++ b/Examples/Modules/laser_injection/inputs @@ -30,18 +30,18 @@ algo.particle_pusher = 0 warpx.cfl = 1.0 # Laser -antennas.nantennas = 1 -antennas.names = laser -laser.profile = Gaussian -laser.position = 0. 0. 9.e-6 # This point is on the laser plane -laser.direction = 0. 0. 1. # The plane normal direction -laser.polarization = 0. 1. 0. # The main polarization vector -laser.e_max = 4.e12 # Maximum amplitude of the laser field (in V/m) -laser.profile_waist = 5.e-6 # The waist of the laser (in meters) -laser.profile_duration = 15.e-15 # The duration of the laser (in seconds) -laser.profile_t_peak = 30.e-15 # The time at which the laser reaches its peak (in seconds) -laser.profile_focal_distance = 100.e-6 # Focal distance from the antenna (in meters) -laser.wavelength = 0.8e-6 # The wavelength of the laser (in meters) +lasers.nlasers = 1 +lasers.names = laser1 +laser1.profile = Gaussian +laser1.position = 0. 0. 9.e-6 # This point is on the laser plane +laser1.direction = 0. 0. 1. # The plane normal direction +laser1.polarization = 0. 1. 0. # The main polarization vector +laser1.e_max = 4.e12 # Maximum amplitude of the laser field (in V/m) +laser1.profile_waist = 5.e-6 # The waist of the laser (in meters) +laser1.profile_duration = 15.e-15 # The duration of the laser (in seconds) +laser1.profile_t_peak = 30.e-15 # The time at which the laser reaches its peak (in seconds) +laser1.profile_focal_distance = 100.e-6 # Focal distance from the antenna (in meters) +laser1.wavelength = 0.8e-6 # The wavelength of the laser (in meters) # I/O amr.plot_int = 20 diff --git a/Examples/Modules/laser_injection/inputs.2d.rt b/Examples/Modules/laser_injection/inputs.2d.rt index 2d68f0320..1c40525f8 100644 --- a/Examples/Modules/laser_injection/inputs.2d.rt +++ b/Examples/Modules/laser_injection/inputs.2d.rt @@ -32,18 +32,18 @@ algo.particle_pusher = 0 warpx.cfl = 1.0 # Laser -antennas.nantennas = 1 -antennas.names = laser -laser.profile = Gaussian -laser.position = 9.e-6 0. 0. # This point is on the laser plane -laser.direction = 1. 0. 0. # The plane normal direction -laser.polarization = 0. 1. 0. # The main polarization vector -laser.e_max = 4.e12 # Maximum amplitude of the laser field (in V/m) -laser.wavelength = 0.8e-6 # The wavelength of the laser (in meters) -laser.profile_waist = 5.e-6 # The waist of the laser (in meters) -laser.profile_duration = 15.e-15 # The duration of the laser (in seconds) -laser.profile_t_peak = 30.e-15 # The time at which the laser reaches its peak (in seconds) -laser.profile_focal_distance = 100.e-6 # Focal distance from the antenna (in meters) +lasers.nlasers = 1 +lasers.names = laser1 +laser1.profile = Gaussian +laser1.position = 9.e-6 0. 0. # This point is on the laser plane +laser1.direction = 1. 0. 0. # The plane normal direction +laser1.polarization = 0. 1. 0. # The main polarization vector +laser1.e_max = 4.e12 # Maximum amplitude of the laser field (in V/m) +laser1.wavelength = 0.8e-6 # The wavelength of the laser (in meters) +laser1.profile_waist = 5.e-6 # The waist of the laser (in meters) +laser1.profile_duration = 15.e-15 # The duration of the laser (in seconds) +laser1.profile_t_peak = 30.e-15 # The time at which the laser reaches its peak (in seconds) +laser1.profile_focal_distance = 100.e-6 # Focal distance from the antenna (in meters) # I/O amr.plot_int = 20 diff --git a/Examples/Modules/laser_injection/inputs.rt b/Examples/Modules/laser_injection/inputs.rt index 071e33f86..b6f49d661 100644 --- a/Examples/Modules/laser_injection/inputs.rt +++ b/Examples/Modules/laser_injection/inputs.rt @@ -32,18 +32,18 @@ algo.particle_pusher = 0 warpx.cfl = 1.0 # Laser -antennas.nantennas = 1 -antennas.names = laser -laser.profile = Gaussian -laser.position = 0. 0. 9.e-6 # This point is on the laser plane -laser.direction = 0. 0. 1. # The plane normal direction -laser.polarization = 0. 1. 0. # The main polarization vector -laser.e_max = 4.e12 # Maximum amplitude of the laser field (in V/m) -laser.profile_waist = 5.e-6 # The waist of the laser (in meters) -laser.profile_duration = 15.e-15 # The duration of the laser (in seconds) -laser.profile_t_peak = 30.e-15 # The time at which the laser reaches its peak (in seconds) -laser.profile_focal_distance = 100.e-6 # Focal distance from the antenna (in meters) -laser.wavelength = 0.8e-6 # The wavelength of the laser (in meters) +lasers.nlasers = 1 +lasers.names = laser1 +laser1.profile = Gaussian +laser1.position = 0. 0. 9.e-6 # This point is on the laser plane +laser1.direction = 0. 0. 1. # The plane normal direction +laser1.polarization = 0. 1. 0. # The main polarization vector +laser1.e_max = 4.e12 # Maximum amplitude of the laser field (in V/m) +laser1.profile_waist = 5.e-6 # The waist of the laser (in meters) +laser1.profile_duration = 15.e-15 # The duration of the laser (in seconds) +laser1.profile_t_peak = 30.e-15 # The time at which the laser reaches its peak (in seconds) +laser1.profile_focal_distance = 100.e-6 # Focal distance from the antenna (in meters) +laser1.wavelength = 0.8e-6 # The wavelength of the laser (in meters) # I/O amr.plot_int = 20 diff --git a/Examples/Physics_applications/laser_acceleration/inputs.2d b/Examples/Physics_applications/laser_acceleration/inputs.2d index 9a90027a8..733ea6b86 100644 --- a/Examples/Physics_applications/laser_acceleration/inputs.2d +++ b/Examples/Physics_applications/laser_acceleration/inputs.2d @@ -82,8 +82,8 @@ warpx.injected_plasma_species = 0 ################################# ############ PLASMA ############# ################################# -lasers.nlasers = 1 -lasers.lasers_names = laser1 +lasers.nlasers = 1 +lasers.names = laser1 laser1.profile = Gaussian laser1.position = 0. 0. 9.e-6 # This point is on the laser plane laser1.direction = 0. 0. 1. # The plane normal direction diff --git a/Examples/Physics_applications/laser_acceleration/inputs.3d b/Examples/Physics_applications/laser_acceleration/inputs.3d index e9cfdf553..91837b23c 100644 --- a/Examples/Physics_applications/laser_acceleration/inputs.3d +++ b/Examples/Physics_applications/laser_acceleration/inputs.3d @@ -64,15 +64,15 @@ warpx.injected_plasma_species = 0 ################################# ############ PLASMA ############# ################################# -antennas.nantennas = 1 -antennas.names = laser -laser.profile = Gaussian -laser.position = 0. 0. 9.e-6 # This point is on the laser plane -laser.direction = 0. 0. 1. # The plane normal direction -laser.polarization = 0. 1. 0. # The main polarization vector -laser.e_max = 16.e12 # Maximum amplitude of the laser field (in V/m) -laser.profile_waist = 5.e-6 # The waist of the laser (in m) -laser.profile_duration = 15.e-15 # The duration of the laser (in s) -laser.profile_t_peak = 30.e-15 # Time at which the laser reaches its peak (in s) -laser.profile_focal_distance = 100.e-6 # Focal distance from the antenna (in m) -laser.wavelength = 0.8e-6 # The wavelength of the laser (in m) +lasers.nlasers = 1 +lasers.names = laser1 +laser1.profile = Gaussian +laser1.position = 0. 0. 9.e-6 # This point is on the laser plane +laser1.direction = 0. 0. 1. # The plane normal direction +laser1.polarization = 0. 1. 0. # The main polarization vector +laser1.e_max = 16.e12 # Maximum amplitude of the laser field (in V/m) +laser1.profile_waist = 5.e-6 # The waist of the laser (in m) +laser1.profile_duration = 15.e-15 # The duration of the laser (in s) +laser1.profile_t_peak = 30.e-15 # Time at which the laser reaches its peak (in s) +laser1.profile_focal_distance = 100.e-6 # Focal distance from the antenna (in m) +laser1.wavelength = 0.8e-6 # The wavelength of the laser (in m) diff --git a/Examples/Physics_applications/plasma_mirror/inputs.2d b/Examples/Physics_applications/plasma_mirror/inputs.2d index 6f94d1096..e16313b42 100644 --- a/Examples/Physics_applications/plasma_mirror/inputs.2d +++ b/Examples/Physics_applications/plasma_mirror/inputs.2d @@ -69,15 +69,15 @@ ions.density_function(x,y,z) = "(zzp)*(z species_names; - std::vector antennas_names; + std::vector lasers_names; std::vector deposit_on_main_grid; @@ -208,7 +208,7 @@ private: void ReadParameters (); // runtime parameters - int nantennas = 0; + int nlasers = 0; int nspecies = 1; // physical particles only. nspecies+nlasers == allcontainers.size(). }; #endif /*WARPX_ParticleContainer_H_*/ diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index e42fbb9db..f98a56568 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -14,7 +14,7 @@ MultiParticleContainer::MultiParticleContainer (AmrCore* amr_core) { ReadParameters(); - allcontainers.resize(nspecies + nantennas); + allcontainers.resize(nspecies + nlasers); for (int i = 0; i < nspecies; ++i) { if (species_types[i] == PCTypes::Physical) { allcontainers[i].reset(new PhysicalParticleContainer(amr_core, i, species_names[i])); @@ -25,8 +25,8 @@ MultiParticleContainer::MultiParticleContainer (AmrCore* amr_core) allcontainers[i]->deposit_on_main_grid = deposit_on_main_grid[i]; } - for (int i = nspecies; i < nspecies+nantennas; ++i) { - allcontainers[i].reset(new LaserParticleContainer(amr_core,i, antennas_names[i-nspecies])); + for (int i = nspecies; i < nspecies+nlasers; ++i) { + allcontainers[i].reset(new LaserParticleContainer(amr_core,i, lasers_names[i-nspecies])); } pc_tmp.reset(new PhysicalParticleContainer(amr_core)); @@ -75,12 +75,12 @@ MultiParticleContainer::ReadParameters () pp.query("use_fdtd_nci_corr", WarpX::use_fdtd_nci_corr); pp.query("l_lower_order_in_v", WarpX::l_lower_order_in_v); - ParmParse ppl("antennas"); - ppl.query("nantennas", nantennas); - BL_ASSERT(nantennas >= 0); - if (nantennas > 0) { - ppl.getarr("names", antennas_names); - BL_ASSERT(antennas_names.size() == nantennas); + ParmParse ppl("lasers"); + ppl.query("nlasers", nlasers); + BL_ASSERT(nlasers >= 0); + if (nlasers > 0) { + ppl.getarr("names", lasers_names); + BL_ASSERT(lasers_names.size() == nlasers); } initialized = true; -- cgit v1.2.3 From d479c907ed9965771fbd26913b6f383f6d83c2a7 Mon Sep 17 00:00:00 2001 From: MaxThevenet Date: Fri, 26 Apr 2019 12:01:04 -0700 Subject: typos and cleaning --- .../laser_acceleration/inputs.2d.boost | 24 ++++++++-------- Examples/Tests/Larmor/inputs | 3 -- Examples/Tests/Larmor/inputs.ml | 3 -- Examples/Tests/self_force_test/inputs | 3 -- GNUmakefile | 2 +- Source/Particles/MultiParticleContainer.cpp | 32 +++++++++++----------- 6 files changed, 29 insertions(+), 38 deletions(-) (limited to 'Source/Particles/MultiParticleContainer.cpp') diff --git a/Examples/Physics_applications/laser_acceleration/inputs.2d.boost b/Examples/Physics_applications/laser_acceleration/inputs.2d.boost index 1a6daf7d1..e07e3a87a 100644 --- a/Examples/Physics_applications/laser_acceleration/inputs.2d.boost +++ b/Examples/Physics_applications/laser_acceleration/inputs.2d.boost @@ -116,15 +116,15 @@ warpx.injected_plasma_species = 0 1 ################################# ############# LASER ############# ################################# -antennas.nantennas = 1 -antennas.names = laser -laser.profile = Gaussian -laser.position = 0. 0. -0.1e-6 # This point is on the laser plane -laser.direction = 0. 0. 1. # The plane normal direction -laser.polarization = 0. 1. 0. # The main polarization vector -laser.e_max = 2.e12 # Maximum amplitude of the laser field (in V/m) -laser.profile_waist = 45.e-6 # The waist of the laser (in meters) -laser.profile_duration = 20.e-15 # The duration of the laser (in seconds) -laser.profile_t_peak = 40.e-15 # The time at which the laser reaches its peak (in seconds) -laser.profile_focal_distance = 0.e-6 # Focal distance from the antenna (in meters) -laser.wavelength = 0.81e-6 # The wavelength of the laser (in meters) +lasers.nlasers = 1 +lasers.names = laser1 +laser1.profile = Gaussian +laser1.position = 0. 0. -0.1e-6 # This point is on the laser plane +laser1.direction = 0. 0. 1. # The plane normal direction +laser1.polarization = 0. 1. 0. # The main polarization vector +laser1.e_max = 2.e12 # Maximum amplitude of the laser field (in V/m) +laser1.profile_waist = 45.e-6 # The waist of the laser (in meters) +laser1.profile_duration = 20.e-15 # The duration of the laser (in seconds) +laser1.profile_t_peak = 40.e-15 # The time at which the laser reaches its peak (in seconds) +laser1.profile_focal_distance = 0.e-6 # Focal distance from the antenna (in meters) +laser1.wavelength = 0.81e-6 # The wavelength of the laser (in meters) diff --git a/Examples/Tests/Larmor/inputs b/Examples/Tests/Larmor/inputs index d335a1837..265a43383 100644 --- a/Examples/Tests/Larmor/inputs +++ b/Examples/Tests/Larmor/inputs @@ -82,7 +82,4 @@ warpx.do_moving_window = 0 # Particle Injection warpx.do_plasma_injection = 0 -# Laser -lasers.nlasers = 0 - warpx.do_dive_cleaning = 1 diff --git a/Examples/Tests/Larmor/inputs.ml b/Examples/Tests/Larmor/inputs.ml index b631d5bd5..9adb655fb 100644 --- a/Examples/Tests/Larmor/inputs.ml +++ b/Examples/Tests/Larmor/inputs.ml @@ -82,7 +82,4 @@ warpx.do_moving_window = 0 # Particle Injection warpx.do_plasma_injection = 0 -# Laser -lasers.nlasers = 0 - warpx.do_dive_cleaning = 1 diff --git a/Examples/Tests/self_force_test/inputs b/Examples/Tests/self_force_test/inputs index 80e947592..9da7d5675 100644 --- a/Examples/Tests/self_force_test/inputs +++ b/Examples/Tests/self_force_test/inputs @@ -72,6 +72,3 @@ warpx.do_moving_window = 0 # Particle Injection warpx.do_plasma_injection = 0 - -# Laser -lasers.nlasers = 0 diff --git a/GNUmakefile b/GNUmakefile index 14f1fea43..be8c80650 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -6,7 +6,7 @@ DEBUG = FALSE #DEBUG = TRUE #DIM = 2 -DIM = 2 +DIM = 3 COMP = gcc #COMP = intel diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index f98a56568..46d26152b 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -38,10 +38,10 @@ MultiParticleContainer::ReadParameters () static bool initialized = false; if (!initialized) { - ParmParse pp("particles"); + ParmParse pp("particles"); - pp.query("nspecies", nspecies); - BL_ASSERT(nspecies >= 0); + pp.query("nspecies", nspecies); + BL_ASSERT(nspecies >= 0); if (nspecies > 0) { pp.getarr("species_names", species_names); @@ -72,18 +72,18 @@ MultiParticleContainer::ReadParameters () } } - pp.query("use_fdtd_nci_corr", WarpX::use_fdtd_nci_corr); - pp.query("l_lower_order_in_v", WarpX::l_lower_order_in_v); + pp.query("use_fdtd_nci_corr", WarpX::use_fdtd_nci_corr); + pp.query("l_lower_order_in_v", WarpX::l_lower_order_in_v); - ParmParse ppl("lasers"); - ppl.query("nlasers", nlasers); - BL_ASSERT(nlasers >= 0); - if (nlasers > 0) { - ppl.getarr("names", lasers_names); - BL_ASSERT(lasers_names.size() == nlasers); - } + ParmParse ppl("lasers"); + ppl.query("nlasers", nlasers); + BL_ASSERT(nlasers >= 0); + if (nlasers > 0) { + ppl.getarr("names", lasers_names); + BL_ASSERT(lasers_names.size() == nlasers); + } - initialized = true; + initialized = true; } } @@ -91,7 +91,7 @@ void MultiParticleContainer::AllocData () { for (auto& pc : allcontainers) { - pc->AllocData(); + pc->AllocData(); } pc_tmp->AllocData(); } @@ -100,7 +100,7 @@ void MultiParticleContainer::InitData () { for (auto& pc : allcontainers) { - pc->InitData(); + pc->InitData(); } pc_tmp->InitData(); } @@ -112,7 +112,7 @@ MultiParticleContainer::FieldGatherES (const Vector > > >& masks) { for (auto& pc : allcontainers) { - pc->FieldGatherES(E, masks); + pc->FieldGatherES(E, masks); } } -- cgit v1.2.3 From c2b4a4e35febef5b6adc7d050a146ac1588cc4d7 Mon Sep 17 00:00:00 2001 From: MaxThevenet Date: Fri, 26 Apr 2019 15:22:25 -0700 Subject: fix indentation on LaserParticleContainer and MultiParticleContainer files --- Source/Laser/LaserParticleContainer.H | 8 +- Source/Laser/LaserParticleContainer.cpp | 368 ++++++++++++++-------------- Source/Particles/MultiParticleContainer.cpp | 55 ++--- 3 files changed, 212 insertions(+), 219 deletions(-) (limited to 'Source/Particles/MultiParticleContainer.cpp') diff --git a/Source/Laser/LaserParticleContainer.H b/Source/Laser/LaserParticleContainer.H index 5e45e3044..5dd94d0c7 100644 --- a/Source/Laser/LaserParticleContainer.H +++ b/Source/Laser/LaserParticleContainer.H @@ -20,14 +20,14 @@ public: #ifdef WARPX_DO_ELECTROSTATIC virtual void EvolveES (const amrex::Vector, 3> >& E, - amrex::Vector >& rho, + amrex::Vector >& rho, amrex::Real t, amrex::Real dt) { BL_ASSERT(false); } #endif // WARPX_DO_ELECTROSTATIC virtual void Evolve (int lev, - const amrex::MultiFab&, const amrex::MultiFab&, const amrex::MultiFab&, - const amrex::MultiFab&, const amrex::MultiFab&, const amrex::MultiFab&, - amrex::MultiFab& jx, amrex::MultiFab& jy, amrex::MultiFab& jz, + const amrex::MultiFab&, const amrex::MultiFab&, const amrex::MultiFab&, + const amrex::MultiFab&, const amrex::MultiFab&, const amrex::MultiFab&, + amrex::MultiFab& jx, amrex::MultiFab& jy, amrex::MultiFab& jz, amrex::MultiFab*, amrex::MultiFab*, amrex::MultiFab*, amrex::MultiFab* rho, amrex::MultiFab* crho, const amrex::MultiFab*, const amrex::MultiFab*, const amrex::MultiFab*, diff --git a/Source/Laser/LaserParticleContainer.cpp b/Source/Laser/LaserParticleContainer.cpp index 7ebb05e39..2b56c3cfd 100644 --- a/Source/Laser/LaserParticleContainer.cpp +++ b/Source/Laser/LaserParticleContainer.cpp @@ -15,7 +15,7 @@ namespace { Vector CrossProduct (const Vector& a, const Vector& b) { - return { a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0] }; + return { a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0] }; } } @@ -34,10 +34,10 @@ LaserParticleContainer::LaserParticleContainer (AmrCore* amr_core, int ispecies, std::transform(laser_type_s.begin(), laser_type_s.end(), laser_type_s.begin(), ::tolower); if (laser_type_s == "gaussian") { profile = laser_t::Gaussian; - } else if(laser_type_s == "harris") { - profile = laser_t::Harris; - } else if(laser_type_s == "parse_field_function") { - profile = laser_t::parse_field_function; + } else if(laser_type_s == "harris") { + profile = laser_t::Harris; + } else if(laser_type_s == "parse_field_function") { + profile = laser_t::parse_field_function; } else { amrex::Abort("Unknown laser type"); } @@ -52,91 +52,90 @@ LaserParticleContainer::LaserParticleContainer (AmrCore* amr_core, int ispecies, if ( profile == laser_t::Gaussian ) { // Parse the properties of the Gaussian profile - pp.get("profile_waist", profile_waist); - pp.get("profile_duration", profile_duration); - pp.get("profile_t_peak", profile_t_peak); - pp.get("profile_focal_distance", profile_focal_distance); - stc_direction = p_X; - pp.queryarr("stc_direction", stc_direction); - pp.query("zeta", zeta); - pp.query("beta", beta); - pp.query("phi2", phi2); + pp.get("profile_waist", profile_waist); + pp.get("profile_duration", profile_duration); + pp.get("profile_t_peak", profile_t_peak); + pp.get("profile_focal_distance", profile_focal_distance); + stc_direction = p_X; + pp.queryarr("stc_direction", stc_direction); + pp.query("zeta", zeta); + pp.query("beta", beta); + pp.query("phi2", phi2); } - if ( profile == laser_t::Harris ) { - // Parse the properties of the Harris profile - pp.get("profile_waist", profile_waist); - pp.get("profile_duration", profile_duration); - pp.get("profile_focal_distance", profile_focal_distance); - } + if ( profile == laser_t::Harris ) { + // Parse the properties of the Harris profile + pp.get("profile_waist", profile_waist); + pp.get("profile_duration", profile_duration); + pp.get("profile_focal_distance", profile_focal_distance); + } - if ( profile == laser_t::parse_field_function ) { - // Parse the properties of the parse_field_function profile - pp.get("field_function(X,Y,t)", field_function); - parser.define(field_function); - parser.registerVariables({"X","Y","t"}); - - ParmParse pp("my_constants"); - std::set symbols = parser.symbols(); - symbols.erase("X"); - symbols.erase("Y"); - symbols.erase("t"); // after removing variables, we are left with constants - for (auto it = symbols.begin(); it != symbols.end(); ) { - Real v; - if (pp.query(it->c_str(), v)) { - parser.setConstant(*it, v); - it = symbols.erase(it); - } else { - ++it; - } - } - for (auto const& s : symbols) { // make sure there no unknown symbols - amrex::Abort("Laser Profile: Unknown symbol "+s); + if ( profile == laser_t::parse_field_function ) { + // Parse the properties of the parse_field_function profile + pp.get("field_function(X,Y,t)", field_function); + parser.define(field_function); + parser.registerVariables({"X","Y","t"}); + + ParmParse pp("my_constants"); + std::set symbols = parser.symbols(); + symbols.erase("X"); + symbols.erase("Y"); + symbols.erase("t"); // after removing variables, we are left with constants + for (auto it = symbols.begin(); it != symbols.end(); ) { + Real v; + if (pp.query(it->c_str(), v)) { + parser.setConstant(*it, v); + it = symbols.erase(it); + } else { + ++it; } } + for (auto const& s : symbols) { // make sure there no unknown symbols + amrex::Abort("Laser Profile: Unknown symbol "+s); + } + } // Plane normal Real s = 1.0/std::sqrt(nvec[0]*nvec[0] + nvec[1]*nvec[1] + nvec[2]*nvec[2]); nvec = { nvec[0]*s, nvec[1]*s, nvec[2]*s }; - if (WarpX::gamma_boost > 1.) { - // Check that the laser direction is equal to the boost direction - AMREX_ALWAYS_ASSERT_WITH_MESSAGE( - nvec[0]*WarpX::boost_direction[0] - + nvec[1]*WarpX::boost_direction[1] - + nvec[2]*WarpX::boost_direction[2] - 1. < 1.e-12, - "The Lorentz boost should be in the same direction as the laser propagation"); - // Get the position of the plane, along the boost direction, in the lab frame - // and convert the position of the antenna to the boosted frame - Z0_lab = nvec[0]*position[0] + nvec[1]*position[1] + nvec[2]*position[2]; - Real Z0_boost = Z0_lab/WarpX::gamma_boost; - position[0] += (Z0_boost-Z0_lab)*nvec[0]; - position[1] += (Z0_boost-Z0_lab)*nvec[1]; - position[2] += (Z0_boost-Z0_lab)*nvec[2]; - } + if (WarpX::gamma_boost > 1.) { + // Check that the laser direction is equal to the boost direction + AMREX_ALWAYS_ASSERT_WITH_MESSAGE( nvec[0]*WarpX::boost_direction[0] + + nvec[1]*WarpX::boost_direction[1] + + nvec[2]*WarpX::boost_direction[2] - 1. < 1.e-12, + "The Lorentz boost should be in the same direction as the laser propagation"); + // Get the position of the plane, along the boost direction, in the lab frame + // and convert the position of the antenna to the boosted frame + Z0_lab = nvec[0]*position[0] + nvec[1]*position[1] + nvec[2]*position[2]; + Real Z0_boost = Z0_lab/WarpX::gamma_boost; + position[0] += (Z0_boost-Z0_lab)*nvec[0]; + position[1] += (Z0_boost-Z0_lab)*nvec[1]; + position[2] += (Z0_boost-Z0_lab)*nvec[2]; + } // The first polarization vector s = 1.0/std::sqrt(p_X[0]*p_X[0] + p_X[1]*p_X[1] + p_X[2]*p_X[2]); p_X = { p_X[0]*s, p_X[1]*s, p_X[2]*s }; Real dp = std::inner_product(nvec.begin(), nvec.end(), p_X.begin(), 0.0); - AMREX_ALWAYS_ASSERT_WITH_MESSAGE(std::abs(dp) < 1.0e-14, - "Laser plane vector is not perpendicular to the main polarization vector"); + AMREX_ALWAYS_ASSERT_WITH_MESSAGE(std::abs(dp) < 1.0e-14, + "Laser plane vector is not perpendicular to the main polarization vector"); p_Y = CrossProduct(nvec, p_X); // The second polarization vector s = 1.0/std::sqrt(stc_direction[0]*stc_direction[0] + stc_direction[1]*stc_direction[1] + stc_direction[2]*stc_direction[2]); stc_direction = { stc_direction[0]*s, stc_direction[1]*s, stc_direction[2]*s }; dp = std::inner_product(nvec.begin(), nvec.end(), stc_direction.begin(), 0.0); - AMREX_ALWAYS_ASSERT_WITH_MESSAGE(std::abs(dp) < 1.0e-14, - "stc_direction is not perpendicular to the laser plane vector"); + AMREX_ALWAYS_ASSERT_WITH_MESSAGE(std::abs(dp) < 1.0e-14, + "stc_direction is not perpendicular to the laser plane vector"); // Get angle between p_X and stc_direction // in 2d, stcs are in the simulation plane #if AMREX_SPACEDIM == 3 theta_stc = acos(stc_direction[0]*p_X[0] + - stc_direction[1]*p_X[1] + - stc_direction[2]*p_X[2]); + stc_direction[1]*p_X[1] + + stc_direction[2]*p_X[2]); #else theta_stc = 0.; #endif @@ -149,16 +148,16 @@ LaserParticleContainer::LaserParticleContainer (AmrCore* amr_core, int ispecies, u_Y = {0., 1., 0.}; #endif - prob_domain = Geometry::ProbDomain(); - { - Vector lo, hi; - if (pp.queryarr("prob_lo", lo)) { - prob_domain.setLo(lo); - } - if (pp.queryarr("prob_hi", hi)) { - prob_domain.setHi(hi); - } + prob_domain = Geometry::ProbDomain(); + { + Vector lo, hi; + if (pp.queryarr("prob_lo", lo)) { + prob_domain.setLo(lo); } + if (pp.queryarr("prob_hi", hi)) { + prob_domain.setHi(hi); + } + } } void @@ -176,60 +175,57 @@ LaserParticleContainer::InitData (int lev) ComputeSpacing(lev, S_X, S_Y); ComputeWeightMobility(S_X, S_Y); - auto Transform = [&](int i, int j) -> Vector - { + auto Transform = [&](int i, int j) -> Vector{ #if (AMREX_SPACEDIM == 3) - return { position[0] + (S_X*(i+0.5))*u_X[0] + (S_Y*(j+0.5))*u_Y[0], - position[1] + (S_X*(i+0.5))*u_X[1] + (S_Y*(j+0.5))*u_Y[1], - position[2] + (S_X*(i+0.5))*u_X[2] + (S_Y*(j+0.5))*u_Y[2] }; + return { position[0] + (S_X*(i+0.5))*u_X[0] + (S_Y*(j+0.5))*u_Y[0], + position[1] + (S_X*(i+0.5))*u_X[1] + (S_Y*(j+0.5))*u_Y[1], + position[2] + (S_X*(i+0.5))*u_X[2] + (S_Y*(j+0.5))*u_Y[2] }; #else - return { position[0] + (S_X*(i+0.5))*u_X[0], - 0.0, - position[2] + (S_X*(i+0.5))*u_X[2] }; + return { position[0] + (S_X*(i+0.5))*u_X[0], + 0.0, + position[2] + (S_X*(i+0.5))*u_X[2] }; #endif }; // Given the "lab" frame coordinates, return the real coordinates in the laser plane coordinates - auto InverseTransform = [&](const Vector& pos) -> Vector - { + auto InverseTransform = [&](const Vector& pos) -> Vector{ #if (AMREX_SPACEDIM == 3) - return {u_X[0]*(pos[0]-position[0])+u_X[1]*(pos[1]-position[1])+u_X[2]*(pos[2]-position[2]), - u_Y[0]*(pos[0]-position[0])+u_Y[1]*(pos[1]-position[1])+u_Y[2]*(pos[2]-position[2])}; + return {u_X[0]*(pos[0]-position[0])+u_X[1]*(pos[1]-position[1])+u_X[2]*(pos[2]-position[2]), + u_Y[0]*(pos[0]-position[0])+u_Y[1]*(pos[1]-position[1])+u_Y[2]*(pos[2]-position[2])}; #else - return {u_X[0]*(pos[0]-position[0])+u_X[2]*(pos[2]-position[2]), 0.0}; + return {u_X[0]*(pos[0]-position[0])+u_X[2]*(pos[2]-position[2]), 0.0}; #endif }; Vector plane_lo(2, std::numeric_limits::max()); Vector plane_hi(2, std::numeric_limits::min()); { - auto compute_min_max = [&](Real x, Real y, Real z) - { - const Vector& pos_plane = InverseTransform({x, y, z}); - int i = pos_plane[0]/S_X; - int j = pos_plane[1]/S_Y; - plane_lo[0] = std::min(plane_lo[0], i); - plane_lo[1] = std::min(plane_lo[1], j); - plane_hi[0] = std::max(plane_hi[0], i); - plane_hi[1] = std::max(plane_hi[1], j); - }; - - const Real* prob_lo = prob_domain.lo(); - const Real* prob_hi = prob_domain.hi(); + auto compute_min_max = [&](Real x, Real y, Real z){ + const Vector& pos_plane = InverseTransform({x, y, z}); + int i = pos_plane[0]/S_X; + int j = pos_plane[1]/S_Y; + plane_lo[0] = std::min(plane_lo[0], i); + plane_lo[1] = std::min(plane_lo[1], j); + plane_hi[0] = std::max(plane_hi[0], i); + plane_hi[1] = std::max(plane_hi[1], j); + }; + + const Real* prob_lo = prob_domain.lo(); + const Real* prob_hi = prob_domain.hi(); #if (AMREX_SPACEDIM == 3) - compute_min_max(prob_lo[0], prob_lo[1], prob_lo[2]); - compute_min_max(prob_hi[0], prob_lo[1], prob_lo[2]); - compute_min_max(prob_lo[0], prob_hi[1], prob_lo[2]); - compute_min_max(prob_hi[0], prob_hi[1], prob_lo[2]); - compute_min_max(prob_lo[0], prob_lo[1], prob_hi[2]); - compute_min_max(prob_hi[0], prob_lo[1], prob_hi[2]); - compute_min_max(prob_lo[0], prob_hi[1], prob_hi[2]); - compute_min_max(prob_hi[0], prob_hi[1], prob_hi[2]); + compute_min_max(prob_lo[0], prob_lo[1], prob_lo[2]); + compute_min_max(prob_hi[0], prob_lo[1], prob_lo[2]); + compute_min_max(prob_lo[0], prob_hi[1], prob_lo[2]); + compute_min_max(prob_hi[0], prob_hi[1], prob_lo[2]); + compute_min_max(prob_lo[0], prob_lo[1], prob_hi[2]); + compute_min_max(prob_hi[0], prob_lo[1], prob_hi[2]); + compute_min_max(prob_lo[0], prob_hi[1], prob_hi[2]); + compute_min_max(prob_hi[0], prob_hi[1], prob_hi[2]); #else - compute_min_max(prob_lo[0], 0.0, prob_lo[1]); - compute_min_max(prob_hi[0], 0.0, prob_lo[1]); - compute_min_max(prob_lo[0], 0.0, prob_hi[1]); - compute_min_max(prob_hi[0], 0.0, prob_hi[1]); + compute_min_max(prob_lo[0], 0.0, prob_lo[1]); + compute_min_max(prob_hi[0], 0.0, prob_lo[1]); + compute_min_max(prob_lo[0], 0.0, prob_hi[1]); + compute_min_max(prob_hi[0], 0.0, prob_hi[1]); #endif } @@ -270,22 +266,22 @@ LaserParticleContainer::InitData (int lev) const Box& bx = plane_ba[i]; for (IntVect cell = bx.smallEnd(); cell <= bx.bigEnd(); bx.next(cell)) { - const Vector& pos = Transform(cell[0], cell[1]); + const Vector& pos = Transform(cell[0], cell[1]); #if (AMREX_SPACEDIM == 3) - const Real* x = pos.dataPtr(); + const Real* x = pos.dataPtr(); #else - const Real x[2] = {pos[0], pos[2]}; + const Real x[2] = {pos[0], pos[2]}; #endif - if (prob_domain.contains(x)) - { - for (int k = 0; k<2; ++k) { - particle_x.push_back(pos[0]); - particle_y.push_back(pos[1]); - particle_z.push_back(pos[2]); - } - particle_w.push_back( weight); - particle_w.push_back(-weight); - } + if (prob_domain.contains(x)) + { + for (int k = 0; k<2; ++k) { + particle_x.push_back(pos[0]); + particle_y.push_back(pos[1]); + particle_z.push_back(pos[2]); + } + particle_w.push_back( weight); + particle_w.push_back(-weight); + } } } } @@ -297,15 +293,15 @@ LaserParticleContainer::InitData (int lev) if (Verbose()) amrex::Print() << "Adding laser particles\n"; AddNParticles(lev, np, particle_x.dataPtr(), particle_y.dataPtr(), particle_z.dataPtr(), - particle_ux.dataPtr(), particle_uy.dataPtr(), particle_uz.dataPtr(), - 1, particle_w.dataPtr(), 1); + particle_ux.dataPtr(), particle_uy.dataPtr(), particle_uz.dataPtr(), + 1, particle_w.dataPtr(), 1); } void LaserParticleContainer::Evolve (int lev, - const MultiFab&, const MultiFab&, const MultiFab&, - const MultiFab&, const MultiFab&, const MultiFab&, - MultiFab& jx, MultiFab& jy, MultiFab& jz, + const MultiFab&, const MultiFab&, const MultiFab&, + const MultiFab&, const MultiFab&, const MultiFab&, + MultiFab& jx, MultiFab& jy, MultiFab& jz, MultiFab* cjx, MultiFab* cjy, MultiFab* cjz, MultiFab* rho, MultiFab* crho, const MultiFab*, const MultiFab*, const MultiFab*, @@ -335,18 +331,18 @@ LaserParticleContainer::Evolve (int lev, #endif { #ifdef _OPENMP - int thread_num = omp_get_thread_num(); + int thread_num = omp_get_thread_num(); #else - int thread_num = 0; + int thread_num = 0; #endif Cuda::ManagedDeviceVector plane_Xp, plane_Yp, amplitude_E; for (WarpXParIter pti(*this, lev); pti.isValid(); ++pti) - { + { Real wt = amrex::second(); - const Box& box = pti.validbox(); + const Box& box = pti.validbox(); auto& attribs = pti.GetAttribs(); @@ -355,80 +351,80 @@ LaserParticleContainer::Evolve (int lev, auto& uyp = attribs[PIdx::uy]; auto& uzp = attribs[PIdx::uz]; - const long np = pti.numParticles(); + const long np = pti.numParticles(); // For now, laser particles do not take the current buffers into account const long np_current = np; m_giv[thread_num].resize(np); - plane_Xp.resize(np); - plane_Yp.resize(np); + plane_Xp.resize(np); + plane_Yp.resize(np); amplitude_E.resize(np); - // - // copy data from particle container to temp arrays - // - BL_PROFILE_VAR_START(blp_copy); + // + // copy data from particle container to temp arrays + // + BL_PROFILE_VAR_START(blp_copy); pti.GetPosition(m_xp[thread_num], m_yp[thread_num], m_zp[thread_num]); - BL_PROFILE_VAR_STOP(blp_copy); + BL_PROFILE_VAR_STOP(blp_copy); if (rho) DepositCharge(pti, wp, rho, crho, 0, np_current, np, thread_num, lev); - // - // Particle Push - // - BL_PROFILE_VAR_START(blp_pxr_pp); + // + // Particle Push + // + BL_PROFILE_VAR_START(blp_pxr_pp); // Find the coordinates of the particles in the emission plane calculate_laser_plane_coordinates( &np, - m_xp[thread_num].dataPtr(), - m_yp[thread_num].dataPtr(), - m_zp[thread_num].dataPtr(), - plane_Xp.dataPtr(), plane_Yp.dataPtr(), - &u_X[0], &u_X[1], &u_X[2], &u_Y[0], &u_Y[1], &u_Y[2], - &position[0], &position[1], &position[2] ); - // Calculate the laser amplitude to be emitted, - // at the position of the emission plane - if (profile == laser_t::Gaussian) { - warpx_gaussian_laser( &np, plane_Xp.dataPtr(), plane_Yp.dataPtr(), - &t_lab, &wavelength, &e_max, &profile_waist, &profile_duration, - &profile_t_peak, &profile_focal_distance, amplitude_E.dataPtr(), - &zeta, &beta, &phi2, &theta_stc ); - } + m_xp[thread_num].dataPtr(), + m_yp[thread_num].dataPtr(), + m_zp[thread_num].dataPtr(), + plane_Xp.dataPtr(), plane_Yp.dataPtr(), + &u_X[0], &u_X[1], &u_X[2], &u_Y[0], &u_Y[1], &u_Y[2], + &position[0], &position[1], &position[2] ); + // Calculate the laser amplitude to be emitted, + // at the position of the emission plane + if (profile == laser_t::Gaussian) { + warpx_gaussian_laser( &np, plane_Xp.dataPtr(), plane_Yp.dataPtr(), + &t_lab, &wavelength, &e_max, &profile_waist, &profile_duration, + &profile_t_peak, &profile_focal_distance, amplitude_E.dataPtr(), + &zeta, &beta, &phi2, &theta_stc ); + } if (profile == laser_t::Harris) { - warpx_harris_laser( &np, plane_Xp.dataPtr(), plane_Yp.dataPtr(), + warpx_harris_laser( &np, plane_Xp.dataPtr(), plane_Yp.dataPtr(), &t, &wavelength, &e_max, &profile_waist, &profile_duration, &profile_focal_distance, amplitude_E.dataPtr() ); - } + } if (profile == laser_t::parse_field_function) { for (int i = 0; i < np; ++i) { amplitude_E[i] = parser.eval(plane_Xp[i], plane_Yp[i], t); } - } - // Calculate the corresponding momentum and position for the particles + } + // Calculate the corresponding momentum and position for the particles update_laser_particle( - &np, - m_xp[thread_num].dataPtr(), - m_yp[thread_num].dataPtr(), - m_zp[thread_num].dataPtr(), - uxp.dataPtr(), uyp.dataPtr(), uzp.dataPtr(), - m_giv[thread_num].dataPtr(), - wp.dataPtr(), amplitude_E.dataPtr(), &p_X[0], &p_X[1], &p_X[2], - &nvec[0], &nvec[1], &nvec[2], &mobility, &dt, - &PhysConst::c, &WarpX::beta_boost, &WarpX::gamma_boost ); - BL_PROFILE_VAR_STOP(blp_pxr_pp); - - // - // Current Deposition - // + &np, + m_xp[thread_num].dataPtr(), + m_yp[thread_num].dataPtr(), + m_zp[thread_num].dataPtr(), + uxp.dataPtr(), uyp.dataPtr(), uzp.dataPtr(), + m_giv[thread_num].dataPtr(), + wp.dataPtr(), amplitude_E.dataPtr(), &p_X[0], &p_X[1], &p_X[2], + &nvec[0], &nvec[1], &nvec[2], &mobility, &dt, + &PhysConst::c, &WarpX::beta_boost, &WarpX::gamma_boost ); + BL_PROFILE_VAR_STOP(blp_pxr_pp); + + // + // Current Deposition + // DepositCurrent(pti, wp, uxp, uyp, uzp, jx, jy, jz, cjx, cjy, cjz, np_current, np, thread_num, lev, dt); - // - // copy particle data back - // - BL_PROFILE_VAR_START(blp_copy); + // + // copy particle data back + // + BL_PROFILE_VAR_START(blp_copy); pti.SetPosition(m_xp[thread_num], m_yp[thread_num], m_zp[thread_num]); BL_PROFILE_VAR_STOP(blp_copy); @@ -443,7 +439,7 @@ LaserParticleContainer::Evolve (int lev, costfab->plus(wt, work_box); }); } - } + } } } @@ -464,14 +460,14 @@ LaserParticleContainer::ComputeSpacing (int lev, Real& Sx, Real& Sy) const const Real eps = dx[0]*1.e-50; #if (AMREX_SPACEDIM == 3) Sx = std::min(std::min(dx[0]/(std::abs(u_X[0])+eps), - dx[1]/(std::abs(u_X[1])+eps)), - dx[2]/(std::abs(u_X[2])+eps)); + dx[1]/(std::abs(u_X[1])+eps)), + dx[2]/(std::abs(u_X[2])+eps)); Sy = std::min(std::min(dx[0]/(std::abs(u_Y[0])+eps), - dx[1]/(std::abs(u_Y[1])+eps)), - dx[2]/(std::abs(u_Y[2])+eps)); + dx[1]/(std::abs(u_Y[1])+eps)), + dx[2]/(std::abs(u_Y[2])+eps)); #else Sx = std::min(dx[0]/(std::abs(u_X[0])+eps), - dx[2]/(std::abs(u_X[2])+eps)); + dx[2]/(std::abs(u_X[2])+eps)); Sy = 1.0; #endif } diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index 46d26152b..0485f7b8f 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -130,7 +130,7 @@ MultiParticleContainer::EvolveES (const VectorEvolveES(E, rho, t, dt); + pc->EvolveES(E, rho, t, dt); } for (unsigned i = 0; i < nlevs; i++) { @@ -159,7 +159,7 @@ MultiParticleContainer::Evolve (int lev, if (rho) rho->setVal(0.0); for (auto& pc : allcontainers) { pc->Evolve(lev, Ex, Ey, Ez, Bx, By, Bz, jx, jy, jz, cjx, cjy, cjz, - rho, cEx, cEy, cEz, cBx, cBy, cBz, t, dt); + rho, cEx, cEy, cEz, cBx, cBy, cBz, t, dt); } } @@ -167,7 +167,7 @@ void MultiParticleContainer::PushXES (Real dt) { for (auto& pc : allcontainers) { - pc->PushXES(dt); + pc->PushXES(dt); } } @@ -183,7 +183,7 @@ DepositCharge (Vector >& rho, bool local) } for (unsigned i = 0, n = allcontainers.size(); i < n; ++i) { - allcontainers[i]->DepositCharge(rho, true); + allcontainers[i]->DepositCharge(rho, true); } if (!local) { @@ -212,7 +212,7 @@ MultiParticleContainer::FieldGather (int lev, const MultiFab& Bx, const MultiFab& By, const MultiFab& Bz) { for (auto& pc : allcontainers) { - pc->FieldGather(lev, Ex, Ey, Ez, Bx, By, Bz); + pc->FieldGather(lev, Ex, Ey, Ez, Bx, By, Bz); } } @@ -237,7 +237,7 @@ MultiParticleContainer::Evolve (int lev, if (crho) crho->setVal(0.0); for (auto& pc : allcontainers) { pc->Evolve(lev, Ex, Ey, Ez, Bx, By, Bz, jx, jy, jz, cjx, cjy, cjz, - rho, crho, cEx, cEy, cEz, cBx, cBy, cBz, t, dt); + rho, crho, cEx, cEy, cEz, cBx, cBy, cBz, t, dt); } } @@ -245,7 +245,7 @@ void MultiParticleContainer::PushX (Real dt) { for (auto& pc : allcontainers) { - pc->PushX(dt); + pc->PushX(dt); } } @@ -255,7 +255,7 @@ MultiParticleContainer::PushP (int lev, Real dt, const MultiFab& Bx, const MultiFab& By, const MultiFab& Bz) { for (auto& pc : allcontainers) { - pc->PushP(lev, dt, Ex, Ey, Ez, Bx, By, Bz); + pc->PushP(lev, dt, Ex, Ey, Ez, Bx, By, Bz); } } @@ -264,12 +264,12 @@ MultiParticleContainer::GetChargeDensity (int lev, bool local) { std::unique_ptr rho = allcontainers[0]->GetChargeDensity(lev, true); for (unsigned i = 1, n = allcontainers.size(); i < n; ++i) { - std::unique_ptr rhoi = allcontainers[i]->GetChargeDensity(lev, true); - MultiFab::Add(*rho, *rhoi, 0, 0, 1, rho->nGrow()); + std::unique_ptr rhoi = allcontainers[i]->GetChargeDensity(lev, true); + MultiFab::Add(*rho, *rhoi, 0, 0, 1, rho->nGrow()); } if (!local) { - const Geometry& gm = allcontainers[0]->Geom(lev); - rho->SumBoundary(gm.periodicity()); + const Geometry& gm = allcontainers[0]->Geom(lev); + rho->SumBoundary(gm.periodicity()); } return rho; } @@ -278,7 +278,7 @@ void MultiParticleContainer::SortParticlesByCell () { for (auto& pc : allcontainers) { - pc->SortParticlesByCell(); + pc->SortParticlesByCell(); } } @@ -286,7 +286,7 @@ void MultiParticleContainer::Redistribute () { for (auto& pc : allcontainers) { - pc->Redistribute(); + pc->Redistribute(); } } @@ -294,7 +294,7 @@ void MultiParticleContainer::RedistributeLocal (const int num_ghost) { for (auto& pc : allcontainers) { - pc->Redistribute(0, 0, 0, num_ghost); + pc->Redistribute(0, 0, 0, num_ghost); } } @@ -304,10 +304,10 @@ MultiParticleContainer::NumberOfParticlesInGrid(int lev) const const bool only_valid=true, only_local=true; Vector r = allcontainers[0]->NumberOfParticlesInGrid(lev,only_valid,only_local); for (unsigned i = 1, n = allcontainers.size(); i < n; ++i) { - const auto& ri = allcontainers[i]->NumberOfParticlesInGrid(lev,only_valid,only_local); - for (unsigned j=0, m=ri.size(); jNumberOfParticlesInGrid(lev,only_valid,only_local); + for (unsigned j=0, m=ri.size(); jIncrement(mf,lev); + pc->Increment(mf,lev); } } @@ -325,7 +325,7 @@ void MultiParticleContainer::SetParticleBoxArray (int lev, BoxArray& new_ba) { for (auto& pc : allcontainers) { - pc->SetParticleBoxArray(lev,new_ba); + pc->SetParticleBoxArray(lev,new_ba); } } @@ -333,7 +333,7 @@ void MultiParticleContainer::SetParticleDistributionMap (int lev, DistributionMapping& new_dm) { for (auto& pc : allcontainers) { - pc->SetParticleDistributionMap(lev,new_dm); + pc->SetParticleDistributionMap(lev,new_dm); } } @@ -341,7 +341,7 @@ void MultiParticleContainer::PostRestart () { for (auto& pc : allcontainers) { - pc->PostRestart(); + pc->PostRestart(); } pc_tmp->PostRestart(); } @@ -357,16 +357,13 @@ MultiParticleContainer BL_PROFILE("MultiParticleContainer::GetLabFrameData"); - for (int i = 0; i < nspecies; ++i) - { + for (int i = 0; i < nspecies; ++i){ WarpXParticleContainer* pc = allcontainers[i].get(); WarpXParticleContainer::DiagnosticParticles diagnostic_particles; pc->GetParticleSlice(direction, z_old, z_new, t_boost, t_lab, dt, diagnostic_particles); - for (int lev = 0; lev <= pc->finestLevel(); ++lev) - { - for (auto it = diagnostic_particles[lev].begin(); it != diagnostic_particles[lev].end(); ++it) - { + for (int lev = 0; lev <= pc->finestLevel(); ++lev){ + for (auto it = diagnostic_particles[lev].begin(); it != diagnostic_particles[lev].end(); ++it){ parts[i].GetRealData(DiagIdx::w).insert( parts[i].GetRealData(DiagIdx::w ).end(), it->second.GetRealData(DiagIdx::w ).begin(), it->second.GetRealData(DiagIdx::w ).end()); -- cgit v1.2.3