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