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