From c238eab6e20f732facdef32909f368b9436fb964 Mon Sep 17 00:00:00 2001 From: MaxThevenet Date: Thu, 16 May 2019 17:46:58 -0700 Subject: Photons are derived class from PhysicalParticleContainer --- Source/Particles/PhotonParticleContainer.cpp | 87 ++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 Source/Particles/PhotonParticleContainer.cpp (limited to 'Source/Particles/PhotonParticleContainer.cpp') diff --git a/Source/Particles/PhotonParticleContainer.cpp b/Source/Particles/PhotonParticleContainer.cpp new file mode 100644 index 000000000..14af6c0d9 --- /dev/null +++ b/Source/Particles/PhotonParticleContainer.cpp @@ -0,0 +1,87 @@ +#include +#include +#include + +#ifdef _OPENMP +#include +#endif + +#include +#include +#include +#include + +using namespace amrex; + +PhotonParticleContainer::PhotonParticleContainer (AmrCore* amr_core, int ispecies, + const std::string& name) + : PhysicalParticleContainer(amr_core, ispecies, name) +{ + + // This will read .[...] from the inputs file + // where is the name of your species + ParmParse pp(species_name); + + // read .size_in_inches in the input file, and + // store it into member data. + pp.query("size_in_inches", size_in_inches); + +} + +void PhotonParticleContainer::InitData() +{ + AddParticles(0); // Note - add on level 0 + if (maxLevel() > 0) { + Redistribute(); // We then redistribute + } +} + +void +PhotonParticleContainer::PushPX(WarpXParIter& pti, + Cuda::ManagedDeviceVector& xp, + Cuda::ManagedDeviceVector& yp, + Cuda::ManagedDeviceVector& zp, + Cuda::ManagedDeviceVector& giv, + Real dt) +{ + // 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]; + auto& uzp = attribs[PIdx::uz]; + auto& Exp = attribs[PIdx::Ex]; + auto& Eyp = attribs[PIdx::Ey]; + auto& Ezp = attribs[PIdx::Ez]; + auto& Bxp = attribs[PIdx::Bx]; + auto& Byp = attribs[PIdx::By]; + auto& Bzp = attribs[PIdx::Bz]; + const long np = pti.numParticles(); + + // Probably want to push photons in some way here. + // WarpXParticleContainer::PushX(int lev, Real dt) is probably + // a good start. + // In particular grep ParallelFor thing if you want + // to write GPU-compatible code. +} + +void +PhotonParticleContainer::Evolve (int lev, + const MultiFab& Ex, const MultiFab& Ey, const MultiFab& Ez, + const MultiFab& Bx, const MultiFab& By, const MultiFab& Bz, + MultiFab& jx, MultiFab& jy, MultiFab& jz, + MultiFab* cjx, MultiFab* cjy, MultiFab* cjz, + MultiFab* rho, MultiFab* crho, + const MultiFab* cEx, const MultiFab* cEy, const MultiFab* cEz, + const MultiFab* cBx, const MultiFab* cBy, const MultiFab* cBz, + Real t, Real dt) +{ + PhysicalParticleContainer::Evolve (lev, + Ex, Ey, Ez, + Bx, By, Bz, + jx, jy, jz, + cjx, cjy, cjz, + rho, crho, + cEx, cEy, cEz, + cBx, cBy, cBz, + t, dt); +} -- cgit v1.2.3