GRINS-0.8.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-2017 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,PhysicsNaming::low_mach_navier_stokes(),input),
42  _stab_helper( physics_name+"StabHelper", input )
43  {}
44 
45  template<class Mu, class SH, class TC>
47  {
48  // First call base class
50 
51  // We need pressure derivatives
52  context.get_element_fe(this->_press_var.p())->get_dphi();
53 
54  // We also need second derivatives, so initialize those.
55  context.get_element_fe(this->_flow_vars.u())->get_d2phi();
56  context.get_element_fe(this->_temp_vars.T())->get_d2phi();
57  }
58 
59  template<class Mu, class SH, class TC>
61  unsigned int qp ) const
62  {
63  libMesh::Real T = context.fixed_interior_value(this->_temp_vars.T(), qp);
64  libMesh::RealGradient grad_T = context.fixed_interior_gradient(this->_temp_vars.T(), qp);
65 
66  libMesh::RealGradient U( context.fixed_interior_value(this->_flow_vars.u(), qp),
67  context.fixed_interior_value(this->_flow_vars.v(), qp) );
68 
69  libMesh::RealGradient grad_u, grad_v;
70 
71  grad_u = context.fixed_interior_gradient(this->_flow_vars.u(), qp);
72  grad_v = context.fixed_interior_gradient(this->_flow_vars.v(), qp);
73 
74  libMesh::Real divU = grad_u(0) + grad_v(1);
75 
76 
77  if( this->_flow_vars.dim() == 3 )
78  {
79  U(2) = context.fixed_interior_value(this->_flow_vars.w(), qp);
80  divU += (context.fixed_interior_gradient(this->_flow_vars.w(), qp))(2);
81  }
82 
83  return divU - (U*grad_T)/T;
84  }
85 
86  template<class Mu, class SH, class TC>
88  unsigned int qp ) const
89  {
90  libMesh::Real T = context.fixed_interior_value(this->_temp_vars.T(), qp);
91  libMesh::Real T_dot = context.interior_value(this->_temp_vars.T(), qp);
92 
93  libMesh::Real RC_t = -T_dot/T;
94 
95  if( this->_enable_thermo_press_calc )
96  {
97  libMesh::Real p0 = context.fixed_interior_value(this->_p0_var->p0(), qp);
98  libMesh::Real p0_dot = context.interior_value(this->_p0_var->p0(), qp);
99 
100  RC_t += p0_dot/p0;
101  }
102 
103  return RC_t;
104  }
105 
106  template<class Mu, class SH, class TC>
108  unsigned int qp ) const
109  {
110  libMesh::Real T = context.fixed_interior_value(this->_temp_vars.T(), qp);
111 
112  libMesh::Real rho = this->rho(T, this->get_p0_transient(context,qp) );
113 
114  libMesh::RealGradient U( context.fixed_interior_value(this->_flow_vars.u(), qp),
115  context.fixed_interior_value(this->_flow_vars.v(), qp) );
116 
117  if(this->_flow_vars.dim() == 3)
118  U(2) = context.fixed_interior_value(this->_flow_vars.w(), qp);
119 
120  libMesh::RealGradient grad_p = context.fixed_interior_gradient(this->_press_var.p(), qp);
121 
122  libMesh::RealGradient grad_u = context.fixed_interior_gradient(this->_flow_vars.u(), qp);
123  libMesh::RealGradient grad_v = context.fixed_interior_gradient(this->_flow_vars.v(), qp);
124 
125  libMesh::RealTensor hess_u = context.fixed_interior_hessian(this->_flow_vars.u(), qp);
126  libMesh::RealTensor hess_v = context.fixed_interior_hessian(this->_flow_vars.v(), qp);
127 
128  libMesh::RealGradient rhoUdotGradU;
129  libMesh::RealGradient divGradU;
130  libMesh::RealGradient divGradUT;
131  libMesh::RealGradient divdivU;
132 
133  if( this->_flow_vars.dim() < 3 )
134  {
135  rhoUdotGradU = rho*_stab_helper.UdotGradU( U, grad_u, grad_v );
136  divGradU = _stab_helper.div_GradU( hess_u, hess_v );
137  divGradUT = _stab_helper.div_GradU_T( hess_u, hess_v );
138  divdivU = _stab_helper.div_divU_I( hess_u, hess_v );
139  }
140  else
141  {
142  libMesh::RealGradient grad_w = context.fixed_interior_gradient(this->_flow_vars.w(), qp);
143  libMesh::RealTensor hess_w = context.fixed_interior_hessian(this->_flow_vars.w(), qp);
144 
145  rhoUdotGradU = rho*_stab_helper.UdotGradU( U, grad_u, grad_v, grad_w );
146 
147  divGradU = _stab_helper.div_GradU( hess_u, hess_v, hess_w );
148  divGradUT = _stab_helper.div_GradU_T( hess_u, hess_v, hess_w );
149  divdivU = _stab_helper.div_divU_I( hess_u, hess_v, hess_w );
150  }
151 
152  libMesh::RealGradient divT = this->_mu(T)*(divGradU + divGradUT - 2.0/3.0*divdivU);
153 
154  if( this->_mu.deriv(T) != 0.0 )
155  {
156  libMesh::Gradient grad_T = context.fixed_interior_gradient(this->_temp_vars.T(), qp);
157 
158  libMesh::Gradient grad_u = context.fixed_interior_gradient(this->_flow_vars.u(), qp);
159  libMesh::Gradient grad_v = context.fixed_interior_gradient(this->_flow_vars.v(), qp);
160 
161  libMesh::Gradient gradTgradu( grad_T*grad_u, grad_T*grad_v );
162 
163  libMesh::Gradient gradTgraduT( grad_T(0)*grad_u(0) + grad_T(1)*grad_u(1),
164  grad_T(0)*grad_v(0) + grad_T(1)*grad_v(1) );
165 
166  libMesh::Real divU = grad_u(0) + grad_v(1);
167 
168  libMesh::Gradient gradTdivU( grad_T(0)*divU, grad_T(1)*divU );
169 
170  if(this->_flow_vars.dim() == 3)
171  {
172  libMesh::Gradient grad_w = context.fixed_interior_gradient(this->_flow_vars.w(), qp);
173 
174  gradTgradu(2) = grad_T*grad_w;
175 
176  gradTgraduT(0) += grad_T(2)*grad_u(2);
177  gradTgraduT(1) += grad_T(2)*grad_v(2);
178  gradTgraduT(2) = grad_T(0)*grad_w(0) + grad_T(1)*grad_w(1) + grad_T(2)*grad_w(2);
179 
180  divU += grad_w(2);
181  gradTdivU(0) += grad_T(0)*grad_w(2);
182  gradTdivU(1) += grad_T(1)*grad_w(2);
183  gradTdivU(2) += grad_T(2)*divU;
184  }
185 
186  divT += this->_mu.deriv(T)*( gradTgradu + gradTgraduT - 2.0/3.0*gradTdivU );
187  }
188 
189  libMesh::RealGradient rhog( rho*this->_g(0), rho*this->_g(1) );
190  if(this->_flow_vars.dim() == 3)
191  rhog(2) = rho*this->_g(2);
192 
193  return rhoUdotGradU + grad_p - divT - rhog;
194  }
195 
196  template<class Mu, class SH, class TC>
198  unsigned int qp ) const
199  {
200  libMesh::Real T = context.fixed_interior_value(this->_temp_vars.T(), qp);
201  libMesh::Real rho = this->rho(T, this->get_p0_transient(context,qp) );
202 
203  libMesh::RealGradient u_dot( context.interior_value(this->_flow_vars.u(), qp), context.interior_value(this->_flow_vars.v(), qp) );
204 
205  if(this->_flow_vars.dim() == 3)
206  u_dot(2) = context.interior_value(this->_flow_vars.w(), qp);
207 
208  return rho*u_dot;
209  }
210 
211  template<class Mu, class SH, class TC>
213  unsigned int qp ) const
214  {
215  libMesh::Real T = context.fixed_interior_value(this->_temp_vars.T(), qp);
216  libMesh::Gradient grad_T = context.fixed_interior_gradient(this->_temp_vars.T(), qp);
217  libMesh::Tensor hess_T = context.fixed_interior_hessian(this->_temp_vars.T(), qp);
218 
219  libMesh::Real rho = this->rho(T, this->get_p0_transient(context,qp) );
220  libMesh::Real rho_cp = rho*this->_cp(T);
221 
222  libMesh::RealGradient rhocpU( rho_cp*context.fixed_interior_value(this->_flow_vars.u(), qp),
223  rho_cp*context.fixed_interior_value(this->_flow_vars.v(), qp) );
224 
225  if(this->_flow_vars.dim() == 3)
226  rhocpU(2) = rho_cp*context.fixed_interior_value(this->_flow_vars.w(), qp);
227 
228  libMesh::Real hess_term = hess_T(0,0) + hess_T(1,1);
229 #if LIBMESH_DIM > 2
230  hess_term += hess_T(2,2);
231 #endif
232 
233  return rhocpU*grad_T - this->_k.deriv(T)*(grad_T*grad_T) - this->_k(T)*(hess_term);
234  }
235 
236 
237  template<class Mu, class SH, class TC>
239  unsigned int qp ) const
240  {
241  libMesh::Real T = context.fixed_interior_value(this->_temp_vars.T(), qp);
242  libMesh::Real rho = this->rho(T, this->get_p0_transient(context,qp) );
243  libMesh::Real rho_cp = rho*this->_cp(T);
244  libMesh::Real T_dot = context.interior_value(this->_temp_vars.T(), qp);
245 
246  libMesh::Real RE_t = rho_cp*T_dot;
247 
248  if( this->_enable_thermo_press_calc )
249  {
250  RE_t -= context.interior_value(this->_p0_var->p0(), qp);
251  }
252 
253  return RE_t;
254  }
255 
256 } // namespace GRINS
257 
258 // 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 Tue Dec 19 2017 12:47:28 for GRINS-0.8.0 by  doxygen 1.8.9.1