GRINS-0.8.0
inc_navier_stokes_stab_helper.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
33 #include "grins/single_variable.h"
34 #include "grins/physics_naming.h"
35 
36 //libMesh
37 #include "libmesh/getpot.h"
38 #include "libmesh/mesh.h"
39 #include "libmesh/fem_system.h"
40 
41 namespace GRINS
42 {
43 
45  (const std::string & helper_name,
46  const GetPot& input)
47  : StabilizationHelper(helper_name),
48  _C(1),
49  _tau_factor(0.5),
50  _flow_vars(GRINSPrivate::VariableWarehouse::get_variable_subclass<VelocityVariable>(VariablesParsing::velocity_variable_name(input,PhysicsNaming::incompressible_navier_stokes(),VariablesParsing::PHYSICS))),
51  _press_var(GRINSPrivate::VariableWarehouse::get_variable_subclass<PressureFEVariable>(VariablesParsing::press_variable_name(input,PhysicsNaming::incompressible_navier_stokes(),VariablesParsing::PHYSICS)))
52  {
53  if (input.have_variable("Stabilization/tau_constant_vel"))
54  this->set_parameter
55  (_C, input, "Stabilization/tau_constant_vel", _C );
56  else
57  this->set_parameter
58  (_C, input, "Stabilization/tau_constant", _C );
59 
60  if (input.have_variable("Stabilization/tau_factor_vel"))
61  this->set_parameter
62  (_tau_factor, input, "Stabilization/tau_factor_vel", _tau_factor );
63  else
64  this->set_parameter
65  (_tau_factor, input, "Stabilization/tau_factor", _tau_factor );
66 
67  return;
68  }
69 
71  {
72  return;
73  }
74 
75  libMesh::RealGradient IncompressibleNavierStokesStabilizationHelper::UdotGradU( libMesh::Gradient& U,
76  libMesh::Gradient& grad_u ) const
77  {
78  return libMesh::RealGradient( U*grad_u );
79  }
80 
81  libMesh::RealGradient IncompressibleNavierStokesStabilizationHelper::UdotGradU( libMesh::Gradient& U,
82  libMesh::Gradient& grad_u,
83  libMesh::Gradient& grad_v ) const
84  {
85  return libMesh::RealGradient( U*grad_u, U*grad_v );
86  }
87 
88  libMesh::RealGradient IncompressibleNavierStokesStabilizationHelper::UdotGradU( libMesh::Gradient& U,
89  libMesh::Gradient& grad_u,
90  libMesh::Gradient& grad_v,
91  libMesh::Gradient& grad_w ) const
92  {
93  return libMesh::RealGradient( U*grad_u, U*grad_v, U*grad_w );
94  }
95 
96  libMesh::RealGradient IncompressibleNavierStokesStabilizationHelper::div_GradU( libMesh::RealTensor& hess_u ) const
97  {
98  return libMesh::RealGradient( hess_u(0,0) );
99  }
100 
101  libMesh::RealGradient IncompressibleNavierStokesStabilizationHelper::div_GradU( libMesh::RealTensor& hess_u,
102  libMesh::RealTensor& hess_v ) const
103  {
104  return libMesh::RealGradient( hess_u(0,0) + hess_u(1,1),
105  hess_v(0,0) + hess_v(1,1) );
106  }
107 
108  libMesh::RealGradient IncompressibleNavierStokesStabilizationHelper::div_GradU_axi( libMesh::Real r,
109  const libMesh::Gradient& U,
110  const libMesh::Gradient& grad_u,
111  const libMesh::Gradient& grad_v,
112  const libMesh::RealTensor& hess_u,
113  const libMesh::RealTensor& hess_v ) const
114  {
115  return libMesh::RealGradient( hess_u(0,0) + hess_u(1,1) + (grad_u(0) - U(0)/r)/r,
116  hess_v(0,0) + hess_v(1,1) + grad_v(0)/r );
117  }
118 
119  libMesh::RealGradient IncompressibleNavierStokesStabilizationHelper::div_GradU( libMesh::RealTensor& hess_u,
120  libMesh::RealTensor& hess_v,
121  libMesh::RealTensor& hess_w ) const
122  {
123  return libMesh::RealGradient( hess_u(0,0) + hess_u(1,1) + hess_u(2,2),
124  hess_v(0,0) + hess_v(1,1) + hess_v(2,2),
125  hess_w(0,0) + hess_w(1,1) + hess_w(2,2) );
126  }
127 
128  libMesh::RealGradient IncompressibleNavierStokesStabilizationHelper::div_GradU_T( libMesh::RealTensor& hess_u ) const
129  {
130  return libMesh::RealGradient( hess_u(0,0) );
131  }
132 
133  libMesh::RealGradient IncompressibleNavierStokesStabilizationHelper::div_GradU_T( libMesh::RealTensor& hess_u,
134  libMesh::RealTensor& hess_v ) const
135  {
136  return libMesh::RealGradient( hess_u(0,0) + hess_v(0,1),
137  hess_u(1,0) + hess_v(1,1));
138  }
139 
141  const libMesh::Gradient& U,
142  const libMesh::Gradient& grad_u,
143  const libMesh::RealTensor& hess_u,
144  const libMesh::RealTensor& hess_v ) const
145  {
146  return libMesh::RealGradient( hess_u(0,0) + hess_v(0,1) + (grad_u(0) - U(0)/r)/r,
147  hess_u(1,0) + hess_v(1,1) + grad_u(1)/r );
148  }
149 
150  libMesh::RealGradient IncompressibleNavierStokesStabilizationHelper::div_GradU_T( libMesh::RealTensor& hess_u,
151  libMesh::RealTensor& hess_v,
152  libMesh::RealTensor& hess_w ) const
153  {
154  return libMesh::RealGradient( hess_u(0,0) + hess_v(0,1) + hess_w(0,2),
155  hess_u(1,0) + hess_v(1,1) + hess_w(1,2),
156  hess_u(2,0) + hess_v(2,1) + hess_w(2,2) );
157  }
158 
159  libMesh::RealGradient IncompressibleNavierStokesStabilizationHelper::div_divU_I( libMesh::RealTensor& hess_u ) const
160  {
161  return libMesh::RealGradient( hess_u(0,0) );
162  }
163 
164  libMesh::RealGradient IncompressibleNavierStokesStabilizationHelper::div_divU_I( libMesh::RealTensor& hess_u,
165  libMesh::RealTensor& hess_v ) const
166  {
167  return libMesh::RealGradient( hess_u(0,0) + hess_v(1,0),
168  hess_u(0,1) + hess_v(1,1) );
169  }
170 
172  const libMesh::Gradient& U,
173  const libMesh::Gradient& grad_u,
174  const libMesh::RealTensor& hess_u,
175  const libMesh::RealTensor& hess_v ) const
176  {
177  return libMesh::RealGradient( hess_u(0,0) + hess_v(1,0) + (grad_u(0) - U(0)/r)/r,
178  hess_u(0,1) + hess_v(1,1) + grad_u(1)/r );
179  }
180 
181  libMesh::RealGradient IncompressibleNavierStokesStabilizationHelper::div_divU_I( libMesh::RealTensor& hess_u,
182  libMesh::RealTensor& hess_v,
183  libMesh::RealTensor& hess_w) const
184  {
185  return libMesh::RealGradient( hess_u(0,0) + hess_v(1,0) + hess_w(2,0),
186  hess_u(0,1) + hess_v(1,1) + hess_w(2,1),
187  hess_u(0,2) + hess_v(1,2) + hess_w(2,2) );
188  }
189 
191  unsigned int qp ) const
192  {
193  libMesh::RealGradient grad_u, grad_v;
194 
195  grad_u = context.fixed_interior_gradient(this->_flow_vars.u(), qp);
196 
197  libMesh::Real divU = grad_u(0);
198 
199  if( this->_flow_vars.dim() > 1 )
200  {
201  divU += (context.fixed_interior_gradient(this->_flow_vars.v(), qp))(1);
202  }
203 
204  if( this->_flow_vars.dim() == 3 )
205  {
206  divU += (context.fixed_interior_gradient(this->_flow_vars.w(), qp))(2);
207  }
208 
209  return divU;
210  }
211 
213  ( AssemblyContext& context,
214  unsigned int qp,
215  libMesh::Real &res_C,
216  libMesh::Tensor &d_res_C_dgradU
217  ) const
218  {
219  libMesh::RealGradient grad_u =
220  context.fixed_interior_gradient(this->_flow_vars.u(), qp);
221 
222  libMesh::Real divU = grad_u(0);
223  d_res_C_dgradU = 0;
224  d_res_C_dgradU(0,0) = 1;
225 
226  if( this->_flow_vars.dim() > 1 )
227  {
228  divU += (context.fixed_interior_gradient(this->_flow_vars.v(), qp))(1);
229  d_res_C_dgradU(1,1) = 1;
230  }
231 
232  if( this->_flow_vars.dim() == 3 )
233  {
234  divU += (context.fixed_interior_gradient(this->_flow_vars.w(), qp))(2);
235  d_res_C_dgradU(2,2) = 1;
236  }
237 
238  res_C = divU;
239  }
240 
242  unsigned int qp, const libMesh::Real rho, const libMesh::Real mu ) const
243  {
244  libMesh::RealGradient U( context.fixed_interior_value(this->_flow_vars.u(), qp) );
245  if(this->_flow_vars.dim() > 1)
246  U(1) = context.fixed_interior_value(this->_flow_vars.v(), qp);
247  if(this->_flow_vars.dim() == 3)
248  U(2) = context.fixed_interior_value(this->_flow_vars.w(), qp);
249 
250  libMesh::RealGradient grad_p = context.fixed_interior_gradient(this->_press_var.p(), qp);
251 
252  libMesh::RealGradient grad_u = context.fixed_interior_gradient(this->_flow_vars.u(), qp);
253 
254  libMesh::RealTensor hess_u = context.fixed_interior_hessian(this->_flow_vars.u(), qp);
255 
256  libMesh::RealGradient rhoUdotGradU;
257  libMesh::RealGradient divGradU;
258 
259  if( this->_flow_vars.dim() == 1 )
260  {
261  rhoUdotGradU = rho*this->UdotGradU( U, grad_u );
262  divGradU = this->div_GradU( hess_u );
263  }
264  else if( this->_flow_vars.dim() == 2 )
265  {
266  libMesh::RealGradient grad_v = context.fixed_interior_gradient(this->_flow_vars.v(), qp);
267  libMesh::RealTensor hess_v = context.fixed_interior_hessian(this->_flow_vars.v(), qp);
268 
269  rhoUdotGradU = rho*this->UdotGradU( U, grad_u, grad_v );
270  divGradU = this->div_GradU( hess_u, hess_v );
271  }
272  else
273  {
274  libMesh::RealGradient grad_v = context.fixed_interior_gradient(this->_flow_vars.v(), qp);
275  libMesh::RealTensor hess_v = context.fixed_interior_hessian(this->_flow_vars.v(), qp);
276 
277  libMesh::RealGradient grad_w = context.fixed_interior_gradient(this->_flow_vars.w(), qp);
278  libMesh::RealTensor hess_w = context.fixed_interior_hessian(this->_flow_vars.w(), qp);
279 
280  rhoUdotGradU = rho*this->UdotGradU( U, grad_u, grad_v, grad_w );
281 
282  divGradU = this->div_GradU( hess_u, hess_v, hess_w );
283  }
284 
285  return rhoUdotGradU + grad_p - mu*divGradU;
286  }
287 
289  ( AssemblyContext& context,
290  unsigned int qp, const libMesh::Real rho, const libMesh::Real mu,
291  libMesh::Gradient &res_M,
292  libMesh::Tensor &d_res_M_dgradp,
293  libMesh::Tensor &d_res_M_dU,
294  libMesh::Gradient &d_res_Muvw_dgraduvw,
295  libMesh::Tensor &d_res_Muvw_dhessuvw
296  ) const
297  {
298  libMesh::RealGradient U( context.fixed_interior_value(this->_flow_vars.u(), qp) );
299  if(this->_flow_vars.dim() > 1)
300  U(1) = context.fixed_interior_value(this->_flow_vars.v(), qp);
301  if(this->_flow_vars.dim() == 3)
302  U(2) = context.fixed_interior_value(this->_flow_vars.w(), qp);
303 
304  libMesh::RealGradient grad_p = context.fixed_interior_gradient(this->_press_var.p(), qp);
305 
306  libMesh::RealGradient grad_u = context.fixed_interior_gradient(this->_flow_vars.u(), qp);
307 
308  libMesh::RealTensor hess_u = context.fixed_interior_hessian(this->_flow_vars.u(), qp);
309 
310  libMesh::RealGradient rhoUdotGradU;
311  libMesh::RealGradient divGradU;
312 
313  if( this->_flow_vars.dim() == 1 )
314  {
315  rhoUdotGradU = rho*this->UdotGradU( U, grad_u );
316  divGradU = this->div_GradU( hess_u );
317  }
318  else if( this->_flow_vars.dim() == 2 )
319  {
320  libMesh::RealGradient grad_v = context.fixed_interior_gradient(this->_flow_vars.v(), qp);
321  libMesh::RealTensor hess_v = context.fixed_interior_hessian(this->_flow_vars.v(), qp);
322 
323  d_res_M_dU(0,1) = rho * grad_u(1);
324  d_res_M_dU(1,0) = rho * grad_v(0);
325  d_res_M_dU(1,1) = rho * grad_v(1);
326 
327  d_res_Muvw_dgraduvw(1) = rho * U(1);
328  d_res_M_dgradp(1,1) = 1;
329  d_res_Muvw_dhessuvw(1,1) = mu;
330 
331  if( this->_flow_vars.dim() == 3 )
332  {
333  libMesh::RealGradient grad_w = context.fixed_interior_gradient(this->_flow_vars.w(), qp);
334  libMesh::RealTensor hess_w = context.fixed_interior_hessian(this->_flow_vars.w(), qp);
335 
336  rhoUdotGradU = rho*this->UdotGradU( U, grad_u, grad_v, grad_w );
337 
338  divGradU = this->div_GradU( hess_u, hess_v, hess_w );
339 
340  d_res_M_dU(0,2) = rho * grad_u(2);
341  d_res_M_dU(1,2) = rho * grad_v(2);
342  d_res_M_dU(2,0) = rho * grad_w(0);
343  d_res_M_dU(2,1) = rho * grad_w(1);
344  d_res_M_dU(2,2) = rho * grad_w(2);
345 
346  d_res_Muvw_dgraduvw(2) = rho * U(2);
347  d_res_M_dgradp(2,2) = 1;
348  d_res_Muvw_dhessuvw(2,2) = mu;
349  }
350  else
351  {
352  rhoUdotGradU = rho*this->UdotGradU( U, grad_u, grad_v );
353  divGradU = this->div_GradU( hess_u, hess_v );
354  }
355  }
356 
357  res_M = rhoUdotGradU + grad_p - mu*divGradU;
358 
359  d_res_M_dU(0,0) = rho * grad_u(0);
360 
361  d_res_Muvw_dgraduvw(0) = rho * U(0);
362 
363  d_res_M_dgradp(0,0) = 1;
364 
365  d_res_Muvw_dhessuvw(0,0) = mu;
366  }
367 
368 
369  libMesh::RealGradient IncompressibleNavierStokesStabilizationHelper::compute_res_momentum_transient( AssemblyContext& context, unsigned int qp, const libMesh::Real rho ) const
370  {
371  libMesh::RealGradient u_dot;
372  context.interior_rate(this->_flow_vars.u(), qp, u_dot(0));
373  if(this->_flow_vars.dim() > 1)
374  context.interior_rate(this->_flow_vars.v(), qp, u_dot(1));
375  if(this->_flow_vars.dim() == 3)
376  context.interior_rate(this->_flow_vars.w(), qp, u_dot(2));
377 
378  return rho*u_dot;
379  }
380 
381 
383  ( AssemblyContext& context,
384  unsigned int qp,
385  const libMesh::Real rho,
386  libMesh::RealGradient &res_M,
387  libMesh::Real &d_res_Muvw_duvw
388  ) const
389  {
390  libMesh::RealGradient u_dot;
391  context.interior_rate(this->_flow_vars.u(), qp, u_dot(0));
392  if(this->_flow_vars.dim() > 1)
393  context.interior_rate(this->_flow_vars.v(), qp, u_dot(1));
394  if(this->_flow_vars.dim() == 3)
395  context.interior_rate(this->_flow_vars.w(), qp, u_dot(2));
396 
397  res_M = rho*u_dot;
398  d_res_Muvw_duvw = rho;
399  }
400 
401 } // namespace GRINS
libMesh::RealGradient div_GradU_T(libMesh::RealTensor &hess_u) const
libMesh::RealGradient div_divU_I_axi(libMesh::Real r, const libMesh::Gradient &U, const libMesh::Gradient &grad_u, const libMesh::RealTensor &hess_u, const libMesh::RealTensor &hess_v) const
libMesh::RealGradient compute_res_momentum_steady(AssemblyContext &context, unsigned int qp, const libMesh::Real rho, const libMesh::Real mu) const
libMesh::RealGradient UdotGradU(libMesh::Gradient &U, libMesh::Gradient &grad_u) const
libMesh::RealGradient compute_res_momentum_transient(AssemblyContext &context, unsigned int qp, const libMesh::Real rho) const
static std::string velocity_variable_name(const GetPot &input, const std::string &subsection_name, const SECTION_TYPE section_type)
static std::string press_variable_name(const GetPot &input, const std::string &subsection_name, const SECTION_TYPE section_type)
libMesh::RealGradient div_GradU_axi(libMesh::Real r, const libMesh::Gradient &U, const libMesh::Gradient &grad_u, const libMesh::Gradient &grad_v, const libMesh::RealTensor &hess_u, const libMesh::RealTensor &hess_v) const
GRINS namespace.
VariableIndex p() const
static PhysicsName incompressible_navier_stokes()
libMesh::RealGradient div_GradU(libMesh::RealTensor &hess_u) const
void compute_res_momentum_steady_and_derivs(AssemblyContext &context, unsigned int qp, const libMesh::Real rho, const libMesh::Real mu, libMesh::Gradient &res_M, libMesh::Tensor &d_res_M_dgradp, libMesh::Tensor &d_res_M_dU, libMesh::Gradient &d_res_Muvw_dgraduvw, libMesh::Tensor &d_res_Muvw_dhessuvw) const
void compute_res_momentum_transient_and_derivs(AssemblyContext &context, unsigned int qp, const libMesh::Real rho, libMesh::RealGradient &res_M, libMesh::Real &d_res_Muvw_duvw) const
unsigned int dim() const
Number of components.
void compute_res_continuity_and_derivs(AssemblyContext &context, unsigned int qp, libMesh::Real &res_C, libMesh::Tensor &d_res_C_dgradU) const
libMesh::RealGradient div_divU_I(libMesh::RealTensor &hess_u) const
libMesh::RealGradient div_GradU_T_axi(libMesh::Real r, const libMesh::Gradient &U, const libMesh::Gradient &grad_u, const libMesh::RealTensor &hess_u, const libMesh::RealTensor &hess_v) const
IncompressibleNavierStokesStabilizationHelper(const std::string &helper_name, const GetPot &input)
libMesh::Real compute_res_continuity(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