diff --git a/cmake/Modules/UseOnlyNeeded.cmake b/cmake/Modules/UseOnlyNeeded.cmake index fe8246bf..16f3d078 100644 --- a/cmake/Modules/UseOnlyNeeded.cmake +++ b/cmake/Modules/UseOnlyNeeded.cmake @@ -4,11 +4,23 @@ # in order to get only the minimal set of dependencies. function (prepend var_name value) - if (${var_name}) - set (${var_name} "${value} ${${var_name}}" PARENT_SCOPE) - else (${var_name}) - set (${var_name} "${value}") - endif (${var_name}) + # only add the prefix if it is not already at the beginning. this + # prevents the same string to be added at the same place every time + # we check for reconfiguration (e.g. "--as-needed" below) + string (LENGTH "${value}" _val_len) + string (LENGTH "${${var_name}}" _var_len) + if (NOT (${_var_len} LESS ${_val_len})) + string (SUBSTRING "${${var_name}}" 0 ${_val_len} _var_pre) + else (NOT (${_var_len} LESS ${_val_len})) + set (_var_pre) + endif (NOT (${_var_len} LESS ${_val_len})) + if (NOT ("${_var_pre}" STREQUAL "${value}")) + if (${var_name}) + set (${var_name} "${value} ${${var_name}}" PARENT_SCOPE) + else (${var_name}) + set (${var_name} "${value}") + endif (${var_name}) + endif (NOT ("${_var_pre}" STREQUAL "${value}")) endfunction (prepend var_name value) # only ELF shared objects can be underlinked, and only GNU will accept diff --git a/opm/core/io/eclipse/EclipseGridParser.cpp b/opm/core/io/eclipse/EclipseGridParser.cpp index 78693232..c33d6fd7 100644 --- a/opm/core/io/eclipse/EclipseGridParser.cpp +++ b/opm/core/io/eclipse/EclipseGridParser.cpp @@ -101,7 +101,8 @@ namespace EclipseKeywords string("DEPTHZ"), string("TOPS"), string("MAPAXES"), string("SWCR"), string("SWL"), string("SWU"), string("SOWCR"), string("KRW"), string("KRWR"), - string("KRO"), string("KRORW"), string("NTG") + string("KRO"), string("KRORW"), string("NTG"), + string("RHO") }; const int num_floating_fields = sizeof(floating_fields) / sizeof(floating_fields[0]); @@ -561,7 +562,8 @@ void EclipseGridParser::convertToSI() key == "SGAS" || key == "SWAT" || key == "SOIL" || key == "NTG" || key == "SWCR" || key == "SWL" || key == "SWU" || key == "SOWCR" || key == "KRW" || - key == "KRWR" || key == "KRORW" || key == "KRO") { + key == "KRWR" || key == "KRORW" || key == "KRO" || + key == "RHO") /* nonstandard field with no unit logic. use with caution */ { unit = 1.0; do_convert = false; // Dimensionless keywords... } else if (key == "PRESSURE") { diff --git a/opm/core/pressure/fsh.h b/opm/core/pressure/fsh.h index 8e71e9c4..08cfebc5 100644 --- a/opm/core/pressure/fsh.h +++ b/opm/core/pressure/fsh.h @@ -18,7 +18,7 @@ */ #ifndef OPM_FSH_HEADER_INCLUDED -#define OPM_FHS_HEADER_INCLUDED +#define OPM_FSH_HEADER_INCLUDED /** * \file diff --git a/opm/core/utility/PropertySystem.hpp b/opm/core/utility/PropertySystem.hpp index dc624400..bd81ff44 100644 --- a/opm/core/utility/PropertySystem.hpp +++ b/opm/core/utility/PropertySystem.hpp @@ -790,61 +790,33 @@ struct propertyDefinedOnSelf PropertyTag> >::value; }; - // template class to revert the order or a std::tuple's // arguments. This is required to make the properties of children // defined on the right overwrite the properties of the previous -// children. this is not a very nice solution, but it works... -template -struct RevertedTuple; +// children. See https://sydius.me/2011/07/reverse-tuple-in-c/ +template +class RevertedTuple +{ +private: + template + struct RevertedTupleOuter + { + template + struct RevertedTupleInner: RevertedTupleOuter::template RevertedTupleInner { }; + }; -template <> -struct RevertedTuple<> -{ typedef std::tuple<> type; }; + template + struct RevertedTupleOuter<0, All...> + { + template + struct RevertedTupleInner { + typedef std::tuple type; + }; + }; -template -struct RevertedTuple -{ typedef std::tuple type; }; - -template -struct RevertedTuple -{ typedef std::tuple type; }; - -template -struct RevertedTuple -{ typedef std::tuple type; }; - -template -struct RevertedTuple -{ typedef std::tuple type; }; - -template -struct RevertedTuple -{ typedef std::tuple type; }; - -template -struct RevertedTuple -{ typedef std::tuple type; }; - -template -struct RevertedTuple -{ typedef std::tuple type; }; - -template -struct RevertedTuple -{ typedef std::tuple type; }; - -template -struct RevertedTuple -{ typedef std::tuple type; }; - -template -struct RevertedTuple -{ typedef std::tuple type; }; - -template -struct RevertedTuple -{ typedef std::tuple type; }; +public: + typedef typename RevertedTupleOuter::template RevertedTupleInner::type type; +}; template @@ -867,146 +839,109 @@ struct Splices }; } // namespace PTag -// retrieve a property which is not defined on a splice -template -struct GetDirectProperty_ -{ - // set the ::type attribute to the type tag for which the - // requested property was defined. First check whether the - // property is directly defined for the type tag, and if not, - // check all splices, then check all children - template ::value > - struct GetEffectiveTypeTag_; - - // set the ::type attribute to the child type tag for which the - // requested property was defined. The first child is ignored. - template - struct TraverseRemainingChildren_; - - // if the first argument != void this is the value of the ::type member, ... - template - struct StopAtFirstChildElseTraverseRemaining_ - { typedef EffTypeTag type; }; - - // ... or else the type tag is defined by the remaining children - template - struct StopAtFirstChildElseTraverseRemaining_ - { typedef typename TraverseRemainingChildren_ >::type type; }; - - // set the ::type attribute to the type tag to the child for which - // the requested property was defined, or ... - template - struct TraverseRemainingChildren_ > - { typedef typename StopAtFirstChildElseTraverseRemaining_::type, RemainingChildren...>::type type; }; - - // ... if there there are no children which we did not check - // anymore, the ::type attribute is void (i.e. the property was - // not defined for a given subtree) - template - struct TraverseRemainingChildren_ > - { typedef void type; }; - - template - struct GetEffectiveTypeTag_ - { typedef CurTree type; }; - - template - struct GetEffectiveTypeTag_ - { typedef typename TraverseRemainingChildren_::type type; }; - -public: - typedef Property::type, PropertyTag> p; -}; - template struct GetProperty { - // set the ::type attribute to the type tag for which the - // requested property was defined. First check whether the - // property is directly defined for the type tag, and if not, - // check all splices, then check all children - template ::value > + template ::value> struct GetEffectiveTypeTag_; - // set the ::type attribute to the child type tag for which the - // requested property was defined. The first child is ignored. - template - struct TraverseRemainingChildren_; + template + struct SearchTypeTagList_; - // set the ::type attribute to the type tag for which the - // requested property was defined. First check all splices of the - // type tag, then check all children. The first splice is ignored. - template - struct TraverseRemainingSplicesAndChildren_; + template + struct SearchTypeTagList_FirstThenRemaining_; - // if the first argument != void this is the value of the ::type member, ... - template - struct StopAtFirstChildElseTraverseRemaining_ - { typedef EffTypeTag type; }; + template + struct SearchSpliceList_; - // ... or else the type tag is defined by the remaining children - template - struct StopAtFirstChildElseTraverseRemaining_ - { typedef typename TraverseRemainingChildren_ >::type type; }; + template + struct SearchSpliceList_FirstThenRemaining_; - // set the ::type attribute to the type tag to the child for which - // the requested property was defined, or ... - template - struct TraverseRemainingChildren_ > - { typedef typename StopAtFirstChildElseTraverseRemaining_::type, RemainingChildren...>::type type; }; - - // ... if there there are no children which we did not check - // anymore, the ::type attribute is void (i.e. the property was - // not defined for a given subtree) - template - struct TraverseRemainingChildren_ > + // find the first type tag in a tuple for which the property is + // defined + template + struct SearchTypeTagTuple_ { typedef void type; }; - template - struct StopAtSpliceIfPropDefinedElseTraverseRemaining_ - { typedef EffTypeTag type; }; + template + struct SearchTypeTagTuple_ > + { typedef typename SearchTypeTagList_::type type; }; - template - struct StopAtSpliceIfPropDefinedElseTraverseRemaining_ - { typedef typename TraverseRemainingSplicesAndChildren_ >::type type; }; + template + struct SearchTypeTagList_ + { typedef void type; }; - // if the property was defined for the current splice, stop - // here. If not... - template - struct StopAtFirstSpliceElseTraverseRemaining_ - { typedef typename StopAtSpliceIfPropDefinedElseTraverseRemaining_::type, - RemainingSplices...>::type type; }; + template + struct SearchTypeTagList_ + { + typedef typename SearchTypeTagList_FirstThenRemaining_< + typename GetEffectiveTypeTag_::type, + RemainingElements...>::type type; + }; - // ... check the remaining splices. - template - struct StopAtFirstSpliceElseTraverseRemaining_ - { typedef typename TraverseRemainingSplicesAndChildren_ >::type type; }; + template + struct SearchTypeTagList_FirstThenRemaining_ + { typedef EffectiveTypeTag type; }; - // check whether the property is defined on the remaining splices - // of a list (i.e. discard its first member) ... - template - struct TraverseRemainingSplicesAndChildren_ > - { typedef typename StopAtFirstSpliceElseTraverseRemaining_, RemainingSplices...>::type type; }; + template + struct SearchTypeTagList_FirstThenRemaining_ + { typedef typename SearchTypeTagList_::type type; }; - // ... or if there are no splices left to check, proceed with the - // children of the type tag. - template - struct TraverseRemainingSplicesAndChildren_ > - { typedef typename TraverseRemainingChildren_::type type; }; + // find the first type tag in a tuple of splices for which the + // property is defined + template + struct SearchSpliceTuple_ + { typedef void type; }; + + template + struct SearchSpliceTuple_ > + { typedef typename SearchSpliceList_::type type; }; + + template + struct SearchSpliceList_ + { typedef void type; }; + + template + struct SearchSpliceList_ + { + typedef typename SearchSpliceList_FirstThenRemaining_< + typename GetEffectiveTypeTag_::p::type>::type, + RemainingSplices...>::type type; + }; + + template + struct SearchSpliceList_FirstThenRemaining_ + { typedef EffectiveTypeTag type; }; + + template + struct SearchSpliceList_FirstThenRemaining_ + { typedef typename SearchSpliceList_::type type; }; + + // find the splice or the child type tag for which the property is defined + template ::tuple >::type > + struct SearchSplicesThenChildren_ + { typedef SpliceTypeTag type; }; template - struct GetEffectiveTypeTag_ - { typedef CurTree type; }; + struct SearchSplicesThenChildren_ + { typedef typename SearchTypeTagTuple_::type type; }; + + // find the type tag for which the property is defined + template + struct GetEffectiveTypeTag_ + { typedef typename CurTree::SelfType type; }; template - struct GetEffectiveTypeTag_ - { typedef typename TraverseRemainingSplicesAndChildren_::tuple >::type type; }; + struct GetEffectiveTypeTag_ + { typedef typename SearchSplicesThenChildren_::type type; }; public: typedef Property::type, PropertyTag> p; - typedef typename GetEffectiveTypeTag_::type q; }; #if !defined NO_PROPERTY_INTROSPECTION