diff options
author | 2019-10-10 09:09:33 -0700 | |
---|---|---|
committer | 2019-10-10 09:09:33 -0700 | |
commit | ba0bfcaaa4aa56867f4ee36713426719491d5b1f (patch) | |
tree | 5cba446b613cd08cc580d97c3892621f85fbfb9a /Source/Particles/ParticleCreation/ElementaryProcess.cpp | |
parent | 85aa9abe9860c018e5db5051a6e805f10ea3b7e4 (diff) | |
download | WarpX-ba0bfcaaa4aa56867f4ee36713426719491d5b1f.tar.gz WarpX-ba0bfcaaa4aa56867f4ee36713426719491d5b1f.tar.zst WarpX-ba0bfcaaa4aa56867f4ee36713426719491d5b1f.zip |
add template option for particle transformation
Diffstat (limited to 'Source/Particles/ParticleCreation/ElementaryProcess.cpp')
-rw-r--r-- | Source/Particles/ParticleCreation/ElementaryProcess.cpp | 118 |
1 files changed, 0 insertions, 118 deletions
diff --git a/Source/Particles/ParticleCreation/ElementaryProcess.cpp b/Source/Particles/ParticleCreation/ElementaryProcess.cpp index 406911481..ff21fccfd 100644 --- a/Source/Particles/ParticleCreation/ElementaryProcess.cpp +++ b/Source/Particles/ParticleCreation/ElementaryProcess.cpp @@ -9,102 +9,6 @@ elementaryProcess::createParticles ( std::unique_ptr< WarpXParticleContainer>& pc_product, Gpu::ManagedDeviceVector<int>& is_flagged, bool do_boosted_product) -{ - BL_PROFILE("createIonizedParticles"); - - const int grid_id = mfi.index(); - const int tile_id = mfi.LocalTileIndex(); - - // Get source particle data - auto& ptile_source = pc_source->GetParticles(lev)[std::make_pair(grid_id,tile_id)]; - const int np_source = ptile_source.GetArrayOfStructs().size(); - if (np_source == 0) return; - // --- source AoS particle data - WarpXParticleContainer::ParticleType* particles_source = ptile_source.GetArrayOfStructs()().data(); - // --- source SoA particle data - auto& soa_source = ptile_source.GetStructOfArrays(); - amrex::GpuArray<amrex::ParticleReal*,PIdx::nattribs> attribs_source; - for (int ia = 0; ia < PIdx::nattribs; ++ia) { - attribs_source[ia] = soa_source.GetRealData(ia).data(); - } - // --- source runtime attribs - amrex::GpuArray<amrex::ParticleReal*,3> runtime_uold_source; - // Prepare arrays for boosted frame diagnostics. - runtime_uold_source[0] = soa_source.GetRealData(PIdx::ux).data(); - runtime_uold_source[1] = soa_source.GetRealData(PIdx::uy).data(); - runtime_uold_source[2] = soa_source.GetRealData(PIdx::uz).data(); - - // Indices of product particle for each ionized source particle. - // i_product[i]-1 is the location in product tile of product particle - // from source particle i. - amrex::Gpu::ManagedDeviceVector<int> i_product; - i_product.resize(np_source); - // 0<i<np_source - // 0<i_product<np_ionized - // Strictly speaking, i_product should be an exclusive_scan of - // is_flagged. However, for indices where is_flagged is 1, the - // inclusive scan gives the same result with an offset of 1. - // The advantage of inclusive_scan is that the sum of is_flagged - // is in the last element, so no other reduction is required to get - // number of particles. - // Gpu::inclusive_scan runs on the current GPU stream, and synchronizes - // with the CPU, so that the next line (executed by the CPU) has the - // updated values of i_product - amrex::Gpu::inclusive_scan(is_flagged.begin(), is_flagged.end(), i_product.begin()); - int np_ionized = i_product[np_source-1]; - if (np_ionized == 0) return; - - // Get product particle data - auto& ptile_product = pc_product->GetParticles(lev)[std::make_pair(grid_id,tile_id)]; - // old and new (i.e., including ionized particles) number of particles - // for product species - const int np_product_old = ptile_product.GetArrayOfStructs().size(); - const int np_product_new = np_product_old + np_ionized; - // Allocate extra space in product species for ionized particles. - ptile_product.resize(np_product_new); - // --- product AoS particle data - // First element is the first newly-created product particle - WarpXParticleContainer::ParticleType* particles_product = ptile_product.GetArrayOfStructs()().data() + np_product_old; - // --- product SoA particle data - auto& soa_product = ptile_product.GetStructOfArrays(); - amrex::GpuArray<amrex::ParticleReal*,PIdx::nattribs> attribs_product; - for (int ia = 0; ia < PIdx::nattribs; ++ia) { - // First element is the first newly-created product particle - attribs_product[ia] = soa_product.GetRealData(ia).data() + np_product_old; - } - // --- product runtime attribs - amrex::GpuArray<amrex::ParticleReal*,6> runtime_attribs_product; - - if (do_boosted_product) { - std::map<std::string, int> comps_product = pc_product->getParticleComps(); - runtime_attribs_product[0] = soa_product.GetRealData(comps_product[ "xold"]).data() + np_product_old; - runtime_attribs_product[1] = soa_product.GetRealData(comps_product[ "yold"]).data() + np_product_old; - runtime_attribs_product[2] = soa_product.GetRealData(comps_product[ "zold"]).data() + np_product_old; - runtime_attribs_product[3] = soa_product.GetRealData(comps_product["uxold"]).data() + np_product_old; - runtime_attribs_product[4] = soa_product.GetRealData(comps_product["uyold"]).data() + np_product_old; - runtime_attribs_product[5] = soa_product.GetRealData(comps_product["uzold"]).data() + np_product_old; - } - - int pid_product; -#pragma omp critical (doFieldIonization_nextid) - { - // ID of first newly-created product particle - pid_product = pc_product->NextID(); - // Update NextID to include particles created in this function - pc_product->setNextID(pid_product+np_ionized); - } - const int cpuid = amrex::ParallelDescriptor::MyProc(); - - copyParticle copy_functor = initialize_copy( - cpuid, do_boosted_product, - runtime_uold_source, - attribs_source, - attribs_product, - runtime_attribs_product); - - copyAndTransformParticles(is_flagged, i_product, np_source, pid_product, - particles_product, particles_source, copy_functor); -} void elementaryProcess::copyAndTransformParticles( @@ -114,25 +18,3 @@ elementaryProcess::copyAndTransformParticles( WarpXParticleContainer::ParticleType* particles_product, WarpXParticleContainer::ParticleType* particles_source, copyParticle copy_functor) -{ - int const * const AMREX_RESTRICT p_is_flagged = is_flagged.dataPtr(); - int const * const AMREX_RESTRICT p_i_product = i_product.dataPtr(); - // Loop over all source particles. If is_flagged, copy particle data - // to corresponding product particle. - amrex::For( - np_source, [=] AMREX_GPU_DEVICE (int is) noexcept - { - if(p_is_flagged[is]){ - // offset of 1 due to inclusive scan - int ip = p_i_product[is]-1; - // is: index of ionized particle in source species - // ip: index of corresponding new particle in product species - WarpXParticleContainer::ParticleType& p_product = particles_product[ip]; - WarpXParticleContainer::ParticleType& p_source = particles_source[is]; - copy_functor(is, ip, pid_product, p_source, p_product); - transformSourceParticle(is, p_source); - //transformProductParticle<ProcessT>(ip, p_product); - } - } - ); -} |