-
Notifications
You must be signed in to change notification settings - Fork 0
/
gpuAV.h
144 lines (127 loc) · 4.44 KB
/
gpuAV.h
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
#include <iostream>
#include <unistd.h>
#include <memory>
#include <stdlib.h>
#include <cmath>
#include <queue>
#include <set>
#include <vector>
using std::cout;
using std::endl;
using namespace std::chrono;
#ifndef AV_H
#define AV_H
namespace AnisoVoro {
class Position {
public:
double x, y, z;
Position();
Position(double x, double y, double z);
//friend std::ostream& operator<<(std::ostream &os, const Position &p);
//Position& operator<<(const Position& p);
//~Position();
};
//Shapes are centered at the origin by default
class Shape {
public:
std::vector<Position> points;
//int voxDegree;
Shape();
Shape(std::vector<Position>& points);
Shape(std::vector<int> &shapePoints, int xDim, int yDim, int zDim, int voxDegree);
//shapeFromVertices(std::vector<Position>& v, int vD);
};
class Quaternion {
public:
double w;
double x;
double y;
double z;
Quaternion();
Quaternion(double w, double x, double y, double z);
};
Position rotatePoint(Position p, Quaternion q);
Position rotatePoint(double pd[3], double qd[4]);
class BoxDim {
public:
double x, y, z;
BoxDim();
BoxDim(double x, double y, double z);
void print();
};
class VoxelIndex{
public:
int i, x, y, z;
VoxelIndex();
VoxelIndex(Position vbp, BoxDim vbd);
VoxelIndex(int i, BoxDim vbd);
//~VoxelIndex();
};
class VoxelBit {
public:
int layer;
VoxelIndex index;
std::set<int> origins;
bool isParticle, isBoundary;
//~VoxelBit();
VoxelBit();
VoxelBit(int i, bool isParticle, int particleNum, BoxDim vbd);
void getNeighborsIndices2D(BoxDim vbd, int (&neighbors)[8]);
void getNeighborsIndices3D(BoxDim vbd, int (&neighbors)[26]);
};
class VoxelVector {
public:
std::vector<VoxelBit> v;
VoxelVector();
VoxelVector(int size);
VoxelVector(int xLength, int yLength, int zLength, int voxDegree);
};
class SimBox {
public:
std::vector<VoxelBit> pVoxArr; // initial particle voxelization
std::vector<Shape> shapeArr;
std::vector<Position> positions;
int voxDegree; //number of voxels per simulation box unit
BoxDim simBoxDim;
BoxDim voxBoxDim; //simUnitBoxDim * voxDegree
bool is2D;
int partNum;
Position center;
Position voxCenter;
SimBox();
SimBox(double xLength, double yLength, double zLength,
std::vector<VoxelBit>& pVoxArr, int voxDegree);
SimBox(double xLength, double yLength, double zLength, int voxDegree);
void setVoxel(Position p, bool isParticle, int particleNum);
void placeShape(Shape s, Quaternion q, Position p, int particleNum);
//void particleTypes(std::vector<int>& type_id,
// std::vector<std::vector<Position>>& particleTypes,
// std::vector<Position> positions,
// std::vector<Quaternion>& orientations);
//std::vector<double> localDensity();
//std::vector<std::vector<int> > densityNeighbors();
int particleNum();
void particleNum(int num);
void printBox();
void printBoundaries();
void printCells();
void runVoro();
//~SimBox();
private:
std::vector<int> voxelTracker;
std::vector<VoxelBit> neighbors;
std::queue<int> layerRun;
std::queue<int> originRun;
std::queue<int> boundaryIndices;
void initialize();
void adjustPosition(Position &p);
int indexFromPosition(Position p);
Position positionFromIndex(int i);
void initializeQueue();
void runLayerByLayer();
void updateNeighbors(int currentLayer, VoxelBit& v);
void updateOrigins(int currentLayer);
void originUpdater(int currentLayer, VoxelBit& v);
};
}
#endif