From 048943620d5eac5be779000539fd34ce3bb6b78c Mon Sep 17 00:00:00 2001 From: Timo Koch <timo.koch@iws.uni-stuttgart.de> Date: Tue, 3 Nov 2015 10:11:06 +0100 Subject: [PATCH] [parameters] Don't check consistent type for parameter macro The check was turned on for debug purposes and exited with an error if the same parameter was read into object of different type. This is not an error. For reading vectors it is even an important feature that it's possible to read it into different types of containers depending on the usage. Reviewed by martins --- dumux/common/parameters.hh | 55 -------------------------------------- 1 file changed, 55 deletions(-) diff --git a/dumux/common/parameters.hh b/dumux/common/parameters.hh index 926624b3d9..a7c0608167 100644 --- a/dumux/common/parameters.hh +++ b/dumux/common/parameters.hh @@ -267,24 +267,6 @@ public: static const ParamType &getRuntime(const char *groupOrParamName, const char *paramNameOrNil = 0) { -#ifndef NDEBUG - // make sure that the parameter is used consistently. since - // this is potentially quite expensive, it is only done if - // debugging code is not explicitly turned off. - const char *paramName, *groupName; - static const std::string propertyName(""); - if (paramNameOrNil && strlen(paramNameOrNil) > 0) { - groupName = groupOrParamName; - paramName = paramNameOrNil; - } - else { - groupName = ""; - paramName = groupOrParamName; - } - - check_(Dune::className<ParamType>(), propertyName, groupName, paramName); -#endif - return retrieveRuntime_<ParamType>(groupOrParamName, paramNameOrNil); } @@ -303,36 +285,6 @@ private: } }; - static void check_(const std::string ¶mTypeName, - const std::string &propertyName, - const char *groupName, - const char *paramName) - { - typedef std::unordered_map<std::string, Blubb> StaticData; - static StaticData staticData; - - typename StaticData::iterator it = staticData.find(paramName); - Blubb *b; - if (it == staticData.end()) - { - Blubb a; - a.propertyName = propertyName; - a.paramTypeName = paramTypeName; - a.groupName = groupName; - staticData[paramName] = a; - b = &staticData[paramName]; - } - else - b = &(it->second); - - if (b->paramTypeName != paramTypeName && b->groupName == groupName) { - DUNE_THROW(Dune::InvalidStateException, - "GET_*_PARAM for parameter '" << paramName << "' in group '" - << groupName << "' called with at least two different types (" - << b->paramTypeName << " and " << paramTypeName << ")"); - } - } - template <class ParamType, class PropTag> static const ParamType &retrieve_(const char *propertyName, const char *groupOrParamName, @@ -348,13 +300,6 @@ private: paramName = groupOrParamName; } -#ifndef NDEBUG - // make sure that the parameter is used consistently. since - // this is potentially quite expensive, it is only done if - // debugging code is not explicitly turned off. - check_(Dune::className<ParamType>(), propertyName, groupName, paramName); -#endif - // prefix the parameter name by 'GroupName.'. E.g. 'Newton' // and 'WriteConvergence' becomes 'Newton.WriteConvergence' // with the default value specified by the -- GitLab