-
Notifications
You must be signed in to change notification settings - Fork 0
/
user_specific_initial_particle_setting.cpp
50 lines (37 loc) · 1.28 KB
/
user_specific_initial_particle_setting.cpp
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
/*!
* \author Yu, Kwangmin <yukwangmin@gmail.com>
* \date Thu Oct. 27 2012
*
*/
#include <cmath>
#include "user_specific_initial_particle_setting.h"
size_t TestParticleSetting1::fillGrid(std::vector<bool>& level_set) {
size_t xgridsize, ygridsize, zgridsize;
double xleft, yleft, zleft, xright, yright, zright;
double dx, dy, dz;
getGridSize(xgridsize, ygridsize, zgridsize);
getDomain(xleft, yleft, zleft, xright, yright, zright);
dx = (xright-xleft)/xgridsize;
dy = (yright-yleft)/ygridsize;
dz = (zright-zleft)/zgridsize;
level_set.clear();
size_t size = (xgridsize+1)*(ygridsize+1)*(zgridsize+1);
level_set.resize(size);
//Now fill up the grid.
size_t index;
for (size_t k = 0; k < zgridsize; ++k) {
for (size_t j = 0; j < ygridsize; ++j) {
for (size_t i = 0; i < xgridsize; ++i) {
index = i + j*xgridsize + k*xgridsize*ygridsize;
//A diamond shaped region.
//double temp = fabs( xleft + i*dx - 0.128) + fabs( yleft + j*dy - 0.128) + fabs( zleft + k*dz - 0.128);
if ( fabs( xleft + i*dx - 0.128) + fabs( yleft + j*dy - 0.128) + fabs( zleft + k*dz - 0.576) <= 0.128 ) {
level_set[index] = true;
} else {
level_set[index] = false;
}
}
}
}
return size;
}