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 : #ifdef ENABLE_OPENMC_COUPLING 20 : 21 : #include "TallyInterface.h" 22 : 23 : #include "UserErrorChecking.h" 24 : 25 : InputParameters 26 9499 : TallyInterface::validParams() 27 : { 28 9499 : InputParameters params = OpenMCBase::validParams(); 29 9499 : return params; 30 : } 31 : 32 5135 : TallyInterface::TallyInterface(const ParallelParamObject * object, 33 5135 : const InputParameters & parameters) 34 5135 : : OpenMCBase(object, parameters), _object(object) 35 : { 36 5133 : } 37 : 38 : std::string 39 332 : TallyInterface::getScore(const std::string & score_param) 40 : { 41 332 : std::string score = _object->getParam<MooseEnum>(score_param); 42 : std::replace(score.begin(), score.end(), '_', '-'); 43 : 44 332 : if (!_openmc_problem->hasScore(score)) 45 16 : _object->paramError(score_param, 46 8 : "The problem does not contain any score named " + 47 0 : std::string(_object->getParam<MooseEnum>(score_param)) + 48 : "! Please ensure that one of your [Tallies] is " 49 : "accumulating the requested score."); 50 : 51 324 : return score; 52 : } 53 : 54 : std::string 55 102 : TallyInterface::tallyByScore(const std::string & score, const std::string & tally_param) 56 : { 57 102 : if (_openmc_problem->getNumScoringTallies(score) == 0) 58 0 : _object->mooseError("No tallies are adding a " + score + " score!"); 59 : 60 : // When the problem has more then one tally accumulating the given score, the user needs to tell 61 : // us which one to use. 62 : std::string tally_name; 63 102 : if (_openmc_problem->getNumScoringTallies(score) > 1) 64 : { 65 62 : checkRequiredParam(_object->parameters(), 66 : tally_param, 67 62 : "adding more than one tally with " + score + " in the [Tallies] block"); 68 : 69 60 : tally_name = _object->getParam<std::string>(tally_param); 70 60 : const auto * tally = _openmc_problem->getTally(tally_name); 71 60 : if (!tally) 72 2 : _object->paramError(tally_param, "This tally does not exist in the [Tallies] block!"); 73 : 74 58 : if (!tally->hasScore(score)) 75 4 : _object->paramError(tally_param, "This tally does not score " + score + "!"); 76 : } 77 : else 78 : { 79 40 : const auto & all_tallies = _openmc_problem->getLocalTallies(); 80 86 : for (const auto & t : all_tallies) 81 46 : if (t->hasScore(score)) 82 : tally_name = t->name(); 83 : } 84 : 85 96 : return tally_name; 86 : } 87 : 88 : #endif