Line data Source code
1 : /********************************************************************/ 2 : /* SOFTWARE COPYRIGHT NOTIFICATION */ 3 : /* Cardinal */ 4 : /* */ 5 : /* (c) 2021 UChicago Argonne, LLC */ 6 : /* ALL RIGHTS RESERVED */ 7 : /* */ 8 : /* Prepared by UChicago Argonne, LLC */ 9 : /* Under Contract No. DE-AC02-06CH11357 */ 10 : /* With the U. S. Department of Energy */ 11 : /* */ 12 : /* Prepared by Battelle Energy Alliance, LLC */ 13 : /* Under Contract No. DE-AC07-05ID14517 */ 14 : /* With the U. S. Department of Energy */ 15 : /* */ 16 : /* See LICENSE for full restrictions */ 17 : /********************************************************************/ 18 : 19 : #include "UserErrorChecking.h" 20 : #include "CardinalApp.h" 21 : 22 : void 23 516 : checkUnusedParam(const InputParameters & p, 24 : const std::vector<std::string> & names, 25 : const std::string & explanation, 26 : const bool error) 27 : { 28 4104 : for (const auto & n : names) 29 3588 : checkUnusedParam(p, n, explanation, error); 30 516 : } 31 : 32 : void 33 31188 : checkUnusedParam(const InputParameters & p, 34 : const std::string & name, 35 : const std::string & explanation, 36 : const bool error) 37 : { 38 31188 : if (p.isParamSetByUser(name)) 39 : { 40 180 : if (error) 41 3 : mooseError("When " + explanation + ", the '" + name + "' parameter is unused!"); 42 : else 43 535 : mooseWarning("When " + explanation + ", the '" + name + "' parameter is unused!"); 44 : } 45 31185 : } 46 : 47 : void 48 75 : checkRequiredParam(const InputParameters & p, 49 : const std::vector<std::string> & names, 50 : const std::string & explanation) 51 : { 52 375 : for (const auto & n : names) 53 300 : checkRequiredParam(p, n, explanation); 54 75 : } 55 : 56 : void 57 4600 : checkRequiredParam(const InputParameters & p, 58 : const std::string & name, 59 : const std::string & explanation) 60 : { 61 4600 : if (!p.isParamValid(name)) 62 18 : mooseError("When " + explanation + ", the '" + name + "' parameter is required!"); 63 4594 : } 64 : 65 : void 66 881 : checkJointParams(const InputParameters & p, 67 : const std::vector<std::string> & name, 68 : const std::string & explanation) 69 : { 70 : bool at_least_one_present = false; 71 : bool at_least_one_not_present = false; 72 881 : std::string name_list = ""; 73 : 74 2643 : for (const auto & s : name) 75 : { 76 1762 : name_list += " '" + s + "',"; 77 : 78 1762 : if (p.isParamValid(s)) 79 : at_least_one_present = true; 80 : else 81 : at_least_one_not_present = true; 82 : } 83 : 84 881 : if (at_least_one_present && at_least_one_not_present) 85 : { 86 0 : name_list.pop_back(); 87 0 : mooseError("When " + explanation + ", the" + name_list + 88 : " parameters\nmust either ALL " 89 : "be specified or ALL omitted; you have only provided a subset of parameters!"); 90 : } 91 881 : } 92 : 93 : #ifdef ENABLE_OPENMC_COUPLING 94 : void 95 24525247 : catchOpenMCError(const int & err, const std::string descriptor) 96 : { 97 24525247 : if (err) 98 8 : mooseError( 99 8 : "In attempting to ", descriptor, ", OpenMC reported:\n\n", std::string(openmc_err_msg)); 100 24525239 : } 101 : #endif