www.mooseframework.org
PorousFlowDarcyBase.h
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 
10 #pragma once
11 
12 #include "Kernel.h"
13 #include "PorousFlowDictator.h"
14 
24 {
25 public:
27 
29 
30 protected:
31  virtual void timestepSetup() override;
32  virtual Real computeQpResidual() override;
33  virtual void computeResidual() override;
34  virtual void computeJacobian() override;
35  virtual void computeOffDiagJacobian(unsigned int jvar) override;
36 
38  virtual Real darcyQp(unsigned int ph) const;
39 
41  virtual Real darcyQpJacobian(unsigned int jvar, unsigned int ph) const;
42 
49  virtual Real mobility(unsigned nodenum, unsigned phase) const;
50 
57  virtual Real dmobility(unsigned nodenum, unsigned phase, unsigned pvar) const;
58 
59  enum class JacRes
60  {
63  };
64 
66 
82  void computeResidualAndJacobian(JacRes res_or_jac, unsigned int jvar);
83 
86 
89 
92 
95 
98 
101 
104 
107 
110 
113 
116 
119 
122 
125 
127  const unsigned int _num_phases;
128 
131 
133  const bool _perm_derivs;
134 
139  const unsigned _full_upwind_threshold;
140 
151 
158  std::vector<std::vector<Real>> _proto_flux;
159 
165  std::vector<std::vector<std::vector<Real>>> _jacobian;
166 
172  std::unordered_map<unsigned, std::vector<std::vector<unsigned>>> _num_upwinds;
173 
179  std::unordered_map<unsigned, std::vector<std::vector<unsigned>>> _num_downwinds;
180 
187  void fullyUpwind(JacRes res_or_jac, unsigned int ph, unsigned int pvar);
188 
196  void quickUpwind(JacRes res_or_jac, unsigned int ph, unsigned int pvar);
197 
205  void harmonicMean(JacRes res_or_jac, unsigned int ph, unsigned int pvar);
206 };
virtual void computeResidualAndJacobian()
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(PorousFlow 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(PorousFlow variable)
enum PorousFlowDarcyBase::FallbackEnum _fallback_scheme
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.
virtual void computeResidualAndJacobian() override
std::vector< std::vector< std::vector< Real > > > _jacobian
Derivative of _proto_flux with respect to nodal variables.
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_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 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.
const MaterialProperty< std::vector< std::vector< RealGradient > > > & _dgrad_p_dvar
Derivative of Grad porepressure in each phase wrt PorousFlow variables.
static InputParameters validParams()
const PorousFlowDictator & _dictator
PorousFlowDictator UserObject.
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.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual Real mobility(unsigned nodenum, unsigned phase) const
The mobility of the fluid.
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 void computeJacobian() override
const InputParameters & parameters() const
virtual Real darcyQp(unsigned int ph) const
The Darcy part of the flux (this is the non-upwinded part)
const bool _perm_derivs
Flag to check whether permeabiity derivatives are non-zero.
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.