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