NeoPZ
pzausmflux.cpp
Go to the documentation of this file.
1 
6 #include "pzausmflux.h"
7 
9  this->fGamma = gamma;
10  this->fAlpha = 3./16.;
11  this->fBeta = 1./8.;
12 }
13 
15  this->fGamma = cp.fGamma;
16  this->fAlpha = cp.fAlpha;
17  this->fBeta = cp.fBeta;
18 }
19 
21  STATE LeftSoundSpeed,RightSoundSpeed,
22  LeftSpeed,RightSpeed,
23  LeftNormalSpeed, RightNormalSpeed,
24  LeftEnthalpy,RightEnthalpy,
25  LeftPress, RightPress;
26 
27  this->ComputeInitialData(solL,normal,LeftSoundSpeed,LeftSpeed,LeftNormalSpeed,LeftEnthalpy,LeftPress);
28  this->ComputeInitialData(solR,normal,RightSoundSpeed,RightSpeed,RightNormalSpeed,RightEnthalpy,RightPress);
29 
30  const STATE NumericalSoundSpeed = NumSoundSpeed(LeftSoundSpeed,RightSoundSpeed);
31  const STATE LeftNumMach = LeftNormalSpeed/NumericalSoundSpeed;
32  const STATE RightNumMach = RightNormalSpeed/NumericalSoundSpeed;
33 
34  const STATE FacePressure = this->FacePressure(LeftPress,RightPress,LeftNumMach,RightNumMach);
35  const STATE FaceMach = this->FaceMachNumber(LeftNumMach,RightNumMach);
36  const STATE MassFlux = this->MassFlux(NumericalSoundSpeed,solL[0], solR[0], FaceMach);
37 
38  const STATE uL = solL[1]/solL[0];
39  const STATE vL = solL[2]/solL[0];
40  const STATE wL = solL[3]/solL[0];
41 
42  const STATE uR = solR[1]/solR[0];
43  const STATE vR = solR[2]/solR[0];
44  const STATE wR = solR[3]/solR[0];
45 
46  F[0] = ((STATE)0.5)*(MassFlux* ((STATE)(2.)));
47  F[1] = ((STATE)0.5)*MassFlux* (uL+uR) -((STATE)0.5)*fabs(MassFlux)* (uR-uL) + FacePressure*normal[0];
48  F[2] = 0.5*MassFlux* (vL+vR) -0.5*fabs(MassFlux)* (vR-vL) + FacePressure*((STATE)normal[1]);
49  F[3] = 0.5*MassFlux* (wL+wR) -0.5*fabs(MassFlux)* (wR-wL) + FacePressure*normal[2];
50  F[4] = 0.5*MassFlux* (LeftEnthalpy+RightEnthalpy) -0.5*fabs(MassFlux)* (RightEnthalpy-LeftEnthalpy) + 0.;
51 
52 }//void
53 
54 void TPZAUSMFlux::ComputeInitialData(TPZVec<STATE>&sol,TPZVec<REAL> &normal, STATE&soundSpeed,
55  STATE &Speed, STATE &NormalSpeed, STATE &Enthalpy, STATE &press){
56  press = this->Pressure(sol);
57  soundSpeed = this->SoundSpeed(sol,press);
58  Speed = this->Speed(sol,normal,NormalSpeed);
59  Enthalpy = this->Enthalpy(soundSpeed,Speed);
60 }//void
61 
62 STATE TPZAUSMFlux::SoundSpeed(TPZVec<STATE> &sol,STATE press){
63  const STATE rho = sol[0];
64  if(rho < 1e-10){
65  PZError << "TPZEulerEquation(::cSpeed Too small or negative density\n";
66  DebugStop();
67  }
68 
69  const STATE c = sqrt(this->fGamma * press/ sol[0]);
70  return c;
71 }
72 
74  if(fabs(sol[0]) < 1.e-6){
75  PZError << "TPZEulerEquation::Pressure - Negative or too small density"
76  << sol[0] << std::endl;
77  DebugStop();
78  }
79 
80  STATE press = 0.0;
81 
82  const STATE rho_velocity2 = ( sol[1]*sol[1] + sol[2]*sol[2] + sol[3]*sol[3] )/sol[0];
83  press = ((this->fGamma-1.)*( sol[4] - 0.5 * rho_velocity2 ));
84 
85  if(press < 0){
86  STATE temp = (this->fGamma-1.)*sol[4];
87  PZError << "TPZEulerEquation::Pressure Negative pressure: " << press << " (gama-1)*E = " << temp << std::endl;
88  DebugStop();
89  }
90  return press;
91 }//method
92 
93 STATE TPZAUSMFlux::Speed(TPZVec<STATE> &sol, TPZVec<REAL> &normal, STATE &NormalSpeed){
94  const STATE rho = sol[0];
95  const STATE rhoU = sol[1];
96  const STATE rhoV = sol[2];
97  const STATE rhoW = sol[3];
98  const STATE u = rhoU/rho;
99  const STATE v = rhoV/rho;
100  const STATE w = rhoW/rho;
101  const STATE speed = sqrt(u*u+v*v+w*w);
102  NormalSpeed = u*normal[0]+v*normal[1]+w*normal[2];
103  return speed;
104 }//method
105 
106 STATE TPZAUSMFlux::Enthalpy(STATE soundSpeed, STATE speed){
107  const STATE enthalpy = soundSpeed*soundSpeed/(this->fGamma-1.)+0.5*speed*speed;
108  return enthalpy;
109 }//method
110 
111 STATE TPZAUSMFlux::FacePressure(STATE pL, STATE pR, STATE Ml, STATE Mr){
112  STATE Pplus;
113  if(Ml >= 1.) Pplus = 1.;
114  else if(Ml <= -1.) Pplus = 0.;
115  else{
116  Pplus = 0.25*(Ml+1.)*(Ml+1.)*(2.-Ml)+this->fAlpha*Ml*(Ml*Ml-1.)*(Ml*Ml-1.);
117  }
118 
119  STATE Pminus;
120  if(Mr >= 1.) Pminus = 0.;
121  else if(Mr <= -1.) Pminus = 1.;
122  else{
123  Pminus = 0.25*(Mr-1.)*(Mr-1.)*(2.+Mr)-this->fAlpha*Mr*(Mr*Mr-1.)*(Mr*Mr-1.);
124  }
125 
126  const STATE pFace = pL*Pplus+pR*Pminus;
127  return pFace;
128 
129 }//method
130 
131 STATE TPZAUSMFlux::FaceMachNumber(STATE Ml, STATE Mr){
132  STATE Mplus;
133  if(Ml >= 1.) Mplus = Ml;
134  else if(Ml <= -1.) Mplus = 0.;
135  else{
136  Mplus = 0.25*(Ml+1.)*(Ml+1.)+this->fBeta*(Ml*Ml-1.)*(Ml*Ml-1.);
137  }
138 
139  STATE Mminus;
140  if(Mr >= 1.) Mminus = 0.;
141  else if(Mr <= -1.) Mminus = Mr;
142  else{
143  Mminus = -0.25*(Mr-1.)*(Mr-1.)-this->fBeta*(Mr*Mr-1.)*(Mr*Mr-1.);
144  }
145 
146  const STATE faceMach = Mplus+Mminus;
147  return faceMach;
148 
149 }//method
150 
151 STATE TPZAUSMFlux::NumSoundSpeed(STATE LeftSoundSpeed,STATE RightSoundSpeed){
152  return sqrt(LeftSoundSpeed*RightSoundSpeed);
153 }//method
154 
155 STATE TPZAUSMFlux::MassFlux(STATE NumericalSoundSpeed, STATE rhoL, STATE rhoR, STATE FaceMach){
156  STATE min = 0., max = 0.;
157  if(FaceMach > 0.) max = FaceMach;
158  if(FaceMach < 0.) min = FaceMach;
159 
160  const STATE m = NumericalSoundSpeed*(rhoL*max+rhoR*min);
161  return m;
162 }//method
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ fabs
Definition: tfadfunc.h:140
STATE fAlpha
Method constants.
Definition: pzausmflux.h:25
TPZAUSMFlux(STATE gamma)
Constructor with Gamma value.
Definition: pzausmflux.cpp:8
STATE Speed(TPZVec< STATE > &sol, TPZVec< REAL > &normal, STATE &NormalSpeed)
Returns speed.
Definition: pzausmflux.cpp:93
void ComputeInitialData(TPZVec< STATE > &sol, TPZVec< REAL > &normal, STATE &soundSpeed, STATE &Speed, STATE &NormalSpeed, STATE &Enthalpy, STATE &press)
Auxiliar method only.
Definition: pzausmflux.cpp:54
STATE Enthalpy(STATE soundSpeed, STATE speed)
Returns enthalpy.
Definition: pzausmflux.cpp:106
STATE FacePressure(STATE pL, STATE pR, STATE Ml, STATE Mr)
Returns pressure in the face.
Definition: pzausmflux.cpp:111
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
STATE MassFlux(STATE NumericalSoundSpeed, STATE rhoL, STATE rhoR, STATE FaceMach)
Returns the mass flux.
Definition: pzausmflux.cpp:155
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ sqrt
Definition: tfadfunc.h:120
Contains the TPZAUSMFlux class.
long double gamma(unsigned int n)
Evaluate the factorial of a integer.
STATE fBeta
Definition: pzausmflux.h:25
void ComputeFlux(TPZVec< STATE > &solL, TPZVec< STATE > &solR, TPZVec< REAL > &normal, TPZVec< STATE > &F)
Computes numerical flux.
Definition: pzausmflux.cpp:20
STATE SoundSpeed(TPZVec< STATE > &sol, STATE press)
Returns sound speed.
Definition: pzausmflux.cpp:62
STATE NumSoundSpeed(STATE LeftSoundSpeed, STATE RightSoundSpeed)
Computes the numerical sound speed at the face.
Definition: pzausmflux.cpp:151
STATE FaceMachNumber(STATE Ml, STATE Mr)
Returns mach number in the face.
Definition: pzausmflux.cpp:131
STATE fGamma
Ratio between specific heat is constant and the specific heat the constant volume of a polytropic gas...
Definition: pzausmflux.h:22
clarg::argString m("-m", "input matrix file name (text format)", "matrix.txt")
STATE Pressure(TPZVec< STATE > &sol)
Returns pressure values.
Definition: pzausmflux.cpp:73
Implements the numerical flux for AUSM problem. (Jorge?)
Definition: pzausmflux.h:17
#define PZError
Defines the output device to error messages and the DebugStop() function.
Definition: pzerror.h:15