MAST
primitive_fluid_solution.cpp
Go to the documentation of this file.
1 /*
2  * MAST: Multidisciplinary-design Adaptation and Sensitivity Toolkit
3  * Copyright (C) 2013-2019 Manav Bhatia
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 
21 // C++ includes
22 #include <iomanip>
23 
24 // MAST includes
26 
27 
29 {
30  this->zero();
31 }
32 
33 
34 void
36 {
37  this->primitive_sol.setZero();
38  dimension = 0;
39  cp = 0.;
40  cv = 0.;
41  rho = 0.;
42  u1 = 0.;
43  u2 = 0.;
44  u3 = 0.;
45  T = 0.;
46  p = 0.;
47  a = 0.;
48  e_tot = 0.;
49  k = 0.;
50  entropy = 0.;
51  mach = 0.;
52  // viscous values
53  Pr = 0.72;
54  k_thermal = 0.;
55  mu = 0.;
56  lambda = 0.;
57 }
58 
59 
60 
61 void
62 MAST::PrimitiveSolution::init(const unsigned int dim,
63  const RealVectorX &conservative_sol,
64  const Real cp_val,
65  const Real cv_val,
66  bool if_viscous)
67 {
68  dimension = dim;
69  const unsigned int n1 = dim+2;
70  cp = cp_val; cv = cv_val;
71  const Real R = cp-cv, gamma = cp/cv;
72  primitive_sol.resize(n1);
73 
74  rho = conservative_sol(0);
75  primitive_sol(0) = rho;
76 
77  u1 = conservative_sol(1)/rho;
78  primitive_sol(1) = u1;
79  k = u1*u1;
80 
81  if (dim > 1)
82  {
83  u2 = conservative_sol(2)/rho;
84  primitive_sol(2) = u2;
85  k += u2*u2;
86  }
87 
88  if (dim > 2)
89  {
90  u3 = conservative_sol(3)/rho;
91  primitive_sol(3) = u3;
92  k += u3*u3;
93  }
94  k *= 0.5;
95 
96  e_tot = conservative_sol(n1-1)/rho; // cv*T+k;
97 
98  T = (e_tot - k)/cv;
99  primitive_sol(n1-1) = T;
100 
101  p = R*T*rho;
102  a = sqrt(gamma*R*T);
103  mach = sqrt(2.0*k)/a;
104  entropy = log(p/pow(rho,gamma));
105 
106  // viscous quantities
107  if (if_viscous)
108  {
109  mu = 1.458e-6 * pow(T, 1.5)/(T+110.4);
110  lambda = -2./3.*mu;
111  k_thermal = mu*cp/Pr;
112  }
113 }
114 
115 
116 
117 Real
119  const Real q0) const
120 {
121  return (p-p0)/q0;
122 }
123 
124 
125 
126 void
128 {
129  u.setZero();
130 
131  switch (dimension) {
132  case 3:
133  u(2) = u3;
134  case 2:
135  u(1) = u2;
136  case 1:
137  u(0) = u1;
138  }
139 }
140 
141 
142 
143 void
144 MAST::PrimitiveSolution::print(std::ostream& out) const
145 {
146  out
147  << "Primitive Solution:" << std::endl
148  << primitive_sol << std::endl
149  << std::setw(15) << " rho: " << rho << std::endl
150  << std::setw(15) << " u1: " << u1 << std::endl
151  << std::setw(15) << " u2: " << u2 << std::endl
152  << std::setw(15) << " u3: " << u3 << std::endl
153  << std::setw(15) << " mach: " << mach << std::endl
154  << std::setw(15) << " a: " << a << std::endl
155  << std::setw(15) << " T: " << T << std::endl
156  << std::setw(15) << " p: " << p << std::endl
157  << std::setw(15) << " e_tot: " << e_tot << std::endl
158  << std::setw(15) << " k: " << k << std::endl
159  << std::setw(15) << " entropy: " << entropy << std::endl
160  << std::setw(15) << " Pr: " << Pr << std::endl
161  << std::setw(15) << " mu: " << mu << std::endl
162  << std::setw(15) << " lambda: " << lambda << std::endl
163  << std::setw(15) << " k_thermal: " << k_thermal << std::endl << std::endl;
164 
165 }
166 
167 
libMesh::Real Real
Real c_pressure(const Real p0, const Real q0) const
void get_uvec(RealVectorX &u) const
Matrix< Real, Dynamic, 1 > RealVectorX
void init(const unsigned int dim, const RealVectorX &conservative_sol, const Real cp_val, const Real cv_val, bool if_viscous)
void print(std::ostream &out) const