LCOV - code coverage report
Current view: top level - src/materials - PorousFlowVolumetricStrain.C (source / functions) Hit Total Coverage
Test: porous_flow Test Coverage Lines: 50 58 86.2 %
Date: 2017-11-21 14:47:27 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : #include "PorousFlowVolumetricStrain.h"
       9             : #include "MooseMesh.h"
      10             : 
      11             : #include "libmesh/quadrature.h"
      12             : 
      13             : template <>
      14             : InputParameters
      15          43 : validParams<PorousFlowVolumetricStrain>()
      16             : {
      17          43 :   InputParameters params = validParams<PorousFlowMaterialVectorBase>();
      18         129 :   params.addRequiredCoupledVar(
      19             :       "displacements",
      20          43 :       "The displacements appropriate for the simulation geometry and coordinate system");
      21         129 :   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          43 :                         "displaced mesh");
      27          86 :   params.addClassDescription(
      28          43 :       "Compute volumetric strain and the volumetric_strain rate, for use in PorousFlow.");
      29          86 :   params.set<bool>("stateful_displacements") = true;
      30          86 :   params.set<bool>("at_nodes") = false;
      31          43 :   return params;
      32             : }
      33             : 
      34         129 : PorousFlowVolumetricStrain::PorousFlowVolumetricStrain(const InputParameters & parameters)
      35             :   : PorousFlowMaterialVectorBase(parameters),
      36         387 :     _consistent(getParam<bool>("consistent_with_displaced_mesh")),
      37         258 :     _ndisp(coupledComponents("displacements")),
      38             :     _disp(3),
      39             :     _disp_var_num(3),
      40             :     _grad_disp(3),
      41             :     _grad_disp_old(3),
      42             : 
      43         258 :     _vol_strain_rate_qp(declareProperty<Real>("PorousFlow_volumetric_strain_rate_qp")),
      44             :     _dvol_strain_rate_qp_dvar(
      45         258 :         declareProperty<std::vector<RealGradient>>("dPorousFlow_volumetric_strain_rate_qp_dvar")),
      46         258 :     _vol_total_strain_qp(declareProperty<Real>("PorousFlow_total_volumetric_strain_qp")),
      47             :     _dvol_total_strain_qp_dvar(
      48        1161 :         declareProperty<std::vector<RealGradient>>("dPorousFlow_total_volumetric_strain_qp_dvar"))
      49             : {
      50         129 :   if (_ndisp != _mesh.dimension())
      51             :     mooseError("PorousFlowVolumetricStrain: The number of variables supplied in 'displacements' "
      52           0 :                "must match the mesh dimension.");
      53             : 
      54             :   // fetch coupled variables and gradients (as stateful properties if necessary)
      55         903 :   for (unsigned int i = 0; i < _ndisp; ++i)
      56             :   {
      57        1161 :     _disp[i] = &coupledValue("displacements", i);
      58         774 :     _disp_var_num[i] = coupled("displacements", i);
      59         774 :     _grad_disp[i] = &coupledGradient("displacements", i);
      60         774 :     _grad_disp_old[i] = &coupledGradientOld("displacements", i);
      61             :   }
      62             : 
      63             :   // set unused dimensions to zero
      64         129 :   for (unsigned i = _ndisp; i < 3; ++i)
      65             :   {
      66           0 :     _disp[i] = &_zero;
      67           0 :     _disp_var_num[i] = 0;
      68           0 :     while (_dictator.isPorousFlowVariable(_disp_var_num[i]))
      69           0 :       _disp_var_num[i]++; // increment until disp_var_num[i] is not a porflow var
      70           0 :     _grad_disp[i] = &_grad_zero;
      71           0 :     _grad_disp_old[i] = &_grad_zero;
      72             :   }
      73         129 :   if (_nodal_material == true)
      74           0 :     mooseError("PorousFlowVolumetricStrain classes are only defined for at_nodes = false");
      75         129 : }
      76             : 
      77             : void
      78        2064 : PorousFlowVolumetricStrain::initQpStatefulProperties()
      79             : {
      80        4128 :   _vol_total_strain_qp[_qp] = 0.0;
      81        2064 : }
      82             : 
      83             : void
      84      704976 : PorousFlowVolumetricStrain::computeQpProperties()
      85             : {
      86             :   RankTwoTensor A(
      87     2819904 :       (*_grad_disp[0])[_qp], (*_grad_disp[1])[_qp], (*_grad_disp[2])[_qp]); // Deformation gradient
      88      704976 :   RankTwoTensor Fbar((*_grad_disp_old[0])[_qp],
      89      704976 :                      (*_grad_disp_old[1])[_qp],
      90     2819904 :                      (*_grad_disp_old[2])[_qp]); // Old Deformation gradient
      91             : 
      92     1409952 :   _vol_total_strain_qp[_qp] = A.trace();
      93             : 
      94      704976 :   A -= Fbar; // A = grad_disp - grad_disp_old
      95             : 
      96     1409952 :   RankTwoTensor total_strain_increment = 0.5 * (A + A.transpose());
      97      704976 :   const Real andy = (_consistent
      98     1888896 :                          ? 1.0 + (*_grad_disp_old[0])[_qp](0) + (*_grad_disp_old[1])[_qp](1) +
      99      789280 :                                (*_grad_disp_old[2])[_qp](2)
     100             :                          : 1.0);
     101     1409952 :   _vol_strain_rate_qp[_qp] = total_strain_increment.trace() / _dt / andy;
     102             : 
     103             :   // prepare the derivatives with zeroes
     104     1409952 :   _dvol_strain_rate_qp_dvar[_qp].resize(_num_var, RealGradient());
     105     1409952 :   _dvol_total_strain_qp_dvar[_qp].resize(_num_var, RealGradient());
     106     4934832 :   for (unsigned i = 0; i < _ndisp; ++i)
     107     4229856 :     if (_dictator.isPorousFlowVariable(_disp_var_num[i]))
     108             :     {
     109             :       // the i_th displacement is a porous-flow variable
     110     2111280 :       const unsigned int pvar = _dictator.porousFlowVariableNum(_disp_var_num[i]);
     111     4222560 :       _dvol_strain_rate_qp_dvar[_qp][pvar](i) = 1.0 / _dt / andy;
     112     4222560 :       _dvol_total_strain_qp_dvar[_qp][pvar](i) = 1.0;
     113             :     }
     114      707475 : }

Generated by: LCOV version 1.11