chombo-discharge
Loading...
Searching...
No Matches
CD_GenericParticle.H
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2021-2026 SINTEF Energy Research
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
6
13#ifndef CD_GENERICPARTICLE_H
14#define CD_GENERICPARTICLE_H
15
16// Std includes
17#include <string>
18#include <typeinfo>
19#include <cstdio>
20#include <cmath>
21#include <array>
22#include <cstdint>
23
24// Chombo includes
25#include <RealVect.H>
26
27// Our includes
28#include <CD_NamespaceHeader.H>
29
30namespace detail {
37 template <class T>
38 inline void
40 {
41 static_assert(std::is_trivially_copyable<T>::value,
42 "detail::pushParticleProperty expects trivially-copyable fields");
43
44 std::memcpy(p, &a_x, sizeof(T));
45
46 p += sizeof(T);
47 };
48
55 template <class T>
56 inline void
58 {
59 static_assert(std::is_trivially_copyable<T>::value,
60 "detail::pushParticleProperty expects trivially-copyable fields");
61
62 std::memcpy(&a_x, p, sizeof(T));
63
64 p += sizeof(T);
65 };
66} // namespace detail
67
75template <size_t M, size_t N>
77{
78public:
82 inline GenericParticle();
83
89
93 inline virtual ~GenericParticle();
94
99 inline const int32_t&
101
108
115
122
128 position();
129
135 position() const;
136
143
148 inline std::array<Real, M>&
150
157
164
171 template <size_t K>
172 inline Real&
173 real();
174
181 template <size_t K>
183 real() const;
184
191 template <size_t K>
193 vect();
194
201 template <size_t K>
203 vect() const;
204
211 inline bool
213
220 inline bool
222
228 inline bool
230
235 inline virtual int
236 size() const;
237
243 inline virtual void
244 linearOut(void* a_buffer) const;
245
250 inline virtual void
251 linearIn(const void* a_buffer);
252
259 inline virtual int
260 H5size() const;
261
268 inline virtual void
270
277 inline virtual void
279
285
290
295
300
305};
306
313template <size_t M, size_t N>
316
317#include <CD_NamespaceFooter.H>
318
320
321#endif
Implementation of CD_GenericParticle.H.
void pullParticleProperty(const uint8_t *&p, T &a_x)
Helper function for linearizing a buffer onto a particle property.
Definition CD_GenericParticle.H:57
void pushParticleProperty(uint8_t *&p, const T &a_x)
Helper function for linearizing a particle onto a buffer.
Definition CD_GenericParticle.H:39
A generic particle class, holding the position and a specified number of real and vector values.
Definition CD_GenericParticle.H:77
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:207
virtual ~GenericParticle()
Destructor (deallocates runtime memory storage)
const int32_t & particleID() const noexcept
Get the particle ID.
Definition CD_GenericParticleImplem.H:59
virtual int H5size() const
Function that is used when writing particles to HDF5.
Definition CD_GenericParticleImplem.H:263
int32_t m_rankID
MPI rank owning this particle.
Definition CD_GenericParticle.H:289
RealVect & position()
Get the particle position.
Definition CD_GenericParticleImplem.H:45
Real & real()
Get one of the scalars.
Definition CD_GenericParticleImplem.H:116
const std::array< Real, M > & getReals() const noexcept
Get the M scalars.
Definition CD_GenericParticleImplem.H:87
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:191
virtual void H5linearOut(void *a_buffer) const
Linearize the Real components onto a buffer workable by HDF5.
Definition CD_GenericParticleImplem.H:276
RealVect & vect()
Get one of the RealVects.
Definition CD_GenericParticleImplem.H:132
const int32_t & rankID() const noexcept
Get the MPI rank ID.
Definition CD_GenericParticleImplem.H:73
int32_t m_particleID
Particle ID.
Definition CD_GenericParticle.H:284
virtual void linearIn(const void *a_buffer)
Read a linear binary representation of the internal data. Assumes that the buffer has the correct dat...
Definition CD_GenericParticleImplem.H:235
virtual void H5linearIn(const void *a_buffer)
Delinearize the buffer onto the real components in the particle class.
Definition CD_GenericParticleImplem.H:301
RealVect m_position
Particle position.
Definition CD_GenericParticle.H:294
GenericParticle()
Default constructor – initializes everything to zero.
Definition CD_GenericParticleImplem.H:21
std::array< Real, M > m_scalars
Scalar storage array.
Definition CD_GenericParticle.H:299
std::array< RealVect, N > m_vectors
vector storage array
Definition CD_GenericParticle.H:304
const std::array< RealVect, N > & getVects() const noexcept
Get the N vectors.
Definition CD_GenericParticleImplem.H:101
Base class for a tracer particle solver. This solver can advance particles in a pre-defined velocity ...
Definition CD_TracerParticleSolver.H:38
TracerParticleSolver()
Default constructor.
Definition CD_TracerParticleSolverImplem.H:26