Commit 205f04a9 authored by Timo Koch's avatar Timo Koch
Browse files

[quad] Remove Dumux::Quad. Use Dune::Float128 instead.

Unfortunately the CMake logic for quad math detection was overwriting the Quadmath
package from Dune and had to be removed. This removes all quadmath code from
Dumux and uses the quadmath implementation of Dune instead (Dune::Float128)
which is based on the same library.
parent 745553c6
......@@ -8,6 +8,7 @@ Differences Between DuMu<sup>x</sup> 3.3 and DuMu<sup>x</sup> 3.2
### Immediate interface changes not allowing/requiring a deprecation period:
- For the "sequential" models, the property `BoundaryTypes` has been simply renamed to `SequentialBoundaryTypes`
- __Quadmath__: Dumux::Quad has been removed without deprecation. Use Dune::Float128 instead.
### Deprecated properties/classes/functions/files, to be removed after 3.3:
......
......@@ -13,4 +13,3 @@ find_package(NLOPT)
find_package(PTScotch)
find_package(PVPython)
find_package(Valgrind)
find_package(Quadmath)
# Module that checks whether the compiler supports the
# quadruple precision floating point math
#
# Sets the following variables:
# HAVE_QUAD
# QUADMATH_LIBRARIES
#
# perform tests
include(CheckCSourceCompiles)
include(CheckCXXSourceCompiles)
include(CMakePushCheckState)
include(CheckCXXCompilerFlag)
if(NOT DEFINED USE_QUADMATH OR USE_QUADMATH)
if(NOT DEFINED HAVE_EXTENDED_NUMERIC_LITERALS)
check_cxx_compiler_flag("-Werror -fext-numeric-literals" HAVE_EXTENDED_NUMERIC_LITERALS)
endif()
if (HAVE_EXTENDED_NUMERIC_LITERALS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fext-numeric-literals")
endif()
cmake_push_check_state(RESET)
list(APPEND CMAKE_REQUIRED_LIBRARIES "quadmath")
CHECK_CXX_SOURCE_COMPILES("
#include <quadmath.h>
int main(void){
__float128 foo = sqrtq(123.456);
foo = FLT128_MIN;
}" QUADMATH_FOUND)
cmake_pop_check_state()
if (QUADMATH_FOUND)
set(QUADMATH_LIBRARIES "quadmath")
set(HAVE_QUAD "${QUADMATH_FOUND}")
endif()
endif()
if (USE_QUADMATH AND NOT QUADMATH_FOUND)
message(FATAL_ERROR "Quadruple precision math support was explicitly requested but is unavailable!")
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Quadmath
DEFAULT_MSG
QUADMATH_LIBRARIES
HAVE_QUAD
)
......@@ -32,7 +32,6 @@ partial.hh
pdesolver.hh
pointsource.hh
properties.hh
quad.hh
reorderingdofmapper.hh
reservedblockvector.hh
spline.hh
......
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* 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, either version 3 of the License, or *
* (at your option) any later version. *
* *
* 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 <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
* \ingroup Common
* \brief This file provides the infrastructure to use quad-precision
* floating point values in the numerical models.
*/
#if !defined DUMUX_QUAD_HH && HAVE_QUAD
#define DUMUX_QUAD_HH
#include <iostream>
#include <cmath>
#include <limits>
extern "C" {
#include <quadmath.h>
}
#include <dune/common/typetraits.hh>
namespace Dumux {
using Quad = __float128;
} // namespace Dumux
// Dune's desired way of enabling their algebraic operations for
// extended-precision data types, see dune/common/typetraits.hh.
namespace Dune {
template <>
struct IsNumber<Dumux::Quad> : std::true_type {};
} // namespace Dune
namespace std {
// provide the numeric limits for the quad precision type
template <>
class numeric_limits<Dumux::Quad>
{
public:
static constexpr bool is_specialized = true;
static constexpr Dumux::Quad min() noexcept
{ return FLT128_MIN; }
static constexpr Dumux::Quad max() noexcept
{ return FLT128_MAX; }
static constexpr Dumux::Quad lowest() noexcept
{ return -FLT128_MAX; }
// number of bits in mantissa
static constexpr int digits = FLT128_MANT_DIG;
// number of decimal digits
static constexpr int digits10 = FLT128_DIG;
static constexpr int max_digits10 = FLT128_MANT_DIG;
static constexpr bool is_signed = true;
static constexpr bool is_integer = false;
static constexpr bool is_exact = false;
static constexpr int radix = 0;
static constexpr Dumux::Quad epsilon() noexcept
{ return FLT128_EPSILON; }
static constexpr Dumux::Quad round_error() noexcept
{ return 0.5; }
static constexpr int min_exponent = FLT128_MIN_EXP;
static constexpr int min_exponent10 = FLT128_MIN_10_EXP;
static constexpr int max_exponent = FLT128_MAX_EXP;
static constexpr int max_exponent10 = FLT128_MAX_10_EXP;
static constexpr bool has_infinity = true;
static constexpr bool has_quiet_NaN = true;
static constexpr bool has_signaling_NaN = true;
static constexpr float_denorm_style has_denorm = denorm_present;
static constexpr bool has_denorm_loss = false;
static constexpr Dumux::Quad infinity() noexcept
{ return __builtin_huge_valq(); };
static constexpr Dumux::Quad quiet_NaN() noexcept
{ return __builtin_nan(""); }
static constexpr Dumux::Quad signaling_NaN() noexcept
{ return __builtin_nans(""); }
static constexpr Dumux::Quad denorm_min() noexcept
{ return FLT128_DENORM_MIN; }
static constexpr bool is_iec559 = true;
static constexpr bool is_bounded = true;
static constexpr bool is_modulo = false;
static constexpr bool traps = std::numeric_limits<double>::traps;
static constexpr bool tinyness_before = std::numeric_limits<double>::tinyness_before;
static constexpr float_round_style round_style = round_to_nearest;
};
} // namespace std
// Putting the following definitions in the namespace std yields undefined
// behavior. Unfortunately, ADL doesn't work for aliases (Quad) because the underlying type
// is used for the lookup. Putting these functions into any other namespace yields compiler errors.
namespace std {
inline ostream& operator<<(ostream& os, const Dumux::Quad &val)
{
return (os << double(val));
}
inline istream& operator>>(istream& is, Dumux::Quad &val)
{
double tmp;
istream &ret = (is >> tmp);
val = tmp;
return ret;
}
inline Dumux::Quad abs(Dumux::Quad val)
{ return (val < 0)?-val:val; }
inline Dumux::Quad floor(Dumux::Quad val)
{ return floorq(val); }
inline Dumux::Quad ceil(Dumux::Quad val)
{ return ceilq(val); }
inline Dumux::Quad max(Dumux::Quad a, Dumux::Quad b)
{ return (a>b)?a:b; }
inline Dumux::Quad min(Dumux::Quad a, Dumux::Quad b)
{ return (a<b)?a:b; }
inline Dumux::Quad sqrt(Dumux::Quad val)
{ return sqrtq(val); }
template <class ExpType>
inline Dumux::Quad pow(Dumux::Quad base, ExpType exp)
{ return powq(base, exp); }
inline Dumux::Quad exp(Dumux::Quad val)
{ return expq(val); }
inline Dumux::Quad log(Dumux::Quad val)
{ return logq(val); }
inline Dumux::Quad sin(Dumux::Quad val)
{ return sinq(val); }
inline Dumux::Quad cos(Dumux::Quad val)
{ return cosq(val); }
inline Dumux::Quad tan(Dumux::Quad val)
{ return tanq(val); }
inline Dumux::Quad atan(Dumux::Quad val)
{ return atanq(val); }
inline Dumux::Quad atan2(Dumux::Quad a, Dumux::Quad b)
{ return atan2q(a, b); }
inline bool signbit(Dumux::Quad val)
{ return signbitq(val); }
inline bool isfinite(Dumux::Quad val)
{ return !isnanq(val) && !isinfq(val); }
inline bool isnan(Dumux::Quad val)
{ return isnanq(val); }
inline bool isinf(Dumux::Quad val)
{ return isinfq(val); }
} // namespace std
#endif // DUMUX_QUAD_HH
......@@ -27,9 +27,8 @@ dumux_add_test(NAME test_1p_incompressible_tpfa
dumux_add_test(NAME test_1p_incompressible_tpfa_quad
LABELS porousmediumflow 1p
SOURCES main.cc
CMAKE_GUARD HAVE_QUAD
CMAKE_GUARD HAVE_QUADMATH
COMPILE_DEFINITIONS TYPETAG=OnePIncompressibleTpfaQuad NUMDIFFMETHOD=DiffMethod::analytic
LINK_LIBRARIES ${QUADMATH_LIBRARIES}
COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py
CMD_ARGS --script fuzzy
--files ${CMAKE_SOURCE_DIR}/test/references/test_1p_cc-reference.vtu
......
......@@ -27,9 +27,6 @@
#include <ctime>
#include <iostream>
// Support for quad precision has to be included before any other Dune module:
#include <dumux/common/quad.hh>
#include <dune/common/float_cmp.hh>
#include <dune/common/parallel/mpihelper.hh>
#include <dune/common/timer.hh>
......
......@@ -29,10 +29,10 @@
#include <dune/grid/uggrid.hh>
#endif
#include <dune/grid/yaspgrid.hh>
#include <dumux/common/quad.hh>
#if HAVE_QUADMATH
#include <dune/common/quadmath.hh>
#endif
#include <dumux/common/boundarytypes.hh>
#include <dumux/discretization/cctpfa.hh>
#include <dumux/discretization/ccmpfa.hh>
#include <dumux/discretization/box.hh>
......@@ -101,12 +101,12 @@ template<class TypeTag>
struct EnableGridGeometryCache<TypeTag, TTag::OnePIncompressible> { static constexpr bool value = false; };
// define a TypeTag for a quad precision test
#if HAVE_QUAD
#if HAVE_QUADMATH
namespace TTag {
struct OnePIncompressibleTpfaQuad { using InheritsFrom = std::tuple<OnePIncompressibleTpfa>; };
} // end namespace TTag
template<class TypeTag>
struct Scalar<TypeTag, TTag::OnePIncompressibleTpfaQuad> { using type = Quad; };
struct Scalar<TypeTag, TTag::OnePIncompressibleTpfaQuad> { using type = Dune::Float128; };
#endif
} // end namespace Properties
......@@ -140,7 +140,7 @@ public:
if(checkIsConstantVelocity)
{
velocity_[dimWorld-1] = -permeability * dp_dy_;
velocity_[dimWorld-1] /= FluidSystem::viscosity(temperature(), 1.0e5);
velocity_[dimWorld-1] /= FluidSystem::viscosity(temperature(), Scalar(1.0e5));
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment