pybFoam 0.1.6__tar.gz → 0.1.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. {pybfoam-0.1.6 → pybfoam-0.1.8}/CMakeLists.txt +1 -1
  2. {pybfoam-0.1.6 → pybfoam-0.1.8}/PKG-INFO +7 -2
  3. pybfoam-0.1.8/benchmark/bench_complex.png +0 -0
  4. pybfoam-0.1.8/benchmark/bench_vec_add.png +0 -0
  5. pybfoam-0.1.8/benchmark/bench_vec_add_4.png +0 -0
  6. pybfoam-0.1.8/benchmark/benchmark_expression_complex.py +142 -0
  7. pybfoam-0.1.8/benchmark/benchmark_expression_vec_add.py +118 -0
  8. pybfoam-0.1.8/benchmark/benchmark_expression_vec_add_4.py +120 -0
  9. {pybfoam-0.1.6 → pybfoam-0.1.8}/docs/conf.py +1 -1
  10. {pybfoam-0.1.6 → pybfoam-0.1.8}/pyproject.toml +9 -3
  11. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/CMakeLists.txt +0 -1
  12. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/__init__.py +0 -1
  13. pybfoam-0.1.8/src/pybFoam/_version.py +1 -0
  14. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/io/model_base.py +9 -9
  15. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/pybFoam_core/bind_dict.cpp +67 -0
  16. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/pybFoam_core/bind_fvMatrix.cpp +18 -3
  17. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/pybFoam_core/bind_io.cpp +6 -0
  18. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/pybFoam_core/bind_mesh.cpp +4 -0
  19. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/test_surface_sampling.py +0 -243
  20. pybfoam-0.1.6/src/pybFoam/_version.py +0 -1
  21. pybfoam-0.1.6/src/pybFoam/aggregation/CMakeLists.txt +0 -43
  22. pybfoam-0.1.6/src/pybFoam/aggregation/aggregation.cpp +0 -31
  23. pybfoam-0.1.6/src/pybFoam/aggregation/bind_aggregation.cpp +0 -248
  24. pybfoam-0.1.6/src/pybFoam/aggregation/bind_aggregation.hpp +0 -51
  25. pybfoam-0.1.6/tests/pybind/test_aggregation.py +0 -148
  26. {pybfoam-0.1.6 → pybfoam-0.1.8}/.github/workflows/ci.yaml +0 -0
  27. {pybfoam-0.1.6 → pybfoam-0.1.8}/.github/workflows/pages.yaml +0 -0
  28. {pybfoam-0.1.6 → pybfoam-0.1.8}/.github/workflows/release.yaml +0 -0
  29. {pybfoam-0.1.6 → pybfoam-0.1.8}/.gitignore +0 -0
  30. {pybfoam-0.1.6 → pybfoam-0.1.8}/CHANGELOG.md +0 -0
  31. {pybfoam-0.1.6 → pybfoam-0.1.8}/CMakePresets.json +0 -0
  32. {pybfoam-0.1.6 → pybfoam-0.1.8}/LICENSE +0 -0
  33. {pybfoam-0.1.6 → pybfoam-0.1.8}/README.md +0 -0
  34. {pybfoam-0.1.6 → pybfoam-0.1.8}/cmake/Dependencies.cmake +0 -0
  35. {pybfoam-0.1.6 → pybfoam-0.1.8}/cmake/FindOpenFOAM.cmake +0 -0
  36. {pybfoam-0.1.6 → pybfoam-0.1.8}/conftest.py +0 -0
  37. {pybfoam-0.1.6 → pybfoam-0.1.8}/docs/Makefile +0 -0
  38. {pybfoam-0.1.6 → pybfoam-0.1.8}/docs/README.md +0 -0
  39. {pybfoam-0.1.6 → pybfoam-0.1.8}/docs/api.rst +0 -0
  40. {pybfoam-0.1.6 → pybfoam-0.1.8}/docs/changelog.rst +0 -0
  41. {pybfoam-0.1.6 → pybfoam-0.1.8}/docs/contributing.rst +0 -0
  42. {pybfoam-0.1.6 → pybfoam-0.1.8}/docs/index.rst +0 -0
  43. {pybfoam-0.1.6 → pybfoam-0.1.8}/docs/installation.rst +0 -0
  44. {pybfoam-0.1.6 → pybfoam-0.1.8}/docs/introduction.rst +0 -0
  45. {pybfoam-0.1.6 → pybfoam-0.1.8}/docs/make.bat +0 -0
  46. {pybfoam-0.1.6 → pybfoam-0.1.8}/docs/usage.rst +0 -0
  47. {pybfoam-0.1.6 → pybfoam-0.1.8}/scripts/generate_stubs.py +0 -0
  48. {pybfoam-0.1.6 → pybfoam-0.1.8}/scripts/pyInstall.sh +0 -0
  49. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/fvc/CMakeLists.txt +0 -0
  50. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/fvc/bind_fvc.cpp +0 -0
  51. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/fvc/bind_fvc.hpp +0 -0
  52. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/fvc/fvc.cpp +0 -0
  53. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/fvc.pyi +0 -0
  54. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/fvm/CMakeLists.txt +0 -0
  55. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/fvm/bind_fvm.cpp +0 -0
  56. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/fvm/bind_fvm.hpp +0 -0
  57. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/fvm/fvm.cpp +0 -0
  58. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/io/__init__.py +0 -0
  59. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/io/system.py +0 -0
  60. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/py.typed +0 -0
  61. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/pybFoam_core/CMakeLists.txt +0 -0
  62. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/pybFoam_core/bind_cfdTools.cpp +0 -0
  63. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/pybFoam_core/bind_cfdTools.hpp +0 -0
  64. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/pybFoam_core/bind_control.cpp +0 -0
  65. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/pybFoam_core/bind_control.hpp +0 -0
  66. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/pybFoam_core/bind_dict.hpp +0 -0
  67. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/pybFoam_core/bind_dimensioned.cpp +0 -0
  68. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/pybFoam_core/bind_dimensioned.hpp +0 -0
  69. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/pybFoam_core/bind_fields.cpp +0 -0
  70. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/pybFoam_core/bind_fields.hpp +0 -0
  71. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/pybFoam_core/bind_fvMatrix.hpp +0 -0
  72. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/pybFoam_core/bind_geo_fields.cpp +0 -0
  73. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/pybFoam_core/bind_geo_fields.hpp +0 -0
  74. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/pybFoam_core/bind_io.hpp +0 -0
  75. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/pybFoam_core/bind_mesh.hpp +0 -0
  76. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/pybFoam_core/bind_primitives.cpp +0 -0
  77. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/pybFoam_core/bind_primitives.hpp +0 -0
  78. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/pybFoam_core/pybFoam.cpp +0 -0
  79. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/pybFoam_core.pyi +0 -0
  80. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/runTimeTables/CMakeLists.txt +0 -0
  81. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/runTimeTables/foam_runTimeTables.C +0 -0
  82. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/runTimeTables/foam_runTimeTables.H +0 -0
  83. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/runTimeTables/runTimeTables.C +0 -0
  84. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/runTimeTables.pyi +0 -0
  85. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/sampling/CMakeLists.txt +0 -0
  86. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/sampling/__init__.py +0 -0
  87. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/sampling/bind_sampling.cpp +0 -0
  88. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/sampling/bind_sampling.hpp +0 -0
  89. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/sampling/sampling.cpp +0 -0
  90. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/sampling/set_configs.py +0 -0
  91. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/sampling/surface_configs.py +0 -0
  92. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/sampling/utils.py +0 -0
  93. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/sampling.pyi +0 -0
  94. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/thermo/CMakeLists.txt +0 -0
  95. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/thermo/bind_thermo.cpp +0 -0
  96. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/thermo/bind_thermo.hpp +0 -0
  97. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/thermo/thermo.cpp +0 -0
  98. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/thermo.pyi +0 -0
  99. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/turbulence/CMakeLists.txt +0 -0
  100. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/turbulence/bind_turbulence.cpp +0 -0
  101. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/turbulence/bind_turbulence.hpp +0 -0
  102. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/turbulence/turbulence.cpp +0 -0
  103. {pybfoam-0.1.6 → pybfoam-0.1.8}/src/pybFoam/turbulence.pyi +0 -0
  104. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/cavity/0.orig/U +0 -0
  105. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/cavity/0.orig/nu +0 -0
  106. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/cavity/0.orig/p +0 -0
  107. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/cavity/Allclean +0 -0
  108. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/cavity/Allrun +0 -0
  109. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/cavity/constant/transportProperties +0 -0
  110. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/cavity/icoFoam.py +0 -0
  111. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/cavity/log2 +0 -0
  112. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/cavity/system/PDRblockMeshDict +0 -0
  113. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/cavity/system/blockMeshDict +0 -0
  114. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/cavity/system/controlDict +0 -0
  115. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/cavity/system/decomposeParDict +0 -0
  116. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/cavity/system/fvSchemes +0 -0
  117. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/cavity/system/fvSolution +0 -0
  118. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/elbow/0.orig/U +0 -0
  119. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/elbow/0.orig/nu +0 -0
  120. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/elbow/0.orig/p +0 -0
  121. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/elbow/Allclean +0 -0
  122. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/elbow/Allrun +0 -0
  123. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/elbow/constant/transportProperties +0 -0
  124. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/elbow/icoFoam.py +0 -0
  125. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/elbow/system/controlDict +0 -0
  126. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/elbow/system/foamDataToFluentDict +0 -0
  127. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/elbow/system/fvSchemes +0 -0
  128. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/elbow/system/fvSolution +0 -0
  129. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/io/TestDict +0 -0
  130. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/io/TestDict.json +0 -0
  131. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/io/TestDict.yaml +0 -0
  132. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/io/controlDict +0 -0
  133. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/io/fvSchemes +0 -0
  134. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/io/fvSolution +0 -0
  135. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/io/test_controlDict.py +0 -0
  136. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/io/test_fvSchemes.py +0 -0
  137. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/io/test_fvSolution.py +0 -0
  138. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/io/test_parse_ofdict.py +0 -0
  139. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/0/U +0 -0
  140. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/0/alpha.water +0 -0
  141. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/0/p_rgh +0 -0
  142. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/0.orig/U +0 -0
  143. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/0.orig/alpha.water +0 -0
  144. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/0.orig/p_rgh +0 -0
  145. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/Allclean +0 -0
  146. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/Allrun +0 -0
  147. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/Allrun-parallel +0 -0
  148. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/constant/dynamicMeshDict +0 -0
  149. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/constant/g +0 -0
  150. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/constant/polyMesh/boundary +0 -0
  151. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/constant/polyMesh/faces +0 -0
  152. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/constant/polyMesh/neighbour +0 -0
  153. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/constant/polyMesh/owner +0 -0
  154. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/constant/polyMesh/points +0 -0
  155. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/constant/transportProperties +0 -0
  156. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/constant/turbulenceProperties +0 -0
  157. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/system/TestDict +0 -0
  158. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/system/blockMeshDict +0 -0
  159. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/system/controlDict +0 -0
  160. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/system/decomposeParDict +0 -0
  161. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/system/fvSchemes +0 -0
  162. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/system/fvSolution +0 -0
  163. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/system/setFieldsDict +0 -0
  164. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/test_dict.py +0 -0
  165. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/test_fvc.py +0 -0
  166. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/test_fvm.py +0 -0
  167. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/test_geoFields.py +0 -0
  168. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/test_primitives.py +0 -0
  169. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/pybind/test_set_sampling.py +0 -0
  170. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/test_sampling_models.py +0 -0
  171. {pybfoam-0.1.6 → pybfoam-0.1.8}/tests/test_sampling_set_configs.py +0 -0
@@ -5,7 +5,7 @@ if(POLICY CMP0169)
5
5
  cmake_policy(SET CMP0169 OLD)
6
6
  endif()
7
7
 
8
- project(pybFoam VERSION 0.1.6 LANGUAGES CXX)
8
+ project(pybFoam VERSION 0.1.8 LANGUAGES CXX)
9
9
 
10
10
  # Set C++ standard
11
11
  set(CMAKE_CXX_STANDARD 17)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pybFoam
3
- Version: 0.1.6
3
+ Version: 0.1.8
4
4
  Summary: python bindings for OpenFOAM
5
5
  Keywords: OpenFOAM,simulation,CFD
6
6
  Author-Email: Henning Scheufler <henning.scheufler@web.de>
@@ -41,8 +41,13 @@ Requires-Dist: sphinx>=4.0; extra == "docs"
41
41
  Requires-Dist: sphinx-sitemap; extra == "docs"
42
42
  Requires-Dist: furo; extra == "docs"
43
43
  Requires-Dist: sphinxcontrib-mermaid; extra == "docs"
44
+ Provides-Extra: benchmark
45
+ Requires-Dist: jax; extra == "benchmark"
46
+ Requires-Dist: seaborn; extra == "benchmark"
47
+ Requires-Dist: matplotlib; extra == "benchmark"
48
+ Requires-Dist: PyQt6; extra == "benchmark"
44
49
  Provides-Extra: all
45
- Requires-Dist: pybFoam[dev,docs]; extra == "all"
50
+ Requires-Dist: pybFoam[benchmark,dev,docs]; extra == "all"
46
51
  Description-Content-Type: text/markdown
47
52
 
48
53
  # pybFoam
@@ -0,0 +1,142 @@
1
+ # import os
2
+
3
+ # N = 8
4
+
5
+ # os.environ["XLA_FLAGS"] = (
6
+ # f"--xla_cpu_multi_thread_eigen=true "
7
+ # f"intra_op_parallelism_threads={N}"
8
+ # )
9
+ import os
10
+
11
+ def configure_threads(n=1):
12
+ multi_thread = True if n > 1 else False
13
+ os.environ["XLA_FLAGS"] = (
14
+ f"--xla_cpu_multi_thread_eigen={multi_thread} "
15
+ f"intra_op_parallelism_threads={n}"
16
+ )
17
+ os.environ["NPROC"] = f"{n}"
18
+ os.environ["OMP_NUM_THREADS"] = str(n)
19
+ os.environ["MKL_NUM_THREADS"] = str(n)
20
+ os.environ["OPENBLAS_NUM_THREADS"] = str(n)
21
+
22
+ configure_threads(1)
23
+
24
+ from pybFoam import scalarField
25
+ import numpy as np
26
+ import timeit
27
+ import time
28
+ import pandas as pd
29
+ import matplotlib.pyplot as plt
30
+ import seaborn as sns
31
+ import jax
32
+ import jax.numpy as jnp
33
+
34
+
35
+ def pybfoam_expression(n_elements):
36
+ a = scalarField([1.1] * n_elements)
37
+ b = scalarField([2.2] * n_elements)
38
+ c = scalarField([3.3] * n_elements)
39
+ d = scalarField([4.4] * n_elements)
40
+
41
+ def run():
42
+ x = a * b + c
43
+ y = d - a * c
44
+ return (x * y + b) / (a + 1.0)
45
+ return run
46
+
47
+ def numpy_expression(n_elements):
48
+ a = np.full(n_elements, 1.1)
49
+ b = np.full(n_elements, 2.2)
50
+ c = np.full(n_elements, 3.3)
51
+ d = np.full(n_elements, 4.4)
52
+
53
+ def run():
54
+ x = a * b + c
55
+ y = d - a * c
56
+ return (x * y + b) / (a + 1.0)
57
+
58
+ return run
59
+
60
+ def jax_expression(n_elements):
61
+ a = jnp.full(n_elements, 1.1)
62
+ b = jnp.full(n_elements, 2.2)
63
+ c = jnp.full(n_elements, 3.3)
64
+ d = jnp.full(n_elements, 4.4)
65
+
66
+ @jax.jit
67
+ def run():
68
+ x = a * b + c
69
+ y = d - a * c
70
+ return (x * y + b) / (a + 1.0)
71
+
72
+ return run
73
+
74
+ vector_add_data = {
75
+ "n_elements": [],
76
+ "duration": [],
77
+ "method": [],
78
+ # "jax": []
79
+ }
80
+
81
+ def add_data(n_elements, duration, method):
82
+ vector_add_data["n_elements"].append(n_elements)
83
+ vector_add_data["duration"].append(duration)
84
+ vector_add_data["method"].append(method)
85
+
86
+ for n_elements in [10, 100, 1000, 10_000, 100_000, 1_000_000, 10_000_000]:
87
+
88
+ bench = pybfoam_expression(n_elements)
89
+ # duration = timeit.timeit(bench, number=1)
90
+ t0 = time.perf_counter() # lower overhead than timeit
91
+ bench()
92
+ t1 = time.perf_counter()
93
+ duration = t1 - t0
94
+ add_data(n_elements, duration, "pybFoam")
95
+
96
+ bench = numpy_expression(n_elements)
97
+ # duration = timeit.timeit(bench, number=1)
98
+ t0 = time.perf_counter() # lower overhead than timeit
99
+ bench()
100
+ t1 = time.perf_counter()
101
+ duration = t1 - t0
102
+ add_data(n_elements, duration, "NumPy")
103
+
104
+ bench = jax_expression(n_elements)
105
+ # First call to compile
106
+ bench()
107
+ # duration = timeit.timeit(bench, number=1)
108
+ t0 = time.perf_counter() # lower overhead than timeit
109
+ bench()
110
+ t1 = time.perf_counter()
111
+ duration = t1 - t0
112
+ add_data(n_elements, duration, "JAX")
113
+
114
+
115
+ df_vector_add = pd.DataFrame(vector_add_data)
116
+ df_vector_add["time_per_element [ns]"] = df_vector_add["duration"] / df_vector_add["n_elements"] * 1e9 # time per element in nanoseconds
117
+ print("Vector Addition Benchmark:",df_vector_add)
118
+
119
+ sns.lineplot(data=df_vector_add, x="n_elements", y="time_per_element [ns]", hue="method", marker="o")
120
+ plt.xscale("log")
121
+ plt.yscale("log")
122
+ plt.xlabel("Number of Elements")
123
+ plt.ylabel("Time per Element (nanoseconds)")
124
+ plt.title("Expression: (x * y + b) / (a + 1.0)")
125
+ plt.savefig("bench_complex.png")
126
+ n_elements = 10_000_000
127
+ timings = df_vector_add[df_vector_add["n_elements"] == n_elements]
128
+ print(f"Timings for {n_elements} elements:")
129
+ for _, row in timings.iterrows():
130
+ print(f"{row['method']}: {row['time_per_element [ns]']:.2f} ns per element")
131
+ n_elements = 1_000_000
132
+ print("")
133
+ timings = df_vector_add[df_vector_add["n_elements"] == n_elements]
134
+ print(f"Timings for {n_elements} elements:")
135
+ for _, row in timings.iterrows():
136
+ print(f"{row['method']}: {row['time_per_element [ns]']:.2f} ns per element")
137
+
138
+ plt.show()
139
+
140
+
141
+
142
+ # %%
@@ -0,0 +1,118 @@
1
+ import os
2
+
3
+ def configure_threads(n=1):
4
+ multi_thread = True if n > 1 else False
5
+ os.environ["XLA_FLAGS"] = (
6
+ f"--xla_cpu_multi_thread_eigen={multi_thread} "
7
+ f"intra_op_parallelism_threads={n}"
8
+ )
9
+ os.environ["NPROC"] = f"{n}"
10
+ os.environ["OMP_NUM_THREADS"] = str(n)
11
+ os.environ["MKL_NUM_THREADS"] = str(n)
12
+ os.environ["OPENBLAS_NUM_THREADS"] = str(n)
13
+
14
+ configure_threads(1)
15
+
16
+ from pybFoam import scalarField
17
+ import numpy as np
18
+ import timeit
19
+ import time
20
+ import pandas as pd
21
+ import matplotlib.pyplot as plt
22
+ import seaborn as sns
23
+ import jax
24
+ import jax.numpy as jnp
25
+
26
+
27
+ def pybfoam_vector_addition(n_elements):
28
+ a = scalarField([1.0] * n_elements)
29
+ b = scalarField([2.0] * n_elements)
30
+
31
+ def run():
32
+ return a + b
33
+
34
+ return run
35
+
36
+ def numpy_vector_addition(n_elements):
37
+ a = np.ones(n_elements)
38
+ b = np.full(n_elements, 2.0)
39
+
40
+ def run():
41
+ return a + b
42
+
43
+ return run
44
+
45
+ def jax_vector_addition(n_elements):
46
+
47
+ a = jnp.ones(n_elements)
48
+ b = jnp.full(n_elements, 2.0)
49
+
50
+ @jax.jit
51
+ def run():
52
+ return a + b
53
+
54
+ return run
55
+
56
+ vector_add_data = {
57
+ "n_elements": [],
58
+ "duration": [],
59
+ "method": [],
60
+ }
61
+
62
+ def add_data(n_elements, duration, method):
63
+ vector_add_data["n_elements"].append(n_elements)
64
+ vector_add_data["duration"].append(duration)
65
+ vector_add_data["method"].append(method)
66
+
67
+ for n_elements in [10, 100, 1000, 10_000, 100_000, 1_000_000, 10_000_000]:
68
+
69
+ bench = pybfoam_vector_addition(n_elements)
70
+ # duration2 = timeit.timeit(bench, number=1)
71
+ t0 = time.perf_counter() # lower overhead than timeit
72
+ bench()
73
+ t1 = time.perf_counter()
74
+ duration = t1 - t0
75
+ add_data(n_elements, duration, "pybFoam")
76
+
77
+ bench = numpy_vector_addition(n_elements)
78
+ # duration = timeit.timeit(bench, number=1)
79
+ t0 = time.perf_counter() # lower overhead than timeit
80
+ bench()
81
+ t1 = time.perf_counter()
82
+ duration = t1 - t0
83
+ add_data(n_elements, duration, "NumPy")
84
+
85
+ bench = jax_vector_addition(n_elements)
86
+ # First call to compile
87
+ bench()
88
+ # duration = timeit.timeit(bench, number=1)
89
+ t0 = time.perf_counter() # lower overhead than timeit
90
+ bench()
91
+ t1 = time.perf_counter()
92
+ duration = t1 - t0
93
+ add_data(n_elements, duration, "JAX")
94
+
95
+
96
+ df_vector_add = pd.DataFrame(vector_add_data)
97
+ df_vector_add["time_per_element [ns]"] = df_vector_add["duration"] / df_vector_add["n_elements"] * 1e9 # time per element in nanoseconds
98
+ print("Vector Addition Benchmark:",df_vector_add)
99
+
100
+ sns.lineplot(data=df_vector_add, x="n_elements", y="time_per_element [ns]", hue="method", marker="o")
101
+ plt.xscale("log")
102
+ plt.yscale("log")
103
+ plt.xlabel("Number of Elements")
104
+ plt.ylabel("Time per Element (nanoseconds)")
105
+ plt.title("Expression: c = a + b")
106
+ plt.savefig("bench_vec_add.png")
107
+
108
+ n_elements = 10_000_000
109
+ timings = df_vector_add[df_vector_add["n_elements"] == n_elements]
110
+ print(f"Timings for {n_elements} elements:")
111
+ for _, row in timings.iterrows():
112
+ print(f"{row['method']}: {row['time_per_element [ns]']:.2f} ns per element")
113
+
114
+ plt.show()
115
+
116
+
117
+
118
+ # %%
@@ -0,0 +1,120 @@
1
+ import os
2
+
3
+ def configure_threads(n=1):
4
+ multi_thread = True if n > 1 else False
5
+ os.environ["XLA_FLAGS"] = (
6
+ f"--xla_cpu_multi_thread_eigen={multi_thread} "
7
+ f"intra_op_parallelism_threads={n}"
8
+ )
9
+ os.environ["NPROC"] = f"{n}"
10
+ os.environ["OMP_NUM_THREADS"] = str(n)
11
+ os.environ["MKL_NUM_THREADS"] = str(n)
12
+ os.environ["OPENBLAS_NUM_THREADS"] = str(n)
13
+
14
+ configure_threads(1)
15
+
16
+ from pybFoam import scalarField
17
+ import numpy as np
18
+ import timeit
19
+ import time
20
+ import pandas as pd
21
+ import matplotlib.pyplot as plt
22
+ import seaborn as sns
23
+ import jax
24
+ import jax.numpy as jnp
25
+
26
+
27
+ def pybfoam_vector_addition_4(n_elements):
28
+ a = scalarField([1.0] * n_elements)
29
+ b = scalarField([2.0] * n_elements)
30
+ c = scalarField([3.0] * n_elements)
31
+
32
+ def run():
33
+ return a + b + c + a
34
+
35
+ return run
36
+
37
+ def numpy_vector_addition_4(n_elements):
38
+ a = np.ones(n_elements)
39
+ b = np.full(n_elements, 2.0)
40
+ c = np.full(n_elements, 3.0)
41
+ def run():
42
+ return a + b + c + a
43
+
44
+ return run
45
+
46
+ def jax_vector_addition_4(n_elements):
47
+
48
+ a = jnp.ones(n_elements)
49
+ b = jnp.full(n_elements, 2.0)
50
+ c = jnp.full(n_elements, 3.0)
51
+
52
+
53
+ @jax.jit
54
+ def run():
55
+ return a + b + c + a
56
+
57
+ return run
58
+
59
+ vector_add_data_4 = {
60
+ "n_elements": [],
61
+ "duration": [],
62
+ "method": [],
63
+ # "jax": []
64
+ }
65
+
66
+ def add_data(n_elements, duration, method):
67
+ vector_add_data_4["n_elements"].append(n_elements)
68
+ vector_add_data_4["duration"].append(duration)
69
+ vector_add_data_4["method"].append(method)
70
+
71
+ for n_elements in [10, 100, 1000, 10_000, 100_000, 1_000_000, 10_000_000]:
72
+
73
+ bench = pybfoam_vector_addition_4(n_elements)
74
+ # duration = timeit.timeit(bench, number=1)
75
+ t0 = time.perf_counter() # lower overhead than timeit
76
+ bench()
77
+ t1 = time.perf_counter()
78
+ duration = t1 - t0
79
+ add_data(n_elements, duration, "pybFoam")
80
+
81
+ bench = numpy_vector_addition_4(n_elements)
82
+ # duration = timeit.timeit(bench, number=1)
83
+ t0 = time.perf_counter() # lower overhead than timeit
84
+ bench()
85
+ t1 = time.perf_counter()
86
+ duration = t1 - t0
87
+ add_data(n_elements, duration, "NumPy")
88
+
89
+ bench = jax_vector_addition_4(n_elements)
90
+ # First call to compile
91
+ bench()
92
+ # duration = timeit.timeit(bench, number=1)
93
+ t0 = time.perf_counter() # lower overhead than timeit
94
+ bench()
95
+ t1 = time.perf_counter()
96
+ duration = t1 - t0
97
+ add_data(n_elements, duration, "JAX")
98
+
99
+
100
+ df_vector_add = pd.DataFrame(vector_add_data_4)
101
+ df_vector_add["time_per_element [ns]"] = df_vector_add["duration"] / df_vector_add["n_elements"] * 1e9 # time per element in nanoseconds
102
+ print("Vector Addition Benchmark:",df_vector_add)
103
+
104
+ sns.lineplot(data=df_vector_add, x="n_elements", y="time_per_element [ns]", hue="method", marker="o")
105
+ plt.xscale("log")
106
+ plt.yscale("log")
107
+ plt.xlabel("Number of Elements")
108
+ plt.ylabel("Time per Element (nanoseconds)")
109
+ plt.title("Expression: c = a + b + c + a")
110
+ plt.savefig("bench_vec_add_4.png")
111
+ n_elements = 10_000_000
112
+ timings = df_vector_add[df_vector_add["n_elements"] == n_elements]
113
+ print(f"Timings for {n_elements} elements:")
114
+ for _, row in timings.iterrows():
115
+ print(f"{row['method']}: {row['time_per_element [ns]']:.2f} ns per element")
116
+
117
+ plt.show()
118
+
119
+
120
+ # %%
@@ -9,7 +9,7 @@
9
9
  project = "pybFoam"
10
10
  copyright = "2025, Henning Scheufler"
11
11
  author = "Henning Scheufler"
12
- release = "0.1.6"
12
+ release = "0.1.8"
13
13
 
14
14
  # -- General configuration ---------------------------------------------------
15
15
  # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pybFoam"
3
- version = "0.1.6"
3
+ version = "0.1.8"
4
4
  authors = [
5
5
  {name = "Henning Scheufler", email = "henning.scheufler@web.de"},
6
6
  ]
@@ -28,7 +28,7 @@ dependencies = [
28
28
  "numpy>=1.20",
29
29
  "pybind11>=2.6.0",
30
30
  "pydantic",
31
- "pyyaml"
31
+ "pyyaml",
32
32
  ]
33
33
 
34
34
  [project.optional-dependencies]
@@ -49,8 +49,14 @@ docs = [
49
49
  "furo",
50
50
  "sphinxcontrib-mermaid"
51
51
  ]
52
+ benchmark = [
53
+ "jax",
54
+ "seaborn",
55
+ "matplotlib",
56
+ "PyQt6"
57
+ ]
52
58
  all = [
53
- "pybFoam[dev,docs]",
59
+ "pybFoam[dev,docs,benchmark]",
54
60
  ]
55
61
 
56
62
  [project.urls]
@@ -7,7 +7,6 @@ add_subdirectory(fvc)
7
7
  add_subdirectory(fvm)
8
8
  add_subdirectory(thermo)
9
9
  add_subdirectory(turbulence)
10
- add_subdirectory(aggregation)
11
10
  add_subdirectory(sampling)
12
11
 
13
12
  # Create a Python module that includes all components
@@ -24,4 +24,3 @@ from . import fvm
24
24
  from . import runTimeTables
25
25
  from . import thermo
26
26
  from . import turbulence
27
- from . import aggregation
@@ -0,0 +1 @@
1
+ __version__ = "0.1.8"
@@ -7,17 +7,17 @@ from pybFoam import dictionary
7
7
  from pydantic import BaseModel, Field
8
8
 
9
9
  type_dispatch = {
10
- str: lambda v: v, # Keep as string
11
- int: lambda v: int(v),
12
- float: lambda v: float(v),
13
- bool: lambda v: bool(v),
14
- pybFoam.Word: lambda v: pybFoam.Word(v),
10
+ str: lambda s: s, # Keep as string
11
+ int: lambda i: int(i),
12
+ float: lambda f: float(f),
13
+ bool: lambda b: bool(b),
14
+ pybFoam.Word: lambda w: pybFoam.Word(w),
15
15
  pybFoam.vector: lambda v: pybFoam.vector(*v),
16
- pybFoam.tensor: lambda v: pybFoam.tensor(*v),
17
- pybFoam.wordList: lambda v: pybFoam.wordList(v),
18
- pybFoam.scalarField: lambda v: pybFoam.scalarField(v),
16
+ pybFoam.tensor: lambda t: pybFoam.tensor(*t),
17
+ pybFoam.wordList: lambda w: pybFoam.wordList(w),
18
+ pybFoam.scalarField: lambda s: pybFoam.scalarField(s),
19
19
  pybFoam.vectorField: lambda v: pybFoam.vectorField(v),
20
- pybFoam.tensorField: lambda v: pybFoam.tensorField(v),
20
+ pybFoam.tensorField: lambda t: pybFoam.tensorField(t),
21
21
  }
22
22
 
23
23
 
@@ -23,6 +23,8 @@ License
23
23
  #include "IOobject.H"
24
24
  #include "dictionaryEntry.H"
25
25
  #include "entry.H"
26
+ #include "SolverPerformance.H"
27
+ #include "List.H"
26
28
  #include <unordered_map>
27
29
  #include <functional>
28
30
 
@@ -61,6 +63,68 @@ namespace Foam
61
63
  dict.add<Type>(word(key),T);
62
64
  }
63
65
 
66
+ // Helper function to lookup List<SolverPerformance<Type>> and return as std::vector
67
+ // OpenFOAM stores solver performance as List<SolverPerformance<Type>>
68
+ template<class Type>
69
+ std::vector<SolverPerformance<Type>> lookupSolverPerformanceList(const dictionary& dict, const std::string& fieldName)
70
+ {
71
+ // Check if entry exists first
72
+ const entry* e = dict.findEntry(word(fieldName), keyType::LITERAL);
73
+ if (!e)
74
+ {
75
+ throw std::runtime_error(
76
+ "Entry " + fieldName + " not found in dictionary"
77
+ );
78
+ }
79
+
80
+ // Enable exception throwing for FatalIOError to catch type mismatches
81
+ bool previousThrowState = FatalIOError.throwExceptions();
82
+
83
+ try
84
+ {
85
+ // The dictionary stores List<SolverPerformance<Type>>
86
+ List<SolverPerformance<Type>> sp;
87
+ bool success = dict.readIfPresent(word(fieldName), sp);
88
+
89
+ // Restore previous exception state
90
+ FatalIOError.throwExceptions(previousThrowState);
91
+
92
+ if (!success || sp.empty())
93
+ {
94
+ throw std::runtime_error(
95
+ "Entry " + fieldName + " could not be read as List<SolverPerformance<"
96
+ + pTraits<Type>::typeName + ">> type or is empty"
97
+ );
98
+ }
99
+
100
+ // Convert to std::vector for Python compatibility
101
+ std::vector<SolverPerformance<Type>> result;
102
+ result.reserve(sp.size());
103
+ for (const auto& item : sp)
104
+ {
105
+ result.push_back(item);
106
+ }
107
+
108
+ return result;
109
+ }
110
+ catch (const Foam::error& e)
111
+ {
112
+ // Restore previous exception state before rethrowing
113
+ FatalIOError.throwExceptions(previousThrowState);
114
+
115
+ throw std::runtime_error(
116
+ "Entry " + fieldName + " could not be read as List<SolverPerformance<"
117
+ + pTraits<Type>::typeName + ">> type: " + std::string(e.what())
118
+ );
119
+ }
120
+ catch (...)
121
+ {
122
+ // Restore previous exception state before rethrowing
123
+ FatalIOError.throwExceptions(previousThrowState);
124
+ throw;
125
+ }
126
+ }
127
+
64
128
  }
65
129
 
66
130
 
@@ -191,6 +255,9 @@ void bindDict(pybind11::module& m)
191
255
  .def("add", &Foam::add<Foam::Field<Foam::scalar>>)
192
256
  .def("add", &Foam::add<Foam::Field<Foam::vector>>)
193
257
  .def("add", &Foam::add<Foam::Field<Foam::tensor>>)
258
+ .def("lookupSolverPerformanceScalarList", &Foam::lookupSolverPerformanceList<Foam::scalar>)
259
+ .def("lookupSolverPerformanceVectorList", &Foam::lookupSolverPerformanceList<Foam::vector>)
260
+ .def("lookupSolverPerformanceTensorList", &Foam::lookupSolverPerformanceList<Foam::tensor>)
194
261
  .def_property_readonly(
195
262
  "get",
196
263
  [](Foam::dictionary& self) {
@@ -173,6 +173,21 @@ void declare_solve(py::module &m)
173
173
  });
174
174
  }
175
175
 
176
+ template<class Type>
177
+ py::class_<Foam::SolverPerformance<Type>>
178
+ declare_SolverPerformance(py::module &m, std::string className)
179
+ {
180
+ return py::class_<Foam::SolverPerformance<Type>>(m, className.c_str())
181
+ .def(py::init<>())
182
+ .def("solverName", [](const Foam::SolverPerformance<Type>& self) { return self.solverName(); })
183
+ .def("fieldName", [](const Foam::SolverPerformance<Type>& self) { return self.fieldName(); })
184
+ .def("initialResidual", [](const Foam::SolverPerformance<Type>& self) { return self.initialResidual(); })
185
+ .def("finalResidual", [](const Foam::SolverPerformance<Type>& self) { return self.finalResidual(); })
186
+ .def("nIterations", [](const Foam::SolverPerformance<Type>& self) { return self.nIterations(); })
187
+ .def("converged", &Foam::SolverPerformance<Type>::converged)
188
+ .def("singular", &Foam::SolverPerformance<Type>::singular);
189
+ }
190
+
176
191
  }
177
192
 
178
193
  void Foam::bindFvMatrix(py::module& m)
@@ -183,9 +198,9 @@ void Foam::bindFvMatrix(py::module& m)
183
198
  auto fvVectorMatrix = declare_fvMatrix<Foam::vector>(m, std::string("fvVectorMatrix"));
184
199
  auto fvTensorMatrix = declare_fvMatrix<Foam::tensor>(m, std::string("fvTensorMatrix"));
185
200
 
186
- py::class_<Foam::SolverPerformance<Foam::scalar>>(m, "SolverScalarPerformance");
187
- py::class_<Foam::SolverPerformance<Foam::vector>>(m, "SolverVectorPerformance");
188
- py::class_<Foam::SolverPerformance<Foam::tensor>>(m, "SolverTensorPerformance");
201
+ declare_SolverPerformance<Foam::scalar>(m, "SolverScalarPerformance");
202
+ declare_SolverPerformance<Foam::vector>(m, "SolverVectorPerformance");
203
+ declare_SolverPerformance<Foam::tensor>(m, "SolverTensorPerformance");
189
204
 
190
205
  declare_solve<Foam::scalar>(m);
191
206
  declare_solve<Foam::vector>(m);
@@ -20,6 +20,7 @@ License
20
20
  #include "bind_io.hpp"
21
21
 
22
22
  #include "messageStream.H"
23
+ #include "dictionary.H"
23
24
 
24
25
 
25
26
  namespace Foam
@@ -31,6 +32,11 @@ namespace Foam
31
32
  Info << word(message) << endl;
32
33
  });
33
34
 
35
+ m.def("Info", [](const dictionary& dict)
36
+ {
37
+ Info << dict << endl;
38
+ });
39
+
34
40
  }
35
41
 
36
42
 
@@ -114,6 +114,7 @@ void bindMesh(pybind11::module &m)
114
114
  .def("value", &Foam::Time::timeOutputValue)
115
115
  .def("deltaTValue", [](Foam::Time &self) { return self.deltaTValue(); })
116
116
  .def("loop", &Foam::Time::loop)
117
+ .def("run", &Foam::Time::run)
117
118
  .def("write", &Foam::Time::write)
118
119
  .def("increment", [](Foam::Time &self)
119
120
  { self++; }
@@ -155,6 +156,9 @@ void bindMesh(pybind11::module &m)
155
156
  .def("Sf", &Foam::fvMesh::Sf, py::return_value_policy::reference)
156
157
  .def("magSf", &Foam::fvMesh::magSf, py::return_value_policy::reference)
157
158
  .def("setFluxRequired", &Foam::fvMesh::setFluxRequired)
159
+ .def("solverPerformanceDict", [](const Foam::fvMesh &self)
160
+ { return &self.data().solverPerformanceDict(); },
161
+ py::return_value_policy::reference)
158
162
  // dynamic mesh support
159
163
  .def("changing", [](Foam::fvMesh &self)
160
164
  { return self.changing(); })