GRINS-0.6.0
low_mach_navier_stokes_stab_base.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2015 Paul T. Bauman, Roy H. Stogner
7 // Copyright (C) 2010-2013 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 
26 // This class
28 
29 // GRINS
30 #include "grins/assembly_context.h"
34 
35 namespace GRINS
36 {
37 
38  template<class Mu, class SH, class TC>
40  const GetPot& input )
41  : LowMachNavierStokesBase<Mu,SH,TC>(physics_name,input),
42  _stab_helper( physics_name+"StabHelper", input )
43  {
44  return;
45  }
46 
47  template<class Mu, class SH, class TC>
49  {
50  return;
51  }
52 
53  template<class Mu, class SH, class TC>
55  {
56  // First call base class
58 
59  // We need pressure derivatives
60  context.get_element_fe(this->_p_var)->get_dphi();
61 
62  // We also need second derivatives, so initialize those.
63  context.get_element_fe(this->_u_var)->get_d2phi();
64  context.get_element_fe(this->_T_var)->get_d2phi();
65 
66  return;
67  }
68 
69  template<class Mu, class SH, class TC>
71  unsigned int qp ) const
72  {
73  libMesh::Real T = context.fixed_interior_value(this->_T_var, qp);
74  libMesh::RealGradient grad_T = context.fixed_interior_gradient(this->_T_var, qp);
75 
76  libMesh::RealGradient U( context.fixed_interior_value(this->_u_var, qp),
77  context.fixed_interior_value(this->_v_var, qp) );
78 
79  libMesh::RealGradient grad_u, grad_v;
80 
81  grad_u = context.fixed_interior_gradient(this->_u_var, qp);
82  grad_v = context.fixed_interior_gradient(this->_v_var, qp);
83 
84  libMesh::Real divU = grad_u(0) + grad_v(1);
85 
86  if( this->_dim == 3 )
87  {
88  U(2) = context.fixed_interior_value(this->_w_var, qp);
89  divU += (context.fixed_interior_gradient(this->_w_var, qp))(2);
90  }
91 
92  return divU - (U*grad_T)/T;
93  }
94 
95  template<class Mu, class SH, class TC>
97  unsigned int qp ) const
98  {
99  libMesh::Real T = context.fixed_interior_value(this->_T_var, qp);
100  libMesh::Real T_dot = context.interior_value(this->_T_var, qp);
101 
102  libMesh::Real RC_t = -T_dot/T;
103 
104  if( this->_enable_thermo_press_calc )
105  {
106  libMesh::Real p0 = context.fixed_interior_value(this->_p0_var, qp);
107  libMesh::Real p0_dot = context.interior_value(this->_p0_var, qp);
108 
109  RC_t += p0_dot/p0;
110  }
111 
112  return RC_t;
113  }
114 
115  template<class Mu, class SH, class TC>
117  unsigned int qp ) const
118  {
119  libMesh::Real T = context.fixed_interior_value(this->_T_var, qp);
120 
121  libMesh::Real rho = this->rho(T, this->get_p0_transient(context,qp) );
122 
123  libMesh::RealGradient U( context.fixed_interior_value(this->_u_var, qp),
124  context.fixed_interior_value(this->_v_var, qp) );
125  if(this->_dim == 3)
126  U(2) = context.fixed_interior_value(this->_w_var, qp);
127 
128  libMesh::RealGradient grad_p = context.fixed_interior_gradient(this->_p_var, qp);
129 
130  libMesh::RealGradient grad_u = context.fixed_interior_gradient(this->_u_var, qp);
131  libMesh::RealGradient grad_v = context.fixed_interior_gradient(this->_v_var, qp);
132 
133  libMesh::RealTensor hess_u = context.fixed_interior_hessian(this->_u_var, qp);
134  libMesh::RealTensor hess_v = context.fixed_interior_hessian(this->_v_var, qp);
135 
136  libMesh::RealGradient rhoUdotGradU;
137  libMesh::RealGradient divGradU;
138  libMesh::RealGradient divGradUT;
139  libMesh::RealGradient divdivU;
140 
141  if( this->_dim < 3 )
142  {
143  rhoUdotGradU = rho*_stab_helper.UdotGradU( U, grad_u, grad_v );
144  divGradU = _stab_helper.div_GradU( hess_u, hess_v );
145  divGradUT = _stab_helper.div_GradU_T( hess_u, hess_v );
146  divdivU = _stab_helper.div_divU_I( hess_u, hess_v );
147  }
148  else
149  {
150  libMesh::RealGradient grad_w = context.fixed_interior_gradient(this->_w_var, qp);
151  libMesh::RealTensor hess_w = context.fixed_interior_hessian(this->_w_var, qp);
152 
153  rhoUdotGradU = rho*_stab_helper.UdotGradU( U, grad_u, grad_v, grad_w );
154 
155  divGradU = _stab_helper.div_GradU( hess_u, hess_v, hess_w );
156  divGradUT = _stab_helper.div_GradU_T( hess_u, hess_v, hess_w );
157  divdivU = _stab_helper.div_divU_I( hess_u, hess_v, hess_w );
158  }
159 
160  libMesh::RealGradient divT = this->_mu(T)*(divGradU + divGradUT - 2.0/3.0*divdivU);
161 
162  if( this->_mu.deriv(T) != 0.0 )
163  {
164  libMesh::Gradient grad_T = context.fixed_interior_gradient(this->_T_var, qp);
165 
166  libMesh::Gradient grad_u = context.fixed_interior_gradient(this->_u_var, qp);
167  libMesh::Gradient grad_v = context.fixed_interior_gradient(this->_v_var, qp);
168 
169  libMesh::Gradient gradTgradu( grad_T*grad_u, grad_T*grad_v );
170 
171  libMesh::Gradient gradTgraduT( grad_T(0)*grad_u(0) + grad_T(1)*grad_u(1),
172  grad_T(0)*grad_v(0) + grad_T(1)*grad_v(1) );
173 
174  libMesh::Real divU = grad_u(0) + grad_v(1);
175 
176  libMesh::Gradient gradTdivU( grad_T(0)*divU, grad_T(1)*divU );
177 
178  if(this->_dim == 3)
179  {
180  libMesh::Gradient grad_w = context.fixed_interior_gradient(this->_w_var, qp);
181 
182  gradTgradu(2) = grad_T*grad_w;
183 
184  gradTgraduT(0) += grad_T(2)*grad_u(2);
185  gradTgraduT(1) += grad_T(2)*grad_v(2);
186  gradTgraduT(2) = grad_T(0)*grad_w(0) + grad_T(1)*grad_w(1) + grad_T(2)*grad_w(2);
187 
188  divU += grad_w(2);
189  gradTdivU(0) += grad_T(0)*grad_w(2);
190  gradTdivU(1) += grad_T(1)*grad_w(2);
191  gradTdivU(2) += grad_T(2)*divU;
192  }
193 
194  divT += this->_mu.deriv(T)*( gradTgradu + gradTgraduT - 2.0/3.0*gradTdivU );
195  }
196 
197  libMesh::RealGradient rhog( rho*this->_g(0), rho*this->_g(1) );
198  if(this->_dim == 3)
199  rhog(2) = rho*this->_g(2);
200 
201  return rhoUdotGradU + grad_p - divT - rhog;
202  }
203 
204  template<class Mu, class SH, class TC>
206  unsigned int qp ) const
207  {
208  libMesh::Real T = context.fixed_interior_value(this->_T_var, qp);
209  libMesh::Real rho = this->rho(T, this->get_p0_transient(context,qp) );
210 
211  libMesh::RealGradient u_dot( context.interior_value(this->_u_var, qp), context.interior_value(this->_v_var, qp) );
212 
213  if(this->_dim == 3)
214  u_dot(2) = context.interior_value(this->_w_var, qp);
215 
216  return rho*u_dot;
217  }
218 
219  template<class Mu, class SH, class TC>
221  unsigned int qp ) const
222  {
223  libMesh::Real T = context.fixed_interior_value(this->_T_var, qp);
224  libMesh::Gradient grad_T = context.fixed_interior_gradient(this->_T_var, qp);
225  libMesh::Tensor hess_T = context.fixed_interior_hessian(this->_T_var, qp);
226 
227  libMesh::Real rho = this->rho(T, this->get_p0_transient(context,qp) );
228  libMesh::Real rho_cp = rho*this->_cp(T);
229 
230  libMesh::RealGradient rhocpU( rho_cp*context.fixed_interior_value(this->_u_var, qp),
231  rho_cp*context.fixed_interior_value(this->_v_var, qp) );
232  if(this->_dim == 3)
233  rhocpU(2) = rho_cp*context.fixed_interior_value(this->_w_var, qp);
234 
235  libMesh::Real hess_term = hess_T(0,0) + hess_T(1,1);
236 #if LIBMESH_DIM > 2
237  hess_term += hess_T(2,2);
238 #endif
239 
240  return rhocpU*grad_T - this->_k.deriv(T)*(grad_T*grad_T) - this->_k(T)*(hess_term);
241  }
242 
243 
244  template<class Mu, class SH, class TC>
246  unsigned int qp ) const
247  {
248  libMesh::Real T = context.fixed_interior_value(this->_T_var, qp);
249  libMesh::Real rho = this->rho(T, this->get_p0_transient(context,qp) );
250  libMesh::Real rho_cp = rho*this->_cp(T);
251  libMesh::Real T_dot = context.interior_value(this->_T_var, qp);
252 
253  libMesh::Real RE_t = rho_cp*T_dot;
254 
255  if( this->_enable_thermo_press_calc )
256  {
257  RE_t -= context.interior_value(this->_p0_var, qp);
258  }
259 
260  return RE_t;
261  }
262 
263 } // namespace GRINS
264 
265 // Instantiate
libMesh::RealGradient compute_res_momentum_transient(AssemblyContext &context, unsigned int qp) const
GRINS namespace.
libMesh::Real compute_res_energy_steady(AssemblyContext &context, unsigned int qp) const
Adds VMS-based stabilization to LowMachNavierStokes physics class.
libMesh::Real compute_res_energy_transient(AssemblyContext &context, unsigned int qp) const
Physics class for Incompressible Navier-Stokes.
virtual void init_context(AssemblyContext &context)
Initialize context for added physics variables.
virtual void init_context(AssemblyContext &context)
Initialize context for added physics variables.
libMesh::RealGradient compute_res_momentum_steady(AssemblyContext &context, unsigned int qp) const
libMesh::Real compute_res_continuity_steady(AssemblyContext &context, unsigned int qp) const
libMesh::Real compute_res_continuity_transient(AssemblyContext &context, unsigned int qp) const

Generated on Mon Jun 22 2015 21:32:20 for GRINS-0.6.0 by  doxygen 1.8.9.1