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
#![feature(test)]
#![feature(step_by)]
extern crate test;
extern crate core;
#[macro_use]
extern crate arrayref;
extern crate image;
extern crate rayon;
extern crate sdl2;
pub mod moments;
pub mod cell;
pub mod multi_lattice2d;
pub mod lattice2d;
pub mod lattice_ops_2d;
pub mod descriptor2d;
pub mod dynamics;
pub mod io;
pub mod point2d;
pub mod box2d;
pub mod communicator;
pub mod ind_hlp;
pub mod fd_hlp2d;
pub mod lbm_hlp2d;
pub mod colormaps;
pub mod proc_fun;
pub mod red_proc_fun;
pub mod units;
pub mod util;
#[macro_use]
#[cfg(test)]
mod benches {
use test;
use test::Bencher;
const NX: i32 = 500;
const NY: i32 = 500;
#[bench]
fn bench_ml_collide_and_stream(b: &mut Bencher) {
use cell;
use cell::BGK;
use multi_lattice2d::MultiLattice2d;
use lattice_ops_2d::LatticeOps2d;
let omega = 1.9f64;
let (cx,cy):(i32,i32) = ((NX-1)/2,(NY-1)/2);
let sigma = ((NX+NY)/2/10) as f64;
let gauss_rho = |_x:i32,_y:i32| -> f64 {
1.0 + 0.01*((-(_x as i32-cx)*(_x as i32-cx)-(_y as i32-cy)*(_y as i32-cy)) as f64/(2.0*sigma)).exp()
};
let const_u = |_x:i32,_y:i32| -> [f64; cell::D] { [0.1, -0.1] };
let mut lattice = MultiLattice2d::new_eq(
NX as usize,NY as usize, 2, 2, 1, gauss_rho, const_u, BGK::new(omega));
b.iter(|| {
let n = test::black_box(10);
for _i in 0..n {
lattice.collide_and_stream();
}
} );
}
#[bench]
fn bench_ml_collide(b: &mut Bencher) {
use cell;
use cell::BGK;
use multi_lattice2d::MultiLattice2d;
use lattice_ops_2d::LatticeOps2d;
let omega = 1.9f64;
let (cx,cy):(i32,i32) = ((NX-1)/2,(NY-1)/2);
let sigma = ((NX+NY)/2/10) as f64;
let gauss_rho = |_x:i32,_y:i32| -> f64 {
1.0 + 0.01*((-(_x as i32-cx)*(_x as i32-cx)-(_y as i32-cy)*(_y as i32-cy)) as f64/(2.0*sigma)).exp()
};
let const_u = |_x:i32,_y:i32| -> [f64; cell::D] { [0.1, -0.1] };
let mut lattice = MultiLattice2d::new_eq(
NX as usize,NY as usize, 2, 2, 1, gauss_rho, const_u, BGK::new(omega));
b.iter(|| {
lattice.collide()
} );
}
#[bench]
fn bench_ml_stream(b: &mut Bencher) {
use cell;
use cell::BGK;
use multi_lattice2d::MultiLattice2d;
use lattice_ops_2d::LatticeOps2d;
let omega = 1.9f64;
let (cx,cy):(i32,i32) = ((NX-1)/2,(NY-1)/2);
let sigma = ((NX+NY)/2/10) as f64;
let gauss_rho = |_x:i32,_y:i32| -> f64 {
1.0 + 0.01*((-(_x as i32-cx)*(_x as i32-cx)-(_y as i32-cy)*(_y as i32-cy)) as f64/(2.0*sigma)).exp()
};
let const_u = |_x:i32,_y:i32| -> [f64; cell::D] { [0.1, -0.1] };
let mut lattice = MultiLattice2d::new_eq(
NX as usize,NY as usize, 2, 9, 1, gauss_rho, const_u, BGK::new(omega));
b.iter(|| {
lattice.bulk_stream();
lattice.bd_stream();
} );
}
}