www.mooseframework.org
PorousFlowDesorpedMassTimeDerivative.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 
11 
12 #include "MooseVariable.h"
13 
14 #include "libmesh/quadrature.h"
15 
17 
20 {
22  params.addRequiredParam<UserObjectName>(
23  "PorousFlowDictator", "The UserObject that holds the list of PorousFlow variable names.");
24  params.addRequiredCoupledVar(
25  "conc_var", "The variable that represents the concentration of desorped species");
26  params.addClassDescription("Desorped component mass derivative wrt time.");
27  return params;
28 }
29 
31  const InputParameters & parameters)
32  : TimeKernel(parameters),
33  _dictator(getUserObject<PorousFlowDictator>("PorousFlowDictator")),
34  _conc_var_number(coupled("conc_var")),
35  _conc(coupledValue("conc_var")),
36  _conc_old(coupledValueOld("conc_var")),
37  _porosity(getMaterialProperty<Real>("PorousFlow_porosity_qp")),
38  _porosity_old(getMaterialPropertyOld<Real>("PorousFlow_porosity_qp")),
39  _dporosity_dvar(getMaterialProperty<std::vector<Real>>("dPorousFlow_porosity_qp_dvar")),
40  _dporosity_dgradvar(
41  getMaterialProperty<std::vector<RealGradient>>("dPorousFlow_porosity_qp_dgradvar"))
42 {
43 }
44 
45 Real
47 {
48  Real c = (1.0 - _porosity[_qp]) * _conc[_qp];
49  Real c_old = (1.0 - _porosity_old[_qp]) * _conc_old[_qp];
50  return _test[_i][_qp] * (c - c_old) / _dt;
51 }
52 
53 Real
55 {
56  return computeQpJac(_var.number());
57 }
58 
59 Real
61 {
62  return computeQpJac(jvar);
63 }
64 
65 Real
67 {
68  Real deriv = 0.0;
69 
70  if (jvar == _conc_var_number)
71  deriv = (1.0 - _porosity[_qp]) * _phi[_j][_qp];
72 
74  return _test[_i][_qp] * deriv / _dt;
75  const unsigned int pvar = _dictator.porousFlowVariableNum(jvar);
76 
78  deriv -= _dporosity_dvar[_qp][pvar] * _phi[_j][_qp] * _conc[_qp];
79 
80  return _test[_i][_qp] * deriv / _dt;
81 }
const VariableValue & _conc_old
Old value of the concentration variable.
const MaterialProperty< std::vector< RealGradient > > & _dporosity_dgradvar
d(porosity)/d(grad PorousFlow variable) - these derivatives will be wrt grad(vars) at qps ...
bool notPorousFlowVariable(unsigned int moose_var_num) const
Returns true if moose_var_num is not a porous flow variabe.
Kernel = (desorped_mass - desorped_mass_old)/dt It is NOT lumped to the nodes.
MooseVariable & _var
unsigned int number() const
const VariablePhiGradient & _grad_phi
const MaterialProperty< Real > & _porosity_old
Old value of porosity.
const MaterialProperty< std::vector< Real > > & _dporosity_dvar
d(porosity)/d(PorousFlow variable) - these derivatives will be wrt variables at the qps ...
Real & _dt
Real computeQpJac(unsigned int jvar) const
Derivative of residual with respect to variable number jvar This is used by both computeQpJacobian an...
void addRequiredParam(const std::string &name, const std::string &doc_string)
const VariableTestValue & _test
Real deriv(unsigned n, unsigned alpha, unsigned beta, Real x)
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
unsigned int _i
const VariableValue & _conc
The concentration variable.
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
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 PorousFlowDictator & _dictator
PorousFlowDictator UserObject.
const unsigned int _conc_var_number
The MOOSE variable number of the concentration variable.
registerMooseObject("PorousFlowApp", PorousFlowDesorpedMassTimeDerivative)
const MaterialProperty< Real > & _porosity
Porosity at the qps.
void addClassDescription(const std::string &doc_string)
PorousFlowDesorpedMassTimeDerivative(const InputParameters &parameters)
unsigned int porousFlowVariableNum(unsigned int moose_var_num) const
The PorousFlow variable number.
const VariablePhiValue & _phi
static InputParameters validParams()
unsigned int _qp