summaryrefslogtreecommitdiff
path: root/c++/examples/cavity_2d.cpp
blob: 0f96a654ef38e3f44f65b3e4b73a85e0706b2ddf (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
#include "../descriptor.h"

#include <forstio/codec/data.h>

namespace kel {
namespace lbm {
namespace schema {

/**
 * Basic distribution function
 * Base type
 * D
 * Q
 * Scalar factor
 * D factor
 * Q factor
 */
using DfCell2DType = CellType<Float32, 2, 5, 0, 0, 1>;

using CellInfo2DType = CellType<UInt8, 2, 5, 1, 0, 0>;

/**
 * Basic type for simulation
 */
using Cell = CellData<
	Member<DfCell2DType, "dfs">,
	Member<CellInfo2DType, "info">
>;

}
}
}

template<typename Func, typename Schema, size_t Dim>
void apply_for_cells(Func&& func, saw::data<saw::schema::Array<Schema, Dim>, saw::encode::Native>& dat ){
	for(std::size_t i = 0; i < dat.get_dim_size(0); ++i){
		for(std::size_t j = 0; j < dat.get_dim_size(1); ++j){
			func(dat.at(i,j), i, j);
		}
	}
}

int main(){
	using namespace kel::lbm;

	saw::data<schema::Lattice<kel::lbm::schema::Cell,2>, saw::encode::Native> lattice{512, 512};

	apply_for_cells([](auto& cell, std::size_t i, std::size_t j){
		// cell.get<"info">();
	}, lattice);

	return 0;
}