www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PorousFlowFluidMass Class Reference

Postprocessor produces the mass of a given fluid component in a region. More...

#include <PorousFlowFluidMass.h>

Inheritance diagram for PorousFlowFluidMass:
[legend]

Public Member Functions

 PorousFlowFluidMass (const InputParameters &parameters)
 

Protected Member Functions

virtual Real computeIntegral () override
 
virtual Real computeQpIntegral () override
 

Protected Attributes

const PorousFlowDictator_dictator
 PorousFlowDictator UserObject. More...
 
const unsigned int _fluid_component
 The fluid component index that this Postprocessor applies to. More...
 
std::vector< unsigned int > _phase_index
 The phase indices that this Postprocessor is restricted to. More...
 
const MaterialProperty< Real > & _porosity
 Porosity. More...
 
const MaterialProperty< std::vector< Real > > & _fluid_density
 Phase density (kg/m^3) More...
 
const MaterialProperty< std::vector< Real > > & _fluid_saturation
 Phase saturation (-) More...
 
const MaterialProperty< std::vector< std::vector< Real > > > & _mass_fraction
 Mass fraction of each fluid component in each phase. More...
 
const Real _saturation_threshold
 Saturation threshold - only fluid mass at saturations below this are calculated. More...
 
MooseVariable *const _var
 The variable for the corresponding PorousFlowMassTimeDerivative Kernel: this provides test functions. More...
 

Detailed Description

Postprocessor produces the mass of a given fluid component in a region.

Definition at line 24 of file PorousFlowFluidMass.h.

Constructor & Destructor Documentation

◆ PorousFlowFluidMass()

PorousFlowFluidMass::PorousFlowFluidMass ( const InputParameters &  parameters)

Definition at line 50 of file PorousFlowFluidMass.C.

51  : ElementIntegralPostprocessor(parameters),
52 
53  _dictator(getUserObject<PorousFlowDictator>("PorousFlowDictator")),
54  _fluid_component(getParam<unsigned int>("fluid_component")),
55  _phase_index(getParam<std::vector<unsigned int>>("phase")),
56  _porosity(getMaterialProperty<Real>("PorousFlow_porosity_nodal")),
57  _fluid_density(getMaterialProperty<std::vector<Real>>("PorousFlow_fluid_phase_density_nodal")),
58  _fluid_saturation(getMaterialProperty<std::vector<Real>>("PorousFlow_saturation_nodal")),
60  getMaterialProperty<std::vector<std::vector<Real>>>("PorousFlow_mass_frac_nodal")),
61  _saturation_threshold(getParam<Real>("saturation_threshold")),
62  _var(getParam<unsigned>("kernel_variable_number") < _dictator.numVariables()
63  ? _dictator.getCoupledStandardMooseVars()[getParam<unsigned>("kernel_variable_number")]
64  : nullptr)
65 {
66  const unsigned int num_phases = _dictator.numPhases();
67  const unsigned int num_components = _dictator.numComponents();
68 
69  // Check that the number of components entered is not greater than the total number of components
70  if (_fluid_component >= num_components)
71  paramError(
72  "fluid_component",
73  "The Dictator proclaims that the number of components in this simulation is ",
74  num_components,
75  " whereas you have used a component index of ",
77  ". Remember that indexing starts at 0. The Dictator does not take such mistakes lightly.");
78 
79  // Check that the number of phases entered is not more than the total possible phases
80  if (_phase_index.size() > num_phases)
81  paramError("phase",
82  "The Dictator decrees that the number of phases in this simulation is ",
83  num_phases,
84  " but you have entered ",
85  _phase_index.size(),
86  " phases.");
87 
88  // Check that kernel_variable_number is OK
89  if (getParam<unsigned>("kernel_variable_number") >= _dictator.numVariables())
90  paramError("kernel_variable_number",
91  "The Dictator pronounces that the number of PorousFlow variables is ",
93  ", however you have used ",
94  getParam<unsigned>("kernel_variable_number"),
95  ". This is an error");
96 
97  // Also check that the phase indices entered are not greater than the number of phases
98  // to avoid a segfault. Note that the input parser takes care of negative inputs so we
99  // don't need to guard against them
100  if (!_phase_index.empty())
101  {
102  unsigned int max_phase_num = *std::max_element(_phase_index.begin(), _phase_index.end());
103  if (max_phase_num > num_phases - 1)
104  paramError("phase",
105  "The Dictator proclaims that the phase index ",
106  max_phase_num,
107  " is greater than the largest phase index possible, which is ",
108  num_phases - 1);
109  }
110 
111  // Using saturation_threshold only makes sense for a specific phase_index
112  if (_saturation_threshold < 1.0 && _phase_index.size() != 1)
113  paramError("saturation_threshold",
114  "A single phase_index must be entered when prescribing a saturation_threshold");
115 
116  // If _phase_index is empty, create vector of all phase numbers to calculate mass over all phases
117  if (_phase_index.empty())
118  for (unsigned int i = 0; i < num_phases; ++i)
119  _phase_index.push_back(i);
120 }
const MaterialProperty< std::vector< Real > > & _fluid_saturation
Phase saturation (-)
unsigned int numComponents() const
The number of fluid components.
std::vector< unsigned int > _phase_index
The phase indices that this Postprocessor is restricted to.
const Real _saturation_threshold
Saturation threshold - only fluid mass at saturations below this are calculated.
const MaterialProperty< Real > & _porosity
Porosity.
unsigned int numPhases() const
The number of fluid phases.
unsigned int numVariables() const
The number of PorousFlow variables.
const PorousFlowDictator & _dictator
PorousFlowDictator UserObject.
const MaterialProperty< std::vector< Real > > & _fluid_density
Phase density (kg/m^3)
const unsigned int _fluid_component
The fluid component index that this Postprocessor applies to.
MooseVariable *const _var
The variable for the corresponding PorousFlowMassTimeDerivative Kernel: this provides test functions...
const MaterialProperty< std::vector< std::vector< Real > > > & _mass_fraction
Mass fraction of each fluid component in each phase.

Member Function Documentation

◆ computeIntegral()

Real PorousFlowFluidMass::computeIntegral ( )
overrideprotectedvirtual

Definition at line 123 of file PorousFlowFluidMass.C.

124 {
125  Real sum = 0;
126 
127  // The use of _test in the loops below mean that the
128  // integral is exactly the same as the one computed
129  // by the PorousFlowMassTimeDerivative Kernel. Because that
130  // Kernel is lumped, this Postprocessor also needs to
131  // be lumped. Hence the use of the "nodal" Material
132  // Properties
133  const VariableTestValue & test = _var->phi();
134 
135  for (unsigned node = 0; node < test.size(); ++node)
136  {
137  Real nodal_volume = 0.0;
138  for (_qp = 0; _qp < _qrule->n_points(); ++_qp)
139  nodal_volume += _JxW[_qp] * _coord[_qp] * test[node][_qp];
140 
141  Real mass = 0.0;
142  for (auto ph : _phase_index)
143  {
144  if (_fluid_saturation[node][ph] <= _saturation_threshold)
145  mass += _fluid_density[node][ph] * _fluid_saturation[node][ph] *
146  _mass_fraction[node][ph][_fluid_component];
147  }
148  sum += nodal_volume * _porosity[node] * mass;
149  }
150 
151  return sum;
152 }
const MaterialProperty< std::vector< Real > > & _fluid_saturation
Phase saturation (-)
std::vector< unsigned int > _phase_index
The phase indices that this Postprocessor is restricted to.
const Real _saturation_threshold
Saturation threshold - only fluid mass at saturations below this are calculated.
const MaterialProperty< Real > & _porosity
Porosity.
const MaterialProperty< std::vector< Real > > & _fluid_density
Phase density (kg/m^3)
const unsigned int _fluid_component
The fluid component index that this Postprocessor applies to.
MooseVariable *const _var
The variable for the corresponding PorousFlowMassTimeDerivative Kernel: this provides test functions...
const MaterialProperty< std::vector< std::vector< Real > > > & _mass_fraction
Mass fraction of each fluid component in each phase.

◆ computeQpIntegral()

Real PorousFlowFluidMass::computeQpIntegral ( )
overrideprotectedvirtual

Definition at line 155 of file PorousFlowFluidMass.C.

156 {
157  return 0.0;
158 }

Member Data Documentation

◆ _dictator

const PorousFlowDictator& PorousFlowFluidMass::_dictator
protected

PorousFlowDictator UserObject.

Definition at line 34 of file PorousFlowFluidMass.h.

Referenced by PorousFlowFluidMass().

◆ _fluid_component

const unsigned int PorousFlowFluidMass::_fluid_component
protected

The fluid component index that this Postprocessor applies to.

Definition at line 36 of file PorousFlowFluidMass.h.

Referenced by computeIntegral(), and PorousFlowFluidMass().

◆ _fluid_density

const MaterialProperty<std::vector<Real> >& PorousFlowFluidMass::_fluid_density
protected

Phase density (kg/m^3)

Definition at line 42 of file PorousFlowFluidMass.h.

Referenced by computeIntegral().

◆ _fluid_saturation

const MaterialProperty<std::vector<Real> >& PorousFlowFluidMass::_fluid_saturation
protected

Phase saturation (-)

Definition at line 44 of file PorousFlowFluidMass.h.

Referenced by computeIntegral().

◆ _mass_fraction

const MaterialProperty<std::vector<std::vector<Real> > >& PorousFlowFluidMass::_mass_fraction
protected

Mass fraction of each fluid component in each phase.

Definition at line 46 of file PorousFlowFluidMass.h.

Referenced by computeIntegral().

◆ _phase_index

std::vector<unsigned int> PorousFlowFluidMass::_phase_index
protected

The phase indices that this Postprocessor is restricted to.

Definition at line 38 of file PorousFlowFluidMass.h.

Referenced by computeIntegral(), and PorousFlowFluidMass().

◆ _porosity

const MaterialProperty<Real>& PorousFlowFluidMass::_porosity
protected

Porosity.

Definition at line 40 of file PorousFlowFluidMass.h.

Referenced by computeIntegral().

◆ _saturation_threshold

const Real PorousFlowFluidMass::_saturation_threshold
protected

Saturation threshold - only fluid mass at saturations below this are calculated.

Definition at line 48 of file PorousFlowFluidMass.h.

Referenced by computeIntegral(), and PorousFlowFluidMass().

◆ _var

MooseVariable* const PorousFlowFluidMass::_var
protected

The variable for the corresponding PorousFlowMassTimeDerivative Kernel: this provides test functions.

Definition at line 50 of file PorousFlowFluidMass.h.

Referenced by computeIntegral().


The documentation for this class was generated from the following files: