https://mooseframework.inl.gov
PorousFlowEnthalpySink.C
Go to the documentation of this file.
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 #include "PorousFlowEnthalpySink.h"
11 #include "Function.h"
12 #include "PorousFlowDictator.h"
14 #include "MooseVariable.h"
15 #include "PorousFlowSinkBC.h"
16 
17 #include "libmesh/quadrature.h"
18 
19 #include <iostream>
20 
22 
25 {
28  params.addRequiredParam<UserObjectName>(
29  "PorousFlowDictator", "The UserObject that holds the list of PorousFlow variable names");
30  params.addClassDescription(
31  "Applies a source equal to the product of the mass flux and the "
32  "fluid enthalpy. The enthalpy is computed at temperature T_in and pressure equal to the "
33  "porepressure in the porous medium, if fluid_phase is given, otherwise at the supplied "
34  "porepressure. Hence this adds heat energy to the porous medium at rate corresponding to a "
35  "fluid being injected at (porepressure, T_in) at rate (-flux_function).");
36 
37  return params;
38 }
39 
41  : IntegratedBC(parameters),
42  _dictator(getUserObject<PorousFlowDictator>("PorousFlowDictator")),
43  _pressure(isCoupled("porepressure_var") ? &coupledValue("porepressure_var") : nullptr),
44  _ph(isParamValid("fluid_phase") ? getParam<unsigned int>("fluid_phase")
46  _m_func(getFunction("flux_function")),
47  _pp(getMaterialProperty<std::vector<Real>>("PorousFlow_porepressure_nodal")),
48  _dpp_dvar(
49  getMaterialProperty<std::vector<std::vector<Real>>>("dPorousFlow_porepressure_nodal_dvar")),
50  _T_in(getParam<Real>("T_in")),
51  _fp(getUserObject<SinglePhaseFluidProperties>("fp"))
52 {
53  if ((_pressure != nullptr) && (isParamValid("fluid_phase")))
54  mooseError(name(), ": Cannot specify both pressure and pore pressure.");
55 
56  if ((_pressure == nullptr) && (!isParamValid("fluid_phase")))
57  mooseError(name(), ": You have to specify either 'pressure' or 'fluid_phase'.");
58 
59  if (isParamValid("fluid_phase"))
60  if (_ph >= _dictator.numPhases())
61  mooseError(name(),
62  ": Specified 'fluid_phase' is larger than the number of phases available in the "
63  "simulation (",
65  ").");
66 }
67 
68 Real
70 {
71  Real h;
72  if (_pressure)
73  h = _fp.h_from_p_T((*_pressure)[_qp], _T_in);
74  else
75  h = _fp.h_from_p_T(_pp[_i][_ph], _T_in);
76 
77  return _test[_i][_qp] * _m_func.value(_t, _q_point[_qp]) * h;
78 }
79 
80 Real
82 {
83  return jac(_var.number());
84 }
85 
86 Real
88 {
89  return jac(jvar);
90 }
91 
92 Real
93 PorousFlowEnthalpySink::jac(unsigned int jvar) const
94 {
96  return 0.0;
97 
98  const unsigned int pvar = _dictator.porousFlowVariableNum(jvar);
99 
100  if (_i != _j)
101  return 0.0;
102 
103  Real jac;
104  if (_pressure)
105  {
106  jac = 0.;
107  }
108  else
109  {
110  Real h, dh_dpp, dh_dT;
111  _fp.h_from_p_T(_pp[_i][_ph], _T_in, h, dh_dpp, dh_dT);
112  jac = dh_dpp * _dpp_dvar[_i][_ph][pvar];
113  }
114  return _test[_i][_qp] * _m_func.value(_t, _q_point[_qp]) * jac;
115 }
const VariableTestValue & _test
static InputParameters validParams()
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
unsigned int _j
virtual Real computeQpJacobian() override
bool notPorousFlowVariable(unsigned int moose_var_num) const
Returns true if moose_var_num is not a porous flow variabe.
const unsigned int invalid_uint
unsigned int number() const
static InputParameters validParamsCommon()
PorousFlowEnthalpySink(const InputParameters &parameters)
static InputParameters validParams()
unsigned int _i
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...
virtual const std::string & name() const
virtual Real computeQpResidual() override
void addRequiredParam(const std::string &name, const std::string &doc_string)
unsigned int _qp
const Real & _T_in
Specified inlet temperature.
bool isParamValid(const std::string &name) const
const SinglePhaseFluidProperties & _fp
Fluid properties UserObject.
const MooseArray< Point > & _q_point
const VariableValue * _pressure
Pressure (from aux variable)
Common class for single phase fluid properties.
const MaterialProperty< std::vector< Real > > & _pp
Computed nodal values of porepressure of the phases.
const unsigned int _ph
The phase number.
unsigned int numPhases() const
The number of fluid phases.
Real jac(unsigned int jvar) const
Derivative of residual with respect to the jvar variable.
MooseVariable & _var
Applies a flux sink of heat energy to a boundary with specified mass flux and inlet temperature...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
This holds maps between the nonlinear variables used in a PorousFlow simulation and the variable numb...
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
const Function & _m_func
The mass flux.
unsigned int porousFlowVariableNum(unsigned int moose_var_num) const
The PorousFlow variable number.
const MaterialProperty< std::vector< std::vector< Real > > > & _dpp_dvar
d(porepressure)/d(PorousFlow variable)
virtual Real value(Real t, const Point &p) const
registerMooseObject("PorousFlowApp", PorousFlowEnthalpySink)
void ErrorVector unsigned int
const PorousFlowDictator & _dictator
PorousFlowDictator UserObject.