chombo-discharge
CD_GenericParticle.H
Go to the documentation of this file.
1 /* chombo-discharge
2  * Copyright © 2022 SINTEF Energy Research.
3  * Please refer to Copyright.txt and LICENSE in the chombo-discharge root directory.
4  */
5 
12 #ifndef CD_GenericParticle_H
13 #define CD_GenericParticle_H
14 
15 // Std includes
16 #include <string>
17 #include <typeinfo>
18 #include <cstdio>
19 #include <cmath>
20 #include <array>
21 
22 // Chombo includes
23 #include <RealVect.H>
24 
25 // Our includes
26 #include <CD_NamespaceHeader.H>
27 
31 template <size_t M, size_t N>
33 {
34 public:
38  inline GenericParticle();
39 
44  inline GenericParticle(const GenericParticle<M, N>& a_other);
45 
49  inline virtual ~GenericParticle();
50 
55  inline RealVect&
56  position();
57 
62  inline const RealVect&
63  position() const;
64 
69  inline const std::array<Real, M>&
70  getReals() const noexcept;
71 
76  inline std::array<Real, M>&
77  getReals() noexcept;
78 
83  inline const std::array<RealVect, N>&
84  getVects() const noexcept;
85 
90  inline std::array<RealVect, N>&
91  getVects() noexcept;
92 
99  template <size_t K>
100  inline Real&
101  real();
102 
109  template <size_t K>
110  inline const Real&
111  real() const;
112 
119  template <size_t K>
120  inline RealVect&
121  vect();
122 
129  template <size_t K>
130  inline const RealVect&
131  vect() const;
132 
138  inline bool
139  operator==(const GenericParticle<M, N>& a_other) const;
140 
146  inline bool
147  operator!=(const GenericParticle<M, N>& a_other) const;
148 
152  inline bool
153  operator<(const GenericParticle<M, N>& a_other) const noexcept;
154 
158  inline virtual int
159  size() const;
160 
166  inline virtual void
167  linearOut(void* a_buffer) const;
168 
173  inline virtual void
174  linearIn(void* a_buffer);
175 
176 protected:
180  RealVect m_position;
181 
185  std::array<Real, M> m_scalars;
186 
190  std::array<RealVect, N> m_vectors;
191 };
192 
198 template <size_t M, size_t N>
199 inline std::ostream&
200 operator<<(std::ostream& ostr, const GenericParticle<M, N>& p);
201 
202 #include <CD_NamespaceFooter.H>
203 
205 
206 #endif
Implementation of CD_GenericParticle.H.
std::ostream & operator<<(std::ostream &ostr, const GenericParticle< M, N > &p)
Particle printing function.
Definition: CD_GenericParticleImplem.H:232
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