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 : // Holds maps between Richards variables (porepressure, saturations) and the variable number used 11 : // by MOOSE. 12 : // 13 : #include "RichardsVarNames.h" 14 : 15 : registerMooseObject("RichardsApp", RichardsVarNames); 16 : 17 : InputParameters 18 622 : RichardsVarNames::validParams() 19 : { 20 622 : InputParameters params = GeneralUserObject::validParams(); 21 622 : params.addClassDescription("Holds information on the porepressure variable names"); 22 1244 : params.addRequiredCoupledVar("richards_vars", 23 : "List of variables that represent the porepressures or " 24 : "(porepressure, saturations). In single-phase models you will just " 25 : "have one (eg \'pressure\'), in two-phase models you will have two " 26 : "(eg \'p_water p_gas\', or \'p_water s_water\', etc. These names " 27 : "must also be used in your kernels and material."); 28 1244 : MooseEnum var_types("pppp", "pppp"); 29 1244 : params.addParam<MooseEnum>( 30 : "var_types", 31 : var_types, 32 : "Variable types for the problem. Eg, 'pppp' means all the variables are pressure variables"); 33 : 34 622 : return params; 35 622 : } 36 : 37 308 : RichardsVarNames::RichardsVarNames(const InputParameters & parameters) 38 : : GeneralUserObject(parameters), 39 : Coupleable(this, false), 40 308 : _num_v(coupledComponents("richards_vars")), 41 616 : _var_types(getParam<MooseEnum>("var_types")), 42 616 : _moose_var_num(coupledIndices("richards_vars")), 43 308 : _moose_var_value(coupledValues("richards_vars")), 44 616 : _moose_var_value_old(_is_transient ? coupledValuesOld("richards_vars") 45 308 : : std::vector<const VariableValue *>(_num_v, &_zero)), 46 616 : _moose_grad_var(coupledGradients("richards_vars")) 47 : { 48 : unsigned int max_moose_var_num_seen = 0; 49 : 50 308 : _moose_nodal_var_value.resize(_num_v); 51 308 : _moose_nodal_var_value_old.resize(_num_v); 52 715 : for (unsigned int i = 0; i < _num_v; ++i) 53 : { 54 : max_moose_var_num_seen = 55 407 : (max_moose_var_num_seen > _moose_var_num[i] ? max_moose_var_num_seen : _moose_var_num[i]); 56 407 : _moose_nodal_var_value[i] = &coupledDofValues("richards_vars", i); // coupledDofValues returns 57 : // a reference (an alias) to 58 : // a VariableValue, and the 59 : // & turns it into a pointer 60 407 : _moose_nodal_var_value_old[i] = 61 724 : (_is_transient ? &coupledDofValuesOld("richards_vars", i) : &_zero); 62 : } 63 : 64 308 : _ps_var_num.resize(max_moose_var_num_seen + 1); 65 715 : for (unsigned int i = 0; i < max_moose_var_num_seen + 1; ++i) 66 407 : _ps_var_num[i] = _num_v; // NOTE: indicates that i is not a richards variable 67 715 : for (unsigned int i = 0; i < _num_v; ++i) 68 407 : _ps_var_num[_moose_var_num[i]] = i; 69 308 : } 70 : 71 : void 72 4653 : RichardsVarNames::initialize() 73 : { 74 4653 : } 75 : 76 : void 77 4653 : RichardsVarNames::execute() 78 : { 79 4653 : } 80 : 81 : void 82 4653 : RichardsVarNames::finalize() 83 : { 84 4653 : } 85 : 86 : unsigned int 87 1151 : RichardsVarNames::num_v() const 88 : { 89 1151 : return _num_v; 90 : } 91 : 92 : unsigned int 93 12371900 : RichardsVarNames::richards_var_num(unsigned int moose_var_num) const 94 : { 95 12371900 : if (moose_var_num >= _ps_var_num.size() || _ps_var_num[moose_var_num] == _num_v) 96 0 : mooseError("The moose variable with number ", 97 : moose_var_num, 98 : " is not a richards according to the RichardsVarNames UserObject"); 99 12371900 : return _ps_var_num[moose_var_num]; 100 : } 101 : 102 : bool 103 12210594 : RichardsVarNames::not_richards_var(unsigned int moose_var_num) const 104 : { 105 12210594 : if (moose_var_num >= _ps_var_num.size() || _ps_var_num[moose_var_num] == _num_v) 106 2 : return true; 107 : return false; 108 : } 109 : 110 : const VariableValue * 111 2209591 : RichardsVarNames::richards_vals(unsigned int richards_var_num) const 112 : { 113 2209591 : return _moose_var_value[richards_var_num]; // moose_var_value is a vector of pointers to 114 : // VariableValuees 115 : } 116 : 117 : const VariableValue * 118 2209591 : RichardsVarNames::richards_vals_old(unsigned int richards_var_num) const 119 : { 120 2209591 : return _moose_var_value_old[richards_var_num]; 121 : } 122 : 123 : const VariableGradient * 124 2209591 : RichardsVarNames::grad_var(unsigned int richards_var_num) const 125 : { 126 2209591 : return _moose_grad_var[richards_var_num]; 127 : } 128 : 129 : std::string 130 7784090 : RichardsVarNames::var_types() const 131 : { 132 7784090 : return _var_types; 133 : } 134 : 135 : const VariableValue * 136 365 : RichardsVarNames::nodal_var(unsigned int richards_var_num) const 137 : { 138 365 : return _moose_nodal_var_value[richards_var_num]; 139 : } 140 : 141 : const VariableValue * 142 109 : RichardsVarNames::nodal_var_old(unsigned int richards_var_num) const 143 : { 144 109 : return _moose_nodal_var_value_old[richards_var_num]; 145 : }