www.mooseframework.org
PorousFlowDarcyVelocityMaterial.C
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 
11 
13 
14 template <>
15 InputParameters
17 {
18  InputParameters params = validParams<PorousFlowMaterial>();
19  params.addRequiredParam<RealVectorValue>("gravity",
20  "Gravitational acceleration vector downwards (m/s^2)");
21  params.addClassDescription("This Material calculates the Darcy velocity for all phases");
22  params.addPrivateParam<std::string>("pf_material_type", "darcy_velocity");
23  params.set<bool>("at_nodes") = false;
24  return params;
25 }
26 
28  : PorousFlowMaterial(parameters),
29  _num_phases(_dictator.numPhases()),
30  _num_var(_dictator.numVariables()),
31  _permeability(getMaterialProperty<RealTensorValue>("PorousFlow_permeability_qp")),
32  _dpermeability_dvar(
33  getMaterialProperty<std::vector<RealTensorValue>>("dPorousFlow_permeability_qp_dvar")),
34  _dpermeability_dgradvar(getMaterialProperty<std::vector<std::vector<RealTensorValue>>>(
35  "dPorousFlow_permeability_qp_dgradvar")),
36  _fluid_density(getMaterialProperty<std::vector<Real>>("PorousFlow_fluid_phase_density_qp")),
37  _dfluid_density_dvar(getMaterialProperty<std::vector<std::vector<Real>>>(
38  "dPorousFlow_fluid_phase_density_qp_dvar")),
39  _fluid_viscosity(getMaterialProperty<std::vector<Real>>("PorousFlow_viscosity_qp")),
40  _dfluid_viscosity_dvar(
41  getMaterialProperty<std::vector<std::vector<Real>>>("dPorousFlow_viscosity_qp_dvar")),
42  _relative_permeability(
43  getMaterialProperty<std::vector<Real>>("PorousFlow_relative_permeability_qp")),
44  _drelative_permeability_dvar(getMaterialProperty<std::vector<std::vector<Real>>>(
45  "dPorousFlow_relative_permeability_qp_dvar")),
46  _grad_p(getMaterialProperty<std::vector<RealGradient>>("PorousFlow_grad_porepressure_qp")),
47  _dgrad_p_dgradvar(getMaterialProperty<std::vector<std::vector<Real>>>(
48  "dPorousFlow_grad_porepressure_qp_dgradvar")),
49  _dgrad_p_dvar(getMaterialProperty<std::vector<std::vector<RealGradient>>>(
50  "dPorousFlow_grad_porepressure_qp_dvar")),
51  _gravity(getParam<RealVectorValue>("gravity")),
52  _darcy_velocity(declareProperty<std::vector<RealVectorValue>>("PorousFlow_darcy_velocity_qp")),
53  _ddarcy_velocity_dvar(declareProperty<std::vector<std::vector<RealVectorValue>>>(
54  "dPorousFlow_darcy_velocity_qp_dvar")),
55  _ddarcy_velocity_dgradvar(
56  declareProperty<std::vector<std::vector<std::vector<RealVectorValue>>>>(
57  "dPorousFlow_darcy_velocity_qp_dgradvar"))
58 {
59  if (_nodal_material == true)
60  mooseError("PorousFlowDarcyVelocityMaterial is only defined for at_nodes = false");
61 }
62 
63 void
65 {
66  _darcy_velocity[_qp].resize(_num_phases);
67 
68  for (unsigned ph = 0; ph < _num_phases; ++ph)
69  _darcy_velocity[_qp][ph] =
70  -(_permeability[_qp] * (_grad_p[_qp][ph] - _fluid_density[_qp][ph] * _gravity) *
71  _relative_permeability[_qp][ph] / _fluid_viscosity[_qp][ph]);
72 
74  for (unsigned ph = 0; ph < _num_phases; ++ph)
75  _ddarcy_velocity_dvar[_qp][ph].resize(_num_var);
76 
77  for (unsigned ph = 0; ph < _num_phases; ++ph)
78  for (unsigned v = 0; v < _num_var; ++v)
79  {
80  _ddarcy_velocity_dvar[_qp][ph][v] =
81  -_dpermeability_dvar[_qp][v] * (_grad_p[_qp][ph] - _fluid_density[_qp][ph] * _gravity) *
82  _relative_permeability[_qp][ph] / _fluid_viscosity[_qp][ph];
83  _ddarcy_velocity_dvar[_qp][ph][v] -=
84  _permeability[_qp] *
85  (_dgrad_p_dvar[_qp][ph][v] - _dfluid_density_dvar[_qp][ph][v] * _gravity) *
86  _relative_permeability[_qp][ph] / _fluid_viscosity[_qp][ph];
87  _ddarcy_velocity_dvar[_qp][ph][v] -=
88  _permeability[_qp] * (_grad_p[_qp][ph] - _fluid_density[_qp][ph] * _gravity) *
89  (_drelative_permeability_dvar[_qp][ph][v] / _fluid_viscosity[_qp][ph] -
90  _relative_permeability[_qp][ph] * _dfluid_viscosity_dvar[_qp][ph][v] /
91  std::pow(_fluid_viscosity[_qp][ph], 2));
92  }
93 
95  for (unsigned ph = 0; ph < _num_phases; ++ph)
96  {
97  _ddarcy_velocity_dgradvar[_qp][ph].resize(LIBMESH_DIM);
98  for (unsigned i = 0; i < LIBMESH_DIM; ++i)
99  _ddarcy_velocity_dgradvar[_qp][ph][i].resize(_num_var);
100  }
101 
102  for (unsigned ph = 0; ph < _num_phases; ++ph)
103  for (unsigned i = 0; i < LIBMESH_DIM; ++i)
104  for (unsigned v = 0; v < _num_var; ++v)
105  {
106  _ddarcy_velocity_dgradvar[_qp][ph][i][v] =
107  -_dpermeability_dgradvar[_qp][i][v] *
108  (_grad_p[_qp][ph] - _fluid_density[_qp][ph] * _gravity);
109  for (unsigned j = 0; j < LIBMESH_DIM; ++j)
110  _ddarcy_velocity_dgradvar[_qp][ph][i][v](j) -=
111  _permeability[_qp](j, i) * _dgrad_p_dgradvar[_qp][ph][v];
112  _ddarcy_velocity_dgradvar[_qp][ph][i][v] *=
113  _relative_permeability[_qp][ph] / _fluid_viscosity[_qp][ph];
114  }
115 }
PorousFlowMaterial is the base class for all PorousFlow Materials It allows users to specify that the...
VectorValue< Real > RealGradient
const MaterialProperty< std::vector< std::vector< Real > > > & _drelative_permeability_dvar
Derivative of relative permeability of each phase wrt PorousFlow variables.
registerMooseObject("PorousFlowApp", PorousFlowDarcyVelocityMaterial)
const MaterialProperty< std::vector< Real > > & _fluid_density
Fluid density for each phase.
const MaterialProperty< std::vector< RealTensorValue > > & _dpermeability_dvar
d(permeabiity)/d(PorousFlow variable)
MaterialProperty< std::vector< std::vector< std::vector< RealVectorValue > > > > & _ddarcy_velocity_dgradvar
_ddarcy_velocity_dgradvar[_qp][ph][j][v](i) = d(i_th component of Darcy velocity of phase ph at quadp...
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< Real > > & _fluid_viscosity
Viscosity of each component in each phase.
const bool _nodal_material
Whether the derived class holds nodal values.
const MaterialProperty< std::vector< RealGradient > > & _grad_p
Gradient of the pore pressure in each phase.
MaterialProperty< std::vector< RealVectorValue > > & _darcy_velocity
Computed Darcy velocity of each phase.
Material to calculate the Darcy velocity for all phases.
const MaterialProperty< RealTensorValue > & _permeability
Permeability of porous material.
MaterialProperty< std::vector< std::vector< RealVectorValue > > > & _ddarcy_velocity_dvar
_ddarcy_velocity_dvar[_qp][ph][v](i) = d(i_th component of velocity of phase ph at quadpoint _qp)/d(P...
InputParameters validParams< PorousFlowMaterial >()
const MaterialProperty< std::vector< std::vector< Real > > > & _dfluid_density_dvar
Derivative of the fluid density for each phase wrt PorousFlow variables.
PorousFlowDarcyVelocityMaterial(const InputParameters &parameters)
const MaterialProperty< std::vector< std::vector< RealGradient > > > & _dgrad_p_dvar
Derivative of Grad porepressure in each phase wrt PorousFlow variables.
const MaterialProperty< std::vector< Real > > & _relative_permeability
Relative permeability of each phase.
const MaterialProperty< std::vector< std::vector< RealTensorValue > > > & _dpermeability_dgradvar
d(permeabiity)/d(grad(PorousFlow variable))
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
const unsigned int _num_var
Number of PorousFlow variables.
const MaterialProperty< std::vector< std::vector< Real > > > & _dgrad_p_dgradvar
Derivative of Grad porepressure in each phase wrt grad(PorousFlow variables)
const unsigned int _num_phases
Number of phases.
InputParameters validParams< PorousFlowDarcyVelocityMaterial >()