mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Parameters::registerParam: pass Property struct and use parameter type from its definition
This commit is contained in:
parent
8b02ba2efc
commit
069161bd84
@ -41,13 +41,15 @@
|
|||||||
#include <dune/common/classname.hh>
|
#include <dune/common/classname.hh>
|
||||||
#include <dune/common/parametertree.hh>
|
#include <dune/common/parametertree.hh>
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <list>
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <type_traits>
|
||||||
#include <fstream>
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -71,8 +73,8 @@
|
|||||||
* \endcode
|
* \endcode
|
||||||
*/
|
*/
|
||||||
#define EWOMS_REGISTER_PARAM(TypeTag, ParamType, ParamName, Description) \
|
#define EWOMS_REGISTER_PARAM(TypeTag, ParamType, ParamName, Description) \
|
||||||
::Opm::Parameters::registerParam<TypeTag, ParamType>( \
|
::Opm::Parameters::registerParam<TypeTag, Properties::ParamName>( \
|
||||||
#ParamName, getPropValue<TypeTag, Properties::ParamName>(), Description)
|
#ParamName, Description)
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \ingroup Parameter
|
* \ingroup Parameter
|
||||||
@ -1102,14 +1104,18 @@ bool isSet(const char* paramName, bool errorIfNotRegistered = true)
|
|||||||
errorIfNotRegistered);
|
errorIfNotRegistered);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class TypeTag, class ParamType>
|
template <class TypeTag, template<class,class> class Param>
|
||||||
void registerParam(const char* paramName, const ParamType& defaultValue, const char* usageString)
|
void registerParam(const char* paramName, const char* usageString)
|
||||||
{
|
{
|
||||||
using ParamsMeta = GetProp<TypeTag, Properties::ParameterMetaData>;
|
using ParamsMeta = GetProp<TypeTag, Properties::ParameterMetaData>;
|
||||||
if (!ParamsMeta::registrationOpen())
|
if (!ParamsMeta::registrationOpen())
|
||||||
throw std::logic_error("Parameter registration was already closed before "
|
throw std::logic_error("Parameter registration was already closed before "
|
||||||
"the parameter '"+std::string(paramName)+"' was registered.");
|
"the parameter '"+std::string(paramName)+"' was registered.");
|
||||||
|
|
||||||
|
const auto defaultValue = getPropValue<TypeTag, Param>();
|
||||||
|
using ParamType = std::conditional_t<std::is_same_v<decltype(defaultValue),
|
||||||
|
const char* const>, std::string,
|
||||||
|
std::remove_const_t<decltype(defaultValue)>>;
|
||||||
ParamsMeta::registrationFinalizers().emplace_back(
|
ParamsMeta::registrationFinalizers().emplace_back(
|
||||||
new ParamRegFinalizer_<TypeTag, ParamType>(paramName, defaultValue));
|
new ParamRegFinalizer_<TypeTag, ParamType>(paramName, defaultValue));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user