NeoPZ
pzincnskeps.cpp
Go to the documentation of this file.
1 
6 #include "pzincnskeps.h"
7 
10 TPZMaterial(id){
11  this->fDimension = dimension;
12 }
13 
15 
16 void TPZIncNavierStokesKEps::SetParameters(STATE MU, STATE RHO, STATE Cmu, STATE SigmaK, STATE SigmaEps, STATE Cepsilon1, STATE Cepsilon2, TPZVec<STATE> &BodyForce ){
17  fMU = MU;
18  fRHO = RHO;
19  fCmu = Cmu;
20  fSigmaK = SigmaK;
21  fSigmaEps = SigmaEps;
22  fCepsilon1 = Cepsilon1;
23  fCepsilon2 = Cepsilon2;
24  fBodyForce = BodyForce;
25 }
26 
27 void TPZIncNavierStokesKEps::GetParameters(STATE &MU, STATE &RHO, STATE &Cmu, STATE &SigmaK, STATE &SigmaEps, STATE &Cepsilon1, STATE &Cepsilon2, TPZVec<STATE> &BodyForce ){
28  MU = fMU;
29  RHO = fRHO;
30  Cmu = fCmu;
31  SigmaK = fSigmaK;
32  SigmaEps = fSigmaEps;
33  Cepsilon1 = fCepsilon1;
34  Cepsilon2 = fCepsilon2;
35  BodyForce = fBodyForce;
36 }
37 
39  return this->fDimension;
40 }
41 
43  return this->Dimension() + 3; //Vi + p + K + Eps
44 }
45 
46 void TPZIncNavierStokesKEps::Print(std::ostream &out){
47  TPZMaterial::Print(out);
48 }
49 
51  if ( (var == EK) || (var == EEpsilon) || (var == EPressure) ) return 1;
52  if (var == EVvector) return this->Dimension();
53  PZError << "ERROR: " << __PRETTY_FUNCTION__ << " - Variable var " << var << " not found";
54  return 0;
55 }
56 
58  TPZFMatrix<REAL> &axes, int var, TPZVec<STATE> &Solout){
59 
60  if (var == EK){
61  Solout[0] = Sol[EK];
62  return;
63  }//if
64 
65  if (var == EEpsilon){
66  Solout[0] = Sol[EEpsilon];
67  return;
68  }//if
69 
70  if (var == EPressure){
71  Solout[0] = Sol[EPressure];
72  return;
73  }//if
74 
75  if (var == EVvector){
76  int i, n = this->Dimension();
77  for(i = 0; i < n; i++){
78  Solout[i] = Sol[EVx + i];
79  }//for
80  return;
81  }//if
82 
83  PZError << "Variable " << var << " does not have post processing or does not exist" << std::endl;
84 
85 }
86 
88  REAL weight,
90  TPZFMatrix<STATE> &ef){
91 
92  int numbersol = data.sol.size();
93  if (numbersol != 1) {
94  DebugStop();
95  }
96 
97  TPZFMatrix<REAL> &dphi = data.dphix;
98  TPZFMatrix<REAL> &phi = data.phi;
99  TPZVec<STATE> &sol=data.sol[0];
100  TPZFMatrix<STATE> &dsol=data.dsol[0];
101 
102  STATE valor;
103 
104  const int dim = this->Dimension();
105  const int nstate = this->NStateVariables();
106  //Getting state variables
107  STATE K = sol[EK];
108  STATE Eps = sol[EEpsilon];
109  STATE Pressure = sol[EPressure];
110  TPZManVector<STATE,3> V(dim);
111  int i,j;
112  for(i = 0; i < dim; i++) V[i] = sol[EVx+i];
113 
114  //Getting Grad[state variables]
115  TPZManVector<STATE,3> GradK(dim,1);
116  for(i = 0; i < dim; i++) GradK[i] = dsol(i, EK);
117  TPZManVector<STATE,3> GradEps(dim,1);
118  for(i = 0; i < dim; i++) GradEps[i] = dsol(i, EEpsilon);
119  TPZManVector<STATE,3> GradPressure(dim,1);
120  for(i = 0; i < dim; i++) GradPressure[i] = dsol(i, EPressure);
121  TPZFNMatrix<9,STATE> GradV(dim,dim);
122  for(i = 0; i < dim; i++){
123  for(j = 0; j < dim; j++){
124  GradV(i,j) = dsol(j,EVx+i);
125  }
126  }
127 
128  //Constants:
129  STATE Rt = K*K /(Eps*fMU/fRHO);
130  STATE muT = fRHO * fCmu * (K*K/Eps) * exp(-2.5/(1.+Rt/50.));
131 
132  //TURBULENCE RESIDUALS
133  //CONSERVATION OF K
134  const int nShape = phi.Rows();
135  TPZFNMatrix<9,STATE> S(dim,dim);
136  for(i = 0; i < dim; i++){
137  for(j = 0; j < dim; j++){
138  S(i,j) = 0.5 * (GradV(i,j) + GradV(j,i) );
139  }
140  }
141  STATE Diss = 2. * fMU * (1. / (4. * K) ) * this->Dot(GradK, GradK);
142 
143  TPZManVector<STATE,3> GradPhi(dim);
144  for(i = 0; i < nShape; i++){
145  int k;
146  for(k = 0; k < dim; k++) GradPhi[k] = dphi(k,i);
147  ef(i*nstate+EK) += -1. * fRHO * this->Dot(V, GradPhi) * K
148  + (fMU + muT / fSigmaK) * Dot(GradK,GradPhi)
149  -2.0 * muT * this->Dot(S,GradV)*phi[i]
150  + fRHO * Eps * phi[i]
151  -1. * Diss;
152  valor = -1. * fRHO * this->Dot(V, GradPhi) * K
153  + (fMU + muT / fSigmaK) * Dot(GradK,GradPhi)
154  -2.0 * muT * this->Dot(S,GradV)*phi[i]
155  + fRHO * Eps * phi[i]
156  -1. * Diss;
157  }
158 
159  //CONSERVATION OF EPSILON
160  for(i = 0; i < nShape; i++){
161  int k;
162  for(k = 0; k < dim; k++) GradPhi[k] = dphi(k,i);
163  ef(i*nstate+EEpsilon) += -1. * fRHO * this->Dot(V, GradPhi) * Eps
164  + (fMU + muT / fSigmaEps) * this->Dot(GradEps, GradPhi)
165  -1. * fCepsilon1 * (Eps/K) * 2. * muT * this->Dot(S,GradV) * phi[i]
166  + fCepsilon2 * (Eps*Eps/K) * phi[i];
167  valor = -1. * fRHO * this->Dot(V, GradPhi) * Eps
168  + (fMU + muT / fSigmaEps) * this->Dot(GradEps, GradPhi)
169  -1. * fCepsilon1 * (Eps/K) * 2. * muT * this->Dot(S,GradV) * phi[i]
170  + fCepsilon2 * (Eps*Eps/K) * phi[i];
171  }
172 
173  //INCOMPRESSIBLE NAVIERS-STOKES RESIDUALS
174  //CONTINUITY EQUATION
175  for(i = 0; i < nShape; i++){
176  STATE trGradV = 0.;
177  int k;
178  for(k = 0; k < dim; k++) trGradV += GradV(k,k);
179  ef(i*nstate+EPressure) += trGradV * phi[i];
180  valor = trGradV * phi[i];
181  }
182 
183  //CONSERVATION OF LINEAR MOMENTUM
184  TPZFNMatrix<9,STATE> T(dim,dim);
185  //T = -p I + (mu + muT) * 2 * S
186  T = S;
187  T *= (fMU + muT ) *2.;
188  for(i = 0; i < dim; i++) T(i,i) += -1. * Pressure;
189 
190  for(j = 0; j < dim; j++){
191  for(i = 0; i < nShape; i++){
192  int k;
193  for(k = 0; k < dim; k++) GradPhi[k] = dphi(k,i);
194  valor = fRHO * this->Dot(V, GradV, j) * phi[i]
195  -1. * this->Dot(GradPhi, T, j)
196  -1. * fBodyForce[j] * phi[i];
197  ef(i*nstate+ EVx+j) += valor;
198  }
199  }
200 
201 }//method
202 
204  REAL weight,
205  TPZFMatrix<STATE> &ef){
206 
207 }
208 
209 
211  REAL weight,
212  TPZFMatrix<STATE> &ek,
213  TPZFMatrix<STATE> &ef,
214  TPZBndCond &bc){
215 
216 }
217 
219  STATE sum = 0.;
220  int i, j, rows, cols;
221  rows = A.Rows();
222  cols = A.Cols();
223  for(i = 0; i < rows; i++){
224  for(j = 0; j < cols; j++){
225  sum += A(i,j) * B(i,j);
226  }
227  }
228  return sum;
229 }
230 
232  STATE sum = 0.;
233  int i, dim;
234  dim = A.NElements();
235  for(i = 0; i < dim; i++){
236  sum += A[i] * B[i];
237  }
238  return sum;
239 }
240 
242  STATE sum = 0.;
243  int i, dim;
244  dim = A.NElements();
245  for(i = 0; i < dim; i++){
246  sum += A[i] * B(BRow,i);
247  }
248  return sum;
249 }
250 
252  return Hash("TPZIncNavierStokesKEps") ^ TPZMaterial::ClassId() << 1;
253 }
clarg::argBool bc("-bc", "binary checkpoints", false)
virtual int ClassId() const override
Define the class id associated with the class.
clarg::argInt dimension("-d", "Matrices dimension M x M", 1000)
TPZIncNavierStokesKEps(int id, int dimension)
Definition: pzincnskeps.cpp:8
virtual int NSolutionVariables(int var) override
Returns the number of variables associated with the variable indexed by var. var is obtained by cal...
Definition: pzincnskeps.cpp:50
TPZGradSolVec dsol
vector of the derivatives of the solution at the integration point
TPZFNMatrix< 220, REAL > phi
vector of shapefunctions (format is dependent on the value of shapetype)
TPZFNMatrix< 660, REAL > dphix
values of the derivative of the shape functions
virtual void Print(std::ostream &out=std::cout)
Prints out the data associated with the material.
This abstract class defines the behaviour which each derived class needs to implement.
Definition: TPZMaterial.h:39
virtual void Solution(TPZVec< STATE > &Sol, TPZFMatrix< STATE > &DSol, TPZFMatrix< REAL > &axes, int var, TPZVec< STATE > &Solout) override
Returns the solution associated with the var index based on the finite element approximation.
Definition: pzincnskeps.cpp:57
int64_t size() const
Returns the number of elements of the vector.
Definition: pzvec.h:196
void GetParameters(STATE &MU, STATE &RHO, STATE &Cmu, STATE &SigmaK, STATE &SigmaEps, STATE &Cepsilon1, STATE &Cepsilon2, TPZVec< STATE > &BodyForce)
Definition: pzincnskeps.cpp:27
virtual ~TPZIncNavierStokesKEps()
Definition: pzincnskeps.cpp:14
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
This class defines the boundary condition for TPZMaterial objects.
Definition: pzbndcond.h:29
virtual void Contribute(TPZMaterialData &data, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef) override
Computes contribution to the tangent matrix and residual at an integration point. ...
Definition: pzincnskeps.cpp:87
int64_t Rows() const
Returns number of rows.
Definition: pzmatrix.h:803
virtual int NStateVariables() const override
Returns the number of state variables associated with the material.
Definition: pzincnskeps.cpp:42
int32_t Hash(std::string str)
Definition: TPZHash.cpp:10
Contains the TPZIncNavierStokesKEps class which implements an imcompressible Navier-Stokes formulatio...
virtual void ContributeBC(TPZMaterialData &data, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef, TPZBndCond &bc) override
Computes contribution to the stiffness matrix and right hand side at the integration point of a bound...
int ClassId() const override
Unique identifier for serialization purposes.
TPZVec< STATE > fBodyForce
Definition: pzincnskeps.h:43
int64_t Cols() const
Returns number of cols.
Definition: pzmatrix.h:809
void SetParameters(STATE MU, STATE RHO, STATE Cmu, STATE SigmaK, STATE SigmaEps, STATE Cepsilon1, STATE Cepsilon2, TPZVec< STATE > &BodyForce)
Definition: pzincnskeps.cpp:16
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ exp
Definition: tfadfunc.h:125
int64_t NElements() const
Returns the number of elements of the vector.
Definition: pzvec.h:190
virtual int Dimension() const override
Returns the integrable dimension of the material.
Definition: pzincnskeps.cpp:38
This class implements an imcompressible Navier-Stokes formulation with modified KEpsilon turbulence m...
Definition: pzincnskeps.h:35
TPZSolVec sol
vector of the solutions at the integration point
virtual void Print(std::ostream &out=std::cout) override
Print out the data associated with the material.
Definition: pzincnskeps.cpp:46
STATE Dot(TPZFMatrix< STATE > &A, TPZFMatrix< STATE > &B)
Dot for matrices with same dimensions. No consistence test is made.
#define PZError
Defines the output device to error messages and the DebugStop() function.
Definition: pzerror.h:15