GRINS-0.7.0
List of all members | Public Member Functions | Protected Attributes | Private Member Functions
GRINS::IncompressibleNavierStokes< Viscosity > Class Template Reference

Physics class for Incompressible Navier-Stokes. More...

#include <inc_navier_stokes.h>

Inheritance diagram for GRINS::IncompressibleNavierStokes< Viscosity >:
Inheritance graph
[legend]
Collaboration diagram for GRINS::IncompressibleNavierStokes< Viscosity >:
Collaboration graph
[legend]

Public Member Functions

 IncompressibleNavierStokes (const std::string &physics_name, const GetPot &input)
 
 ~IncompressibleNavierStokes ()
 
virtual void auxiliary_init (MultiphysicsSystem &system)
 Any auxillary initialization a Physics class may need. More...
 
virtual void register_postprocessing_vars (const GetPot &input, PostProcessedQuantities< libMesh::Real > &postprocessing)
 Register postprocessing variables for IncompressibleNavierStokes. More...
 
virtual void element_time_derivative (bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
 Time dependent part(s) of physics for element interiors. More...
 
virtual void element_constraint (bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
 Constraint part(s) of physics for element interiors. More...
 
virtual void mass_residual (bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
 Mass matrix part(s) for element interiors. All boundary terms lie within the time_derivative part. More...
 
virtual void compute_postprocessed_quantity (unsigned int quantity_index, const AssemblyContext &context, const libMesh::Point &point, libMesh::Real &value)
 Compute value of postprocessed quantities at libMesh::Point. More...
 
- Public Member Functions inherited from GRINS::IncompressibleNavierStokesBase< Viscosity >
 IncompressibleNavierStokesBase (const std::string &my_physics_name, const std::string &core_physics_name, const GetPot &input)
 
 ~IncompressibleNavierStokesBase ()
 
virtual void init_variables (libMesh::FEMSystem *system)
 Initialization of Navier-Stokes variables. More...
 
virtual void set_time_evolving_vars (libMesh::FEMSystem *system)
 Sets velocity variables to be time-evolving. More...
 
virtual void init_context (AssemblyContext &context)
 Initialize context for added physics variables. More...
 
virtual void register_parameter (const std::string &param_name, libMesh::ParameterMultiAccessor< libMesh::Number > &param_pointer) const
 Each subclass will register its copy of an independent. More...
 
libMesh::Real get_viscosity_value (AssemblyContext &context, unsigned int qp) const
 
- Public Member Functions inherited from GRINS::Physics
 Physics (const GRINS::PhysicsName &physics_name, const GetPot &input)
 
virtual ~Physics ()
 
virtual bool enabled_on_elem (const libMesh::Elem *elem)
 Find if current physics is active on supplied element. More...
 
void set_is_steady (bool is_steady)
 Sets whether this physics is to be solved with a steady solver or not. More...
 
bool is_steady () const
 Returns whether or not this physics is being solved with a steady solver. More...
 
virtual void side_time_derivative (bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
 Time dependent part(s) of physics for boundaries of elements on the domain boundary. More...
 
virtual void nonlocal_time_derivative (bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
 Time dependent part(s) of physics for scalar variables. More...
 
virtual void side_constraint (bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
 Constraint part(s) of physics for boundaries of elements on the domain boundary. More...
 
virtual void nonlocal_constraint (bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
 Constraint part(s) of physics for scalar variables. More...
 
virtual void damping_residual (bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
 Damping matrix part(s) for element interiors. All boundary terms lie within the time_derivative part. More...
 
virtual void nonlocal_mass_residual (bool compute_jacobian, AssemblyContext &context, CachedValues &cache)
 Mass matrix part(s) for scalar variables. More...
 
void init_ics (libMesh::FEMSystem *system, libMesh::CompositeFunction< libMesh::Number > &all_ics)
 
virtual void compute_element_time_derivative_cache (const AssemblyContext &context, CachedValues &cache)
 
virtual void compute_side_time_derivative_cache (const AssemblyContext &context, CachedValues &cache)
 
virtual void compute_nonlocal_time_derivative_cache (const AssemblyContext &context, CachedValues &cache)
 
virtual void compute_element_constraint_cache (const AssemblyContext &context, CachedValues &cache)
 
virtual void compute_side_constraint_cache (const AssemblyContext &context, CachedValues &cache)
 
virtual void compute_nonlocal_constraint_cache (const AssemblyContext &context, CachedValues &cache)
 
virtual void compute_damping_residual_cache (const AssemblyContext &context, CachedValues &cache)
 
virtual void compute_mass_residual_cache (const AssemblyContext &context, CachedValues &cache)
 
virtual void compute_nonlocal_mass_residual_cache (const AssemblyContext &context, CachedValues &cache)
 
ICHandlingBaseget_ic_handler ()
 
- Public Member Functions inherited from GRINS::ParameterUser
 ParameterUser (const std::string &user_name)
 
virtual ~ParameterUser ()
 
virtual void set_parameter (libMesh::Number &param_variable, const GetPot &input, const std::string &param_name, libMesh::Number param_default)
 Each subclass can simultaneously read a parameter value from. More...
 
virtual void set_parameter (libMesh::ParsedFunction< libMesh::Number, libMesh::Gradient > &func, const GetPot &input, const std::string &func_param_name, const std::string &param_default)
 Each subclass can simultaneously read a parsed function from. More...
 
virtual void set_parameter (libMesh::ParsedFEMFunction< libMesh::Number > &func, const GetPot &input, const std::string &func_param_name, const std::string &param_default)
 Each subclass can simultaneously read a parsed function from. More...
 
virtual void move_parameter (const libMesh::Number &old_parameter, libMesh::Number &new_parameter)
 When cloning an object, we need to update parameter pointers. More...
 
virtual void move_parameter (const libMesh::ParsedFunction< libMesh::Number, libMesh::Gradient > &old_func, libMesh::ParsedFunction< libMesh::Number, libMesh::Gradient > &new_func)
 When cloning an object, we need to update parameter pointers. More...
 
virtual void move_parameter (const libMesh::ParsedFEMFunction< libMesh::Number > &old_func, libMesh::ParsedFEMFunction< libMesh::Number > &new_func)
 When cloning an object, we need to update parameter pointers. More...
 

Protected Attributes

PressurePinning _p_pinning
 
bool _pin_pressure
 Enable pressure pinning. More...
 
unsigned int _mu_index
 Index from registering this quantity. More...
 
- Protected Attributes inherited from GRINS::IncompressibleNavierStokesBase< Viscosity >
unsigned int _dim
 Physical dimension of problem. More...
 
VelocityFEVariables _flow_vars
 
PressureFEVariable _press_var
 
libMesh::Number _rho
 Material parameters, read from input. More...
 
Viscosity _mu
 Viscosity object. More...
 
- Protected Attributes inherited from GRINS::Physics
const PhysicsName _physics_name
 Name of the physics object. Used for reading physics specific inputs. More...
 
GRINS::ICHandlingBase_ic_handler
 
std::set< libMesh::subdomain_id_type > _enabled_subdomains
 Subdomains on which the current Physics class is enabled. More...
 

Private Member Functions

 IncompressibleNavierStokes ()
 

Additional Inherited Members

- Static Public Member Functions inherited from GRINS::Physics
static void set_is_axisymmetric (bool is_axisymmetric)
 Set whether we should treat the problem as axisymmetric. More...
 
static bool is_axisymmetric ()
 
- Static Public Attributes inherited from GRINS::ParameterUser
static std::string zero_vector_function = std::string("{0}")
 A parseable function string with LIBMESH_DIM components, all 0. More...
 
- Protected Member Functions inherited from GRINS::Physics
libMesh::UniquePtr< libMesh::FEGenericBase< libMesh::Real > > build_new_fe (const libMesh::Elem *elem, const libMesh::FEGenericBase< libMesh::Real > *fe, const libMesh::Point p)
 
void parse_enabled_subdomains (const GetPot &input, const std::string &physics_name)
 
- Static Protected Attributes inherited from GRINS::Physics
static bool _is_steady = false
 Caches whether or not the solver that's being used is steady or not. More...
 
static bool _is_axisymmetric = false
 Caches whether we are solving an axisymmetric problem or not. More...
 

Detailed Description

template<class Viscosity>
class GRINS::IncompressibleNavierStokes< Viscosity >

Physics class for Incompressible Navier-Stokes.

This physics class implements the classical Incompressible Navier-Stokes equations. This is a templated class, the class Viscosity can be instantiated as a specific type (right now:ConstantViscosity or SpatiallyVaryingViscosity) to allow the user to specify a constant or spatially varying viscosity in the input file

Definition at line 44 of file inc_navier_stokes.h.

Constructor & Destructor Documentation

template<class Mu >
GRINS::IncompressibleNavierStokes< Mu >::IncompressibleNavierStokes ( const std::string &  physics_name,
const GetPot &  input 
)

Definition at line 42 of file inc_navier_stokes.C.

References GRINS::Physics::_ic_handler, GRINS::IncompressibleNavierStokes< Viscosity >::_pin_pressure, and GRINS::PhysicsNaming::incompressible_navier_stokes().

43  : IncompressibleNavierStokesBase<Mu>(physics_name,
44  PhysicsNaming::incompressible_navier_stokes(), /* "core" Physics name */
45  input),
46  _p_pinning(input,physics_name),
47  _mu_index(0)
48  {
49  // This is deleted in the base class
50  this->_ic_handler = new GenericICHandler( physics_name, input );
51 
52  this->_pin_pressure = input("Physics/"+PhysicsNaming::incompressible_navier_stokes()+"/pin_pressure", false );
53  }
GRINS::ICHandlingBase * _ic_handler
Definition: physics.h:269
bool _pin_pressure
Enable pressure pinning.
static PhysicsName incompressible_navier_stokes()
unsigned int _mu_index
Index from registering this quantity.
template<class Viscosity >
GRINS::IncompressibleNavierStokes< Viscosity >::~IncompressibleNavierStokes ( )
inline

Definition at line 50 of file inc_navier_stokes.h.

50 {};
template<class Viscosity >
GRINS::IncompressibleNavierStokes< Viscosity >::IncompressibleNavierStokes ( )
private

Member Function Documentation

template<class Mu >
void GRINS::IncompressibleNavierStokes< Mu >::auxiliary_init ( MultiphysicsSystem system)
virtual

Any auxillary initialization a Physics class may need.

This is called after all variables are added, so this method can safely query the MultiphysicsSystem about variable information.

Reimplemented from GRINS::Physics.

Definition at line 56 of file inc_navier_stokes.C.

57  {
58  if( _pin_pressure )
59  _p_pinning.check_pin_location(system.get_mesh());
60  }
bool _pin_pressure
Enable pressure pinning.
void check_pin_location(const libMesh::MeshBase &mesh)
Check the mesh to ensure pin location is found.
template<class Mu >
void GRINS::IncompressibleNavierStokes< Mu >::compute_postprocessed_quantity ( unsigned int  quantity_index,
const AssemblyContext context,
const libMesh::Point &  point,
libMesh::Real &  value 
)
virtual

Compute value of postprocessed quantities at libMesh::Point.

Reimplemented from GRINS::Physics.

Definition at line 543 of file inc_navier_stokes.C.

547  {
548  if( quantity_index == this->_mu_index )
549  {
550  value = this->_mu(point, context.get_time());
551  }
552 
553  return;
554  }
unsigned int _mu_index
Index from registering this quantity.
template<class Mu >
void GRINS::IncompressibleNavierStokes< Mu >::element_constraint ( bool  compute_jacobian,
AssemblyContext context,
CachedValues cache 
)
virtual

Constraint part(s) of physics for element interiors.

Reimplemented from GRINS::Physics.

Definition at line 331 of file inc_navier_stokes.C.

References GRINS::Physics::is_axisymmetric().

334  {
335 #ifdef GRINS_USE_GRVY_TIMERS
336  this->_timer->BeginTimer("IncompressibleNavierStokes::element_constraint");
337 #endif
338 
339  // The number of local degrees of freedom in each variable.
340  const unsigned int n_u_dofs = context.get_dof_indices(this->_flow_vars.u()).size();
341  const unsigned int n_p_dofs = context.get_dof_indices(this->_press_var.p()).size();
342 
343  // We get some references to cell-specific data that
344  // will be used to assemble the linear system.
345 
346  // Element Jacobian * quadrature weights for interior integration.
347  const std::vector<libMesh::Real> &JxW =
348  context.get_element_fe(this->_flow_vars.u())->get_JxW();
349 
350  // The velocity shape function gradients (in global coords.)
351  // at interior quadrature points.
352  const std::vector<std::vector<libMesh::RealGradient> >& u_gradphi =
353  context.get_element_fe(this->_flow_vars.u())->get_dphi();
354 
355  // The velocity shape function gradients (in global coords.)
356  // at interior quadrature points.
357  const std::vector<std::vector<libMesh::Real> >& u_phi =
358  context.get_element_fe(this->_flow_vars.u())->get_phi();
359 
360  // The pressure shape functions at interior quadrature points.
361  const std::vector<std::vector<libMesh::Real> >& p_phi =
362  context.get_element_fe(this->_press_var.p())->get_phi();
363 
364  const std::vector<libMesh::Point>& u_qpoint =
365  context.get_element_fe(this->_flow_vars.u())->get_xyz();
366 
367  // The subvectors and submatrices we need to fill:
368  //
369  // Kpu, Kpv, Kpw, Fp
370 
371  libMesh::DenseSubMatrix<libMesh::Number> &Kpu = context.get_elem_jacobian(this->_press_var.p(), this->_flow_vars.u()); // R_{p},{u}
372  libMesh::DenseSubMatrix<libMesh::Number> &Kpv = context.get_elem_jacobian(this->_press_var.p(), this->_flow_vars.v()); // R_{p},{v}
373  libMesh::DenseSubMatrix<libMesh::Number>* Kpw = NULL;
374 
375  libMesh::DenseSubVector<libMesh::Number> &Fp = context.get_elem_residual(this->_press_var.p()); // R_{p}
376 
377  if( this->_dim == 3 )
378  {
379  Kpw = &context.get_elem_jacobian(this->_press_var.p(), this->_flow_vars.w()); // R_{p},{w}
380  }
381 
382  // Add the constraint given by the continuity equation.
383  unsigned int n_qpoints = context.get_element_qrule().n_points();
384  for (unsigned int qp=0; qp != n_qpoints; qp++)
385  {
386  // Compute the velocity gradient at the old Newton iterate.
387  libMesh::Gradient grad_u, grad_v, grad_w;
388  grad_u = context.interior_gradient(this->_flow_vars.u(), qp);
389  grad_v = context.interior_gradient(this->_flow_vars.v(), qp);
390  if (this->_dim == 3)
391  grad_w = context.interior_gradient(this->_flow_vars.w(), qp);
392 
393  libMesh::Number divU = grad_u(0) + grad_v(1);
394  if (this->_dim == 3)
395  divU += grad_w(2);
396 
397  const libMesh::Number r = u_qpoint[qp](0);
398 
399  libMesh::Real jac = JxW[qp];
400 
402  {
403  libMesh::Number u = context.interior_value( this->_flow_vars.u(), qp );
404  divU += u/r;
405  jac *= r;
406  }
407 
408  // Now a loop over the pressure degrees of freedom. This
409  // computes the contributions of the continuity equation.
410  for (unsigned int i=0; i != n_p_dofs; i++)
411  {
412  Fp(i) += p_phi[i][qp]*divU*jac;
413 
414  if (compute_jacobian)
415  {
416  libmesh_assert_equal_to (context.get_elem_solution_derivative(), 1.0);
417 
418  for (unsigned int j=0; j != n_u_dofs; j++)
419  {
420  Kpu(i,j) += p_phi[i][qp]*u_gradphi[j][qp](0)*jac * context.get_elem_solution_derivative();
421  Kpv(i,j) += p_phi[i][qp]*u_gradphi[j][qp](1)*jac * context.get_elem_solution_derivative();
422  if (this->_dim == 3)
423  (*Kpw)(i,j) += p_phi[i][qp]*u_gradphi[j][qp](2)*jac * context.get_elem_solution_derivative();
424 
426  {
427  Kpu(i,j) += p_phi[i][qp]*u_phi[j][qp]/r*jac * context.get_elem_solution_derivative();
428  }
429  } // end of the inner dof (j) loop
430 
431  } // end - if (compute_jacobian)
432 
433  } // end of the outer dof (i) loop
434  } // end of the quadrature point (qp) loop
435 
436  // Pin p = p_value at p_point
437  if( _pin_pressure )
438  {
439  _p_pinning.pin_value( context, compute_jacobian, this->_press_var.p() );
440  }
441 
442 #ifdef GRINS_USE_GRVY_TIMERS
443  this->_timer->EndTimer("IncompressibleNavierStokes::element_constraint");
444 #endif
445 
446  return;
447  }
static bool is_axisymmetric()
Definition: physics.h:133
bool _pin_pressure
Enable pressure pinning.
unsigned int _dim
Physical dimension of problem.
VariableIndex p() const
void pin_value(libMesh::DiffContext &context, const bool request_jacobian, const GRINS::VariableIndex var, const double penalty=1.0)
The idea here is to pin a variable to a particular value if there is a null space - e...
template<class Mu >
void GRINS::IncompressibleNavierStokes< Mu >::element_time_derivative ( bool  compute_jacobian,
AssemblyContext context,
CachedValues cache 
)
virtual

Time dependent part(s) of physics for element interiors.

Todo:
Would it be better to put this in its own DoF loop and do the if check once?

Reimplemented from GRINS::Physics.

Definition at line 94 of file inc_navier_stokes.C.

References GRINS::Physics::is_axisymmetric().

97  {
98 #ifdef GRINS_USE_GRVY_TIMERS
99  this->_timer->BeginTimer("IncompressibleNavierStokes::element_time_derivative");
100 #endif
101 
102  // The number of local degrees of freedom in each variable.
103  const unsigned int n_u_dofs = context.get_dof_indices(this->_flow_vars.u()).size();
104  const unsigned int n_p_dofs = context.get_dof_indices(this->_press_var.p()).size();
105 
106  // Check number of dofs is same for this->_flow_vars.u(), v_var and w_var.
107  libmesh_assert (n_u_dofs == context.get_dof_indices(this->_flow_vars.v()).size());
108  if (this->_dim == 3)
109  libmesh_assert (n_u_dofs == context.get_dof_indices(this->_flow_vars.w()).size());
110 
111  // We get some references to cell-specific data that
112  // will be used to assemble the linear system.
113 
114  // Element Jacobian * quadrature weights for interior integration.
115  const std::vector<libMesh::Real> &JxW =
116  context.get_element_fe(this->_flow_vars.u())->get_JxW();
117 
118  // The velocity shape functions at interior quadrature points.
119  const std::vector<std::vector<libMesh::Real> >& u_phi =
120  context.get_element_fe(this->_flow_vars.u())->get_phi();
121 
122  // The velocity shape function gradients (in global coords.)
123  // at interior quadrature points.
124  const std::vector<std::vector<libMesh::RealGradient> >& u_gradphi =
125  context.get_element_fe(this->_flow_vars.u())->get_dphi();
126 
127  // The pressure shape functions at interior quadrature points.
128  const std::vector<std::vector<libMesh::Real> >& p_phi =
129  context.get_element_fe(this->_press_var.p())->get_phi();
130 
131  const std::vector<libMesh::Point>& u_qpoint =
132  context.get_element_fe(this->_flow_vars.u())->get_xyz();
133 
134  // The subvectors and submatrices we need to fill:
135  //
136  // K_{\alpha \beta} = R_{\alpha},{\beta} = \partial{ R_{\alpha} } / \partial{ {\beta} } (where R denotes residual)
137  // e.g., for \alpha = v and \beta = u we get: K{vu} = R_{v},{u}
138  // Note that Kpu, Kpv, Kpw and Fp comes as constraint.
139 
140  libMesh::DenseSubMatrix<libMesh::Number> &Kuu = context.get_elem_jacobian(this->_flow_vars.u(), this->_flow_vars.u()); // R_{u},{u}
141  libMesh::DenseSubMatrix<libMesh::Number> &Kuv = context.get_elem_jacobian(this->_flow_vars.u(), this->_flow_vars.v()); // R_{u},{v}
142  libMesh::DenseSubMatrix<libMesh::Number>* Kuw = NULL;
143 
144  libMesh::DenseSubMatrix<libMesh::Number> &Kvu = context.get_elem_jacobian(this->_flow_vars.v(), this->_flow_vars.u()); // R_{v},{u}
145  libMesh::DenseSubMatrix<libMesh::Number> &Kvv = context.get_elem_jacobian(this->_flow_vars.v(), this->_flow_vars.v()); // R_{v},{v}
146  libMesh::DenseSubMatrix<libMesh::Number>* Kvw = NULL;
147 
148  libMesh::DenseSubMatrix<libMesh::Number>* Kwu = NULL;
149  libMesh::DenseSubMatrix<libMesh::Number>* Kwv = NULL;
150  libMesh::DenseSubMatrix<libMesh::Number>* Kww = NULL;
151 
152  libMesh::DenseSubMatrix<libMesh::Number> &Kup = context.get_elem_jacobian(this->_flow_vars.u(), this->_press_var.p()); // R_{u},{p}
153  libMesh::DenseSubMatrix<libMesh::Number> &Kvp = context.get_elem_jacobian(this->_flow_vars.v(), this->_press_var.p()); // R_{v},{p}
154  libMesh::DenseSubMatrix<libMesh::Number>* Kwp = NULL;
155 
156  libMesh::DenseSubVector<libMesh::Number> &Fu = context.get_elem_residual(this->_flow_vars.u()); // R_{u}
157  libMesh::DenseSubVector<libMesh::Number> &Fv = context.get_elem_residual(this->_flow_vars.v()); // R_{v}
158  libMesh::DenseSubVector<libMesh::Number>* Fw = NULL;
159 
160  if( this->_dim == 3 )
161  {
162  Kuw = &context.get_elem_jacobian(this->_flow_vars.u(), this->_flow_vars.w()); // R_{u},{w}
163  Kvw = &context.get_elem_jacobian(this->_flow_vars.v(), this->_flow_vars.w()); // R_{v},{w}
164  Kwu = &context.get_elem_jacobian(this->_flow_vars.w(), this->_flow_vars.u()); // R_{w},{u};
165  Kwv = &context.get_elem_jacobian(this->_flow_vars.w(), this->_flow_vars.v()); // R_{w},{v};
166  Kww = &context.get_elem_jacobian(this->_flow_vars.w(), this->_flow_vars.w()); // R_{w},{w}
167  Kwp = &context.get_elem_jacobian(this->_flow_vars.w(), this->_press_var.p()); // R_{w},{p}
168  Fw = &context.get_elem_residual(this->_flow_vars.w()); // R_{w}
169  }
170 
171  // Now we will build the element Jacobian and residual.
172  // Constructing the residual requires the solution and its
173  // gradient from the previous timestep. This must be
174  // calculated at each quadrature point by summing the
175  // solution degree-of-freedom values by the appropriate
176  // weight functions.
177  unsigned int n_qpoints = context.get_element_qrule().n_points();
178 
179  for (unsigned int qp=0; qp != n_qpoints; qp++)
180  {
181  // Compute the solution & its gradient at the old Newton iterate.
182  libMesh::Number p, u, v;
183  p = context.interior_value(this->_press_var.p(), qp);
184  u = context.interior_value(this->_flow_vars.u(), qp);
185  v = context.interior_value(this->_flow_vars.v(), qp);
186 
187  libMesh::Gradient grad_u, grad_v, grad_w;
188  grad_u = context.interior_gradient(this->_flow_vars.u(), qp);
189  grad_v = context.interior_gradient(this->_flow_vars.v(), qp);
190  if (this->_dim == 3)
191  grad_w = context.interior_gradient(this->_flow_vars.w(), qp);
192 
193  libMesh::NumberVectorValue U(u,v);
194  if (this->_dim == 3)
195  U(2) = context.interior_value(this->_flow_vars.w(), qp); // w
196 
197  const libMesh::Number grad_u_x = grad_u(0);
198  const libMesh::Number grad_u_y = grad_u(1);
199  const libMesh::Number grad_u_z = (this->_dim == 3)?grad_u(2):0;
200  const libMesh::Number grad_v_x = grad_v(0);
201  const libMesh::Number grad_v_y = grad_v(1);
202  const libMesh::Number grad_v_z = (this->_dim == 3)?grad_v(2):0;
203  const libMesh::Number grad_w_x = (this->_dim == 3)?grad_w(0):0;
204  const libMesh::Number grad_w_y = (this->_dim == 3)?grad_w(1):0;
205  const libMesh::Number grad_w_z = (this->_dim == 3)?grad_w(2):0;
206 
207  const libMesh::Number r = u_qpoint[qp](0);
208 
209  libMesh::Real jac = JxW[qp];
210 
211  // Compute the viscosity at this qp
212  libMesh::Real _mu_qp = this->_mu(context, qp);
213 
215  {
216  jac *= r;
217  }
218 
219  // First, an i-loop over the velocity degrees of freedom.
220  // We know that n_u_dofs == n_v_dofs so we can compute contributions
221  // for both at the same time.
222  for (unsigned int i=0; i != n_u_dofs; i++)
223  {
224  Fu(i) += jac *
225  (-this->_rho*u_phi[i][qp]*(U*grad_u) // convection term
226  +p*u_gradphi[i][qp](0) // pressure term
227  -_mu_qp*(u_gradphi[i][qp]*grad_u) ); // diffusion term
228 
231  {
232  Fu(i) += u_phi[i][qp]*( p/r - _mu_qp*U(0)/(r*r) )*jac;
233  }
234 
235  Fv(i) += jac *
236  (-this->_rho*u_phi[i][qp]*(U*grad_v) // convection term
237  +p*u_gradphi[i][qp](1) // pressure term
238  -_mu_qp*(u_gradphi[i][qp]*grad_v) ); // diffusion term
239 
240  if (this->_dim == 3)
241  {
242  (*Fw)(i) += jac *
243  (-this->_rho*u_phi[i][qp]*(U*grad_w) // convection term
244  +p*u_gradphi[i][qp](2) // pressure term
245  -_mu_qp*(u_gradphi[i][qp]*grad_w) ); // diffusion term
246  }
247 
248  if (compute_jacobian)
249  {
250  for (unsigned int j=0; j != n_u_dofs; j++)
251  {
252  // TODO: precompute some terms like:
253  // (Uvec*u_gradphi[j][qp]),
254  // u_phi[i][qp]*u_phi[j][qp],
255  // (u_gradphi[i][qp]*u_gradphi[j][qp])
256 
257  Kuu(i,j) += jac * context.get_elem_solution_derivative() *
258  (-this->_rho*u_phi[i][qp]*(U*u_gradphi[j][qp]) // convection term
259  -this->_rho*u_phi[i][qp]*grad_u_x*u_phi[j][qp] // convection term
260  -_mu_qp*(u_gradphi[i][qp]*u_gradphi[j][qp])); // diffusion term
261 
262 
264  {
265  Kuu(i,j) -= u_phi[i][qp]*_mu_qp*u_phi[j][qp]/(r*r)*jac * context.get_elem_solution_derivative();
266  }
267 
268  Kuv(i,j) += jac * context.get_elem_solution_derivative() *
269  (-this->_rho*u_phi[i][qp]*grad_u_y*u_phi[j][qp]); // convection term
270 
271  Kvv(i,j) += jac * context.get_elem_solution_derivative() *
272  (-this->_rho*u_phi[i][qp]*(U*u_gradphi[j][qp]) // convection term
273  -this->_rho*u_phi[i][qp]*grad_v_y*u_phi[j][qp] // convection term
274  -_mu_qp*(u_gradphi[i][qp]*u_gradphi[j][qp])); // diffusion term
275 
276  Kvu(i,j) += jac * context.get_elem_solution_derivative() *
277  (-this->_rho*u_phi[i][qp]*grad_v_x*u_phi[j][qp]); // convection term
278 
279  if (this->_dim == 3)
280  {
281  (*Kuw)(i,j) += jac * context.get_elem_solution_derivative() *
282  (-this->_rho*u_phi[i][qp]*grad_u_z*u_phi[j][qp]); // convection term
283 
284  (*Kvw)(i,j) += jac * context.get_elem_solution_derivative() *
285  (-this->_rho*u_phi[i][qp]*grad_v_z*u_phi[j][qp]); // convection term
286 
287  (*Kww)(i,j) += jac * context.get_elem_solution_derivative() *
288  (-this->_rho*u_phi[i][qp]*(U*u_gradphi[j][qp]) // convection term
289  -this->_rho*u_phi[i][qp]*grad_w_z*u_phi[j][qp] // convection term
290  -_mu_qp*(u_gradphi[i][qp]*u_gradphi[j][qp])); // diffusion term
291  (*Kwu)(i,j) += jac * context.get_elem_solution_derivative() *
292  (-this->_rho*u_phi[i][qp]*grad_w_x*u_phi[j][qp]); // convection term
293  (*Kwv)(i,j) += jac * context.get_elem_solution_derivative() *
294  (-this->_rho*u_phi[i][qp]*grad_w_y*u_phi[j][qp]); // convection term
295  }
296  } // end of the inner dof (j) loop
297 
298  // Matrix contributions for the up, vp and wp couplings
299  for (unsigned int j=0; j != n_p_dofs; j++)
300  {
301  Kup(i,j) += u_gradphi[i][qp](0)*p_phi[j][qp]*jac * context.get_elem_solution_derivative();
302  Kvp(i,j) += u_gradphi[i][qp](1)*p_phi[j][qp]*jac * context.get_elem_solution_derivative();
303 
304  if (this->_dim == 3)
305  {
306  (*Kwp)(i,j) += u_gradphi[i][qp](2)*p_phi[j][qp]*jac * context.get_elem_solution_derivative();
307  }
308 
310  {
311  Kup(i,j) += u_phi[i][qp]*p_phi[j][qp]/r*jac * context.get_elem_solution_derivative();
312  }
313 
314  } // end of the inner dof (j) loop
315 
316 
317 
318  } // end - if (compute_jacobian)
319 
320  } // end of the outer dof (i) loop
321  } // end of the quadrature point (qp) loop
322 
323 #ifdef GRINS_USE_GRVY_TIMERS
324  this->_timer->EndTimer("IncompressibleNavierStokes::element_time_derivative");
325 #endif
326 
327  return;
328  }
static bool is_axisymmetric()
Definition: physics.h:133
libMesh::Number _rho
Material parameters, read from input.
unsigned int _dim
Physical dimension of problem.
VariableIndex p() const
template<class Mu >
void GRINS::IncompressibleNavierStokes< Mu >::mass_residual ( bool  compute_jacobian,
AssemblyContext context,
CachedValues cache 
)
virtual

Mass matrix part(s) for element interiors. All boundary terms lie within the time_derivative part.

Reimplemented from GRINS::Physics.

Definition at line 450 of file inc_navier_stokes.C.

References GRINS::Physics::is_axisymmetric().

453  {
454  // Element Jacobian * quadrature weights for interior integration
455  // We assume the same for each flow variable
456  const std::vector<libMesh::Real> &JxW =
457  context.get_element_fe(this->_flow_vars.u())->get_JxW();
458 
459  // The shape functions at interior quadrature points.
460  // We assume the same for each flow variable
461  const std::vector<std::vector<libMesh::Real> >& u_phi =
462  context.get_element_fe(this->_flow_vars.u())->get_phi();
463 
464  const std::vector<libMesh::Point>& u_qpoint =
465  context.get_element_fe(this->_flow_vars.u())->get_xyz();
466 
467  // The number of local degrees of freedom in each variable
468  const unsigned int n_u_dofs = context.get_dof_indices(this->_flow_vars.u()).size();
469 
470  // The subvectors and submatrices we need to fill:
471  libMesh::DenseSubVector<libMesh::Real> &F_u = context.get_elem_residual(this->_flow_vars.u());
472  libMesh::DenseSubVector<libMesh::Real> &F_v = context.get_elem_residual(this->_flow_vars.v());
473  libMesh::DenseSubVector<libMesh::Real>* F_w = NULL;
474 
475  libMesh::DenseSubMatrix<libMesh::Real> &M_uu = context.get_elem_jacobian(this->_flow_vars.u(), this->_flow_vars.u());
476  libMesh::DenseSubMatrix<libMesh::Real> &M_vv = context.get_elem_jacobian(this->_flow_vars.v(), this->_flow_vars.v());
477  libMesh::DenseSubMatrix<libMesh::Real>* M_ww = NULL;
478 
479  if( this->_dim == 3 )
480  {
481  F_w = &context.get_elem_residual(this->_flow_vars.w()); // R_{w}
482  M_ww = &context.get_elem_jacobian(this->_flow_vars.w(), this->_flow_vars.w());
483  }
484 
485  unsigned int n_qpoints = context.get_element_qrule().n_points();
486 
487  for (unsigned int qp = 0; qp != n_qpoints; ++qp)
488  {
489  // For the mass residual, we need to be a little careful.
490  // The time integrator is handling the time-discretization
491  // for us so we need to supply M(u_fixed)*u' for the residual.
492  // u_fixed will be given by the fixed_interior_value function
493  // while u' will be given by the interior_rate function.
494  libMesh::Real u_dot, v_dot, w_dot = 0.0;
495  context.interior_rate(this->_flow_vars.u(), qp, u_dot);
496  context.interior_rate(this->_flow_vars.v(), qp, v_dot);
497 
498  if(this->_dim == 3 )
499  context.interior_rate(this->_flow_vars.w(), qp, w_dot);
500 
501  const libMesh::Number r = u_qpoint[qp](0);
502 
503  libMesh::Real jac = JxW[qp];
504 
506  {
507  jac *= r;
508  }
509 
510  for (unsigned int i = 0; i != n_u_dofs; ++i)
511  {
512  F_u(i) -= this->_rho*u_dot*u_phi[i][qp]*jac;
513  F_v(i) -= this->_rho*v_dot*u_phi[i][qp]*jac;
514 
515  if( this->_dim == 3 )
516  (*F_w)(i) -= this->_rho*w_dot*u_phi[i][qp]*jac;
517 
518  if( compute_jacobian )
519  {
520  for (unsigned int j=0; j != n_u_dofs; j++)
521  {
522  // Assuming rho is constant w.r.t. u, v, w
523  // and T (if Boussinesq added).
524  libMesh::Real value = this->_rho*u_phi[i][qp]*u_phi[j][qp]*jac * context.get_elem_solution_rate_derivative();
525 
526  M_uu(i,j) -= value;
527  M_vv(i,j) -= value;
528 
529  if( this->_dim == 3)
530  {
531  (*M_ww)(i,j) -= value;
532  }
533 
534  } // End dof loop
535  } // End Jacobian check
536  } // End dof loop
537  } // End quadrature loop
538 
539  return;
540  }
static bool is_axisymmetric()
Definition: physics.h:133
libMesh::Number _rho
Material parameters, read from input.
unsigned int _dim
Physical dimension of problem.
template<class Mu >
void GRINS::IncompressibleNavierStokes< Mu >::register_postprocessing_vars ( const GetPot &  input,
PostProcessedQuantities< libMesh::Real > &  postprocessing 
)
virtual

Register postprocessing variables for IncompressibleNavierStokes.

Reimplemented from GRINS::Physics.

Definition at line 63 of file inc_navier_stokes.C.

References GRINS::PhysicsNaming::incompressible_navier_stokes(), and GRINS::PostProcessedQuantities< NumericType >::register_quantity().

65  {
66  std::string section = "Physics/"+PhysicsNaming::incompressible_navier_stokes()+"/output_vars";
67 
68  if( input.have_variable(section) )
69  {
70  unsigned int n_vars = input.vector_variable_size(section);
71 
72  for( unsigned int v = 0; v < n_vars; v++ )
73  {
74  std::string name = input(section,"DIE!",v);
75 
76  if( name == std::string("mu") )
77  {
78  this->_mu_index = postprocessing.register_quantity( name );
79  }
80  else
81  {
82  std::cerr << "Error: Invalid output_vars value for "+PhysicsNaming::incompressible_navier_stokes() << std::endl
83  << " Found " << name << std::endl
84  << " Acceptable values are: mu" << std::endl;
85  libmesh_error();
86  }
87  }
88  }
89 
90  return;
91  }
static PhysicsName incompressible_navier_stokes()
unsigned int _mu_index
Index from registering this quantity.

Member Data Documentation

template<class Viscosity >
unsigned int GRINS::IncompressibleNavierStokes< Viscosity >::_mu_index
protected

Index from registering this quantity.

Definition at line 90 of file inc_navier_stokes.h.

template<class Viscosity >
PressurePinning GRINS::IncompressibleNavierStokes< Viscosity >::_p_pinning
protected

Definition at line 84 of file inc_navier_stokes.h.

template<class Viscosity >
bool GRINS::IncompressibleNavierStokes< Viscosity >::_pin_pressure
protected

Enable pressure pinning.

Definition at line 87 of file inc_navier_stokes.h.

Referenced by GRINS::IncompressibleNavierStokes< Viscosity >::IncompressibleNavierStokes().


The documentation for this class was generated from the following files:

Generated on Thu Jun 2 2016 21:52:31 for GRINS-0.7.0 by  doxygen 1.8.10