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