Merge remote-tracking branch 'upstream/master' into opm-parser-integrate

This commit is contained in:
Joakim Hove 2013-12-16 16:58:22 +01:00
commit 42d058c6db
4 changed files with 124 additions and 175 deletions

View File

@ -4,11 +4,23 @@
# in order to get only the minimal set of dependencies. # in order to get only the minimal set of dependencies.
function (prepend var_name value) function (prepend var_name value)
if (${var_name}) # only add the prefix if it is not already at the beginning. this
set (${var_name} "${value} ${${var_name}}" PARENT_SCOPE) # prevents the same string to be added at the same place every time
else (${var_name}) # we check for reconfiguration (e.g. "--as-needed" below)
set (${var_name} "${value}") string (LENGTH "${value}" _val_len)
endif (${var_name}) 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) endfunction (prepend var_name value)
# only ELF shared objects can be underlinked, and only GNU will accept # only ELF shared objects can be underlinked, and only GNU will accept

View File

@ -101,7 +101,8 @@ namespace EclipseKeywords
string("DEPTHZ"), string("TOPS"), string("MAPAXES"), string("DEPTHZ"), string("TOPS"), string("MAPAXES"),
string("SWCR"), string("SWL"), string("SWU"), string("SWCR"), string("SWL"), string("SWU"),
string("SOWCR"), string("KRW"), string("KRWR"), 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]); 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 == "SGAS" || key == "SWAT" || key == "SOIL" ||
key == "NTG" || key == "SWCR" || key == "SWL" || key == "NTG" || key == "SWCR" || key == "SWL" ||
key == "SWU" || key == "SOWCR" || key == "KRW" || 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; unit = 1.0;
do_convert = false; // Dimensionless keywords... do_convert = false; // Dimensionless keywords...
} else if (key == "PRESSURE") { } else if (key == "PRESSURE") {

View File

@ -18,7 +18,7 @@
*/ */
#ifndef OPM_FSH_HEADER_INCLUDED #ifndef OPM_FSH_HEADER_INCLUDED
#define OPM_FHS_HEADER_INCLUDED #define OPM_FSH_HEADER_INCLUDED
/** /**
* \file * \file

View File

@ -790,61 +790,33 @@ struct propertyDefinedOnSelf
PropertyTag> >::value; PropertyTag> >::value;
}; };
// template class to revert the order or a std::tuple's // template class to revert the order or a std::tuple's
// arguments. This is required to make the properties of children // arguments. This is required to make the properties of children
// defined on the right overwrite the properties of the previous // defined on the right overwrite the properties of the previous
// children. this is not a very nice solution, but it works... // children. See https://sydius.me/2011/07/reverse-tuple-in-c/
template <class ... Args> template<typename... Args>
struct RevertedTuple; class RevertedTuple
{
private:
template<uint N, typename... All>
struct RevertedTupleOuter
{
template<typename Head, typename... Tail>
struct RevertedTupleInner: RevertedTupleOuter<N-1, Head, All...>::template RevertedTupleInner<Tail...> { };
};
template <> template<typename... All>
struct RevertedTuple<> struct RevertedTupleOuter<0, All...>
{ typedef std::tuple<> type; }; {
template<typename... Tail>
struct RevertedTupleInner {
typedef std::tuple<All...> type;
};
};
template <class Arg1> public:
struct RevertedTuple<Arg1> typedef typename RevertedTupleOuter<sizeof...(Args)>::template RevertedTupleInner<Args...>::type type;
{ typedef std::tuple<Arg1> type; }; };
template <class Arg1, class Arg2>
struct RevertedTuple<Arg1, Arg2>
{ typedef std::tuple<Arg2, Arg1> type; };
template <class Arg1, class Arg2, class Arg3>
struct RevertedTuple<Arg1, Arg2, Arg3>
{ typedef std::tuple<Arg3, Arg2, Arg1> type; };
template <class Arg1, class Arg2, class Arg3, class Arg4>
struct RevertedTuple<Arg1, Arg2, Arg3, Arg4>
{ typedef std::tuple<Arg4, Arg3, Arg2, Arg1> type; };
template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5>
struct RevertedTuple<Arg1, Arg2, Arg3, Arg4, Arg5>
{ typedef std::tuple<Arg5, Arg4, Arg3, Arg2, Arg1> type; };
template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6>
struct RevertedTuple<Arg1, Arg2, Arg3, Arg4, Arg5, Arg6>
{ typedef std::tuple<Arg6, Arg5, Arg4, Arg3, Arg2, Arg1> type; };
template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7>
struct RevertedTuple<Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7>
{ typedef std::tuple<Arg7, Arg6, Arg5, Arg4, Arg3, Arg2, Arg1> type; };
template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7, class Arg8>
struct RevertedTuple<Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8>
{ typedef std::tuple<Arg8, Arg7, Arg6, Arg5, Arg4, Arg3, Arg2, Arg1> type; };
template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7, class Arg8, class Arg9>
struct RevertedTuple<Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9>
{ typedef std::tuple<Arg9, Arg8, Arg7, Arg6, Arg5, Arg4, Arg3, Arg2, Arg1> type; };
template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7, class Arg8, class Arg9, class Arg10>
struct RevertedTuple<Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9, Arg10>
{ typedef std::tuple<Arg10, Arg9, Arg8, Arg7, Arg6, Arg5, Arg4, Arg3, Arg2, Arg1> type; };
template <class Arg1, class Arg2, class Arg3, class Arg4, class Arg5, class Arg6, class Arg7, class Arg8, class Arg9, class Arg10, class Arg11>
struct RevertedTuple<Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9, Arg10, Arg11>
{ typedef std::tuple<Arg11, Arg10, Arg9, Arg8, Arg7, Arg6, Arg5, Arg4, Arg3, Arg2, Arg1> type; };
template <class SelfT, template <class SelfT,
typename ... Children> typename ... Children>
@ -867,146 +839,109 @@ struct Splices
}; };
} // namespace PTag } // namespace PTag
// retrieve a property which is not defined on a splice
template <class TypeTag, class PropertyTag>
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 <class CurTree, bool definedOnSelf = propertyDefinedOnSelf<TypeTag, CurTree, PropertyTag>::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 <class Dummy, class ChildrenTuple>
struct TraverseRemainingChildren_;
// if the first argument != void this is the value of the ::type member, ...
template <class EffTypeTag, class ... RemainingChildren>
struct StopAtFirstChildElseTraverseRemaining_
{ typedef EffTypeTag type; };
// ... or else the type tag is defined by the remaining children
template <class ... RemainingChildren>
struct StopAtFirstChildElseTraverseRemaining_<void, RemainingChildren...>
{ typedef typename TraverseRemainingChildren_</*dummy=*/void, std::tuple<RemainingChildren...> >::type type; };
// set the ::type attribute to the type tag to the child for which
// the requested property was defined, or ...
template <class Dummy, class CurChild, class ... RemainingChildren>
struct TraverseRemainingChildren_<Dummy, std::tuple<CurChild, RemainingChildren...> >
{ typedef typename StopAtFirstChildElseTraverseRemaining_<typename GetEffectiveTypeTag_<CurChild>::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 <class Dummy>
struct TraverseRemainingChildren_<Dummy, std::tuple<> >
{ typedef void type; };
template <class CurTree>
struct GetEffectiveTypeTag_<CurTree, /*definedOnSelf=*/true>
{ typedef CurTree type; };
template <class CurTree>
struct GetEffectiveTypeTag_<CurTree, /*definedOnSelf=*/false>
{ typedef typename TraverseRemainingChildren_<CurTree, typename CurTree::ChildrenTuple >::type type; };
public:
typedef Property<TypeTag, typename GetEffectiveTypeTag_<TypeTag>::type, PropertyTag> p;
};
template <class TypeTag, class PropertyTag> template <class TypeTag, class PropertyTag>
struct GetProperty struct GetProperty
{ {
// set the ::type attribute to the type tag for which the template <class CurTree,
// requested property was defined. First check whether the bool directlyDefined =
// property is directly defined for the type tag, and if not, propertyDefinedOnSelf<TypeTag,
// check all splices, then check all children CurTree,
template <class CurTree, bool definedOnSelf = propertyDefinedOnSelf<TypeTag, CurTree, PropertyTag>::value > PropertyTag>::value>
struct GetEffectiveTypeTag_; struct GetEffectiveTypeTag_;
// set the ::type attribute to the child type tag for which the template <class ...Elements>
// requested property was defined. The first child is ignored. struct SearchTypeTagList_;
template <class Dummy, class ChildrenTuple>
struct TraverseRemainingChildren_;
// set the ::type attribute to the type tag for which the template <class EffectiveTypeTag, class ...Elements>
// requested property was defined. First check all splices of the struct SearchTypeTagList_FirstThenRemaining_;
// type tag, then check all children. The first splice is ignored.
template <class CurTree, class SpliceTuple>
struct TraverseRemainingSplicesAndChildren_;
// if the first argument != void this is the value of the ::type member, ... template <class ...SpliceList>
template <class EffTypeTag, class ... RemainingChildren> struct SearchSpliceList_;
struct StopAtFirstChildElseTraverseRemaining_
{ typedef EffTypeTag type; };
// ... or else the type tag is defined by the remaining children template <class EffectiveTypeTag, class ...Splices>
template <class ... RemainingChildren> struct SearchSpliceList_FirstThenRemaining_;
struct StopAtFirstChildElseTraverseRemaining_<void, RemainingChildren...>
{ typedef typename TraverseRemainingChildren_</*dummy=*/void, std::tuple<RemainingChildren...> >::type type; };
// set the ::type attribute to the type tag to the child for which // find the first type tag in a tuple for which the property is
// the requested property was defined, or ... // defined
template <class Dummy, class CurChild, class ... RemainingChildren> template <class TypeTagTuple>
struct TraverseRemainingChildren_<Dummy, std::tuple<CurChild, RemainingChildren...> > struct SearchTypeTagTuple_
{ typedef typename StopAtFirstChildElseTraverseRemaining_<typename GetEffectiveTypeTag_<CurChild>::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 <class Dummy>
struct TraverseRemainingChildren_<Dummy, std::tuple<> >
{ typedef void type; }; { typedef void type; };
template <class CurTree, class FirstSpliceTypeTag, class EffTypeTag, class ... RemainingSplices> template <class ...TypeTagList>
struct StopAtSpliceIfPropDefinedElseTraverseRemaining_ struct SearchTypeTagTuple_<std::tuple<TypeTagList...> >
{ typedef EffTypeTag type; }; { typedef typename SearchTypeTagList_<TypeTagList...>::type type; };
template <class CurTree, class FirstSpliceTypeTag, class ... RemainingSplices> template <class ...Elements>
struct StopAtSpliceIfPropDefinedElseTraverseRemaining_<CurTree, FirstSpliceTypeTag, /*EffTypeTag=*/void, RemainingSplices...> struct SearchTypeTagList_
{ typedef typename TraverseRemainingSplicesAndChildren_<CurTree, std::tuple<RemainingSplices...> >::type type; }; { typedef void type; };
// if the property was defined for the current splice, stop template <class FirstElement, class ...RemainingElements>
// here. If not... struct SearchTypeTagList_<FirstElement, RemainingElements...>
template <class CurTree, class FirstSpliceProperty, class ... RemainingSplices> {
struct StopAtFirstSpliceElseTraverseRemaining_ typedef typename SearchTypeTagList_FirstThenRemaining_<
{ typedef typename StopAtSpliceIfPropDefinedElseTraverseRemaining_<CurTree, typename GetEffectiveTypeTag_<FirstElement>::type,
typename FirstSpliceProperty::p::type, RemainingElements...>::type type;
typename GetEffectiveTypeTag_<typename FirstSpliceProperty::p::type>::type, };
RemainingSplices...>::type type; };
// ... check the remaining splices. template <class EffectiveTypeTag, class ...Elements>
template <class CurTree, class ... RemainingSplices> struct SearchTypeTagList_FirstThenRemaining_
struct StopAtFirstSpliceElseTraverseRemaining_<CurTree, /*FirstSpliceProperty=*/void, RemainingSplices...> { typedef EffectiveTypeTag type; };
{ typedef typename TraverseRemainingSplicesAndChildren_<CurTree, std::tuple<RemainingSplices...> >::type type; };
// check whether the property is defined on the remaining splices template <class ...RemainingElements>
// of a list (i.e. discard its first member) ... struct SearchTypeTagList_FirstThenRemaining_<void, RemainingElements...>
template <class CurTree, class CurSplice, class ... RemainingSplices> { typedef typename SearchTypeTagList_<RemainingElements...>::type type; };
struct TraverseRemainingSplicesAndChildren_<CurTree, std::tuple<CurSplice, RemainingSplices...> >
{ typedef typename StopAtFirstSpliceElseTraverseRemaining_<CurTree, GetDirectProperty_<TypeTag, CurSplice>, RemainingSplices...>::type type; };
// ... or if there are no splices left to check, proceed with the // find the first type tag in a tuple of splices for which the
// children of the type tag. // property is defined
template <class CurTree> template <class SpliceTuple>
struct TraverseRemainingSplicesAndChildren_<CurTree, std::tuple<> > struct SearchSpliceTuple_
{ typedef typename TraverseRemainingChildren_</*dummy=*/void, typename CurTree::ChildrenTuple>::type type; }; { typedef void type; };
template <class ...SpliceList>
struct SearchSpliceTuple_<std::tuple<SpliceList...> >
{ typedef typename SearchSpliceList_<SpliceList...>::type type; };
template <class ...SpliceList>
struct SearchSpliceList_
{ typedef void type; };
template <class FirstSplice, class ...RemainingSplices>
struct SearchSpliceList_<FirstSplice, RemainingSplices...>
{
typedef typename SearchSpliceList_FirstThenRemaining_<
typename GetEffectiveTypeTag_<typename GetProperty<TypeTag, FirstSplice>::p::type>::type,
RemainingSplices...>::type type;
};
template <class EffectiveTypeTag, class ...Splices>
struct SearchSpliceList_FirstThenRemaining_
{ typedef EffectiveTypeTag type; };
template <class ...RemainingSplices>
struct SearchSpliceList_FirstThenRemaining_<void, RemainingSplices...>
{ typedef typename SearchSpliceList_<RemainingSplices...>::type type; };
// find the splice or the child type tag for which the property is defined
template <class CurTree,
class SpliceTypeTag = typename SearchSpliceTuple_< typename PTag::Splices<CurTree>::tuple >::type >
struct SearchSplicesThenChildren_
{ typedef SpliceTypeTag type; };
template <class CurTree> template <class CurTree>
struct GetEffectiveTypeTag_<CurTree, /*definedOnSelf=*/true> struct SearchSplicesThenChildren_<CurTree, void>
{ typedef CurTree type; }; { typedef typename SearchTypeTagTuple_<typename CurTree::ChildrenTuple>::type type; };
// find the type tag for which the property is defined
template <class CurTree, bool directlyDefined>
struct GetEffectiveTypeTag_
{ typedef typename CurTree::SelfType type; };
template <class CurTree> template <class CurTree>
struct GetEffectiveTypeTag_<CurTree, /*definedOnSelf=*/false> struct GetEffectiveTypeTag_<CurTree, /*directlyDefined = */false>
{ typedef typename TraverseRemainingSplicesAndChildren_<CurTree, typename PTag::Splices<CurTree>::tuple >::type type; }; { typedef typename SearchSplicesThenChildren_<CurTree>::type type; };
public: public:
typedef Property<TypeTag, typename GetEffectiveTypeTag_<TypeTag>::type, PropertyTag> p; typedef Property<TypeTag, typename GetEffectiveTypeTag_<TypeTag>::type, PropertyTag> p;
typedef typename GetEffectiveTypeTag_<TypeTag>::type q;
}; };
#if !defined NO_PROPERTY_INTROSPECTION #if !defined NO_PROPERTY_INTROSPECTION