Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetPosition 2D3V: y=0 #2233

Merged
merged 1 commit into from
Aug 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Docs/source/developers/dimensionality.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,8 @@ extra SoA attribute ``theta``
==================== =========== =========== ===========

Please see the following sections for particle AoS and SoA details.

Conventions
-----------

In 2D3V, we assume that the position of a particle in ``y`` is equal to ``0``.
20 changes: 11 additions & 9 deletions Source/Particles/Pusher/GetAndSetPosition.H
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,13 @@ void get_particle_position (const WarpXParticleContainer::SuperParticleType& p,
z = p.pos(2);
#else
x = p.pos(0);
y = std::numeric_limits<amrex::ParticleReal>::quiet_NaN();
y = amrex::ParticleReal(0.0);
z = p.pos(1);
#endif
}

/** \brief Functor that can be used to extract the positions of the macroparticles
* inside a ParallelFor kernel
*
* \tparam ptiType the type of the particle iterator used in the constructor
*
* \param a_pti iterator to the tile containing the macroparticles
* \param a_offset offset to apply to the particle indices
*/
struct GetParticlePosition
{
Expand All @@ -59,11 +54,18 @@ struct GetParticlePosition
#if (defined WARPX_DIM_RZ)
const RType* m_theta = nullptr;
#elif (AMREX_SPACEDIM == 2)
static constexpr RType m_snan = std::numeric_limits<RType>::quiet_NaN();
static constexpr RType m_y_default = RType(0.0);
#endif

GetParticlePosition () = default;

/** Constructor
*
* \tparam ptiType the type of the particle iterator used in the constructor
*
* \param a_pti iterator to the tile containing the macroparticles
* \param a_offset offset to apply to the particle indices
*/
template <typename ptiType>
GetParticlePosition (const ptiType& a_pti, int a_offset = 0) noexcept
{
Expand Down Expand Up @@ -93,7 +95,7 @@ struct GetParticlePosition
z = p.pos(2);
#else
x = p.pos(0);
y = m_snan;
y = m_y_default;
z = p.pos(1);
#endif
}
Expand All @@ -117,7 +119,7 @@ struct GetParticlePosition
z = p.pos(2);
#else
x = p.pos(0);
y = m_snan;
y = m_y_default;
z = p.pos(1);
#endif
}
Expand Down