LCOV - code coverage report
Current view: top level - src/kernels - PorousFlowFullySaturatedMassTimeDerivative.C (source / functions) Hit Total Coverage
Test: porous_flow Test Coverage Lines: 75 76 98.7 %
Date: 2017-11-20 14:50:56 Functions: 8 8 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 "PorousFlowFullySaturatedMassTimeDerivative.h"
       9             : 
      10             : // MOOSE includes
      11             : #include "MooseVariable.h"
      12             : 
      13             : template <>
      14             : InputParameters
      15          10 : validParams<PorousFlowFullySaturatedMassTimeDerivative>()
      16             : {
      17          10 :   InputParameters params = validParams<TimeKernel>();
      18          30 :   MooseEnum coupling_type("Hydro ThermoHydro HydroMechanical ThermoHydroMechanical", "Hydro");
      19          30 :   params.addParam<MooseEnum>("coupling_type",
      20             :                              coupling_type,
      21             :                              "The type of simulation.  For simulations involving Mechanical "
      22             :                              "deformations, you will need to supply the correct Biot coefficient.  "
      23             :                              "For simulations involving Thermal flows, you will need an associated "
      24          10 :                              "ConstantThermalExpansionCoefficient Material");
      25          40 :   params.addRangeCheckedParam<Real>(
      26          10 :       "biot_coefficient", 1.0, "biot_coefficient>=0 & biot_coefficient<=1", "Biot coefficient");
      27          30 :   params.addParam<bool>("multiply_by_density",
      28             :                         true,
      29             :                         "If true, then this Kernel is the time derivative of the fluid "
      30             :                         "mass.  If false, then this Kernel is the derivative of the "
      31          10 :                         "fluid volume (which is common in poro-mechanics)");
      32          30 :   params.addRequiredParam<UserObjectName>(
      33          10 :       "PorousFlowDictator", "The UserObject that holds the list of Porous-Flow variable names.");
      34          20 :   params.addClassDescription("Fully-saturated version of the single-component, single-phase fluid "
      35          10 :                              "mass derivative wrt time");
      36          10 :   return params;
      37             : }
      38             : 
      39          10 : PorousFlowFullySaturatedMassTimeDerivative::PorousFlowFullySaturatedMassTimeDerivative(
      40          10 :     const InputParameters & parameters)
      41             :   : TimeKernel(parameters),
      42          20 :     _dictator(getUserObject<PorousFlowDictator>("PorousFlowDictator")),
      43          10 :     _var_is_porflow_var(_dictator.isPorousFlowVariable(_var.number())),
      44          30 :     _multiply_by_density(getParam<bool>("multiply_by_density")),
      45          20 :     _coupling_type(getParam<MooseEnum>("coupling_type").getEnum<CouplingTypeEnum>()),
      46          10 :     _includes_thermal(_coupling_type == CouplingTypeEnum::ThermoHydro ||
      47             :                       _coupling_type == CouplingTypeEnum::ThermoHydroMechanical),
      48          10 :     _includes_mechanical(_coupling_type == CouplingTypeEnum::HydroMechanical ||
      49             :                          _coupling_type == CouplingTypeEnum::ThermoHydroMechanical),
      50          30 :     _biot_coefficient(getParam<Real>("biot_coefficient")),
      51          20 :     _biot_modulus(getMaterialProperty<Real>("PorousFlow_constant_biot_modulus_qp")),
      52             :     _thermal_coeff(
      53          10 :         _includes_thermal
      54          21 :             ? &getMaterialProperty<Real>("PorousFlow_constant_thermal_expansion_coefficient_qp")
      55             :             : nullptr),
      56             :     _fluid_density(
      57          10 :         _multiply_by_density
      58          24 :             ? &getMaterialProperty<std::vector<Real>>("PorousFlow_fluid_phase_density_qp")
      59             :             : nullptr),
      60          10 :     _dfluid_density_dvar(_multiply_by_density
      61          14 :                              ? &getMaterialProperty<std::vector<std::vector<Real>>>(
      62          18 :                                    "dPorousFlow_fluid_phase_density_qp_dvar")
      63             :                              : nullptr),
      64          20 :     _pp(getMaterialProperty<std::vector<Real>>("PorousFlow_porepressure_qp")),
      65          20 :     _pp_old(getMaterialPropertyOld<std::vector<Real>>("PorousFlow_porepressure_qp")),
      66             :     _dpp_dvar(
      67          20 :         getMaterialProperty<std::vector<std::vector<Real>>>("dPorousFlow_porepressure_qp_dvar")),
      68          21 :     _temperature(_includes_thermal ? &getMaterialProperty<Real>("PorousFlow_temperature_qp")
      69             :                                    : nullptr),
      70          21 :     _temperature_old(_includes_thermal ? &getMaterialPropertyOld<Real>("PorousFlow_temperature_qp")
      71             :                                        : nullptr),
      72             :     _dtemperature_dvar(
      73          10 :         _includes_thermal
      74          21 :             ? &getMaterialProperty<std::vector<Real>>("dPorousFlow_temperature_qp_dvar")
      75             :             : nullptr),
      76          10 :     _strain_rate(_includes_mechanical
      77          29 :                      ? &getMaterialProperty<Real>("PorousFlow_volumetric_strain_rate_qp")
      78             :                      : nullptr),
      79          10 :     _dstrain_rate_dvar(_includes_mechanical
      80          19 :                            ? &getMaterialProperty<std::vector<RealGradient>>(
      81          28 :                                  "dPorousFlow_volumetric_strain_rate_qp_dvar")
      82         200 :                            : nullptr)
      83             : {
      84          10 :   if (_dictator.numComponents() != 1 || _dictator.numPhases() != 1)
      85             :     mooseError("PorousFlowFullySaturatedMassTimeDerivative is only applicable to single-phase, "
      86             :                "single-component fluid-flow problems.  The Dictator proclaims that you have more "
      87             :                "than one phase or more than one fluid component.  The Dictator does not take such "
      88           0 :                "mistakes lightly");
      89          10 : }
      90             : 
      91             : Real
      92     1117888 : PorousFlowFullySaturatedMassTimeDerivative::computeQpResidual()
      93             : {
      94             :   const unsigned phase = 0;
      95     4471552 :   Real volume = (_pp[_qp][phase] - _pp_old[_qp][phase]) / _dt / _biot_modulus[_qp];
      96     1117888 :   if (_includes_thermal)
      97       32512 :     volume -= (*_thermal_coeff)[_qp] * ((*_temperature)[_qp] - (*_temperature_old)[_qp]) / _dt;
      98     1117888 :   if (_includes_mechanical)
      99     2229376 :     volume += _biot_coefficient * (*_strain_rate)[_qp];
     100     1117888 :   if (_multiply_by_density)
     101      888384 :     return _test[_i][_qp] * (*_fluid_density)[_qp][phase] * volume;
     102     1643520 :   return _test[_i][_qp] * volume;
     103             : }
     104             : 
     105             : Real
     106     3491456 : PorousFlowFullySaturatedMassTimeDerivative::computeQpJacobian()
     107             : {
     108             :   /// If the variable is not a PorousFlow variable (very unusual), the diag Jacobian terms are 0
     109     3491456 :   if (!_var_is_porflow_var)
     110             :     return 0.0;
     111     3491456 :   return computeQpJac(_dictator.porousFlowVariableNum(_var.number()));
     112             : }
     113             : 
     114             : Real
     115    10466304 : PorousFlowFullySaturatedMassTimeDerivative::computeQpOffDiagJacobian(unsigned int jvar)
     116             : {
     117             :   /// If the variable is not a PorousFlow variable, the OffDiag Jacobian terms are 0
     118    10466304 :   if (_dictator.notPorousFlowVariable(jvar))
     119             :     return 0.0;
     120    10466304 :   return computeQpJac(_dictator.porousFlowVariableNum(jvar));
     121             : }
     122             : 
     123             : Real
     124    13957760 : PorousFlowFullySaturatedMassTimeDerivative::computeQpJac(unsigned int pvar)
     125             : {
     126             :   const unsigned phase = 0;
     127    55831040 :   Real volume = (_pp[_qp][phase] - _pp_old[_qp][phase]) / _dt / _biot_modulus[_qp];
     128    41873280 :   Real dvolume = _dpp_dvar[_qp][phase][pvar] / _dt / _biot_modulus[_qp] * _phi[_j][_qp];
     129    13957760 :   if (_includes_thermal)
     130             :   {
     131       30720 :     volume -= (*_thermal_coeff)[_qp] * ((*_temperature)[_qp] - (*_temperature_old)[_qp]) / _dt;
     132       15360 :     dvolume -= (*_thermal_coeff)[_qp] * (*_dtemperature_dvar)[_qp][pvar] / _dt * _phi[_j][_qp];
     133             :   }
     134    13957760 :   if (_includes_mechanical)
     135             :   {
     136    27909120 :     volume += _biot_coefficient * (*_strain_rate)[_qp];
     137    41863680 :     dvolume += _biot_coefficient * (*_dstrain_rate_dvar)[_qp][pvar] * _grad_phi[_j][_qp];
     138             :   }
     139    13957760 :   if (_multiply_by_density)
     140    20769280 :     return _test[_i][_qp] * ((*_fluid_density)[_qp][phase] * dvolume +
     141    15576960 :                              (*_dfluid_density_dvar)[_qp][phase][pvar] * _phi[_j][_qp] * volume);
     142    17530880 :   return _test[_i][_qp] * dvolume;
     143        2499 : }

Generated by: LCOV version 1.11