LCOV - code coverage report
Current view: top level - src/materials - PorousFlow2PhasePP.C (source / functions) Hit Total Coverage
Test: porous_flow Test Coverage Lines: 87 89 97.8 %
Date: 2017-11-21 14:47:27 Functions: 10 10 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 "PorousFlow2PhasePP.h"
       9             : #include "PorousFlowCapillaryPressure.h"
      10             : 
      11             : template <>
      12             : InputParameters
      13          48 : validParams<PorousFlow2PhasePP>()
      14             : {
      15          48 :   InputParameters params = validParams<PorousFlowVariableBase>();
      16         144 :   params.addRequiredCoupledVar("phase0_porepressure",
      17             :                                "Variable that is the porepressure of phase "
      18             :                                "0 (eg, the water phase).  It will be <= "
      19          48 :                                "phase1_porepressure.");
      20         144 :   params.addRequiredCoupledVar("phase1_porepressure",
      21          48 :                                "Variable that is the porepressure of phase 1 (eg, the gas phase)");
      22         144 :   params.addParam<UserObjectName>("capillary_pressure",
      23          48 :                                   "Name of the UserObject defining the capillary pressure");
      24          96 :   params.addClassDescription("This Material calculates the 2 porepressures and the 2 saturations "
      25             :                              "in a 2-phase isothermal situation, and derivatives of these with "
      26          48 :                              "respect to the PorousFlowVariables");
      27          48 :   return params;
      28             : }
      29             : 
      30         144 : PorousFlow2PhasePP::PorousFlow2PhasePP(const InputParameters & parameters)
      31             :   : PorousFlowVariableBase(parameters),
      32             : 
      33         432 :     _phase0_porepressure(_nodal_material ? coupledNodalValue("phase0_porepressure")
      34         270 :                                          : coupledValue("phase0_porepressure")),
      35         288 :     _phase0_gradp_qp(coupledGradient("phase0_porepressure")),
      36         288 :     _phase0_porepressure_varnum(coupled("phase0_porepressure")),
      37         144 :     _p0var(_dictator.isPorousFlowVariable(_phase0_porepressure_varnum)
      38         144 :                ? _dictator.porousFlowVariableNum(_phase0_porepressure_varnum)
      39             :                : 0),
      40             : 
      41         432 :     _phase1_porepressure(_nodal_material ? coupledNodalValue("phase1_porepressure")
      42         270 :                                          : coupledValue("phase1_porepressure")),
      43         288 :     _phase1_gradp_qp(coupledGradient("phase1_porepressure")),
      44         288 :     _phase1_porepressure_varnum(coupled("phase1_porepressure")),
      45         144 :     _p1var(_dictator.isPorousFlowVariable(_phase1_porepressure_varnum)
      46         144 :                ? _dictator.porousFlowVariableNum(_phase1_porepressure_varnum)
      47             :                : 0),
      48         288 :     _pc_uo(parameters.isParamSetByUser("capillary_pressure")
      49         432 :                ? &getUserObject<PorousFlowCapillaryPressure>("capillary_pressure")
      50        1440 :                : nullptr)
      51             : {
      52         144 :   if (_num_phases != 2)
      53             :     mooseError("The Dictator announces that the number of phases is ",
      54           0 :                _dictator.numPhases(),
      55             :                " whereas PorousFlow2PhasePP can only be used for 2-phase simulation.  When you "
      56           0 :                "have an efficient government, you have a dictatorship.");
      57         144 : }
      58             : 
      59             : void
      60        3696 : PorousFlow2PhasePP::initQpStatefulProperties()
      61             : {
      62        3696 :   PorousFlowVariableBase::initQpStatefulProperties();
      63        3696 :   buildQpPPSS();
      64        3696 : }
      65             : 
      66             : void
      67      598250 : PorousFlow2PhasePP::computeQpProperties()
      68             : {
      69             :   // size stuff correctly and prepare the derivative matrices with zeroes
      70      598250 :   PorousFlowVariableBase::computeQpProperties();
      71             : 
      72      598250 :   const Real pc = buildQpPPSS();
      73      598250 :   const Real dseff = dEffectiveSaturation_dP(pc); // d(seff)/d(pc)
      74             : 
      75      598250 :   if (!_nodal_material)
      76             :   {
      77      790986 :     (*_gradp_qp)[_qp][0] = _phase0_gradp_qp[_qp];
      78      527324 :     (*_gradp_qp)[_qp][1] = _phase1_gradp_qp[_qp];
      79      527324 :     (*_grads_qp)[_qp][0] = dseff * ((*_gradp_qp)[_qp][0] - (*_gradp_qp)[_qp][1]);
      80      263662 :     (*_grads_qp)[_qp][1] = -(*_grads_qp)[_qp][0];
      81             :   }
      82             : 
      83             :   // the derivatives of porepressure with respect to porepressure
      84             :   // remain fixed (at unity) throughout the simulation
      85      598250 :   if (_dictator.isPorousFlowVariable(_phase0_porepressure_varnum))
      86             :   {
      87     1196500 :     _dporepressure_dvar[_qp][0][_p0var] = 1.0;
      88      598250 :     if (!_nodal_material)
      89      527324 :       (*_dgradp_qp_dgradv)[_qp][0][_p0var] = 1.0;
      90             :   }
      91      598250 :   if (_dictator.isPorousFlowVariable(_phase1_porepressure_varnum))
      92             :   {
      93     1196500 :     _dporepressure_dvar[_qp][1][_p1var] = 1.0;
      94      598250 :     if (!_nodal_material)
      95      527324 :       (*_dgradp_qp_dgradv)[_qp][1][_p1var] = 1.0;
      96             :   }
      97             : 
      98      598250 :   if (_dictator.isPorousFlowVariable(_phase0_porepressure_varnum))
      99             :   {
     100     1196500 :     _dsaturation_dvar[_qp][0][_p0var] = dseff;
     101      598250 :     _dsaturation_dvar[_qp][1][_p0var] = -dseff;
     102             :   }
     103      598250 :   if (_dictator.isPorousFlowVariable(_phase1_porepressure_varnum))
     104             :   {
     105     1196500 :     _dsaturation_dvar[_qp][0][_p1var] = -dseff;
     106      598250 :     _dsaturation_dvar[_qp][1][_p1var] = dseff;
     107             :   }
     108             : 
     109      598250 :   if (!_nodal_material)
     110             :   {
     111      263662 :     const Real d2seff_qp = d2EffectiveSaturation_dP2(pc); // d^2(seff_qp)/d(pc_qp)^2
     112      263662 :     if (_dictator.isPorousFlowVariable(_phase0_porepressure_varnum))
     113             :     {
     114      527324 :       (*_dgrads_qp_dgradv)[_qp][0][_p0var] = dseff;
     115      527324 :       (*_dgrads_qp_dv)[_qp][0][_p0var] =
     116      527324 :           d2seff_qp * (_phase0_gradp_qp[_qp] - _phase1_gradp_qp[_qp]);
     117      263662 :       (*_dgrads_qp_dgradv)[_qp][1][_p0var] = -dseff;
     118      263662 :       (*_dgrads_qp_dv)[_qp][1][_p0var] =
     119      263662 :           -d2seff_qp * (_phase0_gradp_qp[_qp] - _phase1_gradp_qp[_qp]);
     120             :     }
     121      263662 :     if (_dictator.isPorousFlowVariable(_phase1_porepressure_varnum))
     122             :     {
     123      527324 :       (*_dgrads_qp_dgradv)[_qp][0][_p1var] = -dseff;
     124      527324 :       (*_dgrads_qp_dv)[_qp][0][_p1var] =
     125      790986 :           -d2seff_qp * (_phase0_gradp_qp[_qp] - _phase1_gradp_qp[_qp]);
     126      263662 :       (*_dgrads_qp_dgradv)[_qp][1][_p1var] = dseff;
     127      263662 :       (*_dgrads_qp_dv)[_qp][1][_p1var] =
     128             :           d2seff_qp * (_phase0_gradp_qp[_qp] - _phase1_gradp_qp[_qp]);
     129             :     }
     130             :   }
     131      598250 : }
     132             : 
     133             : Real
     134      601946 : PorousFlow2PhasePP::buildQpPPSS()
     135             : {
     136     1805838 :   _porepressure[_qp][0] = _phase0_porepressure[_qp];
     137     1203892 :   _porepressure[_qp][1] = _phase1_porepressure[_qp];
     138      601946 :   const Real pc = _phase0_porepressure[_qp] - _phase1_porepressure[_qp]; // this is <= 0
     139      601946 :   const Real seff = effectiveSaturation(pc);
     140     1203892 :   _saturation[_qp][0] = seff;
     141      601946 :   _saturation[_qp][1] = 1.0 - seff;
     142      601946 :   return pc;
     143             : }
     144             : 
     145             : Real
     146      601946 : PorousFlow2PhasePP::effectiveSaturation(Real pc) const
     147             : {
     148      601946 :   return _pc_uo->effectiveSaturation(pc);
     149             : }
     150             : 
     151             : Real
     152      598250 : PorousFlow2PhasePP::dEffectiveSaturation_dP(Real pc) const
     153             : {
     154      598250 :   return _pc_uo->dEffectiveSaturation(pc);
     155             : }
     156             : 
     157             : Real
     158      263662 : PorousFlow2PhasePP::d2EffectiveSaturation_dP2(Real pc) const
     159             : {
     160      263662 :   return _pc_uo->d2EffectiveSaturation(pc);
     161        2499 : }

Generated by: LCOV version 1.11