12 #ifndef CD_GenericParticleImplem_H
13 #define CD_GenericParticleImplem_H
17 #include <CD_NamespaceHeader.H>
19 template <
size_t M,
size_t N>
22 m_position = RealVect::Zero;
24 for (
auto& s : m_scalars) {
28 for (
auto& v : m_vectors) {
33 template <
size_t M,
size_t N>
41 template <
size_t M,
size_t N>
45 template <
size_t M,
size_t N>
52 template <
size_t M,
size_t N>
53 inline const RealVect&
59 template <
size_t M,
size_t N>
60 inline const std::array<Real, M>&
66 template <
size_t M,
size_t N>
67 inline std::array<Real, M>&
73 template <
size_t M,
size_t N>
74 inline const std::array<RealVect, N>&
80 template <
size_t M,
size_t N>
81 inline std::array<RealVect, N>&
87 template <
size_t M,
size_t N>
92 return std::get<K>(m_scalars);
95 template <
size_t M,
size_t N>
100 return std::get<K>(m_scalars);
103 template <
size_t M,
size_t N>
108 return std::get<K>(m_vectors);
111 template <
size_t M,
size_t N>
113 inline const RealVect&
116 return std::get<K>(m_vectors);
119 template <
size_t M,
size_t N>
126 template <
size_t M,
size_t N>
130 return !(*
this == a_p);
133 template <
size_t M,
size_t N>
137 const RealVect& x = m_position;
138 const RealVect& y = a_other.m_position;
163 template <
size_t M,
size_t N>
168 return SpaceDim *
sizeof(Real) + M *
sizeof(Real) + N * SpaceDim *
sizeof(Real);
171 template <
size_t M,
size_t N>
175 Real* buffer = (Real*)buf;
178 *buffer++ = m_position[0];
179 *buffer++ = m_position[1];
181 *buffer++ = m_position[2];
185 for (
size_t i = 0; i < M; i++) {
186 *buffer++ = m_scalars[i];
190 for (
size_t i = 0; i < N; i++) {
191 const RealVect& v = m_vectors[i];
201 template <
size_t M,
size_t N>
205 Real* buffer = (Real*)buf;
207 m_position[0] = *buffer++;
208 m_position[1] = *buffer++;
210 m_position[2] = *buffer++;
214 for (
size_t i = 0; i < M; i++) {
215 m_scalars[i] = *buffer++;
219 for (
size_t i = 0; i < N; i++) {
220 RealVect& v = m_vectors[i];
230 template <
size_t M,
size_t N>
234 ostr <<
"GenericParticle : \n";
237 ostr <<
"\tPosition = " << p.
position() <<
"\n";
242 #include <CD_NamespaceFooter.H>
std::ostream & operator<<(std::ostream &ostr, const GenericParticle< M, N > &p)
Particle printing function.
Definition: CD_GenericParticleImplem.H:232
Declaration of a generic particle class.
A generic particle class, holding the position and a specified number of real and vector values.
Definition: CD_GenericParticle.H:33
virtual void linearOut(void *a_buffer) const
Write a linear binary representation of the internal data. Assumes that sufficient memory for the buf...
Definition: CD_GenericParticleImplem.H:173
virtual ~GenericParticle()
Destructor (deallocates runtime memory storage)
Definition: CD_GenericParticleImplem.H:42
virtual void linearIn(void *a_buffer)
Read a linear binary representation of the internal data. Assumes that the buffer has the correct dat...
Definition: CD_GenericParticleImplem.H:203
RealVect & position()
Get the particle position.
Definition: CD_GenericParticleImplem.H:47
Real & real()
Get one of the scalars.
Definition: CD_GenericParticleImplem.H:90
const std::array< Real, M > & getReals() const noexcept
Get the M scalars.
Definition: CD_GenericParticleImplem.H:61
virtual int size() const
Returns the size, in number of bytes, of a flat representation of the data in this object.
Definition: CD_GenericParticleImplem.H:165
RealVect & vect()
Get one of the RealVects.
Definition: CD_GenericParticleImplem.H:106
bool operator==(const GenericParticle< M, N > &a_other) const
Comparison operator with other particle.
Definition: CD_GenericParticleImplem.H:121
bool operator!=(const GenericParticle< M, N > &a_other) const
Comparison operator with other particle.
Definition: CD_GenericParticleImplem.H:128
bool operator<(const GenericParticle< M, N > &a_other) const noexcept
Particle comparison operator. Returns lexicographical ordering.
Definition: CD_GenericParticleImplem.H:135
RealVect m_position
Particle position.
Definition: CD_GenericParticle.H:180
GenericParticle()
Default constructor – initializes everything to zero.
Definition: CD_GenericParticleImplem.H:20
std::array< Real, M > m_scalars
Scalar storage array.
Definition: CD_GenericParticle.H:185
std::array< RealVect, N > m_vectors
vector storage array
Definition: CD_GenericParticle.H:190
const std::array< RealVect, N > & getVects() const noexcept
Get the N vectors.
Definition: CD_GenericParticleImplem.H:75