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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
#include <kel/lbm/lbm.hpp>
#include <kel/lbm/sycl/lbm.hpp>
#include <forstio/remote/filesystem/easy.hpp>
#include <forstio/codec/json/json.hpp>
namespace kel {
namespace lbm {
constexpr uint64_t dim_x = 16u;
constexpr uint64_t dim_y = 4u;
namespace sch {
using namespace saw::schema;
template<typename T, typename Desc>
using CellStruct = Struct<
Member<FixedArray<T,Desc::Q>, "dfs">,
Member<FixedArray<T,Desc::Q>, "dfs_old">,
Member<UInt8, "info">,
Member<Vector<T,Desc::D>, "velocity">,
Member<Vector<T,Desc::D>, "force">
>;
using InfoChunk = Chunk<UInt8, 0u, dim_x, dim_y>;
template<typename T, typename Desc>
using DfChunk = Chunk<FixedArray<T,Desc::Q>, 1u, dim_x, dim_y>;
template<typename T, typename Desc>
using ChunkStruct = Struct<
Member<InfoChunk, "info">
>;
}
template<typename T, typename Desc>
saw::error_or<void> setup_initial_conditions(saw::data<sch::ChunkStruct<T,Desc>>& fields){
auto& info_f = fields.get<"info">();
// Set everything as walls
iterator<Desc::D>::apply(
[&](auto& index){
info_f.at(index).set(2u);
},
{{0u,0u}},
{{dim_x, dim_y}},
{{0u,0u}}
);
// Fluid
iterator<Desc::D>::apply(
[&](auto& index){
info_f.at(index).set(1u);
},
{{0u,0u}},
{{dim_x, dim_y}},
{{1u,1u}}
);
// Inflow
iterator<Desc::D>::apply(
[&](auto& index){
info_f.at(index).set(3u);
},
{{0u,0u}},
{{1u, dim_y}},
{{0u,1u}}
);
// Outflow
iterator<Desc::D>::apply(
[&](auto& index){
info_f.at(index).set(4u);
},
{{dim_x-1u,0u}},
{{dim_x, dim_y}},
{{0u,1u}}
);
return saw::make_void();
}
template<typename T, typename Desc>
saw::error_or<void> step(){
return saw::make_void();
}
}
}
template<typename T, typename Desc>
saw::error_or<void> lbm_main(int argc, char** argv){
using namespace kel::lbm;
using dfi = df_info<T,Desc>;
auto eo_lbm_dir = output_directory();
if(eo_lbm_dir.is_error()){
return std::move(eo_lbm_dir.get_error());
}
auto& lbm_dir = eo_lbm_dir.get_value();
auto out_dir = lbm_dir / "poiseulle_particles_2d_gpu";
converter<sch::Float64> conv {
// delta_x
{{1.0}},
// delta_t
{{1.0}}
};
// saw::data<sch::FixedArray<sch::UInt64,Desc::D>> meta{{dim_x,dim_y}};
saw::data<sch::ChunkStruct<T,Desc>> lbm_data{};
acpp::sycl::queue sycl_q;
sycl_q.wait();
{
auto eov = setup_initial_conditions<T,Desc>(lbm_data);
if(eov.is_error()){
return eov;
}
}
/*
iterator<Desc::D>::apply(
[&](auto& index){
std::cout<<index.at({0u}).get()<<" "<<index.at({1u}).get()<<" "<<lbm_data.get<"info">().at(index).template cast_to<sch::UInt16>().get()<<"\n";
},
{{0u,0u}},
{{dim_x, dim_y}}
);
*/
return saw::make_void();
}
using FloatT = kel::lbm::sch::Float32;
int main(int argc, char** argv){
auto eov = lbm_main<FloatT,kel::lbm::sch::D2Q9>(argc, argv);
if(eov.is_error()){
auto& err = eov.get_error();
std::cerr<<"[Error] "<<err.get_category();
auto err_msg = err.get_message();
if(err_msg.size() > 0u){
std::cerr<<" - "<<err_msg;
}
std::cerr<<std::endl;
return err.get_id();
}
return 0;
}
|