Darcy advective flux. More...
#include <PorousFlowDarcyBase.h>
Public Member Functions | |
PorousFlowDarcyBase (const InputParameters ¶meters) | |
Protected Types | |
enum | JacRes { JacRes::CALCULATE_RESIDUAL = 0, JacRes::CALCULATE_JACOBIAN = 1 } |
enum | FallbackEnum { FallbackEnum::QUICK, FallbackEnum::HARMONIC } |
If full upwinding is failing due to nodes swapping between upwind and downwind in successive nonlinear iterations (within one timestep and element) a fallback scheme is used instead. More... | |
Protected Member Functions | |
virtual void | timestepSetup () override |
virtual Real | computeQpResidual () override |
virtual void | computeResidual () override |
virtual void | computeJacobian () override |
virtual void | computeOffDiagJacobian (MooseVariableFEBase &jvar) override |
virtual Real | darcyQp (unsigned int ph) const |
The Darcy part of the flux (this is the non-upwinded part) More... | |
virtual Real | darcyQpJacobian (unsigned int jvar, unsigned int ph) const |
Jacobian of the Darcy part of the flux. More... | |
virtual Real | mobility (unsigned nodenum, unsigned phase) const |
The mobility of the fluid. More... | |
virtual Real | dmobility (unsigned nodenum, unsigned phase, unsigned pvar) const |
The derivative of mobility with respect to PorousFlow variable pvar. More... | |
void | computeResidualAndJacobian (JacRes res_or_jac, unsigned int jvar) |
Computation of the residual and Jacobian. More... | |
void | fullyUpwind (JacRes res_or_jac, unsigned int ph, unsigned int pvar) |
Calculate the residual or Jacobian using full upwinding. More... | |
void | quickUpwind (JacRes res_or_jac, unsigned int ph, unsigned int pvar) |
Calculate the residual or Jacobian using the nodal mobilities, but without conserving fluid mass. More... | |
void | harmonicMean (JacRes res_or_jac, unsigned int ph, unsigned int pvar) |
Calculate the residual or Jacobian by using the harmonic mean of the nodal mobilities for the entire element. More... | |
Protected Attributes | |
const MaterialProperty< RealTensorValue > & | _permeability |
Permeability of porous material. More... | |
const MaterialProperty< std::vector< RealTensorValue > > & | _dpermeability_dvar |
d(permeabiity)/d(PorousFlow variable) More... | |
const MaterialProperty< std::vector< std::vector< RealTensorValue > > > & | _dpermeability_dgradvar |
d(permeabiity)/d(grad(PorousFlow variable)) More... | |
const MaterialProperty< std::vector< Real > > & | _fluid_density_node |
Fluid density for each phase (at the node) More... | |
const MaterialProperty< std::vector< std::vector< Real > > > & | _dfluid_density_node_dvar |
Derivative of the fluid density for each phase wrt PorousFlow variables (at the node) More... | |
const MaterialProperty< std::vector< Real > > & | _fluid_density_qp |
Fluid density for each phase (at the qp) More... | |
const MaterialProperty< std::vector< std::vector< Real > > > & | _dfluid_density_qp_dvar |
Derivative of the fluid density for each phase wrt PorousFlow variables (at the qp) More... | |
const MaterialProperty< std::vector< Real > > & | _fluid_viscosity |
Viscosity of each component in each phase. More... | |
const MaterialProperty< std::vector< std::vector< Real > > > & | _dfluid_viscosity_dvar |
Derivative of the fluid viscosity for each phase wrt PorousFlow variables. More... | |
const MaterialProperty< std::vector< Real > > & | _pp |
Nodal pore pressure in each phase. More... | |
const MaterialProperty< std::vector< RealGradient > > & | _grad_p |
Gradient of the pore pressure in each phase. More... | |
const MaterialProperty< std::vector< std::vector< Real > > > & | _dgrad_p_dgrad_var |
Derivative of Grad porepressure in each phase wrt grad(PorousFlow variables) More... | |
const MaterialProperty< std::vector< std::vector< RealGradient > > > & | _dgrad_p_dvar |
Derivative of Grad porepressure in each phase wrt PorousFlow variables. More... | |
const PorousFlowDictator & | _dictator |
PorousFlowDictator UserObject. More... | |
const unsigned int | _num_phases |
The number of fluid phases. More... | |
const RealVectorValue | _gravity |
Gravity. Defaults to 9.81 m/s^2. More... | |
const bool | _perm_derivs |
Flag to check whether permeabiity derivatives are non-zero. More... | |
const unsigned | _full_upwind_threshold |
If the number of upwind-downwind swaps is less than this amount then full upwinding is used. More... | |
enum PorousFlowDarcyBase::FallbackEnum | _fallback_scheme |
std::vector< std::vector< Real > > | _proto_flux |
The Darcy flux. More... | |
std::vector< std::vector< std::vector< Real > > > | _jacobian |
Derivative of _proto_flux with respect to nodal variables. More... | |
std::unordered_map< unsigned, std::vector< std::vector< unsigned > > > | _num_upwinds |
Number of nonlinear iterations (in this timestep and this element) that a node is an upwind node for a given fluid phase. More... | |
std::unordered_map< unsigned, std::vector< std::vector< unsigned > > > | _num_downwinds |
Number of nonlinear iterations (in this timestep and this element) that a node is an downwind node for a given fluid phase. More... | |
Darcy advective flux.
A fully-updwinded version is implemented, where the mobility of the upstream nodes is used. Alternately, after some number of upwind-downwind swaps, another type of handling of the mobility may be employed (see fallback_scheme, below)
Definition at line 28 of file PorousFlowDarcyBase.h.
|
strongprotected |
If full upwinding is failing due to nodes swapping between upwind and downwind in successive nonlinear iterations (within one timestep and element) a fallback scheme is used instead.
QUICK: use the nodal mobilities, as in full upwinding, but do not attempt to conserve fluid mass. HARMONIC: assign the harmonic mean of the mobilities to the entire element.
Enumerator | |
---|---|
QUICK | |
HARMONIC |
Definition at line 152 of file PorousFlowDarcyBase.h.
|
strongprotected |
Enumerator | |
---|---|
CALCULATE_RESIDUAL | |
CALCULATE_JACOBIAN |
Definition at line 63 of file PorousFlowDarcyBase.h.
PorousFlowDarcyBase::PorousFlowDarcyBase | ( | const InputParameters & | parameters | ) |
Definition at line 45 of file PorousFlowDarcyBase.C.
|
overrideprotectedvirtual |
Definition at line 141 of file PorousFlowDarcyBase.C.
|
overrideprotectedvirtual |
Definition at line 147 of file PorousFlowDarcyBase.C.
|
overrideprotectedvirtual |
Definition at line 128 of file PorousFlowDarcyBase.C.
|
overrideprotectedvirtual |
Definition at line 135 of file PorousFlowDarcyBase.C.
|
protected |
Computation of the residual and Jacobian.
If res_or_jac=CALCULATE_JACOBIAN then the residual gets calculated anyway (becuase we have to know which nodes are upwind and which are downwind) except we don't actually need to store the residual in _assembly.residualBlock and we don't need to save in save_in.
If res_or_jac=CALCULATE_RESIDUAL then we don't have to do all the Jacobian calculations.
res_or_jac | Whether to calculate the residual or the jacobian. |
jvar | PorousFlow variable to take derivatives wrt to |
Definition at line 153 of file PorousFlowDarcyBase.C.
Referenced by computeJacobian(), computeOffDiagJacobian(), and computeResidual().
|
protectedvirtual |
The Darcy part of the flux (this is the non-upwinded part)
Definition at line 95 of file PorousFlowDarcyBase.C.
Referenced by computeResidualAndJacobian().
|
protectedvirtual |
Jacobian of the Darcy part of the flux.
Definition at line 102 of file PorousFlowDarcyBase.C.
Referenced by computeResidualAndJacobian().
|
protectedvirtual |
The derivative of mobility with respect to PorousFlow variable pvar.
nodenum | The node-number to evaluate the mobility for |
phase | the fluid phase number |
pvar | the PorousFlow variable pvar |
Reimplemented in PorousFlowAdvectiveFlux, and PorousFlowHeatAdvection.
Definition at line 517 of file PorousFlowDarcyBase.C.
Referenced by fullyUpwind(), harmonicMean(), and quickUpwind().
|
protected |
Calculate the residual or Jacobian using full upwinding.
res_or_jac | whether to compute the residual or jacobian |
ph | fluid phase number |
pvar | differentiate wrt to this PorousFlow variable (when computing the jacobian) |
Perform the full upwinding by multiplying the residuals at the upstream nodes by their mobilities. Mobility is different for each phase, and in each situation: mobility = density / viscosity for single-component Darcy flow mobility = mass_fraction * density * relative_perm / viscosity for multi-component, multiphase flow mobility = enthalpy * density * relative_perm / viscosity for heat convection
The residual for the kernel is the sum over Darcy fluxes for each phase. The Darcy flux for a particular phase is R_i = int{mobility*flux_no_mob} = int{mobility*grad(pot)*permeability*grad(test_i)} for node i. where int is the integral over the element. However, in fully-upwind, the first step is to take the mobility outside the integral, which was done in the _proto_flux calculation above.
NOTE: Physically _proto_flux[i][ph] is a measure of fluid of phase ph flowing out of node i. If we had left in mobility, it would be exactly the component mass flux flowing out of node i.
This leads to the definition of upwinding:
If _proto_flux(i)[ph] is positive then we use mobility_i. That is we use the upwind value of mobility.
The final subtle thing is we must also conserve fluid mass: the total component mass flowing out of node i must be the sum of the masses flowing into the other nodes.
note the -= means the result is positive
Definition at line 307 of file PorousFlowDarcyBase.C.
Referenced by computeResidualAndJacobian().
|
protected |
Calculate the residual or Jacobian by using the harmonic mean of the nodal mobilities for the entire element.
res_or_jac | whether to compute the residual or jacobian |
ph | fluid phase number |
pvar | differentiate wrt to this PorousFlow variable (when computing the jacobian) |
Definition at line 457 of file PorousFlowDarcyBase.C.
Referenced by computeResidualAndJacobian().
|
protectedvirtual |
The mobility of the fluid.
For multi-component Darcy flow this is mass_fraction * fluid_density * relative_permeability / fluid_viscosity
nodenum | The node-number to evaluate the mobility for |
phase | the fluid phase number |
Reimplemented in PorousFlowAdvectiveFlux, and PorousFlowHeatAdvection.
Definition at line 511 of file PorousFlowDarcyBase.C.
Referenced by fullyUpwind(), harmonicMean(), and quickUpwind().
|
protected |
Calculate the residual or Jacobian using the nodal mobilities, but without conserving fluid mass.
res_or_jac | whether to compute the residual or jacobian |
ph | fluid phase number |
pvar | differentiate wrt to this PorousFlow variable (when computing the jacobian) |
Definition at line 420 of file PorousFlowDarcyBase.C.
Referenced by computeResidualAndJacobian().
|
overrideprotectedvirtual |
Definition at line 87 of file PorousFlowDarcyBase.C.
|
protected |
Derivative of the fluid density for each phase wrt PorousFlow variables (at the node)
Definition at line 99 of file PorousFlowDarcyBase.h.
Referenced by PorousFlowAdvectiveFlux::dmobility(), PorousFlowHeatAdvection::dmobility(), and dmobility().
|
protected |
Derivative of the fluid density for each phase wrt PorousFlow variables (at the qp)
Definition at line 105 of file PorousFlowDarcyBase.h.
Referenced by darcyQpJacobian().
|
protected |
Derivative of the fluid viscosity for each phase wrt PorousFlow variables.
Definition at line 111 of file PorousFlowDarcyBase.h.
Referenced by PorousFlowAdvectiveFlux::dmobility(), PorousFlowHeatAdvection::dmobility(), and dmobility().
|
protected |
Derivative of Grad porepressure in each phase wrt grad(PorousFlow variables)
Definition at line 120 of file PorousFlowDarcyBase.h.
Referenced by darcyQpJacobian().
|
protected |
Derivative of Grad porepressure in each phase wrt PorousFlow variables.
Definition at line 123 of file PorousFlowDarcyBase.h.
Referenced by darcyQpJacobian().
|
protected |
PorousFlowDictator UserObject.
Definition at line 126 of file PorousFlowDarcyBase.h.
Referenced by computeResidualAndJacobian(), and darcyQpJacobian().
|
protected |
d(permeabiity)/d(grad(PorousFlow variable))
Definition at line 93 of file PorousFlowDarcyBase.h.
Referenced by darcyQpJacobian().
|
protected |
d(permeabiity)/d(PorousFlow variable)
Definition at line 90 of file PorousFlowDarcyBase.h.
Referenced by darcyQpJacobian().
|
protected |
Referenced by computeResidualAndJacobian().
|
protected |
Fluid density for each phase (at the node)
Definition at line 96 of file PorousFlowDarcyBase.h.
Referenced by PorousFlowAdvectiveFlux::dmobility(), PorousFlowHeatAdvection::dmobility(), dmobility(), PorousFlowAdvectiveFlux::mobility(), PorousFlowHeatAdvection::mobility(), and mobility().
|
protected |
Fluid density for each phase (at the qp)
Definition at line 102 of file PorousFlowDarcyBase.h.
Referenced by darcyQp(), and darcyQpJacobian().
|
protected |
Viscosity of each component in each phase.
Definition at line 108 of file PorousFlowDarcyBase.h.
Referenced by PorousFlowAdvectiveFlux::dmobility(), PorousFlowHeatAdvection::dmobility(), dmobility(), PorousFlowAdvectiveFlux::mobility(), PorousFlowHeatAdvection::mobility(), and mobility().
|
protected |
If the number of upwind-downwind swaps is less than this amount then full upwinding is used.
Otherwise the fallback scheme is employed
Definition at line 141 of file PorousFlowDarcyBase.h.
Referenced by computeResidualAndJacobian().
|
protected |
Gradient of the pore pressure in each phase.
Definition at line 117 of file PorousFlowDarcyBase.h.
Referenced by darcyQp(), and darcyQpJacobian().
|
protected |
Gravity. Defaults to 9.81 m/s^2.
Definition at line 132 of file PorousFlowDarcyBase.h.
Referenced by darcyQp(), and darcyQpJacobian().
|
protected |
Derivative of _proto_flux with respect to nodal variables.
This gets modified with the mobility and its derivative during computation of MOOSE's Jacobian
Definition at line 167 of file PorousFlowDarcyBase.h.
Referenced by computeResidualAndJacobian(), fullyUpwind(), harmonicMean(), and quickUpwind().
|
protected |
Number of nonlinear iterations (in this timestep and this element) that a node is an downwind node for a given fluid phase.
_num_upwinds[element_number][phase][node_number_in_element]
Definition at line 181 of file PorousFlowDarcyBase.h.
Referenced by computeResidualAndJacobian(), and timestepSetup().
|
protected |
The number of fluid phases.
Definition at line 129 of file PorousFlowDarcyBase.h.
Referenced by computeResidualAndJacobian().
|
protected |
Number of nonlinear iterations (in this timestep and this element) that a node is an upwind node for a given fluid phase.
_num_upwinds[element_number][phase][node_number_in_element]
Definition at line 174 of file PorousFlowDarcyBase.h.
Referenced by computeResidualAndJacobian(), and timestepSetup().
|
protected |
Flag to check whether permeabiity derivatives are non-zero.
Definition at line 135 of file PorousFlowDarcyBase.h.
Referenced by darcyQpJacobian().
|
protected |
Permeability of porous material.
Definition at line 87 of file PorousFlowDarcyBase.h.
Referenced by darcyQp(), and darcyQpJacobian().
|
protected |
Nodal pore pressure in each phase.
Definition at line 114 of file PorousFlowDarcyBase.h.
|
protected |
The Darcy flux.
When multiplied by the mobility, this is the mass flux of fluid moving out of a node. This multiplication occurs during the formation of the residual and Jacobian. _proto_flux[num_phases][num_nodes]
Definition at line 160 of file PorousFlowDarcyBase.h.
Referenced by computeResidualAndJacobian(), fullyUpwind(), harmonicMean(), and quickUpwind().