www.mooseframework.org
RichardsPPenalty.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 
8 #include "RichardsPPenalty.h"
9 
10 #include <iostream>
11 
12 template <>
13 InputParameters
15 {
16  InputParameters params = validParams<Kernel>();
17  params.addParam<Real>(
18  "a",
19  1.0E-10,
20  "Weight of the penalty. Penalty = a*(lower - variable) for variable<lower, "
21  "and zero otherwise. Care should be taken with this parameter choice. "
22  "Determine the typical size of your residual (usually rho*perm*(gradP - "
23  "rho*g)/visc), then typically you want the penalty to ensure p>lower*(1-1E-6), "
24  "so for the PPP formulation you typically Penalty = a*1E-6*|p|. I recommend "
25  "that Penalty = 1E-3*residual, yielding a = 1E3*residual/|P|. ");
26  params.addRequiredCoupledVar(
27  "lower_var", "Your variable will be constrained to be greater than this lower_var variable.");
28  params.addClassDescription("This adds a term to the residual that attempts to enforce variable > "
29  "lower_var. The term is a*(lower - variable) for variable<lower, and "
30  "zero otherwise");
31  return params;
32 }
33 
34 RichardsPPenalty::RichardsPPenalty(const InputParameters & parameters)
35  : Kernel(parameters),
36  _a(getParam<Real>("a")),
37  _lower(coupledValue("lower_var")),
38  _lower_var_num(coupled("lower_var"))
39 {
40 }
41 
42 Real
44 {
45  if (_u[_qp] < _lower[_qp])
46  return _test[_i][_qp] * _a * (_lower[_qp] - _u[_qp]);
47 
48  return 0.0;
49 }
50 
51 Real
53 {
54  if (_u[_qp] < _lower[_qp])
55  return -_test[_i][_qp] * _a * _phi[_j][_qp];
56  ;
57 
58  return 0.0;
59 }
60 
61 Real
63 {
64  if (jvar == _lower_var_num && _u[_qp] < _lower[_qp])
65  return _test[_i][_qp] * _a * _phi[_j][_qp];
66 
67  return 0.0;
68 }
virtual Real computeQpResidual()
Real _a
Kernel = a*(_lower - variable) for variable<lower and zero otherwise.
const VariableValue & _lower
Kernel = a*(_lower - variable) for variable<lower and zero otherwise.
RichardsPPenalty(const InputParameters &parameters)
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
unsigned int _lower_var_num
moose variable number of the _lower variable (needed for OffDiagJacobian)
virtual Real computeQpJacobian()
InputParameters validParams< RichardsPPenalty >()