LCOV - code coverage report
Current view: top level - src/userobjects - PorousFlowDictator.C (source / functions) Hit Total Coverage
Test: idaholab/moose porous_flow: #33380 (547b29) with base 8581c3 Lines: 75 76 98.7 %
Date: 2026-07-20 19:40:36 Functions: 15 15 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://mooseframework.inl.gov
       3             : //*
       4             : //* All rights reserved, see COPYRIGHT for full restrictions
       5             : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
       6             : //*
       7             : //* Licensed under LGPL 2.1, please see LICENSE for details
       8             : //* https://www.gnu.org/licenses/lgpl-2.1.html
       9             : 
      10             : #include "PorousFlowDictator.h"
      11             : #include "NonlinearSystem.h"
      12             : 
      13             : registerMooseObject("PorousFlowApp", PorousFlowDictator);
      14             : 
      15             : InputParameters
      16       10228 : PorousFlowDictator::validParams()
      17             : {
      18       10228 :   InputParameters params = GeneralUserObject::validParams();
      19       10228 :   params.addClassDescription("Holds information on the PorousFlow variable names");
      20       20456 :   params.addRequiredCoupledVar("porous_flow_vars",
      21             :                                "List of primary variables that are used in the PorousFlow "
      22             :                                "simulation.  Jacobian entries involving derivatives wrt these "
      23             :                                "variables will be computed.  In single-phase models you will just "
      24             :                                "have one (eg \'pressure\'), in two-phase models you will have two "
      25             :                                "(eg \'p_water p_gas\', or \'p_water s_water\'), etc.");
      26       20456 :   params.addRequiredParam<unsigned int>("number_fluid_phases",
      27             :                                         "The number of fluid phases in the simulation");
      28       20456 :   params.addRequiredParam<unsigned int>("number_fluid_components",
      29             :                                         "The number of fluid components in the simulation");
      30       20456 :   params.addParam<unsigned int>("number_aqueous_equilibrium",
      31       20456 :                                 0,
      32             :                                 "The number of secondary species in the aqueous-equilibrium "
      33             :                                 "reaction system.  (Leave as zero if the simulation does not "
      34             :                                 "involve chemistry)");
      35       20456 :   params.addParam<unsigned int>("number_aqueous_kinetic",
      36       20456 :                                 0,
      37             :                                 "The number of secondary species in the aqueous-kinetic reaction "
      38             :                                 "system involved in precipitation and dissolution.  (Leave as zero "
      39             :                                 "if the simulation does not involve chemistry)");
      40       20456 :   params.addParam<unsigned int>("aqueous_phase_number",
      41       20456 :                                 0,
      42             :                                 "The fluid phase number of the aqueous phase in which the "
      43             :                                 "equilibrium and kinetic chemical reactions occur");
      44             : 
      45       20456 :   params.addParam<SolverSystemName>("solver_sys", "Name of the solver system for the porepressure");
      46       20456 :   params.addParamNamesToGroup("solver_sys", "Advanced");
      47       10228 :   return params;
      48           0 : }
      49             : 
      50        5116 : PorousFlowDictator::PorousFlowDictator(const InputParameters & parameters)
      51             :   : GeneralUserObject(parameters),
      52             :     Coupleable(this, false),
      53        5116 :     _num_variables(coupledComponents("porous_flow_vars")),
      54       10232 :     _num_phases(getParam<unsigned int>("number_fluid_phases")),
      55       10232 :     _num_components(getParam<unsigned int>("number_fluid_components")),
      56       10232 :     _num_aqueous_equilibrium(getParam<unsigned int>("number_aqueous_equilibrium")),
      57       10232 :     _num_aqueous_kinetic(getParam<unsigned int>("number_aqueous_kinetic")),
      58       10232 :     _aqueous_phase_number(getParam<unsigned int>("aqueous_phase_number")),
      59        5116 :     _consistent_fe_type(false),
      60             :     _fe_type(0),
      61       10232 :     _is_fv(false)
      62             : {
      63        5116 :   _moose_var_num.resize(_num_variables);
      64       13695 :   for (unsigned int i = 0; i < _num_variables; ++i)
      65        8579 :     _moose_var_num[i] = coupled("porous_flow_vars", i);
      66             : 
      67        5116 :   if (_num_variables > 0)
      68             :   {
      69        4188 :     _consistent_fe_type = true;
      70        4188 :     _is_fv = getFieldVar("porous_flow_vars", 0)->isFV();
      71        4188 :     _fe_type = FEType(getFieldVar("porous_flow_vars", 0)->feType());
      72        8579 :     for (unsigned int i = 1; i < _num_variables; ++i)
      73        8782 :       if (getFieldVar("porous_flow_vars", i)->feType() != _fe_type)
      74         136 :         _consistent_fe_type = false;
      75             :   }
      76             : 
      77        5116 :   _pf_var_num.assign(_sys.nVariables(),
      78        5116 :                      _num_variables); // Note: the _num_variables assignment indicates that "this is
      79             :                                       // not a PorousFlow variable"
      80       13692 :   for (unsigned int i = 0; i < _num_variables; ++i)
      81             :   {
      82        8577 :     if (_moose_var_num[i] < _pf_var_num.size())
      83        8576 :       _pf_var_num[_moose_var_num[i]] = i;
      84             :     else
      85             :       // should not couple AuxVariables to the Dictator (Jacobian entries are not calculated for
      86             :       // them)
      87           1 :       mooseError("PorousFlowDictator: AuxVariables variables must not be coupled into the Dictator "
      88             :                  "for this is against specification #1984.  Variable '",
      89           1 :                  coupledName("porous_flow_vars", /*comp=*/i),
      90             :                  "' is either an AuxVariable or from a different nonlinear system.");
      91             :   }
      92             : 
      93        5115 :   if ((_num_phases > 0) && (_aqueous_phase_number >= _num_phases))
      94           3 :     mooseError("PorousflowDictator: The aqueous phase number must be less than the number of fluid "
      95             :                "phases.  The Dictator does not appreciate jokes.");
      96             : 
      97             :   // Don't include permeabiity derivatives in the Jacobian by default (overwrite using
      98             :   // usePermDerivs()) when necessary in permeabiity material classes
      99        5112 :   _perm_derivs = false;
     100        5120 : }
     101             : 
     102             : unsigned int
     103     3893033 : PorousFlowDictator::numVariables() const
     104             : {
     105     3893033 :   return _num_variables;
     106             : }
     107             : 
     108             : unsigned int
     109      228752 : PorousFlowDictator::numPhases() const
     110             : {
     111      228752 :   return _num_phases;
     112             : }
     113             : 
     114             : unsigned int
     115      176998 : PorousFlowDictator::numComponents() const
     116             : {
     117      176998 :   return _num_components;
     118             : }
     119             : 
     120             : unsigned int
     121         315 : PorousFlowDictator::numAqueousEquilibrium() const
     122             : {
     123         315 :   return _num_aqueous_equilibrium;
     124             : }
     125             : 
     126             : unsigned int
     127     5926564 : PorousFlowDictator::numAqueousKinetic() const
     128             : {
     129     5926564 :   return _num_aqueous_kinetic;
     130             : }
     131             : 
     132             : unsigned int
     133        6452 : PorousFlowDictator::aqueousPhaseNumber() const
     134             : {
     135        6452 :   return _aqueous_phase_number;
     136             : }
     137             : 
     138             : unsigned int
     139  3994397790 : PorousFlowDictator::porousFlowVariableNum(unsigned int moose_var_num) const
     140             : {
     141  3994397790 :   if (moose_var_num >= _pf_var_num.size() || _pf_var_num[moose_var_num] == _num_variables)
     142           4 :     mooseError("The Dictator proclaims that the moose variable with number ",
     143             :                moose_var_num,
     144             :                " is not a PorousFlow variable.  Exiting with error code 1984.");
     145  3994397786 :   return _pf_var_num[moose_var_num];
     146             : }
     147             : 
     148             : unsigned int
     149     2473998 : PorousFlowDictator::mooseVariableNum(unsigned int porous_flow_var_num) const
     150             : {
     151     2473998 :   if (porous_flow_var_num >= _num_variables)
     152           1 :     mooseError("The Dictator proclaims that there is no such PorousFlow variable with number ",
     153             :                porous_flow_var_num,
     154             :                ".  Exiting with error code 1984.");
     155     2473997 :   return _moose_var_num[porous_flow_var_num];
     156             : }
     157             : 
     158             : bool
     159   139337434 : PorousFlowDictator::isPorousFlowVariable(unsigned int moose_var_num) const
     160             : {
     161   139337434 :   return !notPorousFlowVariable(moose_var_num);
     162             : }
     163             : 
     164             : bool
     165  3652754468 : PorousFlowDictator::notPorousFlowVariable(unsigned int moose_var_num) const
     166             : {
     167  3652754468 :   return moose_var_num >= _pf_var_num.size() || _pf_var_num[moose_var_num] == _num_variables;
     168             : }
     169             : 
     170             : bool
     171         557 : PorousFlowDictator::consistentFEType() const
     172             : {
     173         557 :   return _consistent_fe_type;
     174             : }
     175             : 
     176             : FEType
     177         562 : PorousFlowDictator::feType() const
     178             : {
     179         562 :   return _fe_type;
     180             : }
     181             : 
     182             : bool
     183        1920 : PorousFlowDictator::isFV() const
     184             : {
     185        1920 :   return _is_fv;
     186             : }

Generated by: LCOV version 1.14