OpenLB 1.8.1
Loading...
Searching...
No Matches
oalgorithm.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2020 Jan E. Marquardt
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
24#ifndef OLB_OALGORITHM_H
25#define OLB_OALGORITHM_H
26
27#include <algorithm>
28
29#include "core/meta.h"
30#include "core/expr.h"
32
33namespace olb {
34
35namespace util {
36
37// Max
38template <typename T>
39any_platform constexpr T max(T a, meta::id_t<T> b) {
40#ifdef __CUDA_ARCH__
41 return ::max(a, b);
42#else
43 return std::max(a, b);
44#endif
45}
46
47template <typename T>
48constexpr T max(std::initializer_list<T> ilist) {
49 return std::max(ilist);
50}
51
52Expr max(Expr a, Expr b);
53
54// Min
55template <typename T>
56any_platform constexpr T min(T a, meta::id_t<T> b) {
57#ifdef __CUDA_ARCH__
58 return ::min(a, b);
59#else
60 return std::min(a, b);
61#endif
62}
63
64template <typename T>
65inline constexpr T min( std::initializer_list<T> ilist ) {
66 return std::min(ilist);
67}
68
69Expr min(Expr a, Expr b);
70
71} // namespace util
72
73} // namespace olb
74
75#endif
Basic value-substitute enabling extraction of expression trees for code generation.
Definition expr.h:39
typename id< TYPE >::type id_t
Definition meta.h:92
Expr min(Expr a, Expr b)
Definition expr.cpp:249
Expr max(Expr a, Expr b)
Definition expr.cpp:245
Top level namespace for all of OpenLB.
#define any_platform
Define preprocessor macros for device-side functions, constant storage.
Definition platform.h:77