www.mooseframework.org
PorousFlowVolumetricStrain.C
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 
9 #include "MooseMesh.h"
10 
11 #include "libmesh/quadrature.h"
12 
13 template <>
14 InputParameters
16 {
17  InputParameters params = validParams<PorousFlowMaterialVectorBase>();
18  params.addRequiredCoupledVar(
19  "displacements",
20  "The displacements appropriate for the simulation geometry and coordinate system");
21  params.addParam<bool>("consistent_with_displaced_mesh",
22  true,
23  "The volumetric strain rate will "
24  "include terms that ensure fluid "
25  "mass conservation in the "
26  "displaced mesh");
27  params.addClassDescription(
28  "Compute volumetric strain and the volumetric_strain rate, for use in PorousFlow.");
29  params.set<bool>("stateful_displacements") = true;
30  params.set<bool>("at_nodes") = false;
31  return params;
32 }
33 
34 PorousFlowVolumetricStrain::PorousFlowVolumetricStrain(const InputParameters & parameters)
35  : PorousFlowMaterialVectorBase(parameters),
36  _consistent(getParam<bool>("consistent_with_displaced_mesh")),
37  _ndisp(coupledComponents("displacements")),
38  _disp(3),
39  _disp_var_num(3),
40  _grad_disp(3),
41  _grad_disp_old(3),
42 
43  _vol_strain_rate_qp(declareProperty<Real>("PorousFlow_volumetric_strain_rate_qp")),
44  _dvol_strain_rate_qp_dvar(
45  declareProperty<std::vector<RealGradient>>("dPorousFlow_volumetric_strain_rate_qp_dvar")),
46  _vol_total_strain_qp(declareProperty<Real>("PorousFlow_total_volumetric_strain_qp")),
47  _dvol_total_strain_qp_dvar(
48  declareProperty<std::vector<RealGradient>>("dPorousFlow_total_volumetric_strain_qp_dvar"))
49 {
50  if (_ndisp != _mesh.dimension())
51  mooseError("PorousFlowVolumetricStrain: The number of variables supplied in 'displacements' "
52  "must match the mesh dimension.");
53 
54  // fetch coupled variables and gradients (as stateful properties if necessary)
55  for (unsigned int i = 0; i < _ndisp; ++i)
56  {
57  _disp[i] = &coupledValue("displacements", i);
58  _disp_var_num[i] = coupled("displacements", i);
59  _grad_disp[i] = &coupledGradient("displacements", i);
60  _grad_disp_old[i] = &coupledGradientOld("displacements", i);
61  }
62 
63  // set unused dimensions to zero
64  for (unsigned i = _ndisp; i < 3; ++i)
65  {
66  _disp[i] = &_zero;
67  _disp_var_num[i] = 0;
68  while (_dictator.isPorousFlowVariable(_disp_var_num[i]))
69  _disp_var_num[i]++; // increment until disp_var_num[i] is not a porflow var
70  _grad_disp[i] = &_grad_zero;
71  _grad_disp_old[i] = &_grad_zero;
72  }
73  if (_nodal_material == true)
74  mooseError("PorousFlowVolumetricStrain classes are only defined for at_nodes = false");
75 }
76 
77 void
79 {
80  _vol_total_strain_qp[_qp] = 0.0;
81 }
82 
83 void
85 {
86  RankTwoTensor A(
87  (*_grad_disp[0])[_qp], (*_grad_disp[1])[_qp], (*_grad_disp[2])[_qp]); // Deformation gradient
88  RankTwoTensor Fbar((*_grad_disp_old[0])[_qp],
89  (*_grad_disp_old[1])[_qp],
90  (*_grad_disp_old[2])[_qp]); // Old Deformation gradient
91 
92  _vol_total_strain_qp[_qp] = A.trace();
93 
94  A -= Fbar; // A = grad_disp - grad_disp_old
95 
96  RankTwoTensor total_strain_increment = 0.5 * (A + A.transpose());
97  const Real andy = (_consistent
98  ? 1.0 + (*_grad_disp_old[0])[_qp](0) + (*_grad_disp_old[1])[_qp](1) +
99  (*_grad_disp_old[2])[_qp](2)
100  : 1.0);
101  _vol_strain_rate_qp[_qp] = total_strain_increment.trace() / _dt / andy;
102 
103  // prepare the derivatives with zeroes
104  _dvol_strain_rate_qp_dvar[_qp].resize(_num_var, RealGradient());
105  _dvol_total_strain_qp_dvar[_qp].resize(_num_var, RealGradient());
106  for (unsigned i = 0; i < _ndisp; ++i)
107  if (_dictator.isPorousFlowVariable(_disp_var_num[i]))
108  {
109  // the i_th displacement is a porous-flow variable
110  const unsigned int pvar = _dictator.porousFlowVariableNum(_disp_var_num[i]);
111  _dvol_strain_rate_qp_dvar[_qp][pvar](i) = 1.0 / _dt / andy;
112  _dvol_total_strain_qp_dvar[_qp][pvar](i) = 1.0;
113  }
114 }
InputParameters validParams< PorousFlowVolumetricStrain >()
MaterialProperty< std::vector< RealGradient > > & _dvol_strain_rate_qp_dvar
The derivative of the volumetric strain rate with respect to the porous flow variables.
std::vector< const VariableGradient * > _grad_disp_old
old value of gradient of the displacements
const unsigned int _ndisp
number of displacements supplied (1 in 1D, 2 in 2D, 3 in 3D)
virtual void computeQpProperties() override
MaterialProperty< Real > & _vol_total_strain_qp
The total volumetric strain at the quadpoints.
InputParameters validParams< PorousFlowMaterialVectorBase >()
std::vector< const VariableValue * > _disp
displacement variable values at the quad point
Base class for all PorousFlow vector materials.
virtual void initQpStatefulProperties() override
MaterialProperty< Real > & _vol_strain_rate_qp
The volumetric strain rate at the quadpoints.
MaterialProperty< std::vector< RealGradient > > & _dvol_total_strain_qp_dvar
The derivative of the total volumetric strain with respect to the porous flow variables.
PorousFlowVolumetricStrain(const InputParameters &parameters)
const unsigned int _num_var
Number of PorousFlow variables.
std::vector< const VariableGradient * > _grad_disp
gradient of the displacements
const bool _consistent
If true then the strain rate will include terms that ensure mass is conserved when doing integrals ov...
std::vector< unsigned int > _disp_var_num
moose variable number of the displacements variables provided