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