OpenLB 1.7
Loading...
Searching...
No Matches
descriptorFunction.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2019 Adrian Kummerlaender
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 DESCRIPTOR_FUNCTION_H
25#define DESCRIPTOR_FUNCTION_H
26
27#include <type_traits>
28#include <stdexcept>
29
30#include "descriptorTag.h"
31
32#include "utilities/fraction.h"
33#include "core/meta.h"
34
35namespace olb {
36
37template <typename, unsigned> class Vector;
38
39namespace descriptors {
40
43
44
47
48
49namespace data {
50
52
53template <unsigned D, unsigned Q>
55
56template <unsigned D, unsigned Q>
57platform_constant int c[Q][D] = {};
58
59template <unsigned D, unsigned Q>
61
62template <unsigned D, unsigned Q>
64
65template <unsigned D, unsigned Q>
67
68template <unsigned D, unsigned Q>
70
71template <unsigned D, unsigned Q>
73
74}
75
76template <unsigned D, unsigned Q>
77constexpr int vicinity() any_platform
78{
79 return data::vicinity<D,Q>;
80}
81
82template <unsigned D, unsigned Q>
83constexpr int c(unsigned iPop, unsigned iDim) any_platform
84{
85 return data::c<D,Q>[iPop][iDim];
86}
87
88template <unsigned D, unsigned Q>
89constexpr Vector<int,D> c(unsigned iPop) any_platform
90{
91 return Vector<int,D>(data::c<D,Q>[iPop]);
92}
93
94template <unsigned D, unsigned Q>
95constexpr int opposite(unsigned iPop) any_platform
96{
97 return data::opposite<D,Q>[iPop];
98}
99
100template <typename T, unsigned D, unsigned Q>
101constexpr T t(unsigned iPop, tag::DEFAULT) any_platform
102{
103 return data::t<D,Q>[iPop].template as<T>();
104}
105
106template <typename T, unsigned D, unsigned Q>
107constexpr T invCs2() any_platform
108{
109 return data::cs2<D,Q>.template inverseAs<T>();
110}
111
112template <typename T, unsigned D, unsigned Q>
114{
115 return data::lambda_e<D,Q>.template inverseAs<T>();
116}
117
118template <typename T, unsigned D, unsigned Q>
120{
121 return data::lambda_h<D,Q>.template inverseAs<T>();
122}
123
125
126template <typename DESCRIPTOR>
127constexpr int d() any_platform
128{
129 return DESCRIPTOR::d;
130}
131
132struct dimension {
133 template <typename DESCRIPTOR>
135 return d<DESCRIPTOR>;
136 }
137};
138
139template <typename DESCRIPTOR>
140constexpr int q() any_platform
141{
142 return DESCRIPTOR::q;
143}
144
145template <typename DESCRIPTOR>
146constexpr int vicinity() any_platform
147{
148 return vicinity<DESCRIPTOR::d, DESCRIPTOR::q>();
149}
150
151template <typename DESCRIPTOR>
152constexpr int c(unsigned iPop, unsigned iDim) any_platform
153{
154 return c<DESCRIPTOR::d, DESCRIPTOR::q>(iPop, iDim);
155}
156
157template <typename DESCRIPTOR>
159{
160 return c<DESCRIPTOR::d, DESCRIPTOR::q>(iPop);
161}
162
163template <typename DESCRIPTOR>
164constexpr int opposite(unsigned iPop) any_platform
165{
166 return opposite<DESCRIPTOR::d, DESCRIPTOR::q>(iPop);
167}
168
169template <typename T, typename DESCRIPTOR>
170constexpr T t(unsigned iPop) any_platform
171{
172 return t<T, DESCRIPTOR::d, DESCRIPTOR::q>(iPop, typename DESCRIPTOR::category_tag());
173}
174
175template <typename T, typename DESCRIPTOR>
176constexpr T invCs2() any_platform
177{
178 return invCs2<T, DESCRIPTOR::d, DESCRIPTOR::q>();
179}
180
181template <typename T, typename DESCRIPTOR>
183{
184 return lambda_e<T, DESCRIPTOR::d, DESCRIPTOR::q>();
185}
186
187template <typename T, typename DESCRIPTOR>
189{
190 return lambda_h<T, DESCRIPTOR::d, DESCRIPTOR::q>();
191}
192
194template <typename DESCRIPTOR, typename PREDICATE>
195constexpr auto filter_population_indices(PREDICATE predicate) any_platform {
196 return meta::filter_index_sequence(predicate,
197 std::make_index_sequence<DESCRIPTOR::q>());
198}
199
201
202}
203
204}
205
206#endif
Plain old scalar vector.
Definition vector.h:47
Floating-point independent fraction type.
Definition fraction.h:34
platform_constant Fraction lambda_e
platform_constant Fraction lambda_h
platform_constant int opposite[Q]
platform_constant Fraction cs2
platform_constant int vicinity
platform_constant Fraction t[Q]
platform_constant int c[Q][D]
constexpr T lambda_h() any_platform
constexpr int q() any_platform
constexpr T invCs2() any_platform
constexpr T t(unsigned iPop, tag::CUM) any_platform
Definition cum.h:69
constexpr int c(unsigned iPop, unsigned iDim) any_platform
constexpr int d() any_platform
constexpr int opposite(unsigned iPop) any_platform
constexpr int vicinity() any_platform
constexpr auto filter_population_indices(PREDICATE predicate) any_platform
Return array of population indices of DESCRIPTOR matching PREDICATE.
constexpr T lambda_e() any_platform
constexpr auto filter_index_sequence()
Return index sequence of Is matching COND using index_sequence of TYPES.
Definition meta.h:465
Top level namespace for all of OpenLB.
#define platform_constant
Definition platform.h:79
#define any_platform
Define preprocessor macros for device-side functions, constant storage.
Definition platform.h:78
constexpr auto operator()(meta::id< DESCRIPTOR >=meta::id< DESCRIPTOR >{}) const
Implicit default category of normal descriptors.
Identity type to pass non-constructible types as value.
Definition meta.h:79