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 9992 : PorousFlowDictator::validParams() 17 : { 18 9992 : InputParameters params = GeneralUserObject::validParams(); 19 9992 : params.addClassDescription("Holds information on the PorousFlow variable names"); 20 19984 : 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 19984 : params.addRequiredParam<unsigned int>("number_fluid_phases", 27 : "The number of fluid phases in the simulation"); 28 19984 : params.addRequiredParam<unsigned int>("number_fluid_components", 29 : "The number of fluid components in the simulation"); 30 19984 : params.addParam<unsigned int>("number_aqueous_equilibrium", 31 19984 : 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 19984 : params.addParam<unsigned int>("number_aqueous_kinetic", 36 19984 : 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 19984 : params.addParam<unsigned int>("aqueous_phase_number", 41 19984 : 0, 42 : "The fluid phase number of the aqueous phase in which the " 43 : "equilibrium and kinetic chemical reactions occur"); 44 : 45 19984 : params.addParam<SolverSystemName>("solver_sys", "Name of the solver system for the porepressure"); 46 19984 : params.addParamNamesToGroup("solver_sys", "Advanced"); 47 9992 : return params; 48 0 : } 49 : 50 4998 : PorousFlowDictator::PorousFlowDictator(const InputParameters & parameters) 51 : : GeneralUserObject(parameters), 52 : Coupleable(this, false), 53 4998 : _num_variables(coupledComponents("porous_flow_vars")), 54 9996 : _num_phases(getParam<unsigned int>("number_fluid_phases")), 55 9996 : _num_components(getParam<unsigned int>("number_fluid_components")), 56 9996 : _num_aqueous_equilibrium(getParam<unsigned int>("number_aqueous_equilibrium")), 57 9996 : _num_aqueous_kinetic(getParam<unsigned int>("number_aqueous_kinetic")), 58 9996 : _aqueous_phase_number(getParam<unsigned int>("aqueous_phase_number")), 59 4998 : _consistent_fe_type(false), 60 4998 : _fe_type(0) 61 : { 62 4998 : _moose_var_num.resize(_num_variables); 63 13387 : for (unsigned int i = 0; i < _num_variables; ++i) 64 8389 : _moose_var_num[i] = coupled("porous_flow_vars", i); 65 : 66 4998 : if (_num_variables > 0) 67 : { 68 4070 : _consistent_fe_type = true; 69 4070 : _fe_type = FEType(getFieldVar("porous_flow_vars", 0)->feType()); 70 8389 : for (unsigned int i = 1; i < _num_variables; ++i) 71 8638 : if (getFieldVar("porous_flow_vars", i)->feType() != _fe_type) 72 136 : _consistent_fe_type = false; 73 : } 74 : 75 4998 : _pf_var_num.assign(_sys.nVariables(), 76 4998 : _num_variables); // Note: the _num_variables assignment indicates that "this is 77 : // not a PorousFlow variable" 78 13384 : for (unsigned int i = 0; i < _num_variables; ++i) 79 : { 80 8387 : if (_moose_var_num[i] < _pf_var_num.size()) 81 8386 : _pf_var_num[_moose_var_num[i]] = i; 82 : else 83 : // should not couple AuxVariables to the Dictator (Jacobian entries are not calculated for 84 : // them) 85 1 : mooseError("PorousFlowDictator: AuxVariables variables must not be coupled into the Dictator " 86 : "for this is against specification #1984. Variable '", 87 1 : coupledName("porous_flow_vars", /*comp=*/i), 88 : "' is either an AuxVariable or from a different nonlinear system."); 89 : } 90 : 91 4997 : if ((_num_phases > 0) && (_aqueous_phase_number >= _num_phases)) 92 3 : mooseError("PorousflowDictator: The aqueous phase number must be less than the number of fluid " 93 : "phases. The Dictator does not appreciate jokes."); 94 : 95 : // Don't include permeabiity derivatives in the Jacobian by default (overwrite using 96 : // usePermDerivs()) when necessary in permeabiity material classes 97 4994 : _perm_derivs = false; 98 5002 : } 99 : 100 : unsigned int 101 3890645 : PorousFlowDictator::numVariables() const 102 : { 103 3890645 : return _num_variables; 104 : } 105 : 106 : unsigned int 107 224216 : PorousFlowDictator::numPhases() const 108 : { 109 224216 : return _num_phases; 110 : } 111 : 112 : unsigned int 113 173384 : PorousFlowDictator::numComponents() const 114 : { 115 173384 : return _num_components; 116 : } 117 : 118 : unsigned int 119 315 : PorousFlowDictator::numAqueousEquilibrium() const 120 : { 121 315 : return _num_aqueous_equilibrium; 122 : } 123 : 124 : unsigned int 125 5926564 : PorousFlowDictator::numAqueousKinetic() const 126 : { 127 5926564 : return _num_aqueous_kinetic; 128 : } 129 : 130 : unsigned int 131 6452 : PorousFlowDictator::aqueousPhaseNumber() const 132 : { 133 6452 : return _aqueous_phase_number; 134 : } 135 : 136 : unsigned int 137 3994425852 : PorousFlowDictator::porousFlowVariableNum(unsigned int moose_var_num) const 138 : { 139 3994425852 : if (moose_var_num >= _pf_var_num.size() || _pf_var_num[moose_var_num] == _num_variables) 140 4 : mooseError("The Dictator proclaims that the moose variable with number ", 141 : moose_var_num, 142 : " is not a PorousFlow variable. Exiting with error code 1984."); 143 3994425848 : return _pf_var_num[moose_var_num]; 144 : } 145 : 146 : unsigned int 147 2475102 : PorousFlowDictator::mooseVariableNum(unsigned int porous_flow_var_num) const 148 : { 149 2475102 : if (porous_flow_var_num >= _num_variables) 150 1 : mooseError("The Dictator proclaims that there is no such PorousFlow variable with number ", 151 : porous_flow_var_num, 152 : ". Exiting with error code 1984."); 153 2475101 : return _moose_var_num[porous_flow_var_num]; 154 : } 155 : 156 : bool 157 139767451 : PorousFlowDictator::isPorousFlowVariable(unsigned int moose_var_num) const 158 : { 159 139767451 : return !notPorousFlowVariable(moose_var_num); 160 : } 161 : 162 : bool 163 3653193647 : PorousFlowDictator::notPorousFlowVariable(unsigned int moose_var_num) const 164 : { 165 3653193647 : return moose_var_num >= _pf_var_num.size() || _pf_var_num[moose_var_num] == _num_variables; 166 : } 167 : 168 : bool 169 557 : PorousFlowDictator::consistentFEType() const 170 : { 171 557 : return _consistent_fe_type; 172 : } 173 : 174 : FEType 175 562 : PorousFlowDictator::feType() const 176 : { 177 562 : return _fe_type; 178 : }