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
 Holds info on the PorousFlow variables. 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 23 of file PorousFlowFluidMass.h.

Constructor & Destructor Documentation

PorousFlowFluidMass::PorousFlowFluidMass ( const InputParameters &  parameters)

Check that the number of components entered is not greater than the total number of components

Check that the number of phases entered is not more than the total possible phases

Check that kernel_variable_number is OK

Also check that the phase indices entered are not greater than the number of phases to avoid a segfault. Note that the input parser takes care of negative inputs so we don't need to guard against them

Using saturation_threshold only makes sense for a specific phase_index

If _phase_index is empty, create vector of all phase numbers to calculate mass over all phases

Definition at line 47 of file PorousFlowFluidMass.C.

48  : ElementIntegralPostprocessor(parameters),
49 
50  _dictator(getUserObject<PorousFlowDictator>("PorousFlowDictator")),
51  _fluid_component(getParam<unsigned int>("fluid_component")),
52  _phase_index(getParam<std::vector<unsigned int>>("phase")),
53  _porosity(getMaterialProperty<Real>("PorousFlow_porosity_nodal")),
54  _fluid_density(getMaterialProperty<std::vector<Real>>("PorousFlow_fluid_phase_density_nodal")),
55  _fluid_saturation(getMaterialProperty<std::vector<Real>>("PorousFlow_saturation_nodal")),
57  getMaterialProperty<std::vector<std::vector<Real>>>("PorousFlow_mass_frac_nodal")),
58  _saturation_threshold(getParam<Real>("saturation_threshold")),
59  _var(getParam<unsigned>("kernel_variable_number") < _dictator.numVariables()
60  ? _dictator.getCoupledMooseVars()[getParam<unsigned>("kernel_variable_number")]
61  : nullptr)
62 {
63  const unsigned int num_phases = _dictator.numPhases();
64  const unsigned int num_components = _dictator.numComponents();
65 
67  if (_fluid_component >= num_components)
68  mooseError("The Dictator proclaims that the number of components in this simulation is ",
69  num_components,
70  " whereas you have used the Postprocessor PorousFlowFluidMass with component = ",
72  ". The Dictator does not take such mistakes lightly.");
73 
75  if (_phase_index.size() > num_phases)
76  mooseError("The Dictator decrees that the number of phases in this simulation is ",
77  num_phases,
78  " but you have entered ",
79  _phase_index.size(),
80  " phases in the Postprocessor ",
81  _name);
82 
84  if (getParam<unsigned>("kernel_variable_number") >= _dictator.numVariables())
85  mooseError(
86  "PorousFlowFluidMass: The dictator pronounces that the number of porous-flow variables is ",
88  ", however you have used kernel_variable_number = ",
89  getParam<unsigned>("kernel_variable_number"),
90  ". This is an error");
91 
97  if (!_phase_index.empty())
98  {
99  unsigned int max_phase_num = *std::max_element(_phase_index.begin(), _phase_index.end());
100  if (max_phase_num > num_phases - 1)
101  mooseError("The Dictator proclaims that the phase index ",
102  max_phase_num,
103  " in the Postprocessor ",
104  _name,
105  " is greater than the largest phase index possible, which is ",
106  num_phases - 1);
107  }
108 
110  if (_saturation_threshold < 1.0 && _phase_index.size() != 1)
111  mooseError("A single phase_index must be entered when prescribing a saturation_threshold in "
112  "the Postprocessor ",
113  _name);
114 
116  if (_phase_index.empty())
117  for (unsigned int i = 0; i < num_phases; ++i)
118  _phase_index.push_back(i);
119 }
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.
const PorousFlowDictator & _dictator
Holds info on the PorousFlow variables.
unsigned int numPhases() const
the number of fluid phases
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.
unsigned int numVariables() const
The number of PorousFlow variables.
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

Real PorousFlowFluidMass::computeIntegral ( )
overrideprotectedvirtual

The use of _test in the loops below mean that the integral is exactly the same as the one computed by the PorousFlowMassTimeDerivative Kernel. Because that Kernel is lumped, this Postprocessor also needs to be lumped. Hence the use of the "nodal" Material Properties

Definition at line 122 of file PorousFlowFluidMass.C.

123 {
124  Real sum = 0;
125 
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.
Real PorousFlowFluidMass::computeQpIntegral ( )
overrideprotectedvirtual

Definition at line 155 of file PorousFlowFluidMass.C.

156 {
157  return 0.0;
158 }

Member Data Documentation

const PorousFlowDictator& PorousFlowFluidMass::_dictator
protected

Holds info on the PorousFlow variables.

Definition at line 33 of file PorousFlowFluidMass.h.

Referenced by PorousFlowFluidMass().

const unsigned int PorousFlowFluidMass::_fluid_component
protected

The fluid component index that this Postprocessor applies to.

Definition at line 35 of file PorousFlowFluidMass.h.

Referenced by computeIntegral(), and PorousFlowFluidMass().

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

Phase density (kg/m^3)

Definition at line 41 of file PorousFlowFluidMass.h.

Referenced by computeIntegral().

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

Phase saturation (-)

Definition at line 43 of file PorousFlowFluidMass.h.

Referenced by computeIntegral().

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

Mass fraction of each fluid component in each phase.

Definition at line 45 of file PorousFlowFluidMass.h.

Referenced by computeIntegral().

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

The phase indices that this Postprocessor is restricted to.

Definition at line 37 of file PorousFlowFluidMass.h.

Referenced by computeIntegral(), and PorousFlowFluidMass().

const MaterialProperty<Real>& PorousFlowFluidMass::_porosity
protected

Porosity.

Definition at line 39 of file PorousFlowFluidMass.h.

Referenced by computeIntegral().

const Real PorousFlowFluidMass::_saturation_threshold
protected

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

Definition at line 47 of file PorousFlowFluidMass.h.

Referenced by computeIntegral(), and PorousFlowFluidMass().

MooseVariable* const PorousFlowFluidMass::_var
protected

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

Definition at line 49 of file PorousFlowFluidMass.h.

Referenced by computeIntegral().


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