ECP-WarpX / WarpX

WarpX is an advanced electromagnetic & electrostatic Particle-In-Cell code.
https://ecp-warpx.github.io
Other
304 stars 194 forks source link

Rewrite `ParticleDiag` so that `nullptr` can be passed for `WarpXParticleContainer` #3075

Open RemiLehe opened 2 years ago

RemiLehe commented 2 years ago

For BTD diagnostics, the ParticleDiag uses data from the PinnedMemoryParticleContainer passed in the constructor: https://github.com/ECP-WarpX/WarpX/blob/development/Source/Diagnostics/ParticleDiag/ParticleDiag.cpp#L16

However, it is still need to pass a WarpXParticleContainer (otherwise the code segfault, because it extracts from meta-information from the WarpXParticleContainer.

ax3l commented 2 years ago

You could use a std::variant<WarpXParticleContainer, PinnedMemoryParticleContainer> if only one of both is passed at a time :) https://en.cppreference.com/w/cpp/utility/variant That allows you to not have to template and keep the implementation in a .cpp file (better compile time). Discussed: easier to go for the particle container base class and pass extra info separately.

Discussed with Reva: needs to add the member variable that names the particle attributes to the 2nd type (pinned type).