LCOV - code coverage report
Current view: top level - src/postprocessors - Q2PPiecewiseLinearSinkFlux.C (source / functions) Hit Total Coverage
Test: idaholab/moose richards: #31405 (292dce) with base fef103 Lines: 40 41 97.6 %
Date: 2025-09-04 07:56:35 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://mooseframework.inl.gov
       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             : //
      12             : #include "Q2PPiecewiseLinearSinkFlux.h"
      13             : #include "Function.h"
      14             : 
      15             : registerMooseObject("RichardsApp", Q2PPiecewiseLinearSinkFlux);
      16             : 
      17             : InputParameters
      18          51 : Q2PPiecewiseLinearSinkFlux::validParams()
      19             : {
      20          51 :   InputParameters params = SideIntegralPostprocessor::validParams();
      21         102 :   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         102 :   params.addParam<Real>("fluid_viscosity", "The fluid dynamic viscosity.");
      29         102 :   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         102 :   params.addCoupledVar("saturation", "The name of the water saturation variable");
      36         102 :   params.addRequiredCoupledVar("porepressure", "The name of the porepressure variable");
      37         102 :   params.addRequiredParam<std::vector<Real>>(
      38             :       "pressures", "Tuple of pressure values.  Must be monotonically increasing.");
      39         102 :   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         102 :   params.addParam<FunctionName>("multiplying_fcn",
      49         102 :                                 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          51 :   params.addClassDescription("Records the fluid flow into a sink (positive values indicate fluid "
      54             :                              "is flowing from porespace into the sink).");
      55          51 :   return params;
      56           0 : }
      57             : 
      58          22 : Q2PPiecewiseLinearSinkFlux::Q2PPiecewiseLinearSinkFlux(const InputParameters & parameters)
      59             :   : SideIntegralPostprocessor(parameters),
      60          66 :     _sink_func(getParam<std::vector<Real>>("pressures"),
      61             :                getParam<std::vector<Real>>("bare_fluxes")),
      62          22 :     _m_func(getFunction("multiplying_fcn")),
      63          22 :     _pp(coupledValue("porepressure")),
      64          70 :     _use_mobility(isParamValid("fluid_density") && isParamValid("fluid_viscosity")),
      65          57 :     _use_relperm(isParamValid("fluid_relperm") && isCoupled("saturation")),
      66          57 :     _density(isParamValid("fluid_density") ? &getUserObject<RichardsDensity>("fluid_density")
      67             :                                            : NULL),
      68          70 :     _viscosity(isParamValid("fluid_viscosity") ? getParam<Real>("fluid_viscosity") : 1),
      69          57 :     _relperm(isParamValid("fluid_relperm") ? &getUserObject<RichardsRelPerm>("fluid_relperm")
      70             :                                            : NULL),
      71          35 :     _sat(isCoupled("saturation") ? coupledValue("saturation") : _zero),
      72          66 :     _permeability(getMaterialProperty<RealTensorValue>("permeability"))
      73             : {
      74         100 :   if ((isParamValid("fluid_density") && !isParamValid("fluid_viscosity")) ||
      75          82 :       (!isParamValid("fluid_density") && isParamValid("fluid_viscosity")))
      76           2 :     mooseError("Q2PPiecewiseLinearSink: you must supply both of fluid_density and fluid_viscosity "
      77             :                "if you wish to multiply by the mobility");
      78          79 :   if ((isParamValid("fluid_relperm") && !isCoupled("saturation")) ||
      79          65 :       (!isParamValid("fluid_relperm") && isCoupled("saturation")))
      80           2 :     mooseError("Q2PPiecewiseLinearSink: you must supply both of fluid_relperm and saturation if "
      81             :                "you wish to multiply by the relative permeaility");
      82          18 : }
      83             : 
      84             : Real
      85         234 : Q2PPiecewiseLinearSinkFlux::computeQpIntegral()
      86             : {
      87         234 :   Real flux = _sink_func.sample(_pp[_qp]);
      88             : 
      89         234 :   flux *= _m_func.value(_t, _q_point[_qp]);
      90             : 
      91         234 :   if (_use_mobility)
      92             :   {
      93         156 :     Real k = (_permeability[_qp] * _normals[_qp]) * _normals[_qp];
      94         156 :     flux *= _density->density(_pp[_qp]) * k / _viscosity;
      95             :   }
      96         234 :   if (_use_relperm)
      97         156 :     flux *= _relperm->relperm(_sat[_qp]);
      98             : 
      99         234 :   return flux * _dt;
     100             : }

Generated by: LCOV version 1.14