From a607daa6e1eb69b778d3911015e2dabc798a6119 Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Wed, 14 Dec 2016 09:46:16 +0100 Subject: [PATCH 1/3] delete ClassName.hpp it is now replaced in favour of Dune::className() from dune/common/classname.hh --- opm/material/checkFluidSystem.hpp | 4 +- opm/material/common/ClassName.hpp | 84 ------------------- opm/material/fluidsystems/BaseFluidSystem.hpp | 30 +++---- tests/checkComponent.hpp | 4 +- 4 files changed, 19 insertions(+), 103 deletions(-) delete mode 100644 opm/material/common/ClassName.hpp diff --git a/opm/material/checkFluidSystem.hpp b/opm/material/checkFluidSystem.hpp index b98320341..191219947 100644 --- a/opm/material/checkFluidSystem.hpp +++ b/opm/material/checkFluidSystem.hpp @@ -46,7 +46,7 @@ #include #include -#include +#include #include #include @@ -276,7 +276,7 @@ void checkFluidState(const BaseFluidState &fs) template void checkFluidSystem() { - std::cout << "Testing fluid system '" << Opm::className() << "'\n"; + std::cout << "Testing fluid system '" << Dune::className() << "'\n"; // make sure the fluid system provides the number of phases and // the number of components diff --git a/opm/material/common/ClassName.hpp b/opm/material/common/ClassName.hpp deleted file mode 100644 index 1670768a9..000000000 --- a/opm/material/common/ClassName.hpp +++ /dev/null @@ -1,84 +0,0 @@ -// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- -// vi: set et ts=4 sw=4 sts=4: -/* - Copyright (C) 2012-2013 by Andreas Lauser - Copyright (C) 2010 by Oliver Sander - Copyright (C) 2011 by Martin Nolte - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, version 2. - - This file is based on works developed by the DUNE project, see - . The following license exception - applies to it: - - As a special exception, you may use the DUNE library without - restriction. Specifically, if other files instantiate templates or - use macros or inline functions from one or more of the DUNE source - files, or you compile one or more of the DUNE source files and link - them with other files to produce an executable, this does not by - itself cause the resulting executable to be covered by the GNU - General Public License. This exception does not however invalidate - any other reasons why the executable file might be covered by the - GNU General Public License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ -/*! - * \file - * \brief A free function to provide the demangled class name of a given object or type - * as a string - */ -#ifndef OPM_CLASS_NAME_HPP -#define OPM_CLASS_NAME_HPP - -#include -#include -#include - -#if HAVE_CXA_DEMANGLE -#include -#endif - -namespace Opm { -/** \brief Provide the demangled class name of a given object as a string */ -template -std::string className() -{ - std::string className = typeid( T ).name(); -#if HAVE_CXA_DEMANGLE - int status; - char *demangled = abi::__cxa_demangle( className.c_str(), 0, 0, &status ); - if( demangled ) - { - className = demangled; - std::free( demangled ); - } -#endif // HAVE_CXA_DEMANGLE - return className; -} - -#if HAVE_QUAD -// specialize for quad precision floating point values to avoid -// needing a type_info structure -template <> -inline std::string className<__float128>() -{ return "quad"; } -#endif - -/** \brief Provide the demangled class name of a given object as a string */ -template -std::string className(const T &) -{ - return className(); -} -} // namespace Opm - -#endif // OPM_CLASS_NAME_HPP diff --git a/opm/material/fluidsystems/BaseFluidSystem.hpp b/opm/material/fluidsystems/BaseFluidSystem.hpp index 38bc48f5e..f15e6f295 100644 --- a/opm/material/fluidsystems/BaseFluidSystem.hpp +++ b/opm/material/fluidsystems/BaseFluidSystem.hpp @@ -31,7 +31,7 @@ #include #include -#include +#include namespace Opm { @@ -74,7 +74,7 @@ public: static char *phaseName(unsigned /*phaseIdx*/) { OPM_THROW(std::runtime_error, - "Not implemented: The fluid system '" << Opm::className() << "' does not provide a phaseName() method!"); + "Not implemented: The fluid system '" << Dune::className() << "' does not provide a phaseName() method!"); } /*! @@ -85,7 +85,7 @@ public: static bool isLiquid(unsigned /*phaseIdx*/) { OPM_THROW(std::runtime_error, - "Not implemented: The fluid system '" << Opm::className() << "' does not provide a isLiquid() method!"); + "Not implemented: The fluid system '" << Dune::className() << "' does not provide a isLiquid() method!"); } /*! @@ -105,7 +105,7 @@ public: static bool isIdealMixture(unsigned /*phaseIdx*/) { OPM_THROW(std::runtime_error, - "Not implemented: The fluid system '" << Opm::className() << "' does not provide a isIdealMixture() method!"); + "Not implemented: The fluid system '" << Dune::className() << "' does not provide a isIdealMixture() method!"); } /*! @@ -120,7 +120,7 @@ public: static bool isCompressible(unsigned /*phaseIdx*/) { OPM_THROW(std::runtime_error, - "Not implemented: The fluid system '" << Opm::className() << "' does not provide a isCompressible() method!"); + "Not implemented: The fluid system '" << Dune::className() << "' does not provide a isCompressible() method!"); } /*! @@ -132,7 +132,7 @@ public: static bool isIdealGas(unsigned /*phaseIdx*/) { OPM_THROW(std::runtime_error, - "Not implemented: The fluid system '" << Opm::className() << "' does not provide a isIdealGas() method!"); + "Not implemented: The fluid system '" << Dune::className() << "' does not provide a isIdealGas() method!"); } /*! @@ -143,7 +143,7 @@ public: static const char *componentName(unsigned /*compIdx*/) { OPM_THROW(std::runtime_error, - "Not implemented: The fluid system '" << Opm::className() << "' does not provide a componentName() method!"); + "Not implemented: The fluid system '" << Dune::className() << "' does not provide a componentName() method!"); } /*! @@ -154,7 +154,7 @@ public: static Scalar molarMass(unsigned /*compIdx*/) { OPM_THROW(std::runtime_error, - "Not implemented: The fluid system '" << Opm::className() << "' does not provide a molarMass() method!"); + "Not implemented: The fluid system '" << Dune::className() << "' does not provide a molarMass() method!"); } /*! @@ -175,7 +175,7 @@ public: unsigned /*phaseIdx*/) { OPM_THROW(std::runtime_error, - "Not implemented: The fluid system '" << Opm::className() << "' does not provide a density() method!"); + "Not implemented: The fluid system '" << Dune::className() << "' does not provide a density() method!"); } /*! @@ -198,7 +198,7 @@ public: unsigned /*phaseIdx*/, unsigned /*compIdx*/) { - OPM_THROW(std::runtime_error, "Not implemented: The fluid system '" << Opm::className() << "' does not provide a fugacityCoefficient() method!"); + OPM_THROW(std::runtime_error, "Not implemented: The fluid system '" << Dune::className() << "' does not provide a fugacityCoefficient() method!"); } /*! @@ -212,7 +212,7 @@ public: ParamCache& /*paramCache*/, unsigned /*phaseIdx*/) { - OPM_THROW(std::runtime_error, "Not implemented: The fluid system '" << Opm::className() << "' does not provide a viscosity() method!"); + OPM_THROW(std::runtime_error, "Not implemented: The fluid system '" << Dune::className() << "' does not provide a viscosity() method!"); } /*! @@ -238,7 +238,7 @@ public: unsigned /*phaseIdx*/, unsigned /*compIdx*/) { - OPM_THROW(std::runtime_error, "Not implemented: The fluid system '" << Opm::className() << "' does not provide a diffusionCoefficient() method!"); + OPM_THROW(std::runtime_error, "Not implemented: The fluid system '" << Dune::className() << "' does not provide a diffusionCoefficient() method!"); } /*! @@ -253,7 +253,7 @@ public: ParamCache& /*paramCache*/, unsigned /*phaseIdx*/) { - OPM_THROW(std::runtime_error, "Not implemented: The fluid system '" << Opm::className() << "' does not provide an enthalpy() method!"); + OPM_THROW(std::runtime_error, "Not implemented: The fluid system '" << Dune::className() << "' does not provide an enthalpy() method!"); } /*! @@ -267,7 +267,7 @@ public: ParamCache& /*paramCache*/, unsigned /*phaseIdx*/) { - OPM_THROW(std::runtime_error, "Not implemented: The fluid system '" << Opm::className() << "' does not provide a thermalConductivity() method!"); + OPM_THROW(std::runtime_error, "Not implemented: The fluid system '" << Dune::className() << "' does not provide a thermalConductivity() method!"); } /*! @@ -281,7 +281,7 @@ public: ParamCache& /*paramCache*/, unsigned /*phaseIdx*/) { - OPM_THROW(std::runtime_error, "Not implemented: The fluid system '" << Opm::className() << "' does not provide a heatCapacity() method!"); + OPM_THROW(std::runtime_error, "Not implemented: The fluid system '" << Dune::className() << "' does not provide a heatCapacity() method!"); } }; diff --git a/tests/checkComponent.hpp b/tests/checkComponent.hpp index 4a4125fa0..dac96c7ee 100644 --- a/tests/checkComponent.hpp +++ b/tests/checkComponent.hpp @@ -28,7 +28,7 @@ #define OPM_CHECK_COMPONENT_HPP #include -#include +#include #include #include @@ -42,7 +42,7 @@ template void checkComponent() { - std::cout << "Testing component '" << Opm::className() << "'\n"; + std::cout << "Testing component '" << Dune::className() << "'\n"; // make sure the necessary typedefs exist typedef typename Component::Scalar Scalar; From 39c5c94ac7a281a4554d4a5399c9c56289d3edcb Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Wed, 14 Dec 2016 09:46:21 +0100 Subject: [PATCH 2/3] the new home of Valgrind.hpp is opm-common! --- .../common/UniformXTabulated2DFunction.hpp | 2 +- opm/material/common/Valgrind.hpp | 311 ------------------ opm/material/components/H2O.hpp | 2 +- .../CompositionFromFugacities.hpp | 2 +- .../ComputeFromReferencePhase.hpp | 2 +- .../constraintsolvers/ImmiscibleFlash.hpp | 2 +- .../MiscibleMultiPhaseComposition.hpp | 2 +- opm/material/constraintsolvers/NcpFlash.hpp | 2 +- opm/material/densead/Evaluation.hpp | 2 +- opm/material/eos/PengRobinsonParams.hpp | 2 +- .../BrooksCoreyParams.hpp | 2 +- .../EclDefaultMaterial.hpp | 2 +- .../EclMultiplexerMaterial.hpp | 2 +- .../EclStone1Material.hpp | 2 +- .../EclStone2Material.hpp | 2 +- .../EclTwoPhaseMaterial.hpp | 2 +- .../LinearMaterial.hpp | 2 +- .../ThreePhaseParkerVanGenuchtenParams.hpp | 2 +- .../fluidstates/CompositionalFluidState.hpp | 2 +- .../FluidStateCompositionModules.hpp | 2 +- .../fluidstates/FluidStateDensityModules.hpp | 2 +- .../fluidstates/FluidStateEnthalpyModules.hpp | 2 +- .../fluidstates/FluidStateFugacityModules.hpp | 2 +- .../fluidstates/FluidStatePressureModules.hpp | 2 +- .../FluidStateSaturationModules.hpp | 2 +- .../FluidStateTemperatureModules.hpp | 2 +- .../FluidStateViscosityModules.hpp | 2 +- .../fluidstates/ImmiscibleFluidState.hpp | 2 +- .../fluidstates/ModularFluidState.hpp | 2 +- .../fluidstates/NonEquilibriumFluidState.hpp | 2 +- .../fluidstates/PressureOverlayFluidState.hpp | 2 +- .../SaturationOverlayFluidState.hpp | 2 +- .../TemperatureOverlayFluidState.hpp | 2 +- .../fluidsystems/BlackOilFluidSystem.hpp | 2 +- .../fluidsystems/H2OAirFluidSystem.hpp | 2 +- .../fluidsystems/H2ON2FluidSystem.hpp | 2 +- .../H2ON2LiquidPhaseFluidSystem.hpp | 2 +- opm/material/heatconduction/Somerton.hpp | 2 +- 38 files changed, 37 insertions(+), 348 deletions(-) delete mode 100644 opm/material/common/Valgrind.hpp diff --git a/opm/material/common/UniformXTabulated2DFunction.hpp b/opm/material/common/UniformXTabulated2DFunction.hpp index 83bbcd361..ce8d8eab8 100644 --- a/opm/material/common/UniformXTabulated2DFunction.hpp +++ b/opm/material/common/UniformXTabulated2DFunction.hpp @@ -28,7 +28,7 @@ #ifndef OPM_UNIFORM_X_TABULATED_2D_FUNCTION_HPP #define OPM_UNIFORM_X_TABULATED_2D_FUNCTION_HPP -#include +#include #include #include #include diff --git a/opm/material/common/Valgrind.hpp b/opm/material/common/Valgrind.hpp deleted file mode 100644 index e0894a61b..000000000 --- a/opm/material/common/Valgrind.hpp +++ /dev/null @@ -1,311 +0,0 @@ -// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- -// vi: set et ts=4 sw=4 sts=4: -/* - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . - - Consult the COPYING file in the top-level source directory of this - module for the precise wording of the license and the list of - copyright holders. -*/ -/*! - * \file - * \brief Some templates to wrap the valgrind client request macros - */ -#ifndef OPM_VALGRIND_HPP -#define OPM_VALGRIND_HPP - -#include - -#if HAVE_VALGRIND -#include -#endif - -#if HAVE_VALGRIND -#define OPM_VALGRIND_OPTIM_UNUSED OPM_OPTIM_UNUSED -#else -#define OPM_VALGRIND_OPTIM_UNUSED OPM_UNUSED -#endif - -namespace Valgrind -{ -/*! - * \ingroup Valgrind - * \brief Returns whether the program is running under Valgrind or not. - */ -inline bool IsRunning() -{ -#if !defined NDEBUG && HAVE_VALGRIND - return RUNNING_ON_VALGRIND; -#else - return false; -#endif -} - -/*! - * \ingroup Valgrind - * \brief Make valgrind complain if any of the memory occupied by an object - * is undefined. - * - * Please note that this does not check whether the destinations of an - * object's pointers or references are defined. Also, for performance - * reasons the compiler might insert "padding bytes" between within - * the objects which leads to false positives. - * - * Example: - * - * \code - * int i; - * Valgrind::CheckDefined(i); // Valgrind complains! - * \endcode - * - * \tparam T The type of the object which ought to be checked - * - * \param value the object which valgrind should check - * - * \return true iff there are no undefined bytes in the memory - * occupied by the object. - */ -template -inline bool CheckDefined(const T& value OPM_VALGRIND_OPTIM_UNUSED) -{ -#if !defined NDEBUG && HAVE_VALGRIND - auto tmp = VALGRIND_CHECK_MEM_IS_DEFINED(&value, sizeof(T)); - return tmp == 0; -#else - return true; -#endif -} - - - -/*! - * \ingroup Valgrind - * \brief Make valgrind complain if any of the memory occupied by an object - * is not addressable. - * - * Example: - * - * \code - * int* i = NULL; - * Valgrind::CheckAddressable(*i); // Valgrind complains! - * \endcode - * - * \tparam T The type of the object which ought to be checked - * - * \param value the object which valgrind should check - * - * \return true iff there are no unadressable bytes in the memory - * occupied by the object. - */ -template -inline bool CheckAddressable(const T& value OPM_VALGRIND_OPTIM_UNUSED) -{ -#if !defined NDEBUG && HAVE_VALGRIND - auto tmp = VALGRIND_CHECK_MEM_IS_ADDRESSABLE(&value, sizeof(T)); - return tmp == 0; -#else - return true; -#endif -} - -/*! - * \ingroup Valgrind - * \brief Make valgrind complain if any of the the memory occupied - * by a C-style array objects is undefined. - * - * Please note that this does not check whether the destinations of an - * object's pointers or references are defined. Also, for performance - * reasons the compiler might insert "padding bytes" between within - * the objects which leads to false positives. - * - * Example: - * - * \code - * int i[2]; - * Valgrind::CheckDefined(i, 2); // Valgrind complains! - * \endcode - * - * \tparam T The type of the object which ought to be checked - * - * \param value Pointer to the first object of the array. - * \param size The size of the array in number of objects - * - * \return true iff there are no undefined bytes in the memory - * occupied by the array. - */ -template -inline bool CheckDefined(const T* value OPM_VALGRIND_OPTIM_UNUSED, int size OPM_VALGRIND_OPTIM_UNUSED) -{ -#if !defined NDEBUG && HAVE_VALGRIND - auto tmp = VALGRIND_CHECK_MEM_IS_DEFINED(value, size*sizeof(T)); - return tmp == 0; -#else - return true; -#endif -} - -/*! - * \ingroup Valgrind - * \brief Make the memory on which an object resides undefined in - * valgrind runs. - * - * Example: - * - * \code - * int i = 0; - * Valgrind::SetUndefined(i); - * Valgrind::CheckDefined(i); // Valgrind complains! - * \endcode - * - * \tparam T The type of the object which ought to be set to undefined - * - * \param value The object which's memory valgrind should be told is undefined - */ -template -inline void SetUndefined(const T &value OPM_VALGRIND_OPTIM_UNUSED) -{ -#if !defined NDEBUG && HAVE_VALGRIND - VALGRIND_MAKE_MEM_UNDEFINED(&value, sizeof(T)); -#endif -} - -/*! - * \ingroup Valgrind - * \brief Make the memory on which an array of object resides - * undefined in valgrind runs. - * - * Example: - * - * \code - * int i[3] = {0, 1, 3}; - * Valgrind::SetUndefined(&i[1], 2); - * Valgrind::CheckDefined(i, 3); // Valgrind complains! - * \endcode - * - * \tparam T The type of the object which ought to be set to undefined - * - * \param value Pointer to the first object of the array. - * \param size The size of the array in number of objects - */ -template -inline void SetUndefined(const T* value OPM_VALGRIND_OPTIM_UNUSED, int size OPM_VALGRIND_OPTIM_UNUSED) -{ -#if !defined NDEBUG && HAVE_VALGRIND - VALGRIND_MAKE_MEM_UNDEFINED(value, size*sizeof(T)); -#endif -} - -/*! - * \ingroup Valgrind - * \brief Make the memory on which an object resides defined. - * - * Example: - * - * \code - * int i; - * Valgrind::SetDefined(i); - * Valgrind::CheckDefined(i); // Valgrind does not complain! - * \endcode - * - * \tparam T The type of the object which valgrind should consider as defined - * - * \param value The object which's memory valgrind should consider as defined - */ -template -inline void SetDefined(const T& value OPM_VALGRIND_OPTIM_UNUSED) -{ -#if !defined NDEBUG && HAVE_VALGRIND - VALGRIND_MAKE_MEM_DEFINED(&value, sizeof(T)); -#endif -} - -/*! - * \ingroup Valgrind - * \brief Make the memory on which a C-style array of objects resides - * defined. - * - * Example: - * - * \code - * int i[3]; - * Valgrind::SetDefined(i, 3); - * Valgrind::CheckDefined(i, 3); // Valgrind does not complain! - * \endcode - * - * \tparam T The type of the object which valgrind should consider as defined - * - * \param value Pointer to the first object of the array. - * \param n The size of the array in number of objects - */ -template -inline void SetDefined(const T *value OPM_VALGRIND_OPTIM_UNUSED, int n OPM_VALGRIND_OPTIM_UNUSED) -{ -#if !defined NDEBUG && HAVE_VALGRIND - VALGRIND_MAKE_MEM_DEFINED(value, n*sizeof(T)); -#endif -} - -/*! - * \ingroup Valgrind - * \brief Make valgrind complain if an object's memory is accessed. - * - * Example: - * - * \code - * int i = 1; - * Valgrind::SetNoAccess(i); - * int j = i; // Valgrind complains! - * \endcode - * - * \tparam T The type of the object which valgrind should complain if accessed - * - * \param value The object which's memory valgrind should complain if accessed - */ -template -inline void SetNoAccess(const T &value OPM_VALGRIND_OPTIM_UNUSED) -{ -#if !defined NDEBUG && HAVE_VALGRIND - VALGRIND_MAKE_MEM_NOACCESS(&value, sizeof(T)); -#endif -} - -/*! - * \ingroup Valgrind - * \brief Make valgrind complain if the memory of a C-style array of - * objects is accessed. - * - * Example: - * - * \code - * int i[3] = {0, 1, 2}; - * Valgrind::SetNoAccess(i, 2); - * int j = i[1]; // Valgrind complains! - * \endcode - * - * \param value Pointer to the first object of the array. - * \param size The size of the array in number of objects - */ -template -inline void SetNoAccess(const T *value OPM_VALGRIND_OPTIM_UNUSED, int size OPM_VALGRIND_OPTIM_UNUSED) -{ -#if !defined NDEBUG && HAVE_VALGRIND - VALGRIND_MAKE_MEM_NOACCESS(value, size*sizeof(T)); -#endif -} - -} // namespace Valgrind - -#endif diff --git a/opm/material/components/H2O.hpp b/opm/material/components/H2O.hpp index 80c701593..c680b95ec 100644 --- a/opm/material/components/H2O.hpp +++ b/opm/material/components/H2O.hpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include "Component.hpp" diff --git a/opm/material/constraintsolvers/CompositionFromFugacities.hpp b/opm/material/constraintsolvers/CompositionFromFugacities.hpp index 597499b59..3d975ab74 100644 --- a/opm/material/constraintsolvers/CompositionFromFugacities.hpp +++ b/opm/material/constraintsolvers/CompositionFromFugacities.hpp @@ -40,7 +40,7 @@ #include #include -#include +#include #include diff --git a/opm/material/constraintsolvers/ComputeFromReferencePhase.hpp b/opm/material/constraintsolvers/ComputeFromReferencePhase.hpp index e9ec8aa9a..f32597055 100644 --- a/opm/material/constraintsolvers/ComputeFromReferencePhase.hpp +++ b/opm/material/constraintsolvers/ComputeFromReferencePhase.hpp @@ -31,7 +31,7 @@ #include #include -#include +#include #include diff --git a/opm/material/constraintsolvers/ImmiscibleFlash.hpp b/opm/material/constraintsolvers/ImmiscibleFlash.hpp index 0709ddd76..5c73ea01d 100644 --- a/opm/material/constraintsolvers/ImmiscibleFlash.hpp +++ b/opm/material/constraintsolvers/ImmiscibleFlash.hpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include diff --git a/opm/material/constraintsolvers/MiscibleMultiPhaseComposition.hpp b/opm/material/constraintsolvers/MiscibleMultiPhaseComposition.hpp index d993dd768..4c1815f79 100644 --- a/opm/material/constraintsolvers/MiscibleMultiPhaseComposition.hpp +++ b/opm/material/constraintsolvers/MiscibleMultiPhaseComposition.hpp @@ -40,7 +40,7 @@ #include #include -#include +#include namespace Opm { diff --git a/opm/material/constraintsolvers/NcpFlash.hpp b/opm/material/constraintsolvers/NcpFlash.hpp index 7f04d18be..378618887 100644 --- a/opm/material/constraintsolvers/NcpFlash.hpp +++ b/opm/material/constraintsolvers/NcpFlash.hpp @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include diff --git a/opm/material/densead/Evaluation.hpp b/opm/material/densead/Evaluation.hpp index a7015a16b..8af7925d4 100644 --- a/opm/material/densead/Evaluation.hpp +++ b/opm/material/densead/Evaluation.hpp @@ -31,7 +31,7 @@ #include "Math.hpp" -#include +#include #include diff --git a/opm/material/eos/PengRobinsonParams.hpp b/opm/material/eos/PengRobinsonParams.hpp index 7a27f4b6f..3d3b8b4fd 100644 --- a/opm/material/eos/PengRobinsonParams.hpp +++ b/opm/material/eos/PengRobinsonParams.hpp @@ -27,7 +27,7 @@ #ifndef OPM_PENG_ROBINSON_PARAMS_HPP #define OPM_PENG_ROBINSON_PARAMS_HPP -#include +#include namespace Opm { diff --git a/opm/material/fluidmatrixinteractions/BrooksCoreyParams.hpp b/opm/material/fluidmatrixinteractions/BrooksCoreyParams.hpp index d45c2712c..1a9609316 100644 --- a/opm/material/fluidmatrixinteractions/BrooksCoreyParams.hpp +++ b/opm/material/fluidmatrixinteractions/BrooksCoreyParams.hpp @@ -27,7 +27,7 @@ #ifndef OPM_BROOKS_COREY_PARAMS_HPP #define OPM_BROOKS_COREY_PARAMS_HPP -#include +#include #include diff --git a/opm/material/fluidmatrixinteractions/EclDefaultMaterial.hpp b/opm/material/fluidmatrixinteractions/EclDefaultMaterial.hpp index 360a107c4..61571c354 100644 --- a/opm/material/fluidmatrixinteractions/EclDefaultMaterial.hpp +++ b/opm/material/fluidmatrixinteractions/EclDefaultMaterial.hpp @@ -29,7 +29,7 @@ #include "EclDefaultMaterialParams.hpp" -#include +#include #include #include diff --git a/opm/material/fluidmatrixinteractions/EclMultiplexerMaterial.hpp b/opm/material/fluidmatrixinteractions/EclMultiplexerMaterial.hpp index fb56330ef..b217754cf 100644 --- a/opm/material/fluidmatrixinteractions/EclMultiplexerMaterial.hpp +++ b/opm/material/fluidmatrixinteractions/EclMultiplexerMaterial.hpp @@ -33,7 +33,7 @@ #include "EclStone2Material.hpp" #include "EclTwoPhaseMaterial.hpp" -#include +#include #include #include #include diff --git a/opm/material/fluidmatrixinteractions/EclStone1Material.hpp b/opm/material/fluidmatrixinteractions/EclStone1Material.hpp index ebb329acb..e84342b44 100644 --- a/opm/material/fluidmatrixinteractions/EclStone1Material.hpp +++ b/opm/material/fluidmatrixinteractions/EclStone1Material.hpp @@ -29,7 +29,7 @@ #include "EclStone1MaterialParams.hpp" -#include +#include #include #include diff --git a/opm/material/fluidmatrixinteractions/EclStone2Material.hpp b/opm/material/fluidmatrixinteractions/EclStone2Material.hpp index ad80732d3..ead676d02 100644 --- a/opm/material/fluidmatrixinteractions/EclStone2Material.hpp +++ b/opm/material/fluidmatrixinteractions/EclStone2Material.hpp @@ -29,7 +29,7 @@ #include "EclStone2MaterialParams.hpp" -#include +#include #include #include diff --git a/opm/material/fluidmatrixinteractions/EclTwoPhaseMaterial.hpp b/opm/material/fluidmatrixinteractions/EclTwoPhaseMaterial.hpp index 0711149ee..aa9036bf6 100644 --- a/opm/material/fluidmatrixinteractions/EclTwoPhaseMaterial.hpp +++ b/opm/material/fluidmatrixinteractions/EclTwoPhaseMaterial.hpp @@ -29,7 +29,7 @@ #include "EclTwoPhaseMaterialParams.hpp" -#include +#include #include #include diff --git a/opm/material/fluidmatrixinteractions/LinearMaterial.hpp b/opm/material/fluidmatrixinteractions/LinearMaterial.hpp index 8719124b1..d3028df29 100644 --- a/opm/material/fluidmatrixinteractions/LinearMaterial.hpp +++ b/opm/material/fluidmatrixinteractions/LinearMaterial.hpp @@ -30,7 +30,7 @@ #include "LinearMaterialParams.hpp" #include -#include +#include #include #include diff --git a/opm/material/fluidmatrixinteractions/ThreePhaseParkerVanGenuchtenParams.hpp b/opm/material/fluidmatrixinteractions/ThreePhaseParkerVanGenuchtenParams.hpp index 5f665c0ab..48d3f4c02 100644 --- a/opm/material/fluidmatrixinteractions/ThreePhaseParkerVanGenuchtenParams.hpp +++ b/opm/material/fluidmatrixinteractions/ThreePhaseParkerVanGenuchtenParams.hpp @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include diff --git a/opm/material/fluidstates/CompositionalFluidState.hpp b/opm/material/fluidstates/CompositionalFluidState.hpp index 4dc79b9a5..0bc39f66f 100644 --- a/opm/material/fluidstates/CompositionalFluidState.hpp +++ b/opm/material/fluidstates/CompositionalFluidState.hpp @@ -32,7 +32,7 @@ #include "ModularFluidState.hpp" -#include +#include #include namespace Opm { diff --git a/opm/material/fluidstates/FluidStateCompositionModules.hpp b/opm/material/fluidstates/FluidStateCompositionModules.hpp index a10876dd1..52aa3f443 100644 --- a/opm/material/fluidstates/FluidStateCompositionModules.hpp +++ b/opm/material/fluidstates/FluidStateCompositionModules.hpp @@ -28,7 +28,7 @@ #ifndef OPM_FLUID_STATE_COMPOSITION_MODULES_HPP #define OPM_FLUID_STATE_COMPOSITION_MODULES_HPP -#include +#include #include #include diff --git a/opm/material/fluidstates/FluidStateDensityModules.hpp b/opm/material/fluidstates/FluidStateDensityModules.hpp index fe57c700c..80774c7db 100644 --- a/opm/material/fluidstates/FluidStateDensityModules.hpp +++ b/opm/material/fluidstates/FluidStateDensityModules.hpp @@ -32,7 +32,7 @@ #include #include -#include +#include #include diff --git a/opm/material/fluidstates/FluidStateEnthalpyModules.hpp b/opm/material/fluidstates/FluidStateEnthalpyModules.hpp index 6a8996d28..d95f782f6 100644 --- a/opm/material/fluidstates/FluidStateEnthalpyModules.hpp +++ b/opm/material/fluidstates/FluidStateEnthalpyModules.hpp @@ -32,7 +32,7 @@ #include #include -#include +#include #include diff --git a/opm/material/fluidstates/FluidStateFugacityModules.hpp b/opm/material/fluidstates/FluidStateFugacityModules.hpp index 8e6648780..ccfefd3bb 100644 --- a/opm/material/fluidstates/FluidStateFugacityModules.hpp +++ b/opm/material/fluidstates/FluidStateFugacityModules.hpp @@ -28,7 +28,7 @@ #ifndef OPM_FLUID_STATE_FUGACITY_MODULES_HPP #define OPM_FLUID_STATE_FUGACITY_MODULES_HPP -#include +#include #include #include diff --git a/opm/material/fluidstates/FluidStatePressureModules.hpp b/opm/material/fluidstates/FluidStatePressureModules.hpp index 574179842..521a52f2e 100644 --- a/opm/material/fluidstates/FluidStatePressureModules.hpp +++ b/opm/material/fluidstates/FluidStatePressureModules.hpp @@ -29,7 +29,7 @@ #define OPM_FLUID_STATE_PRESSURE_MODULES_HPP #include -#include +#include #include #include diff --git a/opm/material/fluidstates/FluidStateSaturationModules.hpp b/opm/material/fluidstates/FluidStateSaturationModules.hpp index 9dfb51427..502ce937d 100644 --- a/opm/material/fluidstates/FluidStateSaturationModules.hpp +++ b/opm/material/fluidstates/FluidStateSaturationModules.hpp @@ -32,7 +32,7 @@ #include #include -#include +#include #include diff --git a/opm/material/fluidstates/FluidStateTemperatureModules.hpp b/opm/material/fluidstates/FluidStateTemperatureModules.hpp index e297bd4c2..d5c359e07 100644 --- a/opm/material/fluidstates/FluidStateTemperatureModules.hpp +++ b/opm/material/fluidstates/FluidStateTemperatureModules.hpp @@ -28,7 +28,7 @@ #ifndef OPM_FLUID_STATE_TEMPERATURE_MODULES_HPP #define OPM_FLUID_STATE_TEMPERATURE_MODULES_HPP -#include +#include #include #include diff --git a/opm/material/fluidstates/FluidStateViscosityModules.hpp b/opm/material/fluidstates/FluidStateViscosityModules.hpp index 56e2ecd64..3c993a52c 100644 --- a/opm/material/fluidstates/FluidStateViscosityModules.hpp +++ b/opm/material/fluidstates/FluidStateViscosityModules.hpp @@ -32,7 +32,7 @@ #include #include -#include +#include #include diff --git a/opm/material/fluidstates/ImmiscibleFluidState.hpp b/opm/material/fluidstates/ImmiscibleFluidState.hpp index fb90d2d8a..0f3532e6f 100644 --- a/opm/material/fluidstates/ImmiscibleFluidState.hpp +++ b/opm/material/fluidstates/ImmiscibleFluidState.hpp @@ -32,7 +32,7 @@ #include "ModularFluidState.hpp" -#include +#include #include diff --git a/opm/material/fluidstates/ModularFluidState.hpp b/opm/material/fluidstates/ModularFluidState.hpp index 42a53c231..157670981 100644 --- a/opm/material/fluidstates/ModularFluidState.hpp +++ b/opm/material/fluidstates/ModularFluidState.hpp @@ -36,7 +36,7 @@ #include "FluidStateViscosityModules.hpp" #include "FluidStateEnthalpyModules.hpp" -#include +#include #include namespace Opm { diff --git a/opm/material/fluidstates/NonEquilibriumFluidState.hpp b/opm/material/fluidstates/NonEquilibriumFluidState.hpp index 8d89372b4..bad9d5698 100644 --- a/opm/material/fluidstates/NonEquilibriumFluidState.hpp +++ b/opm/material/fluidstates/NonEquilibriumFluidState.hpp @@ -32,7 +32,7 @@ #include "ModularFluidState.hpp" -#include +#include #include namespace Opm { diff --git a/opm/material/fluidstates/PressureOverlayFluidState.hpp b/opm/material/fluidstates/PressureOverlayFluidState.hpp index 7fb56b59c..88e2a36da 100644 --- a/opm/material/fluidstates/PressureOverlayFluidState.hpp +++ b/opm/material/fluidstates/PressureOverlayFluidState.hpp @@ -27,7 +27,7 @@ #ifndef OPM_PRESSURE_OVERLAY_FLUID_STATE_HPP #define OPM_PRESSURE_OVERLAY_FLUID_STATE_HPP -#include +#include #include #include diff --git a/opm/material/fluidstates/SaturationOverlayFluidState.hpp b/opm/material/fluidstates/SaturationOverlayFluidState.hpp index 13f1ef67c..aca1b7834 100644 --- a/opm/material/fluidstates/SaturationOverlayFluidState.hpp +++ b/opm/material/fluidstates/SaturationOverlayFluidState.hpp @@ -27,7 +27,7 @@ #ifndef OPM_SATURATION_OVERLAY_FLUID_STATE_HPP #define OPM_SATURATION_OVERLAY_FLUID_STATE_HPP -#include +#include #include #include diff --git a/opm/material/fluidstates/TemperatureOverlayFluidState.hpp b/opm/material/fluidstates/TemperatureOverlayFluidState.hpp index 451d249b5..df88c4b56 100644 --- a/opm/material/fluidstates/TemperatureOverlayFluidState.hpp +++ b/opm/material/fluidstates/TemperatureOverlayFluidState.hpp @@ -27,7 +27,7 @@ #ifndef OPM_TEMPERATURE_OVERLAY_FLUID_STATE_HPP #define OPM_TEMPERATURE_OVERLAY_FLUID_STATE_HPP -#include +#include #include diff --git a/opm/material/fluidsystems/BlackOilFluidSystem.hpp b/opm/material/fluidsystems/BlackOilFluidSystem.hpp index 3ae350d46..56ff881fa 100644 --- a/opm/material/fluidsystems/BlackOilFluidSystem.hpp +++ b/opm/material/fluidsystems/BlackOilFluidSystem.hpp @@ -35,7 +35,7 @@ #include #include -#include +#include #include #include #include diff --git a/opm/material/fluidsystems/H2OAirFluidSystem.hpp b/opm/material/fluidsystems/H2OAirFluidSystem.hpp index 4d01a7133..668778b73 100644 --- a/opm/material/fluidsystems/H2OAirFluidSystem.hpp +++ b/opm/material/fluidsystems/H2OAirFluidSystem.hpp @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include diff --git a/opm/material/fluidsystems/H2ON2FluidSystem.hpp b/opm/material/fluidsystems/H2ON2FluidSystem.hpp index 07e8d6f2c..6107c7253 100644 --- a/opm/material/fluidsystems/H2ON2FluidSystem.hpp +++ b/opm/material/fluidsystems/H2ON2FluidSystem.hpp @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include diff --git a/opm/material/fluidsystems/H2ON2LiquidPhaseFluidSystem.hpp b/opm/material/fluidsystems/H2ON2LiquidPhaseFluidSystem.hpp index 67a06c641..c918f2d8e 100644 --- a/opm/material/fluidsystems/H2ON2LiquidPhaseFluidSystem.hpp +++ b/opm/material/fluidsystems/H2ON2LiquidPhaseFluidSystem.hpp @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include diff --git a/opm/material/heatconduction/Somerton.hpp b/opm/material/heatconduction/Somerton.hpp index 71cecdb50..efb5cb753 100644 --- a/opm/material/heatconduction/Somerton.hpp +++ b/opm/material/heatconduction/Somerton.hpp @@ -31,7 +31,7 @@ #include -#include +#include #include #include From 4ab2b3dc7024bf714071e296ef349b107693c658 Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Wed, 14 Dec 2016 12:36:09 +0100 Subject: [PATCH 3/3] move over the quadruple precision math code from eWoms --- opm/material/common/quad.hpp | 344 +++++++++++++++++++++++++++++++++++ 1 file changed, 344 insertions(+) create mode 100644 opm/material/common/quad.hpp diff --git a/opm/material/common/quad.hpp b/opm/material/common/quad.hpp new file mode 100644 index 000000000..cdeb2d844 --- /dev/null +++ b/opm/material/common/quad.hpp @@ -0,0 +1,344 @@ +// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +// vi: set et ts=4 sw=4 sts=4: +/* + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . + + Consult the COPYING file in the top-level source directory of this + module for the precise wording of the license and the list of + copyright holders. +*/ +/*! + * \file + * + * \brief This file provides the infrastructure to use quad-precision + * floating point values in the numerical models. + */ +#if HAVE_DUNE_COMMON +#ifdef DUNE_CLASSNAME_HH +#error "Due to some trickery required for the linker, this file must be included _before_ Dune's classname.hh!" +#endif + +#include +#endif // HAVE_DUNE_COMMON + +#if !defined OPM_COMMON_QUAD_HPP && HAVE_QUAD +#define OPM_COMMON_QUAD_HPP + +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +typedef __float128 quad; + +namespace std { + +// provide the numeric limits for the quad precision type +template <> +class numeric_limits +{ +public: + static const bool is_specialized = true; + + static quad min() throw() + { return FLT128_MIN; } + static quad max() throw() + { return FLT128_MAX; } + + // number of bits in mantissa + static const int digits = FLT128_MANT_DIG; + // number of decimal digits + static const int digits10 = FLT128_DIG; + static const bool is_signed = true; + static const bool is_integer = false; + static const bool is_exact = false; + static const int radix = 0; + static quad epsilon() throw() + { return FLT128_EPSILON; } + static quad round_error() throw() + { return 0.5; } + + static const int min_exponent = FLT128_MIN_EXP; + static const int min_exponent10 = FLT128_MIN_10_EXP; + static const int max_exponent = FLT128_MAX_EXP; + static const int max_exponent10 = FLT128_MAX_10_EXP; + + static const bool has_infinity = true; + static const bool has_quiet_NaN = true; + static const bool has_signaling_NaN = true; + static const float_denorm_style has_denorm = denorm_present; + static const bool has_denorm_loss = false; + static quad infinity() throw() + { return __builtin_huge_valq(); } + static quad quiet_NaN() throw() + { return __builtin_nan(""); } + static quad signaling_NaN() throw() + { return __builtin_nans(""); } + static quad denorm_min() throw() + { return FLT128_DENORM_MIN; } + + static const bool is_iec559 = true; + static const bool is_bounded = true; + static const bool is_modulo = false; + + static const bool traps = std::numeric_limits::traps; + static const bool tinyness_before = std::numeric_limits::tinyness_before; + static const float_round_style round_style = round_to_nearest; +}; + +// provide some type traits for the quadruple precision type +template <> +struct is_floating_point + : public integral_constant +{}; + +template <> +struct is_arithmetic + : public integral_constant +{}; + +template <> +struct is_fundamental + : public integral_constant +{}; + +template <> +struct is_scalar + : public integral_constant +{}; + +template <> +struct is_pod + : public integral_constant +{}; + +template <> +struct is_signed + : public integral_constant +{}; + + +template <> +struct is_standard_layout + : public integral_constant +{}; + +template <> +struct is_trivial + : public integral_constant +{}; + +/* +template <> +struct is_trivially_copyable + : public integral_constant +{}; +*/ + +template +struct is_assignable + : public integral_constant::value> +{}; + +template +struct is_nothrow_assignable + : public is_assignable +{}; + +/* +template +struct is_trivially_assignable + : public integral_constant::value> +{}; +*/ + +template <> +struct is_copy_assignable + : public integral_constant +{}; + +template <> +struct is_nothrow_copy_assignable + : public integral_constant +{}; + +template <> +struct is_move_assignable + : public integral_constant +{}; + +template <> +struct is_nothrow_move_assignable + : public integral_constant +{}; + +template <> +struct is_constructible + : public integral_constant +{}; + +template <> +struct is_nothrow_constructible + : public integral_constant +{}; + +template <> +struct is_default_constructible + : public integral_constant +{}; + +template <> +struct is_nothrow_default_constructible + : public integral_constant +{}; + +/* +template <> +struct is_trivially_default_constructible + : public integral_constant +{}; +*/ + +template <> +struct is_copy_constructible + : public integral_constant +{}; + +template <> +struct is_move_constructible + : public integral_constant +{}; + +template <> +struct is_nothrow_move_constructible + : public integral_constant +{}; + + +template <> +struct is_destructible + : public integral_constant +{}; + +template <> +struct is_nothrow_destructible + : public integral_constant +{}; + +template +struct is_convertible + : public is_arithmetic +{ }; + +inline std::ostream& operator<<(std::ostream& os, const quad& val) +{ + if (os.precision() > std::numeric_limits::digits10) + throw std::runtime_error("The precision requested for output cannot " + "be represented by a double precision floating " + "point object"); + + return os << static_cast(val); +} + +inline std::istream& operator>>(std::istream& is, quad& val) +{ + double tmp; + std::istream& ret = (is >> tmp); + val = tmp; + return ret; +} + +inline quad abs(quad val) +{ return (val < 0) ? -val : val; } + +inline quad floor(quad val) +{ return floorq(val); } + +inline quad ceil(quad val) +{ return ceilq(val); } + +inline quad max(quad a, quad b) +{ return (a > b) ? a : b; } + +inline quad min(quad a, quad b) +{ return (a < b) ? a : b; } + +inline quad sqrt(quad val) +{ return sqrtq(val); } + +template +inline quad pow(quad base, ExpType exp) +{ return powq(base, static_cast(exp)); } + +template +inline quad pow(BaseType base, quad exp) +{ return powq(static_cast(base), exp); } + +inline quad pow(quad base, quad exp) +{ return powq(base, exp); } + +inline quad exp(quad val) +{ return expq(val); } + +inline quad log(quad val) +{ return logq(val); } + +inline quad sin(quad val) +{ return sinq(val); } + +inline quad cos(quad val) +{ return cosq(val); } + +inline quad tan(quad val) +{ return tanq(val); } + +inline quad atan(quad val) +{ return atanq(val); } + +inline quad atan2(quad a, quad b) +{ return atan2q(a, b); } + +inline quad round(quad val) +{ return roundq(val); } + +inline bool isfinite(quad val) +{ return finiteq(val); } + +inline bool isnan(quad val) +{ return isnanq(val); } + +inline bool isinf(quad val) +{ return isinfq(val); } + +} // namespace std + +#if HAVE_DUNE_COMMON +// specialize Dune::className for __float128 since it former does not work properly with +// __float128 (this is mainly the fault of GCC/libstdc++) +namespace Dune { +template <> +inline std::string className<__float128>() +{ return "quad"; } +} // namespace Dune +#endif // HAVE_DUNE_COMMON + +#endif // OPM_COMMON_QUAD_HPP