www.mooseframework.org
INSExplicitTimestepSelector.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
9 
10 #include "libmesh/quadrature.h"
11 
12 template <>
13 InputParameters
15 {
16  InputParameters params = validParams<ElementPostprocessor>();
17 
18  params.addClassDescription("Postprocessor that computes the minimum value of h_min/|u|, where "
19  "|u| is coupled in as an aux variable.");
20 
21  // Coupled variables
22  params.addRequiredCoupledVar("vel_mag", "Velocity magnitude");
23 
24  // Required parameters
25  params.addRequiredParam<Real>("beta",
26  "0 < beta < 1, choose some fraction of the limiting timestep size");
27 
28  // Optional parameters
29  params.addParam<MaterialPropertyName>("mu_name", "mu", "The name of the dynamic viscosity");
30  params.addParam<MaterialPropertyName>("rho_name", "rho", "The name of the density");
31 
32  return params;
33 }
34 
36  : ElementPostprocessor(parameters),
37  _vel_mag(coupledValue("vel_mag")),
38 
39  // Other parameters
40  _beta(getParam<Real>("beta")),
41 
42  // Material properties
43  _mu(getMaterialProperty<Real>("mu_name")),
44  _rho(getMaterialProperty<Real>("rho_name"))
45 {
46 }
47 
49 
50 void
52 {
53  _value = std::numeric_limits<Real>::max();
54 }
55 
56 void
58 {
59  Real h_min = _current_elem->hmin();
60 
61  // The space dimension plays a role in the diffusive dt limit. The more
62  // space dimensions there are, the smaller this limit is.
63  Real dim = static_cast<Real>(_current_elem->dim());
64 
65  for (unsigned qp = 0; qp < _qrule->n_points(); ++qp)
66  {
67  // Don't divide by zero...
68  Real vel_mag = std::max(_vel_mag[qp], std::numeric_limits<Real>::epsilon());
69 
70  // For explicit Euler, we always have to satisfy the Courant condition for stability.
71  Real courant_limit_dt = h_min / vel_mag;
72 
73  // But we also have to obey the diffusive time restriction,
74  // dt <= 1/(2*nu)*(1/h1^2 + 1/h2^2 + 1/h3^2)^(-1) <=
75  // <= h_min^2 / n_dim / (2*nu)
76  Real diffusive_limit_dt = 0.5 * h_min * h_min / (_mu[qp] / _rho[qp]) / dim;
77 
78  // And the "combined" condition, dt <= 2*nu/|u|^2
79  Real combined_limit_dt = 2. * (_mu[qp] / _rho[qp]) / vel_mag / vel_mag;
80 
81  // // Debugging:
82  // Moose::out << "courant_limit_dt = " << courant_limit_dt << "\n"
83  // << "diffusive_limit_dt = " << diffusive_limit_dt << "\n"
84  // << "combined_limit_dt = " << combined_limit_dt
85  // << std::endl;
86 
87  _value = std::min(
88  _value,
89  _beta * std::min(std::min(courant_limit_dt, diffusive_limit_dt), combined_limit_dt));
90  }
91 }
92 
93 Real
95 {
96  _communicator.min(_value);
97  return _value;
98 }
99 
100 void
102 {
103  const INSExplicitTimestepSelector & pps = dynamic_cast<const INSExplicitTimestepSelector &>(uo);
104  _value = std::min(_value, pps._value);
105 }
Real _beta
We can compute maximum stable timesteps based on the linearized theory, but even those timesteps are ...
const MaterialProperty< Real > & _mu
Material properties: the explicit time scheme limit for the viscous problem also depends on the kinem...
InputParameters validParams< INSExplicitTimestepSelector >()
const MaterialProperty< Real > & _rho
Postprocessor that computes the minimum value of h_min/|u|, where |u| is coupled in as an aux variabl...
const VariableValue & _vel_mag
Velocity magnitude. Hint: Use VectorMagnitudeAux in Moose for this.
INSExplicitTimestepSelector(const InputParameters &parameters)
virtual void threadJoin(const UserObject &uo)
Real _value
The value of dt (NOTE: _dt member variable is already defined)