From eee063ceca2707824b63ac0966acf265c2b67457 Mon Sep 17 00:00:00 2001 From: Diana Amorim Date: Tue, 9 Jul 2019 16:22:09 -0700 Subject: Changed warpx_copy_attribs function from F90 to CPP inside PhysicalParticleContainer class. --- Source/Particles/PhysicalParticleContainer.cpp | 56 ++++++++++++++++++-------- 1 file changed, 39 insertions(+), 17 deletions(-) (limited to 'Source/Particles/PhysicalParticleContainer.cpp') diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index 43b46ec49..69c27cd21 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -1729,7 +1729,13 @@ PhysicalParticleContainer::PushPX(WarpXParIter& pti, Real dt) { - // This wraps the call to warpx_particle_pusher so that inheritors can modify the call. + if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) + { + warpx_copy_attribs(pti, xp.dataPtr(), yp.dataPtr(), zp.dataPtr()); + } + + // The following attributes should be included in CPP version of warpx_particle_pusher + // This wraps the call to warpx_particle_pusher so that inheritors can modify the call. auto& attribs = pti.GetAttribs(); auto& uxp = attribs[PIdx::ux]; auto& uyp = attribs[PIdx::uy]; @@ -1741,22 +1747,7 @@ PhysicalParticleContainer::PushPX(WarpXParIter& pti, auto& Byp = attribs[PIdx::By]; auto& Bzp = attribs[PIdx::Bz]; const long np = pti.numParticles(); - - if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) - { - auto& xpold = pti.GetAttribs(particle_comps["xold"]); - auto& ypold = pti.GetAttribs(particle_comps["yold"]); - auto& zpold = pti.GetAttribs(particle_comps["zold"]); - auto& uxpold = pti.GetAttribs(particle_comps["uxold"]); - auto& uypold = pti.GetAttribs(particle_comps["uyold"]); - auto& uzpold = pti.GetAttribs(particle_comps["uzold"]); - - warpx_copy_attribs(&np, xp.dataPtr(), yp.dataPtr(), zp.dataPtr(), - uxp.dataPtr(), uyp.dataPtr(), uzp.dataPtr(), - xpold.dataPtr(), ypold.dataPtr(), zpold.dataPtr(), - uxpold.dataPtr(), uypold.dataPtr(), uzpold.dataPtr()); - } - + warpx_particle_pusher(&np, xp.dataPtr(), yp.dataPtr(), @@ -1870,6 +1861,37 @@ PhysicalParticleContainer::PushP (int lev, Real dt, } } +void PhysicalParticleContainer::warpx_copy_attribs(WarpXParIter& pti,const amrex::Real* xp, + const amrex::Real* yp, const amrex::Real* zp) +{ + auto& attribs = pti.GetAttribs(); + + Real* AMREX_RESTRICT uxp = attribs[PIdx::ux].dataPtr(); + Real* AMREX_RESTRICT uyp = attribs[PIdx::uy].dataPtr(); + Real* AMREX_RESTRICT uzp = attribs[PIdx::uz].dataPtr(); + + Real* AMREX_RESTRICT xpold = attribs[PIdx::nattribs].dataPtr(); + Real* AMREX_RESTRICT ypold = attribs[PIdx::nattribs+1].dataPtr(); + Real* AMREX_RESTRICT zpold = attribs[PIdx::nattribs+2].dataPtr(); + Real* AMREX_RESTRICT uxpold = attribs[PIdx::nattribs+3].dataPtr(); + Real* AMREX_RESTRICT uypold = attribs[PIdx::nattribs+4].dataPtr(); + Real* AMREX_RESTRICT uzpold = attribs[PIdx::nattribs+5].dataPtr(); + + const long np = pti.numParticles(); + + ParallelFor( np, + [=] AMREX_GPU_DEVICE (long i) { + xpold[i]=xp[i]; + ypold[i]=yp[i]; + zpold[i]=zp[i]; + + uxpold[i]=uxp[i]; + uypold[i]=uyp[i]; + uzpold[i]=uzp[i]; + } + ); +} + void PhysicalParticleContainer::GetParticleSlice(const int direction, const Real z_old, const Real z_new, const Real t_boost, const Real t_lab, const Real dt, -- cgit v1.2.3 From 9957d80bce7bf685f96ccffe15b420b2216d7f11 Mon Sep 17 00:00:00 2001 From: Diana Amorim Date: Tue, 9 Jul 2019 18:06:24 -0700 Subject: Attempt to fix segfault issue - Unsuccessful. Tested alternatives to . --- .DS_Store | Bin 6148 -> 0 bytes .gitignore | 1 + Source/Particles/PhysicalParticleContainer.cpp | 22 ++++++++++++---------- 3 files changed, 13 insertions(+), 10 deletions(-) delete mode 100644 .DS_Store (limited to 'Source/Particles/PhysicalParticleContainer.cpp') diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index b96111fac..000000000 Binary files a/.DS_Store and /dev/null differ diff --git a/.gitignore b/.gitignore index 02bd9eafa..13147b8da 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.DS_Store plt* chk* main?d.*.ex diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index 69c27cd21..e8654e573 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -1866,20 +1866,22 @@ void PhysicalParticleContainer::warpx_copy_attribs(WarpXParIter& pti,const amrex { auto& attribs = pti.GetAttribs(); - Real* AMREX_RESTRICT uxp = attribs[PIdx::ux].dataPtr(); - Real* AMREX_RESTRICT uyp = attribs[PIdx::uy].dataPtr(); - Real* AMREX_RESTRICT uzp = attribs[PIdx::uz].dataPtr(); + //Real* AMREX_RESTRICT - Real* AMREX_RESTRICT xpold = attribs[PIdx::nattribs].dataPtr(); - Real* AMREX_RESTRICT ypold = attribs[PIdx::nattribs+1].dataPtr(); - Real* AMREX_RESTRICT zpold = attribs[PIdx::nattribs+2].dataPtr(); - Real* AMREX_RESTRICT uxpold = attribs[PIdx::nattribs+3].dataPtr(); - Real* AMREX_RESTRICT uypold = attribs[PIdx::nattribs+4].dataPtr(); - Real* AMREX_RESTRICT uzpold = attribs[PIdx::nattribs+5].dataPtr(); + const amrex::Real* uxp = attribs[PIdx::ux].dataPtr(); + const amrex::Real* uyp = attribs[PIdx::uy].dataPtr(); + const amrex::Real* uzp = attribs[PIdx::uz].dataPtr(); + + amrex::Real* xpold = attribs[PIdx::nattribs].dataPtr(); + amrex::Real* ypold = attribs[PIdx::nattribs+1].dataPtr(); + amrex::Real* zpold = attribs[PIdx::nattribs+2].dataPtr(); + amrex::Real* uxpold = attribs[PIdx::nattribs+3].dataPtr(); + amrex::Real* uypold = attribs[PIdx::nattribs+4].dataPtr(); + amrex::Real* uzpold = attribs[PIdx::nattribs+5].dataPtr(); const long np = pti.numParticles(); - ParallelFor( np, + amrex::ParallelFor( np, [=] AMREX_GPU_DEVICE (long i) { xpold[i]=xp[i]; ypold[i]=yp[i]; -- cgit v1.2.3 From b69ea2ccf999d80c4f2bb5e295a5ae170bb58a34 Mon Sep 17 00:00:00 2001 From: Diana Amorim Date: Wed, 10 Jul 2019 13:33:48 -0700 Subject: Fixed segfault error. --- Source/Particles/PhysicalParticleContainer.cpp | 27 +++++++++++++------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'Source/Particles/PhysicalParticleContainer.cpp') diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index e8654e573..c45f73f0f 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -1861,27 +1861,26 @@ PhysicalParticleContainer::PushP (int lev, Real dt, } } -void PhysicalParticleContainer::warpx_copy_attribs(WarpXParIter& pti,const amrex::Real* xp, - const amrex::Real* yp, const amrex::Real* zp) +void PhysicalParticleContainer::warpx_copy_attribs(WarpXParIter& pti,const Real* xp, + const Real* yp, const Real* zp) { + auto& attribs = pti.GetAttribs(); - //Real* AMREX_RESTRICT - - const amrex::Real* uxp = attribs[PIdx::ux].dataPtr(); - const amrex::Real* uyp = attribs[PIdx::uy].dataPtr(); - const amrex::Real* uzp = attribs[PIdx::uz].dataPtr(); + Real* AMREX_RESTRICT uxp = attribs[PIdx::ux].dataPtr(); + Real* AMREX_RESTRICT uyp = attribs[PIdx::uy].dataPtr(); + Real* AMREX_RESTRICT uzp = attribs[PIdx::uz].dataPtr(); - amrex::Real* xpold = attribs[PIdx::nattribs].dataPtr(); - amrex::Real* ypold = attribs[PIdx::nattribs+1].dataPtr(); - amrex::Real* zpold = attribs[PIdx::nattribs+2].dataPtr(); - amrex::Real* uxpold = attribs[PIdx::nattribs+3].dataPtr(); - amrex::Real* uypold = attribs[PIdx::nattribs+4].dataPtr(); - amrex::Real* uzpold = attribs[PIdx::nattribs+5].dataPtr(); + Real* AMREX_RESTRICT xpold = pti.GetAttribs(particle_comps["xold"]).dataPtr(); + Real* AMREX_RESTRICT ypold = pti.GetAttribs(particle_comps["xold"]).dataPtr(); + Real* AMREX_RESTRICT zpold = pti.GetAttribs(particle_comps["xold"]).dataPtr(); + Real* AMREX_RESTRICT uxpold = pti.GetAttribs(particle_comps["uxold"]).dataPtr(); + Real* AMREX_RESTRICT uypold = pti.GetAttribs(particle_comps["uyold"]).dataPtr(); + Real* AMREX_RESTRICT uzpold = pti.GetAttribs(particle_comps["uzold"]).dataPtr(); const long np = pti.numParticles(); - amrex::ParallelFor( np, + ParallelFor( np, [=] AMREX_GPU_DEVICE (long i) { xpold[i]=xp[i]; ypold[i]=yp[i]; -- cgit v1.2.3 From fb25dde6d6770f01bdfee71e10137c5fe8a8e035 Mon Sep 17 00:00:00 2001 From: Diana Amorim Date: Wed, 10 Jul 2019 16:56:58 -0700 Subject: Changed name of function to copy_attribs() --- Source/Particles/PhysicalParticleContainer.H | 2 +- Source/Particles/PhysicalParticleContainer.cpp | 4 ++-- Source/Particles/RigidInjectedParticleContainer.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'Source/Particles/PhysicalParticleContainer.cpp') diff --git a/Source/Particles/PhysicalParticleContainer.H b/Source/Particles/PhysicalParticleContainer.H index 99fc0f8da..d55764682 100644 --- a/Source/Particles/PhysicalParticleContainer.H +++ b/Source/Particles/PhysicalParticleContainer.H @@ -78,7 +78,7 @@ public: const amrex::MultiFab& By, const amrex::MultiFab& Bz) override; - void warpx_copy_attribs(WarpXParIter& pti,const amrex::Real* xp, + void copy_attribs(WarpXParIter& pti,const amrex::Real* xp, const amrex::Real* yp, const amrex::Real* zp); virtual void PostRestart () final {} diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index c45f73f0f..addde5e37 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -1731,7 +1731,7 @@ PhysicalParticleContainer::PushPX(WarpXParIter& pti, if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) { - warpx_copy_attribs(pti, xp.dataPtr(), yp.dataPtr(), zp.dataPtr()); + copy_attribs(pti, xp.dataPtr(), yp.dataPtr(), zp.dataPtr()); } // The following attributes should be included in CPP version of warpx_particle_pusher @@ -1861,7 +1861,7 @@ PhysicalParticleContainer::PushP (int lev, Real dt, } } -void PhysicalParticleContainer::warpx_copy_attribs(WarpXParIter& pti,const Real* xp, +void PhysicalParticleContainer::copy_attribs(WarpXParIter& pti,const Real* xp, const Real* yp, const Real* zp) { diff --git a/Source/Particles/RigidInjectedParticleContainer.cpp b/Source/Particles/RigidInjectedParticleContainer.cpp index ca02d1458..9bd4cb4fc 100644 --- a/Source/Particles/RigidInjectedParticleContainer.cpp +++ b/Source/Particles/RigidInjectedParticleContainer.cpp @@ -213,7 +213,7 @@ RigidInjectedParticleContainer::PushPX(WarpXParIter& pti, if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags) { - warpx_copy_attribs(pti, xp.dataPtr(), yp.dataPtr(), zp.dataPtr()); + copy_attribs(pti, xp.dataPtr(), yp.dataPtr(), zp.dataPtr()); } // This wraps the call to warpx_particle_pusher so that inheritors can modify the call. -- cgit v1.2.3 From cd7f25974133d0aef31a90af6d79dd36372fc3fd Mon Sep 17 00:00:00 2001 From: Diana Amorim Date: Fri, 12 Jul 2019 20:24:28 -0700 Subject: Corrected typo of xold incorrect repetition. --- .../laser_acceleration/inputs.2d.boost | 21 +++++++++++---------- Source/Particles/PhysicalParticleContainer.cpp | 4 ++-- 2 files changed, 13 insertions(+), 12 deletions(-) (limited to 'Source/Particles/PhysicalParticleContainer.cpp') diff --git a/Examples/Physics_applications/laser_acceleration/inputs.2d.boost b/Examples/Physics_applications/laser_acceleration/inputs.2d.boost index 5fe4bfcf6..75a246ea6 100644 --- a/Examples/Physics_applications/laser_acceleration/inputs.2d.boost +++ b/Examples/Physics_applications/laser_acceleration/inputs.2d.boost @@ -1,8 +1,8 @@ ################################# ######### BOX PARAMETERS ######## ################################# -max_step = 1000 -# stop_time = 1.9e-12 +# max_step = 2700 +stop_time = 1.9e-12 amr.n_cell = 128 1024 amr.max_grid_size = 64 amr.blocking_factor = 32 @@ -19,8 +19,10 @@ geometry.prob_hi = 128.e-6 0.96e-6 ################################# warpx.verbose = 1 amrex.v = 1 -algo.current_deposition = direct -algo.particle_pusher = vay +algo.current_deposition = direct #2 +algo.charge_deposition = standard # 0 +algo.field_gathering = standard # 0 +algo.particle_pusher = vay # 1 algo.maxwell_fdtd_solver = ckc interpolation.nox = 3 interpolation.noy = 3 @@ -37,12 +39,11 @@ warpx.serialize_ics = 1 ################################# ####### BOOST PARAMETERS ######## ################################# -warpx.gamma_boost = 30. +warpx.gamma_boost = 10. warpx.boost_direction = z warpx.do_boosted_frame_diagnostic = 1 warpx.num_snapshots_lab = 7 warpx.dt_snapshots_lab = 1.6678204759907604e-12 -warpx.boosted_frame_diag_fields = Ex Ez By jz ################################# ############ PLASMA ############# @@ -60,11 +61,11 @@ electrons.momentum_distribution_type = "gaussian" electrons.xmin = -120.e-6 electrons.xmax = 120.e-6 electrons.zmin = 0.5e-3 -electrons.zmax = 1. +electrons.zmax = .0035 electrons.profile = "predefined" electrons.predefined_profile_name = "parabolic_channel" # predefined_profile_params = z_start ramp_up plateau ramp_down rc n0 -electrons.predefined_profile_params = .5e-3 .5e-3 2.e-3 .5e-3 50.e-6 3.5e25 +electrons.predefined_profile_params = .5e-3 .5e-3 2.e-3 .5e-3 50.e-6 3.5e24 electrons.do_continuous_injection = 1 ions.charge = q_e @@ -75,11 +76,11 @@ ions.momentum_distribution_type = "gaussian" ions.xmin = -120.e-6 ions.xmax = 120.e-6 ions.zmin = 0.5e-3 -ions.zmax = 1. +ions.zmax = .0035 ions.profile = "predefined" ions.predefined_profile_name = "parabolic_channel" # predefined_profile_params = z_start ramp_up plateau ramp_down rc n0 -ions.predefined_profile_params = .5e-3 .5e-3 2.e-3 .5e-3 50.e-6 3.5e25 +ions.predefined_profile_params = .5e-3 .5e-3 2.e-3 .5e-3 50.e-6 3.5e24 ions.do_continuous_injection = 1 beam.charge = -q_e diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index addde5e37..d6c4973c3 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -1872,8 +1872,8 @@ void PhysicalParticleContainer::copy_attribs(WarpXParIter& pti,const Real* xp, Real* AMREX_RESTRICT uzp = attribs[PIdx::uz].dataPtr(); Real* AMREX_RESTRICT xpold = pti.GetAttribs(particle_comps["xold"]).dataPtr(); - Real* AMREX_RESTRICT ypold = pti.GetAttribs(particle_comps["xold"]).dataPtr(); - Real* AMREX_RESTRICT zpold = pti.GetAttribs(particle_comps["xold"]).dataPtr(); + Real* AMREX_RESTRICT ypold = pti.GetAttribs(particle_comps["yold"]).dataPtr(); + Real* AMREX_RESTRICT zpold = pti.GetAttribs(particle_comps["zold"]).dataPtr(); Real* AMREX_RESTRICT uxpold = pti.GetAttribs(particle_comps["uxold"]).dataPtr(); Real* AMREX_RESTRICT uypold = pti.GetAttribs(particle_comps["uyold"]).dataPtr(); Real* AMREX_RESTRICT uzpold = pti.GetAttribs(particle_comps["uzold"]).dataPtr(); -- cgit v1.2.3