summaryrefslogtreecommitdiff
path: root/c++/descriptor.h
blob: 1d22f91f5ef162f7a177bc6e7b79d554d673f14a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#pragma once

#include <forstio/codec/data.hpp>

namespace kel {
namespace lbm {
namespace schema {
using namespace saw::schema;

template<typename T, uint64_t D, uint64_t Q>
struct Descriptor {};

template<typename T, uint64_t D, uint64_t Q, uint64_t SC, uint64_t DC, uint64_t QC>
using CellType = FixedArray<T,SC+D*DC+Q*QC>;

/**
 * T... is restricted to Member schemas
 */
template<typename... CellT> 
using CellData = Struct<
	CellT...
>;

/**
 * T is an array of CellData
 */
template<typename T, size_t D>
using Lattice = Array<T, D>;
}

template<typename T>
class df_info{};

template<typename T>
class df_info<schema::Descriptor<T, 2, 5>> {
	static constexpr std::array<std::array<int32_t, 2>, 5> directions = {{
		{ 0, 0},
		{-1, 0},
		{ 0,-1},
		{ 0, 1},
		{ 1, 0}
	}};

	static constexpr std::array<typename saw::native_data_type<T>::type,5> weights = {
		1./3.,
		1./6.,
		1./6.,
		1./6.,
		1./6.
	};

	static constexpr typename saw::native_data_type<T>::type cs2 = 1./3.;
};
}
}