www.mooseframework.org
Q2PPiecewiseLinearSinkFlux.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 
8 // This post processor returns the mass due to a flux from the boundary of a volume.
9 //
11 #include "Function.h"
12 
13 template <>
14 InputParameters
16 {
17  InputParameters params = validParams<SideIntegralPostprocessor>();
18  params.addParam<UserObjectName>(
19  "fluid_density",
20  "The fluid density as a RichardsDensity UserObject. If this and the "
21  "fluid_viscosity are given, then fluxes are multiplied by "
22  "(density*permeability_nn/viscosity), where the '_nn' indicates the "
23  "component normal to the boundary. In this case bare_flux is measured in "
24  "Pa.s^-1. This can be used in conjunction with fluid_relperm.");
25  params.addParam<Real>("fluid_viscosity", "The fluid dynamic viscosity.");
26  params.addParam<UserObjectName>(
27  "fluid_relperm",
28  "The fluid density as a RichardsRelPerm UserObject (eg RichardsRelPermPower "
29  "for water, or Q2PRelPermPostGas for gas). If this and the saturation "
30  "variable are defined then the flux will be motiplied by relative "
31  "permeability. This can be used in conjunction with fluid_density");
32  params.addCoupledVar("saturation", "The name of the water saturation variable");
33  params.addRequiredCoupledVar("porepressure", "The name of the porepressure variable");
34  params.addRequiredParam<std::vector<Real>>(
35  "pressures", "Tuple of pressure values. Must be monotonically increasing.");
36  params.addRequiredParam<std::vector<Real>>(
37  "bare_fluxes",
38  "Tuple of flux values (measured in kg.m^-2.s^-1 if not using fluid_density, "
39  "otherwise in Pa.s^-1). This flux is OUT of the medium: hence positive "
40  "values of flux means this will be a SINK, while negative values indicate "
41  "this flux will be a SOURCE. A piecewise-linear fit is performed to the "
42  "(pressure,bare_fluxes) pairs to obtain the flux at any arbitrary pressure, "
43  "and the first or last bare_flux values are used if the quad-point pressure "
44  "falls outside this range.");
45  params.addParam<FunctionName>("multiplying_fcn",
46  1.0,
47  "The flux will be multiplied by this spatially-and-temporally "
48  "varying function. This is useful if the boundary is a moving "
49  "boundary controlled by RichardsExcav.");
50  params.addClassDescription("Records the fluid flow into a sink (positive values indicate fluid "
51  "is flowing from porespace into the sink).");
52  return params;
53 }
54 
55 Q2PPiecewiseLinearSinkFlux::Q2PPiecewiseLinearSinkFlux(const InputParameters & parameters)
56  : SideIntegralPostprocessor(parameters),
57  _sink_func(getParam<std::vector<Real>>("pressures"),
58  getParam<std::vector<Real>>("bare_fluxes")),
59  _m_func(getFunction("multiplying_fcn")),
60  _pp(coupledValue("porepressure")),
61  _use_mobility(isParamValid("fluid_density") && isParamValid("fluid_viscosity")),
62  _use_relperm(isParamValid("fluid_relperm") && isCoupled("saturation")),
63  _density(isParamValid("fluid_density") ? &getUserObject<RichardsDensity>("fluid_density")
64  : NULL),
65  _viscosity(isParamValid("fluid_viscosity") ? getParam<Real>("fluid_viscosity") : 1),
66  _relperm(isParamValid("fluid_relperm") ? &getUserObject<RichardsRelPerm>("fluid_relperm")
67  : NULL),
68  _sat(isCoupled("saturation") ? coupledValue("saturation") : _zero),
69  _permeability(getMaterialProperty<RealTensorValue>("permeability"))
70 {
71  if ((isParamValid("fluid_density") && !isParamValid("fluid_viscosity")) ||
72  (!isParamValid("fluid_density") && isParamValid("fluid_viscosity")))
73  mooseError("Q2PPiecewiseLinearSink: you must supply both of fluid_density and fluid_viscosity "
74  "if you wish to multiply by the mobility");
75  if ((isParamValid("fluid_relperm") && !isCoupled("saturation")) ||
76  (!isParamValid("fluid_relperm") && isCoupled("saturation")))
77  mooseError("Q2PPiecewiseLinearSink: you must supply both of fluid_relperm and saturation if "
78  "you wish to multiply by the relative permeaility");
79 }
80 
81 Real
83 {
84  Real flux = _sink_func.sample(_pp[_qp]);
85 
86  flux *= _m_func.value(_t, _q_point[_qp]);
87 
88  if (_use_mobility)
89  {
90  Real k = (_permeability[_qp] * _normals[_qp]) * _normals[_qp];
91  flux *= _density->density(_pp[_qp]) * k / _viscosity;
92  }
93  if (_use_relperm)
94  flux *= _relperm->relperm(_sat[_qp]);
95 
96  return flux * _dt;
97 }
Base class for Richards relative permeability classes that provide relative permeability as a functio...
Real _viscosity
fluid viscosity, optional
virtual Real density(Real p) const =0
fluid density as a function of porepressure This must be over-ridden in derived classes to provide an...
const VariableValue & _pp
the porepressure variable
const RichardsRelPerm * _relperm
fluid relative permeaility, optional
InputParameters validParams< Q2PPiecewiseLinearSinkFlux >()
Q2PPiecewiseLinearSinkFlux(const InputParameters &parameters)
const MaterialProperty< RealTensorValue > & _permeability
medium permeability
virtual Real relperm(Real seff) const =0
relative permeability as a function of effective saturation This must be over-ridden in your derived ...
const RichardsDensity * _density
fluid density, optional
bool _use_relperm
whether to include relative permeability in the flux
LinearInterpolation _sink_func
the sink function, which is a piecewise linear function of porepressure values
Base class for fluid density as a function of porepressure The functions density, ddensity and d2dens...
bool _use_mobility
whether to include density*permeability_nn/viscosity in the flux
Function & _m_func
the multiplier function
const VariableValue & _sat
saturation variable, optional