0% found this document useful (0 votes)
2 views

SDK Manual

The SDK Manual for Prometech Software, Inc. details the features and functionalities of Release 8.0.0, including distribution modes, objects, and their properties. It covers various components such as sessions, projects, scenes, nodes, and user functions, along with their respective properties and limitations. The document serves as a comprehensive guide for users to understand and utilize the software effectively.

Uploaded by

040520349
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

SDK Manual

The SDK Manual for Prometech Software, Inc. details the features and functionalities of Release 8.0.0, including distribution modes, objects, and their properties. It covers various components such as sessions, projects, scenes, nodes, and user functions, along with their respective properties and limitations. The document serves as a comprehensive guide for users to understand and utilize the software effectively.

Uploaded by

040520349
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 365

SDK Manual

Release 8.0.0

Prometech Software, Inc.

Jun 05, 2023


CONTENTS

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

3 API Reference 117


3.1 Session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
3.1.1 Data Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
3.1.2 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
3.2 Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
3.2.1 Data Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
3.2.2 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
3.3 Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
3.3.1 Data Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
3.3.2 Function(target all components) . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
3.3.3 Functions(Property) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
3.4 Scene . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
3.4.1 Data Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
3.4.2 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
3.5 Node . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
3.5.1 Data Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
3.5.2 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
3.6 Material . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
3.6.1 Data Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
3.6.2 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
3.7 Widget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
3.7.1 Data Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
3.7.2 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
3.8 Distance Field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193

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

4 Adding Properties 255


4.1 Related API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
4.2 How to Add . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255

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

5 File I/O API Reference 261


5.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
5.2 Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
5.2.1 Data Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
5.2.2 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
5.3 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
5.3.1 File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
5.3.2 Licence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276

6 Python Reference 277


6.1 Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
6.1.1 CUI execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
6.1.2 GUI execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
6.1.3 Notes on the bundled Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
6.2 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
6.2.1 Object Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
6.2.2 Value Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
6.2.3 Node Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
6.2.4 Material Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
6.2.5 Widget Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
6.2.6 Property Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282
6.2.7 Log Level . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
6.2.8 Scene Path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
6.2.9 Mesh Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
6.2.10 Task State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
6.2.11 Animation Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
6.2.12 Animation Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
6.2.13 Phys Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
6.2.14 Renderer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
6.2.15 Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
6.2.16 Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
6.2.17 Rotation Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
6.2.18 Error Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
6.3 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
6.3.1 Normal functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
6.3.2 Functions (Only available in GUI) . . . . . . . . . . . . . . . . . . . . . . . . . . 287
6.4 Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
6.4.1 Session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
6.4.2 Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289

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

7 User-Created Programs 333


7.1 Common . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
7.1.1 Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
7.1.2 Environment Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
7.1.3 Visual Studio Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334
7.2 Standalone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334
7.2.1 main function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334
7.2.2 Makefile (gmake) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335
7.3 Plugin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
7.3.1 Entry Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
7.3.2 Makefile (gmake) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337

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

Following files are runtime modules related to the SDK.

1
SDK Manual, Release 8.0.0

Filename (Windows) Filename (Linux) Description


bin/app.solver.double. bin/app.solver.double Solver executable file (double-
exe precision)
bin/app.solver.float.exe bin/app.solver.float Solver executable file (single-
precision)
bin/pw.api.double.dll bin/pw.api.double.so SDK Dynamic Library (double-
precision)
bin/pw.solver.float.dll bin/pw.solver.float. SDK Dynamic Library (single-
so precision)
sdk/bin/double/pw. sdk/bin/double/pw. Examples executable file (double-
executable.example.exe executable.example precision, Standalone format)
sdk/bin/double/pw. sdk/bin/double/pw. Examples executable file (double-
plugin.example.dll plugin.example.so precision, Plugin format)
sdk/bin/float/pw. sdk/bin/float/pw. Examples executable file (single-
executable.example.exe executable.example precision, Standalone format)
sdk/bin/float/pw.plugin. sdk/bin/float/pw. Examples executable file (single-
example.dll plugin.example.so precision, Plugin format)

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.

1.2.4 Python API

You can also call the API using Python. See Python Reference for details. Using the Python API consumes
a license for the Viewer SDK.

1.2.5 Available Objects and Functions

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

• SDK API calls lock a global lock for thread-safety.


• Error messages returned by PW_ERROR_get_last_message() are stored in TLS (Thread Local Stor-
age).

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.

Function Corresponding API


Handle PW_SESSION_t
Access other objects such as Scene and Node PW_SESSION_enumerate_objects()
User Function registration PW_SESSION_add_user_function()
Reading and writing .profbin file PW_SESSION_read_particles(), etc.

2.2 Project

Project corresponds to “Project” in the GUI.

2.1. Session 7
SDK Manual, Release 8.0.0

Function Corresponding API


Handle PW_PROJECT_t
Get file path PW_PROJECT_get_path()
Create scene PW_PROJECT_create_scene()

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.

Function Corresponding API


Handle PW_SCENE_t
Get subordinate objects PW_SCENE_enumerate_objects()
Access property sheet PW_OBJECT_get_property()

2.3.1 Active state

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

This is an explanation of followings about available properties:


• Name in property sheet in the GUI
• Name in SDK
• Type
• Remarks (possible values, etc.)

unit

Name (GUI) Name (SDK) Type Remarks


Length unit.length string Choices : “m”, “mm”
Angle unit.angle string Choices : “degree”, “radian”
Volume unit.volume string Choices : “m^3”, “liter”
Temperature unit.temperature string Choices : “Celsius”

pre

Name (GUI) Name Type Remarks


(SDK)
Coordinate System pre.coordinateSystem
string Choices : “xyz”, “xy”, “yz”, “zx”
Particle Size pre.initialDistance
scalar
Auto Grid Interval pre.autoGrid bool
Grid Interval pre.distanceOfGrid
scalar
Inside/Outside De- pre.pointInMeshScale
scalar
termination Res.
DF Memory pre.dfMemory string Choices : “Compatible”, “BlockDF” (displayed as Compat-
ible, Memory Efficient in GUI, respectively)

mps

Name Name Type Remarks


(GUI) (SDK)
Type mps.type string Choices : “conventional”, “mpfi” (displayed as MPS, MPFI in GUI,
respectively)

2.3. Scene 9
SDK Manual, Release 8.0.0

physics

Name (GUI) Name (SDK) Type Remarks


Mass Density of Air physics.massDensityOfAir scalar

pressure

Name (GUI) Name (SDK) Type Remarks


Type pressure.type string Choices : “Implicit”, “Explicit”
Mode pres- string Choices : “Normal”, “Stabilized”, “Div. Free”,
sure.mode.implicit “Negative Pressure”, “Iterative (beta)”, “Custom”
Mode pres- string Choices : “Normal”, “Stabilized”, “Negative Pres-
sure.mode.explicit sure”, “Iterative (beta)”, “Custom”
Speed of Sound pres- scalar
sure.speedOfSound
Number of correc- pres- int
tions sure.numberOfCorrection
Beta pressure.beta scalar
Gamma pressure.gamma scalar
dt Independent pres- bool
Model sure.dtIndependentModel
Wall-Tangential pres- bool
Pressure Gradient sure.WallTangentialPressureGradient
Blend Ratio of pressure.blendRatio scalar
Pressure Gradient
Symmetric Pres- pres- bool
sure Gradient sure.symmetricGradientModel
Model
Mixed Pressure pres- bool
Gradient Model sure.mixedGradientModel
Polygon Contribu- pres- scalar
tion to Coef. Matrix sure.diagCoefficient
Divergence Free pressure.divSource bool
Source Term
Blend Ratio of pres- scalar
Source Term sure.sourceBlendRatio
Pressure Smooth- pressure.smoothing bool
ing
Remove Negative pres- string Choices : “Default”, “Near Surface”
Pressure sure.removeNegativePressure

10 Chapter 2. Objects
SDK Manual, Release 8.0.0

viscosity

Name (GUI) Name (SDK) Type Remarks


Type viscosity.type string Choices : “None”, “Implicit”, “Explicit”
Beta viscosity.beta scalar

surfaceTension

Name (GUI) Name (SDK) Type Remarks


Type surfaceTension.type string Choices : “None”, “Poten-
tial”, “CSF”
Surface Tension Threshold surfaceTension.threshold scalar
Target Physical Property surfaceTension.physicalProperty int Object ID
Only Interact Nearest DF surfaceTen- bool
sion.onlyInteractNearestDF
Dynamic Contact Angle surfaceTen- string Choices : “None”, “Friction”
Model sion.dynamicContactAngleModel
Enabled (Potential Ampli- surfaceTension.amplify.enabled bool
fier)
Acceleration (Potential surfaceTen- ar- Scalar array
Amplifier) sion.amplify.acceleration ray
Coefficient (Potential Am- surfaceTension.amplify.coefficient ar- Scalar array
plifier) ray

rigidBody

Name (GUI) Name (SDK) Type Remarks


Type rigidBody.type string Choices : “Rigid”
Ratio of Spring Constant rigidBody.springConstant scalar
Ratio of Damping Coefficient rigidBody.dampingCoefficient scalar

2.3. Scene 11
SDK Manual, Release 8.0.0

thermal

Name (GUI) Name (SDK) Type Remarks


Type thermal.type string Choices : “None”, “Thermal”
Shear Heating thermal.shearHeating bool
Shear Heating Mode thermal.shearHeatingMode string Choices : “Normal”, “Improved”
Type for HTC thermal.htc.type string Choices : “None”, “Const”,
“Calc”
HTC Calculation Range thermal.htc.calculationRadius scalar
Temperature Dependency thermal.useDatabase bool
Specific Heat File thermal.specificHeatFile string File Path
Thermal Conductivity ther- string File Path
File mal.thermalConductivityFile
Target Physical Property thermal.physicalProperty int Object ID

htc

Name (GUI) Name (SDK) Type Remarks


Type htc.type string Choices : “None”, “HTC”,
“Script”
Heat Transfer Coefficient Calcu- htc.relativisticContactLength scalar
lation Range
Heat Transfer Coefficient Lower htc.lowerLimitOfHeatTransferCoefficient
scalar
Limit
Heat Transfer Coefficient Upper htc.upperLimitOfHeatTransferCoefficient
scalar
Limit
Clear Heat Transfer Coefficient htc.clearWhenContactAnotherMaterialDF
bool
Critical Re htc.ReOfTurbulentTransitionBeginscalar
Re of Fully Developed Turbulent htc.ReOfFullyTurbulent scalar
NuC(laminar) htc.laminar.NuCoefficient scalar
PrE(laminar) htc.laminar.PrExponent scalar
ReE(laminar) htc.laminar.ReExponent scalar
NuC(turbulent) htc.turbulent.NuCoefficient scalar
PrE(turbulent) htc.turbulent.PrExponent scalar
ReE(turbulent) htc.turbulent.ReExponent scalar
User Function htc.userFunction.text string

12 Chapter 2. Objects
SDK Manual, Release 8.0.0

turbulence

Name (GUI) Name (SDK) Type Remarks


Type turbulence.type string Choices : “None”, “Turbulence”
Smagorinsky Constant turbulence.smagorinskyConstant scalar
Kappa turbulence.kappa scalar
B turbulence.beta scalar
Boundary Parameter1 turbulence.boundaryParameter1 scalar
Boundary Parameter2 turbulence.boundaryParameter2 scalar
Target Physical Property turbulence.physicalProperty int Object ID

cht

Name (GUI) Name (SDK) Type Remarks


Type for Simulation cht.steadyState.type string Choices : “None”, “Unsteady”,
“Steady”
Tolerance cht.steadyState.eps scalar
Max Iterations cht.steadyState.maxIterations
int
Type for Heat Transfer cht.type string Choices : “None”, “HTC”,
“HeatConduction”
Type for Thermal Conduction cht.conduction.type string Choices : “None”, “Explicit”,
“Implicit”
Heat Transfer from CHT to MPS cht.s2f.enable bool
Heat Transfer between CHTs cht.chtcht bool
Heat Transfer from Ambient to CHT cht.ambient.enable bool
Ambient Temperature cht.ambientTemperaturescalar
Type for HTC cht.htc.type string Choices : “Const”, “Calc”
Searching Radius for Spatially Dis- cht.heatSource.MLS.radius
scalar
tributed Heat Source
Calculation for Isothermal Boundary cht.bc.type string Choices : “None”, “Dirichlet”,
“HeatTransfer”
Boundary Distance Ratio cht.bc.boundaryRatio scalar
Thermal Boost cht.thermalBoost bool
Time to Start Boost cht.startBoosting scalar
Time to End Boost cht.endBoosting scalar
Thermal Boost Ratio cht.dtFactorDuringBoosting
scalar

2.3. Scene 13
SDK Manual, Release 8.0.0

passiveScalar

Name (GUI) Name (SDK) Type Remarks


Type passiveScalar.type string Choices : “None”, “Passive Scalar”
Diffusivity passiveScalar.diffusivity scalar
Turbulent Schmidt Number passiveScalar.schmidtNum scalar

mpfi

Name (GUI) Name (SDK) Type Remarks


Speed of Sound mpfi.speedOfSound scalar
Alpha mpfi.pressureAlpha scalar
Implicit Pressure Smoothing mpfi.implicitPressureSmoothing bool
Smoothing Factor mpfi.smoothingDelta scalar
Matrix Free mpfi.matrixFree bool
Two-Grid Preconditioner mpfi.twoGrid bool
Iterative Solver Tolerance (Particle) mpfi.tolerance scalar
Iterative Solver Tolerance (Grid) mpfi.coarseTolerance scalar
Only Interact Nearest DF (number density) mpfi.onlyInteractNearestDF bool

14 Chapter 2. Objects
SDK Manual, Release 8.0.0

particleShifting

Name (GUI) Name (SDK) Type Remarks


Type particleShifting.type string Choices : “None”, “ParticleShift-
ing”
Shifting Coefficient particleShifting.coefficient scalar
Max Distance particleShift- scalar
ing.maxDistance
Mach Number particleShifting.mach scalar
Density Threshold particleShift- scalar
ing.densityThreshold
Count Threshold particleShift- scalar
ing.countThreshold
Penalty Threshold particleShift- scalar
ing.penaltyThreshold
Radius of Curvature particleShift- scalar
ing.radiusCurvature
Interpolation of Physical particleShift- string Choices : “Inner Particles”, “All
Quantities ing.interpolationMode Particles”, “None”
Only Interact Nearest DF particleShift- bool
ing.onlyInteractNearestDF
Limitation of Shifting by Par- particleShift- bool
ticle Velocity ing.velocityLimiter
Max Velocity particleShift- scalar
ing.maxVelocity

dem

Name (GUI) Name (SDK) Type Remarks


Type dem.type string Choices : “DEM”
Substeps dem.substeps int
Coarse Grain Ratio dem.coarseGrainRatio scalar
Calculate Force between Powder and Fluid dem.calculatePowderToFluid bool
Excluded Volume Effect dem.excludedVolumeEffect bool

dem_contact

Name (GUI) Name (SDK) Type Remarks


Contact Force dem.contact.model string Choices : “Default”, “Hooke”, “Hertz”,
Model “ConstWB”, “VarWB”, “Thornton”
Contact Force dem.contact.particleInteraction
bool
(DEM - DEM)
Impact Velocity dem.contact.characteristicImpactVelocity
scalar

2.3. Scene 15
SDK Manual, Release 8.0.0

dem_rollingResistance

Name (GUI) Name (SDK) Type Remarks


Rolling Resistance Model dem.rollingResistance.model string Choices : “None”, “EPP”
Threshold (DEM - DEM) dem.rollingResistance.errorDEMDEM scalar
Threshold (DEM - DF) dem.rollingResistance.errorDEMDF scalar

dem_intermolecular

Name (GUI) Name (SDK) Type Remarks


Intermolecular Force Model dem.intermolecular.model string Choices : “None”, “van der
Waals”
Intermolecular Force (DEM dem.intermolecular.vdW.calculationDEMDEM
bool
- DEM)
Intermolecular Force (DEM dem.intermolecular.vdW.calculationDEMDF
bool
- DF)
Lower Cutoff Ratio dem.intermolecular.vdW.ratioOfCutoffMin
scalar
Upper Cutoff Ratio dem.intermolecular.vdW.ratioOfCutoffMax
scalar

dem_liquidBridge

Name (GUI) Name (SDK) Type Remarks


Surface Tension dem.liquidBridge.surfaceTension.model string Choices : “None”, “Wil-
Model lett2000”, “No-slip”
Surface Tension dem.liquidBridge.surfaceTension.calculationDEMDEM
bool
(DEM - DEM)
Surface Tension dem.liquidBridge.surfaceTension.calculationDEMDF
bool
(DEM - DF)

dem_heatTransfer

Name (GUI) Name (SDK) Type Remarks


Heat Transfer Model dem.heatTransfer.model string Choices : “None”,
“Hertz”
Heat Transfer (DEM - dem.heatTransfer.calculationDEMDEM bool
DEM)
Heat Transfer (DEM - DF) dem.heatTransfer.calculationDEMDF bool

16 Chapter 2. Objects
SDK Manual, Release 8.0.0

dem_sdem

Name (GUI) Name (SDK) Type Remarks


SDEM Model dem.sdem.SDEM string Choices : “None”, “SDEM”
Coarse Grain Ratio dem.sdem.coarseGrainRatio scalar
Volume Fraction dem.sdem.volumeFraction scalar
Rigid Model dem.sdem.rigidModel string Choices : “Rigid”, “non-Rigid”

2.3. Scene 17
SDK Manual, Release 8.0.0

fvm

Name (GUI) Name (SDK) Type Remarks


Type fvm.type string Choices : “None”, “PISO”, “SIMPLE”,
“SIMPLE->PISO”
Max Iterations fvm.simple.maxIterationsint
Tolerance (Velocity) fvm.simple.eps.velocity scalar
Tolerance (Pressure) fvm.simple.eps.pressure scalar
Tolerance (Turbulence) fvm.simple.eps.turbulencescalar
Tolerance (Passive fvm.simple.eps.passiveScalar
scalar
Scalar)
File Output Interval fvm.simple.outputIntervalint
Grid Interval fvm.gridInterval scalar
Advection Scheme fvm.convection string Choices : “Upwind”, “Linear Upwind”
Advection Blending Fac- fvm.convection.blend scalar
tor
Turbulence Model fvm.turbulence string Choices : “None”, “k-epsilon”
Passive Scalar fvm.passiveScalar string Choices : “None”, “Passive Scalar”
Diffusivity fvm.passiveScalar.diffusivity
scalar
Turbulent Schmidt Num- fvm.passiveScalar.schmidtNum
scalar
ber
Relaxation Factor (Veloc- fvm.relaxationVelocity scalar
ity)
Relaxation Factor (Pres- fvm.relaxationPressure scalar
sure)
Relaxation Factor (Turbu- fvm.relaxationTurbulencescalar
lence)
Relaxation Factor (Pas- fvm.relaxationPassiveScalar
scalar
sive Scalar)
Iterative Solver Tolerance fvm.epsSolver scalar
Coefficient Matrix Diago- fvm.diagFactor scalar
nal Factor
Enable AMG fvm.pressure.amg bool
Coupling Type fvm.coupling.type string Choices : “One-way”, “Two-way”
Pressure Gradient Factor fvm.coupling.factorPresGrad
scalar
Maximum Density Ratio fvm.coupling.densityRatioscalar
Maximum Viscosity Ra- fvm.coupling.viscosityRatio
scalar
tio
Drag Coefficient fvm.coupling.dragCoefficient
scalar
Target Physical Property fvm.physicalProperty int Object ID

18 Chapter 2. Objects
SDK Manual, Release 8.0.0

lbm

Name (GUI) Name (SDK) Type Remarks


Type lbm.type string Choices : “None”, “Cumu-
lant”
Grid Interval lbm.interval scalar
Grid Refinement lbm.refinement.type string Choices : “None”, “De-
fault”
Minimum Grid Interval lbm.refinement.minimum_interval
scalar
Layer Width lbm.refinement.layer int
Refinement Range lbm.refinement.polygon_radiusscalar
Remove Unstable Cells lbm.remove_unstable_cells string Choices : “Default”,
“None”
Density lbm.density scalar
Kinematic Viscosity lbm.kinematic_viscosity scalar
Factor for External Force lbm.external_force scalar
Maximum Velocity lbm.physical_max_velocity scalar
Wall Boundary Condition lbm.wall.type string Choices : “No-Slip”, “Tur-
bulent”
Set a constant of kappa in LBM wall lbm.wall_law.KarmanC scalar
function.
Set a constant of B in LBM wall func- lbm.wall_law.B scalar
tion.
Coefficient of Wall Shear Stress lbm.wall.friction_coefficient scalar
Load / Torque Calculation lbm.load_torque bool
Drag Coefficient lbm.cosim.drag_coefficient scalar
Particle Reaction Coefficient lbm.cosim.reaction_coefficientscalar

aeration

Name (GUI) Name (SDK) Type Remarks


Type aeration.type string Choices : “N
Virtual Mass Coefficient aeration.virtualMassCoefficient scalar
Drag Model aeration.dragModel string Choices : “N
Drag Adjust Coefficient aeration.dragAdjustCoefficient scalar
Buoyancy Model aeration.buoyancyModel string Choices : “N
Lift Model aeration.liftModel string Choices : “N
Wall Lubrication Model aeration.wallLubricationModel string Choices : “N
Pipe Diameter aeration.dimensionOfTheSystemInWall scalar
Tangential Wall Contact Model aeration.bubbleWallContactModelOfTangentialComponent string Choices : “D
Wall Viscous Damping Coefficient aeration.bubbleWallViscousDampingCoefficient scalar
Dt Correction by Virtual Mass aeration.useVirtualMassForDt string Choices : “D
Gravity Correction by Liquid Film aeration.gravityCorrection bool

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

Name (GUI) Name (SDK) Type Remarks


Type air.type string Choices : “Normal”,
“Improved”
Drag Adjustment Parameter for air.dragAdjustmentParameterForIsolatedParticles
scalar
Isolated Particles

20 Chapter 2. Objects
SDK Manual, Release 8.0.0

overlap

Name (GUI) Name (SDK) Type Remarks


Type overlap.type string Choices : “None”, “OPT” (displayed as
None, Multi-Resolution in GUI, respec-
tively)
Ratio of Particle Size over- int
lap.particleSizeRatio
Auto Setting of dt over- bool
lap.autoTimeStepRatio
Ratio of dt over- int
lap.timeStepRatio
Automatic Adjustment of over- bool
Shifting Coefficient lap.adjustShiftingCoefficient
Shifting Coefficient over- scalar
lap.shiftingAlpha
Adjustment Coefficient over- scalar
lap.shiftingGamma
Shifting Threshold overlap.shiftingBeta scalar
Max Distance of Shifting over- scalar
lap.maxShiftingDistance
Only Interact Nearest DF over- bool
lap.shiftingOnlyNearestDF
Blend Ratio of Velocity overlap.blendRatio scalar
Automatic Adjustment of over- bool
Surface Tension Coefficient lap.adjustSurfaceTensionCoefficient
Surface Tension Coefficient over- scalar
lap.surfaceTensionCoefficient

simulation

Name (GUI) Name (SDK) Type Remarks


Finish Time simulation.finishTime scalar
Initial dt simulation.initialDt scalar

options

Name (GUI) Name (SDK)


Domain Decomposition options.domainDecomposition
DF Memory options.dfMemory
Courant Number options.courantNumber
Courant Limiter options.courantLimiter

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

Name (GUI) Name (SDK) Type Remarks


Precision output.precision string Choices : “default”, “single”
Type output.type string Choices : “simulationTime”,
“timeStep”
File Output Interval Time out- scalar
put.fileOutputIntervalTime
File Output Interval Frame out- int
put.fileOutputIntervalFrame
File Output Skip output.fileOutputSkip bool
Output Skip Interval output.fileOutputSkipInterval int
Load / Torque Type output.torqueType string Choices : “Sampling”,
“TimeAveraged”
Load / Torque Output Interval out- scalar
put.torqueOutputIntervalTime
Heat Balance Type output.heatBalanceType string Choices : “Sampling”,
“TimeAveraged”
Heat Balance Output Interval out- scalar
put.heatBalanceOutputIntervalTime
Restrict particles output to out- output.regionOnly bool
put regions
Console Output Interval Time output.logIntervalTime scalar
Trace Log Interval Frame output.traceIntervalStep int
Output Inflow / Outflow logs output.inflowOutflowLog bool
Start Time of Time-Averaging out- scalar
put.turbulence_average_start_time

outputFlags

Name (GUI) Name (SDK) Type Remarks


Pressure outputFlags.pressure bool
Number Density outputFlags.numberDensity bool
Kinematic Viscosity outputFlags.kinematicViscosity bool
Molecular Kinematic Viscosity outputFlags.kinematicViscosityMolecular bool
Turbulent Kinematic Viscosity outputFlags.kinematicViscosityTurbulent bool
Turbulent Viscosity outputFlags.viscosityTurbulent bool
Wall Turbulent Viscosity outputFlags.viscosityTurbulentWall bool
Absolute Velocity Gradient outputFlags.absoluteVelocityGradient bool
Velocity Gradient outputFlags.velocityGradient bool
Deformation Tensor outputFlags.deformationTensor bool
Stress Tensor outputFlags.stressTensor bool
Angular Velocity outputFlags.angularVelocity bool
continues on next page

2.3. Scene 23
SDK Manual, Release 8.0.0

Table 3 – continued from previous page


Name (GUI) Name (SDK) Type Remarks
Von Mises Stress outputFlags.vonMisesStress bool
Wall Y+ outputFlags.wallY bool
Turbulent Energy outputFlags.turbulentEnergy bool
Turbulent Energy Dissipation Rate outputFlags.dissipationRate bool
Time-Averaged Velocity outputFlags.averageVelocity bool
van der Waals Force outputFlags.vanDerWaalsForce bool
Liquid Bridge Force outputFlags.liquidBridgeForce bool
Interaction Between DEM Particles outputFlags.demInteractionForcePP bool
Airflow Velocity outputFlags.airFlowVelocity bool
Airflow Neighbor Count outputFlags.numberOfNeighborNodeOfAirFlow bool
Surface Area outputFlags.surfaceAreaForAirResistance bool
Air Drag Coefficient outputFlags.airDragCoefficient bool
Pathline Length outputFlags.pathlineLength bool
Heat Flux (Output) outputFlags.heatFlux bool
Passive Scalar outputFlags.passiveScalar bool
Rigid Body Impulsive Force outputFlags.rigidBodyImpulsiveForce bool
Rigid Body Cumulative Impulse outputFlags.rigidBodyCumulativeImpulse bool
Residence Time outputFlags.residenceTime bool
FVM Force outputFlags.fvmForce bool

scene options

Name (GUI) Name (SDK) Type Remarks


Background view.background string Color
Use Gradient view.gradient bool
Background Low view.backgroundLow string Color
Color Map view.colorMap int Object ID
Show Gizmo view.gizmoVisible bool
Ref. Frame transform.referenceFrame int Object ID

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.

Function Corresponding API


Handle PW_NODE_t
Property access PW_OBJECT_get_property()
ID PW_NODE_get_group_id()
Motion PW_NODE_get_transform_matrix()

2.4. Node 25
SDK Manual, Release 8.0.0

2.4.1 Properties (Input)

Airflow (CSV)

Name (GUI) Name (SDK) Type Re-


marks
Name name string
Visible visible bool
Repeat Airflow Data phys.repeatAirflowFlag bool
Number of Neighboring Air Flow Data phys.numOfNeighAirFlowDataPoints int
Points
Mass Density of Air phys.massDensityOfAir scalar
Air Drag Coefficient phys.airResistanceCoefficient scalar
Kinematic Viscosity of Air phys.kinematicViscosityOfAir scalar

Airflow (LBM)

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
Repeat Airflow Data phys.repeatAirflowFlag bool
Start Frame phys.repeatAirflowStartFrame int
End Frame phys.repeatAirflowEndFrame int
Air Drag Coefficient phys.airResistanceCoefficient scalar
Show Gas Cells material.showCellGas bool
Show Solid Wall material.showCellSolid bool

Airflow (FVM)

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
Show Only Gas material.showOnlyGas bool
Repeat Airflow Data phys.repeatAirflowFlag bool
Start Frame phys.repeatAirflowStartFrame int
End Frame phys.repeatAirflowEndFrame int
Air Drag Coefficient phys.airResistanceCoefficient scalar

26 Chapter 2. Objects
SDK Manual, Release 8.0.0

CHT B.C.

Name Name Type Remarks


(GUI) (SDK)
Name name string
Visi- visible bool
ble
Type chtBc.show.Typestring Choices : “None”, “Convective Heat Transfer (CSV)”, “Convective Heat
Transfer (Profbin)”, “Heat Source”, “Heat Flux”, “Temperature”
Orig- chtBc.show.originalPath
string
inal
Path

Camera

Name Name Type Remarks


(GUI) (SDK)
Name name string
Visible visible bool
Rotation rotateMode string Choices : “TurnTable”, “TrackBall” (displayed as Turn Table,
Mode Track Ball in GUI, respectively)
Turn Table turnTableAxis string Choices : “X”, “Y”, “Z”
Axis
Parent trans- int Object ID
form.parent
Location trans- vec-
form.location tor3
Rotation trans- vec-
form.rotation tor3
Distance gaze scalar
Ortho ortho bool
Field of fieldOfView scalar
View
Near near scalar
Far far scalar

2.4. Node 27
SDK Manual, Release 8.0.0

Output Region

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
Parent transform.parent int Object ID
Location transform.location vector3
Rotation transform.rotation vector3
Center transform.center vector3
Dimensions transform.dimensions vector3
File Output Skip phys.fileOutputSkip bool
Output Skip Interval phys.fileOutputSkipInterval int

28 Chapter 2. Objects
SDK Manual, Release 8.0.0

Domain

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
Parent transform.parent int Object ID
Location transform.location vec-
tor3
Dimensions transform.dimensions vec-
tor3
Type phys.domain.type string Choices : “Default”, “Wind Tunnel”,
“File”
Boundary Condi- phys.xCondition string Choices : “Open”, “Periodic”
tion(X)
Boundary Condi- phys.yCondition string Choices : “Open”, “Periodic”
tion(Y)
Boundary Condi- phys.zCondition string Choices : “Open”, “Periodic”
tion(Z)
Gas Flow Direction phys.wind_tunnel.flow.direction
string Choices : “X+”, “X-”, “Y+”, “Y-”,
“Z+”, “Z-”
Gas Inflow Velocity phys.wind_tunnel.flow.velocityscalar
Wall Velocity phys.wind_tunnel.wall.velocityscalar
Boundary Condition phys.wind_tunnel.boundary.x_histring Choices : “Wall”, “Open”
(X+)
Boundary Condition phys.wind_tunnel.boundary.x_lo
string Choices : “Wall”, “Open”
(X-)
Boundary Condition phys.wind_tunnel.boundary.y_hi
string Choices : “Wall”, “Open”
(Y+)
Boundary Condition phys.wind_tunnel.boundary.y_lo
string Choices : “Wall”, “Open”
(Y-)
Boundary Condition phys.wind_tunnel.boundary.z_hi
string Choices : “Wall”, “Open”
(Z+)
Boundary Condition phys.wind_tunnel.boundary.z_lo
string Choices : “Wall”, “Open”
(Z-)
Model phys.modelId int Object ID
Boundary Condition phys.fvmBoundaryCondition string Choices : “Outflow”, “Pressure Bound-
ary”
Boundary Pressure phys.fvmBoundaryPressure scalar
Initial Velocity phys.fvmInitialVelocity vec-
tor3
Turbulence k phys.fvmTurbulenceK scalar
Turbulence eps phys.fvmTurbulenceEps scalar
Passive Scalar phys.fvmPassiveScalar scalar

2.4. Node 29
SDK Manual, Release 8.0.0

Grid Refinement

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
Parent transform.parent int Object ID
Location transform.location vector3
Rotation transform.rotation vector3
Center transform.center vector3
Dimensions transform.dimensions vector3
Grid Interval phys.gridRefinement.length scalar

Inflow

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
Parent transform.parent int Object ID
Location transform.location vec-
tor3
Rotation transform.rotation vec-
tor3
Center transform.center vec-
tor3
Physical Property phys.physicalProperty int Object ID
Type trans- string Choices : “Rectangle”, “Circle”,
form.emitterType “Donut”, “File”
Inner Ratio trans- scalar
form.innerRadius
Model transform.modelId int Object ID
Width transform.width scalar
Height transform.height scalar
Particle Reduction phys.reductionMode string Choices : “None”, “Percentage”
Percentage phys.reductionPercentagescalar
Random Seed phys.reductionRandomSeedint
Randomization of Particle phys.randomInflow bool
Generation
Random Seed of Particle Gen- phys.randomInflowSeed int
eration
Inherit Temperature phys.inheritTemperature bool

30 Chapter 2. Objects
SDK Manual, Release 8.0.0

Fill

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
Location transform.location vec-
tor3
Physical Property phys.physicalProperty int Object ID
Direction of Parti- trans- string Choices : “xUpper”, “xLower”, “yUpper”,
cle Creation form.directionOfParticleCreation “yLower”, “zUpper”, “zLower”

Flow Record

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
Parent transform.parent int Object ID
Location transform.location vector3
Rotation transform.rotation vector3
Center transform.center vector3
Type transform.emitterType string Choices : “Rectangle”, “Circle”, “Donut”
Inner Ratio transform.innerRadius scalar
Width transform.width scalar
Height transform.height scalar

Flow Replay

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
Parent transform.parent int Object ID
Location transform.location vector3
Rotation transform.rotation vector3
Center transform.center vector3
Physical Property phys.physicalProperty int Object ID

2.4. Node 31
SDK Manual, Release 8.0.0

High-resolution region

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
Parent transform.parent int Object ID
Location transform.location vec-
tor3
Rotation transform.rotation vec-
tor3
Center transform.center vec-
tor3
Dimensions trans- vec-
form.dimensions tor3
Type phys.overlapRegionTypestring Choices : “region”, “file” (displayed as Box Re-
gion, File Region in GUI, respectively)
Model phys.overlapModelId int Object ID
Inside/Outside De- phys.overlapResolution scalar
termination Res.
Offset phys.overlapOffset scalar
Auto Settings of phys.overlapAutoOffset bool
Offset
Auto Settings of phys.overlapAutoSettingbool
Overlap Region
Length of Boundary phys.overlapBoundaryLength
scalar
Region
Length of Gap Re- phys.overlapGapLength scalar
gion
Show Overlapping phys.overlapShowOverlappingRegion
bool
Region

32 Chapter 2. Objects
SDK Manual, Release 8.0.0

FVM Boundary

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
Parent transform.parent int Object ID
Location transform.location vector3
Rotation transform.rotation vector3
Center transform.center vector3
Type transform.emitterType string Choices : “Rectangle”, “Circle”, “File”
Model transform.modelId int Object ID
Width transform.width scalar
Height transform.height scalar
Boundary Type phys.boundaryType string Choices : “Velocity”, “Pressure”
Boundary Velocity phys.boundaryVelocity scalar
Boundary Pressure phys.boundaryPressure scalar
Thickness phys.boundaryThickness scalar
Turbulent Intensity phys.turbulentIntensity scalar
Auto Mixing Length phys.autoMixingLength bool
Mixing Length phys.mixingLength scalar
Auto k and eps phys.autoKEpsilon bool
Turbulence k phys.turbulenceK scalar
Turbulence eps phys.turbulenceEps scalar
Passive Scalar phys.passiveScalar scalar

Residence Time

Name (GUI) Name (SDK) Type Remarks


Name name string
Enabled enabled bool
Region 1 phys.region.0 int Object ID
Region 2 phys.region.1 int Object ID
Region 3 phys.region.2 int Object ID
Region 4 phys.region.3 int Object ID
Region 5 phys.region.4 int Object ID
Region 6 phys.region.5 int Object ID
Region 7 phys.region.6 int Object ID
Region 8 phys.region.7 int Object ID

2.4. Node 33
SDK Manual, Release 8.0.0

Pressure Boundary

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
Parent transform.parent int Object ID
Location transform.location vec-
tor3
Rotation transform.rotation vec-
tor3
Center transform.center vec-
tor3
Physical Prop- phys.physicalProperty int Object ID
erty
Type transform.emitterType string Choices : “Rectangle”, “Circle”,
“Donut”
Inner Ratio transform.innerRadius scalar
Model transform.modelId int Object ID
Width transform.width scalar
Height transform.height scalar
Mode phys.boundaryMode string Choices : “Pressure”, “Tank”
Boundary Pres- phys.boundaryPressure scalar
sure
Area phys.tankArea scalar
Fluid Volume phys.tankVolume scalar
Thickness phys.boundaryThickness scalar
Velocity Limiter phys.pressureBoundaryVelocityLimiter
bool

Gravity

Name (GUI) Name (SDK) Type Remarks


Name name string
Gravity phys.gravityBase vector3
Acceleration phys.gravity vector3

34 Chapter 2. Objects
SDK Manual, Release 8.0.0

Outflow

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
Parent transform.parent int Object ID
Location transform.location vec-
tor3
Rotation transform.rotation vec-
tor3
Center transform.center vec-
tor3
Type transform.emitterType string Choices : “Rectangle”, “Circle”,
“File”
Model transform.modelId int Object ID
Width transform.width scalar
Height transform.height scalar
Thickness phys.outflowThickness scalar
Particle Margin phys.outflowThreshold scalar
Particle-Outflow Interaction phys.outflowInteraction bool
Inflow (Connected Inflows) phys.connectedInflowList array Integer array (Object ID)
Weight (Connected Inflows) phys.connectedInflowWeight array Scalar array
Delay Time (Connected In- phys.connectedInflowDelayTime
array Scalar array
flows)

Polygon

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
Parent transform.parent int Object ID
Location transform.location vector3
Rotation transform.rotation vector3
Center transform.center vector3
Type modelType string Choices : “File”, “Infinite Plane”
Model modelId int Object ID
Physical Property phys.physicalProperty int Object ID

2.4. Node 35
SDK Manual, Release 8.0.0

Group

Name (GUI) Name (SDK) Type Remarks


Name name string
Parent transform.parent int Object ID
Location transform.location vector3
Rotation transform.rotation vector3
Center transform.center vector3
Synchronize Result Motion transform.syncResultMotion bool

Mapping (Solver)

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
Enabled enabled bool
Fields fieldArray array String array
Model modelId int Object ID
Location transform.location vec-
tor3
Rotation transform.rotation vec-
tor3
Center transform.center vec-
tor3
Parent transform.parent int Object ID
Type mapping.type string Choices : “Normal”, “Average”, “Sum”,
“Max”, “Min”
Mapping Side mapping.side string Choices : “Default”, “Front”, “Back”
Calculation mapping.calculation string Choices : “Weighted Average”
Enable CSV Output CSVOutput bool
Remove Duplicate removeDuplicates bool
Vertices
Multiply time ratio to map- bool
CSV ping.multiplyTimeRatio
Effective Radius Ratio EffectiveRadiusRatio scalar
Reset mapping.reset bool
Mapping Side Thresh- map- scalar
old ping.sideThreshold
Resolution Factor map- scalar
ping.dfIntervalRatio
Use polygon wall DF map- bool
ping.reusePolygonDf

36 Chapter 2. Objects
SDK Manual, Release 8.0.0

Probe (Solver)

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
Output Interval executionInter- string Choices : “simulationTime”, “timeStep”
Type val.mode
Output Interval executionInter- int
Frame val.step
Output Interval executionInter- scalar
Time val.time
Fields fieldArray ar- String array
ray
File name fileName string
Create file per re- filePerRegion bool
gion
Prefix outputPrefix string
Output mixing de- flagMixing bool
gree
Prevent double flagDisableDou- bool
counting bleCount
Set Range of Field flagExcludeOutlier bool
Field rangeField string Field name
Component vectorComponent string Choices : “norm”, “x”, “y”, “z”
Component matrixComponent string Choices : “norm”, “xx”, “xy”, “xz”, “yx”, “yy”, “yz”,
“zx”, “zy”, “zz”
Maximum value rangeMax scalar
Minimum value rangeMin scalar

Probe Region

Name (GUI) Name (SDK) Type Remarks


Visible visible bool
Name name string
Location transform.location vector3
Rotation transform.rotation vector3
Center transform.center vector3
Parent transform.parent int Object ID
Solver target solverTarget bool
Mode probe.region.mode string Choices : “Box”, “Sphere”, “File”
Box Size boxSize vector3
Sphere Radius sphereRadius scalar
Model modelId int Object ID
Resolution Factor factorForResolution scalar

2.4. Node 37
SDK Manual, Release 8.0.0

Flow Rate (Solver)

Name Name (SDK) Type Remarks


(GUI)
Name name string
Visible visible bool
Enabled enabled bool
Mode flowRate.mode string Choices : “Rectangle”, “File”, “Surface”, “Solid” (displayed as
Rectangle, File (Plane), File (Surface), File (Solid) in GUI, re-
spectively)
Model modelId int Object ID
Grid Size flowRate.gridSize scalar
Width rectangleWidth scalar
Height rectangle- scalar
Height
Location trans- vec-
form.location tor3
Rotation trans- vec-
form.rotation tor3
Center trans- vec-
form.center tor3
Parent trans- int Object ID
form.parent
Measuring flowRate.margin scalar
Range
Measuring flowRate.distance scalar
Distance
Prevent flagOfKeeping- bool
Double TotalAccumu-
Counting lation

LBM Unstable Region

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
Enabled enabled bool
Parent transform.parent int Object ID

38 Chapter 2. Objects
SDK Manual, Release 8.0.0

2.4.2 Properties (Result)

CHT Cell

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
Model modelId int Object ID

Result View (CHT Cell)

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool

DF

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
Model modelId int Object ID

FVM Grid

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
Show Only Gas material.showOnlyGas bool
Model modelId int Object ID

Result View (FVM Grid)

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
Show Only Gas material.showOnlyGas bool

2.4. Node 39
SDK Manual, Release 8.0.0

LBM Grid

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
Show Gas Cells material.showCellGas bool
Show Solid Wall material.showCellSolid bool
Cell Count statistics.cell_count string
Minimum statistics.min scalar
Maximum statistics.max scalar
Average statistics.average scalar

Result View (LBM Grid)

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
Show Gas Cells material.showCellGas bool
Show Solid Wall material.showCellSolid bool

Particles

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool

Region

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
Model modelId int Object ID

40 Chapter 2. Objects
SDK Manual, Release 8.0.0

2.4.3 Properties (View)

Clipping

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
Parent transform.parent int Object ID
Location transform.location vector3
Dimensions transform.dimensions vector3
Rotation transform.rotation vector3
Center transform.center vector3
Enabled enabled bool

Distance

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
Point 1 measure.distance.point1 vector3
Point 2 measure.distance.point2 vector3

Point

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
Parent transform.parent int Object ID
Location transform.location vector3

Profile

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
Enabled enabled bool
Parent transform.parent int Object ID
Location transform.location vector3
Rotation transform.rotation vector3

2.4. Node 41
SDK Manual, Release 8.0.0

Ruler

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
Parent transform.parent int Object ID
Tick Interval material.tickInterval scalar
Color material.color string Color
Alpha material.alpha scalar
Show Label material.labelVisible bool
Label Size material.labelSize int
Label Format material.labelFormat string
Show Grid material.displayGrid bool
Draw Front material.ignoreDepth bool
Visible x.visible bool
Bounds Min(X) x.boundsMin scalar
Bounds Max(X) x.boundsMax scalar
Bounds Origin(X) x.rangeOrigin scalar
Use Scale Conversion x.useConversion bool
Converted Bounds Min(X) x.rangeMin scalar
Converted Bounds Max(X) x.rangeMax scalar
Visible y.visible bool
Bounds Min(Y) y.boundsMin scalar
Bounds Max(Y) y.boundsMax scalar
Bounds Origin(Y) y.rangeOrigin scalar
Use Scale Conversion y.useConversion bool
Converted Bounds Min(Y) y.rangeMin scalar
Converted Bounds Max(Y) y.rangeMax scalar
Visible z.visible bool
Bounds Min(Z) z.boundsMin scalar
Bounds Max(Z) z.boundsMax scalar
Bounds Origin(Z) z.rangeOrigin scalar
Use Scale Conversion z.useConversion bool
Converted Bounds Min(Z) z.rangeMin scalar
Converted Bounds Max(Z) z.rangeMax scalar

42 Chapter 2. Objects
SDK Manual, Release 8.0.0

Snapshot

Name Name Type Remarks


(GUI) (SDK)
Name name string
Visible visible bool
Rotation rotateMode string Choices : “TurnTable”, “TrackBall” (displayed as Turn Table,
Mode Track Ball in GUI, respectively)
Turn Table turnTableAxis string Choices : “X”, “Y”, “Z”
Axis
Parent trans- int Object ID
form.parent
Location trans- vec-
form.location tor3
Rotation trans- vec-
form.rotation tor3
Distance gaze scalar
Ortho ortho bool
Field of fieldOfView scalar
View
Near near scalar
Far far scalar

2.4.4 Properties (Post)

Filter

Name (GUI) Name (SDK) Type Remarks


Visible visible bool
Name name string
Field field string Field name
Use vector length useNorm bool
Maximum maxScalar scalar
Minimum minScalar scalar
Maximum maxVector3 vector3
Minimum minVector3 vector3
Current Frame frameCurrent bool
Frame Start frameStart int
Frame End frameEnd int
Particle Color particleColor string Color

2.4. Node 43
SDK Manual, Release 8.0.0

Probe Point

Name (GUI) Name (SDK) Type Remarks


Visible visible bool
Name name string
X probe.point.x scalar
Y probe.point.y scalar
Z probe.point.z scalar

2.4.5 Properties (Details)

Inflow

Name (GUI) Name (SDK) Type Remarks


Group ID groupId int
Initial Liquid Vol- phys.demInitialLiquidNonDimensionalVolume
scalar
ume Ratio
Emit Mode phys.emitMode string Choices : “Velocity”, “Volumetric
flow rate”
Emit Velocity phys.emitVelocity scalar
Emit Rate phys.emitRate scalar
Upper Limit phys.upperLimit scalar
Initial Temperature phys.initialTemperature scalar
Initial Scalar phys.initialPassiveScalar scalar
Thickness phys.thickness scalar
Oval Spray Angle phys.randomVelocity.oval bool
Spray Angle phys.randomVelocity scalar
Spray Angle (Width) phys.randomVelocity.x scalar
Spray Angle (Height) phys.randomVelocity.y scalar

Outflow Region

Name (GUI) Name (SDK) Type Remarks


Group ID groupId int
Outflow Volume Rate phys.outflowRegionVolumeRate scalar
Outflow Direction phys.outflowRegionDirection vec-
tor3
Inflow (Connected Inflows) phys.connectedInflowList array Integer array (Object ID)
Weight (Connected Inflows) phys.connectedInflowWeight array Scalar array
Delay Time (Connected In- phys.connectedInflowDelayTime array Scalar array
flows)

44 Chapter 2. Objects
SDK Manual, Release 8.0.0

Fluid

Name (GUI) Name (SDK) Type Remarks


Group ID groupId int
Initial Tempera- phys.initialTemperature scalar
ture
Initial Scalar phys.initialPassiveScalar scalar
Initial Velocity phys.initialVelocity vec-
tor3
Initial Liquid phys.demInitialLiquidNonDimensionalVolume
scalar
Volume Ratio
Particle Interval phys.particleInterval scalar
Particle Origin phys.particleOrigin vec-
tor3
Volume Limit phys.volumeLimit bool
Maximum phys.volume scalar
Volume
Direction phys.directionOfParticleDeletion
string Choices : “xUpper”, “xLower”, “yUpper”,
“yLower”, “zUpper”, “zLower”
Particle Reduc- phys.reductionMode string Choices : “None”, “Percentage”, “Count”
tion
Percentage phys.reductionPercentage scalar
Maximum num- phys.reductionCount int
ber
Random Seed phys.reductionRandomSeed int
Particle Place- phys.particlePlacement string Choices : “Primitive”, “Close packed”, “Sam-
ment pling”

2.4. Node 45
SDK Manual, Release 8.0.0

Fluid (Fill)

Name (GUI) Name (SDK) Type Remarks


Group ID groupId int
Initial Tempera- phys.initialTemperature scalar
ture
Initial Scalar phys.initialPassiveScalar scalar
Initial Velocity phys.initialVelocity vec-
tor3
Initial Liquid phys.demInitialLiquidNonDimensionalVolume
scalar
Volume Ratio
Particle Interval phys.particleInterval scalar
Particle Origin phys.particleOrigin vec-
tor3
Volume Limit phys.volumeLimit bool
Maximum phys.volume scalar
Volume
Direction phys.directionOfParticleDeletion
string Choices : “xUpper”, “xLower”, “yUpper”,
“yLower”, “zUpper”, “zLower”
Particle Reduc- phys.reductionMode string Choices : “None”, “Percentage”, “Count”
tion
Percentage phys.reductionPercentage scalar
Maximum num- phys.reductionCount int
ber
Random Seed phys.reductionRandomSeed int
Particle Place- phys.particlePlacement string Choices : “Primitive”, “Close packed”, “Sam-
ment pling”

Rigid Body

Name (GUI) Name (SDK) Type Remarks


Group ID groupId int
Initial Temperature phys.initialTemperature scalar
Initial Velocity phys.initialVelocity vector3
Center of Rotation phys.centerOfRotation vector3
Initial Angular Velocity phys.initialAngularVelocity vector3

46 Chapter 2. Objects
SDK Manual, Release 8.0.0

Particle Wall

Name (GUI) Name (SDK) Type Remarks


Group ID groupId int
Initial Temperature phys.initialTemperature scalar

Polygon Wall

Name (GUI) Name (SDK) Type Remarks


Group ID groupId int
Initial Temperature phys.initialTemperature scalar
Particle Margin phys.distanceRatioForRemovingParticle
scalar
Double-sided DF phys.doubleSided bool
Thickness of Polygon phys.factorForThickness scalar
Smooth DF phys.DFSmoothing bool
Smoothing repeat(holes) phys.DFSmoothingHoleRepeat int
Smoothing repeat(peaks) phys.DFSmoothingPeakRepeat int
Bubble Generation phys.bubbleGeneration bool
Heat Source (Uniform) phys.heatSourceType string Choices : “None”, “Const”, “Ta-
ble”
Heat Source Unit phys.heatSourceUnit string Choices : “W”, “W/m^3”
Heat Source Power phys.heatSourceConstPower scalar
Heat Source File (Tem- phys.heatSourceTablePower string File Path
poral)
FVM Slip Condition phys.fvmSlipCondition string Choices : “No-slip”, “Free-slip”
Grid Refinement phys.gridRefinement.type string Choices : “None”, “Default”,
“Custom”
Grid Interval phys.gridRefinement.length scalar
Refinement Range phys.gridRefinement.radius scalar
Thickness phys.lbm.factorForThickness scalar
Boundary Condition phys.lbm.wall.type string Choices : “Default”, “No-Slip”,
“Turbulent”
Coefficient of Wall Shear phys.lbm.wall.friction_coefficient scalar
Stress

2.4. Node 47
SDK Manual, Release 8.0.0

Pump

Name (GUI) Name (SDK) Type Remarks


Group ID groupId int
Suction Velocity phys.pumpVelocity scalar
Suction Direction phys.pumpDirection vector3
Adjustment Coefficient phys.pumpCoefficient scalar

Flow Resistance

Name (GUI) Name (SDK) Type Remarks


Group ID groupId int
Coefficient a phys.resistanceCoefficientA scalar
Coefficient b phys.resistanceCoefficientB scalar

Pressure Boundary

Name (GUI) Name (SDK) Type Remarks


Group ID groupId int
Initial Temperature phys.initialTemperature scalar
Initial Scalar phys.initialPassiveScalar scalar
Initial Velocity phys.initialEmitVelocity scalar

2.4.6 Properties (Appearance)

Isosurface (CHT)

Name (GUI) Name (SDK) Type Remarks


Alpha material.alpha scalar
Clip material.clipEnabled bool
Isosurface Threshold material.threshold scalar
Use Color Map material.useColorMap bool
Invert Normals material.invertNormals bool
Shading material.shadedProjection bool

48 Chapter 2. Objects
SDK Manual, Release 8.0.0

Cross Section (Grid, FVM)

Name (GUI) Name (SDK) Type Remarks


Alpha material.alpha scalar
Clip material.clipEnabled bool
Smooth material.smooth bool
Shading material.shadedProjection bool
X Plane material.xVisible bool
X Plane Location material.xPlane scalar
Y Plane material.yVisible bool
Y Plane Location material.yPlane scalar
Z Plane material.zVisible bool
Z Plane Location material.zPlane scalar

Cross Section (LBM)

Name (GUI) Name (SDK) Type Remarks


Clip material.clipEnabled bool
X Plane material.xVisible bool
X Plane Location material.xPlane scalar
Y Plane material.yVisible bool
Y Plane Location material.yPlane scalar
Z Plane material.zVisible bool
Z Plane Location material.zPlane scalar
Smooth material.smooth bool
Show Grid Line material.showGridLine bool
Show Vector Field material.showVector bool
Show Isoline material.showIsoline bool
Clip Objects material.asClippingPlane bool
Capping Color material.cappingColor string Color
Diffuse material.diffuse string Color
Fixed Vector Length material.lengthFixed bool
Vector Length material.vectorLength scalar
Vector Scale material.vectorScale scalar
Triangle Width material.vectorTriangleWidth scalar
Triangle Visible material.triangleVisible bool
Line Width material.lineWidth scalar
Color material.isoline.color string Color
Width material.width scalar
Number of Lines material.numLines int
Auto Range material.isoline.autoRange bool
Min Value material.minValue scalar
Max Value material.maxValue scalar

2.4. Node 49
SDK Manual, Release 8.0.0

Cross Section (DF)

Name (GUI) Name (SDK) Type Remarks


Alpha material.alpha scalar
Clip material.clipEnabled bool
Color(Low) material.colorLow string Color
Color(High) material.colorHigh string Color
Smooth material.smooth bool
X Plane material.xVisible bool
X Plane Location material.xPlane scalar
Y Plane material.yVisible bool
Y Plane Location material.yPlane scalar
Z Plane material.zVisible bool
Z Plane Location material.zPlane scalar

Isosurface (DF)

Name (GUI) Name (SDK) Type Remarks


Alpha material.alpha scalar
Clip material.clipEnabled bool
Isosurface Threshold material.threshold scalar
Invert Normals material.invertNormals bool

Domain

Name (GUI) Name (SDK) Type Remarks


Color material.color string Color

Inflow

Name (GUI) Name (SDK) Type Remarks


Alpha material.alpha scalar
Clip material.clipEnabled bool
Diffuse material.diffuse string Color
Culling material.culling string Choices : “none”, “front”, “back”

50 Chapter 2. Objects
SDK Manual, Release 8.0.0

Flow Rate

Name (GUI) Name (SDK) Type Remarks


Alpha material.alpha scalar
Clip material.clipEnabled bool
Diffuse material.diffuse string Color

Isolines

Name (GUI) Name (SDK) Type Remarks


Alpha material.alpha scalar
Clip material.clipEnabled bool
Number of Lines material.numLines int
Min Value material.minValue scalar
Max Value material.maxValue scalar
Width material.width scalar
X Plane material.xVisible bool
X Plane Location material.xPlane scalar
Y Plane material.yVisible bool
Y Plane Location material.yPlane scalar
Z Plane material.zVisible bool
Z Plane Location material.zPlane scalar

Isosurface (Grid)

Name (GUI) Name (SDK) Type Remarks


Alpha material.alpha scalar
Clip material.clipEnabled bool
Isosurface Threshold material.threshold scalar
Invert Normals material.invertNormals bool

Fill

Name (GUI) Name (SDK) Type Remarks


Alpha material.alpha scalar
Clip material.clipEnabled bool
Diffuse material.diffuse string Color
Culling material.culling string Choices : “none”, “front”, “back”

2.4. Node 51
SDK Manual, Release 8.0.0

Distance

Name (GUI) Name (SDK) Type Remarks


Number of Digits material.digits int
Font material.font string Font
Text Color material.textColor string Color
Background Color material.backgroundColor string Color
Line Color material.lineColor string Color
Show Component material.showComponent bool

Point

Name (GUI) Name (SDK) Type Remarks


Text material.text string
Number of Digits material.digits int
Font material.font string Font
Text Color material.textColor string Color
Background Color material.backgroundColor string Color

Outflow

Name (GUI) Name (SDK) Type Remarks


Alpha material.alpha scalar
Clip material.clipEnabled bool
Diffuse material.diffuse string Color
Culling material.culling string Choices : “none”, “front”, “back”

Edged

Name (GUI) Name (SDK) Type Remarks


Alpha material.alpha scalar
Clip material.clipEnabled bool
Selection Highlight material.selectionVisible bool
Scale material.scale scalar
Use Color Map material.useColorMap bool
Diffuse material.diffuse string Color
Flat Shading material.flatEnabled bool
Thinning Out Rate (Display) material.thinningOutRate scalar
Display Overlapped Particles material.overlapVisible bool

52 Chapter 2. Objects
SDK Manual, Release 8.0.0

Point

Name (GUI) Name (SDK) Type Remarks


Alpha material.alpha scalar
Clip material.clipEnabled bool
Selection Highlight material.selectionVisible bool
Scale material.scale scalar
Use Color Map material.useColorMap bool
Diffuse material.diffuse string Color
Thinning Out Rate (Display) material.thinningOutRate scalar
Display Overlapped Particles material.overlapVisible bool

Vector

Name (GUI) Name (SDK) Type Remarks


Alpha material.alpha scalar
Clip material.clipEnabled bool
Selection Highlight material.selectionVisible bool
Scale material.scale scalar
Use Color Map material.useColorMap bool
Diffuse material.diffuse string Color
Fixed Vector Length material.lengthFixed bool
Vector Length material.vectorLength scalar
Flat Shading material.flatEnabled bool
Vector Scale material.vectorScale scalar
Vector Cone Radius material.vectorConeRadius scalar
Cone Visible material.coneVisible bool
Line Width material.lineWidth scalar
Thinning Out Rate (Display) material.thinningOutRate scalar
Display Overlapped Particles material.overlapVisible bool

Pathline

Name (GUI) Name (SDK) Type Remarks


Line Width material.lineWidth scalar
Alpha material.alpha scalar
Clip material.clipEnabled bool
Display points material.pathlinePoint bool
Use Color Map material.useColorMap bool
Draw Front material.ignoreDepth bool
Animation material.pathlineAnimation bool
Random color material.pathlineRandomColor bool

2.4. Node 53
SDK Manual, Release 8.0.0

Front Back

Name (GUI) Name (SDK) Type Remarks


Alpha material.alpha scalar
Clip material.clipEnabled bool
Front material.frontColor string Color
Back material.backColor string Color
Edge material.edgeVisible bool
Line material.edgeColor string Color

Mapping

Name (GUI) Name (SDK) Type Remarks


Alpha material.alpha scalar
Clip material.clipEnabled bool
Shading material.shadedProjection bool
Show only mapped triangles material.hideUnMapped bool
Multiply time ratio material.reductionTimeRatio bool

Solid

Name (GUI) Name (SDK) Type Remarks


Alpha material.alpha scalar
Clip material.clipEnabled bool
Diffuse material.diffuse string Color
Culling material.culling string Choices : “none”, “front”, “back”
Render as Solid material.closedPolygon bool

Wire

Name (GUI) Name (SDK) Type Remarks


Alpha material.alpha scalar
Clip material.clipEnabled bool
Diffuse material.diffuse string Color

54 Chapter 2. Objects
SDK Manual, Release 8.0.0

Probe Region

Name (GUI) Name (SDK) Type Remarks


Color material.color string Color

Profile

Name (GUI) Name (SDK) Type Remarks


Alpha material.alpha scalar
Clip material.clipEnabled bool
Diffuse material.diffuse string Color
Capping material.profile.capping bool
Use part color for capping material.profile.partColor bool

Streamline

Name (GUI) Name (SDK) Type Remarks


Alpha material.alpha scalar
Clip material.clipEnabled bool
Time Step material.timestep scalar
Length material.length scalar
Width material.width scalar
Omission material.omission int

2.4. Node 55
SDK Manual, Release 8.0.0

Vector (FVM)

Name (GUI) Name (SDK) Type Remarks


Alpha material.alpha scalar
Clip material.clipEnabled bool
Smooth material.smooth bool
X Plane material.xVisible bool
X Plane Location material.xPlane scalar
Y Plane material.yVisible bool
Y Plane Location material.yPlane scalar
Z Plane material.zVisible bool
Z Plane Location material.zPlane scalar
Use Color Map material.useColorMap bool
Diffuse material.diffuse string Color
Fixed Vector Length material.lengthFixed bool
Vector Length material.vectorLength scalar
Vector Scale material.vectorScale scalar
Triangle Width material.vectorTriangleWidth scalar
Triangle Visible material.triangleVisible bool
Line Width material.lineWidth scalar

High-resolution region

Name (GUI) Name (SDK) Type Remarks


Alpha material.alpha scalar
Diffuse material.diffuse string Color

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

Function Corresponding API


Handle PW_WIDGET_t
Get property PW_OBJECT_get_property()
Set property PW_OBJECT_set_property()

2.5.1 Properties

Color bar

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
Width width int
Height height int
Direction direction string Choices : “vertical”, “horizontal”
Anchor anchor string Choices : “free”, “northWest”, “north”, “northEast”, “west”,
“east”, “southWest”, “south”, “southEast”
Position X x int
Position Y y int
Margin X marginX int
Margin Y marginY int
Alpha alpha scalar
Text Color textColor string Color
Text Smooth textSmooth bool
Title Visible titleVisible bool
Title Unit Visi- titleUnitVisi- bool
ble ble
Title Font titleFont string Font
Title Horizontal titleHorizonta- string Choices : “left”, “center”, “right”
Alignment lAlignment
Title Vertical titleVerti- string Choices : “top”, “middle”, “bottom”
Alignment calAlignment
Title Margin titleMargin int
Label Visible labelVisible bool
Label Font labelFont string Font
Label Format labelFormat string
Label Margin labelMargin int
Tick Visible tickVisible bool
Tick Count tickCount int

2.5. Widget 57
SDK Manual, Release 8.0.0

Time

Name Name Type Remarks


(GUI) (SDK)
Name name string
Visible visible bool
Anchor anchor string Choices : “free”, “northWest”, “north”, “northEast”, “west”, “east”,
“southWest”, “south”, “southEast”
Position x int
X
Position y int
Y
Margin marginX int
X
Margin marginY int
Y
Alpha alpha scalar
Font fontColor string Color
Color
Font font string Font
Format format string

58 Chapter 2. Objects
SDK Manual, Release 8.0.0

Plot

Name Name Type Remarks


(GUI) (SDK)
Name name string
Visible visible bool
Anchor anchor string Choices : “free”, “northWest”, “north”, “northEast”, “west”, “east”,
“southWest”, “south”, “southEast”
Position X x int
Position Y y int
Width width int
Height height int
Margin X marginX int
Margin Y marginY int
Title titleText string
Font Color fontColor string Color
Background frame.color string Color
Color
Background frame.alpha scalar
Alpha
Show Win- win- bool
dow dow.visible
Auto Range x.axis.auto bool
(X)
Min. (X) x.axis.min scalar
Max. (X) x.axis.max scalar
Label Count x.axis.divideint
(X)
Label Digits x.axis.digits int
(X)
Auto Range y.axis.auto bool
(Y)
Min. (Y) y.axis.min scalar
Max. (Y) y.axis.max scalar
Label Count y.axis.divide int
(Y)
Label Digits y.axis.digits int
(Y)

2.5. Widget 59
SDK Manual, Release 8.0.0

Axis

Name Name Type Remarks


(GUI) (SDK)
Name name string
Visible visible bool
Anchor anchor string Choices : “free”, “northWest”, “north”, “northEast”, “west”, “east”,
“southWest”, “south”, “southEast”
Position x int
X
Position y int
Y
Margin marginX int
X
Margin marginY int
Y
Alpha alpha scalar
Font fontColor string Color
Color

2.6 Colormap

Colormap is displayed on the colormap panel in the GUI. It is a color map setting for each physical quantity.

You can get and change the settings as properties.

Function Corresponding API


Handle PW_COLORMAP_t
Get property PW_OBJECT_get_property()
Set property PW_OBJECT_set_property()

60 Chapter 2. Objects
SDK Manual, Release 8.0.0

2.6.1 Properties

Name (GUI) Name (SDK) Type Remarks


Name name string
Field field string Field name
Component fieldComponent int
Resolution resolution int
Min rangeMin scalar
Max rangeMax scalar
Clip Enabled clipEnabled bool
Min visibleMin scalar
Max visibleMax scalar
Pattern pattern string

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.

Field Name (GUI) Type Simulation


absolute_velocity_gradient Absolute Velocity Gradient scalar MPS
air_drag_coefficient Air Drag Coefficient scalar MPS, DEM
airflow_neighbor_count_scalar Airflow Neighbor Count scalar MPS, DEM
airflow_velocity Airflow Velocity vector3 MPS, DEM
angular_velocity Angular Velocity vector3 DEM
average_velocity Time-Averaged Velocity vector3 LBM
bulk_density Bulk Density scalar DEM
deformation_tensor Deformation Tensor matrix3x3 MPS
dissipation_rate Turbulent Energy Dissipation Rate scalar FVM
force Force vector3 DEM
fvm_force FVM Force vector3 MPS, DEM
heat_flux Heat Flux scalar MPS
heat_transfer_coefficient Heat Transfer Coefficient scalar MPS
interface_fraction Interface Fraction vector3 MPS
kinematic_viscosity Kinematic Viscosity scalar MPS
kinematic_viscosity_molecular Molecular Kinematic Viscosity scalar MPS
kinematic_viscosity_turbulent Turbulent Kinematic Viscosity scalar MPS
liquid_bridge_force Liquid Bridge Force vector3 DEM
number_density Number Density scalar MPS
number_density_current Number Density (Current) scalar MPS
number_density_previous Number Density (Previous) scalar MPS
passive_scalar Passive Scalar scalar MPS, FVM
pathline_length Pathline Length scalar MPS
position Position vector3
continues on next page

2.6. Colormap 61
SDK Manual, Release 8.0.0

Table 5 – continued from previous page


Field Name (GUI) Type Simulation
pressure Pressure scalar MPS, FVM
radius DEM Radius scalar DEM
relative_position Relative Position vector3
relative_velocity Relative Velocity vector3
residence_time Residence Time scalar MPS, DEM
residence_time.0 Residence Time 1 scalar MPS, DEM
residence_time.1 Residence Time 2 scalar MPS, DEM
residence_time.2 Residence Time 3 scalar MPS, DEM
residence_time.3 Residence Time 4 scalar MPS, DEM
residence_time.4 Residence Time 5 scalar MPS, DEM
residence_time.5 Residence Time 6 scalar MPS, DEM
residence_time.6 Residence Time 7 scalar MPS, DEM
residence_time.7 Residence Time 8 scalar MPS, DEM
rigid_body_cumulative_impulse Rigid Body Cumulative Impulse scalar MPS
rigid_body_impulsive_force Rigid Body Impulsive Force vector3 MPS
stress_tensor Stress Tensor matrix3x3 MPS, DEM
surface_area_for_air_resistance Surface Area scalar MPS, DEM
surface_fraction Surface Fraction scalar MPS
temperature Temperature scalar
torque Torque vector3 DEM
traveled_length_after_contact Traveled Length After Contact scalar MPS
turbulent_energy Turbulent Energy scalar FVM
van_der_waals_force van der Waals Force vector3 DEM
velocity Velocity vector3
velocity_gradient Velocity Gradient matrix3x3 MPS, FVM
viscosity_turbulent Turbulent Viscosity scalar FVM
viscosity_turbulent_wall Wall Turbulent Viscosity scalar FVM
volume_fraction Volume Fraction scalar MPS
von_mises_stress Von Mises Stress scalar DEM
yplus Wall Y+ scalar MPS, FVM, LBM

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

Function Corresponding API


Handle PW_MATERIAL_t
Access property value PW_OBJECT_get_property()
Access interaction setting PW_MATERIAL_get_combination()

2.7.1 Properties

Fluid

Name (GUI) Name (SDK) Type Remarks


Name name string
Density density scalar
Thermal Conductivity thermalConductivity scalar
Specific Heat specificHeat scalar
Kinematic Viscosity kinematicViscosity scalar
Surface Tension Coefficient surfaceTensionCoefficient scalar
Non-Newtonian Fluid Settings nonnewtonian.type string Choices : “None”, “Bingham
Minimum Viscosity nonnewtonian.viscosityMin scalar
Maximum Viscosity nonnewtonian.viscosityMax scalar
Yield nonnewtonian.bingham.yield scalar
Plastic Viscosity nonnewtonian.bingham.plasticViscosity scalar
Yield Point nonnewtonian.bingham.yieldPoint scalar
Plastic Viscosity nonnewtonian.binghamMC.plasticViscosity scalar
Cohesion nonnewtonian.binghamMC.cohesion scalar
Angle of Internal Friction nonnewtonian.binghamMC.frictionAngle scalar
Minimum Shear Velocity nonnewtonian.binghamMC.shearVelocityMin scalar
Minimum Shear Velocity nonnewtonian.powerLaw.shearVelocityMin scalar
C1 nonnewtonian.powerLaw.c1 scalar
C2 nonnewtonian.powerLaw.c2 scalar
C3 nonnewtonian.powerLaw.c3 scalar

2.7. Material 63
SDK Manual, Release 8.0.0

Name (GUI) Name (SDK) Type Remarks


Minimum Shear Velocity nonnewtonian.crossArrhenius.shearVelocityMin scalar
C1 nonnewtonian.crossArrhenius.c1 scalar
C2 nonnewtonian.crossArrhenius.c2 scalar
C3 nonnewtonian.crossArrhenius.c3 scalar
C4 nonnewtonian.crossArrhenius.c4 scalar
Viscosity Data(*.csv) nonnewtonian.table.file string File Path
Scale for Time nonnewtonian.table.columnScale1 scalar
Scale for Temperature nonnewtonian.table.columnScale2 scalar
Sampling Number nonnewtonian.table.sampling int
User Function nonnewtonian.userFunction.text string
Stabilization showCustom.stabilization bool
Compressibility compressibility scalar
Relaxation relaxation scalar

Solid

Name (GUI) Name (SDK) Type Remarks


Name name string
Density density scalar
Thermal Conductiv- thermalConductivity scalar
ity
Specific Heat specificHeat scalar
Thermal Boundary thermalBoundary string Choices : “Adiabatic”, “Isothermal”,
“Calc”
Stabilization showCus- bool
tom.stabilization
Compressibility compressibility scalar
Relaxation relaxation scalar

64 Chapter 2. Objects
SDK Manual, Release 8.0.0

Powder

Name (GUI) Name (SDK) Type Remarks


Name name string
Density density scalar
Specific Heat specificHeat scalar
Thermal Conductivity thermalConductivity scalar
Young’s Modulus youngModulus scalar
Poisson Ratio poissonRatio scalar
Yield Stress yieldStress scalar
Multiple Diameters multipleDiameters bool
Diameter diameter scalar
Diameters diameterTable array Scalar array
Hamaker Constant hamakerConstant scalar
Surface Roughness surfaceRoughness scalar

Polygon

Name (GUI) Name (SDK) Type Remarks


Name name string
Thermal Boundary thermalBoundary string Choices : “Adiabatic”, “Isothermal”,
“Calc”
Density density scalar
Thermal Conductivity thermalConductivity scalar
Specific Heat specificHeat scalar
Ambient Heat Transfer Co- heatTransferCoefficien- scalar
efficient tAmbient
Young’s Modulus youngModulus scalar
Poisson Ratio poissonRatio scalar
Hamaker Constant hamakerConstant scalar
Surface Roughness surfaceRoughness scalar

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).

• The object is represented by the icon in the GUI.

– 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).

Function Corresponding API


Handle PW_PARTICLES_t
Access Arrays PW_PARTICLES_get_arrays()
Access Interaction (p-p) PW_PARTICLES_create_interactions()
Addition and deletion of particles PW_PARTICLES_resize()

2.9 Distance Field

Distance Field represents the distance function from a polygon wall.

• The object is represented by the icon in the GUI.


• The interactions with individual DEM particles are stored in an array. To get this array, use Arrays.

Function Corresponding API


Handle PW_DF_t
Access Arrays PW_DF_get_arrays()
ID PW_DF_get_group_id()
Interaction with particles PW_DF_get_interactions()

2.10 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.

2.10.1 Interaction Pattern

The interactions support the following four patterns.

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

Function Corresponding API


Handle PW_ARRAYS_t
Get array contents PW_ARRAYS_get_array()
List the array names PW_ARRAYS_enumerate_names()

Arrays are named using ASCII strings. The predefined arrays are defined below.

2.11.1 Particles Array

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.

Common to MPS and DEM

Name Type Description


id long Particle ID
position vector3 Particle coordinates
velocity vector3 Particle velocity
group_index int Group ID
material_index int Material ID
residence_time scalar Residence time
residence_time.N scalar Residence time for the region N+1
fvm_force vector3 Force from FVM

68 Chapter 2. Objects
SDK Manual, Release 8.0.0

MPS only

Name Type Description


air- scalar Number of nearby airflow points (air resistance model)
flow_neighbor_count_scalar
airflow_velocity vec- Air velocity (air resistance model)
tor3
boundary_kind int Surface evaluation
pressure_acceleration vec- Acceleration due to the pressure gradient
tor3
internal_energy scalar Internal energy (heat transfer)
kinematic_viscosity scalar Kinematic viscosity coefficient
number_density scalar Particle density number
number_density_current scalar Current particle density number (pressure oscillation re-
moval)
number_density_previous scalar Previous particle density number (pressure oscillation re-
moval)
pressure scalar Pressure
stress_tensor mat3x3 Shear stress tensor
sur- scalar Surface area (air resistance)
face_area_for_air_resistance
temperature scalar Temperature
thermal_conductivity scalar Thermal Conductivity
velocity_gradient mat3x3 Velocity Gradient
velocity_gradient_absolute scalar Absolute Velocity Gradient
velocity_previous vec- Initial velocity for current calculation step
tor3
yplus scalar Y+ (turbulent flow)

DEM only (particle)

Name Type Description


angular_velocity vector3 Angular Velocity vector
force vector3 Force received by the particle
torque vector3 Torque received by the particle
collision_count int Number of collisions

2.11. Arrays 69
SDK Manual, Release 8.0.0

DEM only (interactions)

Name Type Description


displacement vector3 Tangential displacement (contact force model)

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().

2.11.2 Distance Field Array

DEM specific

Name Type Description


displacement vector3 Tangential displacement (contact force model)

70 Chapter 2. Objects
SDK Manual, Release 8.0.0

2.11.3 Particles Array

Same as particles Array.

2.11.4 Node (mapping) Array

Mapping data is expanded for each face of the model file.

In the above case, the vertex indices are as follows

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

Name Type Description


polygon_position vector3 Initial position
polygon_velocity vector3 Rigid body velocity
position vector3 Position
mapping_integration_time scalar Frames or length of simulation time of mapping
mapping_triangle_index int Corresponding vertex index

In addition to these arrays, mapped fields also exist.


If you want to process vertex by vertex, use an array called mapping_vertex_index since the vertices will
be duplicated when expanded. This array holds the first index by which the vertex appears in the expanded
array.

2.11. Arrays 71
SDK Manual, Release 8.0.0

In the example of the above image, this array is as follows

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.

Name Type Description


mapping_vertex_index int Index to the expanded array

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

Solver is an object for analysis processing.

Function Corresponding API


Handle PW_SOLVER_t
Analysis execution PW_SOLVER_step()
Information acquisition PW_SOLVER_get_current_time()

2.12.1 Analysis Algorithm

The analysis process algorithm at each step is as follows:

Module Process Remarks


Common Step Start
Common Motion Update
MPS Heat Transfer
MPS Inflow
MPS Outflow
MPS External Force Beginning of velocity update:
velocity is modified
MPS Flow Resistance/Pump
MPS Air Resistance
MPS Velocity Gradient
MPS Viscosity Coefficient
MPS Turbulent Flow
MPS1 Viscosity Calculation
MPS Surface Tension
MPS Rigid body collision
MPSPage 74, 1 Position Update (using velocity) End of velocity update: position
is updated by the use of current
velocity
MPSPage 74, 1 Rigid body update
MPSPage 74, 1 Particle Wall Update
MPS Particle Shifting
MPS Particle collision Start of pressure update loop
MPS Particle Number Density
MPSPage 74, 1 Pressure
MPS Pressure Smoothing
MPSPage 74, 1 Pressure Gradient
MPSPage 74, 1 Position Update (using pressure
gradient)
MPS2 MPFI (pressure and viscosity)
continues on next page

2.12. Solver 73
SDK Manual, Release 8.0.0

Table 7 – continued from previous page


Module Process Remarks
MPSPage 74, 2 Position Update (using velocity) End of velocity update (MPFI):
position is updated by the use of
current velocity
MPS Rigid body update End of pressure update loop
DEM Inflow
DEM Volume Fraction
DEM Time Integration (Pre) Start of DEM substep
DEM External Force
DEM Outflow
DEM Liquid Bridge Force
DEM van der Waals Force
DEM Contact Force
DEM Rolling Resistance
DEM Particle Number Density
DEM Time Integration (Post)
DEM Heat Transfer End of DEM substep
Common Step End

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.

The following part provides detailed information about each process.

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

Marks the beginning of the analysis algorithm.

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

Array name Remarks


position
velocity
kinematic_viscosity
material_index
group_index
temperature

Output

Array name Remarks


temperature

Description

Heat transfer and shear heat generation calculation is performed.


1. Calculation of internal energy (internal_energy) from temperature
• Sub Kernel configurable (Internal Energy)
2. Calculation of thermal conductivity
3. Heat transfer between particles
4. Heat transfer between polygon wall and particle
5. Calculation of shear heating
6. Conversion of internal energy to temperature

Sub Kernel

Internal Energy

76 Chapter 2. Objects
SDK Manual, Release 8.0.0

Internal Energy

Name

internal_energy

Input

Array name Remarks


material_index
temperature

Output

Array name Remarks


internal_energy

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

All arrays with particle Tag.

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

Array name Remarks


position

Output

Array name Remarks


material_index Sets to “-1” the material_index of an outflowing particle.

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

Array Name Remarks


position
velocity
group_index

Output

Array Name Remarks


velocity

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

Array Name Remarks


position
material_index
group_index

2.12. Solver 79
SDK Manual, Release 8.0.0

Output

Array Name Remarks


velocity

Description

Updates velocity of particles of a Flow Resistance or Pump node.

Air Resistance

Name

calculate_air_resistance

Input

Array Name Remarks


position
velocity
material_index

Output

Array Name Remarks


velocity
airflow_velocity File output (airflow velocity)
air- File output (number of neighboring air flow data points)
flow_neighbor_count

Description

Updates particle velocity by an air resistance.

80 Chapter 2. Objects
SDK Manual, Release 8.0.0

Velocity Gradient

Name

calculate_velocity_gradient

Input

Array Name Remarks


position
velocity
material_index

Output

Array Name Remarks


velocity_gradient File output (velocity gradient)
abso- File output (shear rate)
lute_velocity_gradient

Description

Calculates velocity gradient tensor for turbulence and viscosity calculations.

Viscosity Coefficient

Name

calculate_viscosity_model

Input

Array Name Remarks


material_index
abso- For non-Newtonian fluids only
lute_velocity_gradient
temperature For non-Newtonian fluids only

2.12. Solver 81
SDK Manual, Release 8.0.0

Output

Array Name Remarks


kinematic_viscosity

Description

Calculates kinematic viscosity coefficient used in the viscosity calculation.


1. Sets the kinematic viscosity coefficient set for Material.
2. Adds the kinematic viscosity coefficient according to the constitutive law of a non-Newtonian fluid.
• In Particleworks, the kinematic viscosity coefficient of a non-Newtonian fluid is added to that of
Material.
• Sub Kernel can be set (Kinematic Viscosity Coefficient (p-p)).
3. Constrains the kinematic viscosity coefficient.
4. Calculates the kinematic viscosity coefficient between particles and polygon wall (considering slip
boundary condition).

Sub Kernel

Kinematic Viscosity Coefficient (p-p)

Kinematic Viscosity Coefficient (p-p)

Name

particle_kinematic_viscosity

Input

Array Name Remarks


kinematic_viscosity The kinematic viscosity coefficient set for Material is set.
material_index
group_index

82 Chapter 2. Objects
SDK Manual, Release 8.0.0

Output

Array Name Remarks


kinematic_viscosity

Description

Calculates the kinematic_viscosity of a particle.


When this process is called, kinematic_viscosity is initialized with the kinematic viscosity coefficient set for
Material. In Particleworks, if the fluid is non-Newtonian, the kinematic viscosity coefficient calculated in its
constitutive law is added. If the fluid is Newtonian, this process won’t happen.

Turbulent Flow

Name

calculate_turbulent_smagorinsky_model

Input

Array Name Remarks


velocity
material_index
abso-
lute_velocity_gradient

Output

Array Name Remarks


kinematic_viscosity
yplus File output

2.12. Solver 83
SDK Manual, Release 8.0.0

Description

Updates kinematic viscosity coefficient by using the Smagorinsky turbulence model.

Viscosity Calculation

Name

calculate_viscosity

Input

Array Name Remarks


position
velocity
velocity_previous
kinematic_viscosity
material_index
group_index

Output

Array Name Remarks


velocity

Description

Updates velocity according to the viscosity calculation.

Surface Tension

Name

calculate_surface_tension

84 Chapter 2. Objects
SDK Manual, Release 8.0.0

Input

Array Name Remarks


position
material_index
group_index

Output

Array Name Remarks


velocity

Description

Calculates surface tension and updates velocity.

Position Update (using velocity)

Name

update_position_from_velocity

Input

Array Name Remarks


position
velocity

Output

Array Name Remarks


position

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).

Particle Wall Update

Name

transform_particle_wall

Input

Array Name Remarks


group_index

Output

Array Name Remarks


position
velocity

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

Particle Number Density

Name

calculate_number_density

Input

Array Name Remarks


position

Output

Array Name Remarks


number_density

Description

Calculates Particle Number Density (number_density) to determine the surface particles for the pressure
calculation (Pressure).

Pressure

Name

calculate_pressure

Input

Array Name Remarks


position
velocity
material_index
number_density
num-
ber_density_previous
num-
ber_density_current

2.12. Solver 87
SDK Manual, Release 8.0.0

Output

Array Name Remarks


pressure

Description

Calculates pressure.

Pressure Smoothing

Name

smooth_pressure

Input

Array Name Remarks


position
pressure

Output

Array Name Remarks


pressure

Description

Performs smoothing to remove the high frequency components of pressure.

Pressure Gradient

Name

calculate_pressure_gradient

88 Chapter 2. Objects
SDK Manual, Release 8.0.0

Input

Array Name Remarks


position
pressure
material_index
group_index

Output

Array Name Remarks


pressure_acceleration

Description

Calculates the acceleration on a particle due to the pressure gradient.

Position Update (using pressure gradient)

Name

update_position_and_velocity_from_force

Input

Array Name Remarks


position
velocity
pressure_acceleration

Output

Array Name Remarks


position
velocity

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.

MPFI (pressure and viscosity)

Name

mpfi_solver

Input

Array Name Remarks


position
velocity
velocity_previous
pressure
material_index
number_density
kinematic_viscosity

Output

Array Name Remarks


velocity
pressure

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

All arrays with particle Tag.

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

Array Name Remarks


group_index MPS
position MPS
material_index DEM
radius DEM
position DEM

2.12. Solver 91
SDK Manual, Release 8.0.0

Output

Array Name Remarks


volume_fraction MPS

Description

Calculates volume fraction of fluid particles (MPS) .

Time Integration (Pre)

Name

dem_time_integration_pre

Input

Array Name Remarks


position
velocity
angular_velocity
material_index

Output

Array Name Remarks


position
velocity
angular_velocity

Description

Updates the first part of the Velocity Verlet algorithm.

92 Chapter 2. Objects
SDK Manual, Release 8.0.0

External Force

Name

dem_update_with_gravity

Input

Array Name Remarks


position
radius
material_index
force

Output

Array Name Remarks


force

Description

Applies external forces to particles.

Outflow

Name

dem_detect_ghost

Input

Array Name Remarks


position

2.12. Solver 93
SDK Manual, Release 8.0.0

Output

Array Name Remarks


material_index Sets the material_index of outflowing particle to -1.

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.

Liquid Bridge Force

Name

dem_calculate_liquid_bridge_surface_tension

Input

Array Name Remarks


position
radius
material_index
force

Output

Array Name Remarks


force

Description

Applies force due to a liquid bridge to particles.

94 Chapter 2. Objects
SDK Manual, Release 8.0.0

van der Waals Force

Name

calculate_van_der_Waals

Input

Array Name Remarks


position
radius
material_index
force

Output

Array Name Remarks


force

Description

Applies van der Waals force to particles.

Contact Force

Name

dem_calculate_contact_model

2.12. Solver 95
SDK Manual, Release 8.0.0

Input

Array Name Remarks


position
radius
velocity
angular_velocity
material_index
force
torque
displacement interaction
distance interaction
max_overlap p-p interaction (WB, Thornton only)
max_contact_force interaction (WB, Thornton only)
normal_force interaction (rolling resistance only)
interaction_flag interaction

Output

Array Name Remarks


force
torque
displacement interaction
distance interaction
max_overlap p-p interaction (WB, Thornton only)
max_contact_force interaction (WB, Thornton only)
normal_force interaction (rolling resistance only)
interaction_flag interaction

Description

Adds a contact force to force and torque applied on particles.

Rolling Resistance

Name

dem_calculate_rolling_resistance

96 Chapter 2. Objects
SDK Manual, Release 8.0.0

Input

Array Name Remarks


position
radius
angular_velocity
material_index
torque_rr interaction
normal_force interaction
interaction_flag interaction

Output

Array Name Remarks


torque_rr interaction
interaction_flag interaction

Description

Calculates torque due to a rolling resistance.

Particle Number Density

Name

dem_calculate_number_density_boundary_detection

Input

Array Name Remarks


position

2.12. Solver 97
SDK Manual, Release 8.0.0

Output

Array Name Remarks


num-
ber_density_for_boundary_detection

Description

Calculates Particle Number Density (number_density_for_boundary_detection) to determine the surface par-


ticles.

Time Integration (Post)

Name

dem_time_integration_post

Input

Array Name Remarks


position
radius
velocity
angular_velocity
force
torque
material_index
displacement interaction
distance interaction
torque_rr interaction (rolling resistance only)

Output

Array Name Remarks


position
velocity
angular_velocity
displacement interaction
distance interaction

98 Chapter 2. Objects
SDK Manual, Release 8.0.0

Description

Updates position and speed from force and torque on particles.

Heat Transfer

Name

dem_calculate_heat_transfer

Input

Array Name Remarks


position
radius
temperature
temperature_previous

Output

Array Name Remarks


temperature

Description

Temperature is updated by heat transfer.

Step End

Name

update_end

2.12. Solver 99
SDK Manual, Release 8.0.0

Timing

Marks the end of the analysis algorithm.

2.13 User Function

User Function is an object for callback functions set by users.

Function Corresponding API


Handle PW_USER_FUNCTION_t
Definition PW_USER_FUNCTION_description_t

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.

Process Name (API) Available Interaction Pattern


Step Start update_start
Step End update_end

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.

100 Chapter 2. Objects


SDK Manual, Release 8.0.0

Common to MPS and DEM

Process Name (API) Available Interaction Pattern


Motion Update update_matrix

MPS only

Process Name (API) Available Interaction


Pattern
Inflow update_inflow
Outflow detect_ghost
Heat Transfer calculate_heat_transfer MPS-MPS
External Force update_with_gravity MPS-MPS
Flow Resistance/Pump calculate_flow_accelerator MPS-MPS
Air Resistance calculate_air_resistance MPS-MPS
Velocity Gradient calculate_velocity_gradient MPS-MPS
Viscosity Coefficient calculate_viscosity_model MPS-MPS
Turbulent Flow calcu- MPS-MPS
late_turbulent_smagorinsky_model
Viscosity Calculation calculate_viscosity MPS-MPS
Surface Tension calculate_surface_tension MPS-MPS
Position Update (using velocity) update_position_from_velocity MPS-MPS
Particle Wall Update transform_particle_wall
Particle Number Density calculate_number_density MPS-MPS
Pressure calculate_pressure MPS-MPS
Pressure Smoothing smooth_pressure MPS-MPS
Pressure Gradient calculate_pressure_gradient MPS-MPS
Position Update (using pressure update_position_and_velocity_from_force
MPS-MPS
gradient)
MPFI (pressure and viscosity) mpfi_solver MPS-MPS

2.13. User Function 101


SDK Manual, Release 8.0.0

DEM only

Process Name (API) Available Interaction Pattern


Inflow dem_update_inflow
Volume Fraction dem_calculate_volume_fraction MPS-DEM,DEM-MPS
Time Integration dem_time_integration_pre MPS-DEM,DEM-MPS
(Pre)
External Force dem_update_with_gravity MPS-DEM,DEM-MPS
Outflow dem_detect_ghost MPS-DEM,DEM-MPS
Liquid Bridge Force dem_calculate_liquid_bridge_surface_tension DEM-DEM
van der Waals Force dem_calculate_van_der_Waals DEM-DEM
Contact Force dem_calculate_contact_model DEM-DEM
Rolling Resistance dem_calculate_rolling_resistance DEM-DEM
Particle Number dem_calculate_number_density_boundary_detection
DEM-DEM,MPS-DEM,DEM-
Density MPS
Time Integration dem_time_integration_post DEM-DEM,MPS-DEM,DEM-
(Post) MPS
Heat Transfer dem_calculate_heat_transfer DEM-DEM,MPS-DEM,DEM-
MPS

2.13.3 Sub Kernel

The callback is called by Kernel’s internal processing. The calling methods are the same: replace, pre and,
post.

MPS only

Kernel Sub Kernel Name (API)


Heat Transfer Internal Energy internal_energy
Viscosity Coefficient Kinematic Viscosity Coefficient (p-p) particle_kinematic_viscosity

2.14 Model

In the GUI, Model corresponds to the individual elements of the scene in the Models folder, in the Projects
window.

Model provides the path and data of an .stl or .obj.

102 Chapter 2. Objects


SDK Manual, Release 8.0.0

Function Corresponding API


Handle PW_MODEL_t
ID PW_MODEL_get_id()
Path PW_MODEL_get_path()
Geometry data PW_MODEL_get_triangles()

2.15 Filter

Filter is a function that discriminates particles according to a given condition. It is generated from Node.

Node type Discriminating condition


Flow resistance, pump, or outflow region Is the particle inside the region?

Function Corresponding API


Handle PW_FILTER_t
Discrimination PW_FILTER_apply()

2.16 Task Queue

Task Queue manages Task such as preprocessing, analysis execution, postprocessing. Task Queue corre-
sponds to the Tasks in the GUI.

Function Corresponding API


Handle PW_TASK_QUEUE_t
Add Task PW_TASK_QUEUE_run_task()
Cancel Task PW_TASK_QUEUE_cancel_task()

2.17 Task

Task shows the task such as preprocessing, analysis execution, postprocessing. Task is managed by Task
Queue.

Function Corresponding API


Handle PW_TASK_t
Get state PW_TASK_get_state()

2.15. Filter 103


SDK Manual, Release 8.0.0

2.18 Capture

Note: In Linux, Capture is unavailable.

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.

Function Corresponding API


Handle PW_CAPTURE_t
Prepare video output PW_VIDEO_create()

2.18.1 Properties

Screenshot

Name (GUI) Name (SDK) Type Remarks


Width image.width int
Height image.height int
Spacing Width image.spacing int
Spacing Color image.background string Color
Output Folder image.folder string File Path

104 Chapter 2. Objects


SDK Manual, Release 8.0.0

Video

Name (GUI) Name (SDK) Type Remarks


Frame Start frameStart int
Frame End frameEnd int
Frame Step frameStep int
Width image.width int
Height image.height int
Spacing Width image.spacing int
Spacing Color image.background string Color
Format video.format string Choices : “PNG”, “JPEG”, “MP4”, “GIF”, “WMV”
WMV Version video.wmv.version string Choices : “WMV1”, “WMV2”, “WMV3”
Output Folder image.folder string File Path
Image Prefix image.prefix string
Video File video.file string
Keep Images image.keep bool
FPS video.fps int
Quality (CRF) video.mp4.crf int
Bitrate video.bitrate.flag bool
Bitrate video.bitrate.value int

2.19 Parameters

“Parameters” is setting information of Task and corresponds to the settings such as postprocessing settings
in the GUI.

2.19. Parameters 105


SDK Manual, Release 8.0.0

Function Corresponding API


Handle PW_OBJECT_t
Set parameters PW_OBJECT_set_property()

2.19.1 Properties

Import Airflow

Name (GUI) Name (SDK) Type Remarks


filePath string File Path

Import CHT B.C.

Name Name Type Remarks


(GUI) (SDK)
filePath string File Path
chtBcType string Choices : “None”, “Heat Source”, “Mapping (CSV)”, “Mapping
(Profbin)”
chtBcId int

Preprocess exec.

Name (GUI) Name (SDK) Type Remarks


CPU cpu int
Additional options additional string
Generate DF generateDF bool
Hide generated DF entries hideDF bool
Hide converted fill entries hideFill bool
Hide converted polygon entries hidePolygon bool
Show color bar showColorbar bool

106 Chapter 2. Objects


SDK Manual, Release 8.0.0

Simulation exec.

Name (GUI) Name (SDK) Type Remarks


CPU cpu int
GPU gpu array Integer array
Additional options additional string
Precision precision string Choices : “double”, “single”
Resume resumeFlag bool
Frame to resume resumeFrame int

Flow Rate

Name Name (SDK) Type Remarks


(GUI)
Name name string
Visible visible bool
All Frames frameAll bool
Frame Start frameStart int
Frame End frameEnd int
CPU cores cpuCount int
Mode flowRate.mode string Choices : “Rectangle”, “File”, “Surface”, “Solid” (displayed as
Rectangle, File (Plane), File (Surface), File (Solid) in GUI, re-
spectively)
Model modelId int Object ID
Grid Size flowRate.gridSize scalar
Width rectangleWidth scalar
Height rectangle- scalar
Height
Animation animationRef int Object ID
Reference
All Groups targetAll bool
Groups target ar- Integer array
ray
Measuring flowRate.margin scalar
Range
Measuring flowRate.distance scalar
Distance
Prevent flagOfKeeping- bool
Double TotalAccumu-
Counting lation
Open when openInSystem bool
done

2.19. Parameters 107


SDK Manual, Release 8.0.0

Grid

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
All Frames frameAll bool
Frame Start frameStart int
Frame End frameEnd int
All Groups targetAll bool
Groups target array Integer array
Fields fieldArray array String array
CPU cores cpuCount int
Effective Radius Ratio EffectiveRadiusRatio scalar
Weight weight scalar
Auto autoResolution bool
Grid Resolution resolution vector3
Clip Enabled clipEnabled bool
Clip Minimum clipMinimum vector3
Clip Maximum clipMaximum vector3
Enable CSV Output CSVOutput bool

108 Chapter 2. Objects


SDK Manual, Release 8.0.0

Mapping

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
All Frames frameAll bool
Frame Start frameStart int
Frame End frameEnd int
CPU cores cpuCount int
Fields fieldArray ar- String array
ray
Model modelId int Object ID
Animation Reference animationRef int Object ID
All Groups targetAll bool
Groups target ar- Integer array
ray
Type mapping.type string Choices : “Normal”, “Average”, “Sum”,
“Max”, “Min”
Mapping Side mapping.side string Choices : “Default”, “Front”, “Back”
Calculation mapping.calculation string Choices : “Compatible”, “Weighted Aver-
age”
Enable CSV Output CSVOutput bool
Remove Duplicate removeDuplicates bool
Vertices
Multiply time ratio to map- bool
CSV ping.multiplyTimeRatio
Effective Radius Ra- EffectiveRadiusRatio scalar
tio
Reset mapping.reset bool
Interval mapping.interval int
Output at Intervals map- bool
ping.OutputOnlyResetFrame
Include Start Frame mapping.IncludeFrame0 bool
Mapping Side mapping.sideThreshold scalar
Threshold
Resolution Factor mapping.dfIntervalRatio scalar

2.19. Parameters 109


SDK Manual, Release 8.0.0

Pathline

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
All Frames frameAll bool
Frame Start frameStart int
Frame End frameEnd int
Frame Step frameStep int

110 Chapter 2. Objects


SDK Manual, Release 8.0.0

Probe

Name (GUI) Name (SDK) Type Remarks


Name name string
Visible visible bool
All Frames frameAll bool
Frame Start frameStart int
Frame End frameEnd int
All Groups targetAll bool
Groups target ar- Integer array
ray
CPU cores cpuCount int
Open when done openInSystem bool
Fields fieldArray ar- String array
ray
File name fileName string
Mode probe.mode string Choices : “Point”, “Region”
Search Range probe.range scalar
Interpolation Degree coefficient int
Output region name outputRegion- bool
Name
Create file per region filePerRegion bool
Prefix outputPrefix string
Include results for all flagAllParticles bool
particles
Output mixing degree flagMixing bool
Prevent double count- flagDisableDou- bool
ing bleCount
Set Range of Field flagExcludeOut- bool
lier
Field rangeField string Field name
Component vectorComponent string Choices : “norm”, “x”, “y”, “z”
Component matrixCompo- string Choices : “norm”, “xx”, “xy”, “xz”, “yx”, “yy”,
nent “yz”, “zx”, “zy”, “zz”
Maximum value rangeMax scalar
Minimum value rangeMin scalar

2.19. Parameters 111


SDK Manual, Release 8.0.0

Profbin to Ascii

Name (GUI) Name (SDK) Type Remarks


Directory directory string File Path
All Frames frameAll bool
Frame Start frameStart int
Frame End frameEnd int
Digits digitNum int
Open when done openInSystem bool

112 Chapter 2. Objects


SDK Manual, Release 8.0.0

Surface

Name Name Type Remarks


(GUI) (SDK)
Name name string
Visible visible bool
All frameAll bool
Frames
Frame frameS- int
Start tart
Frame frameEnd int
End
All targetAll bool
Groups
Groups target ar- Integer array
ray
CPU cpuCount int
cores
Format format string Choices : “STL_Binary”, “STL”, “OBJ” (displayed as STL (Binary),
STL, OBJ in GUI, respectively)
Type type string Choices : “All”, “Overlap”, “Remove overlap” (displayed as All, Remove
overlapped surface, Remove un-overlapped surface in GUI, respec-
tively)
Output sur- bool
Surface faceAreaEn-
Area abled
Fineness fineness scalar
Sharp- sharp scalar
ness
Smooth- smooth scalar
ing
Particle parti- scalar
Scale cleScale
Clip clipEn- bool
Enabled abled
Clip Min- clipMini- vec-
imum mum tor3
Clip clipMax- vec-
Maxi- imum tor3
mum

Note: See Field for strings to set in field properties of Grid, Mapping, Probe, etc.

2.19. Parameters 113


SDK Manual, Release 8.0.0

2.20 Settings

Settings corresponds to the settings window displayed by Tools > 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.

114 Chapter 2. Objects


SDK Manual, Release 8.0.0

2.20.1 Properties

Name (GUI) Name (SDK) Type Remarks


Module Directory moduleDirectory string File Path
Use default module moduleDefault bool
directory
Language general.language string Choices : “language.default”, “language.en”, “lan-
guage.ja” (displayed as System default, English,
Japanese in GUI, respectively)
Digits general.digits int
Automatic adjust- gen- bool
ment of geometry eral.memory_limit.auto
memory
Maximum size of gen- int
geometry memory eral.memory_limit.size
Show emitter DF in gen- bool
Interaction Table eral.enableEmitterDF
Maximum particle gen- int
count in Pathline eral.pathline.graph.max
Plots
Python scripting gen- string Choices : “Disable”, “Default”, “User”
eral.python.mode
Python path gen- string File Path
eral.python.path
Sampling of ani- anima- bool
mations in Prepro- tion.copyInPreprocess
cess
Read motions writ- anima- bool
ten by Solver tion.readSolverOutput
Use motions writ- anima- bool
ten by Solver in tion.useSolverOutputInPostprocess
Postprocess
Mouse-over high- view.enableHighlightbool
light
Mouse mode view.mouseMode string Choices : “Particleworks”, “CATIA V5”, “Creo
(Pro/E)”, “Acrobat”

2.20. Settings 115


SDK Manual, Release 8.0.0

2.21 Result File

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.

Function Corresponding API


Handle PW_RESULT_FILE_t
Gets Result File PW_SCENE_lock_result_file()
Gets Arrays PW_RESULT_FILE_get_arrays()
File output PW_RESULT_FILE_write()

116 Chapter 2. Objects


CHAPTER

THREE

API REFERENCE

3.1 Session

3.1.1 Data Structure

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

PW_ERROR_code_t PW_SESSION_start(const char *app, int argc, char **argv, PW_SESSION_t


*session, PW_CSTRING_array_t *unrecognized_args)

118 Chapter 3. API Reference


SDK Manual, Release 8.0.0

Description

Multi-byte character version of PW_SESSION_start_w(). Specify argv as a multi-byte character string.


Multi-byte characters are interpreted according to the code page set by PW_STRING_set_codepage().

PW_SESSION_start_w

PW_ERROR_code_t PW_SESSION_start_w(const char *app, int argc, wchar_t **argv, PW_SESSION_t


*session, PW_CSTRING_array_t *unrecognized_args)

Arguments

Argu- I/O Description


ment
app In- The name of the application. This name is reflected in the log filename.
put
argc, In- Solver startup options
argv put
session Out- Generated Session’s handle
put
un- Out- Arguments that are specified by argv, which were not recognized, are returned. After
recog- put use, it is necessary to free memory by PW_CSTRING_array_free(). NULL specifica-
nized_args tion is possible.

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

PW_ERROR_code_t PW_SESSION_end(PW_SESSION_t session)

Arguments

Argument I/O Description


session Input Session’s handle

3.1. Session 119


SDK Manual, Release 8.0.0

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

PW_ERROR_code_t PW_SESSION_get_solver(PW_SESSION_t session, PW_SOLVER_t *solver)

Arguments

Argument I/O Description


session Input Session's handle
solver Output Solver's handle

Description

Gets Solver's handle, PW_SOLVER_t.

PW_SESSION_get_particles

PW_ERROR_code_t PW_SESSION_get_particles(PW_SESSION_t session, PW_PARTICLES_type_t


type, PW_PARTICLES_t *particles)

Arguments

Argu- I/O Description


ment
session Input Session's handle
type Input Whether to acquire PW_PARTICLES_mps_c or PW_PARTICLES_dem_c must be
specified.
particles Out- Particles’s handle
put

120 Chapter 3. API Reference


SDK Manual, Release 8.0.0

Description

Gets Particles's handle, PW_PARTICLES_t.

PW_SESSION_get_scene

PW_ERROR_code_t PW_SESSION_get_scene(PW_SESSION_t session, PW_SCENE_t *scene)

Arguments

Argument I/O Description


session Input Session's handle
scene Output Scene's handle

Description

Gets Scene's handle, PW_SCENE_t.

PW_SESSION_get_task_queue

PW_ERROR_code_t PW_SESSION_get_task_queue(PW_SESSION_t session, PW_TASK_QUEUE_t


*q)

Arguments

Argument I/O Description


session Input Session’s handle
q Output Task Queue’s handle

Description

Gets Task Queue’s handle PW_TASK_QUEUE_t.

3.1. Session 121


SDK Manual, Release 8.0.0

PW_SESSION_get_settings

PW_ERROR_code_t PW_SESSION_get_settings(PW_SESSION_t session, PW_SETTINGS_t


*settings)

Arguments

Argument I/O Description


session Input Session’s handle
settings Output Settings’s handle

Description

Gets Settings’s handle PW_SETTINGS_t.

PW_SESSION_enumerate_objects

PW_ERROR_code_t PW_SESSION_enumerate_objects(PW_SESSION_t session, PW_OBJECT_type_t


type, PW_OBJECT_array_t *objects)

Arguments

Argu- I/O Description


ment
session In- Session's handle
put
type In- Type of objects you want to obtain
put
objects Out- Array of the handles of the objects specified by type. After use, it is necessary to free
put memory with PW_OBJECT_array_free().

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

122 Chapter 3. API Reference


SDK Manual, Release 8.0.0

– 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

PW_ERROR_code_t PW_SESSION_enumerate_combinations(PW_SESSION_t session,


PW_CSTRING_array_t *names)

Arguments

Argu- I/O Description


ment
session In- Session's handle
put
names Out- Array of names of the interaction settings. After use, it is necessary to free memory
put with PW_CSTRING_array_free().

3.1. Session 123


SDK Manual, Release 8.0.0

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:

Interaction setting Kind Name in SDK


Static Friction staticFriction
Kinetic Friction kineticFriction
Kinematic Viscosity MPS viscosity
Slip Condition MPS slipCondition
Contact Angle MPS contactAngle
Coefficient of Potential MPS surfaceTension
Control Parameter fλ MPS thermalConductivity
Heat Transfer Coefficient MPS heatTransferCoefficient
Thermal Contact Resistance MPS thermalContactResistance
Surface Determination Coeffi- MPS Dynamic Con- dynamicContactAngle.boundaryCoefficient
cient tact Angle
Inner/Outer Determination Co- MPS Dynamic Con- dynamicContactAngle.innerCoefficient
efficient tact Angle
Contact Determination Coeffi- MPS Dynamic Con- dynamicContactAngle.wallCoefficient
cient tact Angle
Coefficient of Dynamic Contact MPS Dynamic Con- dynamicContactAngle.a1
Angle Model a1 tact Angle
Coefficient of Dynamic Contact MPS Dynamic Con- dynamicContactAngle.a2
Angle Model a2 tact Angle
Coefficient of Dynamic Contact MPS Dynamic Con- dynamicContactAngle.a3
Angle Model a3 tact Angle
Coefficient of Restitution DEM Contact dem.restitutionCoefficient
Spring Constant DEM Contact dem.springCoefficient
Spring Constant for WB Model DEM Contact dem.springConstantWBLoad
(Loading)
Spring Constant for WB Model DEM Contact dem.springConstantWBUnload
(Unloading)
Unloading Parameter for WB DEM Contact dem.nonLinearParameterWB
Model
Shape Parameter DEM Rolling Resis- dem.rollingResistance.bond.shapeParameter
tance
Contact Angle (Liquid Bridge) DEM Intermolecular dem.liquidBridge.contactAngle
Coefficient of Surface Tension DEM Intermolecular dem.liquidBridge.surfaceTension
(Liquid Bridge)
Dimensionless Volume (Liquid DEM Intermolecular dem.liquidBridge.dimensionlessBridgeVolume
Bridge)
Adjustment Coefficient (van der DEM Intermolecular dem.vanderWaals.coefficient
Waals Force)

To obtain the interaction setting value, use the name returned here as an argument of

124 Chapter 3. API Reference


SDK Manual, Release 8.0.0

PW_MATERIAL_get_combination().

PW_SESSION_add_user_function

PW_ERROR_code_t PW_SESSION_add_user_function(PW_SESSION_t session,


PW_USER_FUNCTION_description_t
description, PW_USER_FUNCTION_t
*user_func)

Arguments

Argu- I/O Description


ment
session Input Session's handle
descrip- Input Information about user functions. Refer to PW_USER_FUNCTION_description_t
tion for details.
user_func Out- User Function's handle
put

Description

Registers User Function.

PW_SESSION_delete_user_function

PW_ERROR_code_t PW_SESSION_delete_user_function(PW_SESSION_t session,


PW_USER_FUNCTION_t user_func)

Arguments

Argument I/O Description


session Input Session's handle
user_func Input User Function's handle

3.1. Session 125


SDK Manual, Release 8.0.0

Description

Deregisters User Function. The handle returned by PW_SESSION_add_user_function() is given to


user_func.

PW_SESSION_read_particles

PW_ERROR_code_t PW_SESSION_read_particles(PW_SESSION_t session, const wchar_t *path)

Arguments

Argument I/O Description


session Input Session's handle
path Input .profbin path

Description

Reads a .profbin file.


• The PW_ARRAY_description_t acquired with PW_ARRAYS_get_array() before calling this func-
tion becomes invalid.
• 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_write_particles

PW_ERROR_code_t PW_SESSION_write_particles(PW_SESSION_t session, PW_CSTRING_array_t


output, const wchar_t *path)

Arguments

Argument I/O Description


session Input Session's handle
output Input Name of the array to output to the .profbin file
path Input .profbin path

126 Chapter 3. API Reference


SDK Manual, Release 8.0.0

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

PW_ERROR_code_t PW_SESSION_update_motion(PW_SESSION_t session, double time)

Arguments

Argument I/O Description


session Input Session's handle
time Input Time to evaluate the motion.

Description

Updates the coordinate system of all Node. If no animation is set to any Node, nothing is done.

PW_SESSION_update_interaction

PW_ERROR_code_t PW_SESSION_update_interaction(PW_SESSION_t session,


PW_PARTICLES_type_t type, double
max_distance)

Arguments

Argument I/O Description


session Input Session's handle
type Input Type of the Particles to be updated (PW_PARTICLES_type_t)
max_distance Input Maximum distance between particles

3.1. Session 127


SDK Manual, Release 8.0.0

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

PW_ERROR_code_t PW_SESSION_update_cosim_interaction(PW_SESSION_t session,


PW_PARTICLES_type_t type0,
PW_PARTICLES_type_t type1,
double max_distance)

Arguments

Argument I/O Description


session Input Session's handle
type0 Input Type of the Particles to be updated (PW_PARTICLES_type_t)
type1 Input Type of the Particles to be updated (PW_PARTICLES_type_t)
max_distance Input Maximum distance between particles

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.

128 Chapter 3. API Reference


SDK Manual, Release 8.0.0

PW_SESSION_read_model_file

PW_ERROR_code_t PW_SESSION_read_model_file(PW_SESSION_t session, PW_MESH_format_t


format, const wchar_t *path, PW_MODEL_t
*model)

Arguments

Argument I/O Description


session Input Session's handle
format Input File type (PW_MESH_format_t)
path Input File path
model Output Handle of Model read

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

PW_ERROR_code_t PW_SESSION_open_project(PW_SESSION_t session, const wchar_t *path,


PW_BOOL_t create, PW_PROJECT_t *project)

Arguments

Argument I/O Description


session Input Session's handle
path Input Folder of project you want to open
create Input Whether to create a project if it exists
project Output Project's handle

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.

3.1. Session 129


SDK Manual, Release 8.0.0

PW_SESSION_close_project

PW_ERROR_code_t PW_SESSION_close_project(PW_SESSION_t session, PW_PROJECT_t project)

Arguments

Argument I/O Description


session Input Session's handle
project Input Project's handle

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

PW_ERROR_code_t PW_SESSION_wait(PW_SESSION_t session, int millis)

Arguments

Argument I/O Description


session Input Session's handle
millis Input Wait time (in milliseconds)

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.

130 Chapter 3. API Reference


SDK Manual, Release 8.0.0

3.2 Project

3.2.1 Data Structure

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

PW_ERROR_code_t PW_PROJECT_enumerate_objects(PW_PROJECT_t project,


PW_OBJECT_type_t type,
PW_OBJECT_array_t *objects)

Arguments

Argu- I/O Description


ment
project In- Project's handle.
put
type In- Object type you want to get
put
objects Out- Table of the handle of the object specified by type. After use, you need to free the
put memory with PW_OBJECT_array_free().

3.2. Project 131


SDK Manual, Release 8.0.0

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

PW_ERROR_code_t PW_PROJECT_get_path(PW_PROJECT_t project, PW_STRING_t *path)

Arguments

Argument I/O Description


project Input Project's handle.
path Output Path string. After use, you need to free the memory with PW_STRING_free().

Description

Gets the folder path of project.

PW_PROJECT_create_scene

PW_ERROR_code_t PW_PROJECT_create_scene(PW_PROJECT_t project, const wchar_t *name,


PW_SCENE_t *scene)

Arguments

Argument I/O Description


project Input Project's handle.
name Input New Scene name
scene Output Handle of generated Scene

132 Chapter 3. API Reference


SDK Manual, Release 8.0.0

Description

Creates new Scene under project.

PW_PROJECT_duplicate_scene

PW_ERROR_code_t PW_PROJECT_duplicate_scene(PW_PROJECT_t project, PW_SCENE_t scene,


const PW_PROJECT_duplicate_scene_t
*params, PW_SCENE_t *new_scene)

Arguments

Argument I/O Description


project Input Project's handle.
scene Input Handle of the duplicated Scene.
params Input Parameters
new_scene Output Handle of the generated Scene

Description

Duplicates scene under project.


type PW_PROJECT_duplicate_scene_t
Scene duplication parameters.

Member Type Description


name const wchar_t * New Scene name. Automatically set if NULL is specified.
preprocess PW_BOOL_t True if the preprocess result is to be copied.
simulation PW_BOOL_t True if the simulation result is to be copied.
other PW_BOOL_t True if other files (e.g. postprocess results) are to be copied.
result_start int Start of the target frames if simulation results are to be copied.
result_end int End of the the target frames if simulation results are to be copied.

PW_PROJECT_remove_scene

PW_ERROR_code_t PW_PROJECT_remove_scene(PW_PROJECT_t project, PW_SCENE_t scene)

3.2. Project 133


SDK Manual, Release 8.0.0

Arguments

Argument I/O Description


project Input Project's handle
scene Input Scene's handle

Description

Removes scene .

PW_PROJECT_read_model_file

PW_ERROR_code_t PW_PROJECT_read_model_file(PW_PROJECT_t project, PW_MESH_format_t


format, const wchar_t *path, PW_MODEL_t
*model)

Arguments

Argument I/O Description


project Input Project's handle.
format Input File type (PW_MESH_format_t)
path Input File path
model Output Handle of Model read

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

PW_ERROR_code_t PW_PROJECT_remove_model(PW_PROJECT_t project, PW_MODEL_t model)

134 Chapter 3. API Reference


SDK Manual, Release 8.0.0

Arguments

Argument I/O Description


project Input Project's handle
model Input Model's handle

Description

Removes model from project. Note that the file referenced from model is not deleted.

PW_PROJECT_get_model

PW_ERROR_code_t PW_PROJECT_get_model(PW_PROJECT_t project, int id, PW_MODEL_t *model)

Arguments

Argument I/O Description


project Input Project's handle
id Input ID
model Output Model's handle

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.

3.3.1 Data Structure

Type Description
PW_OBJECT_t Handle
PW_OBJECT_type_t Type
PW_PROPERTY_t Property value
PW_PROPERTY_type_t Property type

3.3. Object 135


SDK Manual, Release 8.0.0

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.

136 Chapter 3. API Reference


SDK Manual, Release 8.0.0

Name Type Description


signa- int signature
ture
type PW_PROPERTY_type_tProperty type
u.b PW_BOOL_t If type is PW_PROPERTY_bool_c, the property value is stored in this
field.
u.i int32_t If type is PW_PROPERTY_int_c, the property value is stored in this
field.
u.d double If type is PW_PROPERTY_scalar_c, the property value is stored in this
field.
u.v double[3] If type is PW_PROPERTY_vector3_c, the property value is stored in
this field.
u.ii int[3] If type is PW_PROPERTY_vector3i_c, the property value is stored in
this field.
u.s PW_STRING_t If type is PW_PROPERTY_string_c, the property value is stored in this
field.
u.a PW_VALUE_array_t If type is PW_PROPERTY_array_c, the property value is stored in this
field.
u.ss PW_OBJECT_array_t If type is PW_PROPERTY_string_array_c, the property value is stored
in this field.

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)

3.3. Object 137


SDK Manual, Release 8.0.0

3.3.2 Function(target all components)

The following function can be called for all handles.

Function P S V Description
PW_OBJECT_get_type Y Y Y Gets type

3.3.3 Functions(Property)

The following handles have the property.


• PW_SCENE_t
• PW_NODE_t
• PW_MATERIAL_t
• PW_WIDGET_t
• PW_COLORMAP_t
• PW_PARAMETERS_t
• PW_CAPTURE_t
The following functions can be called for these handles.

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

PW_ERROR_code_t PW_OBJECT_get_type(PW_OBJECT_t object, PW_OBJECT_type_t *type)

Arguments

Argument I/O Description


object Input Handle
type Output Handle type

138 Chapter 3. API Reference


SDK Manual, Release 8.0.0

Description

Gets the type of the handle.

PW_OBJECT_get_name

PW_ERROR_code_t PW_OBJECT_get_name(PW_OBJECT_t object, PW_STRING_t *name)

Arguments

Argument I/O Description


object Input Handle
name Output Name. After use, it is necessary to free memory by using PW_STRING_free().

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

PW_ERROR_code_t PW_OBJECT_enumerate_properties(PW_OBJECT_t object,


PW_CSTRING_array_t *array)

Arguments

Argu- I/O Description


ment
object In- Handle
put
array Out- List of the property names of object. After use, it is necessary to free memory with
put PW_CSTRING_array_free().

3.3. Object 139


SDK Manual, Release 8.0.0

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

PW_ERROR_code_t PW_OBJECT_get_property(PW_OBJECT_t object, const char *name,


PW_PROPERTY_t *property)

Arguments

Argu- I/O Description


ment
object Input Handle
name Input Property name
property Out- Property value. After use, it is necessary to free memory with
put PW_PROPERTY_free().

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

140 Chapter 3. API Reference


SDK Manual, Release 8.0.0

PW_OBJECT_set_property

PW_ERROR_code_t PW_OBJECT_set_property(PW_OBJECT_t object, const char *name,


PW_PROPERTY_t property)

Arguments

Argument I/O Description


object Input Handle
name Input Property name
property Input Property value

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

PW_ERROR_code_t PW_OBJECT_get_scene(PW_OBJECT_t object, PW_SCENE_t *scene)

Arguments

Argument I/O Description


object Input Handle
scene Output Scene handle

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.3. Object 141


SDK Manual, Release 8.0.0

3.4 Scene

3.4.1 Data Structure

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

142 Chapter 3. API Reference


SDK Manual, Release 8.0.0

Table 1 – continued from previous page


Functions P S V Description
PW_SCENE_get_material Y Y Y Gets Material corresponding to ID
PW_SCENE_get_model Y Y Y Gets Model corresponding to ID
PW_SCENE_get_project N N Y Gets parent Project
PW_SCENE_get_colormap N N Y Gets current Colormap
PW_SCENE_set_colormap N N Y Sets current Colormap
PW_SCENE_enumerate_objects Y Y Y Gets subordinate object
PW_SCENE_enumerate_combinations Y Y Y Gets name of combination setting
PW_SCENE_enumerate_fields N N Y Gets fields
PW_SCENE_filter_arrays N N Y Extracts fields
PW_SCENE_create_node N N Y Creates Node
PW_SCENE_create_material N N Y Creates Material
PW_SCENE_create_widget N N Y Creates Widget
PW_SCENE_create_parameters N N Y Creates parameter of Task
PW_SCENE_import_flow_record N N Y Creates Flow Replay node
PW_SCENE_duplicate_object N N Y Duplicates object
PW_SCENE_delete_object N N Y Removes object
PW_SCENE_activate N N Y Makes Active state
PW_SCENE_deactivate N N Y Cancels Active state
PW_SCENE_get_current_frame N N Y Gets current frame
PW_SCENE_set_current_frame N Y Y Reads a frame
PW_SCENE_update_motion Y Y Y Updates motion
PW_SCENE_write N N Y Saves scene
PW_SCENE_import_rd_wall N N Y Import Wall exported from RecurDyn
PW_SCENE_lock_result_file N N Y Loads Result File
PW_SCENE_release_result_file N N Y Releases Result File
PW_OBJECT_get_name Y Y Y Gets name
PW_OBJECT_enumerate_properties Y Y Y Gets property names
PW_OBJECT_get_property Y Y Y Gets property value
PW_OBJECT_set_property Y Y Y Sets property value

PW_SCENE_get_path

PW_ERROR_code_t PW_SCENE_get_path(PW_SCENE_t scene, PW_SCENE_PATH_t type,


PW_STRING_t *path)

3.4. Scene 143


SDK Manual, Release 8.0.0

Arguments

Argument I/O Description


scene Input Scene's handle
type Input Path type (PW_SCENE_PATH_t)
path Output Path string. After use, it is necessary to free memory with PW_STRING_free().

Description

Gets the path associated with scene.

PW_SCENE_get_active

PW_ERROR_code_t PW_SCENE_get_active(PW_SCENE_t scene, PW_BOOL_t *active)

Arguments

Argument I/O Description


scene Input Scene's handle
active Output Active state

Description

Gets Active state of scene.

PW_SCENE_get_particles

PW_ERROR_code_t PW_SCENE_get_particles(PW_SCENE_t scene, PW_PARTICLES_type_t type,


PW_PARTICLES_t *particles)

Arguments

Argument I/O Description


scene Input Scene's handle
type Input Specifying whether to get PW_PARTICLES_mps_c or PW_PARTICLES_dem_c
particles Output Particles's handle

144 Chapter 3. API Reference


SDK Manual, Release 8.0.0

Description

Gets Particles’s handle, PW_PARTICLES_t.

PW_SCENE_get_result_file_count

PW_ERROR_code_t PW_SCENE_get_result_file_count(PW_SCENE_t scene, int *count)

Arguments

Argument I/O Description


scene Input Scene's handle
count Output Number of frames

Description

Gets the number of frames.

PW_SCENE_get_result_file_path

PW_ERROR_code_t PW_SCENE_get_result_file_path(PW_SCENE_t scene, int index,


PW_STRING_t *path)

Arguments

Argument I/O Description


scene Input Scene's handle
index Input Frame number
path Output Path of profbin file

Description

Gets the path of the profbin file by specifying the frame number.

3.4. Scene 145


SDK Manual, Release 8.0.0

PW_SCENE_get_node

PW_ERROR_code_t PW_SCENE_get_node(PW_SCENE_t scene, int id, PW_NODE_t *node)

Arguments

Argument I/O Description


scene Input Scene's handle
id Input ID
node Output Node's handle

Description

Gets Node's handle corresponding to the ID. If the ID is invalid, PW_ERROR_no_object is returned.

PW_SCENE_get_material

PW_ERROR_code_t PW_SCENE_get_material(PW_SCENE_t scene, int id, PW_MATERIAL_t


*material)

Arguments

Argument I/O Description


scene Input Scene's handle
id Input ID
material Output Material's handle

Description

Gets Material's handle corresponding to the ID. If the ID is invalid, PW_ERROR_no_object is returned.

PW_SCENE_get_model

PW_ERROR_code_t PW_SCENE_get_model(PW_SCENE_t scene, int id, PW_MODEL_t *model)

146 Chapter 3. API Reference


SDK Manual, Release 8.0.0

Arguments

Argument I/O Description


scene Input Scene's handle
id Input ID
model Output Model's handle

Description

Gets Model's handle corresponding to the ID. If the ID is invalid, PW_ERROR_no_object is returned.

PW_SCENE_get_project

PW_ERROR_code_t PW_SCENE_get_project(PW_SCENE_t scene, PW_PROJECT_t *project)

Arguments

Argument I/O Description


scene Input Scene's handle
project Output Project's handle

Description

Gets the handle of Project which is the parent of scene.

PW_SCENE_get_colormap

PW_ERROR_code_t PW_SCENE_get_colormap(PW_SCENE_t scene, PW_OBJECT_t *node)

Arguments

Argument I/O Description


scene Input Scene's handle
node Output Colormap's handle

3.4. Scene 147


SDK Manual, Release 8.0.0

Description

Gets the current Colormap.

PW_SCENE_set_colormap

PW_ERROR_code_t PW_SCENE_set_colormap(PW_SCENE_t scene, PW_OBJECT_t node)

Arguments

Argument I/O Description


scene Input Scene's handle
node Input Colormap's handle

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

PW_ERROR_code_t PW_SCENE_enumerate_objects(PW_SCENE_t scene, PW_OBJECT_type_t type,


PW_OBJECT_array_t *array)

Arguments

Argu- I/O Description


ment
scene In- Scene's handle
put
type In- Object type you want to get
put
objects Out- Table of the handle of the object specified by type. After use, you need to free the
put memory with PW_OBJECT_array_free().

148 Chapter 3. API Reference


SDK Manual, Release 8.0.0

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

PW_ERROR_code_t PW_SCENE_enumerate_combinations(PW_SCENE_t scene,


PW_CSTRING_array_t *names)

Arguments

Argu- I/O Description


ment
scene Input Scene's handle
names Out- Names of the interaction setting. After use, you need to free the memory with
put PW_CSTRING_array_free().

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

PW_ERROR_code_t PW_SCENE_enumerate_fields(PW_SCENE_t scene_id, PW_STRING_t *json)

3.4. Scene 149


SDK Manual, Release 8.0.0

Arguments

Argument I/O Description


scene Input Scene's handle
json Output List of available fields

Description

Gets the list of available fields in scene in JSON format.

[
{
"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

PW_ERROR_code_t PW_SCENE_filter_arrays(PW_SCENE_t scene, const char *json, PW_ARRAYS_t


*arrays)

150 Chapter 3. API Reference


SDK Manual, Release 8.0.0

Arguments

Argu- I/O Description


ment
scene Input Scene's handle
json Input Settings
arrays Out- Handle to Arrays to store the extracted results. Delete with
put PW_SCENE_delete_object() after use.

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
}

3.4. Scene 151


SDK Manual, Release 8.0.0

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.

Index Logical operator Comparison operator


0 String : and, or String : >, >=, ==, <=, <
1 Target condition Target field’s name
2 Target condition Number

PW_SCENE_create_node

PW_ERROR_code_t PW_SCENE_create_node(PW_SCENE_t scene, PW_NODE_type_t type,


PW_NODE_t *result)

Arguments

Argument I/O Description


scene Input Scene's handle
type Input Created Node type (PW_NODE_type_t)
result Output Node's handle

Description

Creates Node whose type specified by type.

Note:
• To create PW_NODE_flow_replay_c, use PW_SCENE_import_flow_record().

152 Chapter 3. API Reference


SDK Manual, Release 8.0.0

PW_SCENE_create_material

PW_ERROR_code_t PW_SCENE_create_material(PW_SCENE_t scene, PW_MATERIAL_type_t type,


PW_MATERIAL_t *result)

Arguments

Argument I/O Description


scene Input Scene's handle
type Input Created Material type (PW_MATERIAL_type_t)
result Output Material's handle

Description

Creates Material whose type specified by type.

PW_SCENE_create_widget

PW_ERROR_code_t PW_SCENE_create_widget(PW_SCENE_t scene, PW_WIDGET_type_t type,


PW_WIDGET_t *result)

Arguments

Argument I/O Description


scene Input Scene's handle
type Input Created Widget type (PW_WIDGET_type_t)
result Output Widget's handle

Description

Creates Widget whose type specified by type.

3.4. Scene 153


SDK Manual, Release 8.0.0

PW_SCENE_create_parameters

PW_ERROR_code_t PW_SCENE_create_parameters(PW_SCENE_t scene, PW_PARAMETERS_type_t


type, PW_PARAMETERS_t *node)

Arguments

Argu- I/O Description


ment
scene Input Scene's handle
type Input Task type (PW_PARAMETERS_type_t)
node Out- Created Parameters's handle. After use, delete with
put PW_SCENE_delete_object().

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

PW_ERROR_code_t PW_SCENE_import_flow_record(PW_SCENE_t scene, const wchar_t *path,


PW_BOOL_c replace)

Arguments

Argument I/O Description


scene Input Scene's handle
path Input The scene directory containing the results record by PW_NODE_flow_record_c.
replace Input If true, replace PW_NODE_flow_record_c with PW_NODE_flow_replay_c.

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.

154 Chapter 3. API Reference


SDK Manual, Release 8.0.0

PW_SCENE_duplicate_object

PW_ERROR_code_t PW_SCENE_duplicate_object(PW_SCENE_t scene, PW_OBJECT_t object,


PW_OBJECT_t *duplicated)

Arguments

Argument I/O Description


scene Input Scene's handle
object Input Duplicate source
duplicated Output Duplicated object

Description

Duplicates object. You can copy only PW_NODE_t and PW_MATERIAL_t.

PW_SCENE_delete_object

PW_ERROR_code_t PW_SCENE_delete_object(PW_SCENE_t scene, PW_OBJECT_t object)

Arguments

Argument I/O Description


scene Input Scene's handle
object Input Handle to delete

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

PW_ERROR_code_t PW_SCENE_activate(PW_SCENE_t scene)

3.4. Scene 155


SDK Manual, Release 8.0.0

Arguments

Argument I/O Description


scene Input Scene's handle

Description

Makes scene Active state.

PW_SCENE_deactivate

PW_ERROR_code_t PW_SCENE_deactivate(PW_SCENE_t scene)

Arguments

Argument I/O Description


scene Input Scene's handle

Description

Cancels Active state of scene. Changes to scene not saved with PW_SCENE_write() are discarded.

PW_SCENE_get_current_frame

PW_ERROR_code_t PW_SCENE_get_current_frame(PW_SCENE_t scene, int *r)

Arguments

Argument I/O Description


scene Input Scene's handle
r Output Frame

156 Chapter 3. API Reference


SDK Manual, Release 8.0.0

Description

Gets the current frame

PW_SCENE_set_current_frame

PW_ERROR_code_t PW_SCENE_set_current_frame(PW_SCENE_t scene, int index)

Arguments

Argument I/O Description


scene Input Scene's handle
index Input Frame

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

PW_ERROR_code_t PW_SCENE_update_motion(PW_SCENE_t scene, double time)

Arguments

Argument I/O Description


scene Input Scene's handle
time Input Time

Description

Updates the coordinate system of each Node in scene to the one at the time specified by time.

3.4. Scene 157


SDK Manual, Release 8.0.0

PW_SCENE_write

PW_ERROR_code_t PW_SCENE_write(PW_SCENE_t scene)

Arguments

Argument I/O Description


scene Input Scene's handle

Description

Saves the changes to scene.

PW_SCENE_import_rd_wall

PW_ERROR_code_t PW_SCENE_import_rd_wall(PW_SCENE_t scene, const wchar_t *path,


PW_OBJECT_array_t *nodes)

Arguments

Argu- I/O Description


ment
scene In- Scene's handle
put
path In- .wall file exported from RecurDyn.
put
nodes Out- An array of Nodes of imported polygons. After use, you need to free the memory with
put PW_OBJECT_array_free().

Description

Imports Wall exported from RecurDyn. For more details on the Wall, refer to the RecurDyn Co-simulation
Manual.

158 Chapter 3. API Reference


SDK Manual, Release 8.0.0

PW_SCENE_lock_result_file

PW_ERROR_code_t PW_SCENE_lock_result_file(PW_SCENE_t scene, int index, int flags,


PW_RESULT_FILE_t *file)

Arguments

Argument I/O Description


scene Input Scene's handle
index Input Index of the result file
flags Input Always zero
file Output Result File's handle

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

PW_ERROR_code_t PW_SCENE_release_result_file(PW_SCENE_t scene, int flags,


PW_RESULT_FILE_t file)

Arguments

Argument I/O Description


scene Input Scene's handle
flags Input
file Output Result File's handle

3.4. Scene 159


SDK Manual, Release 8.0.0

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

3.5.1 Data Structure

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.

160 Chapter 3. API Reference


SDK Manual, Release 8.0.0

PW_NODE_type_t

type PW_NODE_type_t
Node's type, which can be obtained with PW_NODE_get_type().

Value Category Icon Type


PW_NODE_polygon_c Input Polygon
PW_NODE_domain_c Input Domain
PW_NODE_output_region_c Input Output region
PW_NODE_gravity_c Input Gravity(External force)
PW_NODE_inflow_c Input Inflow
PW_NODE_outflow_c Input Outflow
PW_NODE_fill_c Input Fill
PW_NODE_group_c Input Group
PW_NODE_air_c Input Air
PW_NODE_cht_bc_c Input CHT B.C.
PW_NODE_input_probe_c Input Probe (Solver)
PW_NODE_probe_region_c Input Probe region
PW_NODE_input_mapping_c Input Mapping (Solver)
PW_NODE_input_flow_rate_c Input Flow rate (Solver)
PW_NODE_flow_record_c Input Flow record
PW_NODE_flow_replay_c Input Flow replay
PW_NODE_overlap_region_c Input High-resolution region
PW_NODE_fvm_boundary_c Input FVM Boundary
PW_NODE_residence_time_c Input Residence Time
PW_NODE_pressure_boundary_c Input Pressure Boundary
PW_NODE_distance_field_c Result DF
PW_NODE_particles_c Result Particles
PW_NODE_region_c Result Region
PW_NODE_cht_cell_c Result CHT Cell
PW_NODE_result_view_cht_cell_c Result Result View (CHT Cell)
PW_NODE_fvm_grid_c Result FVM Grid
continues on next page

3.5. Node 161


SDK Manual, Release 8.0.0

Table 2 – continued from previous page


Value Category Icon Type
PW_NODE_result_view_fvm_grid_c Result Result View (FVM Grid)
PW_NODE_clipping_c View Clipping
PW_NODE_ruler_c View Ruler
PW_NODE_camera_c View Camera
PW_NODE_measure_point_c View Point
PW_NODE_measure_distance_c View Distance
PW_NODE_profile_c View Profile
PW_NODE_snapshot_c View Snapshot
PW_NODE_mapping_c Post Mapping
PW_NODE_surface_c Post Surface
PW_NODE_grid_c Post Grid
PW_NODE_pathline_c Post Pathline
PW_NODE_flow_rate_c Post Flow rate
PW_NODE_ascii_output_c Post Profbin to Ascii
PW_NODE_particle_selection_c Post Filter
PW_NODE_probe_c Post Probe
PW_NODE_probe_point_c Post Probe point

PW_ANIMATION_value_t

type PW_ANIMATION_value_t
Animation of Node

Name Type Description


signa- int signature
ture
type PW_ANIMATION_type_t type (keyframe, script)
x PW_VALUE_array_t In the case of keyframes, an array of times. It has the same length
as y.
y PW_VALUE_array_t In the case of keyframes, an array of values. It has the same length
as x
script PW_STRING_t script
unit PW_ANIMATION_unit_t unit (position, velocity, RPM, etc.)

162 Chapter 3. API Reference


SDK Manual, Release 8.0.0

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)

Value Property Description


PW_ANIMATION_unit_unknown_c Default value
PW_ANIMATION_unit_position_c Position (transform.location) Position
PW_ANIMATION_unit_velocity_c Position (transform.location) Velocity (m/s)
PW_ANIMATION_unit_angle_c Rotation (transform.rotation) Angle (°)
PW_ANIMATION_unit_rpm_c Rotation (transform.rotation) Rotations per minute
PW_ANIMATION_unit_rps_c Rotation (transform.rotation) Radians per second

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.

3.5. Node 163


SDK Manual, Release 8.0.0

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)

164 Chapter 3. API Reference


SDK Manual, Release 8.0.0

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

3.5. Node 165


SDK Manual, Release 8.0.0

Table 3 – continued from previous page


Functions P S V Description
PW_NODE_get_renderer Y Y Y Gets PW_RENDERER_type_t
PW_NODE_set_renderer N N Y Sets PW_RENDERER_type_t
PW_NODE_update_motion Y Y Y Updates motion
PW_NODE_create_filter Y Y Y Generates Filter
PW_NODE_adjust_dimension N N Y Adjusts the size of a node
PW_NODE_set_k_epsilon N N Y Sets 𝑘 and 𝜀 of the domain automatically
PW_NODE_add_result_view N N Y Adds result view
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_INFLOW_fill Y Y N Sets physical quantities of inflow particles
PW_CAMERA_fit_box Y Y Y Camera fit
PW_MAPPING_lock_arrays N N Y Gets mapping result
PW_MAPPING_release_arrays N N Y Unlocks mapping result

PW_NODE_get_type

PW_ERROR_code_t PW_NODE_get_type(PW_NODE_t node, PW_NODE_type_t *type)

Arguments

Argument I/O Description


node Input Node's handle
type Output Type (PW_NODE_type_t)

Description

Gets the type of node.

PW_NODE_get_particle_type

PW_ERROR_code_t PW_NODE_get_particle_type(PW_NODE_t node, PW_PARTICLES_type_t


*type)

166 Chapter 3. API Reference


SDK Manual, Release 8.0.0

Arguments

Argument I/O Description


node Input Node's handle
type Output Particle type

Description

Gets particle type, if node has associated particle properties. For type, the following values can be obtained:

Value Category Type


PW_PARTICLE_unknown_c Input node is not associated with particle properties.
PW_PARTICLE_fluid_c Input Fluid
PW_PARTICLE_powder_c Input Powder
PW_PARTICLE_wall_c Input Wall particle
PW_PARTICLE_rigid_body_c Input Rigid body

PW_NODE_get_polygon_type

PW_ERROR_code_t PW_NODE_get_polygon_type(PW_NODE_t node, PW_POLYGON_type_t *type)

Arguments

Argument I/O Description


node Input Node's handle
type Output Polygon’s type

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:

3.5. Node 167


SDK Manual, Release 8.0.0

Value Poly- Type


gon
PW_POLYGON_unknown_c Input node is not a polygon or is not associated with physical
properties.
PW_POLYGON_distance_function_c
Input Polygon wall (Distance Field)
PW_POLYGON_flow_resistance_c Input Flow resistance
PW_POLYGON_pump_c Input Pump
PW_POLYGON_outflow_region_c Input Outflow Region
PW_POLYGON_fluid_c Input Fluid particles
PW_POLYGON_powder_c Input Powder particles
PW_POLYGON_particle_wall_c Input Particle wall
PW_POLYGON_rigid_body_c Input Rigid body

PW_NODE_get_parent

PW_ERROR_code_t PW_NODE_get_parent(PW_NODE_t node, PW_NODE_t *parent)

Arguments

Argument I/O Description


node Input Node's handle
parent Output Parent Node's handle

Description

Gets the parent’s handle. If node does not have a parent, PW_ERROR_no_parent is returned.

PW_NODE_set_parent

PW_ERROR_code_t PW_NODE_set_parent(PW_NODE_t node, PW_NODE_t parent)

Arguments

Argument I/O Description


node Input Node's handle
parent Input Parent Node's handle

168 Chapter 3. API Reference


SDK Manual, Release 8.0.0

Description

Sets the parent of node.

PW_NODE_get_object_id

PW_ERROR_code_t PW_NODE_get_object_id(PW_NODE_t node, int *object_id)

Arguments

Argument I/O Description


node Input Node's handle
object_id Output ID

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

PW_ERROR_code_t PW_NODE_get_group_id(PW_NODE_t node, int *group_id)

Arguments

Argument I/O Description


node Input Node's handle
group_id Output Group ID

Description

Gets Group ID of node. Group ID can be used to associate Node with particles and Distance Field.

3.5. Node 169


SDK Manual, Release 8.0.0

PW_NODE_get_material

PW_ERROR_code_t PW_NODE_get_material(PW_NODE_t node, PW_MATERIAL_t *material)

Arguments

Argument I/O Description


node Input Node's handle
material Output Handle of Material associated with node

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

PW_ERROR_code_t PW_NODE_set_material(PW_NODE_t node, PW_MATERIAL_t material)

Arguments

Argument I/O Description


node Input Node's handle
material Input Material's handle

Description

Sets Material associated with node. node’s PW_PHYS_DETAIL_type_t may be switched.

PW_NODE_get_model

PW_ERROR_code_t PW_NODE_get_model(PW_NODE_t node, PW_MODEL_t *model)

170 Chapter 3. API Reference


SDK Manual, Release 8.0.0

Arguments

Argument I/O Description


node Input Node's handle
model Output Model's handle associated with node

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

PW_ERROR_code_t PW_NODE_set_model(PW_NODE_t node, PW_MODEL_t model)

Arguments

Argument I/O Description


node Input Node's handle
model Input Model's handle

Description

Sets Model associated with node.

PW_NODE_get_animation_value

PW_ERROR_code_t PW_NODE_get_animation_value(PW_NODE_t node, const char *name, int index,


PW_ANIMATION_value_t *data)

Arguments

Argument I/O Description


node Input Node's handle
name Input Property name
index Input Specify XYZ axis with 0, 1, 2
data Output Animation (PW_ANIMATION_value_t)

3.5. Node 171


SDK Manual, Release 8.0.0

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().

Note: If name is transform.rotation, note the following


• If PW_ROTATION_type_t is PW_ROTATION_axis_c (Axis rotation), index is ignored.
• If node is set to Quaternion interpolation in Particleworks GUI, an error occurs.

PW_NODE_set_animation_value

PW_ERROR_code_t PW_NODE_set_animation_value(PW_NODE_t node, const char *name, int index,


const PW_ANIMATION_value_t *data)

Arguments

Argument I/O Description


node Input Node's handle
name Input Property name
index Input Specify XYZ axis with 0, 1, 2
data Input Animation (PW_ANIMATION_value_t)

Description

Sets the animation of node with the property name name. When the property is a vector, it specifies the axis
with index.

Note: If name is transform.rotation, note the following


• Set a negative value to index if PW_ROTATION_type_t is PW_ROTATION_axis_c.
• If PW_ROTATION_type_t is not PW_ROTATION_normal_c and index is not negative,
PW_NODE_set_rotation_type() is called internally, and PW_ROTATION_normal_c is set.

172 Chapter 3. API Reference


SDK Manual, Release 8.0.0

PW_NODE_get_transform_matrix

PW_ERROR_code_t PW_NODE_get_transform_matrix(PW_NODE_t node, PW_BOOL_t global,


double matrix[16])

Arguments

Argu- I/O Description


ment
node In- Node's handle
put
global In- To obtain the transformation matrix in which the parent’s coordinate system is consid-
put ered, specify PW_BOOL_true.
matrix Out- Transformation matrix
put

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};

for (int i = 0; i < 4; i++) {


for (int j = 0; j < 4; j++) {
q1[i] += matrix[4 * i + j] * q0[j];
}
}
p[0] = q1[0];
p[1] = q1[1];
p[2] = q1[2];
}

3.5. Node 173


SDK Manual, Release 8.0.0

PW_NODE_set_transform_matrix

PW_ERROR_code_t PW_NODE_set_transform_matrix(PW_NODE_t node, PW_BOOL_t global,


double matrix[16])

Arguments

Argu- I/O Description


ment
node In- Node's handle
put
global In- To obtain the transformation matrix using the parent’s coordinate system, specify
put PW_BOOL_true.
matrix In- Transformation matrix
put

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

PW_ERROR_code_t PW_NODE_get_center(PW_NODE_t node, double center[3])

Arguments

Argument I/O Description


node Input Node's handle
center Output Coordinates of the center of rotation

174 Chapter 3. API Reference


SDK Manual, Release 8.0.0

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

PW_ERROR_code_t PW_NODE_set_center(PW_NODE_t node, double center[3])

Arguments

Argument I/O Description


node Input Node's handle
center Input Coordinates of the center of rotation

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

PW_ERROR_code_t PW_NODE_get_velocity(PW_NODE_t node, double velocity[3])

Arguments

Argument I/O Description


node Input Node's handle
velocity Output Translational velocity vector

Description

Gets the translational velocity of node.


• The translational velocity is used as a boundary condition for viscosity calculations.

3.5. Node 175


SDK Manual, Release 8.0.0

PW_NODE_set_velocity

PW_ERROR_code_t PW_NODE_set_velocity(PW_NODE_t node, double velocity[3])

Arguments

Argument I/O Description


node Input Node's handle
velocity Input Translational velocity vector

Description

Sets the translational velocity of node.


• The translational velocity is used as a boundary condition for viscosity calculations.
• The translational velocity is overwritten when a motion update occurs.

PW_NODE_get_angular_velocity

PW_ERROR_code_t PW_NODE_get_angular_velocity(PW_NODE_t node, double omega[3])

Arguments

Argument I/O Description


node Input Node's handle
omega Output Angular velocity vector

Description

Gets the angular velocity vector of node.


• The angular velocity is used as a boundary condition for viscosity calculation.

176 Chapter 3. API Reference


SDK Manual, Release 8.0.0

PW_NODE_set_angular_velocity

PW_ERROR_code_t PW_NODE_set_angular_velocity(PW_NODE_t node, double omega[3])

Arguments

Argument I/O Description


node Input Node's handle
omega Input Angular velocity vector

Description

Sets the angular velocity vector of node.


• The angular velocity is used as a boundary condition for viscosity calculation.
• The angular velocity is overwritten when a motion update occurs.

PW_NODE_get_bounding_box

PW_ERROR_code_t PW_NODE_get_bounding_box(PW_NODE_t node, PW_BOOL_t global, double


box_min[3], double box_max[3])

Arguments

Argument I/O Description


node Input Node's handle
global Input Applies coordinate transformation
box_min Output Minimum coordinates of Axis Aligned Box
box_max Output Maximum coordinates of Axis Aligned Box

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.

3.5. Node 177


SDK Manual, Release 8.0.0

PW_NODE_get_phys_detail

PW_ERROR_code_t PW_NODE_get_phys_detail(PW_NODE_t node, PW_PHYS_DETAIL_t *detail)

Arguments

Argument I/O Description


node Input Node's handle
type Output Type (PW_PHYS_DETAIL_type_t)

Description

Gets details of the physical properties of node.

PW_NODE_set_phys_detail

PW_ERROR_code_t PW_NODE_set_phys_detail(PW_NODE_t node, PW_PHYS_DETAIL_t detail)

Arguments

Argument I/O Description


node Input Node's handle
type Input Type (PW_PHYS_DETAIL_type_t)

Description

Sets details of the physical properties of node.


Changing the PW_PHYS_DETAIL_type_t changes the available properties in Node.
The configurable PW_PHYS_DETAIL_type_t differs according to Node and the type of Material. The com-
binations in the following table are possible.

178 Chapter 3. API Reference


SDK Manual, Release 8.0.0

PW_NODE_type_t PW_MATERIAL_type_t PW_PHYS_DETAIL_type_t


PW_NODE_inflow_c
PW_MATERIAL_fluid_c PW_PHYS_DETAIL_inflow_c
PW_MATERIAL_powder_c

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

PW_ERROR_code_t PW_NODE_get_renderer(PW_NODE_t node, PW_RENDERER_t *detail)

Arguments

Argument I/O Description


node Input Node's handle
type Output Type (PW_RENDERER_type_t)

3.5. Node 179


SDK Manual, Release 8.0.0

Description

Gets the appearance of the node.

PW_NODE_set_renderer

PW_ERROR_code_t PW_NODE_set_renderer(PW_NODE_t node, PW_RENDERER_t detail)

Arguments

Argument I/O Description


node Input Node's handle
type Input Type (PW_RENDERER_type_t)

Description

Sets the appearance of the node.


Changing PW_RENDERER_type_t will also change the available properties in Node.
The configurable PW_RENDERER_type_t differs according to Node. The combinations in the following table
are possible.

180 Chapter 3. API Reference


SDK Manual, Release 8.0.0

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

3.5. Node PW_RENDERER_cross_section_c 181


PW_RENDERER_streamline_c
PW_RENDERER_isolines_c
SDK Manual, Release 8.0.0

PW_NODE_update_motion

PW_ERROR_code_t PW_NODE_update_motion(PW_NODE_t node, double time)

Arguments

Argument I/O Description


node Input Node's handle
time Input Time to evaluate animation

Description

Updates the animation of node.

PW_NODE_create_filter

PW_ERROR_code_t PW_NODE_create_filter(PW_NODE_t node, PW_FILTER_t *filter)

Arguments

Argu- I/O Description


ment
node Input Handle
filter Out- Filter. After use, it is necessary to free the used memory with PW_FILTER_free().
put

Description

Generates Filter from Node. Node that can generate Filter is as follows:

Type Discrimination method


Flow resistance PW_NODE_get_polygon_type() returns PW_POLYGON_flow_resistance_c.

182 Chapter 3. API Reference


SDK Manual, Release 8.0.0

PW_NODE_adjust_dimension

PW_ERROR_code_t PW_NODE_adjust_dimension(PW_NODE_t node, const


PW_NODE_adjust_dimension_t *args)

Arguments

Argument I/O Description


node Input Handle
args Input Adjustment parameters

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.

Mem- Type Description


ber
mar- double Size of the box margin
gin
per- PW_BOOL_tmargin is treated as a percent if this value is PW_BOOL_true_c. If
cent PW_BOOL_false_c, margin is in the length unit.

PW_NODE_set_k_epsilon

PW_ERROR_code_t PW_NODE_set_k_epsilon(PW_NODE_t domain, PW_NODE_t boundary)

3.5. Node 183


SDK Manual, Release 8.0.0

Arguments

Argument I/O Description


domain Input Handle
boundary Input Handle

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

PW_ERROR_code_t PW_NODE_add_result_view(PW_NODE_t node, PW_NODE_t *result_view)

Arguments

Argument I/O Description


node Input Node handle
result_view Output Node handle

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

PW_ERROR_code_t PW_NODE_get_rotation_type(PW_NODE_t id, PW_ROTATION_type_t *type)

Arguments

Argument I/O Description


node Input Node's handle
type Output Rotation type (PW_ROTATION_type_t)

184 Chapter 3. API Reference


SDK Manual, Release 8.0.0

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

PW_ERROR_code_t PW_NODE_set_rotation_type(PW_NODE_t id, PW_ROTATION_type_t type)

Arguments

Argument I/O Description


node Input Node's handle
type Input Rotation type (PW_ROTATION_type_t)

Description

Sets the rotation type of node.


If either the rotation type currently set for node or the value of type is PW_ROTATION_axis_c, and the new
rotation type is different from the existing one, the existing animation of rotation is removed.

PW_NODE_get_rotation_axis

PW_ERROR_code_t PW_NODE_get_rotation_axis(PW_NODE_t id, double axis[3])

Arguments

Argument I/O Description


node Input Node's handle
axis Output Rotation axis

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.

3.5. Node 185


SDK Manual, Release 8.0.0

PW_NODE_set_rotation_axis

PW_ERROR_code_t PW_NODE_set_rotation_axis(PW_NODE_t id, const double axis[3])

Arguments

Argument I/O Description


node Input Node's handle
type Input Rotation axis

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

PW_ERROR_code_t PW_INFLOW_fill(PW_NODE_t node, size_t start)

Arguments

Argument I/O Description


node Input Node's handle
start Input The first index of inflow particles

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.

186 Chapter 3. API Reference


SDK Manual, Release 8.0.0

PW_CAMERA_fit_box

PW_ERROR_code_t PW_CAMERA_fit_box(PW_NODE_t node, int width, int height, const double


box_min[3], const double box_max[3])

Arguments

Argument I/O Description


node Input Node's handle
width Input Viewport width (pixels)
height Input Viewport height (pixels)
box_min Input Minimum coordinates of Axis Aligned Box
box_max Input Maximum coordinates of Axis Aligned Box

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

PW_ERROR_code_t PW_MAPPING_lock_arrays(PW_NODE_t node, int flags, PW_ARRAYS_t *arrays)

Arguments

Argument I/O Description


node Input Node's handle
flags Input Always zero
arrays Output Arrays's handle

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

3.5. Node 187


SDK Manual, Release 8.0.0

PW_MAPPING_release_arrays

PW_ERROR_code_t PW_MAPPING_release_arrays(PW_NODE_t node, int flags, PW_ARRAYS_t


arrays)

Arguments

Argument I/O Description


node Input Node's handle
flags Input Always zero
arrays Input Arrays's handle

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

3.6.1 Data Structure

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.

188 Chapter 3. API Reference


SDK Manual, Release 8.0.0

PW_MATERIAL_type_t

type PW_MATERIAL_type_t
Material's type

Value Icon Type


PW_MATERIAL_fluid_c Fluid
PW_MATERIAL_solid_c Solid
PW_MATERIAL_powder_c Powder
PW_MATERIAL_polygon_c Polygon

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

PW_ERROR_code_t PW_MATERIAL_get_object_id(PW_MATERIAL_t material, int *object_id)

Arguments

Argument I/O Description


material Input Material's handle
object_id Output ID

3.6. Material 189


SDK Manual, Release 8.0.0

Description

Gets the ID. Material can be uniquely specified by the handle type (PW_OBJECT_material_c) and the ID.

PW_MATERIAL_get_type

PW_ERROR_code_t PW_MATERIAL_get_type(PW_MATERIAL_t material, PW_MATERIAL_type_t


*type)

Arguments

Argument I/O Description


material Input Material's handle
type Output Type (PW_MATERIAL_type_t)

Description

Gets the material type.

PW_MATERIAL_get_combination

PW_ERROR_code_t PW_MATERIAL_get_combination(const char *name, PW_MATERIAL_t m0,


PW_MATERIAL_t m1, double *value)

Arguments

Argument I/O Description


name Input Name of interaction setting
m0 Input Material's handle
m1 Input Material's handle
value Output Value of interaction setting

190 Chapter 3. API Reference


SDK Manual, Release 8.0.0

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

PW_ERROR_code_t PW_MATERIAL_set_combination(const char *name, PW_MATERIAL_t m0,


PW_MATERIAL_t m1, double value)

Arguments

Argument I/O Description


name Input Name of interaction setting
m0 Input Material's handle
m1 Input Material's handle
value Input Value of interaction setting

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

3.7.1 Data Structure

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.

3.7. Widget 191


SDK Manual, Release 8.0.0

– It will be deleted when PW_SESSION_t is deleted.


• Viewer
– It is obtained by calling PW_SCENE_enumerate_objects() with PW_OBJECT_widget_c.
– It is deleted by PW_SCENE_delete_object. It will be deleted when PW_SCENE_t is
deleted.

PW_WIDGET_type_t

type PW_WIDGET_type_t
Widget's type

Value Icon Type


PW_WIDGET_colorbar_c Color bar
PW_WIDGET_timelabel_c Time
PW_WIDGET_axis_c Axis
PW_WIDGET_graph_overlay_c Plot (Overlay)

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

PW_ERROR_code_t PW_WIDGET_get_object_id(PW_WIDGET_t widget, int *object_id)

192 Chapter 3. API Reference


SDK Manual, Release 8.0.0

Arguments

Argument I/O Description


widget Input Widget's handle
object_id Output ID

Description

Gets the ID. Widget can be uniquely specified by the handle type (PW_OBJECT_widget_c) and the ID.

PW_WIDGET_get_type

PW_ERROR_code_t PW_WIDGET_get_type(PW_WIDGET_t widget, PW_WIDGET_type_t *type)

Arguments

Argument I/O Description


widget Input Widget's handle
type Output Type (PW_WIDGET_type_t)

Description

Gets the type of widget.

3.8 Distance Field

3.8.1 Data Structure

Type Description
PW_DF_t Distance Field's handle
PW_INTERACTION_PD_t Information required for interaction calculation between particles and Dis-
tance Field

3.8. Distance Field 193


SDK Manual, Release 8.0.0

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.

Name Type Description


size int64_t Number of particles near Distance Field
index const Index of the array of the particles near Distance Field. If this value is NULL,
uint64_t * index will be between 0 and (size - 1).
d const Distance between Distance Field and particle
pw_scalar *
nx, ny, const Gradient vector of Distance Field at particle's position
nz pw_scalar *
vx, vy, const Velocity vector of Distance Field at particle's position
vz pw_scalar *

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)

194 Chapter 3. API Reference


SDK Manual, Release 8.0.0

(continued from previous page)


// Distance between particle and DF
pw_scalar d = pd.d[di];

// Gradient of the distance function at the particle's position


pw_scalar nx = pd.nx[di];
pw_scalar ny = pd.ny[di];
pw_scalar nz = pd.nz[di];

// 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;

// Coordinates of the particle


pw_scalar x0 = rx0[i];
pw_scalar y0 = ry0[i];
pw_scalar z0 = rz0[i];

// The coordinates of the point on the DF


pw_scalar x1 = x0 - d * nx;
pw_scalar y1 = y0 - d * ny;
pw_scalar z1 = z0 - d * nz;

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

3.8. Distance Field 195


SDK Manual, Release 8.0.0

PW_DF_get_arrays

PW_ERROR_code_t PW_DF_get_arrays(PW_DF_t df, PW_ARRAYS_t *arrays)

Arguments

Argument Input or Output Description


df Input Distance Field's handle
arrays Output Arrays' handle

Description

Gets PW_ARRAYS_t that holds the information related to distance_field.

PW_DF_get_interactions

PW_ERROR_code_t PW_DF_get_interactions(PW_DF_t df, PW_PARTICLES_t p,


PW_INTERACTION_PD_t *interaction)

Arguments

Argument I/O Description


df Input Distance Field's handle
p Input Particles' handle
interaction Output PW_INTERACTION_PD_t

Description

Gets PW_INTERACTION_PD_t to calculate the interactions between df and p.

PW_DF_get_group_id

PW_ERROR_code_t PW_DF_get_group_id(PW_DF_t df, int *group_id)

196 Chapter 3. API Reference


SDK Manual, Release 8.0.0

Arguments

Argument I/O Description


df Input Distance Field's handle
interaction Output Group ID

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

PW_ERROR_code_t PW_DF_get_load(PW_DF_t df, PW_LOAD_type_t type, double load[3], double


torque[3])

Arguments

Argument I/O Description


df Input Distance Field's handle
type Input PW_LOAD_type_t
load Output Load. NULL specification is possible.
torque Output Torque. NULL specification is possible.

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

3.8. Distance Field 197


SDK Manual, Release 8.0.0

PW_DF_calculate

PW_ERROR_code_t PW_DF_calculate(PW_DF_t df, const double position[3], PW_BOOL_t *out,


double *distance, double normal[3], double velocity[3])

Arguments

Argument I/O Description


df Input Distance Field's handle
position Input Coordinates
out Output If position is not in the proximity of Distance Field, PW_BOOL_true_c is set.
distance Output Distance evaluated by Distance Field
normal Output Gradient vector of the distance evaluated by Distance Field
velocity Output Velocity of Distance Field at position

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

3.9.1 Data Structure

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

198 Chapter 3. API Reference


SDK Manual, Release 8.0.0

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

The following functions do not support multi-resolution.

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

PW_ERROR_code_t PW_PARTICLES_get_size(PW_PARTICLES_t particles, size_t *size)

Arguments

Argument I/O Description


particles Input Particles' handle
size Output Number of particles. NULL is not allowed.

Description

Gets the number of particles.

PW_PARTICLES_resize

PW_ERROR_code_t PW_PARTICLES_resize(PW_PARTICLES_t particles, size_t size)

3.9. Particles 199


SDK Manual, Release 8.0.0

Arguments

Argument I/O Description


particles Input Particles' handle
size Input New number of particles

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

PW_ERROR_code_t PW_PARTICLES_remove(PW_PARTICLES_t particles, size_t size, const size_t


*indices)

Arguments

Argument I/O Description


particles Input Particles' handle
size Input indices' length
indices Input Index of the particle to delete

Description

Deletes the particles at the index specified by the indices array.

PW_PARTICLES_get_arrays

PW_ERROR_code_t PW_PARTICLES_get_arrays(PW_PARTICLES_t particles, PW_ARRAYS_t


*arrays)

200 Chapter 3. API Reference


SDK Manual, Release 8.0.0

Arguments

Argument Input or Output Description


particles Input Particles' handle
arrays Output Arrays' handle

Description

Gets PW_ARRAYS_t that holds the physical quantities of particles.

PW_PARTICLES_create_interactions

PW_ERROR_code_t PW_PARTICLES_create_interactions(PW_PARTICLES_t p0,


PW_PARTICLES_t p1,
PW_INTERACTION_PP_t *r)

Arguments

Argu- I/O Description


ment
p0 Input Particles' handle
p1 Input Particles' handle
r Out- Interaction (p-p)'s handle. After use, it is necessary to free memory with
put PW_INTERACTION_PP_free().

Description

Generates PW_INTERACTION_PP_t to calculate the interactions between p0 and p1.


The handle of Particles given to the 4 patterns of Interaction Pattern is as follows.

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.

• The handle of the MPS particle is obtained by specifying PW_PARTICLES_mps_c for


PW_SESSION_get_particles().
• The handle of the DEM particle is obtained by specifying PW_PARTICLES_dem_c for
PW_SESSION_get_particles().

3.9. Particles 201


SDK Manual, Release 8.0.0

• 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 .

3.10 Result File

3.10.1 Data Structure

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

PW_ERROR_code_t PW_RESULT_FILE_get_scene(PW_RESULT_FILE_t file, PW_SCENE_t *scene)

Arguments

Argument I/O Description


file Input Result File's handle
scene Output Scene's handle

202 Chapter 3. API Reference


SDK Manual, Release 8.0.0

Description

Gets Scene corresponding to file.

PW_RESULT_FILE_get_path

PW_ERROR_code_t PW_RESULT_FILE_get_path(PW_RESULT_FILE_t file, PW_STRING_t *path)

Arguments

Argument I/O Description


file Input Result File's handle
path Output Path of the result file

Description

Gets the file path of file.

PW_RESULT_FILE_add_material_array

PW_ERROR_code_t PW_RESULT_FILE_add_material_array(PW_RESULT_FILE_t file, const char


*name, const char *key, pw_scalar def)

Arguments

Argument I/O Description


file Input Result File's handle
name Input Name of a material property
key Input Name of the array to be added
def Input Default value

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.

3.10. Result File 203


SDK Manual, Release 8.0.0

PW_RESULT_FILE_get_arrays

PW_ERROR_code_t PW_RESULT_FILE_get_arrays(PW_RESULT_FILE_t file, const char *key,


PW_ARRAYS_t *arrays)

Arguments

Argument I/O Description


file Input Result File's handle
key Input Name of Arrays
arrays Output Arrays's handle

Description

Gets Arrays under file. MPS can be specified as key.

PW_RESULT_FILE_write

PW_ERROR_code_t PW_RESULT_FILE_write(PW_RESULT_FILE_t file, const wchar_t *path)

Arguments

Argument I/O Description


file Input Result File's handle
path Output Output file path

Description

Writes the content of file to the specified path.

3.11 Arrays

3.11.1 Data Structure

Type Description
PW_ARRAYS_t Arrays' handle
PW_ARRAY_description_t Contents of the array

204 Chapter 3. API Reference


SDK Manual, Release 8.0.0

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 Type Description


signa- int signature
ture
name const char * Array name. See Arrays for representative array names.
tags Tag
PW_CSTRING_array_t
value_type PW_VALUE_type_tData type of arrays
size size_t Array length
data void * [16] Array data. The number of arrays is determined by components.
compo- int The number of data. For example, if this value is equal to 3, an array is set
nents at data[0], data[1], and data[2].
ranks int Rank of the tensor. 0 for a scalar array, 1 for a vector array, 2 for a matrix
array.
rank_size int [2] Size of each rank
ini- const void * The initial address of the array. For more details, see
tial_data PW_ARRAYS_set_initial_value().
ini- size_t The initial size of the array. For more details, see
tial_size PW_ARRAYS_set_initial_value().

Name of Array

The name of an array has the following restrictions:


• Only lowercase letters, numbers and underscores are allowed
• The first character must be a lowercase letter
• Characters following an underscore must be a lowercase letter
• The last character must be a lowercase letter or a number.
The following are examples:

3.11. Arrays 205


SDK Manual, Release 8.0.0

Name Valid Description


kinetic_energy OK
kinetic_energy2 OK
KineticEnergy NG Contains capital letters
kinetic_energy_2 NG A number (2) appears after an underscore
kinetic-energy NG Contains a minus (-) sign

Vector type / Matrix type 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).

206 Chapter 3. API Reference


SDK Manual, Release 8.0.0

name value_type compo- ranks rank_size[0] rank_size[1]


nents
group_index PW_VALUE_int_c 1 0 0 0
pressure PW_VALUE_double_c or 1 0 0 0
PW_VALUE_float_c
position PW_VALUE_double_c or 3 1 3 0
PW_VALUE_float_c
veloc- PW_VALUE_double_c or 9 2 3 3
ity_gradient PW_VALUE_float_c

Available Arrays

The following arrays can be obtained with PW_ARRAYS_get_array() or added with


PW_ARRAYS_add_array().

value_type compo- ranks rank_size[0] rank_size[1]


nents
PW_VALUE_char_c 1 0 0 0
PW_VALUE_int_c 1 0 0 0
PW_VALUE_long_c 1 0 0 0
PW_VALUE_double_c or PW_VALUE_float_c 1 0 0 0
PW_VALUE_double_c or PW_VALUE_float_c 3 1 3 0
PW_VALUE_double_c or PW_VALUE_float_c 4 1 4 0
PW_VALUE_double_c or PW_VALUE_float_c 9 2 3 3

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)

3.11. Arrays 207


SDK Manual, Release 8.0.0

(continued from previous page)


PW_ERROR_code_t r;

// 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;
}

// Checking that is vector3 type.


assert(d.value_type == PW_VALUE_double_c || d.value_type == PW_VALUE_
˓→float_c);

assert(d.ranks == 1);
assert(d.rank_size[0] == 3);
assert(d.components == 3);

// Accessing the array.


double x, y, z;
if (d.value_type == PW_VALUE_double_c) {
x = ((double*)d.data[0])[i];
y = ((double*)d.data[1])[i];
z = ((double*)d.data[2])[i];
} else {
x = ((float*)d.data[0])[i];
y = ((float*)d.data[1])[i];
z = ((float*)d.data[2])[i];
}
r_i[0] = x;
r_i[1] = y;
r_i[2] = z;

return PW_ARRAY_description_free(&d);
}

208 Chapter 3. API Reference


SDK Manual, Release 8.0.0

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

PW_ERROR_code_t PW_ARRAYS_enumerate_names(PW_ARRAYS_t arrays, PW_CSTRING_array_t


*names)

Arguments

Argument I/O Description


arrays Input Arrays' handle
names Output Array names list

Description

Gets the list of the names of the arrays defined in arrays.

PW_ARRAYS_get_size

PW_ERROR_code_t PW_ARRAYS_get_size(PW_ARRAYS_t arrays, const char *name, size_t *size)

Arguments

Argument I/O Description


arrays Input Arrays' handle
name Input Array name
size Output Array length

3.11. Arrays 209


SDK Manual, Release 8.0.0

Description

Gets the length of the array specified by name.

PW_ARRAYS_resize

PW_ERROR_code_t PW_ARRAYS_resize(PW_ARRAYS_t arrays, const char *name, size_t size)

Arguments

Argument I/O Description


arrays Input Arrays' handle
name Input Array name
size Input Array length

Description

Resizes the length of the array specified by name.


If the length of a predefined array is modified, such as an array representing the physical quantities of particles
(position, velocity, pressure, etc.), Solver may not function properly. This function is usually not used.

PW_ARRAYS_get_array

PW_ERROR_code_t PW_ARRAYS_get_array(PW_ARRAYS_t arrays, const char *name,


PW_MEMORY_type_t mtype, PW_ACCESS_type_t
access, PW_ARRAY_description_t *data)

Arguments

Argu- I/O Description


ment
ar- Input Arrays' handle
rays
name Input Array name
mtype Input Specify either PW_MEMORY_cpu_c or PW_MEMORY_gpu_c. Specify
PW_MEMORY_cpu_c, except when creating a CUDA kernel.
ac- Input If only the array's data is read, specify PW_ACCESS_read_only_c. To modify
cess the array's data, specify PW_ACCESS_writable_c.
data PW_ARRAY_description_t
Contents of the array (PW_ARRAY_description_t). After use, it is necessary
to free memory with PW_ARRAY_description_free().

210 Chapter 3. API Reference


SDK Manual, Release 8.0.0

Description

Gets the contents of an array specified by name. Refer to PW_ARRAY_description_t for an example code.

PW_ARRAYS_add_array

PW_ERROR_code_t PW_ARRAYS_add_array(PW_ARRAYS_t arrays, PW_ARRAY_description_t data)

Arguments

Argument I/O Description


arrays Input Arrays' handle
data Input Contents of the array to be added

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

PW_ERROR_code_t PW_ARRAYS_remove_array(PW_ARRAYS_t arrays, const char *name)

Arguments

Argument I/O Description


arrays Input Arrays' handle
name Input Array name

3.11. Arrays 211


SDK Manual, Release 8.0.0

Description

Deletes the array specified by name.


If a predefined array is deleted, such as an array representing the physical quantities of particles (position,
velocity, pressure, etc.), Solver may not function properly. This function is usually not used.

PW_ARRAYS_set_initial_value

PW_ERROR_code_t PW_ARRAYS_set_initial_value(PW_ARRAYS_t arrays, const char *name, const


void *data, size_t bytes)

Arguments

Argument I/O Description


arrays Input Arrays' handle
name Input Array name
data Input Memory address of the initial value
bytes Input Number of bytes of memory storing the initial value

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:

double initial[3] = {1.0, 2.0, 3.0};


PW_ARRAYS_set_initial_value(arrays, "test", initial, sizeof(double) * 3);

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

PW_ERROR_code_t PW_ARRAY_description_free(PW_ARRAY_description_t *data)

212 Chapter 3. API Reference


SDK Manual, Release 8.0.0

Arguments

Argument I/O Description


data Input PW_ARRAY_description_t to free

Description

Frees the memory of PW_ARRAY_description_t, returned by PW_ARRAYS_get_array().

3.12 Interaction (p-p)

3.12.1 Data Structure

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.

Member Type Description


index int64_t Particle index i
count size_t Length of peers and pairs (if not NULL)
peers const int64_t * Array of the indexes of j particles
pairs const int64_t * Index sequence of the interactions between DEM particles
(which contains the indexes of DEM only (interactions)).

In the example code below, a callback function that calculates interactions between particle i and j is called.

3.12. Interaction (p-p) 213


SDK Manual, Release 8.0.0

// Callback function to compute the interaction between particles i and j


typedef void (*CALLBACK_t)(int64_t i, int64_t j, void * data);

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;

while (PW_INTERACTION_PP_iterate_indices(interactions, &a) == PW_ERROR_


˓→ no_error) {
int64_t i = a.index; // Index of particle i

for (size_t jj = 0; jj < a.count; jj++) {


int64_t j = a.peers[jj]; // Index of particle j
if (i == j) {
continue;
}

// Interaction of particles i and j


callback(i, j, data);
}
}

PW_INTERACTION_PP_free(interactions);
return PW_ERROR_no_error;
}

214 Chapter 3. API Reference


SDK Manual, Release 8.0.0

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

PW_ERROR_code_t PW_INTERACTION_PP_iterate_indices(PW_INTERACTION_PP_t interactions,


PW_INTERACTION_PP_indices_t
*indices)

Arguments

Argument I/O Description


interactions Input Interaction (p-p)'s handle
indices Output PW_INTERACTION_PP_indices_t

Description

Gets the particle interaction index PW_INTERACTION_PP_indices_t. PW_INTERACTION_PP_t contains


a counter that is incremented each time this function is called, and PW_INTERACTION_PP_indices_t is
acquired at the next counter. When the counter reaches its maximum value, PW_ERROR_end_of_iteration
is returned.
Refer to PW_INTERACTION_PP_indices_t for an example code.

PW_INTERACTION_PP_get_block_count

PW_ERROR_code_t PW_INTERACTION_PP_get_block_count(PW_INTERACTION_PP_t interactions,


size_t *size)

3.12. Interaction (p-p) 215


SDK Manual, Release 8.0.0

Arguments

Argument I/O Description


interactions Input Interaction (p-p)'s handle
size Output Number of blocks

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

PW_ERROR_code_t PW_INTERACTION_PP_create_block(PW_INTERACTION_PP_t interactions,


size_t start, size_t end,
PW_INTERACTION_PP_t *block)

Arguments

Argument I/O Description


interactions Input Interaction (p-p)'s handle
start Input Start index
end Input End index
block Output Interaction (p-p)'s handle shortened to start-end range

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

PW_ERROR_code_t PW_INTERACTION_PP_free(PW_INTERACTION_PP_t interactions)

216 Chapter 3. API Reference


SDK Manual, Release 8.0.0

Arguments

Argument I/O Description


interactions Input Interaction (p-p)'s handle

Description

Frees the memory of Interaction (p-p).

3.12.3 Multi Thread

Multi Thread Support for Interactions between Particles

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:

// Callback function to compute the interaction between particles i and j


typedef void (*CALLBACK_t)(int64_t i, int64_t j, void * data);

PW_ERROR_code_t
interaction_pp_multithread(PW_PARTICLES_t particles, CALLBACK_t callback, void *␣
˓→data)

(continues on next page)

3.12. Interaction (p-p) 217


SDK Manual, Release 8.0.0

(continued from previous page)


{
PW_ERROR_code_t r;
PW_INTERACTION_PP_t source;

/*
* 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;

PW_INTERACTION_PP_t * table = (PW_INTERACTION_PP_t*) malloc(sizeof(PW_


˓→ INTERACTION_PP_t) * count);
if (table == NULL) {
goto END_0;
}
memset(table, 0, sizeof(PW_INTERACTION_PP_t) * count);

for (size_t i = 0; i < count; i++) {


size_t start = unit * i;
size_t end = unit * (i + 1);
if (end > max_block_count) {
end = max_block_count;
}

r = PW_INTERACTION_PP_create_block(source, start, end, &


˓→ table[i]);
if (r != PW_ERROR_no_error) {
goto END_1;
}
(continues on next page)

218 Chapter 3. API Reference


SDK Manual, Release 8.0.0

(continued from previous page)


}

/*
* 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

for (size_t jj = 0; jj < a.count; jj++) {


int64_t j = a.peers[jj]; // Index of particle j
if (i == j) {
continue;
}

// Interaction of particles i and j


callback(i, j, data);
}
}

// Multi Thread <----


}

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)

3.12. Interaction (p-p) 219


SDK Manual, Release 8.0.0

(continued from previous page)

END_0:
PW_INTERACTION_PP_free(source);
return r;
}

3.13 Solver

3.13.1 Data Structure

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

PW_ERROR_code_t PW_SOLVER_get_current_step(PW_SOLVER_t solver, int *step)

220 Chapter 3. API Reference


SDK Manual, Release 8.0.0

Arguments

Argument I/O Description


solver Input Solver's handle
step Output Current step number

Description

Gets Solver's current step number.

PW_SOLVER_get_current_time

PW_ERROR_code_t PW_SOLVER_get_current_time(PW_SOLVER_t solver, double *time)

Arguments

Argument I/O Description


solver Input Solver's handle
time Output Current time

Description

Gets Solver's current time.

PW_SOLVER_get_delta_time

PW_ERROR_code_t PW_SOLVER_get_delta_time(PW_SOLVER_t solver, double *time)

Arguments

Argument I/O Description


solver Input Solver's handle
time Output Time step

3.13. Solver 221


SDK Manual, Release 8.0.0

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

PW_ERROR_code_t PW_SOLVER_get_finish_time(PW_SOLVER_t solver, double *time)

Arguments

Argument I/O Description


solver Input Solver's handle
time Output Analysis end time

Description

Gets Solver's analysis end time.

PW_SOLVER_set_delta_time

PW_ERROR_code_t PW_SOLVER_set_delta_time(PW_SOLVER_t solver, double time)

Arguments

Argument I/O Description


solver Input Solver's handle
time Input Time step

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.

222 Chapter 3. API Reference


SDK Manual, Release 8.0.0

PW_SOLVER_step

PW_ERROR_code_t PW_SOLVER_step(PW_SOLVER_t solver, int steps, PW_BOOL_t *done)

Arguments

Argu- I/O Description


ment
solver In- Solver's handle
put
steps In- Number of steps to execute. Specifying a negative value will run the analysis until the
put analysis end time is reached.
done Out- If it reaches the analysis end time, PW_BOOL_true_c is set. NULL can be specified.
put

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.

3.14 User Function

3.14.1 Data Structure

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().

3.14. User Function 223


SDK Manual, Release 8.0.0

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.

Mem- Type Description


ber
name const char * User Function's name
kernel const char * Kernel whose User Function needs to be set
point PW_CALL_POINT_t Call position of User Function (PW_CALL_POINT_t)
user_function
PW_USER_FUNCTION_callback_t
Pointer to a function that performs actual processing of User Func-
tion (PW_USER_FUNCTION_callback_t).
user_data void * Data passed as an argument of user_function
in- PW_USER_FUNCTION_arrays_t
Input physical quantities
put_arrays
out- PW_USER_FUNCTION_arrays_t
Output physical quantities
put_arrays

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.

Member Type Description


count int Number of array names
arrays const PW_USER_FUNCITON_array_t * Array of array names

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.

Member Type Description


owner PW_ARRAY_OWNER_t Array's owner
name const char * Array name

224 Chapter 3. API Reference


SDK Manual, Release 8.0.0

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.

typedef void (*PW_USER_FUNCTION_callback_t)(PW_SESSION_t session, PW_CALL_PHASE_


˓→t phase, void * user_data)

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.14. User Function 225


SDK Manual, Release 8.0.0

3.15 Model

3.15.1 Data Structure

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

Name Type Description


type PW_TRIANGLES_type_t
Polygon representation method (PW_TRIANGLES_type_t)
face_count
size_t Number of triangles
ver- size_t Number of vertices
tex_count
ver- Vertex array. Vertex array is expressed in AOS format. That is, components for
PW_ARRAY_description_t
tex_array PW_ARRAY_description_t is 1, and size is 3 times the value of vertex_count.
in- Index array. Currently, the only possible type is PW_TRIANGLES_simple_c,
PW_ARRAY_description_t
dex_array so this member is not used.

226 Chapter 3. API Reference


SDK Manual, Release 8.0.0

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

PW_ERROR_code_t PW_MODEL_get_id(PW_MODEL_t model, int *model_id)

Arguments

Argument I/O Description


model Input Model's handle
model_id Output ID

Description

Gets the ID.

3.15. Model 227


SDK Manual, Release 8.0.0

PW_MODEL_get_type

PW_ERROR_code_t PW_MODEL_get_type(PW_MODEL_t model, PW_MODEL_type_t *type)

Arguments

Argument I/O Description


model Input Model's handle
type Output Model type

Description

Gets the type of model.

PW_MODEL_get_path

PW_ERROR_code_t PW_MODEL_get_path(PW_MODEL_t model, PW_STRING_t *path)

Arguments

Argument I/O Description


model Input Model's handle
path Output Path. After use, it is necessary to free memory with PW_STRING_free().

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

PW_ERROR_code_t PW_MODEL_get_absolute_path(PW_MODEL_t model, PW_STRING_t *path)

228 Chapter 3. API Reference


SDK Manual, Release 8.0.0

Arguments

Argument I/O Description


model Input Model's handle
path Output Path. After use, it is necessary to free memory with PW_STRING_free().

Description

Gets the absolute path of model 's geometry file.

PW_MODEL_get_triangles

PW_ERROR_code_t PW_MODEL_get_triangles(PW_MODEL_t model, PW_TRIANGLES_t *triangles)

Arguments

Argument I/O Description


model Input Model's handle
triangles Output Polygon representation of geometry

Description

Gets the polygon representation of model.

PW_MODEL_load

PW_ERROR_code_t PW_MODEL_load(PW_MODEL_t model)

Arguments

Argument I/O Description


model Input Model's handle

3.15. Model 229


SDK Manual, Release 8.0.0

Description

Reads the model file of model. Blocks until the loading is complete.

PW_MODEL_import_to_project

PW_ERROR_code_t PW_MODEL_import_to_project(PW_MODEL_t model)

Arguments

Argument I/O Description


model Input Model's handle

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

3.16.1 Data Structure

Type Description
PW_PARAMETERS_t Parameters' handle
PW_PARAMETERS_type_t Parameters' type

230 Chapter 3. API Reference


SDK Manual, Release 8.0.0

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

3.16. Parameters 231


SDK Manual, Release 8.0.0

PW_PARAMETERS_setup_probe

PW_ERROR_code_t PW_PARAMETERS_setup_probe(PW_PARAMETERS_t parameters, const


PW_OBJECT_array_t *array)

Arguments

Argument I/O Description


parameters Input Parameters' handle
array Input Handle array of probe_region or probe_point

Description

Associates parameters and array.


• If parameters is not PW_PARAMETERS_probe_c, an error occurs.
• If probe.mode of parameters is Point, all array content must be probe_point.
• If probe.mode of parameters is Region, all array content must be probe_region.

PW_PARAMETERS_add_pathline

PW_ERROR_code_t PW_PARAMETERS_add_pathline(PW_PARAMETERS_t parameters, int id_count,


const int64_t *id, int color)

Arguments

Argument I/O Description


parameters Input Parameters's handle
id_count Input Length of id array
id Input Array of target particle IDs
color Input Pathline color

Description

Adds pathline target particle IDs to parameters. If parameter is not PW_PARAMETERS_pathline_c, an


error is returned. “color is calculated as follows.

232 Chapter 3. API Reference


SDK Manual, Release 8.0.0

int rgb(int R, int G, int B) {


assert(0 <= R && R <= 255);
assert(0 <= G && G <= 255);
assert(0 <= B && B <= 255);
return (R << 16) | (G << 8) | (B << 0);
}

3.17 Task Queue

3.17.1 Data Structure

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

3.17. Task Queue 233


SDK Manual, Release 8.0.0

PW_TASK_QUEUE_submit_task

PW_ERROR_code_t PW_TASK_QUEUE_submit_task(PW_TASK_QUEUE_t q, PW_SCENE_t scene,


PW_OBJECT_t parameters, PW_TASK_t *task)

Arguments

Argument I/O Description


q Input Task Queue's handle
scene Input Target Scene's handle
parameters Input Parameters representing contents of task
task Output Generated Task's handle

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

PW_ERROR_code_t PW_TASK_QUEUE_run_task(PW_TASK_QUEUE_t q, PW_TASK_t task)

Arguments

Argument I/O Description


q Input Task Queue's handle
task Input Task's handle

Description

If Task is waiting, executes the task immediately. If the task is not in the waiting state, does nothing.

234 Chapter 3. API Reference


SDK Manual, Release 8.0.0

PW_TASK_QUEUE_cancel_task

PW_ERROR_code_t PW_TASK_QUEUE_cancel_task(PW_TASK_QUEUE_t q, PW_TASK_t task)

Arguments

Argument I/O Description


q Input Task Queue's handle
task Input Task's handle

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

PW_ERROR_code_t PW_TASK_QUEUE_wait(PW_TASK_QUEUE_t q, int millis)

Arguments

Argument I/O Description


q Input Task Queue's handle
millis Input Waiting time (in milliseconds)

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

PW_ERROR_code_t PW_TASK_get_state(PW_TASK_t task, PW_TASK_state_t *state)

3.17. Task Queue 235


SDK Manual, Release 8.0.0

Arguments

Argument I/O Description


task Input Task's handle
state Output State

Description

The following states are obtained in state.

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

Note: Capture is not available on Linux.

3.18.1 Data Structure

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.

236 Chapter 3. API Reference


SDK Manual, Release 8.0.0

PW_CAPTURE_grid_view_t

type PW_CAPTURE_grid_view_t
Settings for each Capture view

Name Type Description


row int Index of row
column int Index of column
scene PW_SCENE_t Scene's handle
snapshot PW_NODE_t Specify Node handle of PW_NODE_snapshot_c as view point

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

PW_ERROR_code_t PW_VIDEO_create(int rows, int columns, const PW_CAPTURE_grid_view_t


*views, PW_CAPTURE_t *capture)

Arguments

Argument I/O Description


rows Input Number of vertical views
columns Input Number of horizontal views
views Input Setting information of each view
capture Output Capture's handle

3.18. Capture 237


SDK Manual, Release 8.0.0

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

PW_ERROR_code_t PW_VIDEO_execute(PW_CAPTURE_t capture)

Arguments

Argument I/O Description


capture Input Capture's handle

Description

Executes the video output.

PW_VIDEO_get_output_path

PW_ERROR_code_t PW_VIDEO_get_output_path(PW_CAPTURE_t capture, int index, PW_STRING_t


*path)

Arguments

Argument I/O Description


capture Input Capture's handle
index Input Specify 0
path Output Video file path

Description

Gets the video file path.

238 Chapter 3. API Reference


SDK Manual, Release 8.0.0

PW_SCREENSHOT_create

PW_ERROR_code_t PW_SCREENSHOT_create(int rows, int columns, const PW_CAPTURE_grid_view_t


*views, PW_CAPTURE_t *capture)

Arguments

Argument I/O Description


rows Input Number of vertical views
columns Input Number of horizontal views
views Input Setting information of each view
capture Output Capture's handle

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

PW_ERROR_code_t PW_SCREENSHOT_execute(PW_CAPTURE_t capture)

Arguments

Argument I/O Description


capture Input Capture's handle

Description

Executes the screenshot generation.

PW_CAPTURE_free

PW_ERROR_code_t PW_CAPTURE_free(PW_CAPTURE_t *data)

3.18. Capture 239


SDK Manual, Release 8.0.0

Arguments

Argument I/O Description


data Input PW_CAPTURE_t to release

Description

Releases the memory of PW_CAPTURE_t created with PW_VIDEO_create() or


PW_SCREENSHOT_create().

3.19 Filter

3.19.1 Data Structure

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

PW_ERROR_code_t PW_FILTER_apply(PW_FILTER_t filter, PW_PARTICLES_t particles, const char


*name, PW_MEMORY_type_t memory, const void
*true_value, const void *false_value)

240 Chapter 3. API Reference


SDK Manual, Release 8.0.0

Arguments

Argument I/O Description


filter Input Handle
particles Input Target particles
name Input Array of results
memory Input Specify whether calculation is performed by CPU or GPU.
true_value Input The value to be set in the array when the condition is satisfied.
false_value Input The value to be set in the array when the condition is NOT satisfied.

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

PW_ERROR_code_t PW_FILTER_free(PW_FILTER_t filter)

Arguments

Argument I/O Description


filter Input Handle

3.19. Filter 241


SDK Manual, Release 8.0.0

Description

Frees the memory used by Filter.

3.20 String

3.20.1 Data Structure

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

242 Chapter 3. API Reference


SDK Manual, Release 8.0.0

PW_STRING_set_codepage

PW_ERROR_code_t PW_STRING_set_codepage(PW_CODEPAGE_t codepage)

Arguments

Arguments I/O Description


codepage Input Code page

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

PW_ERROR_code_t PW_STRING_from_mbs(const char *s, PW_STRING_t *string)

Arguments

Arguments I/O Description


s Input Multi-byte string
string Output String handle

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().

3.20. String 243


SDK Manual, Release 8.0.0

PW_STRING_from_wcs

PW_ERROR_code_t PW_STRING_from_wcs(const wchar_t *s, PW_STRING_t *string)

Arguments

Arguments I/O Description


s Input Wide character string
string Output String handle

Description

Creates a string object from a wide character string.

PW_STRING_get_mbs

const char *PW_STRING_get_mbs(PW_STRING_t string)

Arguments

Arguments I/O Description


string Input String handle

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

const wchar_t *PW_STRING_get_wcs(PW_STRING_t string)

244 Chapter 3. API Reference


SDK Manual, Release 8.0.0

Arguments

Argument I/O Description


string Input String handle

Description

Converts a string object to a wide character string.

PW_STRING_free

const wchar_t *PW_STRING_free(PW_STRING_t string)

Arguments

Argument I/O Description


string Input String handle

Description

Frees the memory of a string object.

3.21 Miscellaneous

3.21.1 signature

The following structures have a member called signature:


• PW_PROPERTY_t
• PW_CSTRING_array_t
• PW_OBJECT_array_t
• PW_VALUE_array_t
• PW_ARRAY_description_t
When memory allocation occurs in the SDK, a special value is set for signature. This member is used when
memory release functions determine whether an illegal structure has been passed.
When assigning a structure on the user side, signature must be set to 0.

3.21. Miscellaneous 245


SDK Manual, Release 8.0.0

3.21.2 Data Structure

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()

246 Chapter 3. API Reference


SDK Manual, Release 8.0.0

Name Type Description


signature int signature
count int Number of ASCII character strings
strings char ** Array of ASCII strings

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().

Name Type Description


signature int signature
count int objects' size
objects PW_OBJECT_t * PW_OBJECT_t array

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().

Name Type Description


signature int signature
type PW_VALUE_type_t Array type
count size_t Array length
bytes size_t Number of bytes in array
objects void * Array's data

PW_CONFIGURATION_t

type PW_CONFIGURATION_t
Information on the SDK

Name Type Description


ma- int Major version
jor_version
mi- int Minor version
nor_version
patch_level int Patch level
scalar_size int The value of sizeof(pw_scalar). It is 8 if the SDK is a double precision version,
4 if the SDK is a single precision version.

3.21. Miscellaneous 247


SDK Manual, Release 8.0.0

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;
}

int v0 = PW_MAJOR_VERSION * 100 + PW_MINOR_VERSION;


int v1 = c.major_version * 100 + c.minor_version ;
if (v1 > v0) {
return PW_BOOL_false_c;
}
if (c.scalar_size != sizeof(pw_scalar)) {
return PW_BOOL_false_c;
}
return PW_BOOL_true_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

248 Chapter 3. API Reference


SDK Manual, Release 8.0.0

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

PW_ERROR_code_t PW_CONFIGURATION_get(PW_CONFIGURATION_t *config)

Arguments

Argument I/O Description


config Output SDK information

Description

Gets SDK information. See PW_CONFIGURATION_t for usage examples.

PW_CONFIGURATION_enumerate_gpu

PW_ERROR_code_t PW_CONFIGURATION_enumerate_gpu(PW_CSTRING_array_t *names)

Arguments

Argument I/O Description


names Output Array of GPU name

3.21. Miscellaneous 249


SDK Manual, Release 8.0.0

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

const char *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

PW_ERROR_code_t PW_LOG_write(PW_LOG_level_t level, const wchar_t *string)

Arguments

Argument I/O Description


level Input Log level
string Input Log message

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

250 Chapter 3. API Reference


SDK Manual, Release 8.0.0

PW_LOG_set_level

PW_ERROR_code_t PW_LOG_set_level(PW_LOG_level_t level)

Arguments

Argument I/O Description


level Input Log level (PW_LOG_level_t)

Description

Sets the log level.

PW_CONSTANT_get_wcs

const wchar_t *PW_CONSTANT_get_wcs(int value)

Arguments

Argument I/O Description


value Input Constant value

Description

Converts a constant value such as PW_NODE_type_t and PW_MATERIAL_type_t to a string.

PW_CSTRING_array_free

PW_ERROR_code_t PW_CSTRING_array_free(PW_CSTRING_array_t *data)

Arguments

Argument I/O Description


data Input PW_CSTRING_array_t to free

3.21. Miscellaneous 251


SDK Manual, Release 8.0.0

Description

Frees the memory of PW_CSTRING_array_t, returned by the following APIs:


• PW_SESSION_start()
• PW_SESSION_enumerate_combinations()
• PW_OBJECT_enumerate_properties()
• PW_ARRAYS_enumerate_names()

PW_OBJECT_array_free

PW_ERROR_code_t PW_OBJECT_array_free(PW_OBJECT_array_t *data)

Arguments

Argument I/O Description


data Input PW_OBJECT_array_t to free

Description

Frees the memory used by PW_OBJECT_array_t, returned by PW_SESSION_enumerate_objects().

PW_PROPERTY_free

PW_ERROR_code_t PW_PROPERTY_free(PW_PROPERTY_t *data)

Arguments

Argument I/O Description


data Input PW_PROPERTY_t to free

252 Chapter 3. API Reference


SDK Manual, Release 8.0.0

Description

Frees the memory used by PW_PROPERTY_t, returned by PW_OBJECT_get_property().

PW_ANIMATION_value_free

PW_ERROR_code_t PW_ANIMATION_value_free(PW_ANIMATION_value_t *data)

Arguments

Argument I/O Description


data Input PW_ANIMATION_value_t to release

Description

Frees the memory of PW_ANIMATION_value_t obtained by PW_NODE_get_animation_value().

3.22 User Module

3.22.1 User-Defined Functions

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

PW_ERROR_code_t PW_MODULE_initialize(PW_SESSION_t session)

3.22. User Module 253


SDK Manual, Release 8.0.0

Arguments

Argument I/O Description


session Input PW_SESSION_t created by Solver

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

PW_ERROR_code_t PW_MODULE_terminate(PW_SESSION_t session)

Arguments

Argument I/O Description


session Input PW_SESSION_t

Description

Performs termination processes, such as freeing the memory allocated by Plugin.

254 Chapter 3. API Reference


CHAPTER

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.

4.1 Related API

• 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()

4.2 How to Add

Move to the Particleworks configuration directory.

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 txt 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.

4.3.2 Example of How to Write

# comment
ext.test1=test 1
ext.test2=test 2
ext.test3=test 3
ext.test4=test 4

4.3.3 Format

• The # at the beginning of the line represents a comment.


• Specify the display name of the property in the form Property=Text.
– Property is the property name defined by json file.

4.4 json file

4.4.1 Filename

Make the file extension .json. All files matching the conditions are read.
• e.g., properties.json

256 Chapter 4. Adding Properties


SDK Manual, Release 8.0.0

4.4.2 Example of How to Write

{
"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. json file 257


SDK Manual, Release 8.0.0

(continued from previous page)


}
]
}

4.4.3 Format

Name Type Description


ver- in- Specify the version of the format. If it is not 1, an error occurs.
sion te-
ger
nodes ar- List of nodes to be changed.
ray
type string Node type
prop- ar- List of properties to add
erties ray
namestring Property name. The name must start with ext..
typestring Property type
ini- Specifies the initial value. Refer to Property type for the description method.
tial
choices
ar- Specify an option if type is enum.
ray
tables ar- List of interaction settings to add.
ray
name string Name of interaction setting. The name must start with ext..
pairs ar- Physical property pair that can be combined. Lists the name pairs described in Physical
ray property type in array format. Refer to Example of How to Write, for an example.
self booleanSpecify whether values can be held between the same physical properties.
de- num- Default value
fault ber

258 Chapter 4. Adding Properties


SDK Manual, Release 8.0.0

Node type

Type Category Description


scene Scene Scene
input_polygon Input Polygon
input_fill Input Fill
input_domain Input Analysis domain
input_emitter Input Inlet
input_outflow Input Outlet
input_gravity Input Gravity
phys_particle_fluid Physical property Fluid particle (Fluid)
phys_particle_solid Physical property Solid particle (Solid)
phys_polygon Physical property Polygon wall (Polygon)
phys_dem Physical property Powder particle (Powder)

Property type

Type Description Type of initial value


int Integer number
boolean Boolean boolean
float Real number number
float3 Vector. The initial value is described by string like “0 0 0”. string
string String string
ref ID of another object integer
enum Enumerated type. The initial value is one of the strings in choices. string
file File string

Physical property type

Physical property Description


phys_particle_fluid Fluid particle (Fluid)
phys_particle_solid Solid particle (Solid)
phys_polygon Polygon wall (Polygon)
phys_dem Powder particle (Powder)

4.4. json file 259


SDK Manual, Release 8.0.0

260 Chapter 4. Adding Properties


CHAPTER

FIVE

FILE I/O API REFERENCE

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

5.2.1 Data Structure

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.

Name Type Description


type PW_FILE_VALUE_type_t Array’s type
ranks int 0 = Scalar, 1 = Vector, 2 = Matrix
rank_size int[2] Dimension (up to 4)
tag_count int Length of tags array
tags char ** tags array
size uint64_t Length of array

ranks and rank_size are determined by the dimension of the physical quantity represented by the array.

Type ranks rank_size[0] rank_size[1] Typical physical quantity


Scalar 0 0 0 Number Density, Pressure
Vector3 1 3 0 Position, Velocity
Matrix3x3 2 3 3 Velocity Gradient, Stress

262 Chapter 5. File I/O API Reference


SDK Manual, Release 8.0.0

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.

Name Type Description


name const char * Name : mps, dem
array_count int Length of arrays
arrays PW_TOC_array_t * Array of PW_TOC_array_t

PW_TOC_extension_t

type PW_TOC_extension_t
This is the table of contents of a result file and represents extended information.

Name Type Description


name const char * Name (up to 64 bytes)
size uint64_t Number of bytes of 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.

Name Type Description


type Parameter’s type
PW_FILE_PARAMETER_type_t
name const char * Name
u.d double Parameter value is stored in this field when type is
PW_FILE_PARAMETER_double_c
u.i int64_t Parameter value is stored in this field when type is
PW_FILE_PARAMETER_int64_c
u.v double[3] Parameter value is stored in this field when type is
PW_FILE_PARAMETER_vector3_c
u.vi int[3] Parameter value is stored in this field when type is
PW_FILE_PARAMETER_vector3i_c
u.s const char * Parameter value is stored in this field when type is
PW_FILE_PARAMETER_string_c

The followings are the parameters used in Particleworks.

5.2. Reference 263


SDK Manual, Release 8.0.0

Name Type Description


unit PW_FILE_PARAMETER_int64_c Unit system (0 = meter, 1 = millimeter)
particle size PW_FILE_PARAMETER_double_c Particle size of MPS particles
initial box min PW_FILE_PARAMETER_vector3_c Minimum of Bounding Box
initial box max PW_FILE_PARAMETER_vector3_c Maximum of Bounding Box
current box min PW_FILE_PARAMETER_vector3_c Minimum of Bounding Box
current box max PW_FILE_PARAMETER_vector3_c Maximum of Bounding Box
time PW_FILE_PARAMETER_double_c Time
delta time PW_FILE_PARAMETER_double_c Time step
particle count PW_FILE_PARAMETER_int64_c Number of particles
field count PW_FILE_PARAMETER_int64_c Number of physical quantities
fvm grid interval PW_FILE_PARAMETER_double_c Interval of FVM grid
fvm grid origin PW_FILE_PARAMETER_vector3_c Origin of FVM grid
fvm grid PW_FILE_PARAMETER_vector3i_c Resolution of FVM grid
resolution

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.

264 Chapter 5. File I/O API Reference


SDK Manual, Release 8.0.0

Name Type Description


version int This is the version of the result file. If this is 0, the format is compat-
ible with Particleworks v5.
ar- int Length of arrays
rays_count
arrays PW_TOC_arrays_t Array of PW_TOC_arrays_t
*
parame- int Length of parameters
ter_count
parameters PW_TOC_parameter_t
Array of PW_TOC_parameter_t
*
exten- int Length of extensions
sion_count
extensions PW_TOC_extension_t
Array of PW_TOC_extension_t
*

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.

Name Type Description


type PW_FILE_VALUE_type_t Type
size uint64_t Length
array.scalar void * Memory address of Scalar array
array.vector void * [4] Memory address of Vector array
array.matrix void * [4][4] Memory address of Matrix array

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().

Name Type Description


arrays const char * Name of PW_TOC_arrays_t
name const char * Name of PW_TOC_array_t
data PW_FILE_array_t Memory

5.2. Reference 265


SDK Manual, Release 8.0.0

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

266 Chapter 5. File I/O API Reference


SDK Manual, Release 8.0.0

PW_FILE_READER_open

PW_ERROR_code_t PW_FILE_READER_open(const wchar_t *path, int modes, PW_FILE_READER_t


*reader)

Arguments

Argument I/O Description


path Input Path of result file
modes Input Specify 0
reader Output Created handle

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

PW_ERROR_code_t PW_FILE_READER_close(PW_FILE_READER_t reader)

Arguments

Argument I/O Description


reader Input Handle

Description

Deletes the handle for reading the result file and frees the memory.

5.2. Reference 267


SDK Manual, Release 8.0.0

PW_FILE_READER_get_toc

PW_ERROR_code_t PW_FILE_READER_get_toc(PW_FILE_READER_t reader, PW_TOC_root_t


**toc)

Arguments

Argument I/O Description


reader Input Handle
toc Output Pointer to table-of-contents information

Description

Gets the table-of-contents information(PW_TOC_root_t) of the opened result file.

PW_FILE_READER_read_array

PW_ERROR_code_t PW_FILE_READER_read_array(PW_FILE_READER_t reader, int count, const


PW_FILE_read_t *requests)

Arguments

Argument I/O Description


reader Input Handle
count Input Length of requests
requests Input Memory for storing name and reading result of array

Description

Reads multiple arrays from the result file.


• If the file format is Particleworks v5 compatible format, it scans the entire file. Therefore, calling this
function multiple times is inefficient.
• If the file format is Particleworks v6 or later format, it reads only the part corresponding to the specified
arrays.
PW_FILE_read_t corresponds to PW_TOC_array_t. PW_FILE_read_t’s data member
(PW_FILE_array_t) and the content of PW_TOC_array_t must match.
• PW_FILE_array_t’s type must match PW_TOC_array_t’s type

268 Chapter 5. File I/O API Reference


SDK Manual, Release 8.0.0

• 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

PW_ERROR_code_t PW_FILE_READER_read_extension(PW_FILE_READER_t reader, const char


*name, size_t size, char *buffer)

Arguments

Argument I/O Description


reader Input Handle
name Input Name of extended information
size Input Number of bytes of buffer
buffer Input Address of memory reading extended information

Description

Reads the extended information from the result file.

PW_FILE_WRITER_create

PW_ERROR_code_t PW_FILE_WRITER_create(int modes, const PW_TOC_root_t *toc,


PW_FILE_WRITER_t *writer)

Arguments

Argument I/O Description


modes Input Modes
toc Input Table-of-contents information
writer Output Handle

5.2. Reference 269


SDK Manual, Release 8.0.0

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.

Name Type Dimension Description


id 64bit integer Scalar ID
position Floating-point number Vector3 Position
group_index 32bit integer Scalar Group ID

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

PW_ERROR_code_t PW_FILE_WRITER_free(PW_FILE_WRITER_t writer)

270 Chapter 5. File I/O API Reference


SDK Manual, Release 8.0.0

Arguments

Argument I/O Description


writer Input Handle

Description

Deletes the handle for writing the result file and frees the memory.

PW_FILE_WRITER_set_array

PW_ERROR_code_t PW_FILE_WRITER_set_array(PW_FILE_WRITER_t writer, const char *arrays,


const char *name, const PW_FILE_array_t *array)

Arguments

Argument I/O Description


writer Input Handle
arrays Input Name of PW_TOC_arrays_t
name Input Name of PW_TOC_array_t
array Input Memory to copy

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

PW_ERROR_code_t PW_FILE_WRITER_set_extension(PW_FILE_WRITER_t writer, const char


*name, size_t size, const void *data)

5.2. Reference 271


SDK Manual, Release 8.0.0

Arguments

Argument I/O Description


writer Input Handle
name Input Name of extended information
size Input Number of bytes of data
data Input Memory to copy

Description

Sets the content of the extended information.

PW_FILE_WRITER_write

PW_ERROR_code_t PW_FILE_WRITER_write(PW_FILE_WRITER_t writer, const wchar_t *path)

Arguments

Argument I/O Description


writer Input Handle
path Input File path

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

PW_ERROR_code_t PW_LBM_READER_open(const wchar_t *path, int modes, PW_LBM_READER_t


*reader)

272 Chapter 5. File I/O API Reference


SDK Manual, Release 8.0.0

Arguments

Argument I/O Description


path Input Path to the simulation result file.
modes Input Always to be zero.
reader Output Created handle

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

PW_ERROR_code_t PW_LBM_READER_create_from_scene(PW_OBJECT_t scene, int modes,


PW_LBM_READER_t *reader)

Arguments

Arguments I/O Description


scene Input Scene’s handle
modes Input Always zero
reader Output Created handle

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

PW_ERROR_code_t PW_LBM_READER_close(PW_LBM_READER_t reader)

5.2. Reference 273


SDK Manual, Release 8.0.0

Arguments

Argument I/O Description


reader Input Handle

Description

Removes a handle for LBM result file reading and frees memory.

PW_LBM_READER_get_header_json

PW_ERROR_code_t PW_LBM_READER_get_header_json(PW_LBM_READER_t reader, int size, char


*buffer, int *rsize)

Arguments

Argument I/O Description


size Input Size of buffer
buffer Output Memory to retrieve the string (can be NULL)
rsize Output Required size of buffer (can be NULL).

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.

JSON Key Description Unit


level_count Level count of the grid refinement
interval Cell width of the coarsest grid. m
origin Origin of the grid. m
resolution Resolution of the coarsest grid.
density Density of gas k𝑔/𝑚3
viscosity Kinematic viscosity of gas 𝑚2 /𝑠

274 Chapter 5. File I/O API Reference


SDK Manual, Release 8.0.0

PW_LBM_READER_get_toc

PW_ERROR_code_t PW_LBM_READER_get_toc(PW_LBM_READER_t reader, PW_TOC_arrays_t *toc)

Arguments

Argument I/O Description


reader Input Handle
toc Output Table of contents

Description

Get the list of physical values (PW_TOC_arrays_t) of the LBM grid in the simulation result file.

PW_LBM_READER_sample

PW_ERROR_code_t PW_LBM_READER_sample(PW_LBM_READER_t reader, const char *name, const


PW_FILE_array_t *point, const PW_FILE_array_t
*result)

Arguments

Argument I/O Description


reader Input Handle
name Input Name of the physical value
point Input Array of the coordinates
result Output Array of the interpolated values

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.2. Reference 275


SDK Manual, Release 8.0.0

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

The example includes picojson.h.

Copyright 2009-2010 Cybozu Labs, Inc.


Copyright 2011-2014 Kazuho Oku
All rights reserved.

Redistribution and use in source and binary forms, with or without


modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,


this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,


this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

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.

276 Chapter 5. File I/O API Reference


CHAPTER

SIX

PYTHON REFERENCE

6.1 Usage

1. Add the directory containing pwpy to sys.path.


• bin directory of Particleworks if the platform is Windows.
• lib directory of Particleworks if the platform is Linux.
2. Execute import pwpy.
There are two execution methods of Python scripts : CUI execution and GUI execution

Note: pwpy has only been tested with the Python bundled with Particleworks. Other versions of Python
may not work properly.

6.1.1 CUI execution

Run the command python3 with a Python script.

$ python3 script.py

• sys.path needs to contain the directory containing pwpy.


– bin directory of Particleworks if the platform is Windows.
– lib directory of Particleworks if the platform is Linux.
• Execute import pwpy.
For example, a call to the function do_something(scene) for Scene must go through Project.

import sys
sys.path.append('/path/to/pwpy')

import pwpy as PW

(continues on next page)

277
SDK Manual, Release 8.0.0

(continued from previous page)


def do_something(scene):
pass

if __name__ == '__main__':
session = PW.Session()
project = session.open_project('/path/to/project')
for scene in project.scenes:
do_something(scene)

6.1.2 GUI execution

Drag & drop a Python script to the GUI.


• Python must be enabled in the GUI setting.
• sys.path is already setup by Particleworks.
• Execute import pwpy.
• __name__ contains "Particleworks".
When calling the function do_something(scene) for Scene, it is possible to go through Project as in CUI
execution. Or Scene with GUI focus can be obtained as follows.

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.

6.1.3 Notes on the bundled Python

Python is bundled in the opt directory of Particleworks.

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.

278 Chapter 6. Python Reference


SDK Manual, Release 8.0.0

When running the bundled Python on Linux, note the following


• Python is built to use shared libraries. To run python3 from the command line, add /path/to/
particleworks/opt/python/lib to the environment variable LD_LIBRARY_PATH.
• Python’s ssl module is linked with the bundled OpenSSL. If your system does not have OpenSSL
1.1.1 installed and you are using functions that require the ssl module, such as pip, add /path/to/
particleworks/opt/openssl/lib to the environment variable LD_LIBRARY_PATH

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.

6.2.1 Object Type

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

6.2. Constants 279


SDK Manual, Release 8.0.0

• OBJECT_input
• OBJECT_result_file

6.2.2 Value Type

PW_VALUE_type_t
• VALUE_unknown
• VALUE_char
• VALUE_short
• VALUE_int
• VALUE_long
• VALUE_float
• VALUE_double

6.2.3 Node Type

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

280 Chapter 6. Python Reference


SDK Manual, Release 8.0.0

• 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

6.2. Constants 281


SDK Manual, Release 8.0.0

6.2.4 Material Type

PW_MATERIAL_type_t
• MATERIAL_unknown
• MATERIAL_fluid
• MATERIAL_solid
• MATERIAL_powder
• MATERIAL_inflow
• MATERIAL_polygon

6.2.5 Widget Type

PW_WIDGET_type_t
• WIDGET_unknown
• WIDGET_colorbar
• WIDGET_timelabel
• WIDGET_axis

6.2.6 Property Type

PW_PROPERTY_type_t
• PROPERTY_unknown
• PROPERTY_bool
• PROPERTY_int
• PROPERTY_scalar
• PROPERTY_string
• PROPERTY_vector3
• PROPERTY_vector3i
• PROPERTY_array

282 Chapter 6. Python Reference


SDK Manual, Release 8.0.0

6.2.7 Log Level

PW_LOG_level_t
• LOG_verbose
• LOG_debug
• LOG_info
• LOG_warning
• LOG_error
• LOG_fatal

6.2.8 Scene Path

PW_SCENE_PATH_t
• SCENE_PATH_root_dir
• SCENE_PATH_result_dir
• SCENE_PATH_scene_file

6.2.9 Mesh Format

PW_MESH_format_t
• MESH_format_auto
• MESH_format_stl
• MESH_format_stl_text
• MESH_format_stl_binary
• MESH_format_obj
• MESH_format_nastran

6.2.10 Task State

PW_TASK_state_t
• TASK_state_unknown
• TASK_state_wait
• TASK_state_execution
• TASK_state_postprocess
• TASK_state_success

6.2. Constants 283


SDK Manual, Release 8.0.0

• TASK_state_cancel
• TASK_state_fail

6.2.11 Animation Type

PW_ANIMATION_type_t
• ANIMATION_keyframe
• ANIMATION_script

6.2.12 Animation Unit

PW_ANIMATION_unit_t
• ANIMATION_unit_unknown
• ANIMATION_unit_position
• ANIMATION_unit_velocity
• ANIMATION_unit_angle
• ANIMATION_unit_rpm
• ANIMATION_unit_rps

6.2.13 Phys Detail

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

284 Chapter 6. Python Reference


SDK Manual, Release 8.0.0

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

6.2. Constants 285


SDK Manual, Release 8.0.0

• PARAMETERS_pathline

6.2.16 Models

PW_MODEL_type_t
• MODEL_unknown
• MODEL_external_file
• MODEL_internal_file

6.2.17 Rotation Type

PW_ROTATION_type_t
• ROTATION_unknown
• ROTATION_normal
• ROTATION_axis

6.2.18 Error Code

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

286 Chapter 6. Python Reference


SDK Manual, Release 8.0.0

• ERROR_runtime
• ERROR_unknown

6.3 Functions

6.3.1 Normal 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

6.3.2 Functions (Only available in GUI)

Following functions raise an error if called in CUI execution.


message_info(text)
Shows an information dialog.
Parameters
text (str) – Message text

6.3. Functions 287


SDK Manual, Release 8.0.0

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)

288 Chapter 6. Python Reference


SDK Manual, Release 8.0.0

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

6.4. Class 289


SDK Manual, Release 8.0.0

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.

290 Chapter 6. Python Reference


SDK Manual, Release 8.0.0

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. Class 291


SDK Manual, Release 8.0.0

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)

# Set particle interval to 1.0


scene['pre.initialDistance'] = 1.0

# Add 5 to the location.x of all polygons


for node in scene.nodes:
if node.node_type == pwpy.NODE_polygon:
p = node['transform.location']
assert len(p) == 3
(continues on next page)

292 Chapter 6. Python Reference


SDK Manual, Release 8.0.0

(continued from previous page)


x = p[0]
y = p[1]
z = p[2]
node['transform.location'] = (x + 5, y, z)

The following table shows the correspondence between a property type (PW_PROPERTY_type_t) and a
Python type.

PW_PROPERTY_type_t Python Type


PW_PROPERTY_bool_c bool
PW_PROPERTY_int_c int
PW_PROPERTY_scalar_c float
PW_PROPERTY_string_c str
PW_PROPERTY_vector3i_c int sequence (length 3)
PW_PROPERTY_vector3_c float sequence (length 3)
PW_PROPERTY_array_c float sequence (any length)
PW_PROPERTY_string_array_c str sequence (any length)

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()

6.4. Class 293


SDK Manual, Release 8.0.0

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()

294 Chapter 6. Python Reference


SDK Manual, Release 8.0.0

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

6.4. Class 295


SDK Manual, Release 8.0.0

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()

296 Chapter 6. Python Reference


SDK Manual, Release 8.0.0

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

6.4. Class 297


SDK Manual, Release 8.0.0

• percent (bool) – Refer to PW_NODE_adjust_dimension().


• margin (float) – Refer to PW_NODE_adjust_dimension().
set_k_epsilon(boundary)
PW_NODE_set_k_epsilon()
Parameters
boundary (Node) – FVM velocity boundary
add_result_view()
PW_NODE_add_result_view()
node_type
PW_NODE_get_type(), Node Type
Type
int
parent
PW_NODE_get_parent(), PW_NODE_set_parent()
Type
Node or None
id
PW_NODE_get_object_id()
Type
int
group_id
PW_NODE_get_group_id()
Type
int
material
PW_NODE_get_material(), PW_NODE_set_material()
Type
Material or None
model
PW_NODE_get_model(), PW_NODE_set_model()
Type
Model or None
matrix
PW_NODE_get_transform_matrix(), PW_NODE_set_transform_matrix()
Type
[float] * 16

298 Chapter 6. Python Reference


SDK Manual, Release 8.0.0

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. Class 299


SDK Manual, Release 8.0.0

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

300 Chapter 6. Python Reference


SDK Manual, Release 8.0.0

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

6.4.10 Arrays, ScalarArray, Vector3Array, Matrix3x3Array

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

6.4. Class 301


SDK Manual, Release 8.0.0

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.

with MappingArrays(node) as arrays:


for a in arrays:
print(a.name)

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__()

302 Chapter 6. Python Reference


SDK Manual, Release 8.0.0

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)

xx, xy, xz, yx, yy, yz, zx, zy, zz


Access to components.
Type
ScalarArray
norm
Norm. Available only if this array belongs to Arrays returned by Filter.run(). Returns None
otherwise.
Type
ScalarArray or None

6.4. Class 303


SDK Manual, Release 8.0.0

6.4.11 ResultFile

class ResultFile
Corresponds to PW_RESULT_FILE_t. Normally used in a with statement.

with ResultFile(scene, index) as f:


arrays = f.arrays('MPS')
for a in arrays:
print(a.name)

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

304 Chapter 6. Python Reference


SDK Manual, Release 8.0.0

6.4.12 Material, Colormap, Widget, Settings

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. Class 305


SDK Manual, Release 8.0.0

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

6.4.14 TaskQueue, Task

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()

306 Chapter 6. Python Reference


SDK Manual, Release 8.0.0

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

6.4.15 ScreenShot, Video

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

6.4. Class 307


SDK Manual, Release 8.0.0

• columns (int) – Number of columns


• views (list[CaptureView]) – List of CaptureView (the length is rows x
columns)
output_path(index)
PW_VIDEO_get_output_path()
Parameters
index (int) – Always zero
execute()
PW_VIDEO_execute()
properties
Gets list of property names
Type
list[str]
class CaptureView
PW_CAPTURE_grid_view_t
row
Row index
Type
int
column
Column index
Type
int
scene

Type
Scene
node

Type
Node
class Camera
PW_NODE_t
Camera(node)

Parameters
node (Node) – Camera (NODE_CAMERA) or Snapshot (NODE_snapshot)

308 Chapter 6. Python Reference


SDK Manual, Release 8.0.0

fit_box(width, height, min, max)


PW_CAMERA_fit_box()
Parameters
• width (int) – Image width (in pixels)
• height (int) – Image height (in pixels)
• min ((float, float, float)) – Lower coordinates of the bounding box
• max ((float, float, float)) – Upper coordinates of the bounding box
fit_nodes(width, height, nodes)
Corresponds to PW_CAMERA_fit_box(). Specify list of Node to nodes.
PW_CAMERA_fit_box() is called for Axis Aligned Box of nodes.
Parameters
• width (int) – Image width (in pixels)
• height (int) – Image height (in pixels)
• nodes (list[Node]) – List of Node

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

6.4. Class 309


SDK Manual, Release 8.0.0

• 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 (<, <=, ==, >=, >).

# Extracts MPS particles whose ID is 15.


a = filter.run('MPS', i == 15)

# Extracts MPS particles whose pressure is greater than 100.


a = filter.run('MPS', p > 100)

Components of Vector3 type can be accessed with .x, .y or .z. Length can be accessed with .norm.

# Extracts MPS particles whose Z components of velocity is smaller than -10.


a = filter.run('MPS', v.z < -10)

# Extracts MPS particles whose velocity is smaller than 10.


a = filter.run('MPS', v.norm < 10)

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.

# Extracts MPS particles whose xx component of velocity gradient is larger than␣


˓→1.

a = filter.run('MPS', L.xx > 1)

# Extracts MPS particles whose norm of velocity gradient is larger than 1.


a = filter.run('MPS', L.norm > 1)

Conditions can be combined by logical operators (&, |).

# Extracts particles whose ID is 5, 23, or 27.


a = filter.run('MPS', (i == 5) | (i == 23) | (i == 27))

(continues on next page)

310 Chapter 6. Python Reference


SDK Manual, Release 8.0.0

(continued from previous page)


# Extracts particles whose velocity is between 5 and 15.
a = filter.run('MPS', (v.norm > 5) & (v.norm < 15))

Expressions to logical operators msut be enclosed in parentheses.

# Following condition will result in error.


a = filter.run('MPS', v.norm > 5 & v.norm < 15)

Note the followings:


• The left side of the comparison operator needs to be a field while the right side must be a number.
Comparison between fields is not poissible.
• NOT operator is not supported.
• Arithmetic operators (+, -, *, / etc.) are not supported.
Filter.run() returns an Arrays object. Each particle can be accessed as followed.

# Obtain all MPS particles


a = pwpy.Filter(scene).run('MPS', None)
i = a['id'] # Particle ID
v = a['velocity'] # Velocity
n = len(i) # Number of particles

# (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])

# (2) Do the same via Vector3


for k in len(n):
v_k = v[k] # Vector3
if v_k.z < -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. Class 311


SDK Manual, Release 8.0.0

xx, xy, xz, yx, yy, yz, zx, zy, zz


Component values.
Type
float

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

312 Chapter 6. Python Reference


SDK Manual, Release 8.0.0

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.

6.4. Class 313


SDK Manual, Release 8.0.0

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())

6.4.19 LBM Reader

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()

314 Chapter 6. Python Reference


SDK Manual, Release 8.0.0

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)

6.5 Sample : Running simulation

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)

6.5. Sample : Running simulation 315


SDK Manual, Release 8.0.0

(continued from previous 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()

def create_project(self, project_path):


# Project
if os.path.isdir(project_path):
shutil.rmtree(project_path)

self.project = self.session.open_project(project_path, True)


self.scene = self.project.scenes[0]
self.scene.activate()

# 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)

316 Chapter 6. Python Reference


SDK Manual, Release 8.0.0

(continued from previous page)


print('running preprocess')

# Create task parameters


p = self.scene.create_parameters(PW.PARAMETERS_preprocess)
p['cpu'] = 2

# Submit task & wait


q = self.session.task_queue
t = q.submit(self.scene, p)
q.wait(-1)
if t.state != PW.TASK_state_success:
print('preprocess failed')
sys.exit(1)
print('preprocess complete')

def simulation(self):
print('running simulation')

# Create task parameters


p = self.scene.create_parameters(PW.PARAMETERS_simulation)
p['cpu'] = 1

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)

# Wait until 50 frames, then cancel the task


n = 0
while n < 50:
q.wait(1000)
n = len(self.scene.result_files)
print('simulation : %d frames complete' % n)
q.cancel(t)
q.wait(-1)

def create_video(self):
print('generating video')
scene = self.scene

(continues on next page)

6.5. Sample : Running simulation 317


SDK Manual, Release 8.0.0

(continued from previous page)


# View size
w = 500
h = 500

# 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()

6.6 Sample : Postprocessing

This sample shows how to run a series of postprocessing.


1. Open an existing project
2. Set colormap
3. Run postprocessing
• Surface generation

318 Chapter 6. Python Reference


SDK Manual, Release 8.0.0

• 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)

6.6. Sample : Postprocessing 319


SDK Manual, Release 8.0.0

(continued from previous page)


self.scene.current_colormap = c

# 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)

320 Chapter 6. Python Reference


SDK Manual, Release 8.0.0

(continued from previous page)


p['probe.mode'] = 'Region'
p['fileName'] = 'probe.csv'
p.setup_probe(r0,r1)
self.submit(p)

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)

def submit(self, p):


p['frameAll'] = True
if 'targetAll' in p.properties:
p['targetAll'] = True

q = self.session.task_queue
t = q.submit(self.scene, p)
q.run(t)

states = [PW.TASK_state_success, PW.TASK_state_fail, PW.TASK_state_


˓→cancel]

while not t.state in states:


q.wait(100)
self.session.wait(0)

if t.state != PW.TASK_state_success:
error_exit('Task failed')

def model_id(self, name):


path = os.path.join(self.model_path, name)
(continues on next page)

6.6. Sample : Postprocessing 321


SDK Manual, Release 8.0.0

(continued from previous page)


m = self.project.read_model_file(path)
return m.id

if __name__ == '__main__':
p = PostProc()
p.execute()

6.7 Sample : Filter

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

(continues on next page)

322 Chapter 6. Python Reference


SDK Manual, Release 8.0.0

(continued from previous page)


p = a['position']
v = a['velocity']
index = numpy.argsort(v.norm.numpy())
for i in index[-3:]:
node = scene.create_node(PW.NODE_measure_point)
node['transform.location'] = p[i]
node['material.text'] = 'id=%d, v=(%.1f , %.1f , %.1f )' % (id[i], v.x[i],␣
˓→v.y[i], v.z[i])

def main():
session = PW.Session()
scene = session.active_scene
if scene != None:
create_markup(scene)

if 'Particleworks' in __name__:
main()

6.8 Sample : matplotlib

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)

import matplotlib.pyplot as plt


plt.clf()
f = plt.figure(figsize=(12.0, 4.0))
a = f.add_subplot(1,2,1)
a.hist(arrays['velocity'].norm, bins=50, edgecolor='black', color='lightblue
(continues on next page)

6.8. Sample : matplotlib 323


SDK Manual, Release 8.0.0

(continued from previous page)


˓→ ')
a.set_xlabel('velocity [m/s]')
a.set_ylabel('# of particles')

a = f.add_subplot(1,2,2)
a.hist(arrays['velocity_gradient'].norm, bins=50, edgecolor='black', color=
˓→'mistyrose')

a.set_xlabel('velocity gradient [1/s]')


a.set_ylabel('# of particles')

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')

import matplotlib.pyplot as plt


plt.add_plot([0,1], [0,1])
plt.show_plot()

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 matplotlib.pyplot as plt


plt.add_plot([0,1], [0,1])
pwpy.show_plot()

324 Chapter 6. Python Reference


SDK Manual, Release 8.0.0

The above has been tested with matplotlib v3.3.3.

6.9 Sample : Input dialog

This sample does the followings:


• Displays an input dialog using Input
• Displays a message by message_info()
• Displays velocities of probe objects arranged in a grid
GUI execution is expected.

Dialog Message Probe results

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)

6.9. Sample : Input dialog 325


SDK Manual, Release 8.0.0

(continued from previous page)


x = a.add_integer('# of X Grid', 1)
y = a.add_integer('# of Y Grid', 1)
z = a.add_integer('# of Z Grid', 1)
if not a.ask():
return False
self.grid = (x.get(), y.get(), z.get())
return True

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)

326 Chapter 6. Python Reference


SDK Manual, Release 8.0.0

(continued from previous page)


node['probe.point.y'] = p[1]
node['probe.point.z'] = p[2]
a.append(node)
probe = self.scene.create_parameters(PW.PARAMETERS_probe)
probe['probe.mode'] = 'Point'
probe['probe.range'] = 3
probe['frameStart'] = frame
probe['frameEnd'] = frame
probe['targetAll'] = True
probe['fieldArray'] = ['velocity']
probe['fileName'] = 'probe.csv'
probe.setup_probe(*a)
self.probe = probe

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)

6.9. Sample : Input dialog 327


SDK Manual, Release 8.0.0

(continued from previous page)


node = self.scene.create_node(PW.NODE_measure_point)
node['transform.location'] = (px, py, pz)
node['material.text'] = '%.1f ' % math.sqrt(vx * vx + vy * vy␣
˓→+ vz * vz)
valid += 1
PW.message_info('Markups created : %d / %d' % (valid, len(self.points)))

def main():
session = PW.Session()
scene = session.active_scene
if scene == None:
return
g = GridProbe(session, scene)
g.run()

if 'Particleworks' in __name__:
main()

6.10 Sample : Simulation Result File

In this sample, a new field is added to the simulation result files.


1. Creates a scene of the output.
2. Loads each result file of the input scene
3. Calculates and adds kinetic energy field from density and velocity.
4. Writes the modified result file to the output scene.
When possible, numpy is used.

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)

328 Chapter 6. Python Reference


SDK Manual, Release 8.0.0

(continued from previous page)

def calculate_numpy(scene, f):


f.add_material_array('density')
arrays = f.arrays('mps')
velocity = arrays['velocity']
e = arrays.add_scalar('kinematic_energy').numpy()
rho = arrays['density'].numpy()
vx = velocity.x.numpy()
vy = velocity.y.numpy()
vz = velocity.z.numpy()
volume = particle_volume(scene)
e[:] = 0.5 * rho * volume * (vx * vx + vy * vy + vz * vz)

def calculate_default(scene, f):


density = []
for m in scene.materials:
if m.material_type != pwpy.MATERIAL_fluid:
continue
i = m.id
while len(density) <= i:
density.append(0.0)
density[i] = m['density']
arrays = f.arrays('mps')
e = arrays.add_scalar('kinematic_energy')
m = arrays['material_index']
v = arrays['velocity']
volume = particle_volume(scene)
for i in range(len(v)):
k = m[i]
rho = density[k] if k >= 0 and k < len(density) else 0.0
e[i] = 0.5 * rho * volume * pow(v[i].norm(), 2)

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)

(continues on next page)

6.10. Sample : Simulation Result File 329


SDK Manual, Release 8.0.0

(continued from previous page)


n = scene.frame_count
for i in range(n):
out_path = '%s/out_%06d.profbin' % (out_dir, i)
print(out_path)
with pwpy.ResultFile(scene, i) as f:
if numpy != None:
calculate_numpy(scene, f)
else:
calculate_default(scene, f)
f.write(out_path)

if 'Particleworks' in __name__:
import pwpy
session = pwpy.Session()
main(session.active_scene)

6.11 Sample : Mapping Result

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 reshape(arrays, name):


a = arrays[name]
n = len(a)
assert n % 3 == 0
if type(a) == pwpy.ScalarArray:
a = a.numpy()
return (a[0::3], a[1::3], a[2::3])
if type(a) == pwpy.Vector3Array:
x = a.x.numpy()
y = a.y.numpy()
z = a.z.numpy()
n = int(n / 3)
def extract(k):
p = numpy.ndarray((n, 3))
p[:,0] = x[k::3]
p[:,1] = y[k::3]
p[:,2] = z[k::3]
return p
(continues on next page)

330 Chapter 6. Python Reference


SDK Manual, Release 8.0.0

(continued from previous page)


return (extract(0), extract(1), extract(2))
raise RuntimeError('Unknown array type : %s', str(type(a)))

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)

print('%s : a0=%g a1=%g' % (node.name, a0, a1))

(continues on next page)

6.11. Sample : Mapping Result 331


SDK Manual, Release 8.0.0

(continued from previous page)


if 'Particleworks' in __name__:
import pwpy
session = pwpy.Session()
main(session.active_scene)

332 Chapter 6. Python Reference


CHAPTER

SEVEN

USER-CREATED PROGRAMS

7.1 Common

7.1.1 Environment

Windows

• Microsoft Visual Studio 2022


• NVIDIA CUDA Toolkit 11.8
• Microsoft MPI v10.1.2

Linux

• Intel Compiler 2021.4.0


• GNU C++ Compiler 11.3.0
• NVIDIA CUDA Toolkit 11.8
• Intel MPI Library 2021.4.0

7.1.2 Environment Variables

Variable name Value


PW_SDK_PATH Specifies path of Particleworks’ sdk directory

333
SDK Manual, Release 8.0.0

7.1.3 Visual Studio Configuration

Common Settings for Double and Single Precisions

Item Change point


C/C++ > General > Additional Include Directories Add $(PW_SDK_PATH)\include
Linker > General > Additional Library Directories Add $(PW_SDK_PATH)\lib
Linker > Input > Additional Dependencies Add advapi32.lib

Double Precision

Item Change point


C/C++ > Preprocessor > Preprocessor Definitions Add PW_DEFINE_SCALAR_DOUBLE
Linker > Input > Additional Dependencies Add pw.api.double.dll.lib

Single Precision

Item Change point


C/C++ > Preprocessor > Preprocessor Definitions Add PW_DEFINE_SCALAR_FLOAT
Linker > Input > Additional Dependencies Add pw.api.float.dll.lib

7.2 Standalone

7.2.1 main function

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)

334 Chapter 7. User-Created Programs


SDK Manual, Release 8.0.0

(continued from previous page)

// User process
do_something(session);

// Free Session
r = PW_SESSION_end(session);
if (r != PW_ERROR_no_error) {
return -1;
}

return 0;
}

7.2.2 Makefile (gmake)

A typical makefile can be seen below:

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

.PHONY : all prepare

all : prepare $(TARGET_EXEC)

prepare :
(continues on next page)

7.2. Standalone 335


SDK Manual, Release 8.0.0

(continued from previous page)


mkdir -p $(BIN_DIR) $(OBJ_DIR)

$(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

7.3.1 Entry Point

When using Plugin format, define PW_MODULE_initialize() and PW_MODULE_terminate().


PW_SESSION_t is passed as an argument of PW_MODULE_initialize().
It is not necessary to call PW_SESSION_end() when you use PW_MODULE_terminate().

#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)

336 Chapter 7. User-Created Programs


SDK Manual, Release 8.0.0

(continued from previous page)


// Session is not freed.
return uninstall_user_functions(session);
}

7.3.2 Makefile (gmake)

A typical makefile can be seen below:

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

.PHONY : all prepare

all : prepare $(TARGET_PLUGIN)

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

7.3. Plugin 337


SDK Manual, Release 8.0.0

Single Precision

Variable Description
CXXFLAGS_BUILD Add -DPW_DEFINE_SCALAR_FLOAT
PRECISION Specify float

338 Chapter 7. User-Created Programs


CHAPTER

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.

$ python run_example.py PRECISION TYPE TARGET

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.

8.2 C++ Sample

8.2.1 C and C++ Languages

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

(continued from previous page)


PW_PROPERTY_t p;
PW_ERROR_code_t r;

// Property acquisition
r = PW_OBJECT_get_property(object, name, &p);
if (r != PW_ERROR_no_error) {
return r;
}

// Checking if the property is a character string


if (p.type != PW_PROPERTY_string_c) {
r = PW_ERROR_bad_type;
goto END;
}

// Checking if the buffer is large enough


const char * s = PW_STRING_get_mbs(p.u.s);
if (strlen(s) + 1 > size) {
r = PW_ERROR_bad_value;
goto END;
}

// Copying the string


strcpy(buf, s);
r = PW_ERROR_no_error;
END:
// Free the memory of the acquired property
PW_PROPERTY_free(&p);
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;

// Generate character string object


r = PW_STRING_from_mbs(buf, &s);
if (r != PW_ERROR_no_error) {
return r;
}

// Set property
PW_PROPERTY_t p;
p.type = PW_PROPERTY_string_c;
(continues on next page)

340 Chapter 8. Examples


SDK Manual, Release 8.0.0

(continued from previous page)


p.u.s = s;

r = PW_OBJECT_set_property(object, name, p);

// Delete the generated string object


PW_STRING_free(s);

return r;
}

Such complex writing can be avoided by using C++.


• Memory management is performed semi-automatically by using variables on the stack.
• If some error occurs, an exception is thrown.
This SDK comes with the sample code of a C++ Wrapper, and the examples are also described with it. The
above string acquisition and setting can simply be rewritten as follows with the C++ Wrapper:

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);
}

8.2.2 C++ Wrapper File

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:

Class Handle Description


pw_vec3 n/a 3 dimensional vector of pw_scalar
pw_vec3f n/a 3 dimensional vector of float
pw_vec3d n/a 3 dimensional vector of double
pw_mat3x3 n/a 3 x 3 matrix of pw_scalar
pw_mat3x3f n/a 3 x 3 matrix of float
pw_mat3x3d n/a 3 x 3 matrix of double
pw::api::Session PW_SESSION_t
continues on next page

8.2. C++ Sample 341


SDK Manual, Release 8.0.0

Table 1 – continued from previous page


Class Handle Description
pw::api::Object PW_OBJECT_t
pw::api::Property PW_PROPERTY_t
pw::api::Scene PW_SCENE_t
pw::api::Node PW_NODE_t
pw::api::Material PW_MATERIAL_t
pw::api::Widget PW_WIDGET_t
pw::api::ColorMap PW_COLORMAP_t
pw::api::Parameters PW_PARAMETERS_t
pw::api::DistanceField PW_DF_t
pw::api::Particles PW_PARTICLES_t
pw::api::Arrays PW_ARRAYS_t
pw::api::ArrayDescription PW_ARRAY_description_t
pw::api::CharArray n/a Array of char belonging to PW_ARRAYS_t
pw::api::IntegerArray n/a Array of int belonging to PW_ARRAYS_t
pw::api::LongArray n/a Array of pw_long belonging to PW_ARRAYS_t
pw::api::ScalarArray n/a Array of pw_scalar belonging to PW_ARRAYS_t
pw::api::Vector3Array n/a Array of pw_vec3 belonging to PW_ARRAYS_t
pw::api::Matrix3x3Array n/a Array of pw_mat3x3 belonging to PW_ARRAYS_t
pw::api::Animation PW_ANIMATION_value_t
pw::api::InteractionPP PW_INTERACTION_PP_t
pw::api::Solver PW_SOLVER_t
pw::api::UserFunction PW_USER_FUNCTION_t
pw::api::Capture PW_CAPTURE_t
pw::api::Video PW_CAPTURE_t
pw::api::ScreenShot PW_CAPTURE_t
pw::api::TaskQueue PW_TASK_QUEUE_t
pw::api::Task PW_TASK_t
pw::api::String PW_STRING_t
pw::api::CStringArray PW_CSTRING_array_t

342 Chapter 8. Examples


SDK Manual, Release 8.0.0

8.3 Example Program Structure

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)

8.3.2 Module Class

Class / Method Description


pw::example::Module Interface to the implementation of the individual examples
pw::example::Module::initialize() Initialization (virtual function)
pw::example::Module::run() Execute processing when Mode is Standalone (virtual func-
tion)

8.3. Example Program Structure 343


SDK Manual, Release 8.0.0

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()

void Module::run(const std::vector<std::string> &args)

Arguments

Argument I/O Description


args Input unrecognized_args of PW_SESSION_start()

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)

344 Chapter 8. Examples


SDK Manual, Release 8.0.0

(continued from previous page)


return pw::example::safe_call([&]() {
// Various initializations
...;

// Module execution
auto module = pw::example::Module::create(key, session.handle());
module->run(args);
});
}

In the default implementation, the analysis execution is as follows:

void
Module::run(const std::vector<std::string> & args)
{
m_session.solver().step(-1);
}

8.4 Example: Calculation of Particle Number Density (Interactions)

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.

8.4.2 Study Case

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.

8.4. Example: Calculation of Particle Number Density (Interactions) 345


SDK Manual, Release 8.0.0

8.4.3 Physical Quantities Array

Name I/O Description


position Input Particle position
num- Input & Holds the inter-particle density calculated by the user function. Newly regis-
ber_density_ppOutput tered.
num- Input & Holds the inter-particle density calculated by the user function between the
ber_density_pdOutput particles and the Distance Field. Newly registered.
num- Input The inter-particle density calculated by Particleworks
ber_density

8.4.4 User Function

class NumberDensityCalculate

• Called before Particleworks' Particle Number Density Kernel (PW_CALL_POINT_pre_c).


• Calculates the particle number density between particles and stores the result in num-
ber_density_pp.
• Calculates the interactions between particles and the Distance Field and stores the result in num-
ber_density_pd
class NumberDensityCompare

• Called after Particleworks' Particle Number Density Kernel (PW_CALL_POINT_post_c).


• Compares the results:
– Particleworks' results are stored in number_density array.
– The user function's results are stored in number_density_pp and number_density_pd arrays.

8.5 Example: User-Defined Viscosity

8.5.1 Objective

• Register User Function as a Sub Kernel of Kinematic Viscosity Coefficient (p-p).


• Replace the viscosity calculation of the physical property manager.

346 Chapter 8. Examples


SDK Manual, Release 8.0.0

8.5.2 Study Case

• Viscous calculation is enabled.


• Physical property name FluidUser exists.

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).

Mud is thrown in the Z+ direction

Mud hits the ceiling


continues on next page

8.5. Example: User-Defined Viscosity 347


SDK Manual, Release 8.0.0

Table 2 – continued from previous page

They attach to the ceiling

Bingham fluid starts to flake off

Bingham fluid detaches


continues on next page

348 Chapter 8. Examples


SDK Manual, Release 8.0.0

Table 2 – continued from previous page

8.5.3 Physical Quantities Array

Name I/O Description


material_index Input Particle property index
absolute_velocity_gradient Input Shear rate (norm of velocity gradient)
kinematic_viscosity Input & Output Kinematic viscosity coefficient

8.5.4 User Function

class CalculateViscosity

• Called immediately after Kinematic Viscosity Coefficient (p-p) Sub Kernel


(PW_CALL_POINT_post_c).
• FluidUser's viscosity calculated according to equation (11) of [IKARI-2012].
• Nothing is done to the FluidBingham particles' properties since they have been calculated by
Particleworks' Kinematic Viscosity Coefficient (p-p) Sub Kernel.

8.6 Example: Manipulating Inflow Particles

8.6.1 Objective

• Register User Function before and after Inflow Kernel.


• Determine when the inflow occurred.
• Delete a part of the inflow particles.

8.6. Example: Manipulating Inflow Particles 349


SDK Manual, Release 8.0.0

8.6.2 Study Case

• There is only one inlet at a given position.


In the project included in the SDK, some of the particles flowing from the rectangular inlet are removed to
make a sin curve-shaped interface, as seen in the figure below.

8.6.3 Physical Quantities Array

Name I/O Description


material_index Output Particle property index. Set to -1 for particles you want to delete.
position Input Particle position

8.6.4 User Function

class InflowPre

• Called before Inflow Kernel (PW_CALL_POINT_pre_c).


• Records the number of MPS particles existing before inflow.
class InflowPost

• Registered after Inflow Kernel (PW_CALL_POINT_post_c).


• Determines whether inflow has occurred:
– The number of MPS particles acquired with InflowPost is larger than that saved with
InflowPre.
• Deletes particles:
– Sets the material_index to -1 if the z-coordinate of the flowing particle exceeds the sin curve.

350 Chapter 8. Examples


SDK Manual, Release 8.0.0

8.7 Example: Adding a Physical Quantity

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.

8.7.2 Study Case

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.

8.7.3 Physical Quantities Array

Name I/O Description


material_index Input Particle property index
velocity Input Particle velocity
kinetic_energy Output Kinetic energy of particle

8.7. Example: Adding a Physical Quantity 351


SDK Manual, Release 8.0.0

8.7.4 User Function

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()

• Read each .profbin output from the result directory.


• Write the kinetic energy to kinetic_energy array.
• Specify saving kinetic_energy and writing it to .profbin.

8.8 Example: Number of Collisions of DEM Particles

8.8.1 Objective

• Calculate the interaction between DEM particles using pw::api::InteractionPP


(PW_INTERACTION_PP_t)
• Obtain PW_INTERACTION_PD_t from pw::api::DistanceField (PW_DF_t) and calculate the in-
teractions between DEM particles and Distance Field
• Record the progress of interaction calculation in the interaction array
• Add a physical quantity to the .profbin saved by Solver

8.8.2 Study Case

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.

352 Chapter 8. Examples


SDK Manual, Release 8.0.0

8.8.3 Physical Quantities Array

Name I/O Description


position Input Particle position
radius Input Particle radius
id Input Particle ID
exam- Input, Out- Flag which indicates whether a collision occurred in the previous
ple_previous_state put step.
example_count_pp Output Number of collisions between DEM particles (stored in .profbin)
exam- Output Number of collisions between wall.obj and DEM particles (stored
ple_count_wall_obj in .profbin)
exam- Output Number of collisions between box.obj and DEM particles (stored
ple_count_box_obj in .profbin)

8.8.4 User Function

void ModuleImpl::initialize()

• Constructs a correspondence table between Group ID and Node name (m_group_names).


• Add the array example_previous_state.
– The target PW_ARRAYS_t is obtained from PW_PARTICLES_t (DEM) and PW_DF_t.
– Adds an interaction tag so that its length is automatically adjusted in order to hold the
information of interacting elements (p-p, p-d).
• Adds an array (example_count_*) to be output to .profbin.
– Includes particle in the tag, so as to be saved in .profbin.

8.8. Example: Number of Collisions of DEM Particles 353


SDK Manual, Release 8.0.0

void ModuleImpl::calculate_pp()

• Called after Time Integration (Post) Kernel.


• Calculates the number of collisions between DEM particles and stores the result in exam-
ple_count_pp.
void ModuleImpl::calculate_pd()

• Called after Time Integration (Post) Kernel.


• Calculates the number of collisions between DEM particles and polygons and stores the result in
example_count_*.

8.9 Example: Calculation of the Volume Fraction of Fluid Particles


(Interactions).

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.

8.9.2 Study Case

If your project is to perform coupled DEM-MPS calculations, you can run this plugin.

8.9.3 Physical Quantities Array

Name I/O Description


position Input Particle position of MPS
group_index Input Group ID of MPS Particle
position Input Particle position of DEM
material_index Input Particle property index of DEM
radius Input Particle radius of DEM
volume_fraction_sdk Output The volume fraction of fluid particles (MPS) by the user function

354 Chapter 8. Examples


SDK Manual, Release 8.0.0

8.9.4 User Function

class VolumeFractionCalculate

• Called before Particleworks' Volume Fraction Kernel (PW_CALL_POINT_pre_c).


• Calculates the volume fraction of fluid particles (MPS) and stores the result in vol-
ume_fraction_sdk.
class VolumeFractionCompare

• Called after Particleworks' Volume Fraction Kernel (PW_CALL_POINT_post_c).


• Compares the results:
– Particleworks' results are stored in volume_fraction array.
– The user function's results are stored in volume_fraction_sdk .

8.10 Example: Calculation of the DEM Particle Number Density (In-


teractions).

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.

8.10.2 Study Case

If your project is to perform coupled DEM-MPS calculations, you can run this plugin..

8.10.3 Physical Quantities Array

Name I/O Description


position Input Particle position of MPS
position Input Particle position of DEM
number_density_dem_sdk Output The number density of DEM by The user function

8.10. Example: Calculation of the DEM Particle Number Density (Interactions). 355
SDK Manual, Release 8.0.0

8.10.4 User Function

class DEM_NumberDensityCalculate

• Called before Particleworks' Particle Number Density Kernel (PW_CALL_POINT_pre_c).


• Calculates the number density of DEM and stores the result in number_density_dem_sdk.
class DEM_NumberDensityCompare

• Called after Particleworks' Particle Number Density Kernel (PW_CALL_POINT_post_c).


• Compares the results:
– Particleworks' results are stored in number_density_for_boundary_detection array.
– The user function's results are stored in number_density_dem_sdk .

356 Chapter 8. Examples


BIBLIOGRAPHY

[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

You might also like