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