forked from brucedjones/pyck
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodel.h
More file actions
203 lines (171 loc) · 6.63 KB
/
model.h
File metadata and controls
203 lines (171 loc) · 6.63 KB
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#ifndef MODEL_H
#define MODEL_H
#include <string>
#include <vector>
#include <map>
#include <vector>
#include <Python.h>
#include "pack.h"
#include "writer.h"
class Model {
public:
/**
* Model Constructor, creates an empty model with no particles
*/
Model();
/**
* Model Constructor
* @param pack Packed pack object
*/
Model(Pack *pack);
/**
* Model Constructor
* @param positions N x 3 array of positions, third dimension should be 0.0 for 2d
* @param states N x 1 array of pack states
* @param numParticles Specifies N particles
* @param dim Specifies the dimensionality of the pack
*/
Model(double *positions, int *states, long numParticles, int dim);
/**
* Model Constructor
* @param positions N x 3 array of positions, third dimension should be 0.0 for 2d
* @param states N x 1 array of pack states
* @param numParticles Specifies N particles
* @param dim Specifies the dimensionality of the pack
*/
Model(std::vector<double> positions, std::vector<int> states, long numParticles, int dim);
~Model();
/**
* Append particles from another pack to this model
* @param pack A fully processed pack object
*/
void AddPack(Pack *pack);
/**
* Append particles to this model
* @param positions Nx3 array of positions (x1,y1,z1,x2,y2,z2,...,xn,yn,zn)
* @param states Length N integer array of states
* @param numParticles Number of particles to add
* @param dim Dimensionality of the pack
*/
void AddPack(double *positions, int *states, long numParticles, int dim);
/**
* Append particles to this model
* @param positions Nx3 array of positions (x1,y1,z1,x2,y2,z2,...,xn,yn,zn)
* @param states Length N integer array of states
* @param numParticles Number of particles to add
* @param dim Dimensionality of the pack
*/
void AddPack(std::vector<double> positions, std::vector<int> states, long numParticles, int dim);
/**
* Create a dim dimensional field of integers
* @param name Name of the field
* @param dim dimensionality of the field
* @return A Handle to the field so that values may be set
*/
int CreateIntField(std::string name, int dim);
/**
* Create a dim dimensional field of floats
* @param name Name of the field
* @param dim dimensionality of the field
* @return A Handle to the field so that values may be set
*/
int CreateDoubleField(std::string name, int dim);
/**
* Set the values of an integer field
* @param handle Handle of the field to be set
* @param state particle state for which these values will be applied
* @param val Array of length equal to the dimensionality of the field
*/
void SetIntField(int handle, int state, std::vector<int> val);
/**
* Set the values of an integer field
* @param handle Handle of the field to be set
* @param state particle state for which these values will be applied
* @param val Value to set
*/
void SetIntField(int handle, int state, int val);
/**
* Set the values of an integer field
* @param handle Handle of the field to be set
* @param state particle state for which these values will be applied
* @param PyFunc Python callback used to determine the value of the field for any given particle. Callback takes an array indicating xyz position, and returns the value of the field at this position.
*/
void SetIntField(int handle, int state, PyObject *PyFunc);
/**
* Get a pointer to a DoubleField
* @param handle Handle of the field
*/
IntField *GetIntField(int handle);
/**
* Get the xyz position of a particle
*/
double *GetPositions();
/**
*/
int GetNumberParticles();
/**
* Set the values of an float field
* @param handle Handle of the field to be set
* @param state particle state for which these values will be applied
* @param val Value to set
*/
void SetDoubleField(int handle, int state, double val);
/**
* Set the values of an float field
* @param handle Handle of the field to be set
* @param state particle state for which these values will be applied
* @param val Array of length equal to the dimensionality of the field
*/
void SetDoubleField(int handle, int state, std::vector<double> val);
/**
* Set the values of a float field
* @param handle Handle of the field to be set
* @param state particle state for which these values will be applied
* @param PyFunc Python callback used to determine the value of the field for any given particle. Callback takes an array indicating xyz position, and returns the value of the field at this position.
*/
void SetDoubleField(int handle, int state, PyObject *PyFunc);
/**
* Get a pointer to a DoubleField
* @param handle Handle of the field
*/
DoubleField *GetDoubleField(int handle);
/**
* Add a parameter to the domain
* @param key The label for this parameter
* @param value The value of this parameter
*/
void SetParameter(std::string key, std::string value);
/**
* Add a parameter to the domain
* @param parameters Map of parameters to add
*/
void SetParameters(std::map<std::string, std::string> ¶meters);
/**
* Read a parameter of integer type
* @param key Parameter name
*/
int ReadSingleIntegerParameter(std::string key);
/**
* Read a parameter of double type or a double array
* Note: n can be as large as 3, but cannot be larger than 3 due to vector interface in swig.
* @param key: parameter name
* @param n: number of elements
*/
std::vector<double> ReadMultipleDoubleParameter(std::string key, int n);
/**
* Write domain to CSV file
* @param fname Output filename
*/
void Serialize(std::string fname, Writer *writer);
private:
double *positions;
int *states;
long numParticles;
int dim;
std::vector<IntField*> intFields; /**< Vector of integer fields */
std::vector<DoubleField*> doubleFields; /**< Vector of double fields */
std::map<std::string, std::string> parameters; /**< Map of parameters */
template<typename T>
int Process_Python_Result(PyObject* incoming, std::vector<T> *data);
};
#endif