diff options
author | 2021-10-04 21:31:53 +0200 | |
---|---|---|
committer | 2021-10-04 12:31:53 -0700 | |
commit | d0cc41acec8fbba8d66fabd3351751adf00903d7 (patch) | |
tree | a81179ac9fa9df10a5f3eee4c62eee2812a5b2f2 /Source/Particles/Collision/BinaryCollision/ParticleCreationFunc.cpp | |
parent | f32fca03f725afa92ee380884d86e116e265aee1 (diff) | |
download | WarpX-d0cc41acec8fbba8d66fabd3351751adf00903d7.tar.gz WarpX-d0cc41acec8fbba8d66fabd3351751adf00903d7.tar.zst WarpX-d0cc41acec8fbba8d66fabd3351751adf00903d7.zip |
Add structure for proton-boron fusion module (#2217)
* Add structure for proton-boron fusion module
* Fix clang compile error
* Generalize structure for other nuclear fusion types
* Workaround: try to use std::vectors to fix clang compile error
* Simplify workaround for clang
* Rebase on 2245 and add empty particle creation functor
* Apply suggestions from code review
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Add couple of consts and runtime assert
* Add another const
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
Diffstat (limited to 'Source/Particles/Collision/BinaryCollision/ParticleCreationFunc.cpp')
-rw-r--r-- | Source/Particles/Collision/BinaryCollision/ParticleCreationFunc.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/Source/Particles/Collision/BinaryCollision/ParticleCreationFunc.cpp b/Source/Particles/Collision/BinaryCollision/ParticleCreationFunc.cpp new file mode 100644 index 000000000..fff4150c1 --- /dev/null +++ b/Source/Particles/Collision/BinaryCollision/ParticleCreationFunc.cpp @@ -0,0 +1,45 @@ +/* Copyright 2021 Neil Zaim + * + * This file is part of WarpX. + * + * License: BSD-3-Clause-LBNL + */ + +#include "ParticleCreationFunc.H" + +#include "BinaryCollisionUtils.H" +#include "Particles/MultiParticleContainer.H" + +#include <AMReX_GpuContainers.H> +#include <AMReX_ParmParse.H> +#include <AMReX_Vector.H> + +#include <string> + +ParticleCreationFunc::ParticleCreationFunc (const std::string collision_name, + MultiParticleContainer const * const mypc) + { + amrex::ParmParse pp_collision_name(collision_name); + + m_collision_type = BinaryCollisionUtils::get_collision_type(collision_name, mypc); + +#ifdef AMREX_USE_GPU + amrex::Vector<int> host_num_products; +#else + amrex::Gpu::DeviceVector<int>& host_num_products = m_num_products; +#endif + if (m_collision_type == CollisionType::ProtonBoronFusion) + { + // Proton-Boron fusion only produces alpha particles + m_num_product_species = 1; + // Proton-Boron fusion produces 3 alpha particles per fusion reaction + host_num_products.push_back(3); + } +#ifdef AMREX_USE_GPU + m_num_products.resize(m_num_product_species); + amrex::Gpu::copyAsync(amrex::Gpu::hostToDevice, host_num_products.begin(), + host_num_products.end(), + m_num_products.begin()); + amrex::Gpu::streamSynchronize(); +#endif + } |