[properties] replace macro calls by native C++

This commit is contained in:
Bernd Flemisch
2020-06-08 16:41:02 +02:00
parent 2e13e846ff
commit 880c5223ac
201 changed files with 3253 additions and 2436 deletions

View File

@@ -49,11 +49,14 @@ BEGIN_PROPERTIES
// +-> ImplicitModel
///////////////////////////////////
// Create new type tags
namespace TTag {
//! Type tag for all models.
NEW_TYPE_TAG(NumericModel, INHERITS_FROM(ParameterSystem));
struct NumericModel { using InheritsFrom = std::tuple<ParameterSystem>; };
//! Type tag for all fully coupled models.
NEW_TYPE_TAG(ImplicitModel, INHERITS_FROM(NumericModel));
struct ImplicitModel { using InheritsFrom = std::tuple<NumericModel>; };
} // end namespace TTag
///////////////////////////////////
// Property names which are always available:
@@ -62,39 +65,50 @@ NEW_TYPE_TAG(ImplicitModel, INHERITS_FROM(NumericModel));
///////////////////////////////////
//! Property to specify the type of scalar values.
NEW_PROP_TAG(Scalar);
template<class TypeTag, class MyTypeTag>
struct Scalar { using type = UndefinedProperty; };
//! Number of equations in the system of PDEs
NEW_PROP_TAG(NumEq);
template<class TypeTag, class MyTypeTag>
struct NumEq { using type = UndefinedProperty; };
//! Property which provides a Dune::ParameterTree.
NEW_PROP_TAG(ParameterTree);
template<class TypeTag, class MyTypeTag>
struct ParameterTree { using type = UndefinedProperty; };
//! The type of the model
NEW_PROP_TAG(Model);
template<class TypeTag, class MyTypeTag>
struct Model { using type = UndefinedProperty; };
//! Property which defines the group that is queried for parameters by default
NEW_PROP_TAG(ModelParameterGroup);
template<class TypeTag, class MyTypeTag>
struct ModelParameterGroup { using type = UndefinedProperty; };
//! Property which provides a Vanguard (manages grids)
NEW_PROP_TAG(Vanguard);
template<class TypeTag, class MyTypeTag>
struct Vanguard { using type = UndefinedProperty; };
//! The type of the DUNE grid
NEW_PROP_TAG(Grid);
template<class TypeTag, class MyTypeTag>
struct Grid { using type = UndefinedProperty; };
NEW_PROP_TAG(GridView);
template<class TypeTag, class MyTypeTag>
struct GridView { using type = UndefinedProperty; };
#if HAVE_DUNE_FEM
NEW_PROP_TAG(GridPart);
template<class TypeTag, class MyTypeTag>
struct GridPart { using type = UndefinedProperty; };
#endif
//! Property which tells the Vanguard how often the grid should be refined
//! after creation.
NEW_PROP_TAG(GridGlobalRefinements);
template<class TypeTag, class MyTypeTag>
struct GridGlobalRefinements { using type = UndefinedProperty; };
//! Property provides the name of the file from which the additional runtime
//! parameters should to be loaded from
NEW_PROP_TAG(ParameterFile);
template<class TypeTag, class MyTypeTag>
struct ParameterFile { using type = UndefinedProperty; };
/*!
* \brief Print all properties on startup?
@@ -102,7 +116,8 @@ NEW_PROP_TAG(ParameterFile);
* 0 means 'no', 1 means 'yes', 2 means 'print only to logfiles'. The
* default is 2.
*/
NEW_PROP_TAG(PrintProperties);
template<class TypeTag, class MyTypeTag>
struct PrintProperties { using type = UndefinedProperty; };
/*!
* \brief Print all parameters on startup?
@@ -110,38 +125,52 @@ NEW_PROP_TAG(PrintProperties);
* 0 means 'no', 1 means 'yes', 2 means 'print only to logfiles'. The
* default is 2.
*/
NEW_PROP_TAG(PrintParameters);
template<class TypeTag, class MyTypeTag>
struct PrintParameters { using type = UndefinedProperty; };
//! The default value for the simulation's end time
NEW_PROP_TAG(EndTime);
template<class TypeTag, class MyTypeTag>
struct EndTime { using type = UndefinedProperty; };
//! The default value for the simulation's initial time step size
NEW_PROP_TAG(InitialTimeStepSize);
template<class TypeTag, class MyTypeTag>
struct InitialTimeStepSize { using type = UndefinedProperty; };
//! The default value for the simulation's restart time
NEW_PROP_TAG(RestartTime);
template<class TypeTag, class MyTypeTag>
struct RestartTime { using type = UndefinedProperty; };
//! The name of the file with a number of forced time step lengths
NEW_PROP_TAG(PredeterminedTimeStepsFile);
template<class TypeTag, class MyTypeTag>
struct PredeterminedTimeStepsFile { using type = UndefinedProperty; };
//! domain size
NEW_PROP_TAG(DomainSizeX);
NEW_PROP_TAG(DomainSizeY);
NEW_PROP_TAG(DomainSizeZ);
template<class TypeTag, class MyTypeTag>
struct DomainSizeX { using type = UndefinedProperty; };
template<class TypeTag, class MyTypeTag>
struct DomainSizeY { using type = UndefinedProperty; };
template<class TypeTag, class MyTypeTag>
struct DomainSizeZ { using type = UndefinedProperty; };
//! grid resolution
NEW_PROP_TAG(CellsX);
NEW_PROP_TAG(CellsY);
NEW_PROP_TAG(CellsZ);
template<class TypeTag, class MyTypeTag>
struct CellsX { using type = UndefinedProperty; };
template<class TypeTag, class MyTypeTag>
struct CellsY { using type = UndefinedProperty; };
template<class TypeTag, class MyTypeTag>
struct CellsZ { using type = UndefinedProperty; };
//! name of the grid file
NEW_PROP_TAG(GridFile);
template<class TypeTag, class MyTypeTag>
struct GridFile { using type = UndefinedProperty; };
//! level of the grid view
NEW_PROP_TAG(GridViewLevel);
template<class TypeTag, class MyTypeTag>
struct GridViewLevel { using type = UndefinedProperty; };
//! Manages the simulation time
NEW_PROP_TAG(Simulator);
template<class TypeTag, class MyTypeTag>
struct Simulator { using type = UndefinedProperty; };
/*!
* \brief The class which marks the border indices associated with the
@@ -149,17 +178,20 @@ NEW_PROP_TAG(Simulator);
*
* This is required for the algebraic overlap stuff.
*/
NEW_PROP_TAG(BorderListCreator);
template<class TypeTag, class MyTypeTag>
struct BorderListCreator { using type = UndefinedProperty; };
///////////////////////////////////
// Values for the properties
///////////////////////////////////
//! Set the default type of scalar values to double
SET_TYPE_PROP(NumericModel, Scalar, double);
template<class TypeTag>
struct Scalar<TypeTag, TTag::NumericModel> { using type = double; };
//! Set the ParameterTree property
SET_PROP(NumericModel, ParameterTree)
template<class TypeTag>
struct ParameterTree<TypeTag, TTag::NumericModel>
{
typedef Dune::ParameterTree type;
@@ -177,19 +209,22 @@ SET_STRING_PROP(NumericModel, ModelParameterGroup, "");
SET_STRING_PROP(NumericModel, GridFile, "");
#if HAVE_DUNE_FEM
SET_PROP(NumericModel, GridPart)
template<class TypeTag>
struct GridPart<TypeTag, TTag::NumericModel>
{
typedef typename GET_PROP_TYPE(TypeTag, Grid) Grid;
typedef GetPropType<TypeTag, Properties::Grid> Grid;
typedef Dune::Fem::AdaptiveLeafGridPart<Grid> type;
};
SET_TYPE_PROP(NumericModel, GridView, typename GET_PROP_TYPE(TypeTag, GridPart)::GridViewType);
template<class TypeTag>
struct GridView<TypeTag, TTag::NumericModel> { using type = typename GetPropType<TypeTag, Properties::GridPart>::GridViewType; };
#else
//! Use the leaf grid view by default.
//!
//! Except for spatial refinement, there is rarly a reason to use
//! anything else...
SET_TYPE_PROP(NumericModel, GridView, typename GET_PROP_TYPE(TypeTag, Grid)::LeafGridView);
template<class TypeTag>
struct GridView<TypeTag, TTag::NumericModel> { using type = typename GetPropType<TypeTag, Properties::Grid>::LeafGridView; };
#endif
//! Set a value for the ParameterFile property
@@ -197,13 +232,16 @@ SET_STRING_PROP(NumericModel, ParameterFile, "");
//! Set the number of refinement levels of the grid to 0. This does not belong
//! here, strictly speaking.
SET_INT_PROP(NumericModel, GridGlobalRefinements, 0);
template<class TypeTag>
struct GridGlobalRefinements<TypeTag, TTag::NumericModel> { static constexpr int value = 0; };
//! By default, print the properties on startup
SET_INT_PROP(NumericModel, PrintProperties, 2);
template<class TypeTag>
struct PrintProperties<TypeTag, TTag::NumericModel> { static constexpr int value = 2; };
//! By default, print the values of the run-time parameters on startup
SET_INT_PROP(NumericModel, PrintParameters, 2);
template<class TypeTag>
struct PrintParameters<TypeTag, TTag::NumericModel> { static constexpr int value = 2; };
//! The default value for the simulation's end time
SET_SCALAR_PROP(NumericModel, EndTime, -1e35);

View File

@@ -75,7 +75,7 @@
*/
#define EWOMS_REGISTER_PARAM(TypeTag, ParamType, ParamName, Description) \
::Opm::Parameters::registerParam<TypeTag, ParamType>( \
#ParamName, #ParamName, GET_PROP_VALUE(TypeTag, ParamName), Description)
#ParamName, #ParamName, getPropValue<TypeTag, Properties::ParamName>(), Description)
/*!
* \ingroup Parameter
@@ -85,7 +85,7 @@
* This allows to deal with unused parameters
*/
#define EWOMS_HIDE_PARAM(TypeTag, ParamName) \
::Opm::Parameters::hideParam<TypeTag>(#ParamName, GET_PROP_VALUE(TypeTag, ParamName))
::Opm::Parameters::hideParam<TypeTag>(#ParamName, getPropValue<TypeTag, Properties::ParamName>())
/*!
* \ingroup Parameter
@@ -116,12 +116,12 @@
*/
#define EWOMS_GET_PARAM(TypeTag, ParamType, ParamName) \
(::Opm::Parameters::get<TypeTag, ParamType>(#ParamName, #ParamName, \
GET_PROP_VALUE(TypeTag, ParamName)))
getPropValue<TypeTag, Properties::ParamName>()))
//!\cond SKIP_THIS
#define EWOMS_GET_PARAM_(TypeTag, ParamType, ParamName) \
(::Opm::Parameters::get<TypeTag, ParamType>(#ParamName, #ParamName, \
GET_PROP_VALUE(TypeTag, ParamName), \
getPropValue<TypeTag, Properties::ParamName>(), \
/*errorIfNotRegistered=*/false))
/*!
@@ -227,11 +227,13 @@ BEGIN_PROPERTIES
// parameter system is to be used
NEW_TYPE_TAG(ParameterSystem);
NEW_PROP_TAG(ParameterMetaData);
template<class TypeTag, class MyTypeTag>
struct ParameterMetaData { using type = UndefinedProperty; };
//! Set the ParameterMetaData property
SET_PROP(ParameterSystem, ParameterMetaData)
template<class TypeTag>
struct ParameterMetaData<TypeTag, TTag::ParameterSystem>
{
typedef Dune::ParameterTree type;

View File

@@ -254,18 +254,6 @@ void printValues(std::ostream& os = std::cout)
}
}
/*!
* \ingroup Properties
* \brief Indicates that property definitions follow
*/
#define BEGIN_PROPERTIES namespace Opm { namespace Properties {
/*!
* \ingroup Properties
* \brief Indicates that all properties have been specified (for now)
*/
#define END_PROPERTIES }}
} // end namespace Opm
// remove this after release 2020.10 to disable macros per default

View File

@@ -375,4 +375,16 @@ SET_PROP_(EffTypeTagName, \
} // namespace Properties
} // namespace Opm
#endif // OPM_PROPERTY_SYSTEM_HH
/*!
* \ingroup Properties
* \brief Indicates that property definitions follow
*/
#define BEGIN_PROPERTIES namespace Opm { namespace Properties {
/*!
* \ingroup Properties
* \brief Indicates that all properties have been specified (for now)
*/
#define END_PROPERTIES }}
#endif // OPM_PROPERTY_SYSTEM_MACROS_HH

View File

@@ -89,11 +89,11 @@ namespace Opm {
template <class TypeTag>
class Simulator
{
typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
typedef typename GET_PROP_TYPE(TypeTag, Vanguard) Vanguard;
typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
typedef typename GET_PROP_TYPE(TypeTag, Model) Model;
typedef typename GET_PROP_TYPE(TypeTag, Problem) Problem;
typedef GetPropType<TypeTag, Properties::Scalar> Scalar;
typedef GetPropType<TypeTag, Properties::Vanguard> Vanguard;
typedef GetPropType<TypeTag, Properties::GridView> GridView;
typedef GetPropType<TypeTag, Properties::Model> Model;
typedef GetPropType<TypeTag, Properties::Problem> Problem;
public:
// do not allow to copy simulators around
@@ -973,7 +973,8 @@ private:
};
namespace Properties {
SET_TYPE_PROP(NumericModel, Simulator, Opm::Simulator<TypeTag>);
template<class TypeTag>
struct Simulator<TypeTag, TTag::NumericModel> { using type = Opm::Simulator<TypeTag>; };
}
} // namespace Opm

View File

@@ -78,8 +78,8 @@ namespace Opm {
template <class TypeTag>
static inline void registerAllParameters_(bool finalizeRegistration = true)
{
typedef typename GET_PROP_TYPE(TypeTag, Simulator) Simulator;
typedef typename GET_PROP_TYPE(TypeTag, ThreadManager) ThreadManager;
typedef GetPropType<TypeTag, Properties::Simulator> Simulator;
typedef GetPropType<TypeTag, Properties::ThreadManager> ThreadManager;
EWOMS_REGISTER_PARAM(TypeTag, std::string, ParameterFile,
"An .ini file which contains a set of run-time "
@@ -114,7 +114,7 @@ static inline int setupParameters_(int argc,
bool allowUnused=false,
bool handleHelp = true)
{
typedef typename GET_PROP_TYPE(TypeTag, Problem) Problem;
typedef GetPropType<TypeTag, Properties::Problem> Problem;
// first, get the MPI rank of the current process
int myRank = 0;
@@ -280,10 +280,10 @@ static inline void resetTerminal_(int signum)
template <class TypeTag>
static inline int start(int argc, char **argv, bool registerParams=true)
{
typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
typedef typename GET_PROP_TYPE(TypeTag, Simulator) Simulator;
typedef typename GET_PROP_TYPE(TypeTag, Problem) Problem;
typedef typename GET_PROP_TYPE(TypeTag, ThreadManager) ThreadManager;
typedef GetPropType<TypeTag, Properties::Scalar> Scalar;
typedef GetPropType<TypeTag, Properties::Simulator> Simulator;
typedef GetPropType<TypeTag, Properties::Problem> Problem;
typedef GetPropType<TypeTag, Properties::ThreadManager> ThreadManager;
// set the signal handlers to reset the TTY to a well defined state on unexpected
// program aborts