https://mooseframework.inl.gov
FVPorousFlowMassTimeDerivative.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 
11 #include "PorousFlowDictator.h"
12 
14 
17 {
19  params.addRequiredParam<UserObjectName>("PorousFlowDictator",
20  "The PorousFlowDictator UserObject");
21  params.addParam<unsigned int>("fluid_component", 0, "The fluid component for this kernel");
22  params.addClassDescription("Derivative of fluid-component mass with respect to time");
23  return params;
24 }
25 
27  : FVTimeKernel(parameters),
28  _dictator(getUserObject<PorousFlowDictator>("PorousFlowDictator")),
29  _num_phases(_dictator.numPhases()),
30  _fluid_component(getParam<unsigned int>("fluid_component")),
31  _porosity(getADMaterialProperty<Real>("PorousFlow_porosity_qp")),
32  _porosity_old(getMaterialPropertyOld<Real>("PorousFlow_porosity_qp")),
33  _density(getADMaterialProperty<std::vector<Real>>("PorousFlow_fluid_phase_density_qp")),
34  _density_old(getMaterialPropertyOld<std::vector<Real>>("PorousFlow_fluid_phase_density_qp")),
35  _saturation(getADMaterialProperty<std::vector<Real>>("PorousFlow_saturation_qp")),
36  _saturation_old(getMaterialPropertyOld<std::vector<Real>>("PorousFlow_saturation_qp")),
37  _mass_fractions(
38  getADMaterialProperty<std::vector<std::vector<Real>>>("PorousFlow_mass_frac_qp")),
39  _mass_fractions_old(
40  getMaterialPropertyOld<std::vector<std::vector<Real>>>("PorousFlow_mass_frac_qp"))
41 {
43  paramError(
44  "fluid_component",
45  "The Dictator proclaims that the maximum fluid component index in this simulation is ",
47  " whereas you have used ",
49  ". Remember that indexing starts at 0. The Dictator does not take such mistakes lightly.");
50 }
51 
52 ADReal
54 {
55  ADReal mass = 0.0;
56  Real mass_old = 0.0;
57 
58  for (const auto p : make_range(_num_phases))
59  {
61  mass_old += _density_old[_qp][p] * _saturation_old[_qp][p] *
63  }
64 
65  return (_porosity[_qp] * mass - _porosity_old[_qp] * mass_old) / _dt;
66 }
const ADMaterialProperty< std::vector< Real > > & _saturation
Fluid phase saturation.
const MaterialProperty< std::vector< Real > > & _density_old
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
const ADMaterialProperty< std::vector< std::vector< Real > > > & _mass_fractions
Mass fraction of fluid components in fluid phases.
static InputParameters validParams()
const unsigned int _fluid_component
Index of the fluid component this kernel applies to.
unsigned int numComponents() const
The number of fluid components.
DualNumber< Real, DNDerivativeType, true > ADReal
void addRequiredParam(const std::string &name, const std::string &doc_string)
registerADMooseObject("PorousFlowApp", FVPorousFlowMassTimeDerivative)
const MaterialProperty< std::vector< std::vector< Real > > > & _mass_fractions_old
const ADMaterialProperty< Real > & _porosity
Porosity.
void paramError(const std::string &param, Args... args) const
const ADMaterialProperty< std::vector< Real > > & _density
Fluid density.
const MaterialProperty< std::vector< Real > > & _saturation_old
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...
const unsigned int _num_phases
Number of fluid phases present.
IntRange< T > make_range(T beg, T end)
const unsigned int _qp
void addClassDescription(const std::string &doc_string)
const MaterialProperty< Real > & _porosity_old
const PorousFlowDictator & _dictator
UserObject that holds information (number of phases, components, etc)
FVPorousFlowMassTimeDerivative(const InputParameters &parameters)
void ErrorVector unsigned int