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