LCOV - code coverage report
Current view: top level - src/materials - PorousFlowPorosityExponentialBase.C (source / functions) Hit Total Coverage
Test: porous_flow Test Coverage Lines: 41 41 100.0 %
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 "PorousFlowPorosityExponentialBase.h"
       9             : 
      10             : template <>
      11             : InputParameters
      12          39 : validParams<PorousFlowPorosityExponentialBase>()
      13             : {
      14          39 :   InputParameters params = validParams<PorousFlowPorosityBase>();
      15         117 :   params.addParam<bool>("strain_at_nearest_qp",
      16             :                         false,
      17             :                         "When calculating nodal porosity that depends on strain, use the strain at "
      18             :                         "the nearest quadpoint.  This adds a small extra computational burden, and "
      19             :                         "is not necessary for simulations involving only linear lagrange elements. "
      20             :                         " If you set this to true, you will also want to set the same parameter to "
      21          39 :                         "true for related Kernels and Materials");
      22         117 :   params.addParam<bool>("ensure_positive",
      23             :                         true,
      24             :                         "Modify the usual exponential relationships that "
      25             :                         "governs porosity so that porosity is always "
      26          39 :                         "positive");
      27          78 :   params.addClassDescription("Base class Material for porosity that is computed via an exponential "
      28             :                              "relationship with coupled variables (strain, porepressure, "
      29          39 :                              "temperature)");
      30          39 :   return params;
      31             : }
      32             : 
      33         117 : PorousFlowPorosityExponentialBase::PorousFlowPorosityExponentialBase(
      34         117 :     const InputParameters & parameters)
      35             :   : PorousFlowPorosityBase(parameters),
      36         351 :     _strain_at_nearest_qp(getParam<bool>("strain_at_nearest_qp")),
      37         585 :     _ensure_positive(getParam<bool>("ensure_positive"))
      38             : {
      39         117 : }
      40             : 
      41             : void
      42        1296 : PorousFlowPorosityExponentialBase::initQpStatefulProperties()
      43             : {
      44        1296 :   const Real a = atNegInfinityQp();
      45        1296 :   const Real b = atZeroQp();
      46             :   mooseAssert(a > b, "PorousFlowPorosityExponentialBase a must be larger than b");
      47        1296 :   const Real decay = decayQp();
      48             : 
      49        1296 :   if (decay <= 0.0 || !_ensure_positive)
      50        2200 :     _porosity[_qp] = a + (b - a) * std::exp(decay);
      51             :   else
      52             :   {
      53         196 :     const Real c = std::log(a / (a - b));
      54         196 :     const Real expx = std::exp(-decay / c);
      55         392 :     _porosity[_qp] = a + (b - a) * std::exp(c * (1.0 - expx));
      56             :   }
      57        1296 : }
      58             : 
      59             : void
      60      223856 : PorousFlowPorosityExponentialBase::computeQpProperties()
      61             : {
      62      223856 :   const Real a = atNegInfinityQp();
      63      223856 :   const Real b = atZeroQp();
      64      223856 :   const Real decay = decayQp();
      65             : 
      66             :   Real deriv = 0.0; // = d(porosity)/d(decay)
      67      223856 :   if (decay <= 0.0 || !_ensure_positive)
      68             :   {
      69      425030 :     _porosity[_qp] = a + (b - a) * std::exp(decay);
      70      425030 :     deriv = _porosity[_qp] - a;
      71             :   }
      72             :   else
      73             :   {
      74       11341 :     const Real c = std::log(a / (a - b));
      75       11341 :     const Real expx = std::exp(-decay / c);
      76             :     // note that at decay = 0, we have expx = 1, so porosity = a + b - a = b
      77             :     // and at decay = infinity, expx = 0, so porosity = a + (b - a) * a / (a - b) = 0
      78       22682 :     _porosity[_qp] = a + (b - a) * std::exp(c * (1.0 - expx));
      79       22682 :     deriv = (_porosity[_qp] - a) * expx;
      80             :   }
      81             : 
      82      447712 :   _dporosity_dvar[_qp].resize(_num_var);
      83      447712 :   _dporosity_dgradvar[_qp].resize(_num_var);
      84     2082992 :   for (unsigned int v = 0; v < _num_var; ++v)
      85             :   {
      86     1859136 :     _dporosity_dvar[_qp][v] = ddecayQp_dvar(v) * deriv;
      87     2788704 :     _dporosity_dgradvar[_qp][v] = ddecayQp_dgradvar(v) * deriv;
      88             :   }
      89      226355 : }

Generated by: LCOV version 1.11