www.mooseframework.org
RichardsHalfGaussianSink.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 // MOOSEincludes
11 #include "Function.h"
12 #include "Material.h"
13 #include "MooseVariable.h"
14 
15 #include "libmesh/utility.h"
16 
17 template <>
18 InputParameters
20 {
21  InputParameters params = validParams<IntegratedBC>();
22  params.addRequiredParam<Real>("max",
23  "Maximum of the flux (measured in kg.m^-2.s^-1). Flux out "
24  "= max*exp((-0.5*(p - centre)/sd)^2) for p<centre, and Flux "
25  "out = max for p>centre. Note, to make this a source "
26  "rather than a sink, let max<0");
27  params.addRequiredParam<Real>("sd",
28  "Standard deviation of the Gaussian (measured in Pa). Flux "
29  "out = max*exp((-0.5*(p - centre)/sd)^2) for p<centre, and "
30  "Flux out = max for p>centre.");
31  params.addRequiredParam<Real>("centre",
32  "Centre of the Gaussian (measured in Pa). Flux out = "
33  "max*exp((-0.5*(p - centre)/sd)^2) for p<centre, and "
34  "Flux out = max for p>centre.");
35  params.addParam<FunctionName>("multiplying_fcn",
36  1.0,
37  "If this function is provided, the flux "
38  "will be multiplied by this function. "
39  "This is useful for spatially or "
40  "temporally varying sinks");
41  params.addRequiredParam<UserObjectName>(
42  "richardsVarNames_UO", "The UserObject that holds the list of Richards variable names.");
43  return params;
44 }
45 
46 RichardsHalfGaussianSink::RichardsHalfGaussianSink(const InputParameters & parameters)
47  : IntegratedBC(parameters),
48  _maximum(getParam<Real>("max")),
49  _sd(getParam<Real>("sd")),
50  _centre(getParam<Real>("centre")),
51  _m_func(getFunction("multiplying_fcn")),
52  _richards_name_UO(getUserObject<RichardsVarNames>("richardsVarNames_UO")),
53  _pvar(_richards_name_UO.richards_var_num(_var.number())),
54  _pp(getMaterialProperty<std::vector<Real>>("porepressure")),
55  _dpp_dv(getMaterialProperty<std::vector<std::vector<Real>>>("dporepressure_dv"))
56 {
57 }
58 
59 Real
61 {
62  const Real test_fcn_f = _test[_i][_qp] * _m_func.value(_t, _q_point[_qp]);
63 
64  if (_pp[_qp][_pvar] >= _centre)
65  return test_fcn_f * _maximum;
66 
67  return test_fcn_f * _maximum *
68  std::exp(-0.5 * Utility::pow<2>((_pp[_qp][_pvar] - _centre) / _sd));
69 }
70 
71 Real
73 {
74  if (_pp[_qp][_pvar] >= _centre)
75  return 0.0;
76 
77  const Real test_fcn_f = _test[_i][_qp] * _m_func.value(_t, _q_point[_qp]);
78  return -test_fcn_f * _maximum * (_pp[_qp][_pvar] - _centre) / Utility::pow<2>(_sd) *
79  std::exp(-0.5 * Utility::pow<2>((_pp[_qp][_pvar] - _centre) / _sd)) * _phi[_j][_qp] *
80  _dpp_dv[_qp][_pvar][_pvar];
81 }
82 
83 Real
85 {
87  return 0.0;
88 
89  if (_pp[_qp][_pvar] >= _centre)
90  return 0.0;
91 
92  const Real test_fcn_f = _test[_i][_qp] * _m_func.value(_t, _q_point[_qp]);
93  const unsigned int dvar = _richards_name_UO.richards_var_num(jvar);
94  return -test_fcn_f * _maximum * (_pp[_qp][_pvar] - _centre) / Utility::pow<2>(_sd) *
95  std::exp(-0.5 * Utility::pow<2>((_pp[_qp][_pvar] - _centre) / _sd)) * _phi[_j][_qp] *
96  _dpp_dv[_qp][_pvar][dvar];
97 }
Real _maximum
maximum of the Gaussian sink
const MaterialProperty< std::vector< Real > > & _pp
porepressure (or porepressure vector for multiphase problems)
InputParameters validParams< RichardsHalfGaussianSink >()
Real _sd
standard deviation of the Gaussian sink
const RichardsVarNames & _richards_name_UO
holds info regarding the names of the Richards variables and methods for extracting values of these v...
bool not_richards_var(unsigned int moose_var_num) const
returns true if moose_var_num is not a richards var
This holds maps between pressure_var or pressure_var, sat_var used in RichardsMaterial and kernels...
Function & _m_func
multiplying function: all fluxes will be multiplied by this
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
const MaterialProperty< std::vector< std::vector< Real > > > & _dpp_dv
d(porepressure_i)/dvariable_j
RichardsHalfGaussianSink(const InputParameters &parameters)
unsigned int _pvar
the index of this variable in the list of Richards variables held by _richards_name_UO.
Real _centre
centre of the Gaussian sink
unsigned int richards_var_num(unsigned int moose_var_num) const
the richards variable number