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
 PorousFlowDictator UserObject. More...
 
const bool _var_is_porflow_var
 Whether the Variable for this Kernel is a PorousFlow 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(PorousFlow variable) - these derivatives will be wrt variables at the nodes More...
 
const MaterialProperty< std::vector< RealGradient > > & _dporosity_dgradvar
 d(porosity)/d(grad PorousFlow 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(PorousFlow 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(PorousFlow 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(PorousFlow 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 27 of file PorousFlowMassTimeDerivative.h.

Constructor & Destructor Documentation

◆ PorousFlowMassTimeDerivative()

PorousFlowMassTimeDerivative::PorousFlowMassTimeDerivative ( const InputParameters &  parameters)

Definition at line 41 of file PorousFlowMassTimeDerivative.C.

42  : TimeKernel(parameters),
43  _fluid_component(getParam<unsigned int>("fluid_component")),
44  _dictator(getUserObject<PorousFlowDictator>("PorousFlowDictator")),
47  _strain_at_nearest_qp(getParam<bool>("strain_at_nearest_qp")),
48  _porosity(getMaterialProperty<Real>("PorousFlow_porosity_nodal")),
49  _porosity_old(getMaterialPropertyOld<Real>("PorousFlow_porosity_nodal")),
50  _dporosity_dvar(getMaterialProperty<std::vector<Real>>("dPorousFlow_porosity_nodal_dvar")),
52  getMaterialProperty<std::vector<RealGradient>>("dPorousFlow_porosity_nodal_dgradvar")),
54  ? &getMaterialProperty<unsigned int>("PorousFlow_nearestqp_nodal")
55  : nullptr),
56  _fluid_density(getMaterialProperty<std::vector<Real>>("PorousFlow_fluid_phase_density_nodal")),
58  getMaterialPropertyOld<std::vector<Real>>("PorousFlow_fluid_phase_density_nodal")),
59  _dfluid_density_dvar(getMaterialProperty<std::vector<std::vector<Real>>>(
60  "dPorousFlow_fluid_phase_density_nodal_dvar")),
61  _fluid_saturation_nodal(getMaterialProperty<std::vector<Real>>("PorousFlow_saturation_nodal")),
63  getMaterialPropertyOld<std::vector<Real>>("PorousFlow_saturation_nodal")),
65  getMaterialProperty<std::vector<std::vector<Real>>>("dPorousFlow_saturation_nodal_dvar")),
66  _mass_frac(getMaterialProperty<std::vector<std::vector<Real>>>("PorousFlow_mass_frac_nodal")),
68  getMaterialPropertyOld<std::vector<std::vector<Real>>>("PorousFlow_mass_frac_nodal")),
69  _dmass_frac_dvar(getMaterialProperty<std::vector<std::vector<std::vector<Real>>>>(
70  "dPorousFlow_mass_frac_nodal_dvar"))
71 {
73  paramError(
74  "fluid_component",
75  "The Dictator proclaims that the maximum fluid component index in this simulation is ",
77  " whereas you have used ",
79  ". Remember that indexing starts at 0. The Dictator does not take such mistakes lightly.");
80 }
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.
bool isPorousFlowVariable(unsigned int moose_var_num) const
Returns true if moose_var_num is a porous flow variable.
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 PorousFlow 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 PorousFlow 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
PorousFlowDictator UserObject.
unsigned int numPhases() const
The number of fluid phases.
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(PorousFlow variable)
const MaterialProperty< std::vector< std::vector< std::vector< Real > > > > & _dmass_frac_dvar
d(nodal mass fraction)/d(PorousFlow variable)
const MaterialProperty< std::vector< std::vector< Real > > > & _dfluid_density_dvar
d(nodal fluid density)/d(PorousFlow 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(PorousFlow 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

◆ computeQpJac()

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

Definition at line 117 of file PorousFlowMassTimeDerivative.C.

Referenced by computeQpJacobian(), and computeQpOffDiagJacobian().

118 {
119  const unsigned nearest_qp = (_strain_at_nearest_qp ? (*_nearest_qp)[_i] : _i);
120 
121  // porosity is dependent on variables that are lumped to the nodes,
122  // but it can depend on the gradient
123  // of variables, which are NOT lumped to the nodes, hence:
124  Real dmass = 0.0;
125  for (unsigned ph = 0; ph < _num_phases; ++ph)
126  dmass += _fluid_density[_i][ph] * _fluid_saturation_nodal[_i][ph] *
127  _mass_frac[_i][ph][_fluid_component] * _dporosity_dgradvar[_i][pvar] *
128  _grad_phi[_j][nearest_qp];
129 
130  if (_i != _j)
131  return _test[_i][_qp] * dmass / _dt;
132 
133  // As the fluid mass is lumped to the nodes, only non-zero terms are for _i==_j
134  for (unsigned ph = 0; ph < _num_phases; ++ph)
135  {
136  dmass += _dfluid_density_dvar[_i][ph][pvar] * _fluid_saturation_nodal[_i][ph] *
137  _mass_frac[_i][ph][_fluid_component] * _porosity[_i];
138  dmass += _fluid_density[_i][ph] * _dfluid_saturation_nodal_dvar[_i][ph][pvar] *
139  _mass_frac[_i][ph][_fluid_component] * _porosity[_i];
140  dmass += _fluid_density[_i][ph] * _fluid_saturation_nodal[_i][ph] *
141  _dmass_frac_dvar[_i][ph][_fluid_component][pvar] * _porosity[_i];
142  dmass += _fluid_density[_i][ph] * _fluid_saturation_nodal[_i][ph] *
143  _mass_frac[_i][ph][_fluid_component] * _dporosity_dvar[_i][pvar];
144  }
145  return _test[_i][_qp] * dmass / _dt;
146 }
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 PorousFlow 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(PorousFlow variable)
const MaterialProperty< std::vector< std::vector< std::vector< Real > > > > & _dmass_frac_dvar
d(nodal mass fraction)/d(PorousFlow variable)
const MaterialProperty< std::vector< std::vector< Real > > > & _dfluid_density_dvar
d(nodal fluid density)/d(PorousFlow 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(PorousFlow variable) - these derivatives will be wrt variables at the nodes ...

◆ computeQpJacobian()

Real PorousFlowMassTimeDerivative::computeQpJacobian ( )
overrideprotectedvirtual

Definition at line 99 of file PorousFlowMassTimeDerivative.C.

100 {
101  // If the variable is not a PorousFlow variable (very unusual), the diag Jacobian terms are 0
102  if (!_var_is_porflow_var)
103  return 0.0;
104  return computeQpJac(_dictator.porousFlowVariableNum(_var.number()));
105 }
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 PorousFlow variable according to the Dictator.
const PorousFlowDictator & _dictator
PorousFlowDictator UserObject.
unsigned int porousFlowVariableNum(unsigned int moose_var_num) const
The PorousFlow variable number.

◆ computeQpOffDiagJacobian()

Real PorousFlowMassTimeDerivative::computeQpOffDiagJacobian ( unsigned int  jvar)
overrideprotectedvirtual

Definition at line 108 of file PorousFlowMassTimeDerivative.C.

109 {
110  // If the variable is not a PorousFlow variable, the OffDiag Jacobian terms are 0
112  return 0.0;
114 }
bool notPorousFlowVariable(unsigned int moose_var_num) const
Returns true if moose_var_num is not a porous flow variabe.
Real computeQpJac(unsigned int pvar)
Derivative of residual with respect to PorousFlow variable number pvar This is used by both computeQp...
const PorousFlowDictator & _dictator
PorousFlowDictator UserObject.
unsigned int porousFlowVariableNum(unsigned int moose_var_num) const
The PorousFlow variable number.

◆ computeQpResidual()

Real PorousFlowMassTimeDerivative::computeQpResidual ( )
overrideprotectedvirtual

Definition at line 83 of file PorousFlowMassTimeDerivative.C.

84 {
85  Real mass = 0.0;
86  Real mass_old = 0.0;
87  for (unsigned ph = 0; ph < _num_phases; ++ph)
88  {
89  mass += _fluid_density[_i][ph] * _fluid_saturation_nodal[_i][ph] *
91  mass_old += _fluid_density_old[_i][ph] * _fluid_saturation_nodal_old[_i][ph] *
93  }
94 
95  return _test[_i][_qp] * (_porosity[_i] * mass - _porosity_old[_i] * mass_old) / _dt;
96 }
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

◆ _dfluid_density_dvar

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

d(nodal fluid density)/d(PorousFlow variable)

Definition at line 74 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpJac().

◆ _dfluid_saturation_nodal_dvar

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

d(nodal fluid saturation)/d(PorousFlow variable)

Definition at line 83 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpJac().

◆ _dictator

const PorousFlowDictator& PorousFlowMassTimeDerivative::_dictator
protected

◆ _dmass_frac_dvar

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

d(nodal mass fraction)/d(PorousFlow variable)

Definition at line 92 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpJac().

◆ _dporosity_dgradvar

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

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

Definition at line 62 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpJac().

◆ _dporosity_dvar

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

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

Definition at line 59 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpJac().

◆ _fluid_component

const unsigned int PorousFlowMassTimeDerivative::_fluid_component
protected

The fluid component index.

Definition at line 38 of file PorousFlowMassTimeDerivative.h.

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

◆ _fluid_density

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

Nodal fluid density.

Definition at line 68 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpJac(), and computeQpResidual().

◆ _fluid_density_old

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

Old value of nodal fluid density.

Definition at line 71 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpResidual().

◆ _fluid_saturation_nodal

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

Nodal fluid saturation.

Definition at line 77 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpJac(), and computeQpResidual().

◆ _fluid_saturation_nodal_old

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

Old value of fluid saturation.

Definition at line 80 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpResidual().

◆ _mass_frac

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

Nodal mass fraction.

Definition at line 86 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpJac(), and computeQpResidual().

◆ _mass_frac_old

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

Old value of nodal mass fraction.

Definition at line 89 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpResidual().

◆ _nearest_qp

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

The nearest qp to the node.

Definition at line 65 of file PorousFlowMassTimeDerivative.h.

◆ _num_phases

const unsigned int PorousFlowMassTimeDerivative::_num_phases
protected

Number of fluid phases.

Definition at line 47 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpJac(), and computeQpResidual().

◆ _porosity

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 53 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpJac(), and computeQpResidual().

◆ _porosity_old

const MaterialProperty<Real>& PorousFlowMassTimeDerivative::_porosity_old
protected

Old value of porosity.

Definition at line 56 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpResidual().

◆ _strain_at_nearest_qp

const bool PorousFlowMassTimeDerivative::_strain_at_nearest_qp
protected

Whether the porosity uses the volumetric strain at the closest quadpoint.

Definition at line 50 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpJac().

◆ _var_is_porflow_var

const bool PorousFlowMassTimeDerivative::_var_is_porflow_var
protected

Whether the Variable for this Kernel is a PorousFlow variable according to the Dictator.

Definition at line 44 of file PorousFlowMassTimeDerivative.h.

Referenced by computeQpJacobian().


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