SDK Manual
SDK Manual
Release 8.0.0
1 Start 1
1.1 Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2.1 Plugin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2.2 Standalone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2.3 Viewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2.4 Python API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2.5 Available Objects and Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Multi-thread . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.4 Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2 Objects 5
2.1 Session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2 Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.3 Scene . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.3.1 Active state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.3.2 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.4 Node . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.4.1 Properties (Input) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.4.2 Properties (Result) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
2.4.3 Properties (View) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
2.4.4 Properties (Post) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
2.4.5 Properties (Details) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
2.4.6 Properties (Appearance) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
2.5 Widget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
2.5.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
2.6 Colormap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
2.6.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
2.6.2 Field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
2.7 Material . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
2.7.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
2.8 Particles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
2.9 Distance Field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
2.10 Interaction (p-p) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
2.10.1 Interaction Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
i
2.11 Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
2.11.1 Particles Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
2.11.2 Distance Field Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
2.11.3 Particles Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
2.11.4 Node (mapping) Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
2.11.5 Tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
2.12 Solver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
2.12.1 Analysis Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
2.13 User Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
2.13.1 Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
2.13.2 Kernel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
2.13.3 Sub Kernel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
2.14 Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
2.15 Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
2.16 Task Queue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
2.17 Task . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
2.18 Capture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
2.18.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
2.19 Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
2.19.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
2.20 Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
2.20.1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
2.21 Result File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
ii
3.8.1 Data Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
3.8.2 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
3.9 Particles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
3.9.1 Data Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
3.9.2 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
3.10 Result File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
3.10.1 Data Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
3.10.2 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
3.11 Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
3.11.1 Data Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
3.11.2 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
3.12 Interaction (p-p) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
3.12.1 Data Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
3.12.2 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
3.12.3 Multi Thread . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
3.13 Solver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
3.13.1 Data Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
3.13.2 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
3.14 User Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
3.14.1 Data Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
3.15 Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
3.15.1 Data Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
3.15.2 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
3.16 Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
3.16.1 Data Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
3.16.2 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
3.17 Task Queue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
3.17.1 Data Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
3.17.2 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
3.18 Capture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
3.18.1 Data Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
3.18.2 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
3.19 Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
3.19.1 Data Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
3.19.2 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
3.20 String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
3.20.1 Data Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
3.20.2 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
3.21 Miscellaneous . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
3.21.1 signature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
3.21.2 Data Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
3.21.3 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
3.22 User Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
3.22.1 User-Defined Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
iii
4.3 txt file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
4.3.1 Filename . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
4.3.2 Example of How to Write . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
4.3.3 Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
4.4 json file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
4.4.1 Filename . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
4.4.2 Example of How to Write . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
4.4.3 Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
iv
6.4.3 Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
6.4.4 Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
6.4.5 Scene . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
6.4.6 Node . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
6.4.7 AnimationValue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
6.4.8 PotentialCoefficient . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
6.4.9 ConnectedInflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
6.4.10 Arrays, ScalarArray, Vector3Array, Matrix3x3Array . . . . . . . . . . . . . . . . 301
6.4.11 ResultFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304
6.4.12 Material, Colormap, Widget, Settings . . . . . . . . . . . . . . . . . . . . . . . . 305
6.4.13 Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306
6.4.14 TaskQueue, Task . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306
6.4.15 ScreenShot, Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
6.4.16 Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
6.4.17 Math . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
6.4.18 Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
6.4.19 LBM Reader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
6.5 Sample : Running simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
6.6 Sample : Postprocessing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318
6.7 Sample : Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
6.8 Sample : matplotlib . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323
6.8.1 Backend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
6.9 Sample : Input dialog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
6.10 Sample : Simulation Result File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328
6.11 Sample : Mapping Result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330
8 Examples 339
8.1 Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339
8.2 C++ Sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339
8.2.1 C and C++ Languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339
8.2.2 C++ Wrapper File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341
8.3 Example Program Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343
8.3.1 Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343
8.3.2 Module Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343
8.4 Example: Calculation of Particle Number Density (Interactions) . . . . . . . . . . . . . . . 345
8.4.1 Objective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
v
8.4.2 Study Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
8.4.3 Physical Quantities Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
8.4.4 User Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
8.5 Example: User-Defined Viscosity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
8.5.1 Objective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
8.5.2 Study Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
8.5.3 Physical Quantities Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
8.5.4 User Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
8.6 Example: Manipulating Inflow Particles . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
8.6.1 Objective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
8.6.2 Study Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
8.6.3 Physical Quantities Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
8.6.4 User Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
8.7 Example: Adding a Physical Quantity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351
8.7.1 Objective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351
8.7.2 Study Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351
8.7.3 Physical Quantities Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351
8.7.4 User Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
8.8 Example: Number of Collisions of DEM Particles . . . . . . . . . . . . . . . . . . . . . . 352
8.8.1 Objective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
8.8.2 Study Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
8.8.3 Physical Quantities Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
8.8.4 User Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
8.9 Example: Calculation of the Volume Fraction of Fluid Particles (Interactions). . . . . . . . 354
8.9.1 Objective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354
8.9.2 Study Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354
8.9.3 Physical Quantities Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354
8.9.4 User Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
8.10 Example: Calculation of the DEM Particle Number Density (Interactions). . . . . . . . . . 355
8.10.1 Objective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
8.10.2 Study Case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
8.10.3 Physical Quantities Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
8.10.4 User Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356
Bibliography 357
vi
CHAPTER
ONE
START
Particleworks/Granuleworks has a C-language API that can be used for your specific needs. Describes how
to use this API.
1.1 Distribution
The SDK has the following directory structure and include in the Particleworks/Granuleworks distribution.
Directory Description
sdk/include Header
sdk/lib Imported libraries
doc/ja/SDK This documentation (Japanese)
doc/en/SDK This documentation (English)
share/sdk/src Examples source codes
share/sdk/project Examples projects
1
SDK Manual, Release 8.0.0
Headers and imported libraries are required to build user programs. See User-Created Programs.
Example source codes can be seen in the Examples section.
1.2 Mode
1.2.1 Plugin
User applications are created as DLLs and work as added functionalities to the solver.
• Available API is limited compared to Standalone. For example, you cannot call
PW_SESSION_write_particles().
• The following analysis is possible:
– RecurDyn coupling
– MPI
Note: The solver can use the Plugin under the following conditions:
• It is in the same directory as the Solver executable (app.solver.float or app.solver.double) or
in the directory specified by the command line option --plugin_dir.
• Filename starts with pw.plugin..
• Having Extension DLLs (.dll on Windows, .so on Linux)
• PW_MODULE_initialize() and PW_MODULE_terminate() are exported.
• PW_MODULE_initialize() call returns PW_ERROR_no_error.
2 Chapter 1. Start
SDK Manual, Release 8.0.0
1.2.2 Standalone
Creates a user application as an exe that links to the SDK DLL version. It is mainly assumed to be used for
postprocessing.
• Debugging is easy because you can control Particleworks / Granuleworks execution.
• You can create postprocessing tools that import and edit execution result files.
• Operations such as adding Node to Scene are not possible.
• The following analysis can not be performed.
– RecurDyn coupling
– MPI
1.2.3 Viewer
Creates a user application as an exe that links to the SDK DLL version. It is assumed to be used for a tool
for GUI operations.
• You can create Project, add Node to Scene, and so on.
• Solver or User Function cannot be handled.
• Preprocessing, analysis execution, and postprocessing start and execute as external processes.
You can also call the API using Python. See Python Reference for details. Using the Python API consumes
a license for the Viewer SDK.
Mode determines which objects and functions are available. The tables in Objects and API Reference are
described as follows.
Functions P S V Description
PW_SESSION_start N Y Y Starts Session
Here, P, S, V mean Plugin, Standalone, and Viewer, respectively. Y means usable, and N means unusable.
In this table, PW_SESSION_start is available on Standalone, Viewer, and unavailable on Plugin.
1.2. Mode 3
SDK Manual, Release 8.0.0
1.3 Multi-thread
1.4 Limitations
• The SDK does not support the calculation of MPS-DEM interactions, such as the aeration feature.
• The FVM, CHT and LBM solvers do not support Plugin and Standalone.
• The multi-resolution does not support the functions in Particles.
4 Chapter 1. Start
CHAPTER
TWO
OBJECTS
The objects’ hierarchical relationship depends on Mode. The hierarchy of Standalone and Plugin are shown
below.
On the other hand, in Viewer, the hierarchy is as below. It is close to the structure in the GUI.
5
SDK Manual, Release 8.0.0
The availability of the objects depends on Mode. In addition, there may be restrictions on functions that can
be called even if they are available.
6 Chapter 2. Objects
SDK Manual, Release 8.0.0
Objects P S V Description
Session Y Y Y Source of all other objects
Project N N Y Project
Scene Y Y Y Scene
Node Y Y Y Setting for objects such as walls and particles
Material Y Y Y Physical properties
Widget Y Y Y Setting for objects such as color bar displayed in the 3D window
Colormap Y Y Y Setting for colormap by each physical quantity
Distance Field Y Y Y Wall distance function
Particles Y Y Y MPS / DEM particle
Interaction (p-p) Y Y N Interaction between particles
Arrays Y Y Y Array that manages physical quantities, among others
Solver Y Y N Solver
User Function Y Y N User function
Model Y Y Y Model geometry
Filter Y Y Y Selects particles conditionally
Task Queue N N Y Task queue
Task N N Y Task such as analysis execution
Capture N N Y Screen capture
Parameters N N Y Setting for task
Settings N N Y Settings of Particleworks
Result File N N Y Result file
2.1 Session
Session is an object that builds bridges Particleworks/Granuleworks and user applications. The user appli-
cations first access this object.
2.2 Project
2.1. Session 7
SDK Manual, Release 8.0.0
2.3 Scene
Scene works differently depending on the Mode. In Plugin and Standalone, it only corresponds to the prop-
erty sheet of the scene window in the GUI.
On the other hand, in Viewer, in addition to the above, Scene manages Node and Material.
In Viewer, there is an active state of Scene. The scene is the active state when a 3D window is open in the
GUI. In the active state, the following is executed.
• Monitor updates of the result folder
• Read data related to time such as profbin, according to frame changes
When the active state is canceled, the memory of loaded profbin is released. The following APIs are relevant.
• PW_SCENE_get_active()
• PW_SCENE_activate()
• PW_SCENE_deactivate()
8 Chapter 2. Objects
SDK Manual, Release 8.0.0
2.3.2 Properties
unit
pre
mps
2.3. Scene 9
SDK Manual, Release 8.0.0
physics
pressure
10 Chapter 2. Objects
SDK Manual, Release 8.0.0
viscosity
surfaceTension
rigidBody
2.3. Scene 11
SDK Manual, Release 8.0.0
thermal
htc
12 Chapter 2. Objects
SDK Manual, Release 8.0.0
turbulence
cht
2.3. Scene 13
SDK Manual, Release 8.0.0
passiveScalar
mpfi
14 Chapter 2. Objects
SDK Manual, Release 8.0.0
particleShifting
dem
dem_contact
2.3. Scene 15
SDK Manual, Release 8.0.0
dem_rollingResistance
dem_intermolecular
dem_liquidBridge
dem_heatTransfer
16 Chapter 2. Objects
SDK Manual, Release 8.0.0
dem_sdem
2.3. Scene 17
SDK Manual, Release 8.0.0
fvm
18 Chapter 2. Objects
SDK Manual, Release 8.0.0
lbm
aeration
2.3. Scene 19
SDK Manual, Release 8.0.0
Table 1 – con
Name (GUI) Name (SDK) Type Remarks
Film Thickness Ratio aeration.FilmThicknessRatio scalar
Bubble Lifetime Model aeration.bubbleLifetimeModel string Choices : “N
Film Drainage Coefficient Capillary aeration.bubbleFilmDrainageCoefficientCapillary scalar
Film Drainage Coefficient Gravity aeration.bubbleFilmDrainageCoefficientGravity scalar
Film Drainage Thickness Ratio aeration.bubbleFilmDrainageThicknessRatio scalar
User Input Bubble Lifetime aeration.userInputBubbleLifetime scalar
Bubble Lifetime Error aeration.bubbleLifetimeError scalar
Bubble Coalescence aeration.coalescence bool
Bubble Contact Time Model aeration.bubbleContactTimeModel string Choices : “C
Bubble Contact Time Coefficient aeration.bubbleContactTimeCoefficient scalar
Bubble Generation aeration.bubbleGeneration bool
Target Physical Property aeration.bubbleGeneration.physicalProperty int Object ID
Weber Number aeration.bubbleGeneration.weberNumber scalar
Froude Number aeration.bubbleGeneration.froudeNumber scalar
Reference Bubble Size aeration.bubbleGeneration.bubbleReferenceSize scalar
Generation by Droplet aeration.bubbleGeneration.generationByDroplet bool
Density Threshold (Sparse) aeration.bubbleGeneration.densityThresholdSparse scalar
Density Threshold (Deep) aeration.bubbleGeneration.densityThresholdDeep scalar
Adjust Coefficient (Droplet) aeration.bubbleGeneration.rateDroplet scalar
Start Time (Droplet) aeration.bubbleGeneration.timeDroplet scalar
Generation by Solid aeration.bubbleGeneration.generationBySolid bool
Velocity Threshold aeration.bubbleGeneration.velocityThreshold scalar
Adjust Coefficient (Solid) aeration.bubbleGeneration.rateSolid scalar
Start Time (Solid) aeration.bubbleGeneration.timeSolid scalar
Minimum Bubble Size aeration.bubbleMinSize scalar
Maximum Bubble Size aeration.bubbleMaxSize scalar
air
20 Chapter 2. Objects
SDK Manual, Release 8.0.0
overlap
simulation
options
2.3. Scene 21
SDK Manual, Release 8.0.0
Table
Name (GUI) Name (SDK)
Velocity Limiter options.velocityLimiter
Maximum Velocity options.maximumVelocity
Density Threshold options.densityThreshold
Precise Surface Detection options.newSurfaceDetection
Collision Distance options.collisionDistance
Collision Coefficient options.collisionCoefficient
Radius(Viscosity) options.viscosityRadius
Radius(Pressure) options.pressureRadius
Radius(Surface Tension) options.surfaceRadius
Radius(Thermal) options.thermalRadius
Radius(Conjugate Heat Transfer) options.chtRadius
Radius(Passive Scalar) options.passiveScalarRadius
Radius(Surface Detection) options.boundaryDetectionRadius
Radius(Particle Shifting) options.psShiftingRadius
Radius(Interpolation for Particle Shifting) options.psInterpolationRadius
DEM Courant Number(Translation) options.dem.courantNumber
DEM Courant Number(Rotation) options.dem.courantNumberForRotation
Coefficient for dt due to the stability of the spring-mass system options.dem.coefficientForSpringMass
Coefficient for dt due to the stability of the rolling resistance torque options.dem.coefficientForMomentRollingStiffness
Coefficient for Hertz Time options.dem.coefficientForHertzTime
Coefficient for Rayleigh Time options.dem.coefficientForRayleighTime
DEM Velocity Limiter(Translation) options.dem.translationalVelocityLimiter
DEM Maximum Velocity(Translation) options.dem.translationalMaximumVelocity
DEM Velocity Limiter(Rotation) options.dem.rotationalVelocityLimiter
DEM Maximum Velocity(Rotation) options.dem.rotationalMaximumVelocity
DEM Density Threshold options.dem.densityThreshold
Polygon Curvature options.polygonCurvature
Inflow Algorithm (MPS) options.mps.inflowAlgorithm
Pressure Gradient Load / Torque Cutoff options.loadTorqueCutoffDepth
22 Chapter 2. Objects
SDK Manual, Release 8.0.0
output
outputFlags
2.3. Scene 23
SDK Manual, Release 8.0.0
scene options
24 Chapter 2. Objects
SDK Manual, Release 8.0.0
2.4 Node
Nodes are objects under the categories such as Input, Result, Post, View in the outline window in the
GUI.
Node has different properties. These can be checked and set in the Properties window of the GUI.
2.4. Node 25
SDK Manual, Release 8.0.0
Airflow (CSV)
Airflow (LBM)
Airflow (FVM)
26 Chapter 2. Objects
SDK Manual, Release 8.0.0
CHT B.C.
Camera
2.4. Node 27
SDK Manual, Release 8.0.0
Output Region
28 Chapter 2. Objects
SDK Manual, Release 8.0.0
Domain
2.4. Node 29
SDK Manual, Release 8.0.0
Grid Refinement
Inflow
30 Chapter 2. Objects
SDK Manual, Release 8.0.0
Fill
Flow Record
Flow Replay
2.4. Node 31
SDK Manual, Release 8.0.0
High-resolution region
32 Chapter 2. Objects
SDK Manual, Release 8.0.0
FVM Boundary
Residence Time
2.4. Node 33
SDK Manual, Release 8.0.0
Pressure Boundary
Gravity
34 Chapter 2. Objects
SDK Manual, Release 8.0.0
Outflow
Polygon
2.4. Node 35
SDK Manual, Release 8.0.0
Group
Mapping (Solver)
36 Chapter 2. Objects
SDK Manual, Release 8.0.0
Probe (Solver)
Probe Region
2.4. Node 37
SDK Manual, Release 8.0.0
38 Chapter 2. Objects
SDK Manual, Release 8.0.0
CHT Cell
DF
FVM Grid
2.4. Node 39
SDK Manual, Release 8.0.0
LBM Grid
Particles
Region
40 Chapter 2. Objects
SDK Manual, Release 8.0.0
Clipping
Distance
Point
Profile
2.4. Node 41
SDK Manual, Release 8.0.0
Ruler
42 Chapter 2. Objects
SDK Manual, Release 8.0.0
Snapshot
Filter
2.4. Node 43
SDK Manual, Release 8.0.0
Probe Point
Inflow
Outflow Region
44 Chapter 2. Objects
SDK Manual, Release 8.0.0
Fluid
2.4. Node 45
SDK Manual, Release 8.0.0
Fluid (Fill)
Rigid Body
46 Chapter 2. Objects
SDK Manual, Release 8.0.0
Particle Wall
Polygon Wall
2.4. Node 47
SDK Manual, Release 8.0.0
Pump
Flow Resistance
Pressure Boundary
Isosurface (CHT)
48 Chapter 2. Objects
SDK Manual, Release 8.0.0
2.4. Node 49
SDK Manual, Release 8.0.0
Isosurface (DF)
Domain
Inflow
50 Chapter 2. Objects
SDK Manual, Release 8.0.0
Flow Rate
Isolines
Isosurface (Grid)
Fill
2.4. Node 51
SDK Manual, Release 8.0.0
Distance
Point
Outflow
Edged
52 Chapter 2. Objects
SDK Manual, Release 8.0.0
Point
Vector
Pathline
2.4. Node 53
SDK Manual, Release 8.0.0
Front Back
Mapping
Solid
Wire
54 Chapter 2. Objects
SDK Manual, Release 8.0.0
Probe Region
Profile
Streamline
2.4. Node 55
SDK Manual, Release 8.0.0
Vector (FVM)
High-resolution region
2.5 Widget
Widgets are objects under the Widget of the Outline window in the GUI.
Widget has different properties. These can be checked and set in the Properties window of the GUI.
56 Chapter 2. Objects
SDK Manual, Release 8.0.0
2.5.1 Properties
Color bar
2.5. Widget 57
SDK Manual, Release 8.0.0
Time
58 Chapter 2. Objects
SDK Manual, Release 8.0.0
Plot
2.5. Widget 59
SDK Manual, Release 8.0.0
Axis
2.6 Colormap
Colormap is displayed on the colormap panel in the GUI. It is a color map setting for each physical quantity.
60 Chapter 2. Objects
SDK Manual, Release 8.0.0
2.6.1 Properties
2.6.2 Field
Following is the list of strings to be used for the field property. These are also used for properties that
specify field names in Grid, Mapping, Probe, etc.
2.6. Colormap 61
SDK Manual, Release 8.0.0
2.7 Material
Material corresponds to each physical property displayed in the Physical property manager in the GUI.
62 Chapter 2. Objects
SDK Manual, Release 8.0.0
2.7.1 Properties
Fluid
2.7. Material 63
SDK Manual, Release 8.0.0
Solid
64 Chapter 2. Objects
SDK Manual, Release 8.0.0
Powder
Polygon
2.8 Particles
“Particles” is a set of particles. There are two types of particles: MPS (PW_PARTICLES_mps_c) and DEM
(PW_PARTICLES_dem_c).
– In the GUI, exists for each Group ID, but in the SDK, it is divided between the analysis
methods (MPS or DEM).
• The physical quantities of each particle are contained in an array. To get this array, use Arrays.
2.8. Particles 65
SDK Manual, Release 8.0.0
• A special spatial data structure is required to compute the interactions between particles. This data
structure can be accessed via Interaction (p-p).
A spatial data structure is required for computing interactions between particles. This object is used to access
this spatial data structure. The API is PW_INTERACTION_PP_t.
Pattern Description
MPS-MPS Interaction between fluid particles (MPS)
DEM-DEM Interaction between DEM particles
MPS-DEM Interaction between fluid particles (MPS) and DEM particles
DEM-MPS Interaction between DEM particles and fluid particles (MPS)
66 Chapter 2. Objects
SDK Manual, Release 8.0.0
2.11 Arrays
Arrays is a collection of arrays and holds a large amount of data, such as particles. The following is a list
of objects that can retrieve Arrays and the role of Arrays
• Particles: Arrays hold the physical quantities of particles.
• Distance Field: Arrays hold the interactions between polygon walls and particles.
• Result File: Arrays hold the simulation result.
• Node (mapping) : Arrays hold the mapping result
Arrays are named using ASCII strings. The predefined arrays are defined below.
The physical quantities of a particle are stored in an array. The Tag of the array is set to particle, and the
length of the array is equal to the number of particles.
Individual particles are represented by an index “i” in the array. The order of the particles in the array can be
rearranged during analysis. Therefore, in order to track a specific particle, its ID (index “i”) should be used.
Additionally, the Arrays for DEM particles include physical quantities due to interactions between particles.
For these interaction arrays, the Tag is set to interaction.
The array types are as follows:
2.11. Arrays 67
SDK Manual, Release 8.0.0
Type Description
char 8bit signed integer
int 32bit signed integer
long 64bit signed integer
scalar floating point value (Refer to pw_scalar)
vector3 A vector composed of 3 scalars
mat3x3 A 3x3 matrix represented by 9 scalars
Refer to the tables below for the names and types of the defined arrays.
68 Chapter 2. Objects
SDK Manual, Release 8.0.0
MPS only
2.11. Arrays 69
SDK Manual, Release 8.0.0
Group ID
A Group ID is allocated to a Node that is used during preprocessing and is used for associating a particle and
a Distance Field.
The Group ID of a Node can be obtained via PW_NODE_get_group_id().
The Group ID of a particle can be obtained from the group_index array. group_index contains the following
two values:
• Group ID (lower 24 bits)
• Particle Type (upper 8 bits)
The Particle Types are shown in the array below:
Type Value
Fluid (MPS) 0
Powder (DEM) 1
Particle Wall (MPS) 2
Rigid Body (MPS) 3
Material ID
Material ID is used to assign Material to particles. The Material ID of a particle can be obtained from the
material_index array. Material ID can be obtained with PW_MATERIAL_get_object_id().
DEM specific
70 Chapter 2. Objects
SDK Manual, Release 8.0.0
mapping_triangle_index = [
0, 2, 3, # Face 0
0, 3, 1, # Face 1
]
Almost all arrays are in this expanded form. Since the model file consists of triangles, and each triangle
consists of 3 vertices, the length of an expanded arrays is three times the number of faces.
The following is the list of arrays that exist regardless of the mapped fields
2.11. Arrays 71
SDK Manual, Release 8.0.0
mapping_vertex_index = [
0, # v0 = mapping_triangle_index[0]
5, # v1 = mapping_triangle_index[5]
1, # v2 = mapping_triangle_index[1]
2, # v3 = mapping_triangle_index[2]
]
The length of the array is the number of vertices in the model file.
2.11.5 Tag
An ASCII character string called tag can be set to an Arrays array. It shows whether the array represents a
physical quantity of particles. Arrays that represent the physical quantities of particles require a specific tag
to be set.
PW_ARRAYS_t depends on whether the array belongs to Particles or Distance Field.
The table below describes the tags when the array belongs to Particles:
Tag Description
particle Physical quantity of a particle.
re- It is set automatically when particle tag is set. The order of the particles in the array is main-
ordered tained.
mpi It is set automatically when particle tag is set. The physical quantity is shared with other MPI
ranks (parallel computing).
interac- Interaction between DEM particles.
tion
user Indicates if the array was registered or not by SDK. It is set automatically.
tempo- Indicates if the array saves or not in .profbin. For arrays registered with SDK, if this tag is
rary not set, the array is saved in .profbin.
The table below describes the tags when the array belongs to Distance Field:
Tag Description
interaction Interaction between DEM particles and Distance Field.
72 Chapter 2. Objects
SDK Manual, Release 8.0.0
2.12 Solver
2.12. Solver 73
SDK Manual, Release 8.0.0
Note:
• The MPS pressure update loop is executed multiple times, depending on the Scene’s pres-
sure.numberOfCorrection parameter.
• The DEM substep is executed multiple times, depending on the Scene’s dem.substeps parameter.
1
Only executed when MPS > Type is MPS.
2
Only executed when MPS > Type is MPFI.
74 Chapter 2. Objects
SDK Manual, Release 8.0.0
Step Start
Name
update_start
Timing
Motion Update
Name
update_matrix
Input
None
Output
None
Description
Executes PW_SESSION_update_motion().
Heat Transfer
Name
calculate_heat_transfer
2.12. Solver 75
SDK Manual, Release 8.0.0
Input
Output
Description
Sub Kernel
Internal Energy
76 Chapter 2. Objects
SDK Manual, Release 8.0.0
Internal Energy
Name
internal_energy
Input
Output
Description
Calculation of internal energy from temperature. When temperature calculation is activated, by default,
internal_energy = density x specific heat x temperature is used.
Inflow
Name
update_inflow
Input
None
2.12. Solver 77
SDK Manual, Release 8.0.0
Output
Description
Inflow of MPS particles from the inlet. Inflowing particles are added to the end of Arrays. Because of this,
it is possible to judge the inflow and to manipulate physical quantities by using the following procedure:
• Previous Number of Particles: N0 = PW_CALL_POINT_pre
• New Number of Particles: N1 = PW_CALL_POINT_post
• If N1 == N0, then no inflow has occurred.
• If N1 > N0, particles in the range of index [N0, N1) flowed in.
By setting the material_index to “-1”, particles can be ghosted (see Outflow).
Outflow
Name
detect_ghost
Input
Output
Description
For particles outside of the analysis area, the material_index is set to -1 (Ghosting). MPS particles that
are Ghost are only allowed for the following kernels:
• Inflow
• Outflow
If there are Ghost particles under the other MPS Kernel execution, an incorrect operation can happen.
78 Chapter 2. Objects
SDK Manual, Release 8.0.0
External Force
Name
update_with_gravity
Input
Output
Description
Velocity is updated by gravity and external forces. If key-framed external forces exist, it will be evaluated in
this kernel.
Flow Resistance/Pump
Name
calculate_flow_accelerator
Input
2.12. Solver 79
SDK Manual, Release 8.0.0
Output
Description
Air Resistance
Name
calculate_air_resistance
Input
Output
Description
80 Chapter 2. Objects
SDK Manual, Release 8.0.0
Velocity Gradient
Name
calculate_velocity_gradient
Input
Output
Description
Viscosity Coefficient
Name
calculate_viscosity_model
Input
2.12. Solver 81
SDK Manual, Release 8.0.0
Output
Description
Sub Kernel
Name
particle_kinematic_viscosity
Input
82 Chapter 2. Objects
SDK Manual, Release 8.0.0
Output
Description
Turbulent Flow
Name
calculate_turbulent_smagorinsky_model
Input
Output
2.12. Solver 83
SDK Manual, Release 8.0.0
Description
Viscosity Calculation
Name
calculate_viscosity
Input
Output
Description
Surface Tension
Name
calculate_surface_tension
84 Chapter 2. Objects
SDK Manual, Release 8.0.0
Input
Output
Description
Name
update_position_from_velocity
Input
Output
2.12. Solver 85
SDK Manual, Release 8.0.0
Description
This Kernel is called after the velocity updates from the following Kernels. It updates position from velocity.
• External Force
• Flow Resistance/Pump
• Air Resistance
• Viscosity Calculation
• Surface Tension
When calculating pressure and viscosity with the MPFI method, this kernel is called after MPFI (pressure
and viscosity).
Name
transform_particle_wall
Input
Output
Description
Positions and velocities of the particles of the particle walls are reverted to the current time value.
86 Chapter 2. Objects
SDK Manual, Release 8.0.0
Name
calculate_number_density
Input
Output
Description
Calculates Particle Number Density (number_density) to determine the surface particles for the pressure
calculation (Pressure).
Pressure
Name
calculate_pressure
Input
2.12. Solver 87
SDK Manual, Release 8.0.0
Output
Description
Calculates pressure.
Pressure Smoothing
Name
smooth_pressure
Input
Output
Description
Pressure Gradient
Name
calculate_pressure_gradient
88 Chapter 2. Objects
SDK Manual, Release 8.0.0
Input
Output
Description
Name
update_position_and_velocity_from_force
Input
Output
2.12. Solver 89
SDK Manual, Release 8.0.0
Description
This Kernel is called at the end of the pressure update loop. It updates position and velocity by using the
acceleration due to the pressure gradient.
Name
mpfi_solver
Input
Output
Description
Calculates pressure gradient and viscosity using the MPFI method and updates velocity and pressure.
Inflow
Name
update_inflow
90 Chapter 2. Objects
SDK Manual, Release 8.0.0
Input
None
Output
Description
Pours DEM particles from the inlet. Inflowing particles are added to the end of Arrays. Because of this, it is
possible to judge the inflow and to manipulate physical quantities by using the following procedure:
• Previous Number of Particles: N0 = PW_CALL_POINT_pre
• New Number of Particles: N1 = PW_CALL_POINT_post
• If N1 == N0, then no inflow has occurred.
• If N1 > N0, then (N1 - N0) particles have flowed in.
By setting the material_index to “-1”, particles can be ghosted (see Outflow).
Volume Fraction
Name
dem_calculate_volume_fraction
Input
2.12. Solver 91
SDK Manual, Release 8.0.0
Output
Description
Name
dem_time_integration_pre
Input
Output
Description
92 Chapter 2. Objects
SDK Manual, Release 8.0.0
External Force
Name
dem_update_with_gravity
Input
Output
Description
Outflow
Name
dem_detect_ghost
Input
2.12. Solver 93
SDK Manual, Release 8.0.0
Output
Description
For particles outside of the analysis area, the material_index is set to -1 (Ghosting). It does not matter if
Ghost particles already exist in the DEM Kernel.
Name
dem_calculate_liquid_bridge_surface_tension
Input
Output
Description
94 Chapter 2. Objects
SDK Manual, Release 8.0.0
Name
calculate_van_der_Waals
Input
Output
Description
Contact Force
Name
dem_calculate_contact_model
2.12. Solver 95
SDK Manual, Release 8.0.0
Input
Output
Description
Rolling Resistance
Name
dem_calculate_rolling_resistance
96 Chapter 2. Objects
SDK Manual, Release 8.0.0
Input
Output
Description
Name
dem_calculate_number_density_boundary_detection
Input
2.12. Solver 97
SDK Manual, Release 8.0.0
Output
Description
Name
dem_time_integration_post
Input
Output
98 Chapter 2. Objects
SDK Manual, Release 8.0.0
Description
Heat Transfer
Name
dem_calculate_heat_transfer
Input
Output
Description
Step End
Name
update_end
2.12. Solver 99
SDK Manual, Release 8.0.0
Timing
There are three ways to call callbacks: Event, Kernel, and Sub Kernel. Each is explained below.
Additionally, it lists the Interaction Pattern that can be used in each process.
PW_SESSION_update_interaction or PW_SESSION_update_cosim_interaction must be called if you
want to use an interaction pattern not listed.
2.13.1 Event
The callback function is called when an event such as the start of analysis occurs.
2.13.2 Kernel
The callback function is called during the calculation (Kernel) of the physical models composing the analysis
step. There are 3 calling methods (PW_CALL_POINT_t):
• replace
– Swaps the Kernel itself. The built-in Kernel is not called, and the callback is called instead.
– Care must be taken with this setting since other physical models can malfunction if the output
array is not set correctly.
• pre
– Callback is called before calling the built-in Kernel.
• post
– Callback is called after calling the built-in Kernel.
MPS only
DEM only
The callback is called by Kernel’s internal processing. The calling methods are the same: replace, pre and,
post.
MPS only
2.14 Model
In the GUI, Model corresponds to the individual elements of the scene in the Models folder, in the Projects
window.
2.15 Filter
Filter is a function that discriminates particles according to a given condition. It is generated from Node.
Task Queue manages Task such as preprocessing, analysis execution, postprocessing. Task Queue corre-
sponds to the Tasks in the GUI.
2.17 Task
Task shows the task such as preprocessing, analysis execution, postprocessing. Task is managed by Task
Queue.
2.18 Capture
Capture is setting information of Video and Screenshot. It corresponds to the settings of Video and Screen-
shot in the GUI. Capture has the properties, and these are checked in the GUI.
2.18.1 Properties
Screenshot
Video
2.19 Parameters
“Parameters” is setting information of Task and corresponds to the settings such as postprocessing settings
in the GUI.
2.19.1 Properties
Import Airflow
Preprocess exec.
Simulation exec.
Flow Rate
Grid
Mapping
Pathline
Probe
Profbin to Ascii
Surface
Note: See Field for strings to set in field properties of Grid, Mapping, Probe, etc.
2.20 Settings
Function API
Handle PW_SETTINGS_t
Set properties PW_OBJECT_set_property()
Note: Changed in version 8.0: To enable the moduleDirectory setting, moduleDefault must be set to
false. If moduleDefault is true, the moduleDirectory setting is ignored and the installed bin/ directory
is used as the module directory.
2.20.1 Properties
Corresponds to the simulation result file out_NNNNNN.profbin output by the solver of Particleworks. The
file contains Arrays for each method such as MPS, LBM, etc.
THREE
API REFERENCE
3.1 Session
Type Description
PW_SESSION_t Session’s handle
PW_SESSION_t
type PW_SESSION_t
Session’s handle. The acquisition method differs depending on Mode.
• In Standalone or Viewer, it is acquired by calling PW_SESSION_start().
• In Plugin, the Solver creates a Session. The created PW_SESSION_t is passed as an argument
to PW_MODULE_initialize().
117
SDK Manual, Release 8.0.0
3.1.2 Functions
Functions P S V Description
PW_SESSION_start N Y Y Starts Session
PW_SESSION_start_w N Y Y Starts Session
PW_SESSION_end N Y Y Ends Session
PW_SESSION_get_solver Y Y N Gets Solver
PW_SESSION_get_particles Y Y N Gets Particles
PW_SESSION_get_scene Y Y N Gets Scene
PW_SESSION_get_task_queue N N Y Gets Task Queue
PW_SESSION_get_settings N N Y Gets Settings
PW_SESSION_enumerate_objects Y Y Y Gets Node
PW_SESSION_enumerate_combinationsY Y N Gets name list of interaction setting
PW_SESSION_add_user_function Y Y N Adds User Function
PW_SESSION_delete_user_function Y Y N Deletes User Function
PW_SESSION_read_particles N Y N Reads .profbin
PW_SESSION_write_particles N Y N Writes .profbin
PW_SESSION_update_motion N Y N Updates animation
PW_SESSION_update_interaction Y Y N Updates interaction
PW_SESSION_update_cosim_interactionY Y N Updates interaction between different types of par-
ticles
PW_SESSION_read_model_file Y Y N Reads model file
PW_SESSION_open_project N N Y Opens project
PW_SESSION_close_project N N Y Closes project
PW_SESSION_wait N N Y Event Processing
PW_SESSION_start
Description
PW_SESSION_start_w
Arguments
Description
When Mode is Standalone or Viewer, it is called to start Session. Calling this function in Plugin will return
some error. In case of Viewer, you must include --viewer in argv.
PW_SESSION_end
Arguments
Description
Terminates the Session started with PW_SESSION_start() when the Mode is Standalone. Calling this func-
tion in Plugin will return some error.
PW_SESSION_get_solver
Arguments
Description
PW_SESSION_get_particles
Arguments
Description
PW_SESSION_get_scene
Arguments
Description
PW_SESSION_get_task_queue
Arguments
Description
PW_SESSION_get_settings
Arguments
Description
PW_SESSION_enumerate_objects
Arguments
Description
Gets all the objects specified by type. The following can be specified as type:
• Standalone, Plugin
– PW_OBJECT_node_c
– PW_OBJECT_material_c
– PW_OBJECT_widget_c
– PW_OBJECT_colormap_c
– PW_OBJECT_particles_c
– PW_OBJECT_distance_field_c
– PW_OBJECT_model_c
• Viewer
– PW_OBJECT_project_c
– PW_OBJECT_task_queue_c
PW_SESSION_enumerate_combinations
Arguments
Description
Gets the name of the interaction setting (e.g., slip condition, contact angle, etc.) between the Materials set
in the session. The following names are usually available:
To obtain the interaction setting value, use the name returned here as an argument of
PW_MATERIAL_get_combination().
PW_SESSION_add_user_function
Arguments
Description
PW_SESSION_delete_user_function
Arguments
Description
PW_SESSION_read_particles
Arguments
Description
PW_SESSION_write_particles
Arguments
Description
Writes a .profbin file. If an array has the temporary tag, it is not written to the .profbin file unless its
name is specified in output.
• Calling this function while executing User Function will return an error.
• When the Mode is Plugin, calling this function will return some error.
PW_SESSION_update_motion
Arguments
Description
Updates the coordinate system of all Node. If no animation is set to any Node, nothing is done.
PW_SESSION_update_interaction
Arguments
Description
Updates the spatial data structure for calculating the interactions between particles and between a particle and
Distance Field. If the positions of particles are changed with User Function, the interaction is not calculated
correctly unless this function is called.
max_distance specifies the maximum distance between particles to calculate the interactions. Specifying a
value lower or equal to 0 will make max_distance use its default value.
PW_SESSION_update_cosim_interaction
Arguments
Description
Updates the spatial data structure for calculating the interactions between different types of particles. If the
positions of particles are changed with User Function, the interaction is not calculated correctly unless this
function is called. Supports the following type0 and type1 combinations.
type0 type1
PW_PARTICLES_mps_c PW_PARTICLES_dem_c
PW_PARTICLES_dem_c PW_PARTICLES_mps_c
max_distance specifies the maximum distance between particles to calculate the interactions. Specifying a
value lower or equal to 0 will make max_distance use its default value.
PW_SESSION_read_model_file
Arguments
Description
Reads the model file specified by format and path. If a file of path has already been read, new Model will
not be created and the existing handle will be set to model.
PW_SESSION_open_project
Arguments
Description
Opens the Project of the project folder specified by path. If there is no project on path and create is
PW_BOOL_true_c, it creates a new project. If the project is already open, the existing PW_PROJECT_t
is returned.
PW_SESSION_close_project
Arguments
Description
Releases project if there is no Scene in Active state. Scene and Model under this Project are also released at
the same time.
If there is a Scene in Active state, the release process is postponed until the Active state is released.
PW_SESSION_wait
Arguments
Description
Performs Session event processing such as recognition of profbin that solver outputs. If millis is no more
than 0, events that occur will be processed without blocking. If millis is greater than 0, event processing will
continue to be performed until the time specified in millis has elapsed.
3.2 Project
Type Description
PW_PROJECT_t Project’s handle
PW_PROJECT_t
type PW_PROJECT_t
Project's handle. It is obtained by calling PW_SESSION_enumerate_objects() with
PW_SESSION_t. It is deleted by PW_SESSION_close_project().
3.2.2 Functions
Functions P S V Description
PW_PROJECT_enumerate_objects N N Y Gets Scene, Model
PW_PROJECT_get_path N N Y Gets folder path of Project
PW_PROJECT_create_scene N N Y Creates Scene
PW_PROJECT_duplicate_scene N N Y Duplicates Scene
PW_PROJECT_remove_scene N N Y Deletes Scene
PW_PROJECT_read_model_file N N Y Adds Model
PW_PROJECT_remove_model N N Y Removes Model
PW_PROJECT_get_model N N Y Gets Model corresponding to ID
PW_PROJECT_enumerate_objects
Arguments
Description
Gets all the objects specified by type. The following can be specified as type.
• PW_OBJECT_scene_c
• PW_OBJECT_model_c
PW_PROJECT_get_path
Arguments
Description
PW_PROJECT_create_scene
Arguments
Description
PW_PROJECT_duplicate_scene
Arguments
Description
PW_PROJECT_remove_scene
Arguments
Description
Removes scene .
PW_PROJECT_read_model_file
Arguments
Description
Reads the model file specified by format and path into project. When a file on path is already read, new
Model will not be created, and the existing handle will be set to model.
PW_PROJECT_remove_model
Arguments
Description
Removes model from project. Note that the file referenced from model is not deleted.
PW_PROJECT_get_model
Arguments
Description
Gets the handle of Model corresponding to the ID. If the ID is invalid, PW_ERROR_no_object is returned.
3.3 Object
Actions that can be performed in common for multiple handles, such as getting property values, can be done
through PW_OBJECT_t.
Type Description
PW_OBJECT_t Handle
PW_OBJECT_type_t Type
PW_PROPERTY_t Property value
PW_PROPERTY_type_t Property type
PW_OBJECT_t
type PW_OBJECT_t
General purpose handle. Operations that can be executed in common (e.g., getting property values)
exist in objects such as Session, Scene, etc.
Such operation is executed as an operation on PW_OBJECT_t.
PW_OBJECT_type_t
type PW_OBJECT_type_t
The type of PW_OBJECT_t can be obtained with PW_OBJECT_get_type().
Value Description
PW_OBJECT_session_c PW_SESSION_t
PW_OBJECT_scene_c PW_SCENE_t
PW_OBJECT_node_c PW_NODE_t
PW_OBJECT_material_c PW_MATERIAL_t
PW_OBJECT_distance_field_c PW_DF_t
PW_OBJECT_solver_c PW_SOLVER_t
PW_OBJECT_particles_c PW_PARTICLES_t
PW_OBJECT_arrays_c PW_ARRAYS_t
PW_OBJECT_interaction_pp_c PW_INTERACTION_PP_t
PW_OBJECT_user_function_c PW_USER_FUNCTION_t
PW_OBJECT_string_c PW_STRING_t
PW_PROPERTY_t
type PW_PROPERTY_t
Property values of Scene, Node, and Material. PW_PROPERTY_t obtained with
PW_OBJECT_get_property() needs to be freed by using PW_PROPERTY_free() after use.
PW_PROPERTY_type_t
type PW_PROPERTY_type_t
Property type (type of PW_PROPERTY_t)
Value Description
PW_PROPERTY_bool_c Boolean
PW_PROPERTY_int_c 32-bit signed integer
PW_PROPERTY_scalar_c 64-bit floating point number
PW_PROPERTY_string_c String (PW_STRING_t)
PW_PROPERTY_vector3i_c 32-bit signed integer × 3
PW_PROPERTY_vector3_c 64-bit floating point number × 3
PW_PROPERTY_array_c Primitive type array (PW_VALUE_array_t)
PW_PROPERTY_string_array_c Array of strings(PW_OBJECT_array_t)
Function P S V Description
PW_OBJECT_get_type Y Y Y Gets type
3.3.3 Functions(Property)
Function P S V Description
PW_OBJECT_get_name Y Y Y Gets name
PW_OBJECT_enumerate_properties Y Y Y Gets property name
PW_OBJECT_get_property Y Y Y Gets property value
PW_OBJECT_set_property Y Y Y Sets property value
PW_OBJECT_get_scene N N Y Gets parent Scene
PW_OBJECT_get_type
Arguments
Description
PW_OBJECT_get_name
Arguments
Description
Gets the name of object. It can only be executed for the following handles:
• PW_SCENE_t (Scene)
• PW_NODE_t (Node)
• PW_MATERIAL_t (Material)
PW_OBJECT_enumerate_properties
Arguments
Description
Gets all the property names of object. It can only be executed for the following handles:
• PW_SCENE_t (Scene)
• PW_NODE_t (Node)
• PW_MATERIAL_t (Material)
PW_OBJECT_get_property
Arguments
Description
Gets the property values of object. For the property name given by name, specify one of the names obtained
with PW_OBJECT_enumerate_properties().
It can only be executed for the following handles:
• PW_SCENE_t (Scene)
• PW_NODE_t (Node)
• PW_MATERIAL_t (Material)
• PW_PARAMETERS_t (Parameters)
• PW_WIDGET_t (Widget)
• Colormap
• Settings
PW_OBJECT_set_property
Arguments
Description
Sets the property values of object. For the property name given by name, specify one of the names obtained
with PW_OBJECT_enumerate_properties(). Depending on the Mode, changing properties may not work
as intended. For example, if you change the density of Material in Plugin, the property of Material is not
be reflected in the analysis even if it changes.
PW_OBJECT_get_scene
Arguments
Description
If object belongs to Scene, get a handle of the parent Scene. If object does not belong to Scene, returns
PW_ERROR_no_object.
3.4 Scene
Type Description
PW_SCENE_t Scene's handle
PW_SCENE_PATH_t The type of the path to be acquired with PW_SCENE_get_path().
PW_SCENE_t
type PW_SCENE_t
Scene's handle
• Standalone, Plugin
– It is obtained by calling PW_SESSION_get_scene() with PW_SESSION_t.
– It will be deleted when PW_SESSION_t is deleted.
• Viewer
– It is obtained by calling PW_PROJECT_enumerate_objects() with PW_SESSION_t.
– It will be deleted when PW_SESSION_t is deleted.
PW_SCENE_PATH_t
type PW_SCENE_PATH_t
Path type acquired with PW_SCENE_get_path()
Value Description
PW_SCENE_PATH_root_dir_c Scene folder
PW_SCENE_PATH_result_dir_c The folder where the result file is stored (result)
PW_SCENE_PATH_scene_file_c Scene setting file (sub.json)
3.4.2 Functions
Functions P S V Description
PW_SCENE_get_path Y Y Y Gets Scene’s path
PW_SCENE_get_active N N Y Makes sure Active state
PW_SCENE_get_particles Y Y Y Gets Particles
PW_SCENE_get_result_file_count N Y Y Gets number of frames
PW_SCENE_get_result_file_path N Y Y Gets profbin path of frame
PW_SCENE_get_node Y Y Y Gets Node corresponding to ID
continues on next page
PW_SCENE_get_path
Arguments
Description
PW_SCENE_get_active
Arguments
Description
PW_SCENE_get_particles
Arguments
Description
PW_SCENE_get_result_file_count
Arguments
Description
PW_SCENE_get_result_file_path
Arguments
Description
Gets the path of the profbin file by specifying the frame number.
PW_SCENE_get_node
Arguments
Description
Gets Node's handle corresponding to the ID. If the ID is invalid, PW_ERROR_no_object is returned.
PW_SCENE_get_material
Arguments
Description
Gets Material's handle corresponding to the ID. If the ID is invalid, PW_ERROR_no_object is returned.
PW_SCENE_get_model
Arguments
Description
Gets Model's handle corresponding to the ID. If the ID is invalid, PW_ERROR_no_object is returned.
PW_SCENE_get_project
Arguments
Description
PW_SCENE_get_colormap
Arguments
Description
PW_SCENE_set_colormap
Arguments
Description
Sets the current Colormap. Colormap is not created explicitly and usually generated according to
the physical quantity to be output in preprocessing execution. You get generated Colormap with
PW_SCENE_enumerate_objects() and specify it to node of this function.
PW_SCENE_enumerate_objects
Arguments
Description
Gets all the objects specified by type. The following can be specified as type.
• PW_OBJECT_node_c
• PW_OBJECT_material_c
• PW_OBJECT_widget_c
• PW_OBJECT_colormap_c
• PW_OBJECT_particles_c
• PW_OBJECT_distance_field_c
• PW_OBJECT_model_c
PW_SCENE_enumerate_combinations
Arguments
Description
Gets the names of the interaction setting (e.g., slip condition, contact angle, etc.) among Material available
for scene. Refer to PW_SESSION_enumerate_combinations() for the strings obtained for names.
PW_SCENE_enumerate_fields
Arguments
Description
[
{
"name" : "position",
"type" : "vec3"
},
{
"name" : "velocity",
"type" : "vec3"
},
{
"name" : "pressure",
"type" : "scalar"
},
{
"name" : "velocity_gradient",
"type" : "mat3x3"
}
]
Key Value
name Field name
type Field type (scalar, vec3, mat3x3)
PW_SCENE_filter_arrays
Arguments
Description
Extracts values of particles or cells of the current frame (PW_SCENE_get_current_frame()). The extrac-
tion settings are specified in JSON format in the argument json.
{
"target" : "MPS",
"condition" : [
"and",
[
"and",
[
">=",
"position.x",
-10.0
],
[
"<=",
"position.x",
10.0
]
],
[
"<",
"velocity",
5.0
]
],
"norm" : true
}
Key Description
target Specifies the kind of particles or cells as string. MPS, LBM, FVM, CHT or DEM can be specified.
condi- Extraction condition
tion
norm Specifies wheter to generate norm arrays in bool. Tags norm and norm(NAME) are attached
to the norm arrays.
condition is an array of length 3. In the case of comparison operators, arrays are nested.
PW_SCENE_create_node
Arguments
Description
Note:
• To create PW_NODE_flow_replay_c, use PW_SCENE_import_flow_record().
PW_SCENE_create_material
Arguments
Description
PW_SCENE_create_widget
Arguments
Description
PW_SCENE_create_parameters
Arguments
Description
Creates Parameters for PW_TASK_QUEUE_submit_task(). Functions of Object are used for detailed set-
tings to Parameters.
PW_SCENE_import_flow_record
Arguments
Description
The recorded flows in path are copied to scene and PW_NODE_flow_replay_c nodes are created at the same
time. If scene is duplicated from the scene of path, set replace to true so that PW_NODE_flow_record_c
nodes are replaced by PW_NODE_flow_replay_c nodes.
PW_SCENE_duplicate_object
Arguments
Description
PW_SCENE_delete_object
Arguments
Description
Deletes Node, Material, Parameters, and Arrays associated with scene. For Arrays, only those created by
PW_SCENE_filter_arrays() can be deleted.
PW_SCENE_activate
Arguments
Description
PW_SCENE_deactivate
Arguments
Description
Cancels Active state of scene. Changes to scene not saved with PW_SCENE_write() are discarded.
PW_SCENE_get_current_frame
Arguments
Description
PW_SCENE_set_current_frame
Arguments
Description
Sets the frame of scene to index and reads the profbin file. The function returns when the loading of the data
associated with the frame is complete.
PW_SCENE_update_motion
Arguments
Description
Updates the coordinate system of each Node in scene to the one at the time specified by time.
PW_SCENE_write
Arguments
Description
PW_SCENE_import_rd_wall
Arguments
Description
Imports Wall exported from RecurDyn. For more details on the Wall, refer to the RecurDyn Co-simulation
Manual.
PW_SCENE_lock_result_file
Arguments
Description
Get the Result File corresponding to the file specified by index among the simulation results of scene.
• All fields stored in the result file is loaded.
• The memory of file is locked and held until
– the Scene is removed from memory
– PW_SCENE_release_result_file is called
PW_SCENE_release_result_file
Arguments
Description
Unlocks file acquired with PW_SCENE_lock_result_file. The associated memory is released at any time after
this function is called.
If 1 is or-ed to flags, the following memory is immediately released so that the pre-lock state is restored.
• Fields loaded by PW_SCENE_lock_result_file
• Arrays added by PW_RESULT_FILE_add_material_array
• Arrays added to Arrays obtained with PW_RESULT_FILE_get_arrays
3.5 Node
Type Description
PW_NODE_t Node's handle
PW_NODE_type_t Node's type
PW_PHYS_DETAIL_type_t Physical property details
PW_RENDERER_type_t Appearance
PW_NODE_t
type PW_NODE_t
Node's handle
• Standalone, Plugin
– It is obtained by calling PW_SESSION_enumerate_objects() with PW_OBJECT_node_c.
– It will be deleted when PW_SESSION_t is deleted.
• Viewer
– It is obtained by calling PW_SESSION_enumerate_objects() with PW_OBJECT_node_c.
– It is deleted by PW_SCENE_delete_object(). It will be deleted when PW_SCENE_t is
deleted.
PW_NODE_type_t
type PW_NODE_type_t
Node's type, which can be obtained with PW_NODE_get_type().
PW_ANIMATION_value_t
type PW_ANIMATION_value_t
Animation of Node
PW_ANIMATION_type_t
type PW_ANIMATION_type_t
How to specify animation (type of PW_ANIMATION_value_t)
Value Description
PW_ANIMATION_keyframe_cKeyframe. PW_ANIMATION_value_t represents keyframe animation
with x, y.
PW_ANIMATION_script_c Script. PW_ANIMATION_value_t represents script animation with
script.
PW_ANIMATION_unit_t
type PW_ANIMATION_unit_t
Unit in animation (unit of PW_ANIMATION_value_t)
PW_PHYS_DETAIL_type_t
type PW_PHYS_DETAIL_type_t
Type of Node dependent on Material
For example, if PW_MATERIAL_solid_c is set to Node of PW_NODE_polygon_c node, rigid body
(PW_PHYS_DETAIL_particle_rigid_c) or particle wall (PW_PHYS_DETAIL_particle_wall_c) can
be selected.
When the PW_PHYS_DETAIL_type_t of Node is changed, the property is also changed.
Switching the type is performed with PW_NODE_set_phys_detail(). Also, even if you change Ma-
terial of Node with PW_NODE_set_material(), it may switch.
Value Property
PW_PHYS_DETAIL_inflow_c Inflow
PW_PHYS_DETAIL_outflow_region_c Outflow Region
PW_PHYS_DETAIL_particle_dynamic_c Fluid
PW_PHYS_DETAIL_particle_filled_c Fluid (Fill)
PW_PHYS_DETAIL_particle_rigid_c Rigid Body
PW_PHYS_DETAIL_particle_wall_c Particle Wall
PW_PHYS_DETAIL_polygon_c Polygon Wall
PW_PHYS_DETAIL_pump_c Pump
PW_PHYS_DETAIL_resistance_c Flow Resistance
PW_RENDERER_type_t
type PW_RENDERER_type_t
Appearance type of Node
For example, Node of PW_NODE_polygon_c can switch the appearance of Solid
(PW_RENDERER_polygon_solid_c), Wire (PW_RENDERER_polygon_wire_c), Front-back
(PW_RENDERER_polygon_front_back_c).
The property changes when the PW_RENDERER_type_t of the Node is changed.
Switching the type is performed with PW_NODE_set_renderer().
Value Property
PW_RENDERER_particle_edged_c Edged
PW_RENDERER_particle_point_c Point
PW_RENDERER_particle_vector_c Vector
PW_RENDERER_polygon_front_back_c Front Back
PW_RENDERER_polygon_solid_c Solid
PW_RENDERER_polygon_wire_c Wire
PW_RENDERER_polygon_projection_c Mapping
PW_RENDERER_df_cross_section_c Cross Section (DF)
PW_RENDERER_df_isosurface_c Isosurface (DF)
PW_RENDERER_cross_section_c Cross Section (Grid, FVM)
PW_RENDERER_isolines_c Flow Rate
PW_RENDERER_isosurface_c Isosurface (Grid)
PW_RENDERER_streamline_c Streamline
PW_RENDERER_cell_isosurface_c Isosurface (CHT)
PW_RENDERER_vector_2d_c Vector (FVM)
PW_ROTATION_type_t
type PW_ROTATION_type_t
Type of rotation animation for Node. Get with PW_NODE_get_rotation_type(), set with
PW_NODE_set_rotation_type(). The SDK does not support Quaternion interpolation.
Value Description
PW_ROTATION_normal_c
Euler angles : Specify the animation for each axis of xyz, described as Legacy
in Particleworks GUI.
PW_ROTATION_axis_cRotation axis : Specify the animation around a rotation axis.
3.5.2 Functions
Functions P S V Description
PW_NODE_get_type Y Y Y Gets type
PW_NODE_get_particle_type Y Y Y Gets particle type
PW_NODE_get_polygon_type Y Y Y Gets polygon type
PW_NODE_get_parent Y Y Y Gets parent
PW_NODE_set_parent Y Y Y Sets parent
PW_OBJECT_get_name Y Y Y Gets name
PW_NODE_get_object_id Y Y Y Gets ID
PW_NODE_get_group_id Y Y Y Gets Group ID
PW_NODE_get_material Y Y Y Gets assigned Material
PW_NODE_set_material Y Y Y Sets assigned Material
PW_NODE_get_model Y Y Y Gets assigned Model
PW_NODE_set_model Y Y Y Sets assigned Model
PW_NODE_get_animation_value Y Y Y Gets PW_ANIMATION_value_t
PW_NODE_set_animation_value Y Y Y Sets PW_ANIMATION_value_t
PW_NODE_get_rotation_type Y Y Y Gets rotation type
PW_NODE_set_rotation_type Y Y Y Sets rotation type
PW_NODE_get_rotation_axis Y Y Y Gets rotation axis
PW_NODE_set_rotation_axis Y Y Y Sets rotation axis
PW_NODE_get_transform_matrix Y Y Y Gets transformation matrix
PW_NODE_set_transform_matrix Y Y Y Sets transformation matrix
PW_NODE_get_center Y Y Y Gets center of rotation
PW_NODE_set_center Y Y Y Sets center of rotation
PW_NODE_get_velocity Y Y Y Gets translational velocity vector
PW_NODE_set_velocity Y Y Y Sets translational velocity vector
PW_NODE_get_angular_velocity Y Y Y Gets angular velocity vector
PW_NODE_set_angular_velocity Y Y Y Set angular velocity vector
PW_NODE_get_bounding_box N N Y Gets approximate size
PW_NODE_get_phys_detail Y Y Y Gets PW_PHYS_DETAIL_type_t
PW_NODE_set_phys_detail N N Y Sets PW_PHYS_DETAIL_type_t
continues on next page
PW_NODE_get_type
Arguments
Description
PW_NODE_get_particle_type
Arguments
Description
Gets particle type, if node has associated particle properties. For type, the following values can be obtained:
PW_NODE_get_polygon_type
Arguments
Description
Gets the type of the generated object, if node is a polygon (PW_NODE_polygon_c is obtained with
PW_NODE_get_type()). For type, the following values can be obtained:
PW_NODE_get_parent
Arguments
Description
Gets the parent’s handle. If node does not have a parent, PW_ERROR_no_parent is returned.
PW_NODE_set_parent
Arguments
Description
PW_NODE_get_object_id
Arguments
Description
Gets the ID. Node can be uniquely specified by the handle type (PW_OBJECT_node_c) and the ID.
PW_NODE_get_group_id
Arguments
Description
Gets Group ID of node. Group ID can be used to associate Node with particles and Distance Field.
PW_NODE_get_material
Arguments
Description
Gets the handle of Material associated with node. If no Material is associated with node,
PW_ERROR_no_material is returned.
PW_NODE_set_material
Arguments
Description
PW_NODE_get_model
Arguments
Description
Gets the Model's handle associated with node. If no Model is associated with node, PW_ERROR_no_model
is returned.
PW_NODE_set_model
Arguments
Description
PW_NODE_get_animation_value
Arguments
Description
Obtains an animation in which the property name of node is name. If the property is a vector type, specify
the axis by index.
data should be released after use with PW_ANIMATION_value_free().
PW_NODE_set_animation_value
Arguments
Description
Sets the animation of node with the property name name. When the property is a vector, it specifies the axis
with index.
PW_NODE_get_transform_matrix
Arguments
Description
If global is PW_BOOL_true, a 4x4 matrix converted from the coordinate system of node to the World coordi-
nate system is obtained. If global is PW_BOOL_false, a 4x4 matrix converted from the coordinate system of
node to its parent's coordinate system is obtained. If node does not have a parent (PW_NODE_get_parent()
returns PW_ERROR_no_parent), the matrix remains unchanged.
Here is an example of coordinate conversion using matrix in order to show the arrangement of the numerical
values of matrix.
void
transform(const double matrix[16], double p[3])
{
double q0[4] = {p[0], p[1], p[2], 1.0};
double q1[4] = {0.0, 0.0, 0.0, 0.0};
PW_NODE_set_transform_matrix
Arguments
Description
If global is PW_BOOL_true, matrix, in the node's coordinate system, is modified to a 4x4 matrix in the
World coordinate system. If global is PW_BOOL_false, matrix, in the node's coordinate system, is modified
to a 4x4 matrix in its parent's coordinate system.
If node does not have a parent (PW_NODE_get_parent() returns PW_ERROR_no_parent), the matrix re-
mains unchanged.
• Refer to the example of PW_NODE_get_transform_matrix for the arrangement of the numerical values
of matrix.
• Please be aware that the transformation matrix of node will be overwritten if a motion update occurs.
PW_NODE_get_center
Arguments
Description
Gets the coordinates of node's center of rotation. The center of rotation is used for calculation of torque and
coordinate conversion calculation.
PW_NODE_set_center
Arguments
Description
Sets the coordinates of node's center of rotation. The center of rotation is used for calculation of torque and
coordinate conversion calculation.
PW_NODE_get_velocity
Arguments
Description
PW_NODE_set_velocity
Arguments
Description
PW_NODE_get_angular_velocity
Arguments
Description
PW_NODE_set_angular_velocity
Arguments
Description
PW_NODE_get_bounding_box
Arguments
Description
Gets the approximate size of node as Axis Aligned Box. If global is PW_BOOL_true_c, calculates Axis
Aligned Box applied the coordinate transformation of node. If Axis Aligned Box can not be calculated,
box_min is larger than box_max.
PW_NODE_get_phys_detail
Arguments
Description
PW_NODE_set_phys_detail
Arguments
Description
PW_NODE_fill_c
PW_MATERIAL_fluid_c
PW_PHYS_DETAIL_particle_filled_c
PW_MATERIAL_powder_c
PW_NODE_polygon_c
PW_MATERIAL_fluid_c
PW_PHYS_DETAIL_particle_dynamic_c
PW_MATERIAL_powder_c
PW_NODE_polygon_c
PW_MATERIAL_solid_c
PW_PHYS_DETAIL_particle_rigid_c
PW_PHYS_DETAIL_particle_wall_c
PW_NODE_polygon_c
PW_MATERIAL_polygon_c
PW_PHYS_DETAIL_polygon_c
PW_PHYS_DETAIL_resistance_c
PW_PHYS_DETAIL_pump_c
PW_PHYS_DETAIL_outflow_region_c
PW_NODE_get_renderer
Arguments
Description
PW_NODE_set_renderer
Arguments
Description
PW_NODE_type_t PW_RENDERER_type_t
PW_NODE_air_c
PW_RENDERER_particle_edged_c
PW_RENDERER_particle_point_c
PW_RENDERER_particle_vector_c
PW_NODE_polygon_c
PW_RENDERER_polygon_solid_c
PW_RENDERER_polygon_wire_c
PW_RENDERER_polygon_front_back_c
PW_NODE_distance_field_c
PW_RENDERER_df_cross_section_c
PW_RENDERER_df_isosurface_c
PW_RENDERER_polygon_solid_c
PW_RENDERER_polygon_wire_c
PW_NODE_particles_c
PW_RENDERER_particle_edged_c
PW_RENDERER_particle_point_c
PW_RENDERER_particle_vector_c
PW_RENDERER_polygon_solid_c
PW_RENDERER_polygon_wire_c
PW_NODE_region_c
PW_RENDERER_polygon_solid_c
PW_RENDERER_polygon_wire_c
PW_NODE_mapping_c
PW_RENDERER_polygon_projection_c
PW_RENDERER_polygon_wire_c
PW_NODE_input_mapping_c
PW_RENDERER_polygon_projection_c
PW_RENDERER_polygon_wire_c
PW_NODE_surface_c
PW_RENDERER_polygon_solid_c
PW_RENDERER_polygon_wire_c
PW_NODE_grid_c
PW_NODE_update_motion
Arguments
Description
PW_NODE_create_filter
Arguments
Description
Generates Filter from Node. Node that can generate Filter is as follows:
PW_NODE_adjust_dimension
Arguments
Description
Adjusts the size of a node (modifies transform.location and transform.dimensions) so that its size contains
the entire scene. The node is one of the following types :
• Domain
• Clipping
Note that you should call PW_MODEL_load() to load each polygon’s model file in order to get the correct
size of the scene.
type PW_NODE_adjust_dimension_t
Adjustment parameters of the box.
PW_NODE_set_k_epsilon
Arguments
Description
Sets 𝑘 and 𝜀 of the domain from boundary. domain must be PW_NODE_domain_c, boundary must be
PW_NODE_fvm_boundary_c (velocity boundary).
PW_NODE_add_result_view
Arguments
Description
Adds a result view of the specified node. node must be PW_NODE_cht_cell_c or PW_NODE_fvm_grid_c.
PW_NODE_get_rotation_type
Arguments
Description
Get the rotation type of node. If node is set to Quaternion interpolation in Particleworks GUI, an error
occurs.
PW_NODE_set_rotation_type
Arguments
Description
PW_NODE_get_rotation_axis
Arguments
Description
Gets the rotation axis of node. If the type of rotation (PW_ROTATION_type_t) set for node is not
PW_ROTATION_axis_c, an error occurs.
PW_NODE_set_rotation_axis
Arguments
Description
Sets the rotation axis of node. The vector specified by axis is normalized before being set as the rotation
axis. If the type of rotation (PW_ROTATION_type_t) set for node is not PW_ROTATION_axis_c, an error
occurs.
PW_INFLOW_fill
Arguments
Description
Sets physical quantities of inflow particles such as Group ID, Material ID, and temperature. The following
points should be considered.
• node must be an inflow. Otherwise, some error occurs.
• Increasing the number of particles by PW_PARTICLES_resize is necessary before executing this func-
tion.
• start corresponds to the number of particles before the increase.
• The values of the position array and the velocity array of particles Array for the inflow particles must
be set before executing this function.
• When the inflow is connected to an outflow or an outflow region, the values of the material_index array
of particles Array must appropriately be changed after executing this function.
PW_CAMERA_fit_box
Arguments
Description
Fits camera to Axis Aligned Box. For node, PW_NODE_t whose PW_NODE_type_t is PW_NODE_camera_c
or PW_NODE_snapshot_c can be specified.
PW_MAPPING_lock_arrays
Arguments
Description
If node is a Node corresponding to a mapping, the mapping result is retrieved in arrays. The memory of the
arrays is locked and held until
• the Scene to which the node belongs is removed from memory
• PW_MAPPING_release_arrays is called
PW_MAPPING_release_arrays
Arguments
Description
Unlocks arrays acquired with PW_MAPPING_lock_arrays. The associated memory is released at any time
after this function is called.
3.6 Material
Type Description
PW_MATERIAL_t Material's handle
PW_MATERIAL_type_t Material's type
PW_MATERIAL_t
type PW_MATERIAL_t
Material's handle
• Standalone, Plugin
– It is obtained by calling PW_SESSION_enumerate_objects() with
PW_OBJECT_material_c.
– It will be deleted when PW_SESSION_t is deleted.
• Viewer
– It is obtained by calling PW_SCENE_enumerate_objects() with
PW_OBJECT_material_c.
– It is deleted by PW_SCENE_delete_object(). It will be deleted when PW_SCENE_t is
deleted.
PW_MATERIAL_type_t
type PW_MATERIAL_type_t
Material's type
3.6.2 Functions
Functions P S V Description
PW_OBJECT_get_name Y Y Y Gets name
PW_MATERIAL_get_object_id Y Y Y Gets ID
PW_MATERIAL_get_type Y Y Y Gets PW_MATERIAL_type_t
PW_OBJECT_enumerate_properties Y Y Y Gets property name
PW_OBJECT_get_property Y Y Y Gets property value
PW_OBJECT_set_property Y Y Y Sets property value
PW_OBJECT_get_scene N N Y Gets parent Scene
PW_MATERIAL_get_combination Y Y Y Gets interaction setting
PW_MATERIAL_set_combination N N Y Sets interaction setting
PW_MATERIAL_get_object_id
Arguments
Description
Gets the ID. Material can be uniquely specified by the handle type (PW_OBJECT_material_c) and the ID.
PW_MATERIAL_get_type
Arguments
Description
PW_MATERIAL_get_combination
Arguments
Description
Gets the value of the interaction settings between Material m0 and Material m1. Refer to
PW_SESSION_enumerate_combinations() for the name given to name.
PW_MATERIAL_set_combination
Arguments
Description
Sets the value of the interaction settings between Material m0 and Material m1. Refer to
PW_SESSION_enumerate_combinations() for the name given to name.
3.7 Widget
Type Description
PW_WIDGET_t Widget's handle
PW_WIDGET_type_t Widget's type
PW_WIDGET_t
type PW_WIDGET_t
Widget's handle
• Standalone, Plugin
– It is obtained by calling PW_SESSION_enumerate_objects() with
PW_OBJECT_widget_c.
PW_WIDGET_type_t
type PW_WIDGET_type_t
Widget's type
3.7.2 Functions
Functions P S V Description
PW_OBJECT_get_name Y Y Y Gets name
PW_WIDGET_get_object_id Y Y Y Gets ID
PW_WIDGET_get_type Y Y Y Gets PW_WIDGET_type_t
PW_OBJECT_enumerate_properties Y Y Y Gets property name
PW_OBJECT_get_property Y Y Y Gets property value
PW_OBJECT_set_property Y Y Y Sets property value
PW_OBJECT_get_scene N N Y Gets parent Scene
PW_WIDGET_get_object_id
Arguments
Description
Gets the ID. Widget can be uniquely specified by the handle type (PW_OBJECT_widget_c) and the ID.
PW_WIDGET_get_type
Arguments
Description
Type Description
PW_DF_t Distance Field's handle
PW_INTERACTION_PD_t Information required for interaction calculation between particles and Dis-
tance Field
PW_DF_t
type PW_DF_t
Distance Field's handle. It is obtained by calling PW_SESSION_enumerate_objects() with
PW_SESSION_t and PW_OBJECT_distance_field_c. It will be deleted when PW_SESSION_t is
deleted.
PW_INTERACTION_PD_t
type PW_INTERACTION_PD_t
Holds the information for calculating the interactions between Particles and Distance Field.
• Distance from Distance Field
• The gradient of the distance function
• Velocity of Distance Field
It does not contain information on all particles. It only has that which are near Distance Field.
The following code calculates the coordinates of the points on the Distance Field from the particle's co-
ordinates (minimal distance to the particle). For the array of particle coordinates, it can be obtained from
PW_ARRAYS_t by calling PW_ARRAYS_get_array() from PW_PARTICLES_t.
void
calculate_point_on_distance_field(
PW_INTERACTION_DP_t pd,
size_t n, // Number of Particle
const pw_scalar * rx0, // x-coordinate of particle
const pw_scalar * ry0, // y-coordinate of particle
const pw_scalar * rz0, // z-coordinate of particle
pw_scalar * rx1, // x-coordinate of point on DF
pw_scalar * ry1, // x-coordinate of point on DF
pw_scalar * rz1) // x-coordinate of point on DF
{
for (int64_t di = 0; di < pd.size; di++) {
(continues on next page)
// Particle index
// If PW_INTERACTION_DP_t.index is not NULL, retrieve from index␣
˓→ array
int64_t i = (pd.index != NULL) ? pd.index[ii] : ii;
rx1[i] = x1;
ry1[i] = y1;
rz1[i] = z1;
}
}
3.8.2 Functions
Functions P S V Description
PW_DF_get_arrays Y Y N Gets Arrays
PW_DF_get_interactions Y Y N Gets Distance Field and particle interactions
PW_DF_get_group_id Y Y N Gets Group ID
PW_DF_get_load Y Y N Gets load
PW_DF_calculate Y Y N Evaluates Distance Field
PW_DF_get_arrays
Arguments
Description
PW_DF_get_interactions
Arguments
Description
PW_DF_get_group_id
Arguments
Description
Gets the Group ID of df. Distance Field can be associated with Node by comparing the ID acquired with
this function with the ID acquired with PW_NODE_get_group_id().
PW_DF_get_load
Arguments
Description
Gets load and torque applied to df. Since loads and torques are updated by Kernel such as Pressure Gradient,
if the value at a certain calculation step is needed, it has to be acquired at Step End.
PW_LOAD_type_t
type PW_LOAD_type_t
Specifies the Kernel for which the load was calculated.
Name Description
PW_LOAD_pressure_gradient_c Load calculated by Pressure Gradient
PW_LOAD_surface_tension_c Load calculated by Surface Tension
PW_LOAD_viscosity_c Load calculated by Viscosity Calculation
PW_LOAD_dem_c Load calculated by DEM
PW_LOAD_sum_c Total amount
PW_DF_calculate
Arguments
Description
Evaluates Distance Field at position. During the evaluation, the coordinate system of Distance Field is used.
out, distance, normal, and velocity can be NULL.
If the evaluated value of Distance Field is needed at the coordinates of Particles, it is quicker to use
PW_INTERACTION_PD_t obtained with PW_DF_get_interactions() rather than this function.
3.9 Particles
Type Description
PW_PARTICLES_type_t Particles' type
PW_PARTICLES_t Particles' handle
PW_PARTICLES_type_t
type PW_PARTICLES_type_t
Particles' type
PW_PARTICLES_mps_c
MPS particle
PW_PARTICLES_dem_c
DEM particle
PW_PARTICLES_t
type PW_PARTICLES_t
Particles' handle. It is obtained by calling PW_SESSION_get_particles() with PW_SESSION_t. It
will be deleted when PW_SESSION_t is deleted.
3.9.2 Functions
Functions P S V Description
PW_PARTICLES_get_size Y Y Y Gets number of particles
PW_PARTICLES_resize Y Y N Resizes number of particles
PW_PARTICLES_remove Y Y N Deletes of specific particles
PW_PARTICLES_get_arrays Y Y Y Gets PW_ARRAYS_t
PW_PARTICLES_create_interactions
Y Y N Creates PW_INTERACTION_PP_t to calculate interactions
between particles.
PW_PARTICLES_get_size
Arguments
Description
PW_PARTICLES_resize
Arguments
Description
Resizes the number of particles. If size is specified as smaller than the current number of particles, particles
are deleted from the end of the physical quantities array. If size is specified as larger than the current number
of particles, the physical quantities of the added particles are initialized to 0.
PW_PARTICLES_remove
Arguments
Description
PW_PARTICLES_get_arrays
Arguments
Description
PW_PARTICLES_create_interactions
Arguments
Description
Pattern Description
MPS-MPS Gives p0 and p1 the handle of the same MPS particle.
DEM-DEM Gives p0 and p1 the handle of the same DEM particle.
MPS-DEM Gives p0 the handle of the MPS particle, and gives p1 the handle of the DEM particle.
DEM-MPS Gives p0 the handle of the DEM particle, and gives p1 the handle of the MPS particle.
• In the case of a combination of different types of particles, Particles whose handle is given p0 are the
particle i described in PW_INTERACTION_PP_indices_t.
Refer to Kernel for Interaction Pattern available in User Function .
Type Description
PW_RESULT_FILE_t Result File's handle
PW_RESULT_FILE_t
type PW_RESULT_FILE_t
Result File's handle. Call PW_SCENE_lock_result_file() for PW_SCENE_t to get this. Call
PW_SCENE_release_result_file() to release memory after use.
3.10.2 Functions
Functions P S V Description
PW_RESULT_FILE_get_scene N N Y Gets Scene
PW_RESULT_FILE_get_path N N Y Gets file path
PW_RESULT_FILE_add_material_array N N Y Adds array of material property
PW_RESULT_FILE_get_arrays N N Y Gets Arrays
PW_RESULT_FILE_write N N Y Write file
PW_RESULT_FILE_get_scene
Arguments
Description
PW_RESULT_FILE_get_path
Arguments
Description
PW_RESULT_FILE_add_material_array
Arguments
Description
For each Arrays under file, add an array of the specified material property. The length of the array is the same
as the number of particles or cells. If a material property cannot be obtained, the value specified in def is
used.
PW_RESULT_FILE_get_arrays
Arguments
Description
PW_RESULT_FILE_write
Arguments
Description
3.11 Arrays
Type Description
PW_ARRAYS_t Arrays' handle
PW_ARRAY_description_t Contents of the array
PW_ARRAYS_t
type PW_ARRAYS_t
Arrays' handle. It can be obtained via the following functions:
• PW_PARTICLES_get_arrays()
• PW_DF_get_arrays()
It will be deleted when PW_SESSION_t is deleted.
PW_ARRAY_description_t
type PW_ARRAY_description_t
It is used to describe the array's content when you get an array (PW_ARRAYS_get_array()) or add
one (PW_ARRAYS_add_array()) from PW_ARRAYS_t.
Name of Array
Vector/Matrix type arrays are held by SoA (Structure of Arrays), not AoS (Array of Structures).
In SoA, the array is different for each component of vector/matrix. For example, an array of 3x3 matrices
has 9 components (xx, xy, xz, yx, yy, yz, zx, zy, zz) which are represented by 9 arrays.
components of PW_ARRAY_description_t represents this number (9 in this example). components has the
following relationship with ranks and rank_size:
• ranks = 0 case, components = 1
• ranks = 1 case, components = rank_size[0]
• ranks = 2 case, components = rank_size[0] × rank_size[1]
For an array of representative physical quantities, refer to the example below for each member's value. For
floating-point type, value_type is PW_VALUE_double_c or PW_VALUE_float_c, depending on the precision
(double or single precision).
Available Arrays
Note: When using an array of floating-point numbers, the value_type should be the value corresponding to
pw_scalar. It is PW_VALUE_double_c for the double-precision version and PW_VALUE_float_c for the
single-precision version.
Code Example
In the following example, the coordinates of the i-th particle are acquired. PW_ARRAYS_t is obtained from
PW_PARTICLES_t with PW_ARRAYS_get_array().
PW_ERROR_code_t
get_position(
PW_ARRAYS_t a,
size_t i, // Particle index
double r_i[3]) // The coordinates of the particle
{
PW_ARRAY_description_t d;
(continues on next page)
// Since it only reads the value, it reads the array in read only mode.
r = PW_ARRAYS_get_array(a, "position", PW_MEMORY_cpu_c, PW_ACCESS_read_
˓→only_c, &d);
if (r != PW_ERROR_no_error) {
return r;
}
assert(d.ranks == 1);
assert(d.rank_size[0] == 3);
assert(d.components == 3);
return PW_ARRAY_description_free(&d);
}
3.11.2 Functions
Functions P S V Description
PW_ARRAYS_enumerate_names Y Y Y Lists the array names
PW_ARRAYS_get_size Y Y Y Gets the size of an array
PW_ARRAYS_resize Y Y Y Resizes the size of an array
PW_ARRAYS_get_array Y Y Y Gets the array's data
PW_ARRAYS_add_array Y Y Y Adds an array
PW_ARRAYS_remove_array Y Y Y Deletes an array
PW_ARRAYS_set_initial_value Y Y Y Sets the initial value
PW_ARRAY_description_free Y Y Y Frees PW_ARRAY_description_t
PW_ARRAYS_enumerate_names
Arguments
Description
PW_ARRAYS_get_size
Arguments
Description
PW_ARRAYS_resize
Arguments
Description
PW_ARRAYS_get_array
Arguments
Description
Gets the contents of an array specified by name. Refer to PW_ARRAY_description_t for an example code.
PW_ARRAYS_add_array
Arguments
Description
Adds an array to Arrays. The length of the added array is set according to the size parameter of
PW_ARRAY_description_t, and the contents of the data parameter are copied. However, if tags has
particle or interaction set, the length of the array is adjusted appropriately.
If an array with the same name already exists, this function is invalid. Therefore, the following names can't
be used:
• Names starting with spatial
• Names including ASCII Code 0x2e (.)
PW_ARRAYS_remove_array
Arguments
Description
PW_ARRAYS_set_initial_value
Arguments
Description
Sets the initial value of the array. If the size of the array is increased, the initialization value for the incre-
mented elements must be specified. data and size must be set correctly according to the data type of the
array (PW_ARRAY_description_t's value_type ) and the number of arrays (components). For example, if
the data type is PW_VALUE_double_c and it consists of 3 arrays (i.e. vec3), it is set as follows:
The initial_data and initial_size of PW_ARRAY_description_t have the same meaning as the data and bytes
arguments. When an initial value is not specified, the initial value is zero.
PW_ARRAY_description_free
Arguments
Description
Type Description
PW_INTERACTION_PP_t Interaction (p-p)'s handle
PW_INTERACTION_PP_indices_t Interacting particle's index
PW_INTERACTION_PP_t
type PW_INTERACTION_PP_t
Interaction (p-p)'s handle. It is obtained by calling PW_PARTICLES_create_interactions() with
PW_PARTICLES_t. To execute multiple threads, Interaction (p-p) with a reduced range can be gener-
ated by using PW_INTERACTION_PP_create_block(). After use, it is necessary to free memory by
using PW_INTERACTION_PP_free().
PW_INTERACTION_PP_indices_t
type PW_INTERACTION_PP_indices_t
Information on particle pairs that may interact. It is obtained by using
PW_INTERACTION_PP_iterate_indices(). The particles are represented by an index of
type int64_t, from which 2 particle indexes, i and j, can be obtained.
In the example code below, a callback function that calculates interactions between particle i and j is called.
PW_ERROR_code_t
interaction_pp_singlethread(PW_PARTICLES_t particles, CALLBACK_t callback, void␣
˓→* data)
{
PW_ERROR_code_t r;
PW_INTERACTION_PP_t interactions;
/*
* Generates PW_INTERACTION_PP_t from PW_PARTICLES_t
*/
r = PW_PARTICLES_create_interactions(particles, particles, &
˓→interactions);
if (r != PW_ERROR_no_error) {
return r;
}
/*
* Interaction calculation
*/
PW_INTERACTION_PP_indices_t a;
PW_INTERACTION_PP_free(interactions);
return PW_ERROR_no_error;
}
3.12.2 Functions
Functions P S V Description
PW_INTERACTION_PP_iterate_indices Y Y N Gets the combinations of interacting particles
PW_INTERACTION_PP_get_block_count Y Y N Gets the number of blocks
PW_INTERACTION_PP_create_block Y Y N Splits into blocks
PW_INTERACTION_PP_free Y Y N Frees memory
PW_INTERACTION_PP_iterate_indices
Arguments
Description
PW_INTERACTION_PP_get_block_count
Arguments
Description
When you divide Interaction (p-p) into blocks, the maximum number of divisions can be obtained. See Multi
Thread Support for Interactions between Particles for usage.
PW_INTERACTION_PP_create_block
Arguments
Description
Generates Interaction (p-p) by reducing its index range to start and end. Refer to Multi Thread Support for
Interactions between Particles for usage.
PW_INTERACTION_PP_free
Arguments
Description
The functions that access Interaction (p-p) are not Thread-Safe. Therefore, for example, if
PW_INTERACTION_PP_iterate_indices() is called by multiple threads simultaneously, data consistency
can't be maintained, and the function will not operate properly.
In order to have Multi Thread calculation for interactions between particles, Interaction (p-p) has to be divided
into multiple blocks, and threads are allocated for each block. The process flow is as follows:
1. Preprocessing (Single Thread)
1. Gets maximum block number using PW_INTERACTION_PP_get_block_count().
2. Generates multiple Interaction (p-p) using PW_INTERACTION_PP_create_block().
2. Interaction calculation (Multi Thread)
1. Starts multiple threads.
2. For each thread, calls PW_INTERACTION_PP_iterate_indices() for separate Interaction (p-
p).
• Be careful not to have multiple threads access the same Interaction (p-p).
• While multiple threads are running, the API of the SDK is not called except for
PW_INTERACTION_PP_iterate_indices().
3. Postprocessing (Single Thread)
1. Deletes the generated Interaction (p-p) using PW_INTERACTION_PP_free().
In the example code below, a callback function that calculates interactions between particle i and j is called:
PW_ERROR_code_t
interaction_pp_multithread(PW_PARTICLES_t particles, CALLBACK_t callback, void *␣
˓→data)
/*
* Generates PW_INTERACTION_PP_t from PW_PARTICLES_t
*/
r = PW_PARTICLES_create_interactions(particles, particles, &source);
if (r != PW_ERROR_no_error) {
return r;
}
/*
* Get the number of blocks
*/
size_t max_block_count;
r = PW_INTERACTION_PP_get_block_count(source, &max_block_count);
if (r != PW_ERROR_no_error) {
goto END_0;
}
/*
* PW_INTERACTION_PP_t is generated with 3 blocks as one unit
*/
size_t unit = 3;
size_t count = (max_block_count + unit - 1) / unit;
/*
* Interaction calculation using multiple threads
*/
#pragma omp parallel for schedule(dynamic, 1)
for (size_t ti = 0; ti < count; ti++) {
// Multi Thread ---->
PW_INTERACTION_PP_t h = table[ti];
PW_INTERACTION_PP_indices_t a;
/*
* Tracking the interactions PW_INTERACTION_PP_iterate_indices()
*
* There is no problem if multiple threads do not call
* PW_INTERACTION_PP_iterate_indices for the same PW_INTERACTION_
˓→PP_t
*/
while (PW_INTERACTION_PP_iterate_indices(h, &a) == PW_ERROR_no_
˓→error) {
int64_t i = a.index; // Index of particle i
r = PW_ERROR_no_error;
END_1:
// Free the generated PW_INTERACTION_PP_t
for (size_t i = 0; i < count; i++) {
if (table[i] != 0) {
PW_INTERACTION_PP_free(table[i]);
}
}
free(table);
(continues on next page)
END_0:
PW_INTERACTION_PP_free(source);
return r;
}
3.13 Solver
Type Description
PW_SOLVER_t Solver's handle
PW_SOLVER_t
type PW_SOLVER_t
Solver's handle. It is obtained by calling PW_SESSION_get_solver() with PW_SESSION_t. It will
be deleted when PW_SESSION_t is deleted.
3.13.2 Functions
Functions P S V Description
PW_SOLVER_get_current_step Y Y N Current step number
PW_SOLVER_get_current_time Y Y N Current time
PW_SOLVER_get_delta_time Y Y N Time step
PW_SOLVER_get_finish_time Y Y N Analysis end time
PW_SOLVER_set_delta_time Y Y N Sets time step
PW_SOLVER_step Y Y N Analysis execution
PW_SOLVER_get_current_step
Arguments
Description
PW_SOLVER_get_current_time
Arguments
Description
PW_SOLVER_get_delta_time
Arguments
Description
When you call this function in the middle of an analysis step by using User Function, the time step of the
current analysis step can be obtained. When you call this function after the analysis step, the time step of the
last analysis step can be obtained.
PW_SOLVER_get_finish_time
Arguments
Description
PW_SOLVER_set_delta_time
Arguments
Description
Sets the time step. To adjust the time step of the analysis, call this function with the following timing:
• If you call this function before calling PW_SOLVER_step(), the specified time step is valid only for
the next one step. Therefore, if you want PW_SOLVER_set_delta_time() to control the time step
for all steps, you need to execute PW_SOLVER_step() one step at a time.
• Register User Function for the calculate_time_interval kernel, then call this function in it.
PW_SOLVER_step
Arguments
Description
Executes the analysis for the number of steps specified by steps. When it reaches the end time of the analysis,
done is set to PW_BOOL_true_c.
Type P S V Description
PW_USER_FUNCTION_t Y Y N User Function's handle
PW_USER_FUNCTION_description_t Y Y N Information on User Function to register
PW_USER_FUNCTION_arrays_t Y Y N Array to be processed by User Function
PW_CALL_POINT_t Y Y N Call position of User Function
PW_CALL_PHASE_t Y Y N Timing of when User Function was called.
PW_USER_FUNCTION_callback_t Y Y N Callback
PW_USER_FUNCTION_t
type PW_USER_FUNCTION_t
User Function's handle. It is obtained by calling PW_SESSION_add_user_function() with
PW_SESSION_t to register User Function. It will be deleted when it is unregistered with
PW_SESSION_delete_user_function().
PW_USER_FUNCTION_description_t
type PW_USER_FUNCTION_description_t
Structure that is an argument of PW_SESSION_add_user_function(). Describes the details of User
Function to be registered.
Note: If the names of the physical quantities to be modified by the user function are not set in output_arrays,
the analysis may not be executed correctly, so they must be set.
PW_USER_FUNCTION_arrays_t
type PW_USER_FUNCTION_arrays_t
Holds the arrays' names to be processed by User Function.
type PW_USER_FUNCTION_array_t
Names of arrays to be processed by User Function. Since there may be an array with the same name
in different Arrays, its owner must be explicitly passed.
PW_ARRAY_OWNER_t
Name Description
PW_ARRAY_OWNER_mps_c MPS Particles
PW_ARRAY_OWNER_dem_c DEM Particles
PW_ARRAY_OWNER_df_c Distance Field
PW_CALL_POINT_t
type PW_CALL_POINT_t
Specifies when User Function is called.
Value Description
PW_CALL_POINT_replace_c Replaces built-in Kernel with User Function.
PW_CALL_POINT_pre_c Calls User Function before executing Kernel.
PW_CALL_POINT_post_c Calls User Function after executing Kernel.
PW_CALL_POINT_event_c Calls User Function when an Event occurs.
PW_CALL_PHASE_t
type PW_CALL_PHASE_t
Timing of when User Function was called. Callbacks normally do nothing at times other than
PW_CALL_PHASE_execute_c.
Value Description
PW_CALL_PHASE_execute_c When the kernel is running
PW_CALL_PHASE_post_read_c Immediately after the .profbin import
PW_CALL_PHASE_pre_write_c Just before the .profbin export
PW_CALL_PHASE_post_write_c Immediately after the .profbin export
PW_USER_FUNCTION_callback_t
type PW_USER_FUNCTION_callback_t
Pointer to the callback for processing User Function.
Argument Description
session Session's handle
phase Callback's timing (PW_CALL_PHASE_t)
user_data Member user_data of PW_USER_FUNCTION_description_t
3.15 Model
Type Description
PW_MODEL_t Model's handle
PW_MODEL_type_t Model file type
PW_TRIANGLES_t Polygon representation of geometry
PW_TRIANGLES_type_t Representation of the polygons
PW_MESH_format_t Mesh file format
PW_MODEL_t
type PW_MODEL_t
Model's handle. It is obtained by calling PW_SESSION_enumerate_objects() with
PW_OBJECT_model_c specified for PW_SESSION_t. It will be deleted when PW_SESSION_t
is deleted.
PW_MODEL_type_t
type PW_MODEL_type_t
Model's type
Value Description
PW_MODEL_external_file_c External file
PW_MODEL_internal_file_c Internal file
PW_TRIANGLES_t
type PW_TRIANGLES_t
Polygon representation of the geometry
PW_TRIANGLES_type_t
type PW_TRIANGLES_type_t
Property type (PW_TRIANGLES_t's type)
Value Description
PW_TRIANGLES_simple_c
Represents polygons only with a vertex array, without an index array. The number of ver-
tices is 3 times the number of triangles and corresponds to OpenGL's GL_TRIANGLES.
3.15.2 Functions
Functions P S V Description
PW_MODEL_get_id Y Y Y Gets ID
PW_MODEL_get_type Y Y Y Gets type
PW_MODEL_get_path Y Y Y Gets path
PW_MODEL_get_absolute_path Y Y Y Gets absolute path
PW_MODEL_get_triangles Y Y Y Gets polygon representation
PW_MODEL_load Y Y Y Reads model file
PW_MODEL_import_to_project N N Y Imports model file to project folder
PW_MODEL_get_id
Arguments
Description
PW_MODEL_get_type
Arguments
Description
PW_MODEL_get_path
Arguments
Description
Gets the path of model 's geometry file. Call PW_MODEL_get_absolute_path() to obtain the absolute path.
PW_MODEL_get_absolute_path
Arguments
Description
PW_MODEL_get_triangles
Arguments
Description
PW_MODEL_load
Arguments
Description
Reads the model file of model. Blocks until the loading is complete.
PW_MODEL_import_to_project
Arguments
Description
Copies the model file of model and imports it into the project folder.
PW_MESH_format_t
type PW_MESH_format_t
The type of model file to specify for PW_PROJECT_read_model_file() and
PW_SESSION_read_model_file()
Value Description
PW_MESH_format_auto_c Automatically detects the format from the extension
PW_MESH_format_stl_c Loads as STL. Automatically detects Binary and Text.
PW_MESH_format_stl_text_c Text STL
PW_MESH_format_stl_binary_c Binary STL
PW_MESH_format_obj_c Alias/WaveFront OBJ
PW_MESH_format_nastran_c Nastran
3.16 Parameters
Type Description
PW_PARAMETERS_t Parameters' handle
PW_PARAMETERS_type_t Parameters' type
PW_PARAMETERS_t
type PW_PARAMETERS_t
Parameters' handle
It is obtained by calling PW_SCENE_create_parameters(). It is deleted by
PW_SCENE_delete_object(). It will be deleted when PW_SCENE_t is deleted.
PW_PARAMETERS_type_t
type PW_PARAMETERS_type_t
Parameters' type
Value Description
PW_PARAMETERS_import_air_c Import of airflow
PW_PARAMETERS_import_cht_bc_c Import of CHT B.C.
PW_PARAMETERS_preprocess_c Preprocessing
PW_PARAMETERS_simulation_c Analysis execution
PW_PARAMETERS_mapping_c Mapping
PW_PARAMETERS_surface_c Surface generator
PW_PARAMETERS_grid_c Grid generator
PW_PARAMETERS_flowrate_c Flow rate
PW_PARAMETERS_ascii_output_c Profbin to Ascii
PW_PARAMETERS_probe_c Probe
3.16.2 Functions
Functions P S V Description
PW_PARAMETERS_setup_probe N N Y Probe initialization
PW_PARAMETERS_add_pathline N N Y Adds pathline target particles
PW_OBJECT_get_name Y Y Y Gets name
PW_OBJECT_enumerate_properties Y Y Y Gets property name
PW_OBJECT_get_property Y Y Y Gets property value
PW_OBJECT_set_property Y Y Y Sets property value
PW_OBJECT_get_scene N N Y Gets parent Scene
PW_PARAMETERS_setup_probe
Arguments
Description
PW_PARAMETERS_add_pathline
Arguments
Description
Type Description
PW_TASK_QUEUE_t Task Queue's handle
PW_TASK_t Task's handle
PW_TASK_QUEUE_t
type PW_TASK_QUEUE_t
Task Queue's handle. It is obtained by calling PW_SESSION_get_task_queue() with
PW_SESSION_t. It will be deleted when PW_SESSION_t is deleted.
PW_TASK_t
type PW_TASK_t
Task's handle. It is obtained by calling PW_TASK_QUEUE_submit_task(). It will be deleted when
PW_TASK_QUEUE_t is deleted.
3.17.2 Functions
Functions P S V Description
PW_TASK_QUEUE_submit_task N N Y Adds Task
PW_TASK_QUEUE_run_task N N Y Forcibly executes Task
PW_TASK_QUEUE_cancel_task N N Y Cancels Task
PW_TASK_QUEUE_wait N N Y Waits for event on Task Queue
PW_TASK_get_state N N Y Gets Task state
PW_TASK_QUEUE_submit_task
Arguments
Description
Creates Task and adds to Task Queue. Task may not be executed immediately due to lack of re-
sources. If the task is executed immediately, calls PW_TASK_QUEUE_run_task(). parameters is created
by PW_SCENE_create_parameters().
PW_TASK_QUEUE_run_task
Arguments
Description
If Task is waiting, executes the task immediately. If the task is not in the waiting state, does nothing.
PW_TASK_QUEUE_cancel_task
Arguments
Description
Cancels Task and deletes it from Task Queue. The running Task process is terminated. If Task is already
finished, does nothing.
PW_TASK_QUEUE_wait
Arguments
Description
Blocks until waiting and running Task in Task Queue ends. When all Tasks finish, it returns
PW_ERROR_no_error. If all Tasks are not finished but more than the time specified by millis elapses,
PW_ERROR_timeout will be returned. If you specify a value less than 0 for millis, no timeout occurs.
PW_TASK_get_state
Arguments
Description
Value State
PW_TASK_state_wait_c Waiting
PW_TASK_state_execution_c Running external process
PW_TASK_state_postprocess_c Waiting for end processing
PW_TASK_state_success_c Success
PW_TASK_state_cancel_c Cancelled
PW_TASK_state_fail_c Failure
3.18 Capture
Type Description
PW_CAPTURE_t Capture's handle
PW_CAPTURE_grid_view_t Multiview setting
PW_CAPTURE_t
type PW_CAPTURE_t
Capture's handle. It is obtained by calling PW_VIDEO_create() or PW_SCREENSHOT_create().
Release it with PW_CAPTURE_free() after use.
PW_CAPTURE_grid_view_t
type PW_CAPTURE_grid_view_t
Settings for each Capture view
3.18.2 Functions
Functions P S V Description
PW_VIDEO_create N N Y Preparing for video creation
PW_VIDEO_execute N N Y Executes video creation
PW_VIDEO_get_output_path N N Y Gets video path
PW_SCREENSHOT_create N N Y Preparing for screen capture
PW_SCREENSHOT_execute N N Y Executes screen capture
PW_CAPTURE_free N N Y Releases handle after use
PW_OBJECT_get_property N N Y Gets property value
PW_OBJECT_set_property N N Y Sets property value
PW_VIDEO_create
Arguments
Description
Creates Capture for video outputs. views is an array of rows × columns pieces of
PW_CAPTURE_grid_view_t. Detailed settings such as output format are done by calling
PW_OBJECT_set_property for capture.
PW_VIDEO_execute
Arguments
Description
PW_VIDEO_get_output_path
Arguments
Description
PW_SCREENSHOT_create
Arguments
Description
Creates Capture for screenshots. views is an array of rows × columns pieces of PW_CAPTURE_grid_view_t.
Detailed settings such as output format are done by calling PW_OBJECT_set_property for capture.
PW_SCREENSHOT_execute
Arguments
Description
PW_CAPTURE_free
Arguments
Description
3.19 Filter
Type Description
PW_FILTER_t Filter's handle
PW_FILTER_t
type PW_FILTER_t
Filter's handle. It is created by calling PW_NODE_create_filter(). After use, its memory needs to
be freed with PW_FILTER_free().
3.19.2 Functions
Functions P S V Description
PW_NODE_create_filter Y Y Y Generated from Node
PW_FILTER_apply Y Y Y Discrimination of particles
PW_FILTER_free Y Y Y Frees PW_FILTER_t
PW_FILTER_apply
Arguments
Description
Searches particles for the particles that match the filter condition, and stores the result in the name array. For
example, if filter is generated from flow resistance, it selects particles inside the flow resistance. true_value
and false_value specify memory addresses matching the type of the name array.
Additionally, true_value and false_value can take NULL. If NULL, no value is set in the array.
Errors occur in the following cases:
• There is no name array for particles,
• The length of the name array is smaller than the number of particles,
• PW_MEMORY_gpu_c was specified for memory, but there is no appropriate CUDA execution envi-
ronment.
PW_FILTER_free
Arguments
Description
3.20 String
Type Description
PW_STRING_t String’s handle
PW_STRING_t
type PW_STRING_t
String handle. When you handle a character string that includes characters that cannot be expressed
with ASCII characters, such as Japanese, this handle is used. PW_STRING_t acquired with the follow-
ing functions must have its memory freed with PW_STRING_free() after use.
• PW_OBJECT_get_name()
• PW_SCENE_get_path()
To set the string's property value with PW_OBJECT_set_property(), use PW_STRING_t obtained
with one of the following functions:
• PW_STRING_from_mbs()
• PW_STRING_from_wcs()
In this case, it is necessary to free memory with PW_STRING_free() after calling
PW_OBJECT_set_property().
3.20.2 Functions
Functions P S V Description
PW_STRING_set_codepage Y Y Y Sets code page for multi-byte character string (Windows
only)
PW_STRING_from_mbs Y Y Y Generates PW_STRING_t from multi-byte character string
PW_STRING_from_wcs Y Y Y Generates PW_STRING_t from wide character string
PW_STRING_get_mbs Y Y Y Gets multi-byte character string from PW_STRING_t
PW_STRING_get_wcs Y Y Y Gets wide character string from PW_STRING_t
PW_STRING_free Y Y Y Frees PW_STRING_t
PW_STRING_set_codepage
Arguments
Description
Specifies a code page for a multi-byte character string. The default code page is UTF8. This API is valid
only on Windows. The following code pages can be specified:
Value Description
PW_CODEPAGE_utf8_c UTF8
PW_CODEPAGE_ansi_c Windows ANSI code page
PW_CODEPAGE_oem_c Windows OEM code page
If the code page is changed, the code page of PW_STRING_t is converted. Therefore, if a multi-byte character
string has been obtained by PW_STRING_get_mbs(), the character string must be reacquired.
PW_STRING_from_mbs
Arguments
Description
Creates a string object from a multi-byte string. The character code of the multi-byte character string is
specified by PW_STRING_set_codepage().
PW_STRING_from_wcs
Arguments
Description
PW_STRING_get_mbs
Arguments
Description
Converts a string object to a multi-byte character string. The character code of the multi-byte character string
is specified by PW_STRING_set_codepage().
PW_STRING_get_wcs
Arguments
Description
PW_STRING_free
Arguments
Description
3.21 Miscellaneous
3.21.1 signature
Type Description
pw_scalar Scalar type, according to precision
PW_VALUE_type_t Primitive type
PW_CSTRING_array_t Array of ASCII strings
PW_OBJECT_array_t Array of PW_OBJECT_t
PW_VALUE_array_t Primitive type array
PW_CONFIGURATION_t Information on the SDK
PW_LOG_level_t Log level
pw_scalar
type pw_scalar
Floating-point type that matches precision. It is float for single precision, and double for double pre-
cision version.
It depends on the PW_DEFINE_SCALAR_FLOAT and PW_DEFINE_SCALAR_DOUBLE specification at the
compile-time. For more details on the build settings, see User-Created Programs.
PW_VALUE_type_t
type PW_VALUE_type_t
Specifies the primitive type.
Name Description
PW_VALUE_char_c Signed integer (8 bit)
PW_VALUE_short_c Signed integer (16 bit)
PW_VALUE_int_c Signed integer (32 bit)
PW_VALUE_long_c Signed integer (64 bit)
PW_VALUE_float_c Floating-point number (32 bit)
PW_VALUE_double_c Floating-point number (64 bit)
PW_CSTRING_array_t
type PW_CSTRING_array_t
An array of ASCII strings. It is acquired by using the following API, and its memory needs to be freed
afterward by using PW_CSTRING_array_free().
• PW_SESSION_start()
• PW_SESSION_enumerate_combinations()
• PW_OBJECT_enumerate_properties()
• PW_ARRAYS_enumerate_names()
PW_OBJECT_array_t
type PW_OBJECT_array_t
An array of PW_OBJECT_t. It is obtained by calling PW_SESSION_enumerate_objects(). After
use, its memory needs to be freed with PW_OBJECT_array_free().
PW_VALUE_array_t
type PW_VALUE_array_t
An array of primitive types (char, short, int, pw_long, float, double). It is obtained as part of
PW_PROPERTY_t by using PW_OBJECT_get_property(). After use, it is necessary to free its mem-
ory by using PW_PROPERTY_free().
PW_CONFIGURATION_t
type PW_CONFIGURATION_t
Information on the SDK
In the following example code, it can be checked whether the user's program and the SDK versions are
compatible.
PW_BOOL_t
check_sdk()
{
PW_CONFIGURATION_t c;
if (PW_CONFIGURATION_get(&c) != PW_ERROR_no_error) {
return PW_BOOL_false_c;
}
PW_LOG_level_t
type PW_LOG_level_t
Log level
• PW_LOG_verbose_c
• PW_LOG_debug_c
• PW_LOG_info_c
• PW_LOG_warning_c
• PW_LOG_error_c
• PW_LOG_fatal_c
3.21.3 Functions
Functions P S V Description
PW_CONFIGURATION_get Y Y Y Gets PW_CONFIGURATION_t
PW_CONFIGURATION_enumerate_gpu Y Y Y Gets name of GPU
PW_ERROR_get_last_message Y Y Y Gets the message of the last error
PW_LOG_write Y Y Y Log output
PW_LOG_set_level Y Y Y Log level setting
PW_CONSTANT_get_wcs Y Y Y Gets string of constant value
PW_CSTRING_array_free Y Y Y Frees PW_CSTRING_array_t
PW_OBJECT_array_free Y Y Y Frees PW_OBJECT_array_t
PW_PROPERTY_free Y Y Y Frees PW_PROPERTY_t
PW_ANIMATION_value_free Y Y Y Frees PW_ANIMATION_value_t
PW_CONFIGURATION_get
Arguments
Description
PW_CONFIGURATION_enumerate_gpu
Arguments
Description
Gets an array of GPU names. The index of the array is the GPU ID specified at solver execution.
PW_ERROR_get_last_message
Description
Gets the message of the last error that occurred. Error message is stored in TLS (Thread Local Storage).
PW_LOG_write
Arguments
Description
Outputs a character string to the log. The following levels can be specified:
• PW_LOG_verbose_c
• PW_LOG_debug_c
• PW_LOG_info_c
• PW_LOG_warning_c
• PW_LOG_error_c
• PW_LOG_fatal_c
PW_LOG_set_level
Arguments
Description
PW_CONSTANT_get_wcs
Arguments
Description
PW_CSTRING_array_free
Arguments
Description
PW_OBJECT_array_free
Arguments
Description
PW_PROPERTY_free
Arguments
Description
PW_ANIMATION_value_free
Arguments
Description
The functions described below are functions that users need to define when the Mode is Plugin. They are
not APIs provided by Particleworks/Granuleworks.
Also, if the Mode is Standalone or Viewer, the definition is unnecessary.
Function Description
PW_MODULE_initialize Initializes user created module
PW_MODULE_terminate Terminates user created module
PW_MODULE_initialize
Arguments
Description
Called when the Plugin DLL is loaded in the Solver. On the Plugin side, it saves the session argument and
performs various initialization and User Function processes.
PW_MODULE_terminate
Arguments
Description
FOUR
ADDING PROPERTIES
If you add a physical model with User Function, you need to add properties to control the function. The
following describes how to add properties and interaction settings. The added properties can be referenced
and edited in the GUI.
• Property
– PW_OBJECT_enumerate_properties()
– PW_OBJECT_get_property()
– PW_OBJECT_set_property()
• Interaction settings
– PW_SESSION_enumerate_combinations()
– PW_MATERIAL_get_combination()
– PW_MATERIAL_set_combination()
OS Director
Windows %APPDATA%\Prometech Software\Particleworks\7.0\resources
Linux ~/.particleworks/7.0/resources
The version above is 7.0, but enter the version of Particleworks you are using.
Create messages and schema directories in the resources directory.
255
SDK Manual, Release 8.0.0
Director Role
messages Put a .txt file that describes the display of property names in the GUI. Details are described
in txt file.
schema Put a .json file that describes the property definition. Details are described in json file.
4.3.1 Filename
Make the end of the filename _ja.txt or _en.txt. All files matching the condition are read.
• e.g., properties_ja.txt
• _ja.txt corresponds to Japanese.
• _en.txt corresponds to English.
# comment
ext.test1=test 1
ext.test2=test 2
ext.test3=test 3
ext.test4=test 4
4.3.3 Format
4.4.1 Filename
Make the file extension .json. All files matching the conditions are read.
• e.g., properties.json
{
"version" : 1,
"nodes" : [
{
"type" : "scene",
"properties" : [
{
"name" : "ext.test1",
"type" : "enum",
"initial" : "A",
"choices" : ["A", "B", "C"]
}
]
},
{
"type" : "input_polygon",
"properties" : [
{
"name" : "ext.test2",
"type" : "float",
"initial" : 123
}
]
},
{
"type" : "phys_particle_fluid",
"properties" : [
{
"name" : "ext.test3",
"type" : "string",
"initial" : ""
}
]
}
],
"tables" : [
{
"name" : "ext.test4",
"pairs" : [
["phys_particle_fluid", "phys_particle_fluid"],
["phys_particle_fluid", "phys_polygon"]
],
"self" : true,
"default" : 0.0
(continues on next page)
4.4.3 Format
Node type
Property type
FIVE
5.1 Overview
The APIs defined in the header file particleworks_file_api.h enable you to read and write result files.
• The APIs work independently of Mode.
• There is no need to create Session.
• No license check is performed except for the following APIs
– PW_LBM_READER_create_from_scene()
5.2 Reference
Type Description
PW_FILE_READER_t Reading result file
PW_FILE_WRITER_t Writing result file
PW_LBM_READER_t Reading LBM result file
PW_TOC_array_t Contents of result file : Array
PW_TOC_arrays_t Contents of result file : Collection of arrays
PW_TOC_extension_t Contents of result file : Extended information
PW_TOC_parameter_t Contents of result file : Parameter
PW_TOC_root_t Contents of result file
PW_FILE_array_t Reading and writing array in result file
PW_FILE_read_t Specifying array to be read in result file
PW_FILE_VALUE_type_t Array’s type
261
SDK Manual, Release 8.0.0
PW_FILE_READER_t
type PW_FILE_READER_t
Handle for reading a result file. It is created by PW_FILE_READER_open(). Release the memory by
PW_FILE_READER_close() after use.
PW_FILE_WRITER_t
type PW_FILE_WRITER_t
Handle for writing a result file. It is created by PW_FILE_WRITER_create(). Release the memory
by PW_FILE_WRITER_free() after use.
PW_LBM_READER_t
type PW_LBM_READER_t
Handle for obtaining information on the LBM grid in the simulation result file. Create this handle with
PW_LBM_READER_open(). After use, delete it with PW_LBM_READER_close().
PW_TOC_array_t
type PW_TOC_array_t
This is the table of contents of a result file and represents an array of such as a physical quantity.
ranks and rank_size are determined by the dimension of the physical quantity represented by the array.
PW_TOC_arrays_t
type PW_TOC_arrays_t
This is the table of contents of a result file and represents a collection of arrays.
PW_TOC_extension_t
type PW_TOC_extension_t
This is the table of contents of a result file and represents extended information.
PW_TOC_parameter_t
type PW_TOC_parameter_t
This is the table of contents of a result file and represents a parameter.
type PW_FILE_PARAMETER_type_t
Parameter’s type
Value Description
PW_FILE_PARAMETER_double_c 64bit floating-point number
PW_FILE_PARAMETER_int64_c 64bit integer
PW_FILE_PARAMETER_vector3_c 64bit floating-point number × 3
PW_FILE_PARAMETER_vector3i_c 32bit integer × 3
PW_FILE_PARAMETER_string_c String
PW_TOC_root_t
type PW_TOC_root_t
This is the table of contents of a result file.
PW_FILE_array_t
type PW_FILE_array_t
Specify the memory type and size when reading and writing the array from a result file.
PW_FILE_read_t
type PW_FILE_read_t
Specify the name and memory of the array you want to read with PW_FILE_READER_read_array().
PW_FILE_VALUE_type_t
type PW_FILE_VALUE_type_t
Array’s type
Value Description
PW_FILE_VALUE_int8_c 8bit signed integer
PW_FILE_VALUE_uint8_c 8bit unsigned integer
PW_FILE_VALUE_int16_c 16bit signed integer
PW_FILE_VALUE_uint16_c 16bit unsigned integer
PW_FILE_VALUE_int32_c 32bit signed integer
PW_FILE_VALUE_uint32_c 32bit unsigned integer
PW_FILE_VALUE_int64_c 64bit signed integer
PW_FILE_VALUE_uint64_c 64bit unsigned integer
PW_FILE_VALUE_float_c 32bit floating-point number
PW_FILE_VALUE_double_c 64bit floating-point number
5.2.2 Functions
Functions Description
PW_FILE_READER_open Opens result file
PW_FILE_READER_close Closes result file
PW_FILE_READER_get_toc Gets contents of result file
PW_FILE_READER_read_array Reads array from result file
PW_FILE_READER_read_extension Reads extended information from result file
PW_FILE_WRITER_create Creates PW_FILE_WRITER_t
PW_FILE_WRITER_free Frees PW_FILE_WRITER_t
PW_FILE_WRITER_set_array Sets array to write
PW_FILE_WRITER_set_extension Sets extended information to write
PW_FILE_WRITER_write Writes result file
PW_LBM_READER_open Reads LBM result file
PW_LBM_READER_create_from_scene Reads LBM grid from Scene
PW_LBM_READER_close Closes LBM result file
PW_LBM_READER_get_header_json Retrieves information of LBM grid
PW_LBM_READER_get_toc Retrieves list of LBM arrays
PW_LBM_READER_sample Interpolation on LBM grid
PW_FILE_READER_open
Arguments
Description
Opens the result file. The action varies depending on the file version.
• If the file format is Particleworks v5 compatible format, it scans the entire file to generate table-of-
contents information (PW_TOC_root_t). Therefore, it takes time for the function to return.
• If the file format is Particleworks v6 or later format, the entire file is not scanned.
PW_FILE_READER_close
Arguments
Description
Deletes the handle for reading the result file and frees the memory.
PW_FILE_READER_get_toc
Arguments
Description
PW_FILE_READER_read_array
Arguments
Description
• PW_FILE_array_t’s array must be set according to PW_TOC_array_t’s ranks and rank_size (If the
address set in array is invalid, the program may terminate abnormally)
PW_FILE_READER_read_extension
Arguments
Description
PW_FILE_WRITER_create
Arguments
Description
Creates the handle for the output of the result file. According to the table-of-contents information, memory
for PW_TOC_array_t is allocated. The logical OR of the following values can be specified for the mode.
Flag Description
PW_FILE_WRITER_auto_header_f Set automatically if some parameters are undefined
When writing particles, PW_TOC_array_t under toc have to satisfy the followings.
• tags includes particle
• size matches the number of particles
When writing grid, PW_TOC_array_t under toc have to satisfy the followings.
• tags includes grid
• size matches the number of grid points
If there is an array containing particle or grid in the tags, the following arrays must also exist under the
same PW_TOC_arrays_t.
Only 0 or 2 can be specified to version in PW_TOC_root_t specifying to toc. If version is 0, there are the
following restrictions.
• array_count can be specified only 1
• Subordinate PW_TOC_array_t can only be particles
– tags must include particle, and size must match the number of particles
– If you write information other than particles, output to the extended area
PW_FILE_WRITER_free
Arguments
Description
Deletes the handle for writing the result file and frees the memory.
PW_FILE_WRITER_set_array
Arguments
Description
Sets the content of the array to write. The content of array must match the content of PW_TOC_array_t.
• PW_FILE_array_t’s type must match PW_TOC_array_t’s type
• PW_FILE_array_t’s array must be set according to PW_TOC_array_t’s ranks and rank_size (If the
address set in array is invalid, the program may terminate abnormally)
PW_FILE_WRITER_set_extension
Arguments
Description
PW_FILE_WRITER_write
Arguments
Description
Writes the result file. Calling this function will change the order of some arrays. Do not call
PW_FILE_WRITER_set_array() after calling this function.
PW_LBM_READER_open
Arguments
Description
Open the simulation result file and prepare to interpolate the value of the LBM grid. This API consumes a
relatively large memory as all information of the LBM grid is read.
PW_LBM_READER_create_from_scene
Arguments
Description
Copies the LBM grid data from the current frame of scene and prepares for interpolation. This API consumes
a relatively large memory as all information of the LBM grid is copied.
This API can be called only in the Viewer mode.
PW_LBM_READER_close
Arguments
Description
Removes a handle for LBM result file reading and frees memory.
PW_LBM_READER_get_header_json
Arguments
Description
Obtain information on the LBM grid. By specifying NULL for buffer, the required memory size can be
obtained in rsize. The obtained string is in JSON format and the following keys are available in the dict.
PW_LBM_READER_get_toc
Arguments
Description
Get the list of physical values (PW_TOC_arrays_t) of the LBM grid in the simulation result file.
PW_LBM_READER_sample
Arguments
Description
Interpolates values on the LBM grid. The positions to interpolate are specified in point (in meters).
The following is a note about PW_FILE_array_t (point, result).
Mem- Note
ber
type Set PW_FILE_VALUE_float_c for the single-precision version of the SDK, or
PW_FILE_VALUE_double_c for the double-precision version.
size Array lengths must match in point and result.
array point needs to be of type vec3. Type of result depends on the physical value. You can get the
type of values with PW_LBM_READER_get_toc().
5.3 Example
5.3.1 File
File Description
example_file_read. Reading profbin file and writing the content to json file
cpp
example_file_write. Reading json file and writing the content to profbin file
cpp
picojson.h Reading json file
example_file.hpp Common definition of example_file_read.cpp and
example_file_write.cpp
5.3.2 Licence
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
SIX
PYTHON REFERENCE
6.1 Usage
Note: pwpy has only been tested with the Python bundled with Particleworks. Other versions of Python
may not work properly.
$ python3 script.py
import sys
sys.path.append('/path/to/pwpy')
import pwpy as PW
277
SDK Manual, Release 8.0.0
if __name__ == '__main__':
session = PW.Session()
project = session.open_project('/path/to/project')
for scene in project.scenes:
do_something(scene)
def do_something(scene):
pass
if 'Particleworks' in __name__:
session = pwpy.Session()
scene = session.active_scene
if scene != None:
do_something(scene)
Input and functions listed in Functions (Only available in GUI) are avaiable only in GUI.
File Description
opt/python Python 3.10.7
opt/openssl OpenSSL 1.1.1q (Available only in Linux)
Note: Normally you do not have a write permission to files under opt/python. To install packages with
pip, you can avoid writing under opt/python by using the --user option, for example.
6.2 Constants
Constants of the following types are defined in pwpy. The name of constants is the name excluding PW_ at
the beginning and _c at the end. For example, PW_NODE_unknown_c has the name of NODE_unknown.
PW_OBJECT_type_t
• OBJECT_unknown
• OBJECT_session
• OBJECT_scene
• OBJECT_node
• OBJECT_material
• OBJECT_distance_field
• OBJECT_solver
• OBJECT_particles
• OBJECT_arrays
• OBJECT_interaction_pp
• OBJECT_user_function
• OBJECT_string
• OBJECT_model
• OBJECT_filter
• OBJECT_project
• OBJECT_task_queue
• OBJECT_task
• OBJECT_parameters
• OBJECT_capture
• OBJECT_settings
• OBJECT_input
• OBJECT_result_file
PW_VALUE_type_t
• VALUE_unknown
• VALUE_char
• VALUE_short
• VALUE_int
• VALUE_long
• VALUE_float
• VALUE_double
PW_NODE_type_t
• NODE_unknown
• NODE_polygon
• NODE_domain
• NODE_output_region
• NODE_gravity
• NODE_inflow
• NODE_outflow
• NODE_fill
• NODE_group
• NODE_air
• NODE_flow_record
• NODE_flow_replay
• NODE_distance_field
• NODE_particles
• NODE_clipping
• NODE_ruler
• NODE_mapping
• NODE_camera
• NODE_profile
• NODE_snapshot
• NODE_region
• NODE_measure_point
• NODE_measure_distance
• NODE_surface
• NODE_grid
• NODE_pathline
• NODE_flow_rate
• NODE_ascii_output
• NODE_particle_selection
• NODE_probe
• NODE_probe_region
• NODE_probe_point
• NODE_cht_cell
• NODE_result_view_cht_cell
• NODE_fvm_grid
• NODE_result_view_fvm_grid
• NODE_fvm_boundary
• NODE_input_probe
• NODE_input_mapping
• NODE_input_flow_rate
• NODE_residence_time
• NODE_pressure_boundary
• NODE_overlap_region
• NODE_cht_bc
PW_MATERIAL_type_t
• MATERIAL_unknown
• MATERIAL_fluid
• MATERIAL_solid
• MATERIAL_powder
• MATERIAL_inflow
• MATERIAL_polygon
PW_WIDGET_type_t
• WIDGET_unknown
• WIDGET_colorbar
• WIDGET_timelabel
• WIDGET_axis
PW_PROPERTY_type_t
• PROPERTY_unknown
• PROPERTY_bool
• PROPERTY_int
• PROPERTY_scalar
• PROPERTY_string
• PROPERTY_vector3
• PROPERTY_vector3i
• PROPERTY_array
PW_LOG_level_t
• LOG_verbose
• LOG_debug
• LOG_info
• LOG_warning
• LOG_error
• LOG_fatal
PW_SCENE_PATH_t
• SCENE_PATH_root_dir
• SCENE_PATH_result_dir
• SCENE_PATH_scene_file
PW_MESH_format_t
• MESH_format_auto
• MESH_format_stl
• MESH_format_stl_text
• MESH_format_stl_binary
• MESH_format_obj
• MESH_format_nastran
PW_TASK_state_t
• TASK_state_unknown
• TASK_state_wait
• TASK_state_execution
• TASK_state_postprocess
• TASK_state_success
• TASK_state_cancel
• TASK_state_fail
PW_ANIMATION_type_t
• ANIMATION_keyframe
• ANIMATION_script
PW_ANIMATION_unit_t
• ANIMATION_unit_unknown
• ANIMATION_unit_position
• ANIMATION_unit_velocity
• ANIMATION_unit_angle
• ANIMATION_unit_rpm
• ANIMATION_unit_rps
PW_PHYS_DETAIL_type_t
• PHYS_DETAIL_unknown
• PHYS_DETAIL_inflow
• PHYS_DETAIL_particle_dynamic
• PHYS_DETAIL_particle_filled
• PHYS_DETAIL_particle_rigid
• PHYS_DETAIL_particle_wall
• PHYS_DETAIL_polygon
• PHYS_DETAIL_resistance
• PHYS_DETAIL_pump
• PHYS_DETAIL_outflow_region
6.2.14 Renderer
PW_RENDERER_type_t
• RENDERER_unknown
• RENDERER_particle_edged
• RENDERER_particle_point
• RENDERER_particle_vector
• RENDERER_polygon_front_back
• RENDERER_polygon_solid
• RENDERER_polygon_wire
• RENDERER_polygon_projection
• RENDERER_df_cross_section
• RENDERER_df_isosurface
• RENDERER_cross_section
• RENDERER_isolines
• RENDERER_isosurface
• RENDERER_streamline
• RENDERER_cell_isosurface
• RENDERER_vector_2d
6.2.15 Parameters
PW_PARAMETERS_type_t
• PARAMETERS_import_air
• PARAMETERS_import_cht_bc
• PARAMETERS_preprocess
• PARAMETERS_simulation
• PARAMETERS_mapping
• PARAMETERS_surface
• PARAMETERS_grid
• PARAMETERS_flowrate
• PARAMETERS_ascii_output
• PARAMETERS_probe
• PARAMETERS_pathline
6.2.16 Models
PW_MODEL_type_t
• MODEL_unknown
• MODEL_external_file
• MODEL_internal_file
PW_ROTATION_type_t
• ROTATION_unknown
• ROTATION_normal
• ROTATION_axis
PW_ERROR_code_t
• ERROR_no_error
• ERROR_null_pointer
• ERROR_bad_state
• ERROR_bad_id
• ERROR_bad_type
• ERROR_bad_name
• ERROR_bad_value
• ERROR_bad_memory
• ERROR_bad_thread
• ERROR_unsupported
• ERROR_no_parent
• ERROR_no_material
• ERROR_no_model
• ERROR_end_of_iteration
• ERROR_no_combination
• ERROR_timeout
• ERROR_runtime
• ERROR_unknown
6.3 Functions
enumerate_gpu()
PW_CONFIGURATION_enumerate_gpu()
Return type
list(str)
Returns
List of available GPUs
set_log_level(level)
Parameters
level (int) – Log Level
version()
Return type
tuple(int, int, int)
Returns
Particleworks version
constant_string(n)
PW_CONSTANT_get_wcs()
Parameters
n (int) – Constants
Return type
str
Returns
String corresponding to the constant value
message_warning(text)
Shows a warning dialog.
Parameters
text (str) – Message text
message_error(text)
Shows an error dialog.
Parameters
text (str) – Message text
show_image(b)
Shows an image in the Python console.
Parameters
b (bytes) – bytes of an PNG image file.
show_plot()
Shows an image of matplotlib.pyplot.show() call if matplotlib is available.
6.4 Class
6.4.1 Session
class Session
PW_SESSION_t
open_project(path, create=False)
PW_SESSION_open_project()
Parameters
• path (str) – Path of Project
• create (bool) – If True, create a new Project when none exists.
Return type
Project
close_project(project)
PW_SESSION_close_project()
Parameters
project (Project) – Project to close
wait(millis)
PW_SESSION_wait()
Parameters
millis (int) – Wait time (milli seconds)
lock()
Stops GUI temporarily.
When multiple editing operations are performed in a script, GUI execution may cause script
execution to be slow due to alternating GUI drawing and script editing operations. In such a
case, use this method with a with statement as follows to pause the GUI during script execution.
with session.lock():
for i in range(100):
scene.create_node(pwpy.NODE_inflow)
Note that execution of statements inside with cannot be interrupted from the GUI. This method
is not used in CUI execution normally.
active_scene
Returns Scene that has a focus in the GUI. Returns None if called in CUI execution.
Type
Scene
task_queue
Returns Task Queue
Type
TaskQueue
settings
Returns Settings
Type
Settings
projects
List of opened Project
Type
list[Project]
6.4.2 Project
class Project
PW_PROJECT_t
read_model_file(path)
PW_PROJECT_read_model_file()
Parameters
path (str) – Path of the file to read
Return type
Model
remove_model(model)
PW_PROJECT_remove_model()
Parameters
model (Model) – Model to remove
create_scene(name)
PW_PROJECT_create_scene()
Parameters
name (str) – Name of Scene
duplicate_scene(scene, name=None, preprocess=False, simulation=False, other=False,
result_start=0, result_end=-1)
PW_PROJECT_duplicate_scene()
Parameters
• scene (Scene) – Scene to duplicate
• name (str) – Name of the duplicated Scene
• preprocess (bool) – See PW_PROJECT_duplicate_scene_t
• simulation (bool) – See PW_PROJECT_duplicate_scene_t
• other (bool) – See PW_PROJECT_duplicate_scene_t
• result_start (int) – See PW_PROJECT_duplicate_scene_t
• result_end (int) – See PW_PROJECT_duplicate_scene_t
Returns
Duplicated new Scene
Return type
Scene
remove_scene(scene)
PW_PROJECT_remove_scene()
Parameters
scene (Scene) – Scene to remove
model(id)
Corresponds to PW_PROJECT_get_model(). Returns None if there is no Model corresponding
to the id.
Parameters
id (int) – Model ID
Return type
Model or None
scenes
Returns the list of Scene under this project.
Type
list[Scene]
models
Returns the list of Model under this project.
Type
list[Model]
6.4.3 Model
class Model
PW_MODEL_t
load()
PW_MODEL_load()
import_to_project()
PW_MODEL_import_to_project()
model_type
PW_MODEL_get_type(), Models
id
PW_MODEL_get_id()
Type
int
path
PW_MODEL_get_path()
Type
str
absolute_path
PW_MODEL_get_absolute_path()
Type
str
face_count
Obtains the number of faces.
Type
int
vertex_count
Obtains the number of vertices.
Type
int
6.4.4 Object
class Object
name
Name of the object
properties
List of property names
Type
list[str]
scene
PW_OBJECT_get_scene()
Type
Scene
Object is inherited by following classes.
• Scene
• Node
• Material
• Parameters
• Colormap
• Widget
• Settings
• Video
• ScreenShot
Properties of these objects can be accessed in dict-like manner with a property name as
key.(PW_OBJECT_get_property(), PW_OBJECT_set_property())
# List properties
for name in scene.properties:
print(name)
The following table shows the correspondence between a property type (PW_PROPERTY_type_t) and a
Python type.
6.4.5 Scene
class Scene
PW_SCENE_t
create_node(type)
PW_SCENE_create_node()
Parameters
type (int) – Node Type
Returns
Newly created Node
Return type
Node
create_material(type)
PW_SCENE_create_material()
Parameters
type (int) – Material Type
Returns
Newly created Material
Return type
Material
create_parameters(type)
PW_SCENE_create_parameters()
Parameters
type (int) – Parameters
Returns
Newly created Parameters
Return type
Parameters
import_flow_record(source, replace=True)
PW_SCENE_import_flow_record()
Parameters
• source (str or Scene) – Path to the scene containing a flow_record, or Scene
object
• replace (bool) – See PW_SCENE_import_flow_record()
delete_object(object)
PW_SCENE_delete_object()
Parameters
object (Node, Material, Parameters, Arrays) – Object to remove
activate()
PW_SCENE_activate()
deactivate()
PW_SCENE_deactivate()
path(type)
PW_SCENE_get_path()
Parameters
type (int) – Scene Path
Returns
Path string
Return type
str
update_motion(time)
PW_SCENE_update_motion()
Parameters
time (float) – Time
write()
PW_SCENE_write()
import_rd_wall(path)
PW_SCENE_import_rd_wall()
Parameters
path (str) – Path to the wall file
Returns
List of the generated Node
Return type
list[Node]
node(id)
Corresponds to PW_SCENE_get_node(). Returns None if there is no Node corresponding to the
id.
Parameters
id (int) – Node ID
Return type
Node or None
material(id)
Corresponds to PW_SCENE_get_material(). Returns None if there is no Material correspond-
ing to the id.
Parameters
id (int) – Material ID
Return type
Material or None
model(id)
Corresponds to PW_SCENE_get_model(). Returns None if there is no Model corresponding to
the id.
Parameters
id (int) – Model ID
Return type
Model or None
active
PW_SCENE_get_active()
Type
bool
nodes
List of Node objects under this Scene
Type
list[Node]
materials
List of Material objects under this Scene
Type
list[Material]
colormaps
List of Colormap objects under this Scene
Type
list[Colormap]
widgets
List of Widget objects under this Scene
Type
list[Widget]
project
PW_SCENE_get_project()
Type
Project
combinations
PW_SCENE_enumerate_combinations()
Type
list[str]
current_frame
PW_SCENE_get_current_frame(), PW_SCENE_set_current_frame()
Type
int
frame_count
PW_SCENE_get_result_file_count()
Type
int
result_files
PW_SCENE_get_result_file_path()
Type
list[str]
current_colormap
PW_SCENE_get_colormap(), PW_SCENE_set_colormap()
Type
Colormap or None
name
PW_OBJECT_get_name()
Type
str
properties
List of property names
Type
list[str]
potential_amplifier
Potential Amplifier. To enable or disable the Potential Amplifier, use surfaceTen-
sion.amplify.enabled in surfaceTension.
Type
list[PotentialCoefficient]
6.4.6 Node
class Node(Object)
PW_NODE_t
update_motion(time)
PW_NODE_update_motion()
Parameters
time (float) – Time
get_animation(name, index)
PW_NODE_get_animation_value()
Parameters
• name (str) – Property name
• index (int) – Axis
Return type
AnimationValue
set_animation(name, index, value)
PW_NODE_set_animation_value()
Parameters
• name (str) – Property name
• index (int) – Axis
• value (AnimationValue) – An animation to be set
adjust_dimension(percent=False, margin=0.0)
PW_NODE_adjust_dimension()
Parameters
center
PW_NODE_get_center(), PW_NODE_set_center()
Type
[float] * 3
velocity
PW_NODE_get_velocity(), PW_NODE_set_velocity()
Type
[float] * 3
angular_velocity
PW_NODE_get_angular_velocity(), PW_NODE_set_angular_velocity()
Type
[float] * 3
rotation_type
PW_NODE_get_rotation_type(), PW_NODE_set_rotation_type(), Rotation Type
Type
int
rotation_axis
PW_NODE_get_rotation_axis(), PW_NODE_set_rotation_axis()
Type
[float] * 3
bounding_box
PW_NODE_get_bounding_box()
Type
((float, float, float), (float, float, float))
phys_detail
PW_NODE_get_phys_detail(), PW_NODE_set_phys_detail(), Phys Detail
Type
int
renderer
PW_NODE_get_renderer(), PW_NODE_set_renderer(), Renderer
Type
int
connected_inflows
List of connected inflows
Type
list[ConnectedInflow]
6.4.7 AnimationValue
class AnimationValue
PW_ANIMATION_value_t
type
Animation Type
Type
int
unit
Animation Unit
Type
int
x
List of times (for keyframes)
Type
list[float]
y
List of values (for keyframes)
Type
list[float]
script
Script
Type
str
6.4.8 PotentialCoefficient
class PotentialCoefficient
An object for defining an amplification ratio for potential coefficients, which corresponds to a single
row in the Potential Amplifier table in the GUI.
acceleration
Acceleration
Type
float
coefficient
Coefficient
Type
float
6.4.9 ConnectedInflow
class ConnectedInflow
An object for defining a connected inflow, which corresponds to a single row in the Connected inflow
table in the GUI.
node
Specify the inflow to be connected or None.
Type
Node
weight
Weight
Type
float
delay
Delay Time
Type
float
class Arrays
Corresponding to PW_ARRAYS_t. A field of particles or cells are stored as an array.
• Result of Filter.run()
• Mapping result (MappingArrays)
• Simulation result (ResultFile)
keys()
Returns
List of field names
Return type
list[str]
__getitem__(key)
Parameters
key (str) – Field name
Return type
Array
add_scalar(key)
Corresponds to PW_ARRAYS_add_array(). Add an array of a scalar field. The length of the
array is the number of particles or cells.
Parameters
key (str) – Field name to add
Return type
ScalarArray
add_vec3(key)
Corresponds to PW_ARRAYS_add_array(). Add an array of a vector3 field. The length of the
array is the number of particles or cells.
Parameters
key (str) – Field name to add
Return type
Vector3Array
add_mat3x3(key)
Corresponds to PW_ARRAYS_add_array(). Add an array of a matrix field. The length of the
array is the number of particles or cells.
Parameters
key (str) – Field name to add
Return type
Matrix3x3Array
class MappingArrays(Arrays)
An object for accessing mapping results. Usually used in a with statement.
MappingArrays(node)
PW_MAPPING_lock_arrays()
Parameters
node (Node) – Mapping node
__exit__()
PW_MAPPING_release_arrays()
class Array
This object is an array of field values of particles or cells. Corresponds to PW_ARRAY_description_t.
__len__()
Returns
Number of particles or cells
Return type
int
__getitem__(i)
Parameters
i (int) – Index
Returns
Returns the value of i-th particle or cell. The returned object type differs depending
on the field type.
Return type
float or Vector3 or Matrix3x3
class ScalarArray(Array)
numpy()
Returns
Returns an array as numpy.ndarray if numpy is available.
class Vector3Array(Array)
x, y, z
Access to components.
Type
ScalarArray
norm
Length of vectors. Available only if this array belongs to Arrays returned by Filter.run().
Returns None otherwise.
Type
ScalarArray or None
class Matrix3x3Array(Array)
6.4.11 ResultFile
class ResultFile
Corresponds to PW_RESULT_FILE_t. Normally used in a with statement.
ResultFile(scene, index)
PW_SCENE_lock_result_file()
Parameters
• scene (Scene) – Scene
• index (int) – Index of a simulation result file.
__exit__()
PW_SCENE_release_result_file()
add_material_array(name)
Corresponds to PW_RESULT_FILE_add_material_array(). Adds an array to Arrays with the
same name as the material property.
Parameters
name (str) – Name of a material property
arrays(key)
PW_RESULT_FILE_get_arrays()
Parameters
key (str) – Name of Arrays. Specify MPS.
write(path)
PW_RESULT_FILE_write()
Parameters
path (str) – Output file path
path
PW_RESULT_FILE_get_path()
Type
str
scene
PW_RESULT_FILE_get_scene()
Type
Scene
class Material(Object)
PW_MATERIAL_t
get_combination(peer, name)
PW_MATERIAL_get_combination()
Parameters
• peer (Material) – Material
• name (str) – Name of the combination
Return type
float
set_combination(peer, name, value)
PW_MATERIAL_set_combination()
Parameters
• peer (Material) – Material
• name (str) – Name of the combination
• value (float) – Value of the combination
material_type
PW_MATERIAL_get_object_type(), Material Type
Type
int
id
PW_MATERIAL_get_object_id()
Type
int
class Colormap(Object)
PW_NODE_t
class Widget(Object)
PW_WIDGET_t
widget_type
PW_WIDGET_get_type(), Widget Type
id
PW_WIDGET_get_object_id()
class Settings(Object)
PW_SETTINGS_t
6.4.13 Parameters
class Parameters(Object)
PW_PARAMETERS_t
setup_probe(*args)
PW_PARAMETERS_setup_probe()
Parameters
args (list[Node]) – List of target probe nodes
add_pathline(a, color):
PW_PARAMETERS_add_pathline()
Parameters
• a (list[int]) – List of particle IDs
• color ((float, float, float)) – Specifies the color of pathlines with 3
floats (0.0 to 1.0 range)
parameters_type
Parameters
Type
int
class TaskQueue
PW_TASK_QUEUE_t
submit(scene, params)
PW_TASK_QUEUE_submit_task()
Parameters
• scene (Scene) – Scene
• params (Parameters) – Parameters
Return type
Task
run(task)
PW_TASK_QUEUE_run_task()
Parameters
task (Task) – Task
cancel(task)
PW_TASK_QUEUE_cancel_task()
Parameters
task (Task) – Task
wait(millis)
PW_TASK_QUEUE_wait()
Parameters
millis (int) – Wait time (milli seconds)
class Task
PW_TASK_t
state
PW_TASK_get_state(), Task State
Type
int
Note: ScreenShot and Video are not available on Linux when CUI execution.
class ScreenShot
PW_CAPTURE_t
ScreenShot(rows, columns, views)
Parameters
• rows (int) – Number of rows
• columns (int) – Number of columns
• views (list[CaptureView]) – List of CaptureView (the length is rows x
columns)
execute()
PW_SCREENSHOT_execute()
properties
Gets list of property names
class Video
PW_CAPTURE_t
Video(rows, columns, views)
PW_VIDEO_create()
Parameters
• rows (int) – Number of rows
Type
Scene
node
Type
Node
class Camera
PW_NODE_t
Camera(node)
Parameters
node (Node) – Camera (NODE_CAMERA) or Snapshot (NODE_snapshot)
6.4.16 Filter
class Filter
An object used to call PW_SCENE_filter_arrays(). Refer to Sample : Filter for the usage example.
Filter(scene)
Parameters
scene (Scene) – Target scene
keys()
Returns list of field names which can be used in conditions of run().
Returns
List of field names
__getitem__(key)
Gets a field which can be used in conditions of run() in dict-like manner
Parameters
key (str) – Field name
Returns
Field
run(target, condition)
Extracts field values
Parameters
• target (str) – Specifies the kind of target. MPS, LBM, CHT, FVM or DEM can be
specified.
• condition – Extraction condition. Values of all particles or cells are obtained
if None is specified.
Returns
Returns Arrays object
The fields used for the extraction condition of Filter.run() can be obtained in dict-like manner from the
Filter object.
filter = pwpy.Filter(scene)
i = filter['id'] # Particle ID
p = filter['pressure'] # Pressure (Scalar)
v = filter['velocity'] # Velocity (Vector3)
L = filter['velocity_gradient'] # Velocity gradient (Matrix3x3)
Specify a condition using a field and comparison operators (<, <=, ==, >=, >).
Components of Vector3 type can be accessed with .x, .y or .z. Length can be accessed with .norm.
Components of Matrix3x3 type can be accessed with .xx, .xy, .xz, .yx, .yy, .yz, .zx, .zy or .zz. Matrix
norm can be accessed with .norm.
# (1) Display IDs of particles whose z component of velocity is smaller than -10.
for k in len(n):
if v.z[k] < -10:
print(i[k])
6.4.17 Math
class Vector3
An object representing a vector.
x, y, z
Component values.
Type
float
class Matrix3x3
An object representing a matrix (3 x 3).
6.4.18 Input
class Input
An object to display an input dialog. This cannot be used in CUI execution.
add_integer(name, initial=0)
Adds an integer property.
Parameters
• name (str) – Property name
• initial (int) – Initial value
Return type
GetValue
add_string(name, initial='')
Adds a string property.
Parameters
• name (str) – Property name
• initial (int) – Initial value
Return type
GetValue
add_boolean(name, initial=False)
Adds a boolean property.
Parameters
• name (str) – Property name
• initial (int) – Initial value
Return type
GetValue
add_float(name, initial=0.0)
Adds a floating-point property.
Parameters
• name (str) – Property name
• initial (int) – Initial value
Return type
GetValue
add_vector3(name, initial=(0.0, 0.0, 0.0))
Adds a vector-type property.
Parameters
• name (str) – Property name
• initial (int) – Initial value
Return type
GetValue
add_node_ref(name)
Adds a Node reference property.
Parameters
name (str) – Property name
Return type
GetValue
add_material_ref(name)
Adds a Material property.
Parameters
name (str) – Property name
Return type
GetValue
add_model_ref(name)
Adds a Model property.
Parameters
name (str) – Property name
Return type
GetValue
add_file(name)
Adds a file reference property.
Parameters
name (str) – Property name
Return type
GetValue
ask(scene=None)
Displays a dialog. If there are reference properties of Node, Material or Model, it is necessary to
specify Scene which contains these objects.
Parameters
scene (Scene) – Scene containing referenced objects
Returns
Returns False if the cancel button is pressed in the dialog.
Return type
bool
class GetValue
get()
Obtains the value entered in the dialog.
Add properties with methods such as Input.add_integer() and Input.add_string(), and call Input.
ask() to display the dialog. Values entered in the dialog can be retrieved by either of the following:
• dict-like access to the Input object with the property name as a key.
• Call GetValue.get() on the GetValue object returned by the add property methods.
def show_dialog():
dialog = pwpy.Input()
a = dialog.add_integer('A', 1)
b = dialog.add_string('B', 'b')
c = dialog.add_enum('C', ['c 1', 'c 2', 'c 3'])
if not dialog.ask():
print('Cancelled')
return
# dict-like access
print(dialog['A'], dialog['B'], dialog['C'])
# GetValue.get()
print(a.get(), b.get(), c.get())
class LBM_Reader
PW_LBM_READER_t
LBM_Reader(source)
If source is a Scene object, the LBM grid of the current frame is read.
(PW_LBM_READER_create_from_scene())
Otherwise, source is treated as a path from which LBM grid is read. (PW_LBM_READER_open())
sample(name, points)
PW_LBM_READER_sample()
If you give an array of coordinates as a tuple of three numbers, it returns the interpolated values
at these positions as follows
reader = pwpy.LBM_Reader('/path/to/profbin')
points = [(10.0, 5.0, 0.0), (10.0, 5.0, 1.0), (10.0, 5.0, 2.0)]
velocities = reader.sample('velocity', points)
for v in velocities:
print(v)
Parameters
• name (str) – Name of value to be interpolated
• points – List of coordinates
header
PW_LBM_READER_get_header_json()
Type
dict
toc
PW_LBM_READER_get_toc()
Type
list(dict)
This sample shows how to run a DamBreak simulation and capture a video and a screenshot.
1. Project creation of DamBreak
2. Preprocess and simulation
3. Cancel of a running simulation
4. Video capture
5. Screenshot capture
import os.path
import shutil
import sys
sys.path.append('/path/to/particleworks/bin' if sys.platform == 'win32' else '/
˓→path/to/particleworks/lib')
import pwpy
PW = pwpy
PW.set_log_level(PW.LOG_fatal)
(continues on next page)
class DamBreak:
def __init__(self):
self.session = PW.Session()
def execute(self):
# Project & Scene
self.create_project('/path/to/projects')
print('project created')
# Run simulation
self.preprocess()
self.simulation()
# Video
self.create_video()
# Scene
scene = self.scene
model_path = '/path/to/models'
polygon = scene.create_node(PW.NODE_polygon)
def copy_polygon(fname, mtype):
model = self.project.read_model_file(os.path.join(model_path,␣
˓→fname))
material = scene.create_material(mtype)
node = scene.duplicate_object(polygon)
node.name = fname
node.model = model
node.material = material
return node
self.water = copy_polygon('water.obj', PW.MATERIAL_fluid)
self.wall = copy_polygon('wall.obj', PW.MATERIAL_polygon)
self.wall['material.alpha'] = 0.5
scene.delete_object(polygon)
scene.write()
def preprocess(self):
(continues on next page)
def simulation(self):
print('running simulation')
if False:
gpu = PW.enumerate_gpu()
for i in range(0,len(gpu)):
if len(gpu[i]) > 0:
p['gpu'] = [i]
break
# Submit task
q = self.session.task_queue
t = q.submit(self.scene, p)
def create_video(self):
print('generating video')
scene = self.scene
# Camera
def create_camera(p, a):
c = scene.create_node(PW.NODE_snapshot)
c['transform.location'] = p
c['transform.rotation'] = a
PW.Camera(c).fit_nodes(w, h, [self.wall, self.water])
return c
c0 = create_camera((30,-30,30), (45,0,45))
c1 = create_camera(( 0,-20,10), (90,0, 0))
# Video
v0 = PW.CaptureView(0,0,scene,c0)
v1 = PW.CaptureView(0,1,scene,c1)
video = PW.Video(1,2,[v0,v1])
video['image.width'] = 2 * w
video['image.height'] = h
video['video.format'] = 'MP4'
video['video.fps'] = 10
video.execute()
print('video : ' + video.output_path(0))
# Screenshot
ss = PW.ScreenShot(1,1,[v0])
path = os.path.join(scene.path(PW.SCENE_PATH_root_dir), "capture.jpg")
ss.execute(path)
if __name__ == '__main__':
d = DamBreak()
d.execute()
• Grid
• Mapping
• Flow rate
• Probe (region)
• Probe (point)
• Ascii output
import os.path
import shutil
import sys
sys.path.append('/path/to/particleworks/bin' if sys.platform == 'win32' else '/
˓→path/to/particleworks/lib')
import pwpy
PW = pwpy
PW.set_log_level(PW.LOG_fatal)
def error_exit(msg):
print(msg);
sys.exit(2)
class PostProc:
def __init__(self):
self.session = PW.Session()
self.project = self.session.open_project('/path/to/project')
self.scene = None
self.model_path = '/path/to/models'
def execute(self):
# Find 'scene'
for scene in self.project.scenes:
if scene.name == 'scene':
self.scene = scene
break
if self.scene == None:
error_exit('Cannot find scene')
self.scene.activate()
self.session.wait(0)
# Set colormap
for c in self.scene.colormaps:
if c['field'] == 'velocity' and c['fieldComponent'] == 0:
c['rangeMin'] = 0
c['rangeMax'] = 10
(continues on next page)
# Execute Postprocessings
self.postproc_surface()
self.postproc_grid()
self.postproc_mapping()
self.postproc_flowrate()
self.postproc_probe_region()
self.postproc_probe_point()
self.postproc_ascii_output()
def postproc_surface(self):
print('Surface')
p = self.scene.create_parameters(PW.PARAMETERS_surface)
p['format'] = 'STL_Binary'
self.submit(p)
def postproc_grid(self):
print('Grid')
p = self.scene.create_parameters(PW.PARAMETERS_grid)
p['fieldArray'] = ['velocity']
self.submit(p)
def postproc_mapping(self):
print('Mapping')
p = self.scene.create_parameters(PW.PARAMETERS_mapping)
p['modelId'] = self.model_id('wall.obj')
self.submit(p)
def postproc_flowrate(self):
print('Flow Rate')
p = self.scene.create_parameters(PW.PARAMETERS_flowrate)
p['modelId'] = self.model_id('flowrate.obj')
self.submit(p)
def postproc_probe_region(self):
print('Region Probe')
def create_sphere(x,y,z,radius):
r = self.scene.create_node(PW.NODE_probe_region)
r['transform.location'] = (x,y,z)
r['probe.region.mode'] = 'Sphere'
r['sphereRadius'] = radius
return r
r0 = create_sphere(-10,0,5,5)
r1 = create_sphere( 10,0,5,5)
p = self.scene.create_parameters(PW.PARAMETERS_probe)
(continues on next page)
def postproc_probe_point(self):
print('Point Probe')
def create_point(x,y,z):
r = self.scene.create_node(PW.NODE_probe_point)
r['probe.point.x'] = x
r['probe.point.y'] = y
r['probe.point.z'] = z
return r
r0 = create_point(-10,0,5)
r1 = create_point( 10,0,5)
p = self.scene.create_parameters(PW.PARAMETERS_probe)
p['probe.mode'] = 'Point'
p['fileName'] = 'probe.csv'
p.setup_probe(r0,r1)
self.submit(p)
def postproc_ascii_output(self):
print('Ascii Output')
p = self.scene.create_parameters(PW.PARAMETERS_ascii_output)
self.submit(p)
q = self.session.task_queue
t = q.submit(self.scene, p)
q.run(t)
if t.state != PW.TASK_state_success:
error_exit('Task failed')
if __name__ == '__main__':
p = PostProc()
p.execute()
In this sample, MPS particles with position −10 ≤ 𝑥 ≤ 10 and velocity greater than 10 are extracted, the
markups for the three particles with the largest velocity are created. GUI execution is expected.
import pwpy as PW
def create_markup(scene):
f = PW.Filter(scene)
p = f['position']
v = f['velocity']
a = f.run('MPS', (-10 <= p.x) & (p.x <= 10) & (v.norm > 10))
import numpy
id = a['id']
if len(id) < 3:
PW.message_warning('Not enough number of particles : N=%d' % len(id))
return
def main():
session = PW.Session()
scene = session.active_scene
if scene != None:
create_markup(scene)
if 'Particleworks' in __name__:
main()
This sample uses matplotlib to display histograms in the Python console for the velocity and velocity gradient
of all particles. GUI execution is expected.
import matplotlib
matplotlib.use('module://pwpy.plot_backend')
import pwpy as PW
def show_histogram(scene):
arrays = PW.Filter(scene).run('MPS', None)
a = f.add_subplot(1,2,2)
a.hist(arrays['velocity_gradient'].norm, bins=50, edgecolor='black', color=
˓→'mistyrose')
plt.show()
plt.close(f)
def main():
session = PW.Session()
scene = session.active_scene
if scene != None:
show_histogram(scene)
if 'Particleworks' in __name__:
main()
6.8.1 Backend
An appropriate backend needs to be specified to use matplotlib in GUI execution. Set backend before using
matplotlib.pyplot.
import matplotlib
matplotlib.use('module://pwpy.plot_backend')
The backend (pwpy.plot_backend) provided by Particleworks displays the active Figure in the Python console
of the Particleworks GUI.
Alternatively, the AGG backend can be used to perform the same operation by calling show_plot().
import matplotlib
matplotlib.use('AGG')
import pwpy as PW
class GridProbe:
def __init__(self, session, scene):
self.session = session
self.scene = scene
self.grid = (0, 0, 0)
self.points = []
self.probe = None
def run(self):
with self.session.lock():
if not self.ask():
return
self.clear()
self.get_points()
self.create_probe()
self.run_probe()
self.create_markup()
def ask(self):
a = PW.Input()
(continues on next page)
def get_points(self):
p = q = None
for node in self.scene.nodes:
if node.node_type == PW.NODE_particles:
p, q = node.bounding_box
break
assert p != None
assert q != None
n = self.grid
f = lambda k, i: p[k] + (q[k] - p[k]) * ((i + 1) / (n[k] + 1))
for ix in range(n[0]):
for iy in range(n[1]):
for iz in range(n[2]):
x, y, z = (f(0,ix), f(1,iy), f(2,iz))
self.points.append((x,y,z))
def clear(self):
for node in self.scene.nodes:
t = node.node_type
if t in (PW.NODE_probe, PW.NODE_probe_point, PW.NODE_measure_point):
self.scene.delete_object(node)
def current_frame(self):
import os.path
import re
i = self.scene.current_frame
s = os.path.basename(self.scene.result_files[i])
m = re.match(r'out_(\d+).profbin', s)
if m:
return int(m.group(1))
raise RuntimeError('Cannot parse result file name : ' + s)
def create_probe(self):
frame = self.current_frame()
a = []
for p in self.points:
node = self.scene.create_node(PW.NODE_probe_point)
node['probe.point.x'] = p[0]
(continues on next page)
def run_probe(self):
q = self.session.task_queue
t = q.submit(self.scene, self.probe)
while True:
s = t.state
if s == PW.TASK_state_success:
return
if s in (PW.TASK_state_fail, PW.TASK_state_cancel):
raise RuntimeError('Probe failed')
q.wait(100)
def create_markup(self):
from pathlib import Path
import csv
import math
root = self.scene.path(PW.SCENE_PATH_root_dir)
name = self.probe['folderName']
path = Path(root)/'probe'/name/'probe.csv'
valid = 0
with open(path) as f:
first = True
for row in csv.reader(f):
if first:
p_index = row.index('position.x')
v_index = row.index('velocity.x')
first = False
else:
get = lambda k: (float(row[i + k]) for i in range(3))
px, py, pz = get(p_index)
vx, vy, vz = get(v_index)
if vx == 0 and vy == 0 and vz == 0:
continue
(continues on next page)
def main():
session = PW.Session()
scene = session.active_scene
if scene == None:
return
g = GridProbe(session, scene)
g.run()
if 'Particleworks' in __name__:
main()
import os
import os.path
import shutil
try:
import numpy
except:
numpy = None
def particle_volume(scene):
l0 = scene['pre.initialDistance']
if scene['unit.length'] == 'mm':
l0 *= 0.001
return l0 * l0 * l0
(continues on next page)
def main(scene):
if scene == None:
return
project = scene.project
out_name = scene.name + '_out'
out_scene = next((p for p in project.scenes if p['name'] == out_name), None)
if out_scene == None:
out_scene = project.duplicate_scene(scene, name=out_name)
out_dir = out_scene.path(pwpy.SCENE_PATH_result_dir)
if os.path.exists(out_dir):
shutil.rmtree(out_dir)
os.makedirs(out_dir)
if 'Particleworks' in __name__:
import pwpy
session = pwpy.Session()
main(session.active_scene)
This sample calculates the total area of the mapping model file and the area in the vicinity of particles.When
possible, numpy is used.
try:
import numpy
except:
numpy = None
def area_numpy(arrays):
(t0, t1, t2) = reshape(arrays, 'mapping_integration_time')
(p0, p1, p2) = reshape(arrays, 'position')
nn = numpy.cross(p1 - p0, p2 - p0)
nx = nn[:,0]
ny = nn[:,1]
nz = nn[:,2]
area = numpy.sqrt(nx * nx + ny * ny + nz * nz) * 0.5
sum0 = numpy.sum(area)
sum1 = numpy.sum(numpy.where(
(t0 > 0) & (t1 > 0) & (t2 > 0),
area,
0.0))
return (sum0, sum1)
def area_default(arrays):
time = arrays['mapping_integration_time']
position = arrays['position']
n = len(time)
assert n == len(position)
assert n % 3 == 0
sum0 = 0.0
sum1 = 0.0
for i in range(0, n, 3):
p0, p1, p2 = position[i:i+3]
t0, t1, t2 = time[i:i+3]
area = (p1 - p0).cross(p2 - p0).norm() * 0.5
sum0 += area
if t0 > 0 and t1 > 0 and t2 > 0:
sum1 += area
return (sum0, sum1)
def main(scene):
if scene == None:
return
for node in scene.nodes:
if node.node_type != pwpy.NODE_mapping:
continue
with pwpy.MappingArrays(node) as arrays:
a0, a1 = area_numpy(arrays) if numpy != None else area_
˓→default(arrays)
SEVEN
USER-CREATED PROGRAMS
7.1 Common
7.1.1 Environment
Windows
Linux
333
SDK Manual, Release 8.0.0
Double Precision
Single Precision
7.2 Standalone
When creating a program as Standalone, define a main() function. Call PW_SESSION_start() in the
main() function and create PW_SESSION_t.
#include <sdk/particleworks_api.h>
int
main(int argc, char * argv)
{
PW_ERROR_code_t r;
PW_SESSION_t session;
// Generate Session
r = PW_SESSION_start("test", argc, argv, &session, NULL);
if (r != PW_ERROR_no_error) {
return -1;
}
(continues on next page)
// User process
do_something(session);
// Free Session
r = PW_SESSION_end(session);
if (r != PW_ERROR_no_error) {
return -1;
}
return 0;
}
CXX = icpc
CXXFLAGS = -fPIC -g -std=c++11 -fopenmp -I$(PW_SDK_PATH)/include $(CXXFLAGS_
˓→BUILD)
SOURCES = example.cpp
OBJ_DIR = obj
OBJECTS = $(patsubst %.cpp,$(OBJ_DIR)/%.o,$(SOURCES))
BIN_DIR = bin
TARGET_EXEC = $(BIN_DIR)/pw.executable.example
LIBRARIES = -lpw.api.$(PRECISION)
LIBRARIES += -lpw.opengl.$(PRECISION)
LIBRARIES += -lpw.viewer.$(PRECISION)
LIBRARIES += -lpw.postprocess.$(PRECISION)
LIBRARIES += -lpw.dem.$(PRECISION)
LIBRARIES += -lpw.mps.$(PRECISION)
LIBRARIES += -lpw.core.$(PRECISION)
LIBRARIES += -lboost_filesystem
LIBRARIES += -lboost_program_options
LIBRARIES += -lboost_serialization
prepare :
(continues on next page)
$(TARGET_EXEC) : $(OBJECTS)
$(CXX) $(CXXFLAGS) -o $@ $(OBJECTS) -L$(PW_SDK_PATH)/../lib $(LIBRARIES)
$(OBJ_DIR)/%.o : %.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
Double Precision
Variable Description
CXXFLAGS_BUILD Add -DPW_DEFINE_SCALAR_DOUBLE
PRECISION Specify double
Single Precision
Variable Description
CXXFLAGS_BUILD Add -DPW_DEFINE_SCALAR_FLOAT
PRECISION Specify float
7.3 Plugin
#include <sdk/particleworks_api.h>
PW_ERROR_code_t
PW_MODULE_initialize(PW_SESSION_t session)
{
// Session from Solver is passed.
return install_user_functions(session);
}
PW_ERROR_code_t
PW_MODULE_terminate(PW_SESSION_t session)
{
(continues on next page)
CXX = icpc
CXXFLAGS = -fPIC -g -std=c++11 -fopenmp -I$(PW_SDK_PATH)/include $(CXXFLAGS_
˓→BUILD)
SOURCES = example.cpp
OBJ_DIR = obj
OBJECTS = $(patsubst %.cpp,$(OBJ_DIR)/%.o,$(SOURCES))
BIN_DIR = bin
TARGET_PLUGIN = $(BIN_DIR)/pw.plugin.example.so
prepare :
mkdir -p $(BIN_DIR) $(OBJ_DIR)
$(TARGET_PLUGIN) :$(OBJECTS)
$(CXX) $(CXXFLAGS) -o $@ -shared $(OBJECTS)
$(OBJ_DIR)/%.o : %.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
Double Precision
Variable Description
CXXFLAGS_BUILD Add -DPW_DEFINE_SCALAR_DOUBLE
PRECISION Specify double
Single Precision
Variable Description
CXXFLAGS_BUILD Add -DPW_DEFINE_SCALAR_FLOAT
PRECISION Specify float
EIGHT
EXAMPLES
8.1 Execution
Use sdk/share/run_example.py to run the already-built examples included in the SDK. Python 3.8 is
required to run the examples.
Ar- Description
gu-
ment
PRE- Precision. Specify double or float.
CI-
SION
TYPE Specify whether to execute in Plugin or Standalone. Specify plugin or standalone.
TAR- Specify the name of the example to run. Specify either number_density, user_visibility,
GET wave_inflow, add_physical_value, dem_collision_count, volume_fraction, or
dem_number_density.
The API written in C makes the program inconvenient for the following reasons:
• Memory management
• Error handling
For example, the function to set and get a string property is as follows:
PW_ERROR_code_t
get_string_property(PW_OBJECT_t object, const char * name, char * buf, size_t␣
˓→size)
{
(continues on next page)
339
SDK Manual, Release 8.0.0
// Property acquisition
r = PW_OBJECT_get_property(object, name, &p);
if (r != PW_ERROR_no_error) {
return r;
}
PW_ERROR_code_t
set_string_property(PW_OBJECT_t object, const char * name, const char * buf)
{
PW_ERROR_code_t r;
PW_STRING_t s;
// Set property
PW_PROPERTY_t p;
p.type = PW_PROPERTY_string_c;
(continues on next page)
return r;
}
std::string
get_property_string(pw::api::Object & object, std::string name)
{
return object.property_value<std::string>(name);
}
void
set_property_string(pw::api::Object & object, std::string name, std::string␣
˓→value)
{
object.property_value<std::string>(name, value);
}
The C++ Wrapper is included in sdk/include directory of the Particleworks. Since it is provided as a
Header-only source library, it can be viewed and modified. The following classes are defined:
8.3.1 Files
Files Description
example_main.cpp Entry Point in Standalone (main() function)
example_dll.cpp Entry Point in Plugin (PW_MODULE_initialize() function)
example_module.cpp, pw::example::Module's implementation (shared class)
example_module.hpp
example_number_density.cpp, pw::example::number_density::Module's implemen-
example_number_density.hpp tation (Example: Calculation of Particle Number Density
(Interactions))
example_user_viscosity.cpp, pw::example::user_viscosity::Module's implementa-
example_user_viscosity.hpp tion (Example: User-Defined Viscosity)
example_add_physical_value. pw::example::add_physical_value::Module's imple-
cpp, example_add_physical_value. mentation (Example: Adding a Physical Quantity)
hpp
example_wave_inflow.cpp, pw::example::wave_inflow::Module's implementation
example_wave_inflow.hpp (Example: Manipulating Inflow Particles)
example_dem_collision_count. pw::example::dem::collision_count::Module's im-
cpp, example_dem_collision_count. plementation (Example: Number of Collisions of DEM
hpp Particles)
pw::example::Module
class pw::example::Module
Description
A class representing the processes of each example. In the example class, this class is inherited and
pw::example::Module::initialize() is implemented.
Also, pw::example::Module::run() is implemented if required.
pw::example::Module::initialize()
void Module::initialize()
Description
Performs the initialization of the example. In it, the following processes are performed:
• Registration of Session and User Function
• Registration of the physical quantities, used in an example, in Arrays
• Acquiring the physical properties values from Material
pw::example::Module::run()
Arguments
Description
In the case of Standalone, describe the processes to be executed after initialization with
pw::example::Module::initialize().
int
main(int argc, char * argv[])
{
(continues on next page)
// Module execution
auto module = pw::example::Module::create(key, session.handle());
module->run(args);
});
}
void
Module::run(const std::vector<std::string> & args)
{
m_session.solver().step(-1);
}
8.4.1 Objective
• Register User Function before and after the Particle Number Density Kernel.
• Calculate the interactions between MPS particles using pw::api::InteractionPP
(PW_INTERACTION_PP_t).
• Obtain PW_INTERACTION_PD_t from pw::api::DistanceField (PW_DF_t)and calculate the inter-
actions between MPS particles and the Distance Field.
• Compare the calculated results with those of Particleworks.
The project included with the SDK is a Dam Break case, but since Particle Number Density is always gen-
erated for fluid analysis, it can be executed for any other case.
class NumberDensityCalculate
8.5.1 Objective
In the project included in the SDK, we set up different properties for 2 blocks of mud and compare their
adhesion to the ceiling when they are thrown at it. The one on the left side of the image is a Bingham fluid
(FluidBingham), and the one on the right side uses the viscosity overwritten by User Function (FluidUser).
class CalculateViscosity
8.6.1 Objective
class InflowPre
8.7.1 Objective
• Create an editing tool for .profbin which acts when Mode is Standalone.
• Add the physical quantity kinetic_energy representing the kinetic energy from the existing physical
quantity velocity and store it in .profbin.
The project included in the SDK is a Dam Break case, but since velocity is normally stored in .profbin, it
can be executed for any other case.
The added physical quantity can be confirmed in the GUI with the Particle Detail.
void Module::initialize()
• Construct a correspondence table between material_index and the physical property density
(m_densities):
– The ID obtained with PW_MATERIAL_get_object_id() from PW_MATERIAL_t matches
material_index.
• Add the kinetic_energy array to MPS Particles.
void Module::run()
8.8.1 Objective
If doing DEM calculations, this can be done generically. The number of collisions is saved as a physi-
cal quantity starting with example_count, and its value can be confirmed in the GUI with the Particle
Detail.
void ModuleImpl::initialize()
void ModuleImpl::calculate_pp()
8.9.1 Objective
• Calculate the interaction between fluid particles (MPS) and DEM particles using
pw::api::InteractionPP (PW_INTERACTION_PP_t)
• Compare the calculated results with those of Particleworks.
If your project is to perform coupled DEM-MPS calculations, you can run this plugin.
class VolumeFractionCalculate
8.10.1 Objective
• Calculate the interaction between DEM particles and fluid particles (MPS) using
pw::api::InteractionPP (PW_INTERACTION_PP_t)
• Obtain PW_INTERACTION_PD_t from pw::api::DistanceField (PW_DF_t)and calculate the inter-
actions between DEM particles and the Distance Field.
• Compare the calculated results with those of Particleworks.
If your project is to perform coupled DEM-MPS calculations, you can run this plugin..
8.10. Example: Calculation of the DEM Particle Number Density (Interactions). 355
SDK Manual, Release 8.0.0
class DEM_NumberDensityCalculate
[IKARI-2012] H. Ikari, H. Gotoh, T. Arai, Numerical Simulation on Land-slide induced Tsunami by Parti-
cleMethod with Non-Newtonian Fluid Model” (in Japanese), Journal of Japan Society of Civil
Engineers, Ser. B2 (Coastal Engineering), Vol.68, No.2, 2012, I_066-I_070
357