OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | List of all members
olb::InamuroNewtonRaphsonDynamics< T, DESCRIPTOR, Dynamics, MOMENTA, direction, orientation > Class Template Reference

This class computes the inamuro BC with general dynamics. More...

#include <inamuroNewtonRaphsonDynamics.h>

+ Inheritance diagram for olb::InamuroNewtonRaphsonDynamics< T, DESCRIPTOR, Dynamics, MOMENTA, direction, orientation >:
+ Collaboration diagram for olb::InamuroNewtonRaphsonDynamics< T, DESCRIPTOR, Dynamics, MOMENTA, direction, orientation >:

Public Member Functions

 InamuroNewtonRaphsonDynamics (T omega)
 Constructor.
 
computeEquilibrium (int iPop, T rho, const T u[DESCRIPTOR::d], T uSqr) const override
 Compute equilibrium distribution function.
 
CellStatistic< T > collide (Cell< T, DESCRIPTOR > &cell, LatticeStatistics< T > &statistics) override
 Collision step.
 
getOmega () const
 Get local relaxation parameter of the dynamics.
 
void setOmega (T omega)
 Set local relaxation parameter of the dynamics.
 
- Public Member Functions inherited from olb::legacy::BasicDynamics< T, DESCRIPTOR, MOMENTA >
computeEquilibrium (int iPop, T rho, const T u[DESCRIPTOR::d]) const override
 Return iPop equilibrium for given first and second momenta.
 
std::type_index id () override
 Expose unique type-identifier for RTTI.
 
AbstractParameters< T, DESCRIPTOR > & getParameters (BlockLattice< T, DESCRIPTOR > &block) override
 Parameters access for legacy post processors.
 
- Public Member Functions inherited from olb::dynamics::CustomCollision< T, DESCRIPTOR, MOMENTA >
void initialize (Cell< T, DESCRIPTOR > &cell) override
 Initialize dynamics-specific data for cell.
 
computeRho (ConstCell< T, DESCRIPTOR > &cell) const override
 Compute particle density.
 
void computeU (ConstCell< T, DESCRIPTOR > &cell, T u[DESCRIPTOR::d]) const override
 Compute fluid velocity.
 
void computeJ (ConstCell< T, DESCRIPTOR > &cell, T j[DESCRIPTOR::d]) const override
 Compute fluid momentum.
 
void computeStress (ConstCell< T, DESCRIPTOR > &cell, T rho, const T u[DESCRIPTOR::d], T pi[util::TensorVal< DESCRIPTOR >::n]) const override
 Compute stress tensor.
 
void computeRhoU (ConstCell< T, DESCRIPTOR > &cell, T &rho, T u[DESCRIPTOR::d]) const override
 Compute fluid velocity and particle density.
 
void computeAllMomenta (ConstCell< T, DESCRIPTOR > &cell, T &rho, T u[DESCRIPTOR::d], T pi[util::TensorVal< DESCRIPTOR >::n]) const override
 Compute all momenta up to second order.
 
void defineRho (Cell< T, DESCRIPTOR > &cell, T rho) override
 Set particle density.
 
void defineU (Cell< T, DESCRIPTOR > &cell, const T u[DESCRIPTOR::d]) override
 Set fluid velocity.
 
void defineRhoU (Cell< T, DESCRIPTOR > &cell, T rho, const T u[DESCRIPTOR::d]) override
 Define fluid velocity and particle density.
 
void defineAllMomenta (Cell< T, DESCRIPTOR > &cell, T rho, const T u[DESCRIPTOR::d], const T pi[util::TensorVal< DESCRIPTOR >::n]) override
 Define all momenta up to second order.
 
void inverseShiftRhoU (ConstCell< T, DESCRIPTOR > &cell, T &rho, T u[DESCRIPTOR::d]) const override
 Calculate population momenta s.t. the physical momenta are reproduced by the computeRhoU.
 
- Public Member Functions inherited from olb::Dynamics< T, DESCRIPTOR >
virtual ~Dynamics () any_platform
 
virtual std::string getName () const
 Return human-readable name.
 
virtual CellStatistic< T > collide (Cell< T, DESCRIPTOR > &cell)
 Perform purely-local collision step on Cell interface (legacy, to be deprecated)
 
void iniEquilibrium (Cell< T, DESCRIPTOR > &cell, T rho, const T u[DESCRIPTOR::d])
 Initialize to equilibrium distribution.
 
void iniRegularized (Cell< T, DESCRIPTOR > &cell, T rho, const T u[DESCRIPTOR::d], const T pi[util::TensorVal< DESCRIPTOR >::n])
 Initialize cell to equilibrium and non-equilibrum part.
 

Additional Inherited Members

- Public Types inherited from olb::dynamics::CustomCollision< T, DESCRIPTOR, MOMENTA >
using value_t = T
 
using descriptor_t = DESCRIPTOR
 
using MomentaF = typename MOMENTA::template type<DESCRIPTOR>
 
- Public Types inherited from olb::Dynamics< T, DESCRIPTOR >
using value_t = T
 
using descriptor_t = DESCRIPTOR
 

Detailed Description

template<typename T, typename DESCRIPTOR, typename Dynamics, typename MOMENTA, int direction, int orientation>
class olb::InamuroNewtonRaphsonDynamics< T, DESCRIPTOR, Dynamics, MOMENTA, direction, orientation >

This class computes the inamuro BC with general dynamics.

It uses the formula from the paper by Inamuro et al. but since there is no explict solution for a lattice different from the D2Q9 and for a speed of sound c_s=q/util::sqrt(3), we have to use a Newton-Raphson algorithm to implement these boundary conditions.

Definition at line 40 of file inamuroNewtonRaphsonDynamics.h.

Constructor & Destructor Documentation

◆ InamuroNewtonRaphsonDynamics()

template<typename T , typename DESCRIPTOR , typename Dynamics , typename MOMENTA , int direction, int orientation>
olb::InamuroNewtonRaphsonDynamics< T, DESCRIPTOR, Dynamics, MOMENTA, direction, orientation >::InamuroNewtonRaphsonDynamics ( T omega)

Constructor.

Definition at line 39 of file inamuroNewtonRaphsonDynamics.hh.

40 : legacy::BasicDynamics<T,DESCRIPTOR,MOMENTA>(),
41 _boundaryDynamics(omega),
42 clout(std::cout,"InamuroNewtonRaphsonDynamics")
43{
44 this->getName() = "InamuroNewtonRaphsonDynamics";
45 _xi[0] = (T)1;
46 for (int iDim = 1; iDim < DESCRIPTOR::d; ++iDim) {
47 _xi[iDim] = T();
48 }
49}
virtual std::string getName() const
Return human-readable name.
Definition interface.h:63

References olb::Dynamics< T, DESCRIPTOR >::getName().

+ Here is the call graph for this function:

Member Function Documentation

◆ collide()

template<typename T , typename DESCRIPTOR , typename Dynamics , typename MOMENTA , int direction, int orientation>
CellStatistic< T > olb::InamuroNewtonRaphsonDynamics< T, DESCRIPTOR, Dynamics, MOMENTA, direction, orientation >::collide ( Cell< T, DESCRIPTOR > & cell,
LatticeStatistics< T > & statistics )
override

Collision step.

Definition at line 59 of file inamuroNewtonRaphsonDynamics.hh.

62{
63 typedef DESCRIPTOR L;
64
65 T rho, u[L::d];
66 MOMENTA().computeRhoU(cell,rho,u);
67
68 constexpr auto missingIndexes = util::subIndexOutgoing<L,direction,orientation>();
69 std::vector<int> knownIndexes;
70 bool test[L::q];
71 for (int iPop = 0; iPop < L::q; ++iPop) {
72 test[iPop] = true;
73 }
74
75 for (unsigned iPop = 0; iPop < missingIndexes.size(); ++iPop) {
76 test[missingIndexes[iPop]] = false;
77 }
78 for (int iPop = 0; iPop < L::q; ++iPop) {
79 if (test[iPop]) {
80 knownIndexes.push_back(iPop);
81 }
82 }
83
84 T approxMomentum[L::d];
85
86 computeApproxMomentum(approxMomentum,cell,rho,u,_xi,knownIndexes,missingIndexes);
87
88 T error = computeError(rho, u,approxMomentum);
89 int counter = 0;
90
91 while (error > 1.0e-15) {
92 ++counter;
93
94 T gradError[L::d], gradGradError[L::d][L::d];
95 computeGradGradError(gradGradError,gradError,rho,u,_xi,approxMomentum,missingIndexes);
96
97 bool everythingWentFine = newtonRaphson(_xi,gradError,gradGradError);
98 if ((counter > 100000) || everythingWentFine == false) {
99 // if we need more that 100000 iterations or
100 // if we have a problem with the inversion of the
101 // jacobian matrix, we stop the program and
102 // print this error message on the screen.
103 clout << "Failed to converge...." << std::endl;
104 clout << "Error = " << error << std::endl;
105 clout << "u = (" << rho*u[0];
106 for (int iD=1; iD<DESCRIPTOR::d; ++iD) {
107 clout << ", " << rho*u[iD];
108 }
109 clout << ")" << std::endl;
110 clout << "uApprox = (" << approxMomentum[0];
111 for (int iD=1; iD<DESCRIPTOR::d; ++iD) {
112 clout << ", " << approxMomentum[iD];
113 }
114 clout << ")" << std::endl;
115 clout << "xi = (" << _xi[0];
116 for (int iD=1; iD<DESCRIPTOR::d; ++iD) {
117 clout << ", " << _xi[iD];
118 }
119 clout << ")" << std::endl;
120
121 exit(1);
122 }
123
124 computeApproxMomentum(approxMomentum,cell,rho,u,_xi,knownIndexes,missingIndexes);
125 error = computeError(rho, u,approxMomentum);
126
127 }
128
129 T uCs[L::d];
130 int counterDim = 0;
131 for (int iDim = 0; iDim < L::d; ++iDim) {
132 if (direction == iDim) {
133 ++counterDim;
134 uCs[iDim] = u[iDim];
135 }
136 else {
137 uCs[iDim] = u[iDim] + _xi[iDim+1-counterDim];
138 }
139 }
140
141 T uCsSqr = util::normSqr<T,L::d>(uCs);
142
143 for (unsigned iPop = 0; iPop < missingIndexes.size(); ++iPop) {
144 cell[missingIndexes[iPop]] = computeEquilibrium(missingIndexes[iPop],_xi[0],uCs,uCsSqr);
145 }
146
147 _boundaryDynamics.collide(cell, statistics);
148}
T computeEquilibrium(int iPop, T rho, const T u[DESCRIPTOR::d], T uSqr) const override
Compute equilibrium distribution function.
void exit(int exitcode)
Definition singleton.h:165
virtual CellStatistic< T > collide(Cell< T, DESCRIPTOR > &cell)
Perform purely-local collision step on Cell interface (legacy, to be deprecated)
Definition interface.h:74

◆ computeEquilibrium()

template<typename T , typename DESCRIPTOR , typename Dynamics , typename MOMENTA , int direction, int orientation>
T olb::InamuroNewtonRaphsonDynamics< T, DESCRIPTOR, Dynamics, MOMENTA, direction, orientation >::computeEquilibrium ( int iPop,
T rho,
const T u[DESCRIPTOR::d],
T uSqr ) const
override

Compute equilibrium distribution function.

Definition at line 52 of file inamuroNewtonRaphsonDynamics.hh.

54{
55 return _boundaryDynamics.computeEquilibrium(iPop, rho, u, uSqr);
56}
virtual T computeEquilibrium(int iPop, T rho, const T u[DESCRIPTOR::d]) const any_platform=0
Return iPop equilibrium for given first and second momenta.

◆ getOmega()

template<typename T , typename DESCRIPTOR , typename Dynamics , typename MOMENTA , int direction, int orientation>
T olb::InamuroNewtonRaphsonDynamics< T, DESCRIPTOR, Dynamics, MOMENTA, direction, orientation >::getOmega ( ) const

Get local relaxation parameter of the dynamics.

Definition at line 151 of file inamuroNewtonRaphsonDynamics.hh.

152{
153 return _boundaryDynamics.getOmega();
154}

◆ setOmega()

template<typename T , typename DESCRIPTOR , typename Dynamics , typename MOMENTA , int direction, int orientation>
void olb::InamuroNewtonRaphsonDynamics< T, DESCRIPTOR, Dynamics, MOMENTA, direction, orientation >::setOmega ( T omega)

Set local relaxation parameter of the dynamics.

Definition at line 157 of file inamuroNewtonRaphsonDynamics.hh.

158{
159 _boundaryDynamics.setOmega(omega);
160}

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