12#ifndef CD_GenericParticleImplem_H
13#define CD_GenericParticleImplem_H
17#include <CD_NamespaceHeader.H>
19template <
size_t M,
size_t N>
26 for (
auto&
s : m_scalars) {
30 for (
auto&
v : m_vectors) {
35template <
size_t M,
size_t N>
38 this->m_position =
a_other.m_position;
39 this->m_scalars =
a_other.m_scalars;
40 this->m_vectors =
a_other.m_vectors;
43template <
size_t M,
size_t N>
47template <
size_t M,
size_t N>
54template <
size_t M,
size_t N>
61template <
size_t M,
size_t N>
68template <
size_t M,
size_t N>
75template <
size_t M,
size_t N>
82template <
size_t M,
size_t N>
89template <
size_t M,
size_t N>
96template <
size_t M,
size_t N>
103template <
size_t M,
size_t N>
110template <
size_t M,
size_t N>
117template <
size_t M,
size_t N>
125template <
size_t M,
size_t N>
133template <
size_t M,
size_t N>
141template <
size_t M,
size_t N>
149template <
size_t M,
size_t N>
153 return (this->m_position ==
a_p.m_position &&
this->m_scalars ==
a_p.m_scalars &&
this->m_vectors ==
a_p.m_vectors);
156template <
size_t M,
size_t N>
160 return !(*
this ==
a_p);
163template <
size_t M,
size_t N>
193template <
size_t M,
size_t N>
203 size +=
M *
sizeof(
Real);
209template <
size_t M,
size_t N>
215 detail::pushParticleProperty(p, m_particleID);
216 detail::pushParticleProperty(p, m_rankID);
218 detail::pushParticleProperty(p, m_position[0]);
219 detail::pushParticleProperty(p, m_position[1]);
221 detail::pushParticleProperty(p, m_position[2]);
224 for (
size_t i = 0;
i <
M;
i++) {
225 detail::pushParticleProperty(p, m_scalars[
i]);
228 for (
size_t i = 0;
i <
N;
i++) {
229 detail::pushParticleProperty(p, m_vectors[
i][0]);
230 detail::pushParticleProperty(p, m_vectors[
i][1]);
232 detail::pushParticleProperty(p, m_vectors[
i][2]);
237template <
size_t M,
size_t N>
243 detail::pullParticleProperty(p, m_particleID);
244 detail::pullParticleProperty(p, m_rankID);
246 detail::pullParticleProperty(p, m_position[0]);
247 detail::pullParticleProperty(p, m_position[1]);
249 detail::pullParticleProperty(p, m_position[2]);
252 for (
size_t i = 0;
i <
M;
i++) {
253 detail::pullParticleProperty(p, m_scalars[
i]);
256 for (
size_t i = 0;
i <
N;
i++) {
257 detail::pullParticleProperty(p, m_vectors[
i][0]);
258 detail::pullParticleProperty(p, m_vectors[
i][1]);
260 detail::pullParticleProperty(p, m_vectors[
i][2]);
265template <
size_t M,
size_t N>
272 size +=
M *
sizeof(
Real);
278template <
size_t M,
size_t N>
284 detail::pushParticleProperty(p, m_position[0]);
285 detail::pushParticleProperty(p, m_position[1]);
287 detail::pushParticleProperty(p, m_position[2]);
290 for (
size_t i = 0;
i <
M;
i++) {
291 detail::pushParticleProperty(p, m_scalars[
i]);
294 for (
size_t i = 0;
i <
N;
i++) {
295 detail::pushParticleProperty(p, m_vectors[
i][0]);
296 detail::pushParticleProperty(p, m_vectors[
i][1]);
298 detail::pushParticleProperty(p, m_vectors[
i][2]);
303template <
size_t M,
size_t N>
309 detail::pullParticleProperty(p, m_position[0]);
310 detail::pullParticleProperty(p, m_position[1]);
312 detail::pullParticleProperty(p, m_position[2]);
315 for (
size_t i = 0;
i <
M;
i++) {
316 detail::pullParticleProperty(p, m_scalars[
i]);
319 for (
size_t i = 0;
i <
N;
i++) {
320 detail::pullParticleProperty(p, m_vectors[
i][0]);
321 detail::pullParticleProperty(p, m_vectors[
i][1]);
323 detail::pullParticleProperty(p, m_vectors[
i][2]);
328template <
size_t M,
size_t N>
332 ostr <<
"GenericParticle : \n";
335 ostr <<
"\tPosition = " << p.position() <<
"\n";
340#include <CD_NamespaceFooter.H>
std::ostream & operator<<(std::ostream &ostr, const GenericParticle< M, N > &p)
Particle printing function.
Definition CD_GenericParticleImplem.H:330
Declaration of a generic particle class.
virtual ~GenericParticle()
Destructor (deallocates runtime memory storage)
Definition CD_GenericParticleImplem.H:44
virtual void linearOut(void *const a_buffer) const
Write a linear binary representation of the internal data. Assumes that sufficient memory for the buf...
Definition CD_GenericParticleImplem.H:211
const int32_t & particleID() const noexcept
Get the particle ID.
Definition CD_GenericParticleImplem.H:63
virtual int H5size() const
Function that is used when writing particles to HDF5.
Definition CD_GenericParticleImplem.H:267
RealVect & position()
Get the particle position.
Definition CD_GenericParticleImplem.H:49
Real & real()
Get one of the scalars.
Definition CD_GenericParticleImplem.H:120
virtual void linearIn(const void *const a_buffer)
Read a linear binary representation of the internal data. Assumes that the buffer has the correct dat...
Definition CD_GenericParticleImplem.H:239
const std::array< Real, M > & getReals() const noexcept
Get the M scalars.
Definition CD_GenericParticleImplem.H:91
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:195
RealVect & vect()
Get one of the RealVects.
Definition CD_GenericParticleImplem.H:136
virtual void H5linearOut(void *const a_buffer) const
Linearize the Real components onto a buffer workable by HDF5.
Definition CD_GenericParticleImplem.H:280
const int32_t & rankID() const noexcept
Get the MPI rank ID.
Definition CD_GenericParticleImplem.H:77
virtual void H5linearIn(const void *const a_buffer)
Delinearize the buffer onto the real components in the particle class.
Definition CD_GenericParticleImplem.H:305
bool operator==(const GenericParticle< M, N > &a_other) const
Comparison operator with other particle.
Definition CD_GenericParticleImplem.H:151
bool operator!=(const GenericParticle< M, N > &a_other) const
Comparison operator with other particle.
Definition CD_GenericParticleImplem.H:158
bool operator<(const GenericParticle< M, N > &a_other) const noexcept
Particle comparison operator. Returns lexicographical ordering.
Definition CD_GenericParticleImplem.H:165
GenericParticle()
Default constructor – initializes everything to zero.
Definition CD_GenericParticleImplem.H:20
const std::array< RealVect, N > & getVects() const noexcept
Get the N vectors.
Definition CD_GenericParticleImplem.H:105
Base class for a tracer particle solver. This solver can advance particles in a pre-defined velocity ...
Definition CD_TracerParticleSolver.H:37
TracerParticleSolver()
Default constructor.
Definition CD_TracerParticleSolverImplem.H:25