MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
lptellipsoidal.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 _MAIAPARTICLEELLIPSOIDAL_H
8#define _MAIAPARTICLEELLIPSOIDAL_H
9
10#include <cmath>
11#include "UTIL/materialstate.h"
12#include "lptbase.h"
13
14template <MInt nDim, class SysEqn>
16
17template <MInt nDim>
18class LPTBase;
19
20template <MInt nDim>
21class LPTEllipsoidal : public LPTBase<nDim> {
22 public:
23 using LPTBase<nDim>::m_oldPos;
24 using LPTBase<nDim>::m_position;
25 using LPTBase<nDim>::m_velocity;
26 using LPTBase<nDim>::m_accel;
27 using LPTBase<nDim>::m_oldVel;
28 using LPTBase<nDim>::m_densityRatio;
29 using LPTBase<nDim>::s_backPtr;
30 using LPTBase<nDim>::m_cellId;
31 using LPTBase<nDim>::m_oldCellId;
32 using LPTBase<nDim>::m_partId;
33 using LPTBase<nDim>::m_creationTime;
34
35 using LPTBase<nDim>::firstStep;
36 using LPTBase<nDim>::isWindow;
37 using LPTBase<nDim>::reqSend;
38 using LPTBase<nDim>::reqBroadcast;
39 using LPTBase<nDim>::isInvalid;
40 using LPTBase<nDim>::hasCollided;
41 using LPTBase<nDim>::hadWallColl;
42 using LPTBase<nDim>::toBeDeleted;
43 using LPTBase<nDim>::wasSend;
44 using LPTBase<nDim>::toBeRespawn;
47
49 using LPTBase<nDim>::getNghbrList;
50 using LPTBase<nDim>::checkCellChange;
51 using LPTBase<nDim>::updateProperties;
52 using LPTBase<nDim>::m_neighborList;
53
55 ~LPTEllipsoidal() override = default;
56
57 LPTEllipsoidal(const LPTEllipsoidal&) = default;
59
61 std::array<MFloat, nDim> m_angularVel{};
63 std::array<MFloat, nDim> m_angularAccel{};
65 std::array<MFloat, nDim> m_fluidVel{};
67 MFloat m_fluidDensity = std::numeric_limits<MFloat>::quiet_NaN();
68
70 std::array<MFloat, nDim> m_oldAccel{};
72 std::array<MFloat, nDim> m_oldAngularVel{};
74 std::array<MFloat, nDim> m_oldAngularAccel{};
76 std::array<MFloat, nDim> m_oldFluidVel{};
77
79 std::array<MFloat, nDim * nDim> m_velocityGradientFluid{};
80
82 MFloat m_oldFluidDensity = std::numeric_limits<MFloat>::quiet_NaN();
83
85 MFloat m_aspectRatio = std::numeric_limits<MFloat>::quiet_NaN();
87 MFloat m_semiMinorAxis = std::numeric_limits<MFloat>::quiet_NaN();
89 std::array<MFloat, 4> m_shapeParams{std::numeric_limits<MFloat>::quiet_NaN()};
90
91 // Particle orientation using quaternions
92 std::array<MFloat, 4> m_quaternion{};
93 std::array<MFloat, 4> m_oldQuaternion{};
94
96 MFloat m_temperature = std::numeric_limits<MFloat>::quiet_NaN();
98 MFloat m_fluidVelMag = std::numeric_limits<MFloat>::quiet_NaN();
100 MFloat m_heatFlux = std::numeric_limits<MFloat>::quiet_NaN();
101
102 static constexpr MInt s_floatElements = 7 + 8 * nDim + 4 * 2;
103 static constexpr MInt s_intElements = 0;
104
105 MInt m_particleMajorAxis = 2; // index to the major axis, i.e. z-axis
106
108 static MFloat s_Re;
109 static MFloat s_Pr;
110 static MFloat s_Sc;
111 static MFloat s_We;
112 static std::array<MFloat, nDim> s_Frm;
113
114 // weights of the matching neighbors
115 std::vector<MFloat> m_redistWeight{};
116
117 void motionEquation() override;
118 void energyEquation() override;
119 void coupling() override;
120 void advanceParticle() override;
121 void resetWeights() override {
122 m_neighborList.clear();
123 this->template interpolateAndCalcWeights<0, 0>(m_cellId, m_position.data(), nullptr, m_redistWeight);
124 };
125
126 void calculateMajorAxisOrientation(MFloat* majorAxis);
127
128 MFloat dragFactor(const MFloat partRe, const MFloat beta = 1, const MFloat inclinationAngle = 0, const MFloat K0 = 0,
129 const MFloat K2 = 0);
130 MFloat liftFactor(const MFloat partRe, const MFloat beta, const MFloat inclinationAngle, const MFloat K0,
131 const MFloat K2);
132 MFloat torqueFactor(const MFloat partRe, const MFloat beta, const MFloat inclinationAngle);
133 void setParticleFluidVelocities(MInt cellId, MFloat* position, MFloat* quaternions, MFloat* fluidVel,
134 MFloat* fluidVelGrad);
135
136
137 template <MInt>
138 friend std::ostream& operator<<(std::ostream& os, const LPTEllipsoidal& m);
139
143 inline MFloat minParticleRadius() const { return m_semiMinorAxis; }
145 inline MFloat particleRadius(MInt direction) const {
146 if(direction == m_particleMajorAxis) {
147 return maxParticleRadius();
148 }
149 return minParticleRadius();
150 }
151
153 inline MFloat equivalentRadius() const { return F1B2 * m_eqDiameter; }
154
156 inline MFloat equivalentDiameter() const { return m_eqDiameter; }
157
159 inline MFloat particleVolume() const { return F4B3 * PI * POW3(m_semiMinorAxis) * m_aspectRatio; }
160
162 inline MFloat particleMass() const {
163 return F4B3 * PI * POW3(m_semiMinorAxis) * m_aspectRatio * s_backPtr->m_material->density();
164 }
165
167 inline MFloat magRelVel(const MFloat* const velocity1, const MFloat* const velocity2) const {
168 MFloat magnitude = 0.0;
169 for(MInt i = 0; i < nDim; i++) {
170 magnitude += POW2(velocity1[i] - velocity2[i]);
171 }
172 return sqrt(magnitude);
173 }
174
176 inline MFloat particleRe(const MFloat velocity, const MFloat density, const MFloat dynamicViscosity) {
177 return density * velocity * m_eqDiameter / dynamicViscosity;
178 }
179
181 inline MFloat fParticleRelTime(const MFloat dynamicViscosity) {
182 return 18.0 * dynamicViscosity / (m_eqDiameter * m_eqDiameter * s_backPtr->m_material->density());
183 }
184
186 inline MFloat effectiveWallCollisionRadius() const override { return equivalentRadius(); }
187
189 ASSERT(!std::isnan(m_aspectRatio), "Aspect Ratio not set!");
190 ASSERT(!std::isnan(m_semiMinorAxis), "Semi Minor Axis not set!");
193 }
194
196 std::array<MFloat, nDim + 1> result{};
197 std::vector<MFloat> weights;
198 this->template interpolateAndCalcWeights<0, nDim + 1>(m_cellId, m_position.data(), result.data(), weights);
199 for(MInt i = 0; i < nDim; i++) {
200 m_oldFluidVel[i] = result[i];
201 m_fluidVel[i] = result[i];
202 }
203 m_oldFluidDensity = result[nDim];
204 m_fluidDensity = result[nDim];
205 }
206
207 private:
209 MFloat m_eqDiameter = std::numeric_limits<MFloat>::quiet_NaN();
210
211 void initShapeParams();
213
214 void interpolateVelocityAndDensity(const MInt cellId, const MFloat* const position, MFloat* const velocity,
215 MFloat& density, std::vector<MFloat>& weights) {
216 std::array<MFloat, nDim + 1> result{};
217 this->template interpolateAndCalcWeights<0, nDim + 1>(cellId, position, result.data(), weights);
218 for(MInt n = 0; n < nDim; n++) {
219 velocity[n] = result[n];
220 }
221 density = result[nDim];
222 }
223
224 void interpolateVelocityAndVelocitySlopes(const MInt cellId, const MFloat* const position, MFloat* const velocity,
225 MFloat* const velocityGradient, std::vector<MFloat>& weights) {
226 std::array<MFloat, nDim> result{};
227 std::array<MFloat, nDim * nDim> gradientResult{};
228 this->template interpolateAndCalcWeights<0, nDim>(cellId, position, result.data(), weights, gradientResult.data());
229 for(MInt n = 0; n < nDim; n++) {
230 velocity[n] = result[n];
231 }
232 for(MInt n = 0; n < nDim * nDim; n++) {
233 velocityGradient[n] = gradientResult[n];
234 }
235 }
236
237 void momentumCoupling();
238 void heatCoupling();
239 void massCoupling();
240};
241
242template <MInt nDim>
243std::ostream& operator<<(std::ostream& os, const LPTEllipsoidal<nDim>& m) {
244 return os << m.m_partId;
245}
246
247#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
std::vector< MInt > m_neighborList
Definition: lptbase.h:82
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
MLong m_partId
Definition: lptbase.h:45
void getNghbrList(std::vector< MInt > &, const MInt)
Definition: lptbase.cpp:183
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
MInt m_oldCellId
Definition: lptbase.h:47
std::array< MFloat, nDim > m_oldVel
particle velocity of the last time step
Definition: lptbase.h:41
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
MInt m_cellId
Definition: lptbase.h:46
BitsetType::reference isInvalid()
Definition: lptbase.h:151
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
MFloat liftFactor(const MFloat partRe, const MFloat beta, const MFloat inclinationAngle, const MFloat K0, const MFloat K2)
Calculates the lift factor for current particle with given Re number, aspect ratio,...
static MFloat s_lengthFactor
std::array< MFloat, 4 > m_oldQuaternion
MFloat fParticleRelTime(const MFloat dynamicViscosity)
Calculates the reciprocal of the particle relaxation time.
MFloat m_eqDiameter
equivalent particle diameter
void resetWeights() override
LPTEllipsoidal(const LPTEllipsoidal &)=default
MFloat maxParticleRadius() const
Returns the largest radius.
LPTEllipsoidal()
constructor of ellipsoidal particles
MFloat torqueFactor(const MFloat partRe, const MFloat beta, const MFloat inclinationAngle)
Calculates the torque factor for current particle with given Re number, aspect ratio and inclination ...
static MFloat s_Re
MFloat effectiveWallCollisionRadius() const override
Returns the relevant particle radius for the wall collision.
friend std::ostream & operator<<(std::ostream &os, const LPTEllipsoidal &m)
std::array< MFloat, nDim > m_oldAccel
particle acceleration of the last time step
void interpolateVelocityAndVelocitySlopes(const MInt cellId, const MFloat *const position, MFloat *const velocity, MFloat *const velocityGradient, std::vector< MFloat > &weights)
MFloat particleVolume() const
Calculates the current volume.
static std::array< MFloat, nDim > s_Frm
void calculateMajorAxisOrientation(MFloat *majorAxis)
Calculate the orientation of the major axis in the world coordinate system.
void initVelocityAndDensity()
MFloat m_fluidVelMag
fluid velocity magnitude
void motionEquation() override
void interpolateVelocityAndDensity(const MInt cellId, const MFloat *const position, MFloat *const velocity, MFloat &density, std::vector< MFloat > &weights)
std::array< MFloat, nDim > m_oldAngularAccel
particle angular acceleration of the last time step
void heatCoupling()
add the heat flux from the particle to the cell/all surrounding cells
~LPTEllipsoidal() override=default
void initShapeParams()
Calcultes shape parameters for current particle (see Siewert, 2014)
static constexpr MInt s_intElements
MFloat m_oldFluidDensity
old fluid density
MFloat equivalentDiameter() const
Returns the equivalent diameter.
std::array< MFloat, nDim > m_fluidVel
fluid velocity
std::vector< MFloat > m_redistWeight
void coupling() override
single particle coupling terms
void momentumCoupling()
add the momentum flux from the particle to the cell/all surrounding cells
MFloat particleRe(const MFloat velocity, const MFloat density, const MFloat dynamicViscosity)
Calculates the particle Reynolds number.
MFloat minParticleRadius() const
Returns the smallest radius.
std::array< MFloat, nDim > m_angularAccel
particle angular acceleration
static MFloat s_Sc
MFloat m_temperature
temperature
static MFloat s_We
LPTEllipsoidal & operator=(const LPTEllipsoidal &)=default
std::array< MFloat, nDim > m_oldFluidVel
fluid velocity of the last time step
MFloat magRelVel(const MFloat *const velocity1, const MFloat *const velocity2) const
Calculates the magnitude of the relative velocity of the two given velocity vectors.
MFloat m_aspectRatio
aspect ratio a/c of ellipsoidal: 0 < oblate < 1, =1 spherical, >1 prolate
MFloat particleRadius(MInt direction) const
Returns the radius in direction d.
MFloat equivalentRadius() const
Returns the equivalent radius.
void advanceParticle() override
advance to new timeStep
static constexpr MInt s_floatElements
void energyEquation() override
std::array< MFloat, 4 > m_shapeParams
Shape parameters for ellipsoid.
MFloat particleMass() const
Calculates the current mass.
MFloat dragFactor(const MFloat partRe, const MFloat beta=1, const MFloat inclinationAngle=0, const MFloat K0=0, const MFloat K2=0)
Calculates the drag factor for current particle with given Re number, aspect ratio and inclination an...
static MFloat s_Pr
std::array< MFloat, nDim > m_oldAngularVel
particle angular velocity of the last time step
void massCoupling()
add the mass flux from the particle to the cell/all surrounding cells
std::array< MFloat, nDim *nDim > m_velocityGradientFluid
gradient of fluid velocity in the particle fixed coordinate system
std::array< MFloat, nDim > m_angularVel
particle angular velocity
std::array< MFloat, 4 > m_quaternion
void initEllipsoialProperties()
MFloat m_fluidDensity
fluid density
MFloat m_heatFlux
heat flux to cell
MFloat m_semiMinorAxis
semi minor axis a
void setParticleFluidVelocities(MInt cellId, MFloat *position, MFloat *quaternions, MFloat *fluidVel, MFloat *fluidVelGrad)
constexpr Real POW3(const Real x)
Definition: functions.h:123
constexpr Real POW2(const Real x)
Definition: functions.h:119
std::ostream & operator<<(std::ostream &os, const LPTEllipsoidal< nDim > &m)
int32_t MInt
Definition: maiatypes.h:62
double MFloat
Definition: maiatypes.h:52