From ee7f4242b54d79618f7d9243b9dd3b23a852b6c1 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Tue, 10 Dec 2013 21:01:22 +0100 Subject: [PATCH 1/4] Only add linker option if it is not really there This code is run unconditionally each time we do a reconfigure; if the option is added at each time, they will accumulate (needlessly) on the command-line, making it harder to inspect the log. --- cmake/Modules/UseOnlyNeeded.cmake | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) 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 From 34e26ae5bcfd41419cd4be2b6bbad4ef4a8def4d Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Wed, 11 Dec 2013 17:26:24 +0100 Subject: [PATCH 2/4] Property system: some simplifications and bugfixes this simplifies the template meta programming a bit. (Which does not mean that it suddenly gets easy.) The main motivation for this work is to make the splices feature work properly which allows eWoms to properly select the spatial discretization at any point. Further, the number of type tags a node can inherit from now is truely unlimited thanks the the generic tuple reversal class provided by https://sydius.me/2011/07/reverse-tuple-in-c/ . (before, the maximum number of nodes from which a type tag could inherit was 11, so this limitation did not really matter in practice.) --- opm/core/utility/PropertySystem.hpp | 269 +++++++++++----------------- 1 file changed, 102 insertions(+), 167 deletions(-) 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 From f1ba3d4b70807bc8444cadd013bcf4e65df627cb Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Thu, 12 Dec 2013 12:43:30 +0100 Subject: [PATCH 3/4] added: nonstandard 'RHO' field in eclipse grid parser note that as this is a nonstandard field, there is no unit conversion handling. use with caution --- opm/core/io/eclipse/EclipseGridParser.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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") { From b66041999270a1dd18eb55fbb821d3ec6c65a3c9 Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Sun, 15 Dec 2013 18:10:27 +0100 Subject: [PATCH 4/4] fix typo in guard macro of fsh.h on CLang 3.4 svn this produced ``` /home/erne/src/opm-core/opm/core/pressure/fsh.h:20:9: warning: 'OPM_FSH_HEADER_INCLUDED' is used as a header guard here, followed by #define of a different macro [-Wheader-guard] ``` which is correct... --- opm/core/pressure/fsh.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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