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 : #pragma once 20 : 21 : #include "ExternalProblem.h" 22 : 23 : /** 24 : * Base class for all MOOSE wrappings in Cardinal 25 : */ 26 0 : class CardinalProblem : public ExternalProblem 27 : { 28 : public: 29 : CardinalProblem(const InputParameters & params); 30 : 31 : static InputParameters validParams(); 32 : 33 : /** 34 : * Check for duplicate entries in a 1-d vector 35 : * @param[in] var input vector 36 : * @param[in] name string to use for printing error message 37 : */ 38 : template <typename T> 39 5030 : void checkDuplicateEntries(const std::vector<T> & var, const std::string & name) const 40 : { 41 : std::set<T> set_var; 42 12082 : for (const auto & v : var) 43 : { 44 : if (set_var.count(v)) 45 8 : mooseError("Entries cannot be repeated in '" + name + "'!"); 46 7052 : set_var.insert(v); 47 : } 48 5026 : } 49 : 50 : /** 51 : * Check whether the user has already created a variable using one of the protected 52 : * names that the wrapping is using. 53 : * @param[in] name variable name 54 : */ 55 : void checkDuplicateVariableName(const std::string & name) const; 56 : 57 : /** 58 : * Whether a string ends in a particular sub-string 59 : * @param[in] full full string 60 : * @param[in] ending sub-string ending 61 : * @return whether full string has ending 62 : */ 63 : bool stringHasEnding(std::string const & full, std::string const & ending) const; 64 : };