OGS
TimeIncrement.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include <algorithm>
7#include <cmath>
8#include <compare>
9#include <iomanip>
10#include <limits>
11
12#include "MathLib/KahanSum.h"
13
14namespace NumLib
15{
16struct TimeIncrement;
17}
18
19template <>
20struct fmt::formatter<NumLib::TimeIncrement> : fmt::ostream_formatter
21{
22};
23
24namespace NumLib
25{
27{
28 constexpr explicit TimeIncrement(double const dt) : value_{dt} {}
29
30 constexpr double operator()() const { return value_; }
31
32 friend inline std::ostream& operator<<(std::ostream& os,
33 TimeIncrement const& dt)
34 {
35 auto const precision = os.precision();
36 return os << std::setprecision(
37 std::numeric_limits<double>::max_digits10)
38 << dt.value_ << std::setprecision(precision);
39 }
40
41private:
42 double value_;
43};
44
45} // namespace NumLib
friend std::ostream & operator<<(std::ostream &os, TimeIncrement const &dt)
constexpr double operator()() const
constexpr TimeIncrement(double const dt)