From f19507218effe499581c2d22d2ab086de1245c6c Mon Sep 17 00:00:00 2001 From: "L. Diana Amorim" Date: Fri, 27 Mar 2020 09:48:08 -0700 Subject: [mini-PR] Read species distribution from OPMD file (#847) * Added .profile=external_file and .profile_file * Added description of input parameters to Docs * Changed from profile to injection option for external file * Fix typo in amrex abort message (due to copy paste) * Added the OpenPMD use amrex abort message * Minor fix - not sure how to remove EOL issue * Tried to add AddExternalFileBeam functon to PhysicalParticleContainer * Trued to fix EOL white space issue * Added read/print species name from OPMD file * Update Source/Initialization/PlasmaInjector.cpp Co-Authored-By: Axel Huebl * Update Source/Particles/PhysicalParticleContainer.cpp Co-Authored-By: Axel Huebl * Update Source/Particles/PhysicalParticleContainer.cpp Co-Authored-By: Axel Huebl * Update Source/Particles/PhysicalParticleContainer.H Co-Authored-By: Axel Huebl * Update Source/Particles/PhysicalParticleContainer.cpp Co-Authored-By: Axel Huebl * No need to include openPMD header yet * Fix EOL according to @ax3l's recommendation in #845 * Remove commented out AbortMessage Co-Authored-By: MaxThevenet * Removed commented out part initialization (used only in branch for next PR) Co-Authored-By: MaxThevenet * Added warning that this is WIP Co-Authored-By: MaxThevenet * Changed function name to AddPlasmaFromFile * Removed AMReX warning from loop Co-Authored-By: MaxThevenet Co-authored-by: Axel Huebl Co-authored-by: MaxThevenet --- Source/Particles/PhysicalParticleContainer.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'Source/Particles/PhysicalParticleContainer.cpp') diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index fe6fe80f2..0eb9b52df 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -309,6 +309,23 @@ PhysicalParticleContainer::AddGaussianBeam(Real x_m, Real y_m, Real z_m, 1, particle_w.dataPtr(),1); } +void +PhysicalParticleContainer::AddPlasmaFromFile(const std::string s_f) +{ +#ifdef WARPX_USE_OPENPMD + openPMD::Series series = openPMD::Series(s_f, openPMD::AccessType::READ_ONLY); + amrex::Print() << "openPMD standard version " << series.openPMD() << "\n"; + + openPMD::Iteration& i = series.iterations[1]; + amrex::Print() << "File contains " << i.particles.size() << " specie(s):" << "\n"; + for( auto const& ps : i.particles ) { + amrex::Print() << "\t" << ps.first << "\n"; + } + amrex::Print()<<"WARNING: this is WIP, no particle has been injected!!"; +#endif + return; +} + void PhysicalParticleContainer::CheckAndAddParticle(Real x, Real y, Real z, std::array u, @@ -365,6 +382,11 @@ PhysicalParticleContainer::AddParticles (int lev) return; } + if (plasma_injector->external_file) { + AddPlasmaFromFile(plasma_injector->str_injection_file); + return; + } + if ( plasma_injector->doInjection() ) { AddPlasma( lev ); } -- cgit v1.2.3