37 #include "libmesh/getpot.h"
38 #include "libmesh/mesh.h"
39 #include "libmesh/fem_system.h"
45 (
const std::string & helper_name,
53 if (input.have_variable(
"Stabilization/tau_constant_vel"))
55 (_C, input,
"Stabilization/tau_constant_vel", _C );
58 (_C, input,
"Stabilization/tau_constant", _C );
60 if (input.have_variable(
"Stabilization/tau_factor_vel"))
62 (_tau_factor, input,
"Stabilization/tau_factor_vel", _tau_factor );
65 (_tau_factor, input,
"Stabilization/tau_factor", _tau_factor );
76 libMesh::Gradient& grad_u )
const
78 return libMesh::RealGradient( U*grad_u );
82 libMesh::Gradient& grad_u,
83 libMesh::Gradient& grad_v )
const
85 return libMesh::RealGradient( U*grad_u, U*grad_v );
89 libMesh::Gradient& grad_u,
90 libMesh::Gradient& grad_v,
91 libMesh::Gradient& grad_w )
const
93 return libMesh::RealGradient( U*grad_u, U*grad_v, U*grad_w );
98 return libMesh::RealGradient( hess_u(0,0) );
102 libMesh::RealTensor& hess_v )
const
104 return libMesh::RealGradient( hess_u(0,0) + hess_u(1,1),
105 hess_v(0,0) + hess_v(1,1) );
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
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 );
120 libMesh::RealTensor& hess_v,
121 libMesh::RealTensor& hess_w )
const
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) );
130 return libMesh::RealGradient( hess_u(0,0) );
134 libMesh::RealTensor& hess_v )
const
136 return libMesh::RealGradient( hess_u(0,0) + hess_v(0,1),
137 hess_u(1,0) + hess_v(1,1));
141 const libMesh::Gradient& U,
142 const libMesh::Gradient& grad_u,
143 const libMesh::RealTensor& hess_u,
144 const libMesh::RealTensor& hess_v )
const
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 );
151 libMesh::RealTensor& hess_v,
152 libMesh::RealTensor& hess_w )
const
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) );
161 return libMesh::RealGradient( hess_u(0,0) );
165 libMesh::RealTensor& hess_v )
const
167 return libMesh::RealGradient( hess_u(0,0) + hess_v(1,0),
168 hess_u(0,1) + hess_v(1,1) );
172 const libMesh::Gradient& U,
173 const libMesh::Gradient& grad_u,
174 const libMesh::RealTensor& hess_u,
175 const libMesh::RealTensor& hess_v )
const
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 );
182 libMesh::RealTensor& hess_v,
183 libMesh::RealTensor& hess_w)
const
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) );
191 unsigned int qp )
const
193 libMesh::RealGradient grad_u, grad_v;
195 grad_u = context.fixed_interior_gradient(this->
_flow_vars.
u(), qp);
197 libMesh::Real divU = grad_u(0);
201 divU += (context.fixed_interior_gradient(this->
_flow_vars.
v(), qp))(1);
206 divU += (context.fixed_interior_gradient(this->
_flow_vars.
w(), qp))(2);
215 libMesh::Real &res_C,
216 libMesh::Tensor &d_res_C_dgradU
219 libMesh::RealGradient grad_u =
220 context.fixed_interior_gradient(this->_flow_vars.u(), qp);
222 libMesh::Real divU = grad_u(0);
224 d_res_C_dgradU(0,0) = 1;
226 if( this->_flow_vars.dim() > 1 )
228 divU += (context.fixed_interior_gradient(this->_flow_vars.v(), qp))(1);
229 d_res_C_dgradU(1,1) = 1;
232 if( this->_flow_vars.dim() == 3 )
234 divU += (context.fixed_interior_gradient(this->_flow_vars.w(), qp))(2);
235 d_res_C_dgradU(2,2) = 1;
242 unsigned int qp,
const libMesh::Real rho,
const libMesh::Real mu )
const
244 libMesh::RealGradient U( context.fixed_interior_value(this->_flow_vars.u(), qp) );
246 U(1) = context.fixed_interior_value(this->
_flow_vars.
v(), qp);
248 U(2) = context.fixed_interior_value(this->
_flow_vars.
w(), qp);
250 libMesh::RealGradient grad_p = context.fixed_interior_gradient(this->
_press_var.
p(), qp);
252 libMesh::RealGradient grad_u = context.fixed_interior_gradient(this->
_flow_vars.
u(), qp);
254 libMesh::RealTensor hess_u = context.fixed_interior_hessian(this->
_flow_vars.
u(), qp);
256 libMesh::RealGradient rhoUdotGradU;
257 libMesh::RealGradient divGradU;
261 rhoUdotGradU = rho*this->
UdotGradU( U, grad_u );
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);
269 rhoUdotGradU = rho*this->
UdotGradU( U, grad_u, grad_v );
270 divGradU = this->
div_GradU( hess_u, hess_v );
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);
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);
280 rhoUdotGradU = rho*this->
UdotGradU( U, grad_u, grad_v, grad_w );
282 divGradU = this->
div_GradU( hess_u, hess_v, hess_w );
285 return rhoUdotGradU + grad_p - mu*divGradU;
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
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);
304 libMesh::RealGradient grad_p = context.fixed_interior_gradient(this->_press_var.p(), qp);
306 libMesh::RealGradient grad_u = context.fixed_interior_gradient(this->_flow_vars.u(), qp);
308 libMesh::RealTensor hess_u = context.fixed_interior_hessian(this->_flow_vars.u(), qp);
310 libMesh::RealGradient rhoUdotGradU;
311 libMesh::RealGradient divGradU;
313 if( this->_flow_vars.dim() == 1 )
315 rhoUdotGradU = rho*this->UdotGradU( U, grad_u );
316 divGradU = this->div_GradU( hess_u );
318 else if( this->_flow_vars.dim() == 2 )
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);
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);
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;
331 if( this->_flow_vars.dim() == 3 )
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);
336 rhoUdotGradU = rho*this->UdotGradU( U, grad_u, grad_v, grad_w );
338 divGradU = this->div_GradU( hess_u, hess_v, hess_w );
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);
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;
352 rhoUdotGradU = rho*this->UdotGradU( U, grad_u, grad_v );
353 divGradU = this->div_GradU( hess_u, hess_v );
357 res_M = rhoUdotGradU + grad_p - mu*divGradU;
359 d_res_M_dU(0,0) = rho * grad_u(0);
361 d_res_Muvw_dgraduvw(0) = rho * U(0);
363 d_res_M_dgradp(0,0) = 1;
365 d_res_Muvw_dhessuvw(0,0) = mu;
371 libMesh::RealGradient u_dot;
372 context.interior_rate(this->
_flow_vars.
u(), qp, u_dot(0));
374 context.interior_rate(this->_flow_vars.v(), qp, u_dot(1));
376 context.interior_rate(this->_flow_vars.w(), qp, u_dot(2));
385 const libMesh::Real rho,
386 libMesh::RealGradient &res_M,
387 libMesh::Real &d_res_Muvw_duvw
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));
398 d_res_Muvw_duvw = rho;
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
const VelocityVariable & _flow_vars
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
static PhysicsName incompressible_navier_stokes()
const PressureFEVariable & _press_var
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)
~IncompressibleNavierStokesStabilizationHelper()
libMesh::Real compute_res_continuity(AssemblyContext &context, unsigned int qp) const