NeoN
A framework for CFD software
Loading...
Searching...
No Matches
scalar.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2023 - 2026 NeoN authors
2//
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
7#include <Kokkos_Core.hpp> // IWYU pragma: keep
8
10
11// TODO this needs to be implemented in the corresponding cmake file
12namespace NeoN
13{
14#ifdef NeoN_DP_SCALAR
15typedef double scalar;
16#else
17typedef float scalar;
18#endif
19
20constexpr scalar ROOTVSMALL = 1e-18;
21
22KOKKOS_INLINE_FUNCTION
23scalar mag(const scalar& s) { return std::abs(s); }
24
25// traits for scalar
26template<>
27KOKKOS_INLINE_FUNCTION scalar one<scalar>()
28{
29 return 1.0;
30};
31
32template<>
33KOKKOS_INLINE_FUNCTION scalar zero<scalar>()
34{
35 return 0.0;
36};
37
38template<>
39KOKKOS_INLINE_FUNCTION scalar inv<scalar>(scalar in)
40{
41 return 1.0 / in;
42};
43
44} // namespace NeoN
Integer types used throughout NeoN.
Definition array.hpp:18
KOKKOS_INLINE_FUNCTION scalar one< scalar >()
Definition scalar.hpp:27
KOKKOS_INLINE_FUNCTION scalar mag(const scalar &s)
Definition scalar.hpp:23
float scalar
Definition scalar.hpp:17
constexpr scalar ROOTVSMALL
Definition scalar.hpp:20
KOKKOS_INLINE_FUNCTION scalar zero< scalar >()
Definition scalar.hpp:33
KOKKOS_INLINE_FUNCTION scalar inv< scalar >(scalar in)
Definition scalar.hpp:39