GRINS-0.7.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-2016 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
34 
35 //libMesh
36 #include "libmesh/getpot.h"
37 #include "libmesh/mesh.h"
38 #include "libmesh/fem_system.h"
39 
40 namespace GRINS
41 {
42 
44  (const std::string & helper_name,
45  const GetPot& input)
46  : StabilizationHelper(helper_name),
47  _C(1),
48  _tau_factor(0.5),
49  _flow_vars(GRINSPrivate::VariableWarehouse::get_variable_subclass<VelocityFEVariables>(VariablesParsing::velocity_section())),
50  _press_var(GRINSPrivate::VariableWarehouse::get_variable_subclass<PressureFEVariable>(VariablesParsing::pressure_section()))
51  {
52  if (input.have_variable("Stabilization/tau_constant_vel"))
53  this->set_parameter
54  (_C, input, "Stabilization/tau_constant_vel", _C );
55  else
56  this->set_parameter
57  (_C, input, "Stabilization/tau_constant", _C );
58 
59  if (input.have_variable("Stabilization/tau_factor_vel"))
60  this->set_parameter
61  (_tau_factor, input, "Stabilization/tau_factor_vel", _tau_factor );
62  else
63  this->set_parameter
64  (_tau_factor, input, "Stabilization/tau_factor", _tau_factor );
65 
66  return;
67  }
68 
70  {
71  return;
72  }
73 
74  libMesh::RealGradient IncompressibleNavierStokesStabilizationHelper::UdotGradU( libMesh::Gradient& U,
75  libMesh::Gradient& grad_u,
76  libMesh::Gradient& grad_v ) const
77  {
78  return libMesh::RealGradient( U*grad_u, U*grad_v );
79  }
80 
81  libMesh::RealGradient IncompressibleNavierStokesStabilizationHelper::UdotGradU( libMesh::Gradient& U,
82  libMesh::Gradient& grad_u,
83  libMesh::Gradient& grad_v,
84  libMesh::Gradient& grad_w ) const
85  {
86  return libMesh::RealGradient( U*grad_u, U*grad_v, U*grad_w );
87  }
88 
89  libMesh::RealGradient IncompressibleNavierStokesStabilizationHelper::div_GradU( libMesh::RealTensor& hess_u,
90  libMesh::RealTensor& hess_v ) const
91  {
92  return libMesh::RealGradient( hess_u(0,0) + hess_u(1,1),
93  hess_v(0,0) + hess_v(1,1) );
94  }
95 
96  libMesh::RealGradient IncompressibleNavierStokesStabilizationHelper::div_GradU_axi( libMesh::Real r,
97  const libMesh::Gradient& U,
98  const libMesh::Gradient& grad_u,
99  const libMesh::Gradient& grad_v,
100  const libMesh::RealTensor& hess_u,
101  const libMesh::RealTensor& hess_v ) const
102  {
103  return libMesh::RealGradient( hess_u(0,0) + hess_u(1,1) + (grad_u(0) - U(0)/r)/r,
104  hess_v(0,0) + hess_v(1,1) + grad_v(0)/r );
105  }
106 
107  libMesh::RealGradient IncompressibleNavierStokesStabilizationHelper::div_GradU( libMesh::RealTensor& hess_u,
108  libMesh::RealTensor& hess_v,
109  libMesh::RealTensor& hess_w ) const
110  {
111  return libMesh::RealGradient( hess_u(0,0) + hess_u(1,1) + hess_u(2,2),
112  hess_v(0,0) + hess_v(1,1) + hess_v(2,2),
113  hess_w(0,0) + hess_w(1,1) + hess_w(2,2) );
114  }
115 
116  libMesh::RealGradient IncompressibleNavierStokesStabilizationHelper::div_GradU_T( libMesh::RealTensor& hess_u,
117  libMesh::RealTensor& hess_v ) const
118  {
119  return libMesh::RealGradient( hess_u(0,0) + hess_v(0,1),
120  hess_u(1,0) + hess_v(1,1));
121  }
122 
124  const libMesh::Gradient& U,
125  const libMesh::Gradient& grad_u,
126  const libMesh::RealTensor& hess_u,
127  const libMesh::RealTensor& hess_v ) const
128  {
129  return libMesh::RealGradient( hess_u(0,0) + hess_v(0,1) + (grad_u(0) - U(0)/r)/r,
130  hess_u(1,0) + hess_v(1,1) + grad_u(1)/r );
131  }
132 
133  libMesh::RealGradient IncompressibleNavierStokesStabilizationHelper::div_GradU_T( libMesh::RealTensor& hess_u,
134  libMesh::RealTensor& hess_v,
135  libMesh::RealTensor& hess_w ) const
136  {
137  return libMesh::RealGradient( hess_u(0,0) + hess_v(0,1) + hess_w(0,2),
138  hess_u(1,0) + hess_v(1,1) + hess_w(1,2),
139  hess_u(2,0) + hess_v(2,1) + hess_w(2,2) );
140  }
141 
142  libMesh::RealGradient IncompressibleNavierStokesStabilizationHelper::div_divU_I( libMesh::RealTensor& hess_u,
143  libMesh::RealTensor& hess_v ) const
144  {
145  return libMesh::RealGradient( hess_u(0,0) + hess_v(1,0),
146  hess_u(0,1) + hess_v(1,1) );
147  }
148 
150  const libMesh::Gradient& U,
151  const libMesh::Gradient& grad_u,
152  const libMesh::RealTensor& hess_u,
153  const libMesh::RealTensor& hess_v ) const
154  {
155  return libMesh::RealGradient( hess_u(0,0) + hess_v(1,0) + (grad_u(0) - U(0)/r)/r,
156  hess_u(0,1) + hess_v(1,1) + grad_u(1)/r );
157  }
158 
159  libMesh::RealGradient IncompressibleNavierStokesStabilizationHelper::div_divU_I( libMesh::RealTensor& hess_u,
160  libMesh::RealTensor& hess_v,
161  libMesh::RealTensor& hess_w) const
162  {
163  return libMesh::RealGradient( hess_u(0,0) + hess_v(1,0) + hess_w(2,0),
164  hess_u(0,1) + hess_v(1,1) + hess_w(2,1),
165  hess_u(0,2) + hess_v(1,2) + hess_w(2,2) );
166  }
167 
169  unsigned int qp ) const
170  {
171  libMesh::RealGradient grad_u, grad_v;
172 
173  grad_u = context.fixed_interior_gradient(this->_flow_vars.u(), qp);
174  grad_v = context.fixed_interior_gradient(this->_flow_vars.v(), qp);
175 
176  libMesh::Real divU = grad_u(0) + grad_v(1);
177 
178  if( context.get_system().get_mesh().mesh_dimension() == 3 )
179  {
180  divU += (context.fixed_interior_gradient(this->_flow_vars.w(), qp))(2);
181  }
182 
183  return divU;
184  }
185 
187  ( AssemblyContext& context,
188  unsigned int qp,
189  libMesh::Real &res_C,
190  libMesh::Tensor &d_res_C_dgradU
191  ) const
192  {
193  libMesh::RealGradient grad_u, grad_v;
194 
195  grad_u = context.fixed_interior_gradient(this->_flow_vars.u(), qp);
196  grad_v = context.fixed_interior_gradient(this->_flow_vars.v(), qp);
197 
198  libMesh::Real divU = grad_u(0) + grad_v(1);
199  d_res_C_dgradU = 0;
200  d_res_C_dgradU(0,0) = 1;
201  d_res_C_dgradU(1,1) = 1;
202 
203  if( context.get_system().get_mesh().mesh_dimension() == 3 )
204  {
205  divU += (context.fixed_interior_gradient(this->_flow_vars.w(), qp))(2);
206  d_res_C_dgradU(2,2) = 1;
207  }
208 
209  res_C = divU;
210  }
211 
213  unsigned int qp, const libMesh::Real rho, const libMesh::Real mu ) const
214  {
215  libMesh::RealGradient U( context.fixed_interior_value(this->_flow_vars.u(), qp),
216  context.fixed_interior_value(this->_flow_vars.v(), qp) );
217  if(context.get_system().get_mesh().mesh_dimension() == 3)
218  U(2) = context.fixed_interior_value(this->_flow_vars.w(), qp);
219 
220  libMesh::RealGradient grad_p = context.fixed_interior_gradient(this->_press_var.p(), qp);
221 
222  libMesh::RealGradient grad_u = context.fixed_interior_gradient(this->_flow_vars.u(), qp);
223  libMesh::RealGradient grad_v = context.fixed_interior_gradient(this->_flow_vars.v(), qp);
224 
225  libMesh::RealTensor hess_u = context.fixed_interior_hessian(this->_flow_vars.u(), qp);
226  libMesh::RealTensor hess_v = context.fixed_interior_hessian(this->_flow_vars.v(), qp);
227 
228  libMesh::RealGradient rhoUdotGradU;
229  libMesh::RealGradient divGradU;
230 
231  if( context.get_system().get_mesh().mesh_dimension() < 3 )
232  {
233  rhoUdotGradU = rho*this->UdotGradU( U, grad_u, grad_v );
234  divGradU = this->div_GradU( hess_u, hess_v );
235  }
236  else
237  {
238  libMesh::RealGradient grad_w = context.fixed_interior_gradient(this->_flow_vars.w(), qp);
239  libMesh::RealTensor hess_w = context.fixed_interior_hessian(this->_flow_vars.w(), qp);
240 
241  rhoUdotGradU = rho*this->UdotGradU( U, grad_u, grad_v, grad_w );
242 
243  divGradU = this->div_GradU( hess_u, hess_v, hess_w );
244  }
245 
246  return rhoUdotGradU + grad_p - mu*divGradU;
247  }
248 
250  ( AssemblyContext& context,
251  unsigned int qp, const libMesh::Real rho, const libMesh::Real mu,
252  libMesh::Gradient &res_M,
253  libMesh::Tensor &d_res_M_dgradp,
254  libMesh::Tensor &d_res_M_dU,
255  libMesh::Gradient &d_res_Muvw_dgraduvw,
256  libMesh::Tensor &d_res_Muvw_dhessuvw
257  ) const
258  {
259  libMesh::RealGradient U( context.fixed_interior_value(this->_flow_vars.u(), qp),
260  context.fixed_interior_value(this->_flow_vars.v(), qp) );
261  if(context.get_system().get_mesh().mesh_dimension() == 3)
262  U(2) = context.fixed_interior_value(this->_flow_vars.w(), qp);
263 
264  libMesh::RealGradient grad_p = context.fixed_interior_gradient(this->_press_var.p(), qp);
265 
266  libMesh::RealGradient grad_u = context.fixed_interior_gradient(this->_flow_vars.u(), qp);
267  libMesh::RealGradient grad_v = context.fixed_interior_gradient(this->_flow_vars.v(), qp);
268 
269  libMesh::RealTensor hess_u = context.fixed_interior_hessian(this->_flow_vars.u(), qp);
270  libMesh::RealTensor hess_v = context.fixed_interior_hessian(this->_flow_vars.v(), qp);
271 
272  libMesh::RealGradient rhoUdotGradU;
273  libMesh::RealGradient divGradU;
274 
275  if( context.get_system().get_mesh().mesh_dimension() < 3 )
276  {
277  rhoUdotGradU = rho*this->UdotGradU( U, grad_u, grad_v );
278  divGradU = this->div_GradU( hess_u, hess_v );
279  }
280  else
281  {
282  libMesh::RealGradient grad_w = context.fixed_interior_gradient(this->_flow_vars.w(), qp);
283  libMesh::RealTensor hess_w = context.fixed_interior_hessian(this->_flow_vars.w(), qp);
284 
285  rhoUdotGradU = rho*this->UdotGradU( U, grad_u, grad_v, grad_w );
286 
287  divGradU = this->div_GradU( hess_u, hess_v, hess_w );
288 
289  d_res_M_dU(0,2) = rho * grad_u(2);
290  d_res_M_dU(1,2) = rho * grad_v(2);
291 
292  d_res_Muvw_dgraduvw(2) = rho * U(2);
293  d_res_M_dgradp(2,2) = 1;
294  d_res_Muvw_dhessuvw(2,2) = mu;
295 
296  d_res_M_dU(2,0) = rho * grad_w(0);
297  d_res_M_dU(2,1) = rho * grad_w(1);
298  d_res_M_dU(2,2) = rho * grad_w(2);
299  }
300 
301  res_M = rhoUdotGradU + grad_p - mu*divGradU;
302 
303  d_res_M_dU(0,0) = rho * grad_u(0);
304  d_res_M_dU(0,1) = rho * grad_u(1);
305  d_res_M_dU(1,0) = rho * grad_v(0);
306  d_res_M_dU(1,1) = rho * grad_v(1);
307 
308  d_res_Muvw_dgraduvw(0) = rho * U(0);
309  d_res_Muvw_dgraduvw(1) = rho * U(1);
310 
311  d_res_M_dgradp(0,0) = 1;
312  d_res_M_dgradp(1,1) = 1;
313 
314  d_res_Muvw_dhessuvw(0,0) = mu;
315  d_res_Muvw_dhessuvw(1,1) = mu;
316  }
317 
318 
319  libMesh::RealGradient IncompressibleNavierStokesStabilizationHelper::compute_res_momentum_transient( AssemblyContext& context, unsigned int qp, const libMesh::Real rho ) const
320  {
321  libMesh::RealGradient u_dot;
322  context.interior_rate(this->_flow_vars.u(), qp, u_dot(0));
323  context.interior_rate(this->_flow_vars.v(), qp, u_dot(1));
324  if(context.get_system().get_mesh().mesh_dimension() == 3)
325  context.interior_rate(this->_flow_vars.w(), qp, u_dot(2));
326 
327  return rho*u_dot;
328  }
329 
330 
332  ( AssemblyContext& context,
333  unsigned int qp,
334  const libMesh::Real rho,
335  libMesh::RealGradient &res_M,
336  libMesh::Real &d_res_Muvw_duvw
337  ) const
338  {
339  libMesh::RealGradient u_dot;
340  context.interior_rate(this->_flow_vars.u(), qp, u_dot(0));
341  context.interior_rate(this->_flow_vars.v(), qp, u_dot(1));
342  if(context.get_system().get_mesh().mesh_dimension() == 3)
343  context.interior_rate(this->_flow_vars.w(), qp, u_dot(2));
344 
345  res_M = rho*u_dot;
346  d_res_Muvw_duvw = rho;
347  }
348 
349 } // namespace GRINS
libMesh::RealGradient div_divU_I(libMesh::RealTensor &hess_u, libMesh::RealTensor &hess_v) 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 compute_res_momentum_transient(AssemblyContext &context, unsigned int qp, const libMesh::Real rho) const
libMesh::RealGradient div_GradU(libMesh::RealTensor &hess_u, libMesh::RealTensor &hess_v) const
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 std::string velocity_section()
static std::string pressure_section()
libMesh::RealGradient UdotGradU(libMesh::Gradient &U, libMesh::Gradient &grad_u, libMesh::Gradient &grad_v) const
libMesh::RealGradient div_GradU_T(libMesh::RealTensor &hess_u, libMesh::RealTensor &hess_v) 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
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_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 Thu Jun 2 2016 21:52:28 for GRINS-0.7.0 by  doxygen 1.8.10