LCOV - code coverage report
Current view: top level - src/userobjects - PorousFlowDictator.C (source / functions) Hit Total Coverage
Test: porous_flow Test Coverage Lines: 44 46 95.7 %
Date: 2017-11-17 17:48:31 Functions: 14 14 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             : //  Holds maps between PorousFlow variables (porepressure, saturations) and the variable number used
       9             : //  by MOOSE.
      10             : #include "PorousFlowDictator.h"
      11             : #include "NonlinearSystem.h"
      12             : 
      13             : template <>
      14             : InputParameters
      15         252 : validParams<PorousFlowDictator>()
      16             : {
      17         252 :   InputParameters params = validParams<GeneralUserObject>();
      18         504 :   params.addClassDescription("Holds information on the PorousFlow variable names");
      19         756 :   params.addRequiredCoupledVar("porous_flow_vars",
      20             :                                "List of primary variables that are used in the PorousFlow "
      21             :                                "simulation.  Jacobian entries involving derivatives wrt these "
      22             :                                "variables will be computed.  In single-phase models you will just "
      23             :                                "have one (eg \'pressure\'), in two-phase models you will have two "
      24         252 :                                "(eg \'p_water p_gas\', or \'p_water s_water\'), etc.");
      25         756 :   params.addRequiredParam<unsigned int>("number_fluid_phases",
      26         252 :                                         "The number of fluid phases in the simulation");
      27         756 :   params.addRequiredParam<unsigned int>("number_fluid_components",
      28         252 :                                         "The number of fluid components in the simulation");
      29         252 :   return params;
      30             : }
      31             : 
      32         252 : PorousFlowDictator::PorousFlowDictator(const InputParameters & parameters)
      33             :   : GeneralUserObject(parameters),
      34             :     Coupleable(this, false),
      35             :     ZeroInterface(parameters),
      36         504 :     _num_variables(coupledComponents("porous_flow_vars")),
      37         756 :     _num_phases(getParam<unsigned int>("number_fluid_phases")),
      38        1764 :     _num_components(getParam<unsigned int>("number_fluid_components"))
      39             : {
      40         252 :   _moose_var_num.resize(_num_variables);
      41        1368 :   for (unsigned int i = 0; i < _num_variables; ++i)
      42        1674 :     _moose_var_num[i] = coupled("porous_flow_vars", i);
      43             : 
      44         252 :   _pf_var_num.assign(_fe_problem.getNonlinearSystemBase().nVariables(),
      45             :                      _num_variables); // Note: the _num_variables assignment indicates that "this is
      46             :                                       // not a PorousFlow variable"
      47         810 :   for (unsigned int i = 0; i < _num_variables; ++i)
      48        1674 :     if (_moose_var_num[i] < _pf_var_num.size())
      49         558 :       _pf_var_num[_moose_var_num[i]] = i;
      50             :     else
      51             :       // should not couple AuxVariables to the Dictator (Jacobian entries are not calculated for
      52             :       // them)
      53             :       mooseError("PorousFlowDictator: AuxVariables variables must not be coupled into the Dictator "
      54             :                  "for this is against specification #1984.  Variable number ",
      55             :                  i,
      56           0 :                  " is an AuxVariable.");
      57         252 : }
      58             : 
      59             : unsigned int
      60        6617 : PorousFlowDictator::numVariables() const
      61             : {
      62        6617 :   return _num_variables;
      63             : }
      64             : 
      65             : unsigned int
      66        8009 : PorousFlowDictator::numPhases() const
      67             : {
      68        8009 :   return _num_phases;
      69             : }
      70             : 
      71             : unsigned int
      72        5819 : PorousFlowDictator::numComponents() const
      73             : {
      74        5819 :   return _num_components;
      75             : }
      76             : 
      77             : unsigned int
      78   328253435 : PorousFlowDictator::porousFlowVariableNum(unsigned int moose_var_num) const
      79             : {
      80   984760305 :   if (moose_var_num >= _pf_var_num.size() || _pf_var_num[moose_var_num] == _num_variables)
      81             :     mooseError("The Dictator proclaims that the moose variable with number ",
      82             :                moose_var_num,
      83           0 :                " is not a PorousFlow variable.  Exiting with error code 1984.");
      84   328253435 :   return _pf_var_num[moose_var_num];
      85             : }
      86             : 
      87             : bool
      88    14370586 : PorousFlowDictator::isPorousFlowVariable(unsigned int moose_var_num) const
      89             : {
      90    14370586 :   return !notPorousFlowVariable(moose_var_num);
      91             : }
      92             : 
      93             : bool
      94   309488511 : PorousFlowDictator::notPorousFlowVariable(unsigned int moose_var_num) const
      95             : {
      96   927867678 :   return moose_var_num >= _pf_var_num.size() || _pf_var_num[moose_var_num] == _num_variables;
      97             : }
      98             : 
      99             : const VariableName
     100        3036 : PorousFlowDictator::pressureVariableNameDummy() const
     101             : {
     102        3036 :   return "pressure_variable_dummy";
     103             : }
     104             : 
     105             : const VariableName
     106        2676 : PorousFlowDictator::saturationVariableNameDummy() const
     107             : {
     108        2676 :   return "saturation_variable_dummy";
     109             : }
     110             : 
     111             : const VariableName
     112        3036 : PorousFlowDictator::temperatureVariableNameDummy() const
     113             : {
     114        3036 :   return "temperature_variable_dummy";
     115             : }
     116             : 
     117             : const VariableName
     118        1974 : PorousFlowDictator::massFractionVariableNameDummy() const
     119             : {
     120        1974 :   return "mass_fraction_variable_dummy";
     121        2499 : }

Generated by: LCOV version 1.11