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 
18 template <>
19 InputParameters
21 {
22  InputParameters params = validParams<TimeKernel>();
23  params.addRequiredParam<UserObjectName>(
24  "PorousFlowDictator", "The UserObject that holds the list of PorousFlow variable names.");
25  params.addRequiredCoupledVar(
26  "conc_var", "The variable that represents the concentration of desorped species");
27  params.addClassDescription("Desorped component mass derivative wrt time.");
28  return params;
29 }
30 
32  const InputParameters & parameters)
33  : TimeKernel(parameters),
34  _dictator(getUserObject<PorousFlowDictator>("PorousFlowDictator")),
35  _conc_var_number(coupled("conc_var")),
36  _conc(coupledValue("conc_var")),
37  _conc_old(coupledValueOld("conc_var")),
38  _porosity(getMaterialProperty<Real>("PorousFlow_porosity_qp")),
39  _porosity_old(getMaterialPropertyOld<Real>("PorousFlow_porosity_qp")),
40  _dporosity_dvar(getMaterialProperty<std::vector<Real>>("dPorousFlow_porosity_qp_dvar")),
41  _dporosity_dgradvar(
42  getMaterialProperty<std::vector<RealGradient>>("dPorousFlow_porosity_qp_dgradvar"))
43 {
44 }
45 
46 Real
48 {
49  Real c = (1.0 - _porosity[_qp]) * _conc[_qp];
50  Real c_old = (1.0 - _porosity_old[_qp]) * _conc_old[_qp];
51  return _test[_i][_qp] * (c - c_old) / _dt;
52 }
53 
54 Real
56 {
57  return computeQpJac(_var.number());
58 }
59 
60 Real
62 {
63  return computeQpJac(jvar);
64 }
65 
66 Real
68 {
69  Real deriv = 0.0;
70 
71  if (jvar == _conc_var_number)
72  deriv = (1.0 - _porosity[_qp]) * _phi[_j][_qp];
73 
75  return _test[_i][_qp] * deriv / _dt;
76  const unsigned int pvar = _dictator.porousFlowVariableNum(jvar);
77 
78  deriv -= _dporosity_dgradvar[_qp][pvar] * _grad_phi[_j][_qp] * _conc[_qp];
79  deriv -= _dporosity_dvar[_qp][pvar] * _phi[_j][_qp] * _conc[_qp];
80 
81  return _test[_i][_qp] * deriv / _dt;
82 }
PorousFlowDesorpedMassTimeDerivative::computeQpResidual
virtual Real computeQpResidual() override
Definition: PorousFlowDesorpedMassTimeDerivative.C:47
validParams< PorousFlowDesorpedMassTimeDerivative >
InputParameters validParams< PorousFlowDesorpedMassTimeDerivative >()
Definition: PorousFlowDesorpedMassTimeDerivative.C:20
PorousFlowDesorpedMassTimeDerivative::_conc_old
const VariableValue & _conc_old
Old value of the concentration variable.
Definition: PorousFlowDesorpedMassTimeDerivative.h:44
libMesh::RealGradient
VectorValue< Real > RealGradient
Definition: GrainForceAndTorqueInterface.h:17
registerMooseObject
registerMooseObject("PorousFlowApp", PorousFlowDesorpedMassTimeDerivative)
PorousFlowDictator::notPorousFlowVariable
bool notPorousFlowVariable(unsigned int moose_var_num) const
Returns true if moose_var_num is not a porous flow variabe.
Definition: PorousFlowDictator.C:161
PorousFlowDesorpedMassTimeDerivative::computeQpJac
Real computeQpJac(unsigned int jvar) const
Derivative of residual with respect to variable number jvar This is used by both computeQpJacobian an...
Definition: PorousFlowDesorpedMassTimeDerivative.C:67
PorousFlowDesorpedMassTimeDerivative::computeQpJacobian
virtual Real computeQpJacobian() override
Definition: PorousFlowDesorpedMassTimeDerivative.C:55
PorousFlowDictator::porousFlowVariableNum
unsigned int porousFlowVariableNum(unsigned int moose_var_num) const
The PorousFlow variable number.
Definition: PorousFlowDictator.C:135
PorousFlowDesorpedMassTimeDerivative::_porosity
const MaterialProperty< Real > & _porosity
Porosity at the qps.
Definition: PorousFlowDesorpedMassTimeDerivative.h:47
PorousFlowDesorpedMassTimeDerivative::_dictator
const PorousFlowDictator & _dictator
PorousFlowDictator UserObject.
Definition: PorousFlowDesorpedMassTimeDerivative.h:35
PorousFlowDesorpedMassTimeDerivative.h
PorousFlowDictator
This holds maps between the nonlinear variables used in a PorousFlow simulation and the variable numb...
Definition: PorousFlowDictator.h:71
PorousFlowDesorpedMassTimeDerivative
Kernel = (desorped_mass - desorped_mass_old)/dt It is NOT lumped to the nodes.
Definition: PorousFlowDesorpedMassTimeDerivative.h:24
PorousFlowDesorpedMassTimeDerivative::PorousFlowDesorpedMassTimeDerivative
PorousFlowDesorpedMassTimeDerivative(const InputParameters &parameters)
Definition: PorousFlowDesorpedMassTimeDerivative.C:31
PorousFlowDesorpedMassTimeDerivative::_conc_var_number
const unsigned int _conc_var_number
The MOOSE variable number of the concentration variable.
Definition: PorousFlowDesorpedMassTimeDerivative.h:38
PorousFlowDesorpedMassTimeDerivative::_dporosity_dvar
const MaterialProperty< std::vector< Real > > & _dporosity_dvar
d(porosity)/d(PorousFlow variable) - these derivatives will be wrt variables at the qps
Definition: PorousFlowDesorpedMassTimeDerivative.h:53
PorousFlowDesorpedMassTimeDerivative::_porosity_old
const MaterialProperty< Real > & _porosity_old
Old value of porosity.
Definition: PorousFlowDesorpedMassTimeDerivative.h:50
PorousFlowDesorpedMassTimeDerivative::_conc
const VariableValue & _conc
The concentration variable.
Definition: PorousFlowDesorpedMassTimeDerivative.h:41
PorousFlowDesorpedMassTimeDerivative::_dporosity_dgradvar
const MaterialProperty< std::vector< RealGradient > > & _dporosity_dgradvar
d(porosity)/d(grad PorousFlow variable) - these derivatives will be wrt grad(vars) at qps
Definition: PorousFlowDesorpedMassTimeDerivative.h:56
PorousFlowDesorpedMassTimeDerivative::computeQpOffDiagJacobian
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
Definition: PorousFlowDesorpedMassTimeDerivative.C:61