NeoN
WIP Prototype of a modern OpenFOAM core
Loading...
Searching...
No Matches
scalar.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// SPDX-FileCopyrightText: 2023 NeoN authors
3#pragma once
4
5#include <Kokkos_Core.hpp> // IWYU pragma: keep
7
8// TODO this needs to be implemented in the corresponding cmake file
9namespace NeoN
10{
11#ifdef NeoN_DP_SCALAR
12typedef double scalar;
13#else
14typedef float scalar;
15#endif
16
17constexpr scalar ROOTVSMALL = 1e-18;
18
19KOKKOS_INLINE_FUNCTION
20scalar mag(const scalar& s) { return std::abs(s); }
21
22// traits for scalar
23template<>
24KOKKOS_INLINE_FUNCTION scalar one<scalar>()
25{
26 return 1.0;
27};
28
29template<>
30KOKKOS_INLINE_FUNCTION scalar zero<scalar>()
31{
32 return 0.0;
33};
34
35} // namespace NeoN
KOKKOS_INLINE_FUNCTION scalar one< scalar >()
Definition scalar.hpp:24
KOKKOS_INLINE_FUNCTION scalar mag(const scalar &s)
Definition scalar.hpp:20
float scalar
Definition scalar.hpp:14
constexpr scalar ROOTVSMALL
Definition scalar.hpp:17
KOKKOS_INLINE_FUNCTION scalar zero< scalar >()
Definition scalar.hpp:30