www.mooseframework.org
PorousFlowDarcyBase.h
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
8 #ifndef POROUSFLOWDARCYBASE_H
9 #define POROUSFLOWDARCYBASE_H
10 
11 #include "Kernel.h"
12 #include "PorousFlowDictator.h"
13 
15 
16 template <>
17 InputParameters validParams<PorousFlowDarcyBase>();
18 
27 class PorousFlowDarcyBase : public Kernel
28 {
29 public:
30  PorousFlowDarcyBase(const InputParameters & parameters);
31 
32 protected:
33  virtual void timestepSetup() override;
34  virtual Real computeQpResidual() override;
35  virtual void computeResidual() override;
36  virtual void computeJacobian() override;
37  virtual void computeOffDiagJacobian(unsigned int jvar) override;
38 
40  virtual Real darcyQp(unsigned int ph) const;
41 
43  virtual Real darcyQpJacobian(unsigned int jvar, unsigned int ph) const;
44 
50  virtual Real mobility(unsigned nodenum, unsigned phase) const;
51 
57  virtual Real dmobility(unsigned nodenum, unsigned phase, unsigned pvar) const;
58 
59  enum class JacRes
60  {
63  };
64 
80  void computeResidualAndJacobian(JacRes res_or_jac, unsigned int jvar);
81 
83  const MaterialProperty<RealTensorValue> & _permeability;
84 
86  const MaterialProperty<std::vector<RealTensorValue>> & _dpermeability_dvar;
87 
89  const MaterialProperty<std::vector<std::vector<RealTensorValue>>> & _dpermeability_dgradvar;
90 
92  const MaterialProperty<std::vector<Real>> & _fluid_density_node;
93 
95  const MaterialProperty<std::vector<std::vector<Real>>> & _dfluid_density_node_dvar;
96 
98  const MaterialProperty<std::vector<Real>> & _fluid_density_qp;
99 
101  const MaterialProperty<std::vector<std::vector<Real>>> & _dfluid_density_qp_dvar;
102 
104  const MaterialProperty<std::vector<Real>> & _fluid_viscosity;
105 
107  const MaterialProperty<std::vector<std::vector<Real>>> & _dfluid_viscosity_dvar;
108 
110  const MaterialProperty<std::vector<Real>> & _pp;
111 
113  const MaterialProperty<std::vector<RealGradient>> & _grad_p;
114 
116  const MaterialProperty<std::vector<std::vector<Real>>> & _dgrad_p_dgrad_var;
117 
119  const MaterialProperty<std::vector<std::vector<RealGradient>>> & _dgrad_p_dvar;
120 
123 
125  const unsigned int _num_phases;
126 
128  const RealVectorValue _gravity;
129 
134  const unsigned _full_upwind_threshold;
135 
145  const enum class FallbackEnum { QUICK, HARMONIC } _fallback_scheme;
146 
153  std::vector<std::vector<Real>> _proto_flux;
154 
160  std::vector<std::vector<std::vector<Real>>> _jacobian;
161 
167  std::unordered_map<unsigned, std::vector<std::vector<unsigned>>> _num_upwinds;
168 
174  std::unordered_map<unsigned, std::vector<std::vector<unsigned>>> _num_downwinds;
175 
182  void fullyUpwind(JacRes res_or_jac, unsigned int ph, unsigned int pvar);
183 
191  void quickUpwind(JacRes res_or_jac, unsigned int ph, unsigned int pvar);
192 
200  void harmonicMean(JacRes res_or_jac, unsigned int ph, unsigned int pvar);
201 };
202 
203 #endif // POROUSFLOWDARCYBASE_H
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) ...
const MaterialProperty< std::vector< std::vector< RealTensorValue > > > & _dpermeability_dgradvar
d(permeabiity)/d(grad(porous-flow variable))
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) ...
const MaterialProperty< std::vector< RealTensorValue > > & _dpermeability_dvar
d(permeabiity)/d(porous-flow variable)
enum PorousFlowDarcyBase::FallbackEnum _fallback_scheme
void computeResidualAndJacobian(JacRes res_or_jac, unsigned int jvar)
Computation of the residual and Jacobian.
const MaterialProperty< std::vector< Real > > & _fluid_viscosity
Viscosity of each component in each phase.
const MaterialProperty< RealTensorValue > & _permeability
Permeability of porous material.
FallbackEnum
If full upwinding is failing due to nodes swapping between upwind and downwind in successive nonlinea...
Darcy advective flux.
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 fo...
std::vector< std::vector< Real > > _proto_flux
The Darcy flux.
std::vector< std::vector< std::vector< Real > > > _jacobian
Derivative of _proto_flux with respect to nodal variables.
const MaterialProperty< std::vector< Real > > & _fluid_density_qp
Fluid density for each phase (at the qp)
virtual void computeResidual() override
const MaterialProperty< std::vector< RealGradient > > & _grad_p
Gradient of the pore pressure in each phase.
const PorousFlowDictator & _porousflow_dictator
PorousFlow UserObject.
virtual Real darcyQp(unsigned int ph) const
the Darcy part of the flux (this is the non-upwinded part)
const MaterialProperty< std::vector< Real > > & _pp
Nodal pore pressure in each phase.
const MaterialProperty< std::vector< std::vector< Real > > > & _dfluid_viscosity_dvar
Derivative of the fluid viscosity for each phase wrt PorousFlow variables.
InputParameters validParams< PorousFlowDarcyBase >()
const MaterialProperty< std::vector< std::vector< RealGradient > > > & _dgrad_p_dvar
Derivative of Grad porepressure in each phase wrt PorousFlow variables.
const unsigned int _num_phases
The number of fluid phases.
virtual void computeOffDiagJacobian(unsigned int jvar) override
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 ...
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 ...
virtual Real computeQpResidual() override
virtual void timestepSetup() override
const RealVectorValue _gravity
Gravity. Defaults to 9.81 m/s^2.
PorousFlowDarcyBase(const InputParameters &parameters)
const MaterialProperty< std::vector< std::vector< Real > > > & _dgrad_p_dgrad_var
Derivative of Grad porepressure in each phase wrt grad(PorousFlow variables)
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...
This holds maps between the nonlinear variables used in a PorousFlow simulation and the variable numb...
virtual Real dmobility(unsigned nodenum, unsigned phase, unsigned pvar) const
The derivative of mobility with respect to PorousFlow variable pvar.
const unsigned _full_upwind_threshold
If the number of upwind-downwind swaps is less than this amount then full upwinding is used...
virtual Real mobility(unsigned nodenum, unsigned phase) const
The mobility of the fluid.
virtual void computeJacobian() override
virtual Real darcyQpJacobian(unsigned int jvar, unsigned int ph) const
Jacobian of the Darcy part of the flux.
const MaterialProperty< std::vector< Real > > & _fluid_density_node
Fluid density for each phase (at the node)
void fullyUpwind(JacRes res_or_jac, unsigned int ph, unsigned int pvar)
Calculate the residual or Jacobian using full upwinding.