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 
18 {
20  params.addParam<Real>(
21  "a",
22  1.0E-10,
23  "Weight of the penalty. Penalty = a*(lower - variable) for variable<lower, "
24  "and zero otherwise. Care should be taken with this parameter choice. "
25  "Determine the typical size of your residual (usually rho*perm*(gradP - "
26  "rho*g)/visc), then typically you want the penalty to ensure p>lower*(1-1E-6), "
27  "so for the PPP formulation you typically Penalty = a*1E-6*|p|. I recommend "
28  "that Penalty = 1E-3*residual, yielding a = 1E3*residual/|P|. ");
29  params.addRequiredCoupledVar(
30  "lower_var", "Your variable will be constrained to be greater than this lower_var variable.");
31  params.addClassDescription("This adds a term to the residual that attempts to enforce variable > "
32  "lower_var. The term is a*(lower - variable) for variable<lower, and "
33  "zero otherwise");
34  return params;
35 }
36 
38  : Kernel(parameters),
39  _a(getParam<Real>("a")),
40  _lower(coupledValue("lower_var")),
41  _lower_var_num(coupled("lower_var"))
42 {
43 }
44 
45 Real
47 {
48  if (_u[_qp] < _lower[_qp])
49  return _test[_i][_qp] * _a * (_lower[_qp] - _u[_qp]);
50 
51  return 0.0;
52 }
53 
54 Real
56 {
57  if (_u[_qp] < _lower[_qp])
58  return -_test[_i][_qp] * _a * _phi[_j][_qp];
59  ;
60 
61  return 0.0;
62 }
63 
64 Real
66 {
67  if (jvar == _lower_var_num && _u[_qp] < _lower[_qp])
68  return _test[_i][_qp] * _a * _phi[_j][_qp];
69 
70  return 0.0;
71 }
virtual Real computeQpResidual()
static InputParameters validParams()
Real _a
Kernel = a*(_lower - variable) for variable<lower and zero otherwise.
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
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)
const VariableTestValue & _test
registerMooseObject("RichardsApp", RichardsPPenalty)
virtual Real computeQpJacobian()
Kernel = a*(lower - variable) for variable<lower, and zero otherwise This is an attempt to enforce va...
unsigned int _i
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
unsigned int _j
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
const VariablePhiValue & _phi
const VariableValue & _u
unsigned int _qp