chombo-discharge
Loading...
Searching...
No Matches
CD_ItoParticleImplem.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_ITOPARTICLEIMPLEM_H
14#define CD_ITOPARTICLEIMPLEM_H
15
16// Std includes
17#include <string>
18#include <typeinfo>
19#include <cstdio>
20#include <cmath>
21
22// Our includes
23#include <CD_ItoParticle.H>
24#include <CD_NamespaceHeader.H>
25
27{
28 this->define(1.0, RealVect::Zero, RealVect::Zero, 0.0, 0.0, 0.0);
29}
30
32 const RealVect& a_position,
33 const RealVect& a_velocity,
34 const Real a_diffusion,
35 const Real a_mobility,
36 const Real a_energy)
37{
39}
40
42{
43 this->weight() = a_other.weight();
44 this->position() = a_other.position();
45 this->oldPosition() = a_other.oldPosition();
46 this->velocity() = a_other.velocity();
47 this->diffusion() = a_other.diffusion();
48 this->mobility() = a_other.mobility();
49 this->energy() = a_other.energy();
50}
51
54
55inline void
57 const RealVect& a_position,
58 const RealVect& a_velocity,
59 const Real a_diffusion,
60 const Real a_mobility,
61 const Real a_energy)
62{
63 this->weight() = a_weight;
64 this->position() = a_position;
65 this->velocity() = a_velocity;
66 this->diffusion() = a_diffusion;
67 this->mobility() = a_mobility;
68 this->energy() = a_energy;
69}
70
71inline Real&
73{
74 return this->real<0>();
75}
76
77inline const Real&
79{
80 return this->real<0>();
81}
82
83inline Real&
85{
86 return this->real<1>();
87}
88
89inline const Real&
91{
92 return this->real<1>();
93}
94
95inline Real&
97{
98 return this->real<2>();
99}
100
101inline const Real&
103{
104 return this->real<2>();
105}
106
107inline Real&
109{
110 return this->real<3>();
111}
112
113inline const Real&
115{
116 return this->real<3>();
117}
118
119inline RealVect&
121{
122 return this->vect<0>();
123}
124
125inline const RealVect&
127{
128 return this->vect<0>();
129}
130
131inline RealVect&
133{
134 return this->vect<1>();
135}
136
137inline const RealVect&
139{
140 return this->vect<1>();
141}
142
143inline Real
145{
146 return this->weight() * this->mobility();
147}
148
149inline Real
151{
152 return this->weight() * this->diffusion();
153}
154
155inline Real
157{
158 return this->weight() * this->energy();
159}
160
161inline Real&
163{
164 return this->real<4>();
165}
166
167inline const Real&
169{
170 return this->real<4>();
171}
172
173inline RealVect&
175{
176 return this->vect<2>();
177}
178
179inline const RealVect&
181{
182 return this->vect<2>();
183}
184
185inline int
187{
188 int size = 0;
189
190 size += sizeof(Real); // m_weight
191 size += SpaceDim * sizeof(Real); // m_position
192 size += SpaceDim * sizeof(Real); // m_velocity
193
194 return size;
195}
196
197inline void
199{
200 uint8_t* p = static_cast<uint8_t*>(a_buffer);
201
202 detail::pushParticleProperty(p, this->weight());
203
204 detail::pushParticleProperty(p, this->m_position[0]);
205 detail::pushParticleProperty(p, this->m_position[1]);
206#if CH_SPACEDIM == 3
207 detail::pushParticleProperty(p, this->m_position[2]);
208#endif
209
210 detail::pushParticleProperty(p, this->velocity()[0]);
211 detail::pushParticleProperty(p, this->velocity()[1]);
212#if CH_SPACEDIM == 3
213 detail::pushParticleProperty(p, this->velocity()[2]);
214#endif
215}
216
217inline void
219{
220 const uint8_t* p = static_cast<const uint8_t*>(a_buffer);
221
222 detail::pullParticleProperty(p, this->weight());
223
224 detail::pullParticleProperty(p, this->m_position[0]);
225 detail::pullParticleProperty(p, this->m_position[1]);
226#if CH_SPACEDIM == 3
227 detail::pullParticleProperty(p, this->m_position[2]);
228#endif
229
230 detail::pullParticleProperty(p, this->velocity()[0]);
231 detail::pullParticleProperty(p, this->velocity()[1]);
232#if CH_SPACEDIM == 3
233 detail::pullParticleProperty(p, this->velocity()[2]);
234#endif
235}
236
237#include <CD_NamespaceFooter.H>
238
239#include <CD_ItoParticleImplem.H>
240
241#endif
Implementation of CD_ItoParticle.H.
Declaration of a particle class for Ito diffusion.
RealVect & position()
Get the particle position.
Definition CD_GenericParticleImplem.H:45
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
RealVect m_position
Particle position.
Definition CD_GenericParticle.H:294
A particle class for use with ItoSolvers, i.e. drifting Brownian walkers.
Definition CD_ItoParticle.H:41
Real & energy()
Get average particle energy.
Definition CD_ItoParticleImplem.H:108
virtual void H5linearOut(void *const a_buffer) const
Linearize the checkpointed Real components onto a buffer workable by HDF5.
Definition CD_ItoParticleImplem.H:198
virtual void H5linearIn(const void *const a_buffer)
Delinearize the buffer onto the checkpointed real components in the particle class.
Definition CD_ItoParticleImplem.H:218
Real conductivity() const
Get the particle conductivity.
Definition CD_ItoParticleImplem.H:144
virtual ~ItoParticle()
Destructor (deallocates runtime memory storage)
Definition CD_ItoParticleImplem.H:52
Real & diffusion()
Get particle diffusion coefficient.
Definition CD_ItoParticleImplem.H:96
ItoParticle()
Default constructor – user should subsequently set the variables or call define.
Definition CD_ItoParticleImplem.H:26
Real & mobility()
Get mobility coefficient.
Definition CD_ItoParticleImplem.H:84
RealVect & oldPosition()
Get the old particle position.
Definition CD_ItoParticleImplem.H:120
RealVect & tmpVect()
Return scratch RealVect storage.
Definition CD_ItoParticleImplem.H:174
void define(const Real a_weight, const RealVect &a_position, const RealVect &a_velocity=RealVect::Zero, const Real a_diffusion=0.0, const Real a_mobility=1.0, const Real a_energy=0.0)
Full define function.
Definition CD_ItoParticleImplem.H:56
Real diffusivity() const
Get the particle diffusivity.
Definition CD_ItoParticleImplem.H:150
virtual int H5size() const
Function that is used when writing particles to HDF5.
Definition CD_ItoParticleImplem.H:186
Real totalEnergy() const
Get the total energy.
Definition CD_ItoParticleImplem.H:156
Real & weight()
Get particle weight.
Definition CD_ItoParticleImplem.H:72
RealVect & velocity()
Get the particle velocity.
Definition CD_ItoParticleImplem.H:132
Real & tmpReal()
Return scratch scalar storage.
Definition CD_ItoParticleImplem.H:162
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