www.mooseframework.org
PorousFlowHeatEnergy.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 #include "PorousFlowHeatEnergy.h"
9 
10 // MOOSE includes
11 #include "MooseVariable.h"
12 
13 #include "libmesh/quadrature.h"
14 
15 template <>
16 InputParameters
18 {
19  InputParameters params = validParams<ElementIntegralPostprocessor>();
20  params.addRequiredParam<UserObjectName>(
21  "PorousFlowDictator", "The UserObject that holds the list of PorousFlow variable names.");
22  params.addParam<bool>(
23  "include_porous_skeleton", true, "Include the heat energy of the porous skeleton");
24  params.addParam<std::vector<unsigned int>>("phase",
25  "The index(es) of the fluid phase that this "
26  "Postprocessor is restricted to. Multiple "
27  "indices can be entered.");
28  params.set<bool>("use_displaced_mesh") = true;
29  params.addParam<unsigned int>("kernel_variable_number",
30  0,
31  "The PorousFlow variable number (according to the dictatory) of "
32  "the heat-energy kernel. This is required only in the unusual "
33  "situation where a variety of different finite-element "
34  "interpolation schemes are employed in the simulation");
35  params.addClassDescription("Calculates the sum of heat energy of fluid phase(s) and/or the "
36  "porous skeleton in a region");
37  return params;
38 }
39 
40 PorousFlowHeatEnergy::PorousFlowHeatEnergy(const InputParameters & parameters)
41  : ElementIntegralPostprocessor(parameters),
42  _dictator(getUserObject<PorousFlowDictator>("PorousFlowDictator")),
43  _num_phases(_dictator.numPhases()),
44  _fluid_present(_num_phases > 0),
45  _include_porous_skeleton(getParam<bool>("include_porous_skeleton")),
46  _phase_index(getParam<std::vector<unsigned int>>("phase")),
47  _porosity(getMaterialProperty<Real>("PorousFlow_porosity_nodal")),
48  _rock_energy_nodal(getMaterialProperty<Real>("PorousFlow_matrix_internal_energy_nodal")),
49  _fluid_density(
50  _fluid_present
51  ? &getMaterialProperty<std::vector<Real>>("PorousFlow_fluid_phase_density_nodal")
52  : nullptr),
53  _fluid_saturation_nodal(
54  _fluid_present ? &getMaterialProperty<std::vector<Real>>("PorousFlow_saturation_nodal")
55  : nullptr),
56  _energy_nodal(_fluid_present
57  ? &getMaterialProperty<std::vector<Real>>(
58  "PorousFlow_fluid_phase_internal_energy_nodal")
59  : nullptr),
60  _var(getParam<unsigned>("kernel_variable_number") < _dictator.numVariables()
61  ? _dictator.getCoupledMooseVars()[getParam<unsigned>("kernel_variable_number")]
62  : nullptr)
63 {
64  if (!_phase_index.empty())
65  {
67  const unsigned int max_phase_num = *std::max_element(_phase_index.begin(), _phase_index.end());
68  if (max_phase_num > _num_phases - 1)
69  mooseError("The Dictator proclaims that the phase index ",
70  max_phase_num,
71  " in the Postprocessor ",
72  _name,
73  " is greater than the largest phase index possible, which is ",
74  _num_phases - 1);
75  }
76 
78  if (getParam<unsigned>("kernel_variable_number") >= _dictator.numVariables())
79  mooseError("PorousFlowHeatEnergy: The dictator pronounces that the number of porous-flow "
80  "variables is ",
82  ", however you have used kernel_variable_number = ",
83  getParam<unsigned>("kernel_variable_number"),
84  ". This is an error");
85 }
86 
87 Real
89 {
90  Real sum = 0;
91 
99  const VariableTestValue & test = _var->phi();
100 
101  for (unsigned node = 0; node < test.size(); ++node)
102  {
103  Real nodal_volume = 0.0;
104  for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
105  nodal_volume += _JxW[_qp] * _coord[_qp] * test[node][_qp];
106 
107  Real energy = 0.0;
109  energy += (1.0 - _porosity[node]) * _rock_energy_nodal[node];
110 
111  for (auto ph : _phase_index)
112  energy += (*_fluid_density)[node][ph] * (*_fluid_saturation_nodal)[node][ph] *
113  (*_energy_nodal)[node][ph] * _porosity[node];
114 
115  sum += nodal_volume * energy;
116  }
117 
118  return sum;
119 }
120 
121 Real
123 {
124  return 0.0;
125 }
virtual Real computeQpIntegral() override
const MaterialProperty< Real > & _porosity
Porosity.
const MaterialProperty< Real > & _rock_energy_nodal
nodal rock energy density
const PorousFlowDictator & _dictator
Holds info on the PorousFlow variables.
const unsigned int _num_phases
Number of fluid phases.
MooseVariable *const _var
the variable for the corresponding PorousFlowEnergyTimeDerivative Kernel: this provides test function...
This holds maps between the nonlinear variables used in a PorousFlow simulation and the variable numb...
std::vector< unsigned int > _phase_index
The phase indices that this Postprocessor is restricted to.
const bool _include_porous_skeleton
Whether to include the heat energy of the porous skeleton in the calculations.
InputParameters validParams< PorousFlowHeatEnergy >()
unsigned int numVariables() const
The number of PorousFlow variables.
virtual Real computeIntegral() override
PorousFlowHeatEnergy(const InputParameters &parameters)