https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PorousFlowDesorpedMassTimeDerivative.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
12#include "MooseVariable.h"
13
14#include "libmesh/quadrature.h"
15
18
19template <bool is_ad>
22{
24 params.set<MultiMooseEnum>("vector_tags") = "time";
25 params.set<MultiMooseEnum>("matrix_tags") = "system time";
26 params.addRequiredParam<UserObjectName>(
27 "PorousFlowDictator", "The UserObject that holds the list of PorousFlow variable names.");
29 "conc_var", "The variable that represents the concentration of desorped species");
30 params.addClassDescription("Desorped component mass derivative wrt time.");
31 return params;
32}
33
34template <bool is_ad>
36 const InputParameters & parameters)
37 : GenericKernel<is_ad>(parameters),
38 _dictator(this->template getUserObject<PorousFlowDictator>("PorousFlowDictator")),
39 _conc_var_number(this->coupled("conc_var")),
40 _conc(this->template coupledGenericValue<is_ad>("conc_var")),
41 _conc_old(this->coupledValueOld("conc_var")),
42 _porosity(this->template getGenericMaterialProperty<Real, is_ad>("PorousFlow_porosity_qp")),
43 _porosity_old(this->template getMaterialPropertyOld<Real>("PorousFlow_porosity_qp")),
44 _dporosity_dvar(is_ad ? nullptr
45 : &this->template getMaterialProperty<std::vector<Real>>(
46 "dPorousFlow_porosity_qp_dvar")),
47 _dporosity_dgradvar(is_ad ? nullptr
48 : &this->template getMaterialProperty<std::vector<RealGradient>>(
49 "dPorousFlow_porosity_qp_dgradvar"))
50{
51}
52
53template <bool is_ad>
56{
57 GenericReal<is_ad> c = (1.0 - _porosity[_qp]) * _conc[_qp];
58 Real c_old = (1.0 - _porosity_old[_qp]) * _conc_old[_qp];
59 return _test[_i][_qp] * (c - c_old) / this->_dt;
60}
61
62template <bool is_ad>
63Real
65{
66 return computeQpJac(_var.number());
67}
68
69template <bool is_ad>
70Real
72{
73 return computeQpJac(jvar);
74}
75
76template <bool is_ad>
77Real
79{
80 if constexpr (!is_ad)
81 {
82 Real deriv = 0.0;
83
84 if (jvar == _conc_var_number)
85 deriv = (1.0 - this->_porosity[this->_qp]) * this->_phi[this->_j][this->_qp];
86
87 if (_dictator.notPorousFlowVariable(jvar))
88 return this->_test[this->_i][this->_qp] * deriv / this->_dt;
89 const unsigned int pvar = _dictator.porousFlowVariableNum(jvar);
90
91 deriv -= (*_dporosity_dgradvar)[this->_qp][pvar] * this->_grad_phi[this->_j][this->_qp] *
92 this->_conc[this->_qp];
93 deriv -= (*_dporosity_dvar)[this->_qp][pvar] * this->_phi[this->_j][this->_qp] *
94 this->_conc[this->_qp];
95
96 return this->_test[this->_i][this->_qp] * deriv / this->_dt;
97 }
98 else
99 libmesh_ignore(jvar);
100 return 0.0;
101}
102
Moose::GenericType< Real, is_ad > GenericReal
registerMooseObject("PorousFlowApp", PorousFlowDesorpedMassTimeDerivative)
static InputParameters validParams()
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
Kernel = (desorped_mass - desorped_mass_old)/dt It is NOT lumped to the nodes.
virtual GenericReal< is_ad > computeQpResidual() override
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
PorousFlowDesorpedMassTimeDerivativeTempl(const InputParameters &parameters)
Real computeQpJac(unsigned int jvar)
Derivative of residual with respect to variable number jvar (non-AD path only)
This holds maps between the nonlinear variables used in a PorousFlow simulation and the variable numb...