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