www.mooseframework.org
PorousFlowPreDis.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
10 #include "PorousFlowPreDis.h"
11 
12 registerMooseObject("PorousFlowApp", PorousFlowPreDis);
13 
16 {
18  params.addRequiredParam<std::vector<Real>>(
19  "mineral_density",
20  "Density (kg(precipitate)/m^3(precipitate)) of each secondary species in the "
21  "aqueous precipitation-dissolution reaction system");
22  params.addRequiredParam<UserObjectName>(
23  "PorousFlowDictator", "The UserObject that holds the list of PorousFlow variable names.");
24  params.addRequiredParam<std::vector<Real>>("stoichiometry",
25  "A vector of stoichiometric coefficients for the "
26  "primary species that is the Variable of this Kernel: "
27  "one for each precipitation-dissolution reaction "
28  "(these are one columns of the 'reactions' matrix)");
29  params.addClassDescription("Precipitation-dissolution of chemical species");
30  return params;
31 }
32 
34  : TimeKernel(parameters),
35  _mineral_density(getParam<std::vector<Real>>("mineral_density")),
36  _dictator(getUserObject<PorousFlowDictator>("PorousFlowDictator")),
37  _aq_ph(_dictator.aqueousPhaseNumber()),
38  _porosity_old(getMaterialPropertyOld<Real>("PorousFlow_porosity_nodal")),
39  _saturation(getMaterialProperty<std::vector<Real>>("PorousFlow_saturation_nodal")),
40  _dsaturation_dvar(
41  getMaterialProperty<std::vector<std::vector<Real>>>("dPorousFlow_saturation_nodal_dvar")),
42  _reaction_rate(
43  getMaterialProperty<std::vector<Real>>("PorousFlow_mineral_reaction_rate_nodal")),
44  _dreaction_rate_dvar(getMaterialProperty<std::vector<std::vector<Real>>>(
45  "dPorousFlow_mineral_reaction_rate_nodal_dvar")),
46  _stoichiometry(getParam<std::vector<Real>>("stoichiometry"))
47 {
48  /* Not needed due to PorousFlow_mineral_reaction_rate already checking this condition
49  if (_dictator.numPhases() < 1)
50  mooseError("PorousFlowPreDis: The number of fluid phases must not be zero");
51  */
52 
54  paramError("mineral_density",
55  "The Dictator proclaims that the number of precipitation-dissolution secondary "
56  "species in this simulation is ",
58  " whereas you have provided ",
59  _mineral_density.size(),
60  ". The Dictator does not take such mistakes lightly");
61 
63  paramError("stoichiometry",
64  "The Dictator proclaims that the number of precipitation-dissolution secondary "
65  "species in this simulation is ",
67  " whereas you have provided ",
68  _stoichiometry.size(),
69  ". The Dictator does not take such mistakes lightly");
70 }
71 
72 Real
74 {
75  /*
76  *
77  * Note the use of the OLD value of porosity here.
78  * This strategy, which breaks the cyclic dependency between porosity
79  * and mineral concentration, is used in
80  * Kernel: PorousFlowPreDis
81  * Material: PorousFlowPorosity
82  * Material: PorousFlowAqueousPreDisChemistry
83  * Material: PorousFlowAqueousPreDisMineral
84  *
85  */
86  Real res = 0.0;
87  for (unsigned r = 0; r < _dictator.numAqueousKinetic(); ++r)
88  res += _stoichiometry[r] * _mineral_density[r] * _reaction_rate[_i][r];
89  return _test[_i][_qp] * res * _porosity_old[_i] * _saturation[_i][_aq_ph];
90 }
91 
92 Real
94 {
97  return 0.0;
99 }
100 
101 Real
103 {
106  return 0.0;
108 }
109 
110 Real
112 {
113  if (_i != _j)
114  return 0.0;
115 
116  Real res = 0.0;
117  Real dres = 0.0;
118  for (unsigned r = 0; r < _dictator.numAqueousKinetic(); ++r)
119  {
120  dres += _stoichiometry[r] * _mineral_density[r] * _dreaction_rate_dvar[_i][r][pvar];
121  res += _stoichiometry[r] * _mineral_density[r] * _reaction_rate[_i][r];
122  }
123 
124  return _test[_i][_qp] *
125  (dres * _saturation[_i][_aq_ph] + res * _dsaturation_dvar[_i][_aq_ph][pvar]) *
126  _porosity_old[_i];
127 }
const std::vector< Real > _stoichiometry
Stoichiometric coefficients.
const MaterialProperty< Real > & _porosity_old
Old value of porosity.
bool notPorousFlowVariable(unsigned int moose_var_num) const
Returns true if moose_var_num is not a porous flow variabe.
MooseVariable & _var
const MaterialProperty< std::vector< Real > > & _saturation
Saturation.
unsigned int number() const
const PorousFlowDictator & _dictator
PorousFlowDictator UserObject.
const std::vector< Real > _mineral_density
Density of the mineral species.
PorousFlowPreDis(const InputParameters &parameters)
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
virtual Real computeQpJacobian() override
Real computeQpJac(unsigned int pvar)
Derivative of residual with respect to PorousFlow variable number pvar This is used by both computeQp...
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
const unsigned int _aq_ph
Aqueous phase number.
const VariableTestValue & _test
const MaterialProperty< std::vector< Real > > & _reaction_rate
Reaction rate of the yielding the secondary species.
const MaterialProperty< std::vector< std::vector< Real > > > & _dsaturation_dvar
d(saturation)/d(PorousFlow var)
unsigned int _i
Kernel = sum (stoichiometry * density * porosity_old * saturation * reaction_rate) where the sum is o...
void paramError(const std::string &param, Args... args) const
unsigned int numAqueousKinetic() const
The number of aqueous kinetic secondary species.
registerMooseObject("PorousFlowApp", PorousFlowPreDis)
unsigned int _j
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 MaterialProperty< std::vector< std::vector< Real > > > & _dreaction_rate_dvar
d(reaction rate)/d(porflow variable)
void addClassDescription(const std::string &doc_string)
unsigned int porousFlowVariableNum(unsigned int moose_var_num) const
The PorousFlow variable number.
virtual Real computeQpResidual() override
static InputParameters validParams()
unsigned int _qp