MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
maia::lb::LbSrcTerm_nonnewtonian< nDim, nDist, SysEqn > Class Template Reference

Class to handle non-newtonian fluids. More...

Inheritance diagram for maia::lb::LbSrcTerm_nonnewtonian< nDim, nDist, SysEqn >:
[legend]
Collaboration diagram for maia::lb::LbSrcTerm_nonnewtonian< nDim, nDist, SysEqn >:
[legend]

Public Member Functions

 LbSrcTerm_nonnewtonian (LbSolverDxQy< nDim, nDist, SysEqn > *p_solver)
 
void init () override
 
void apply_preCollision () override
 
void apply_postCollision () override
 
void apply_postPropagation () override
 
MFloat powerLaw (const MFloat gamma_dot)
 
MFloat carreau (const MFloat gamma_dot)
 
- Public Member Functions inherited from maia::lb::LbSrcTerm< nDim, nDist, SysEqn >
virtual void init ()=0
 
virtual void apply_preCollision ()=0
 
virtual void apply_postCollision ()=0
 
virtual void apply_postPropagation ()=0
 
virtual ~LbSrcTerm ()=default
 

Public Attributes

MFloat(LbSrcTerm_nonnewtonian::* m_getNuFromNonNewtonianModel )(const MFloat gamma_dot)
 

Protected Member Functions

void readProperties () override
 
virtual void readProperties ()=0
 

Protected Attributes

LbSolverDxQy< nDim, nDist, SysEqn > * m_solver
 
MFloat m_nu0 = F0
 
MFloat m_nuInf = F0
 
MFloat m_lambda = F0
 
MFloat m_n = F0
 
MFloat m_a = F0
 
MString m_model = ""
 

Additional Inherited Members

- Public Types inherited from maia::lb::LbSrcTerm< nDim, nDist, SysEqn >
using SysEqn = SysEqn
 
- Static Public Attributes inherited from maia::lb::LbSrcTerm< nDim, nDist, SysEqn >
static constexpr MInt nDim
 
static constexpr MInt nDist
 

Detailed Description

template<MInt nDim, MInt nDist, class SysEqn>
class maia::lb::LbSrcTerm_nonnewtonian< nDim, nDist, SysEqn >
Author
Moritz Waldmann
Date
12.10.2023

Definition at line 24 of file lbsrctermnonnewtonian.cpp.

Constructor & Destructor Documentation

◆ LbSrcTerm_nonnewtonian()

template<MInt nDim, MInt nDist, class SysEqn >
maia::lb::LbSrcTerm_nonnewtonian< nDim, nDist, SysEqn >::LbSrcTerm_nonnewtonian ( LbSolverDxQy< nDim, nDist, SysEqn > *  p_solver)
inline

Definition at line 39 of file lbsrctermnonnewtonian.cpp.

39: m_solver(p_solver) { readProperties(); };
LbSolverDxQy< nDim, nDist, SysEqn > * m_solver

Member Function Documentation

◆ apply_postCollision()

template<MInt nDim, MInt nDist, class SysEqn >
void maia::lb::LbSrcTerm_nonnewtonian< nDim, nDist, SysEqn >::apply_postCollision ( )
inlineoverridevirtual

Implements maia::lb::LbSrcTerm< nDim, nDist, SysEqn >.

Definition at line 43 of file lbsrctermnonnewtonian.cpp.

43{/*NOT USED*/};

◆ apply_postPropagation()

template<MInt nDim, MInt nDist, class SysEqn >
void maia::lb::LbSrcTerm_nonnewtonian< nDim, nDist, SysEqn >::apply_postPropagation ( )
inlineoverridevirtual

Implements maia::lb::LbSrcTerm< nDim, nDist, SysEqn >.

Definition at line 44 of file lbsrctermnonnewtonian.cpp.

44{/*NOT USED*/};

◆ apply_preCollision()

template<MInt nDim, MInt nDist, class SysEqn >
void maia::lb::LbSrcTerm_nonnewtonian< nDim, nDist, SysEqn >::apply_preCollision
overridevirtual

Implements maia::lb::LbSrcTerm< nDim, nDist, SysEqn >.

Definition at line 92 of file lbsrctermnonnewtonian.cpp.

92 {
93 TRACE();
94 LbSolverDxQy<nDim, nDist, SysEqn>& s = *(m_solver); // alias for readability
95
96 s.m_nu = s.m_Ma * LBCS / s.m_Re * s.m_referenceLength;
97 maia::parallelFor(0, s.m_currentMaxNoCells, [&](MInt index) {
98 const MInt pCellId = s.m_activeCellList[index];
99 const MInt lvlDiff = s.maxLevel() - s.a_level(pCellId);
100 if((globalTimeStep - 1) % IPOW2(lvlDiff) != 0) return;
101
102 constexpr MInt nDimSqr = nDim * nDim;
103 std::array<MFloat, nDimSqr> c{};
104 const MFloat rho = s.a_variable(pCellId, s.PV->RHO);
105#ifndef WAR_NVHPC_PSTL
106 const MFloat* const u = &s.a_variable(pCellId, s.PV->U);
107 const MFloat* const dist = &s.a_oldDistribution(pCellId, 0);
108 s.sysEqn().calcMomentumFlux(rho, u, dist, c.data());
109#else
110 MFloat u[nDim] = {F0};
111 MFloat dist[nDist] = {F0};
112 for(MInt d = 0; d < nDim; d++) {
113 u[d] = s.a_variable(pCellId, d);
114 }
115 for(MInt d = 0; d < nDist; d++) {
116 dist[d] = s.a_oldDistribution(pCellId, d);
117 }
118 s.sysEqn().calcMomentumFlux(rho, u, dist, c.data());
119#endif
120
121 // Compute derivative of rate-of-strain tensor
122 std::array<MFloat, nDimSqr> localS{};
123
124 MFloat nu = F0;
125 MInt noIterations = 0;
126 MBool converged = false;
127 MFloat nuOld = s.a_oldNu(pCellId);
128 const MFloat F1Brho = F1 / rho;
129 while(!converged && noIterations < 50) {
130 MFloat omega = F2 / (F6 * nuOld * FFPOW2(lvlDiff) + F1);
131 for(MInt d = 0; d < nDimSqr; d++) {
132 localS[d] = -F3B2 * omega * F1Brho * c[d];
133 }
134
135 if(nDim == 3) {
136 const MFloat volumeStrains = F1B3 * (localS[0] + localS[4] + localS[8]);
137 localS[0] -= volumeStrains;
138 localS[4] -= volumeStrains;
139 localS[8] -= volumeStrains;
140 }
141
142 // Compute second invariant of the rate-of-strain tensor
143 MFloat D = F0; // Second invariant of rate-of-strain tensor
144 for(MInt d = 0; d < nDimSqr; d++) {
145 D += localS[d] * localS[d];
146 }
147 const MFloat gamma_dot = sqrt(F2 * D);
148
149 nu = (this->*m_getNuFromNonNewtonianModel)(gamma_dot);
150
151 if(fabs(nuOld - nu) < 1e-10) converged = true;
152
153 nuOld = nu;
154 noIterations++;
155 }
156
157 s.a_nu(pCellId) = nu;
158 });
159}
This class represents all LB models.
Definition: lbsolverdxqy.h:29
constexpr SysEqn sysEqn() const
Definition: lbsolverdxqy.h:194
MFloat(LbSrcTerm_nonnewtonian::* m_getNuFromNonNewtonianModel)(const MFloat gamma_dot)
int32_t MInt
Definition: maiatypes.h:62
double MFloat
Definition: maiatypes.h:52
bool MBool
Definition: maiatypes.h:58
void parallelFor(MInt begin, MInt end, UnaryFunction &&f)
Wrapper function for parallel for loop.
Definition: parallelfor.h:147
MFloat dist(const Point< DIM > &p, const Point< DIM > &q)
Definition: pointbox.h:54

◆ carreau()

template<MInt nDim, MInt nDist, class SysEqn >
MFloat maia::lb::LbSrcTerm_nonnewtonian< nDim, nDist, SysEqn >::carreau ( const MFloat  gamma_dot)

Definition at line 174 of file lbsrctermnonnewtonian.cpp.

174 {
175 TRACE();
176
177 // Compute local viscosity
178 const MFloat exp = (m_n - F1) / m_a;
179 const MFloat base = pow(m_lambda * gamma_dot, m_a) + F1;
180 const MFloat nu = m_nuInf + (m_nu0 - m_nuInf) * (pow(base, exp));
181
182 return nu;
183}

◆ init()

template<MInt nDim, MInt nDist, class SysEqn >
void maia::lb::LbSrcTerm_nonnewtonian< nDim, nDist, SysEqn >::init ( )
inlineoverridevirtual

Implements maia::lb::LbSrcTerm< nDim, nDist, SysEqn >.

Definition at line 41 of file lbsrctermnonnewtonian.cpp.

41{/*NOT USED*/};

◆ powerLaw()

template<MInt nDim, MInt nDist, class SysEqn >
MFloat maia::lb::LbSrcTerm_nonnewtonian< nDim, nDist, SysEqn >::powerLaw ( const MFloat  gamma_dot)

Definition at line 162 of file lbsrctermnonnewtonian.cpp.

162 {
163 TRACE();
164
165 // Compute local viscosity
166 const MFloat exp = m_n - F1;
167 const MFloat base = gamma_dot;
168 const MFloat nu = m_nu0 * (pow(base, exp));
169
170 return nu;
171}

◆ readProperties()

template<MInt nDim, MInt nDist, class SysEqn >
void maia::lb::LbSrcTerm_nonnewtonian< nDim, nDist, SysEqn >::readProperties
overrideprotectedvirtual

Implements maia::lb::LbSrcTerm< nDim, nDist, SysEqn >.

Definition at line 53 of file lbsrctermnonnewtonian.cpp.

53 {
54 TRACE();
55 const MInt solverId = m_solver->m_solverId;
56
57 m_model = Context::getSolverProperty<MString>("nonNewtonianModel", solverId, AT_);
58
59 switch(string2enum(m_model)) {
60 case CARREAU: {
61 m_nu0 = m_solver->m_nu;
62 const MFloat nu0 = Context::getSolverProperty<MFloat>("nu0", solverId, AT_);
63 const MFloat c_nu = nu0 / m_nu0;
64
65 const MFloat nuInf = Context::getSolverProperty<MFloat>("nuInf", solverId, AT_);
66 m_nuInf = nuInf / c_nu;
67
68 const MFloat lambda = Context::getSolverProperty<MFloat>("lambda", solverId, AT_);
69
70 m_lambda = lambda * m_solver->m_referenceLength / (m_solver->m_Ma * LBCS);
71
72 m_n = Context::getSolverProperty<MFloat>("nonNewtonian_n", solverId, AT_);
73 m_a = Context::getSolverProperty<MFloat>("nonNewtonian_a", solverId, AT_);
75 break;
76 }
77 case POWERLAW: {
78 m_n = Context::getSolverProperty<MFloat>("nonNewtonian_n", solverId, AT_);
79
80 m_solver->m_nu = pow(m_solver->m_Ma * LBCS, F2 - m_n) / m_solver->m_Re * pow(m_solver->m_referenceLength, m_n);
81 m_nu0 = m_solver->m_nu;
83 break;
84 }
85 default: {
86 mTerm(1, AT_, "This is not an implemented model!!!");
87 }
88 }
89}
MFloat carreau(const MFloat gamma_dot)
MFloat powerLaw(const MFloat gamma_dot)
MInt string2enum(MString theString)
This global function translates strings in their corresponding enum values (integer values)....
Definition: enums.cpp:20
@ POWERLAW
Definition: enums.h:263
@ CARREAU
Definition: enums.h:263
void mTerm(const MInt errorCode, const MString &location, const MString &message)
Definition: functions.cpp:29

Member Data Documentation

◆ m_a

template<MInt nDim, MInt nDist, class SysEqn >
MFloat maia::lb::LbSrcTerm_nonnewtonian< nDim, nDist, SysEqn >::m_a = F0
protected

Definition at line 32 of file lbsrctermnonnewtonian.cpp.

◆ m_getNuFromNonNewtonianModel

template<MInt nDim, MInt nDist, class SysEqn >
MFloat(LbSrcTerm_nonnewtonian::* maia::lb::LbSrcTerm_nonnewtonian< nDim, nDist, SysEqn >::m_getNuFromNonNewtonianModel) (const MFloat gamma_dot)

Definition at line 46 of file lbsrctermnonnewtonian.cpp.

◆ m_lambda

template<MInt nDim, MInt nDist, class SysEqn >
MFloat maia::lb::LbSrcTerm_nonnewtonian< nDim, nDist, SysEqn >::m_lambda = F0
protected

Definition at line 30 of file lbsrctermnonnewtonian.cpp.

◆ m_model

template<MInt nDim, MInt nDist, class SysEqn >
MString maia::lb::LbSrcTerm_nonnewtonian< nDim, nDist, SysEqn >::m_model = ""
protected

Definition at line 33 of file lbsrctermnonnewtonian.cpp.

◆ m_n

template<MInt nDim, MInt nDist, class SysEqn >
MFloat maia::lb::LbSrcTerm_nonnewtonian< nDim, nDist, SysEqn >::m_n = F0
protected

Definition at line 31 of file lbsrctermnonnewtonian.cpp.

◆ m_nu0

template<MInt nDim, MInt nDist, class SysEqn >
MFloat maia::lb::LbSrcTerm_nonnewtonian< nDim, nDist, SysEqn >::m_nu0 = F0
protected

Definition at line 28 of file lbsrctermnonnewtonian.cpp.

◆ m_nuInf

template<MInt nDim, MInt nDist, class SysEqn >
MFloat maia::lb::LbSrcTerm_nonnewtonian< nDim, nDist, SysEqn >::m_nuInf = F0
protected

Definition at line 29 of file lbsrctermnonnewtonian.cpp.

◆ m_solver

template<MInt nDim, MInt nDist, class SysEqn >
LbSolverDxQy<nDim, nDist, SysEqn>* maia::lb::LbSrcTerm_nonnewtonian< nDim, nDist, SysEqn >::m_solver
protected

Definition at line 26 of file lbsrctermnonnewtonian.cpp.


The documentation for this class was generated from the following file: