www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PorousFlowMassTimeDerivative Class Reference

Kernel = (mass_component - mass_component_old)/dt where mass_component = porosity*sum_phases(density_phase*saturation_phase*massfrac_phase^component) It is lumped to the nodes. More...

#include <PorousFlowMassTimeDerivative.h>

Inheritance diagram for PorousFlowMassTimeDerivative:
[legend]

Public Member Functions

 PorousFlowMassTimeDerivative (const InputParameters &parameters)
 

Protected Member Functions

virtual Real computeQpResidual () override
 
virtual Real computeQpJacobian () override
 
virtual Real computeQpOffDiagJacobian (unsigned int jvar) override
 
Real computeQpJac (unsigned int pvar)
 Derivative of residual with respect to PorousFlow variable number pvar This is used by both computeQpJacobian and computeQpOffDiagJacobian. More...
 

Protected Attributes

const unsigned int _fluid_component
 the fluid component index More...
 
const PorousFlowDictator_dictator
 holds info on the PorousFlow variables More...
 
const bool _var_is_porflow_var
 whether the Variable for this Kernel is a porous-flow variable according to the Dictator More...
 
const unsigned int _num_phases
 number of fluid phases More...
 
const bool _strain_at_nearest_qp
 whether the porosity uses the volumetric strain at the closest quadpoint More...
 
const MaterialProperty< Real > & _porosity
 porosity at the nodes, but it can depend on grad(variables) which are actually evaluated at the qps More...
 
const MaterialProperty< Real > & _porosity_old
 old value of porosity More...
 
const MaterialProperty< std::vector< Real > > & _dporosity_dvar
 d(porosity)/d(porous-flow variable) - these derivatives will be wrt variables at the nodes More...
 
const MaterialProperty< std::vector< RealGradient > > & _dporosity_dgradvar
 d(porosity)/d(grad porous-flow variable) - remember these derivatives will be wrt grad(vars) at qps More...
 
const MaterialProperty< unsigned int > *const _nearest_qp
 the nearest qp to the node More...
 
const MaterialProperty< std::vector< Real > > & _fluid_density
 nodal fluid density More...
 
const MaterialProperty< std::vector< Real > > & _fluid_density_old
 old value of nodal fluid density More...
 
const MaterialProperty< std::vector< std::vector< Real > > > & _dfluid_density_dvar
 d(nodal fluid density)/d(porous-flow variable) More...
 
const MaterialProperty< std::vector< Real > > & _fluid_saturation_nodal
 nodal fluid saturation More...
 
const MaterialProperty< std::vector< Real > > & _fluid_saturation_nodal_old
 old value of fluid saturation More...
 
const MaterialProperty< std::vector< std::vector< Real > > > & _dfluid_saturation_nodal_dvar
 d(nodal fluid saturation)/d(porous-flow variable) More...
 
const MaterialProperty< std::vector< std::vector< Real > > > & _mass_frac
 nodal mass fraction More...
 
const MaterialProperty< std::vector< std::vector< Real > > > & _mass_frac_old
 old value of nodal mass fraction More...
 
const MaterialProperty< std::vector< std::vector< std::vector< Real > > > > & _dmass_frac_dvar
 d(nodal mass fraction)/d(porous-flow variable) More...
 

Detailed Description

Kernel = (mass_component - mass_component_old)/dt where mass_component = porosity*sum_phases(density_phase*saturation_phase*massfrac_phase^component) It is lumped to the nodes.

Definition at line 26 of file PorousFlowMassTimeDerivative.h.

Constructor & Destructor Documentation

PorousFlowMassTimeDerivative::PorousFlowMassTimeDerivative ( const InputParameters &  parameters)

Definition at line 39 of file PorousFlowMassTimeDerivative.C.

40  : TimeKernel(parameters),
41  _fluid_component(getParam<unsigned int>("fluid_component")),
42  _dictator(getUserObject<PorousFlowDictator>("PorousFlowDictator")),
45  _strain_at_nearest_qp(getParam<bool>("strain_at_nearest_qp")),
46  _porosity(getMaterialProperty<Real>("PorousFlow_porosity_nodal")),
47  _porosity_old(getMaterialPropertyOld<Real>("PorousFlow_porosity_nodal")),
48  _dporosity_dvar(getMaterialProperty<std::vector<Real>>("dPorousFlow_porosity_nodal_dvar")),
50  getMaterialProperty<std::vector<RealGradient>>("dPorousFlow_porosity_nodal_dgradvar")),
52  ? &getMaterialProperty<unsigned int>("PorousFlow_nearestqp_nodal")
53  : nullptr),
54  _fluid_density(getMaterialProperty<std::vector<Real>>("PorousFlow_fluid_phase_density_nodal")),
56  getMaterialPropertyOld<std::vector<Real>>("PorousFlow_fluid_phase_density_nodal")),
57  _dfluid_density_dvar(getMaterialProperty<std::vector<std::vector<Real>>>(
58  "dPorousFlow_fluid_phase_density_nodal_dvar")),
59  _fluid_saturation_nodal(getMaterialProperty<std::vector<Real>>("PorousFlow_saturation_nodal")),
61  getMaterialPropertyOld<std::vector<Real>>("PorousFlow_saturation_nodal")),
63  getMaterialProperty<std::vector<std::vector<Real>>>("dPorousFlow_saturation_nodal_dvar")),
64  _mass_frac(getMaterialProperty<std::vector<std::vector<Real>>>("PorousFlow_mass_frac_nodal")),
66  getMaterialPropertyOld<std::vector<std::vector<Real>>>("PorousFlow_mass_frac_nodal")),
67  _dmass_frac_dvar(getMaterialProperty<std::vector<std::vector<std::vector<Real>>>>(
68  "dPorousFlow_mass_frac_nodal_dvar"))
69 {
71  mooseError(
72  "The Dictator proclaims that the number of components in this simulation is ",
74  " whereas you have used the Kernel PorousFlowComponetMassTimeDerivative with component = ",
76  ". The Dictator does not take such mistakes lightly");
77 }
const bool _strain_at_nearest_qp
whether the porosity uses the volumetric strain at the closest quadpoint
const MaterialProperty< Real > & _porosity_old
old value of porosity
const MaterialProperty< std::vector< Real > > & _fluid_density_old
old value of nodal fluid density
const MaterialProperty< Real > & _porosity
porosity at the nodes, but it can depend on grad(variables) which are actually evaluated at the qps ...
unsigned int numComponents() const
the number of fluid components
const MaterialProperty< std::vector< Real > > & _fluid_density
nodal fluid density
const MaterialProperty< std::vector< Real > > & _fluid_saturation_nodal
nodal fluid saturation
const MaterialProperty< std::vector< RealGradient > > & _dporosity_dgradvar
d(porosity)/d(grad porous-flow variable) - remember these derivatives will be wrt grad(vars) at qps ...
const bool _var_is_porflow_var
whether the Variable for this Kernel is a porous-flow variable according to the Dictator ...
const MaterialProperty< std::vector< Real > > & _fluid_saturation_nodal_old
old value of fluid saturation
const MaterialProperty< std::vector< std::vector< Real > > > & _mass_frac
nodal mass fraction
const PorousFlowDictator & _dictator
holds info on the PorousFlow variables
const MaterialProperty< std::vector< std::vector< Real > > > & _mass_frac_old
old value of nodal mass fraction
const MaterialProperty< std::vector< std::vector< Real > > > & _dfluid_saturation_nodal_dvar
d(nodal fluid saturation)/d(porous-flow variable)
const MaterialProperty< std::vector< std::vector< std::vector< Real > > > > & _dmass_frac_dvar
d(nodal mass fraction)/d(porous-flow variable)
const MaterialProperty< std::vector< std::vector< Real > > > & _dfluid_density_dvar
d(nodal fluid density)/d(porous-flow variable)
unsigned int numPhases() const
the number of fluid phases
const unsigned int _num_phases
number of fluid phases
bool isPorousFlowVariable(unsigned int moose_var_num) const
returns true if moose_var_num is a porous flow variable
const unsigned int _fluid_component
the fluid component index
const MaterialProperty< std::vector< Real > > & _dporosity_dvar
d(porosity)/d(porous-flow variable) - these derivatives will be wrt variables at the nodes ...
const MaterialProperty< unsigned int > *const _nearest_qp
the nearest qp to the node

Member Function Documentation

Real PorousFlowMassTimeDerivative::computeQpJac ( unsigned int  pvar)
protected

Derivative of residual with respect to PorousFlow variable number pvar This is used by both computeQpJacobian and computeQpOffDiagJacobian.

Parameters
pvartake the derivative of the residual wrt this PorousFlow variable

As the fluid mass is lumped to the nodes, only non-zero terms are for _i==_j

Definition at line 114 of file PorousFlowMassTimeDerivative.C.

Referenced by computeQpJacobian(), and computeQpOffDiagJacobian().

115 {
116  const unsigned nearest_qp = (_strain_at_nearest_qp ? (*_nearest_qp)[_i] : _i);
117 
118  // porosity is dependent on variables that are lumped to the nodes,
119  // but it can depend on the gradient
120  // of variables, which are NOT lumped to the nodes, hence:
121  Real dmass = 0.0;
122  for (unsigned ph = 0; ph < _num_phases; ++ph)
123  dmass += _fluid_density[_i][ph] * _fluid_saturation_nodal[_i][ph] *
124  _mass_frac[_i][ph][_fluid_component] * _dporosity_dgradvar[_i][pvar] *
125  _grad_phi[_j][nearest_qp];
126 
127  if (_i != _j)
128  return _test[_i][_qp] * dmass / _dt;
129 
131  for (unsigned ph = 0; ph < _num_phases; ++ph)
132  {
133  dmass += _dfluid_density_dvar[_i][ph][pvar] * _fluid_saturation_nodal[_i][ph] *
134  _mass_frac[_i][ph][_fluid_component] * _porosity[_i];
135  dmass += _fluid_density[_i][ph] * _dfluid_saturation_nodal_dvar[_i][ph][pvar] *
136  _mass_frac[_i][ph][_fluid_component] * _porosity[_i];
137  dmass += _fluid_density[_i][ph] * _fluid_saturation_nodal[_i][ph] *
138  _dmass_frac_dvar[_i][ph][_fluid_component][pvar] * _porosity[_i];
139  dmass += _fluid_density[_i][ph] * _fluid_saturation_nodal[_i][ph] *
140  _mass_frac[_i][ph][_fluid_component] * _dporosity_dvar[_i][pvar];
141  }
142  return _test[_i][_qp] * dmass / _dt;
143 }
const bool _strain_at_nearest_qp
whether the porosity uses the volumetric strain at the closest quadpoint
const MaterialProperty< Real > & _porosity
porosity at the nodes, but it can depend on grad(variables) which are actually evaluated at the qps ...
const MaterialProperty< std::vector< Real > > & _fluid_density
nodal fluid density
const MaterialProperty< std::vector< Real > > & _fluid_saturation_nodal
nodal fluid saturation
const MaterialProperty< std::vector< RealGradient > > & _dporosity_dgradvar
d(porosity)/d(grad porous-flow variable) - remember these derivatives will be wrt grad(vars) at qps ...
const MaterialProperty< std::vector< std::vector< Real > > > & _mass_frac
nodal mass fraction
const MaterialProperty< std::vector< std::vector< Real > > > & _dfluid_saturation_nodal_dvar
d(nodal fluid saturation)/d(porous-flow variable)
const MaterialProperty< std::vector< std::vector< std::vector< Real > > > > & _dmass_frac_dvar
d(nodal mass fraction)/d(porous-flow variable)
const MaterialProperty< std::vector< std::vector< Real > > > & _dfluid_density_dvar
d(nodal fluid density)/d(porous-flow variable)
const unsigned int _num_phases
number of fluid phases
const unsigned int _fluid_component
the fluid component index
const MaterialProperty< std::vector< Real > > & _dporosity_dvar
d(porosity)/d(porous-flow variable) - these derivatives will be wrt variables at the nodes ...
Real PorousFlowMassTimeDerivative::computeQpJacobian ( )
overrideprotectedvirtual

If the variable is not a PorousFlow variable (very unusual), the diag Jacobian terms are 0

Definition at line 96 of file PorousFlowMassTimeDerivative.C.

97 {
100  return 0.0;
101  return computeQpJac(_dictator.porousFlowVariableNum(_var.number()));
102 }
Real computeQpJac(unsigned int pvar)
Derivative of residual with respect to PorousFlow variable number pvar This is used by both computeQp...
const bool _var_is_porflow_var
whether the Variable for this Kernel is a porous-flow variable according to the Dictator ...
const PorousFlowDictator & _dictator
holds info on the PorousFlow variables
unsigned int porousFlowVariableNum(unsigned int moose_var_num) const
the PorousFlow variable number
Real PorousFlowMassTimeDerivative::computeQpOffDiagJacobian ( unsigned int  jvar)
overrideprotectedvirtual

If the variable is not a PorousFlow variable, the OffDiag Jacobian terms are 0

Definition at line 105 of file PorousFlowMassTimeDerivative.C.

106 {
109  return 0.0;
111 }
Real computeQpJac(unsigned int pvar)
Derivative of residual with respect to PorousFlow variable number pvar This is used by both computeQp...
const PorousFlowDictator & _dictator
holds info on the PorousFlow variables
bool notPorousFlowVariable(unsigned int moose_var_num) const
returns true if moose_var_num is not a porous flow variabe
unsigned int porousFlowVariableNum(unsigned int moose_var_num) const
the PorousFlow variable number
Real PorousFlowMassTimeDerivative::computeQpResidual ( )
overrideprotectedvirtual

Definition at line 80 of file PorousFlowMassTimeDerivative.C.

81 {
82  Real mass = 0.0;
83  Real mass_old = 0.0;
84  for (unsigned ph = 0; ph < _num_phases; ++ph)
85  {
86  mass += _fluid_density[_i][ph] * _fluid_saturation_nodal[_i][ph] *
88  mass_old += _fluid_density_old[_i][ph] * _fluid_saturation_nodal_old[_i][ph] *
90  }
91 
92  return _test[_i][_qp] * (_porosity[_i] * mass - _porosity_old[_i] * mass_old) / _dt;
93 }
const MaterialProperty< Real > & _porosity_old
old value of porosity
const MaterialProperty< std::vector< Real > > & _fluid_density_old
old value of nodal fluid density
const MaterialProperty< Real > & _porosity
porosity at the nodes, but it can depend on grad(variables) which are actually evaluated at the qps ...
const MaterialProperty< std::vector< Real > > & _fluid_density
nodal fluid density
const MaterialProperty< std::vector< Real > > & _fluid_saturation_nodal
nodal fluid saturation
const MaterialProperty< std::vector< Real > > & _fluid_saturation_nodal_old
old value of fluid saturation
const MaterialProperty< std::vector< std::vector< Real > > > & _mass_frac
nodal mass fraction
const MaterialProperty< std::vector< std::vector< Real > > > & _mass_frac_old
old value of nodal mass fraction
const unsigned int _num_phases
number of fluid phases
const unsigned int _fluid_component
the fluid component index

Member Data Documentation

const MaterialProperty<std::vector<std::vector<Real> > >& PorousFlowMassTimeDerivative::_dfluid_density_dvar
protected

d(nodal fluid density)/d(porous-flow variable)

Definition at line 73 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpJac().

const MaterialProperty<std::vector<std::vector<Real> > >& PorousFlowMassTimeDerivative::_dfluid_saturation_nodal_dvar
protected

d(nodal fluid saturation)/d(porous-flow variable)

Definition at line 82 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpJac().

const PorousFlowDictator& PorousFlowMassTimeDerivative::_dictator
protected

holds info on the PorousFlow variables

Definition at line 40 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpJacobian(), computeQpOffDiagJacobian(), and PorousFlowMassTimeDerivative().

const MaterialProperty<std::vector<std::vector<std::vector<Real> > > >& PorousFlowMassTimeDerivative::_dmass_frac_dvar
protected

d(nodal mass fraction)/d(porous-flow variable)

Definition at line 91 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpJac().

const MaterialProperty<std::vector<RealGradient> >& PorousFlowMassTimeDerivative::_dporosity_dgradvar
protected

d(porosity)/d(grad porous-flow variable) - remember these derivatives will be wrt grad(vars) at qps

Definition at line 61 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpJac().

const MaterialProperty<std::vector<Real> >& PorousFlowMassTimeDerivative::_dporosity_dvar
protected

d(porosity)/d(porous-flow variable) - these derivatives will be wrt variables at the nodes

Definition at line 58 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpJac().

const unsigned int PorousFlowMassTimeDerivative::_fluid_component
protected

the fluid component index

Definition at line 37 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpJac(), computeQpResidual(), and PorousFlowMassTimeDerivative().

const MaterialProperty<std::vector<Real> >& PorousFlowMassTimeDerivative::_fluid_density
protected

nodal fluid density

Definition at line 67 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpJac(), and computeQpResidual().

const MaterialProperty<std::vector<Real> >& PorousFlowMassTimeDerivative::_fluid_density_old
protected

old value of nodal fluid density

Definition at line 70 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpResidual().

const MaterialProperty<std::vector<Real> >& PorousFlowMassTimeDerivative::_fluid_saturation_nodal
protected

nodal fluid saturation

Definition at line 76 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpJac(), and computeQpResidual().

const MaterialProperty<std::vector<Real> >& PorousFlowMassTimeDerivative::_fluid_saturation_nodal_old
protected

old value of fluid saturation

Definition at line 79 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpResidual().

const MaterialProperty<std::vector<std::vector<Real> > >& PorousFlowMassTimeDerivative::_mass_frac
protected

nodal mass fraction

Definition at line 85 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpJac(), and computeQpResidual().

const MaterialProperty<std::vector<std::vector<Real> > >& PorousFlowMassTimeDerivative::_mass_frac_old
protected

old value of nodal mass fraction

Definition at line 88 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpResidual().

const MaterialProperty<unsigned int>* const PorousFlowMassTimeDerivative::_nearest_qp
protected

the nearest qp to the node

Definition at line 64 of file PorousFlowMassTimeDerivative.h.

const unsigned int PorousFlowMassTimeDerivative::_num_phases
protected

number of fluid phases

Definition at line 46 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpJac(), and computeQpResidual().

const MaterialProperty<Real>& PorousFlowMassTimeDerivative::_porosity
protected

porosity at the nodes, but it can depend on grad(variables) which are actually evaluated at the qps

Definition at line 52 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpJac(), and computeQpResidual().

const MaterialProperty<Real>& PorousFlowMassTimeDerivative::_porosity_old
protected

old value of porosity

Definition at line 55 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpResidual().

const bool PorousFlowMassTimeDerivative::_strain_at_nearest_qp
protected

whether the porosity uses the volumetric strain at the closest quadpoint

Definition at line 49 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpJac().

const bool PorousFlowMassTimeDerivative::_var_is_porflow_var
protected

whether the Variable for this Kernel is a porous-flow variable according to the Dictator

Definition at line 43 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpJacobian().


The documentation for this class was generated from the following files: