https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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{
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
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}
DualNumber< Real, DNDerivativeType, true > ADReal
registerADMooseObject("PorousFlowApp", FVPorousFlowMassTimeDerivative)
const Real p
void ErrorVector unsigned int
const unsigned int _qp
const ADMaterialProperty< std::vector< Real > > & _density
Fluid density.
const ADMaterialProperty< Real > & _porosity
Porosity.
const ADMaterialProperty< std::vector< std::vector< Real > > > & _mass_fractions
Mass fraction of fluid components in fluid phases.
const MaterialProperty< std::vector< Real > > & _density_old
FVPorousFlowMassTimeDerivative(const InputParameters &parameters)
const ADMaterialProperty< std::vector< Real > > & _saturation
Fluid phase saturation.
const unsigned int _fluid_component
Index of the fluid component this kernel applies to.
const unsigned int _num_phases
Number of fluid phases present.
const PorousFlowDictator & _dictator
UserObject that holds information (number of phases, components, etc)
const MaterialProperty< std::vector< std::vector< Real > > > & _mass_fractions_old
const MaterialProperty< std::vector< Real > > & _saturation_old
const MaterialProperty< Real > & _porosity_old
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void paramError(const std::string &param, Args... args) const
This holds maps between the nonlinear variables used in a PorousFlow simulation and the variable numb...
unsigned int numComponents() const
The number of fluid components.