LCOV - code coverage report
Current view: top level - src/materials - PorousFlowJoiner.C (source / functions) Hit Total Coverage
Test: porous_flow Test Coverage Lines: 61 61 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 "PorousFlowJoiner.h"
       9             : #include "Conversion.h"
      10             : 
      11             : template <>
      12             : InputParameters
      13         658 : validParams<PorousFlowJoiner>()
      14             : {
      15         658 :   InputParameters params = validParams<PorousFlowMaterialVectorBase>();
      16        1974 :   params.addRequiredParam<std::string>("material_property",
      17         658 :                                        "The property that you want joined into a std::vector");
      18        1974 :   params.addParam<bool>(
      19         658 :       "include_old", false, "Join old properties into vectors as well as the current properties");
      20        1316 :   params.addClassDescription("This Material forms a std::vector of properties, old properties "
      21             :                              "(optionally), and derivatives, out of the individual phase "
      22         658 :                              "properties");
      23         658 :   return params;
      24             : }
      25             : 
      26        1974 : PorousFlowJoiner::PorousFlowJoiner(const InputParameters & parameters)
      27             :   : PorousFlowMaterialVectorBase(parameters),
      28             : 
      29        1974 :     _pressure_variable_name(_dictator.pressureVariableNameDummy()),
      30        1974 :     _saturation_variable_name(_dictator.saturationVariableNameDummy()),
      31        1974 :     _temperature_variable_name(_dictator.temperatureVariableNameDummy()),
      32        1974 :     _mass_fraction_variable_name(_dictator.massFractionVariableNameDummy()),
      33             :     _pf_prop(getParam<std::string>("material_property")),
      34        5922 :     _include_old(getParam<bool>("include_old")),
      35             : 
      36        3948 :     _dporepressure_dvar(!_nodal_material ? getMaterialProperty<std::vector<std::vector<Real>>>(
      37        3216 :                                                "dPorousFlow_porepressure_qp_dvar")
      38             :                                          : getMaterialProperty<std::vector<std::vector<Real>>>(
      39        4680 :                                                "dPorousFlow_porepressure_nodal_dvar")),
      40        3948 :     _dsaturation_dvar(!_nodal_material ? getMaterialProperty<std::vector<std::vector<Real>>>(
      41        3216 :                                              "dPorousFlow_saturation_qp_dvar")
      42             :                                        : getMaterialProperty<std::vector<std::vector<Real>>>(
      43        4680 :                                              "dPorousFlow_saturation_nodal_dvar")),
      44             :     _dtemperature_dvar(
      45        1974 :         !_nodal_material
      46        5922 :             ? getMaterialProperty<std::vector<Real>>("dPorousFlow_temperature_qp_dvar")
      47        4680 :             : getMaterialProperty<std::vector<Real>>("dPorousFlow_temperature_nodal_dvar")),
      48             : 
      49        1974 :     _property(declareProperty<std::vector<Real>>(_pf_prop)),
      50       33558 :     _dproperty_dvar(declareProperty<std::vector<std::vector<Real>>>("d" + _pf_prop + "_dvar"))
      51             : {
      52        1974 :   _phase_property.resize(_num_phases);
      53        1974 :   _dphase_property_dp.resize(_num_phases);
      54        1974 :   _dphase_property_ds.resize(_num_phases);
      55        1974 :   _dphase_property_dt.resize(_num_phases);
      56             : 
      57        4497 :   for (unsigned int ph = 0; ph < _num_phases; ++ph)
      58             :   {
      59        2523 :     std::string phase = Moose::stringify(ph);
      60        7569 :     _phase_property[ph] = &getMaterialProperty<Real>(_pf_prop + phase);
      61        5046 :     _dphase_property_dp[ph] =
      62       10092 :         &getMaterialPropertyDerivative<Real>(_pf_prop + phase, _pressure_variable_name);
      63        5046 :     _dphase_property_ds[ph] =
      64       10092 :         &getMaterialPropertyDerivative<Real>(_pf_prop + phase, _saturation_variable_name);
      65        5046 :     _dphase_property_dt[ph] =
      66       10092 :         &getMaterialPropertyDerivative<Real>(_pf_prop + phase, _temperature_variable_name);
      67             :   }
      68        1974 : }
      69             : 
      70             : void
      71    16731996 : PorousFlowJoiner::initQpStatefulProperties()
      72             : {
      73    33463992 :   _property[_qp].resize(_num_phases);
      74             : 
      75    53870272 :   for (unsigned int ph = 0; ph < _num_phases; ++ph)
      76    55707414 :     _property[_qp][ph] = (*_phase_property[ph])[_qp];
      77    16731996 : }
      78             : 
      79             : void
      80    16372508 : PorousFlowJoiner::computeQpProperties()
      81             : {
      82    16372508 :   initQpStatefulProperties();
      83             : 
      84    32745016 :   _dproperty_dvar[_qp].resize(_num_phases);
      85    52767968 :   for (unsigned int ph = 0; ph < _num_phases; ++ph)
      86             :   {
      87    36395460 :     _dproperty_dvar[_qp][ph].resize(_num_var);
      88    89698930 :     for (unsigned v = 0; v < _num_var; ++v)
      89             :     {
      90             :       // the "if" conditions in the following are because a nodal_material's derivatives might
      91             :       // not have been defined.  If that is the case, then DerivativeMaterial passes back a
      92             :       // MaterialProperty with zeroes (for the derivatives), but that property will be sized
      93             :       // by the number of quadpoints in the element, which may be smaller than the number of
      94             :       // nodes!
      95    71501200 :       _dproperty_dvar[_qp][ph][v] = 0.0;
      96    35750600 :       if ((*_dphase_property_dp[ph]).size() > _qp)
      97    70568376 :         _dproperty_dvar[_qp][ph][v] +=
      98   141136752 :             (*_dphase_property_dp[ph])[_qp] * _dporepressure_dvar[_qp][ph][v];
      99    35750600 :       if ((*_dphase_property_ds[ph]).size() > _qp)
     100    68837248 :         _dproperty_dvar[_qp][ph][v] +=
     101   137674496 :             (*_dphase_property_ds[ph])[_qp] * _dsaturation_dvar[_qp][ph][v];
     102    35750600 :       if ((*_dphase_property_dt[ph]).size() > _qp)
     103   141136752 :         _dproperty_dvar[_qp][ph][v] += (*_dphase_property_dt[ph])[_qp] * _dtemperature_dvar[_qp][v];
     104             :     }
     105             :   }
     106    16375007 : }

Generated by: LCOV version 1.11