MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
lptbase.h
Go to the documentation of this file.
1// Copyright (C) 2024 The m-AIA AUTHORS
2//
3// This file is part of m-AIA (https://git.rwth-aachen.de/aia/m-AIA/m-AIA)
4//
5// SPDX-License-Identifier: LGPL-3.0-only
6
7#ifndef _ParticleBase_H
8#define _ParticleBase_H
9
10#include <array>
11#include <vector>
12#include "INCLUDE/maiatypes.h"
13#include "UTIL/functions.h"
14#include "lptbaseproperties.h"
15
16template <MInt nDim>
17class LPT;
18
19template <MInt nDim>
20class LPTBase {
21 public:
22 virtual ~LPTBase() = default;
23
25
30
31 static constexpr MInt s_floatElements = 3 * nDim + 1;
32 static constexpr MInt s_intElements = 5;
33
34 std::array<MFloat, nDim> m_position{};
35 std::array<MFloat, nDim> m_velocity{};
36 std::array<MFloat, nDim> m_accel{};
37
39 std::array<MFloat, nDim> m_oldPos{};
41 std::array<MFloat, nDim> m_oldVel{};
42
43 // initialised with invalid values
48
50 MFloat m_creationTime = std::numeric_limits<MFloat>::quiet_NaN();
51
53 // unversal acces
54 BitsetType::reference hasProperty(const LptBaseProperty p);
55 MBool hasProperty(const LptBaseProperty p) const;
56
57 // access directly to individual base-properties!
58 BitsetType::reference isWindow();
59 MBool isWindow() const;
60 BitsetType::reference reqSend();
61 MBool reqSend() const;
62 BitsetType::reference reqBroadcast();
63 MBool reqBroadcast() const;
64 BitsetType::reference isInvalid();
65 MBool isInvalid() const;
66 BitsetType::reference hasCollided();
67 MBool hasCollided() const;
68 BitsetType::reference hadWallColl();
69 MBool hadWallColl() const;
70 BitsetType::reference firstStep();
71 MBool firstStep() const;
72 BitsetType::reference toBeDeleted();
73 MBool toBeDeleted() const;
74 BitsetType::reference wasSend();
75 MBool wasSend() const;
76 BitsetType::reference toBeRespawn();
77 MBool toBeRespawn() const;
78 BitsetType::reference fullyEvaporated();
79 MBool fullyEvaporated() const;
80
81 // store neighbor cells including diagonals
82 std::vector<MInt> m_neighborList;
83
84 void getNghbrList(std::vector<MInt>&, const MInt);
85
86 template <MInt a, MInt b>
87 void interpolateAndCalcWeights(const MInt cellId, const MFloat* const x, MFloat* const result,
88 std::vector<MFloat>& weight, MFloat* const gradientResult = nullptr);
89
90 virtual void energyEquation() = 0;
91 virtual void coupling() = 0;
92 virtual void motionEquation() = 0;
93 virtual void advanceParticle() = 0;
94 virtual void resetWeights() = 0;
95
96
97 virtual void particleWallCollision();
98 virtual void wallParticleCollision();
99 void initProperties();
100
101 void checkCellChange(const MFloat* oldPosition, const MBool allowHaloNonLeaf = false);
102 void updateProperties(const MBool init = true);
103
104 virtual MFloat effectiveWallCollisionRadius() const { TERMM(-1, "Effective wall collision radius not implemented!"); }
105};
106
108template <MInt nDim>
110 return m_properties[maia::lpt::baseProperty::p(p)];
111}
113template <MInt nDim>
115 return m_properties[maia::lpt::baseProperty::p(p)];
116}
117
118template <MInt nDim>
120 return hasProperty(LptBaseProperty::IsWindow);
121}
122
123template <MInt nDim>
125 return hasProperty(LptBaseProperty::IsWindow);
126}
127template <MInt nDim>
129 return hasProperty(LptBaseProperty::ReqSend);
130}
131
132template <MInt nDim>
134 return hasProperty(LptBaseProperty::ReqSend);
135}
136template <MInt nDim>
138 return hasProperty(LptBaseProperty::ReqBroadcast);
139}
140
141template <MInt nDim>
143 return hasProperty(LptBaseProperty::ReqBroadcast);
144}
145template <MInt nDim>
147 return hasProperty(LptBaseProperty::IsInvalid);
148}
149
150template <MInt nDim>
152 return hasProperty(LptBaseProperty::IsInvalid);
153}
154template <MInt nDim>
156 return hasProperty(LptBaseProperty::HasCollided);
157}
158
159template <MInt nDim>
161 return hasProperty(LptBaseProperty::HasCollided);
162}
163template <MInt nDim>
165 return hasProperty(LptBaseProperty::HadWallColl);
166}
167
168template <MInt nDim>
170 return hasProperty(LptBaseProperty::HadWallColl);
171}
172
173template <MInt nDim>
175 return hasProperty(LptBaseProperty::FirstStep);
176}
177
178template <MInt nDim>
180 return hasProperty(LptBaseProperty::FirstStep);
181}
182
183template <MInt nDim>
185 return hasProperty(LptBaseProperty::ToBeDeleted);
186}
187
188template <MInt nDim>
190 return hasProperty(LptBaseProperty::ToBeDeleted);
191}
192
193template <MInt nDim>
195 return hasProperty(LptBaseProperty::WasSend);
196}
197
198template <MInt nDim>
200 return hasProperty(LptBaseProperty::WasSend);
201}
202template <MInt nDim>
204 return hasProperty(LptBaseProperty::ToBeRespawn);
205}
206
207template <MInt nDim>
209 return hasProperty(LptBaseProperty::ToBeRespawn);
210}
211
212template <MInt nDim>
214 return hasProperty(LptBaseProperty::FullyEvaporated);
215}
216
217template <MInt nDim>
219 return hasProperty(LptBaseProperty::FullyEvaporated);
220}
221
222template <MInt nDim>
224 isWindow() = false;
225 reqSend() = false;
226 reqBroadcast() = false;
227 isInvalid() = false;
228 hasCollided() = false;
229 firstStep() = false;
230 toBeDeleted() = false;
231 wasSend() = false;
232 toBeRespawn() = false;
233 fullyEvaporated() = false;
234 hadWallColl() = false;
235}
236
237#endif
BitsetType::reference toBeRespawn()
Definition: lptbase.h:208
virtual void particleWallCollision()
particle-wall collision step
Definition: lptbase.cpp:319
static LPT< nDim > * s_backPtr
Definition: lptbase.h:29
virtual ~LPTBase()=default
std::vector< MInt > m_neighborList
Definition: lptbase.h:82
virtual MFloat effectiveWallCollisionRadius() const
Definition: lptbase.h:104
void interpolateAndCalcWeights(const MInt cellId, const MFloat *const x, MFloat *const result, std::vector< MFloat > &weight, MFloat *const gradientResult=nullptr)
Definition: lptbase.cpp:24
MFloat m_creationTime
creation time modifier
Definition: lptbase.h:50
std::array< MFloat, nDim > m_position
Definition: lptbase.h:34
virtual void motionEquation()=0
static constexpr MInt s_floatElements
Definition: lptbase.h:31
static MInt s_interpolationOrder
Definition: lptbase.h:26
static MInt s_interpolationMethod
Definition: lptbase.h:27
MLong m_partId
Definition: lptbase.h:45
virtual void advanceParticle()=0
void getNghbrList(std::vector< MInt > &, const MInt)
Definition: lptbase.cpp:183
static constexpr MInt s_intElements
Definition: lptbase.h:32
std::array< MFloat, nDim > m_velocity
Definition: lptbase.h:35
BitsetType::reference firstStep()
Definition: lptbase.h:179
std::array< MFloat, nDim > m_oldPos
particle position of the last time step
Definition: lptbase.h:39
BitsetType::reference wasSend()
Definition: lptbase.h:199
virtual void wallParticleCollision()
wall-particle collision step
Definition: lptbase.cpp:656
BitsetType::reference hadWallColl()
Definition: lptbase.h:169
void updateProperties(const MBool init=true)
Update particle properties.
Definition: lptbase.cpp:299
BitsetType::reference isWindow()
Definition: lptbase.h:124
BitsetType m_properties
Definition: lptbase.h:52
MInt m_oldCellId
Definition: lptbase.h:47
std::array< MFloat, nDim > m_oldVel
particle velocity of the last time step
Definition: lptbase.h:41
void initProperties()
Definition: lptbase.h:223
static MFloat s_distFactorImp
Definition: lptbase.h:28
virtual void resetWeights()=0
virtual void energyEquation()=0
BitsetType::reference hasCollided()
Definition: lptbase.h:160
BitsetType::reference toBeDeleted()
Definition: lptbase.h:189
BitsetType::reference reqBroadcast()
Definition: lptbase.h:142
BitsetType::reference reqSend()
Definition: lptbase.h:133
MFloat m_densityRatio
Definition: lptbase.h:44
BitsetType::reference fullyEvaporated()
Definition: lptbase.h:218
MInt m_cellId
Definition: lptbase.h:46
virtual void coupling()=0
BitsetType::reference isInvalid()
Definition: lptbase.h:151
maia::lpt::baseProperty::BitsetType BitsetType
Definition: lptbase.h:24
void checkCellChange(const MFloat *oldPosition, const MBool allowHaloNonLeaf=false)
Checks whether position is within cell with number cellId if not, cellId is updated.
Definition: lptbase.cpp:233
std::array< MFloat, nDim > m_accel
Definition: lptbase.h:36
BitsetType::reference hasProperty(const LptBaseProperty p)
Accessor for properties.
Definition: lptbase.h:109
Definition: lpt.h:82
LptBaseProperty
Lpt particle Property Labels.
int32_t MInt
Definition: maiatypes.h:62
double MFloat
Definition: maiatypes.h:52
int64_t MLong
Definition: maiatypes.h:64
bool MBool
Definition: maiatypes.h:58
constexpr std::underlying_type< LptBaseProperty >::type p(const LptBaseProperty property)
Converts property name to underlying integer value.
std::bitset< p(LptBaseProperty::NumProperties)> BitsetType