MAST
small_disturbance_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 // C++ includes
21 #include <iomanip>
22 
23 
24 // MAST includes
27 
28 
29 template <typename ValType>
32 
33  this->zero();
34 }
35 
36 
37 template <typename ValType>
39 
40  perturb_primitive_sol.setZero();
41 
42  drho = 0.;
43  du1 = 0.;
44  du2 = 0.;
45  du3 = 0.;
46  dT = 0.;
47  dp = 0.;
48  da = 0.;
49  de_tot = 0.;
50  dk = 0.;
51  dentropy = 0.;
52  dmach = 0.;
53  dk_thermal = 0.;
54  dmu = 0.;
55  dlambda = 0.;
56  primitive_sol = nullptr;
57 }
58 
59 
60 template <typename ValType>
61 void
64  const typename VectorType<ValType>::return_type& delta_sol,
65  bool if_viscous) {
66 
67  primitive_sol = &sol;
68 
69  const unsigned int
70  n1 = sol.dimension+2;
71 
72  const
73  Real
74  R = sol.cp-sol.cv,
75  gamma = sol.cp/sol.cv;
76 
77  perturb_primitive_sol.resize(n1);
78 
79  drho = delta_sol(0);
80  perturb_primitive_sol(0) = drho;
81 
82  du1 = (delta_sol(1) - drho * sol.u1)/sol.rho;
83 
84  perturb_primitive_sol(1) = du1;
85 
86  dk = sol.u1*du1;
87 
88  if (sol.dimension > 1)
89  {
90  du2 = (delta_sol(2) - drho * sol.u2)/sol.rho;
91  perturb_primitive_sol(2) = du2;
92  dk += sol.u2*du2;
93  }
94 
95  if (sol.dimension > 2)
96  {
97  du3 = (delta_sol(3) - drho * sol.u3)/sol.rho;
98  perturb_primitive_sol(3) = du3;
99  dk += sol.u3*du3;
100  }
101 
102  de_tot = (delta_sol(n1-1) - drho * sol.e_tot)/sol.rho;
103 
104  dT = (de_tot - dk)/sol.cv;
105  perturb_primitive_sol(n1-1) = dT;
106 
107  dp = R*(dT*sol.rho + sol.T*drho);
108  da = 0.5*sqrt(gamma*R/sol.T)*dT;
109  dmach = dk/sqrt(2.0*sol.k)/sol.a - sqrt(2.*sol.k)/pow(sol.a,2) * da;
110  dentropy = (dp/pow(sol.rho,gamma) - gamma*sol.p/pow(sol.rho,gamma+1.)*drho)
111  / (sol.p/pow(sol.rho,gamma)) ;
112 
113  // viscous quantities
114  if (if_viscous)
115  {
116  const Real
117  T = primitive_sol->T;
118 
119  dmu = 1.458e-6 * dT * (1.5*pow(T, 0.5)/(T+110.4) - pow(T, 1.5)/pow(T+110.4, 2));
120  dlambda = -2./3.*dmu;
121  dk_thermal = dmu*primitive_sol->cp/primitive_sol->Pr;
122  }
123 }
124 
125 
126 template <typename ValType>
127 void
129 print(std::ostream& out) const {
130 
131  out
132  << "Small Perturbation Primitive Solution:" << std::endl
133  << perturb_primitive_sol << std::endl
134  << std::setw(15) << " drho: " << drho << std::endl
135  << std::setw(15) << " du1: " << du1 << std::endl
136  << std::setw(15) << " du2: " << du2 << std::endl
137  << std::setw(15) << " du3: " << du3 << std::endl
138  << std::setw(15) << " dmach: " << dmach << std::endl
139  << std::setw(15) << " da: " << da << std::endl
140  << std::setw(15) << " dT: " << dT << std::endl
141  << std::setw(15) << " dp: " << dp << std::endl
142  << std::setw(15) << " de_tot: " << de_tot << std::endl
143  << std::setw(15) << " dk: " << dk << std::endl
144  << std::setw(15) << " dentropy: " << dentropy << std::endl << std::endl;
145 }
146 
147 
148 template <typename ValType>
149 ValType
151 c_pressure(const Real q0) const {
152 
153  return dp/q0;
154 }
155 
156 
157 template <typename ValType>
158 void
161 
162  du.setZero();
163 
164  switch (primitive_sol->dimension) {
165  case 3:
166  du(2) = du3;
167  case 2:
168  du(1) = du2;
169  case 1:
170  du(0) = du1;
171  }
172 }
173 
174 
175 
176 // explicit instantiations for real and complex type
179 
Class defines basic operations and calculation of the small disturbance primitive variables...
Class defines the conversion and some basic operations on primitive fluid variables used in calculati...
void init(const MAST::PrimitiveSolution &sol, const typename VectorType< ValType >::return_type &delta_sol, bool if_viscous)
libMesh::Real Real
void get_duvec(typename VectorType< ValType >::return_type &du) const