14#include "libmesh/quadrature.h"
27 "The index corresponding to the fluid component that this Postprocessor acts on");
29 "PorousFlowDictator",
"The UserObject that holds the list of PorousFlow variable names.");
30 params.
addParam<std::vector<unsigned int>>(
"phase",
32 "The index of the fluid phase that this "
33 "Postprocessor is restricted to. Multiple "
34 "indices can be entered");
37 "saturation_threshold >= 0 & saturation_threshold <= 1",
38 "The saturation threshold below which the mass is calculated "
39 "for a specific phase. Default is 1.0. Note: only one "
40 "phase_index can be entered");
41 params.
addParam<
unsigned int>(
"kernel_variable_number",
43 "The PorousFlow variable number (according to the dictator) of "
44 "the fluid-mass kernel. This is required only in the unusual "
45 "situation where a variety of different finite-element "
46 "interpolation schemes are employed in the simulation");
49 "For non-mechanically-coupled systems with no TensorMechanics strain calculators, base_name "
50 "need not be set. For mechanically-coupled systems, base_name should be the same base_name "
51 "as given to the TensorMechanics object that computes strain, so that this Postprocessor can "
52 "correctly account for changes in mesh volume. For non-mechanically-coupled systems, "
53 "base_name should not be the base_name of any TensorMechanics strain calculators.");
54 params.
set<
bool>(
"use_displaced_mesh") =
false;
65 _fluid_component(getParam<unsigned
int>(
"fluid_component")),
66 _phase_index(getParam<
std::vector<unsigned
int>>(
"phase")),
67 _base_name(isParamValid(
"base_name") ? getParam<
std::string>(
"base_name") +
"_" :
""),
68 _has_total_strain(hasMaterialProperty<
RankTwoTensor>(_base_name +
"total_strain")),
69 _total_strain(_has_total_strain
70 ? &getMaterialProperty<
RankTwoTensor>(_base_name +
"total_strain")
72 _porosity(getGenericMaterialProperty<Real, is_ad>(
"PorousFlow_porosity_nodal")),
73 _fluid_density(getGenericMaterialProperty<
std::vector<Real>, is_ad>(
74 "PorousFlow_fluid_phase_density_nodal")),
76 getGenericMaterialProperty<
std::vector<Real>, is_ad>(
"PorousFlow_saturation_nodal")),
77 _mass_fraction(getGenericMaterialProperty<
std::vector<
std::vector<Real>>, is_ad>(
78 "PorousFlow_mass_frac_nodal")),
79 _saturation_threshold(getParam<Real>(
"saturation_threshold")),
80 _var(getParam<unsigned>(
"kernel_variable_number") < _dictator.numVariables()
81 ? &_fe_problem.getStandardVariable(
84 .getCoupledStandardMooseVars()[getParam<unsigned>(
"kernel_variable_number")]
95 "The Dictator proclaims that the number of components in this simulation is ",
97 " whereas you have used a component index of ",
99 ". Remember that indexing starts at 0. The Dictator does not take such mistakes lightly.");
104 "The Dictator decrees that the number of phases in this simulation is ",
106 " but you have entered ",
113 "The Dictator pronounces that the number of PorousFlow variables is ",
115 ", however you have used ",
116 getParam<unsigned>(
"kernel_variable_number"),
117 ". This is an error");
129 if (max_phase_num > num_phases - 1)
131 "The Dictator proclaims that the phase index ",
133 " is greater than the largest phase index possible, which is ",
140 "A single phase_index must be entered when prescribing a saturation_threshold");
144 for (
unsigned int i = 0; i < num_phases; ++i)
166 for (
unsigned node = 0; node < test.size(); ++node)
168 Real nodal_volume = 0.0;
169 for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
171 const Real n_v = _JxW[_qp] * _coord[_qp] * test[node][_qp];
172 if (_has_total_strain)
173 nodal_volume += n_v * (1.0 + (*_total_strain)[_qp].trace());
179 for (
auto ph : _phase_index)
183 _mass_fraction[node][ph][_fluid_component]);
registerMooseObject("PorousFlowApp", PorousFlowFluidMass)
void ErrorVector unsigned int
static InputParameters validParams()
const InputParameters & parameters() const
void paramError(const std::string ¶m, Args... args) const
void addMooseVariableDependency(MooseVariableFieldBase *var)
This holds maps between the nonlinear variables used in a PorousFlow simulation and the variable numb...
unsigned int numPhases() const
The number of fluid phases.
unsigned int numVariables() const
The number of PorousFlow variables.
unsigned int numComponents() const
The number of fluid components.
Postprocessor produces the mass of a given fluid component in a region.
static InputParameters validParams()
MooseVariable *const _var
The variable for the corresponding PorousFlowMassTimeDerivative Kernel: this provides test functions.
const PorousFlowDictator & _dictator
PorousFlowDictator UserObject.
virtual Real computeIntegral() override
std::vector< unsigned int > _phase_index
The phase indices that this Postprocessor is restricted to.
virtual Real computeQpIntegral() override
const Real _saturation_threshold
Saturation threshold - only fluid mass at saturations below this are calculated.
const std::string _base_name
base name used in the Tensor Mechanics strain calculator
PorousFlowFluidMassTempl(const InputParameters ¶meters)
const unsigned int _fluid_component
The fluid component index that this Postprocessor applies to.
const bool _has_total_strain
Whether there is a Material called _base_name_total_strain.
VariableShapeValue< true > VariableTestValue