LCOV - code coverage report
Current view: top level - src/kernels - PorousFlowHeatVolumetricExpansion.C (source / functions) Hit Total Coverage
Test: porous_flow Test Coverage Lines: 82 82 100.0 %
Date: 2017-11-18 13:30:36 Functions: 9 9 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 "PorousFlowHeatVolumetricExpansion.h"
       9             : 
      10             : // MOOSE includes
      11             : #include "MooseVariable.h"
      12             : 
      13             : template <>
      14             : InputParameters
      15           6 : validParams<PorousFlowHeatVolumetricExpansion>()
      16             : {
      17           6 :   InputParameters params = validParams<TimeKernel>();
      18          18 :   params.addParam<bool>("strain_at_nearest_qp",
      19             :                         false,
      20             :                         "When calculating nodal porosity that depends on strain, use the strain at "
      21             :                         "the nearest quadpoint.  This adds a small extra computational burden, and "
      22             :                         "is not necessary for simulations involving only linear lagrange elements. "
      23             :                         " If you set this to true, you will also want to set the same parameter to "
      24           6 :                         "true for related Kernels and Materials");
      25          18 :   params.addRequiredParam<UserObjectName>(
      26           6 :       "PorousFlowDictator", "The UserObject that holds the list of Porous-Flow variable names.");
      27          12 :   params.addClassDescription("Energy-density*rate_of_solid_volumetric_expansion");
      28           6 :   return params;
      29             : }
      30             : 
      31           6 : PorousFlowHeatVolumetricExpansion::PorousFlowHeatVolumetricExpansion(
      32           6 :     const InputParameters & parameters)
      33             :   : TimeKernel(parameters),
      34          12 :     _dictator(getUserObject<PorousFlowDictator>("PorousFlowDictator")),
      35           6 :     _var_is_porflow_var(_dictator.isPorousFlowVariable(_var.number())),
      36           6 :     _num_phases(_dictator.numPhases()),
      37           6 :     _fluid_present(_num_phases > 0),
      38          18 :     _strain_at_nearest_qp(getParam<bool>("strain_at_nearest_qp")),
      39          12 :     _porosity(getMaterialProperty<Real>("PorousFlow_porosity_nodal")),
      40          12 :     _dporosity_dvar(getMaterialProperty<std::vector<Real>>("dPorousFlow_porosity_nodal_dvar")),
      41             :     _dporosity_dgradvar(
      42          12 :         getMaterialProperty<std::vector<RealGradient>>("dPorousFlow_porosity_nodal_dgradvar")),
      43           6 :     _nearest_qp(_strain_at_nearest_qp
      44          12 :                     ? &getMaterialProperty<unsigned int>("PorousFlow_nearestqp_nodal")
      45             :                     : nullptr),
      46          12 :     _rock_energy_nodal(getMaterialProperty<Real>("PorousFlow_matrix_internal_energy_nodal")),
      47             :     _drock_energy_nodal_dvar(
      48          12 :         getMaterialProperty<std::vector<Real>>("dPorousFlow_matrix_internal_energy_nodal_dvar")),
      49             :     _fluid_density(
      50           6 :         _fluid_present
      51          18 :             ? &getMaterialProperty<std::vector<Real>>("PorousFlow_fluid_phase_density_nodal")
      52             :             : nullptr),
      53           6 :     _dfluid_density_dvar(_fluid_present
      54          12 :                              ? &getMaterialProperty<std::vector<std::vector<Real>>>(
      55          18 :                                    "dPorousFlow_fluid_phase_density_nodal_dvar")
      56             :                              : nullptr),
      57             :     _fluid_saturation_nodal(
      58          18 :         _fluid_present ? &getMaterialProperty<std::vector<Real>>("PorousFlow_saturation_nodal")
      59             :                        : nullptr),
      60           6 :     _dfluid_saturation_nodal_dvar(_fluid_present
      61          12 :                                       ? &getMaterialProperty<std::vector<std::vector<Real>>>(
      62          18 :                                             "dPorousFlow_saturation_nodal_dvar")
      63             :                                       : nullptr),
      64           6 :     _energy_nodal(_fluid_present
      65          12 :                       ? &getMaterialProperty<std::vector<Real>>(
      66          18 :                             "PorousFlow_fluid_phase_internal_energy_nodal")
      67             :                       : nullptr),
      68           6 :     _denergy_nodal_dvar(_fluid_present
      69          12 :                             ? &getMaterialProperty<std::vector<std::vector<Real>>>(
      70          18 :                                   "dPorousFlow_fluid_phase_internal_energy_nodal_dvar")
      71             :                             : nullptr),
      72          12 :     _strain_rate_qp(getMaterialProperty<Real>("PorousFlow_volumetric_strain_rate_qp")),
      73             :     _dstrain_rate_qp_dvar(getMaterialProperty<std::vector<RealGradient>>(
      74         126 :         "dPorousFlow_volumetric_strain_rate_qp_dvar"))
      75             : {
      76           6 : }
      77             : 
      78             : Real
      79       15616 : PorousFlowHeatVolumetricExpansion::computeQpResidual()
      80             : {
      81       46848 :   Real energy = (1.0 - _porosity[_i]) * _rock_energy_nodal[_i];
      82       46848 :   for (unsigned ph = 0; ph < _num_phases; ++ph)
      83       78080 :     energy += (*_fluid_density)[_i][ph] * (*_fluid_saturation_nodal)[_i][ph] *
      84       31232 :               (*_energy_nodal)[_i][ph] * _porosity[_i];
      85             : 
      86       46848 :   return _test[_i][_qp] * energy * _strain_rate_qp[_qp];
      87             : }
      88             : 
      89             : Real
      90       39936 : PorousFlowHeatVolumetricExpansion::computeQpJacobian()
      91             : {
      92       39936 :   return computedEnergyQpJac(_var.number()) + computedVolQpJac(_var.number());
      93             : }
      94             : 
      95             : Real
      96      159744 : PorousFlowHeatVolumetricExpansion::computeQpOffDiagJacobian(unsigned int jvar)
      97             : {
      98      159744 :   return computedEnergyQpJac(jvar) + computedVolQpJac(jvar);
      99             : }
     100             : 
     101             : Real
     102      199680 : PorousFlowHeatVolumetricExpansion::computedVolQpJac(unsigned int jvar)
     103             : {
     104      199680 :   if (_dictator.notPorousFlowVariable(jvar))
     105             :     return 0.0;
     106             : 
     107      599040 :   Real energy = (1.0 - _porosity[_i]) * _rock_energy_nodal[_i];
     108      599040 :   for (unsigned ph = 0; ph < _num_phases; ++ph)
     109      998400 :     energy += (*_fluid_density)[_i][ph] * (*_fluid_saturation_nodal)[_i][ph] *
     110      399360 :               (*_energy_nodal)[_i][ph] * _porosity[_i];
     111             : 
     112      199680 :   const unsigned int pvar = _dictator.porousFlowVariableNum(jvar);
     113      399360 :   Real dvol = _dstrain_rate_qp_dvar[_qp][pvar] * _grad_phi[_j][_qp];
     114             : 
     115      399360 :   return _test[_i][_qp] * energy * dvol;
     116             : }
     117             : Real
     118      199680 : PorousFlowHeatVolumetricExpansion::computedEnergyQpJac(unsigned int jvar)
     119             : {
     120      199680 :   if (_dictator.notPorousFlowVariable(jvar))
     121             :     return 0.0;
     122             : 
     123      199680 :   const unsigned int pvar = _dictator.porousFlowVariableNum(jvar);
     124      199680 :   const unsigned nearest_qp = (_strain_at_nearest_qp ? (*_nearest_qp)[_i] : _i);
     125             : 
     126      798720 :   Real denergy = -_dporosity_dgradvar[_i][pvar] * _grad_phi[_j][_i] * _rock_energy_nodal[_i];
     127      599040 :   for (unsigned ph = 0; ph < _num_phases; ++ph)
     128      798720 :     denergy += (*_fluid_density)[_i][ph] * (*_fluid_saturation_nodal)[_i][ph] *
     129      599040 :                (*_energy_nodal)[_i][ph] * _dporosity_dgradvar[_i][pvar] * _grad_phi[_j][nearest_qp];
     130             : 
     131      199680 :   if (_i != _j)
     132      524160 :     return _test[_i][_qp] * denergy * _strain_rate_qp[_qp];
     133             : 
     134       74880 :   denergy += _drock_energy_nodal_dvar[_i][pvar] * (1.0 - _porosity[_i]);
     135       49920 :   denergy -= _rock_energy_nodal[_i] * _dporosity_dvar[_i][pvar];
     136       74880 :   for (unsigned ph = 0; ph < _num_phases; ++ph)
     137             :   {
     138      124800 :     denergy += (*_dfluid_density_dvar)[_i][ph][pvar] * (*_fluid_saturation_nodal)[_i][ph] *
     139       49920 :                (*_energy_nodal)[_i][ph] * _porosity[_i];
     140       99840 :     denergy += (*_fluid_density)[_i][ph] * (*_dfluid_saturation_nodal_dvar)[_i][ph][pvar] *
     141       24960 :                (*_energy_nodal)[_i][ph] * _porosity[_i];
     142       74880 :     denergy += (*_fluid_density)[_i][ph] * (*_fluid_saturation_nodal)[_i][ph] *
     143       49920 :                (*_denergy_nodal_dvar)[_i][ph][pvar] * _porosity[_i];
     144       49920 :     denergy += (*_fluid_density)[_i][ph] * (*_fluid_saturation_nodal)[_i][ph] *
     145       24960 :                (*_energy_nodal)[_i][ph] * _dporosity_dvar[_i][pvar];
     146             :   }
     147             : 
     148       74880 :   return _test[_i][_qp] * denergy * _strain_rate_qp[_qp];
     149        2499 : }

Generated by: LCOV version 1.11