├── .github └── workflows │ └── ci.yaml ├── .gitignore ├── Allwclean ├── Allwmake ├── LICENSE ├── README.md ├── applications └── utilities │ ├── foamSmartSimSvd │ ├── Make │ │ ├── files │ │ ├── linux64IcxDPInt32Opt │ │ │ ├── options │ │ │ ├── sourceFiles │ │ │ └── variables │ │ └── options │ ├── createFields.H │ └── foamSmartSimSvd.C │ ├── foamSmartSimSvdDBAPI │ ├── Make │ │ ├── files │ │ ├── linux64IcxDPInt32Opt │ │ │ ├── options │ │ │ ├── sourceFiles │ │ │ └── variables │ │ └── options │ ├── createFields.H │ └── foamSmartSimSvdDBAPI.C │ └── svdToFoam │ ├── Make │ ├── files │ ├── linux64IcxDPInt32Opt │ │ ├── options │ │ ├── sourceFiles │ │ └── variables │ └── options │ └── svdToFoam.C ├── docker ├── Dockerfile ├── README.md └── build.yml ├── docs.md ├── src ├── displacementSmartSimMotionSolver │ ├── Make │ │ ├── files │ │ ├── linux64IcxDPInt32Opt │ │ │ ├── options │ │ │ ├── sourceFiles │ │ │ └── variables │ │ └── options │ ├── displacementSmartSimMotionSolver.C │ └── displacementSmartSimMotionSolver.H ├── functionObjects │ ├── Make │ │ ├── files │ │ ├── linux64IcxDPInt32Opt │ │ │ ├── options │ │ │ ├── sourceFiles │ │ │ └── variables │ │ └── options │ └── fieldsToSmartRedisFunctionObject │ │ ├── fieldsToSmartRedisFunctionObject.C │ │ └── fieldsToSmartRedisFunctionObject.H └── smartRedis │ ├── Make │ ├── files │ └── options │ ├── smartRedisAdapter │ ├── Make │ │ ├── files │ │ └── options │ ├── smartRedisAdapter.C │ └── smartRedisAdapter.H │ └── smartRedisClient │ ├── smartRedisClient.C │ ├── smartRedisClient.H │ └── smartRedisClientTemplates.C ├── tests ├── Make │ ├── files │ └── options └── smartRedisClientTests.C └── tutorials ├── bayesianOptimization ├── BOTorch_TwoObjectiveFunctions.py ├── Bayesian_Optimization_BOTorch_ExpectedImprovement.py ├── Bayesian_Optimization_BOTorch_ProbabilityOfImprovement.py ├── Bayesian_Optimization_BOTorch_UpperConfidenceBound.py ├── chip_cooling_with_new_boundaries │ ├── 0 │ │ ├── U │ │ ├── k │ │ ├── nut │ │ ├── omega │ │ ├── p │ │ ├── p_rgh │ │ └── vorticity │ ├── Allclean │ ├── Allrun.pre │ ├── channel.stl │ ├── constant │ │ └── transportProperties │ ├── foam.foam │ └── system │ │ ├── Allclean │ │ ├── Allrun │ │ ├── controlDict │ │ ├── decomposeParDict │ │ ├── fvSchemes │ │ ├── fvSolution │ │ ├── meshDict │ │ └── topoSetDict ├── pitzDaily │ ├── 0 │ │ ├── .ipynb_checkpoints │ │ │ ├── epsilon-checkpoint │ │ │ └── k-checkpoint │ │ ├── U │ │ ├── epsilon │ │ ├── k │ │ ├── nuTilda │ │ ├── nut │ │ ├── omega │ │ └── p │ ├── constant │ │ ├── polyMesh │ │ │ ├── boundary │ │ │ ├── faces │ │ │ ├── neighbour │ │ │ ├── owner │ │ │ └── points │ │ ├── transportProperties │ │ └── turbulenceProperties │ └── system │ │ ├── blockMeshDict │ │ ├── controlDict │ │ ├── fvSchemes │ │ ├── fvSolution │ │ └── streamlines └── tune_k_epsilon.ipynb ├── functionObject ├── README.md ├── openfoam-ensemble.py ├── openfoam-svd.py └── pitzDaily │ ├── 0 │ ├── U │ ├── epsilon │ ├── k │ ├── nuTilda │ ├── nut │ ├── omega │ └── p │ ├── Allrun │ ├── constant │ ├── transportProperties │ └── turbulenceProperties │ └── system │ ├── blockMeshDict │ ├── controlDict │ ├── decomposeParDict │ ├── fvSchemes │ ├── fvSolution │ └── streamlines ├── meshMotion ├── openfoam-smartsim-mesh-motion.ipynb └── spinningDisk │ ├── 0.orig │ └── pointDisplacement │ ├── Allclean │ ├── Allrun.post │ ├── Allrun.pre │ ├── constant │ ├── dynamicMeshDict │ ├── g │ ├── transportProperties │ └── turbulenceProperties │ └── system │ ├── blockMeshDict │ ├── controlDict │ ├── decomposeParDict │ ├── fvSchemes │ └── fvSolution └── postProcessing └── foamSmartSimSvd ├── Allclean ├── README.md ├── cavity ├── 0 │ ├── U │ └── p ├── Allrun ├── Allrun.pre ├── case.foam ├── constant │ └── transportProperties └── system │ ├── PDRblockMeshDict │ ├── blockMeshDict │ ├── controlDict │ ├── decomposeParDict │ ├── fvSchemes │ └── fvSolution ├── cylinder2D ├── 0.org │ ├── U │ └── p ├── Allclean ├── Allrun ├── constant │ ├── transportProperties │ └── turbulenceProperties └── system │ ├── blockMeshDict │ ├── controlDict │ ├── decomposeParDict │ ├── fvSchemes │ ├── fvSolution │ └── setExprBoundaryFieldsDict ├── foam-smartsim-svd-db-api.ipynb ├── foam-smartsim-svd.ipynb ├── partial_svd.py ├── partitioned-svd-cylinder.ipynb └── reconstruction.py /.github/workflows/ci.yaml: -------------------------------------------------------------------------------- 1 | name: tests_ubuntu 2 | defaults: 3 | run: 4 | shell: bash -o pipefail -i {0} 5 | on: 6 | push: 7 | branches: 8 | - main 9 | - ci 10 | - 'bugfix*' 11 | - 'releases/**' 12 | pull_request: 13 | types: [opened, reopened, synchronize] 14 | workflow_dispatch: 15 | inputs: 16 | debug_enabled: 17 | type: boolean 18 | description: 'Tmate debugging session' 19 | required: false 20 | default: false 21 | 22 | jobs: 23 | build: 24 | strategy: 25 | fail-fast: false 26 | matrix: 27 | openfoam_version: ['2312', '2212'] 28 | smartsim_version: ['0.7.0', '0.6.2'] 29 | database_backend: ['redis'] 30 | ubuntu_version: ['22.04', '20.04'] ## SmartSim not available yet for Python 3.12 on Ubuntu 24 31 | exclude: 32 | - ubuntu_version: '20.04' ## SmartSim 0.7.0 not released on ubuntu 20.04 33 | smartsim_version: '0.7.0' 34 | runs-on: ubuntu-22.04 35 | 36 | container: 37 | image: ghcr.io/ofdatacommittee/openfoam-smartsim:of-${{ matrix.openfoam_version }}-smart-${{ matrix.smartsim_version }}-${{ matrix.database_backend }}-ubuntu-${{ matrix.ubuntu_version }} 38 | env: 39 | CATCH_TIMEOUT: 20 40 | FOAM_FOAMUT: "/tmp/foamUT" 41 | SSDB: "smartdb:6379" 42 | 43 | services: 44 | smartdb: 45 | image: ${{ matrix.database_backend == 'redis' && 'redislabs/redisai' || 'eqalpha/keydb' }} 46 | 47 | steps: 48 | - name: Checkout repository 49 | uses: actions/checkout@v4 50 | 51 | - name: Setup tmate session 52 | uses: mxschmitt/action-tmate@v3 53 | if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }} 54 | with: 55 | detached: true 56 | 57 | - name: Compile 58 | run: | 59 | source /usr/lib/openfoam/openfoam${{ matrix.openfoam_version }}/etc/bashrc 60 | mkdir -p $FOAM_USER_LIBBIN 61 | ./Allwmake 62 | 63 | - name: Compile Tests and Run 64 | run: | 65 | source /usr/lib/openfoam/openfoam${{ matrix.openfoam_version }}/etc/bashrc 66 | ./Allwmake 67 | export SSDB="smartdb:6379" 68 | git clone https://github.com/FoamScience/foamUT $FOAM_FOAMUT 69 | sed -i 's/mpirun/mpirun --oversubscribe/g' $FOAM_FOAMUT/Alltest 70 | ln -s "$PWD"/tests "$FOAM_FOAMUT"/tests/smartSimFOTests 71 | cd $FOAM_FOAMUT || exit 1 72 | rm -rf tests/exampleTests 73 | ./Alltest "$@" 74 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | __pycache__ 4 | .vscode 5 | dynamicCode 6 | linux64GccDPInt32Opt 7 | 8 | # Compiled Object files 9 | *.slo 10 | *.lo 11 | *.o 12 | *.obj 13 | 14 | # Precompiled Headers 15 | *.gch 16 | *.pch 17 | 18 | # Compiled Dynamic libraries 19 | *.so 20 | *.dylib 21 | *.dll 22 | 23 | # Fortran module files 24 | *.mod 25 | *.smod 26 | 27 | # Compiled Static libraries 28 | *.lai 29 | *.la 30 | *.a 31 | *.lib 32 | 33 | # Executables 34 | *.exe 35 | *.out 36 | *.app 37 | 38 | # Editor and misc backup files - anywhere 39 | *~ 40 | .*~ 41 | .*.swp 42 | *.bak 43 | *.bak[0-9][0-9] 44 | \#*\# 45 | 46 | # File-browser settings - anywhere 47 | .directory 48 | 49 | # Backup/recovery versions - anywhere 50 | .#* 51 | 52 | # Objects and archives - anywhere 53 | *.[oa] 54 | *.la 55 | *.so 56 | 57 | # Derived files 58 | lex.yy.c 59 | 60 | # Core dumps 61 | core 62 | 63 | # Dependency files - anywhere 64 | *.dep 65 | 66 | # lnInclude (symlink) directories - anywhere 67 | lnInclude 68 | 69 | # Build directories - anywhere 70 | linux*Clang*/ 71 | linux*Gcc*/ 72 | linux*Icc*/ 73 | solaris*Gcc*/ 74 | SunOS*Gcc*/ 75 | platforms/ 76 | 77 | # Top-level build directories 78 | /build/ 79 | /platforms/ 80 | 81 | # Reinstate wmake rules that might look like build directories 82 | !/wmake/rules/*/ 83 | 84 | # Doxygen generated 85 | doc/Doxygen/html 86 | doc/Doxygen/latex 87 | doc/Doxygen/man 88 | doc/Doxygen/DTAGS 89 | 90 | # Generated files in the main and doc directories 91 | /*.html 92 | /doc/*.html 93 | 94 | # Untracked configuration/preferences files 95 | /etc/prefs.csh 96 | /etc/prefs.sh 97 | /etc/config.csh/prefs.* 98 | /etc/config.sh/prefs.* 99 | /wmake/rules/General/mplibUSER* 100 | 101 | # Source packages - anywhere 102 | *.tar.bz2 103 | *.tar.gz 104 | *.tar.xz 105 | *.tar 106 | *.tgz 107 | *.gtgz 108 | 109 | # Ignore tags or project files in the main directory 110 | /.cproject 111 | /.dir-locals.el 112 | /.project 113 | /.tags 114 | 115 | # Ignore the test directory 116 | /tutorialsTest 117 | 118 | # Ignore decomposition 119 | *processor* 120 | 121 | # Editor and misc backup files - anywhere 122 | *~ 123 | .*~ 124 | .*.swp 125 | *.bak 126 | *.bak[0-9][0-9] 127 | \#*\# 128 | 129 | # File-browser settings - anywhere 130 | .directory 131 | 132 | # Backup/recovery versions - anywhere 133 | .#* 134 | 135 | # Objects and archives - anywhere 136 | *.[oa] 137 | *.la 138 | *.so 139 | 140 | # Derived files 141 | lex.yy.c 142 | 143 | # Core dumps 144 | core 145 | 146 | # Dependency files - anywhere 147 | *.dep 148 | CMakeLists.txt 149 | 150 | # lnInclude (symlink) directories - anywhere 151 | lnInclude 152 | 153 | # Build directories - anywhere 154 | linux*Clang*/ 155 | linux*Gcc*/ 156 | linux*Icc*/ 157 | solaris*Gcc*/ 158 | SunOS*Gcc*/ 159 | platforms/ 160 | linux64GccDPInt32Opt 161 | .clangd/ 162 | **/.cache 163 | 164 | # Top-level build directories 165 | /build/ 166 | /platforms/ 167 | 168 | # Reinstate wmake rules that might look like build directories 169 | !/wmake/rules/*/ 170 | 171 | # Doxygen generated 172 | doc/Doxygen/html 173 | doc/Doxygen/latex 174 | doc/Doxygen/man 175 | doc/Doxygen/DTAGS 176 | 177 | # Generated files in the main and doc directories 178 | /*.html 179 | /doc/*.html 180 | 181 | # Untracked configuration/preferences files 182 | /etc/prefs.csh 183 | /etc/prefs.sh 184 | /etc/config.csh/prefs.* 185 | /etc/config.sh/prefs.* 186 | /wmake/rules/General/mplibUSER* 187 | 188 | # Source packages - anywhere 189 | *.tar.bz2 190 | *.tar.gz 191 | *.tar.xz 192 | *.tar 193 | *.tgz 194 | *.gtgz 195 | 196 | # Ignore tags or project files in the main directory 197 | /.cproject 198 | /.dir-locals.el 199 | /.project 200 | /.tags 201 | 202 | # Ignore test cases 203 | **/compile_commands.json 204 | **/*TestDriver 205 | **/testDriver 206 | **/*wmake 207 | 208 | # Ignore XML reports 209 | *.xml 210 | 211 | # SmartRedis/smartSim 212 | smartredis 213 | *.out 214 | *.err 215 | *.dat 216 | log.* 217 | *.log 218 | 219 | # polyMesh 220 | polyMesh/ 221 | 222 | # Jupyter Notebook checkpoints 223 | .ipynb_checkpoints/ 224 | -------------------------------------------------------------------------------- /Allwclean: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [ -d smartredis ]; 4 | then 5 | make clean --directory=smartredis 6 | fi 7 | wclean all src 8 | wclean all applications 9 | -------------------------------------------------------------------------------- /Allwmake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | 3 | orig_dit="$(pwd)" 4 | 5 | # Create the $FOAM_USER_LIBBIN if not existing. 6 | # - This happens with a fresh OpenFOAM installation. 7 | # - openfoam-smartsim libraries are placed into $FOAM_USER_LIBBIN 8 | if [ ! -d "$FOAM_USER_LIBBIN" ]; 9 | then 10 | mkdir -p $FOAM_USER_LIBBIN 11 | fi 12 | 13 | ## Compile SmartRedis libs 14 | export _REPO_ROOT="$(git rev-parse --show-toplevel)" 15 | cd "$_REPO_ROOT" || exit 1 16 | export FOAM_SMARTREDIS="$_REPO_ROOT/smartredis" 17 | if [ ! -d "$FOAM_SMARTREDIS" ]; then 18 | git clone https://github.com/CrayLabs/SmartRedis "$FOAM_SMARTREDIS" 19 | else 20 | cd "$FOAM_SMARTREDIS" || exit 1 21 | git pull origin develop 22 | cd "${_REPO_ROOT}" || exit 1 23 | fi 24 | cd "${FOAM_SMARTREDIS}" || exit 1 25 | 26 | # Force clean: ensures binaries match OpenFOAM's compiler. 27 | make clean 28 | 29 | # Set compiler options 30 | if [ $WM_COMPILER == "Gcc" ]; then 31 | echo "Using gcc and g++" 32 | export CC=gcc 33 | export CXX=g++ 34 | elif [ $WM_COMPILER == "Icx" ]; then 35 | echo "Using icpx" 36 | export CC=icx-cc 37 | export CXX=icpx 38 | fi 39 | make lib 40 | cd "$_REPO_ROOT" || exit 1 41 | cp $FOAM_SMARTREDIS/install/lib/libsmartredis.so $FOAM_USER_LIBBIN 42 | cp $FOAM_SMARTREDIS/build/Release/hiredis-prefix/src/hiredis-build/libhiredis.a $FOAM_USER_LIBBIN 43 | cp $FOAM_SMARTREDIS/build/Release/redis++-prefix/src/redis++-build/libredis++.a $FOAM_USER_LIBBIN 44 | export FOAM_CODE_TEMPLATES=$_REPO_ROOT/etc/dynamicCode/ 45 | 46 | ## Compile OpenFOAM libs 47 | wmake libso src/smartRedis 48 | wmake libso src/functionObjects 49 | wmake libso src/displacementSmartSimMotionSolver 50 | 51 | ## Compile OpenFOAM utilities 52 | wmake all applications 53 | 54 | cd "$orig_dir" || exit 1 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # openfoam-smartsim 2 | 3 | ## General Description 4 | 5 | Sub-module for [OpenFOAM][OpenFOAM] that provides a solver for embedding [SmartSim][SmartSim] 6 | and its external dependencies (i.e. [SmartRedis][SmartRedis]) into arbitrary OpenFOAM simulations. 7 | 8 | The sub-module provides examples for coupling OpenFOAM with SmartSim 9 | - pre-processing application 10 | - function object 11 | - mesh motion solver 12 | - parameter estimation 13 | 14 | ## License 15 | 16 | The source code license: GPL-3.0-or-later 17 | 18 | ## Requirements 19 | 20 | 1. [OpenFOAM-v2312] or newer, or a recent [development version][OpenFOAM-git] 21 | from [OpenFOAM.com][OpenFOAM]. 22 | 2. [SmartSim] 0.6.2 [installation instructions](https://www.craylabs.org/docs/installation_instructions/basic.html) 23 | 3. [SmartRedis] latest, installed automatically by `./Allwmake` 24 | 4. [PyFoam,pandas,matplotlib]: pip install PyFoam pandas matplotlib 25 | 26 | ## Building 27 | 28 | ### Tested compilers 29 | 30 | * `WM_COMPILER=Gcc` , compilers: g++ 11.4.0 31 | * `WM_COMPILER=Icx`, compilers: Intel(R) oneAPI DPC++/C++ Compiler 2023.2.4 32 | 33 | ### Compiling and installation 34 | 35 | The OpenFOAM-SmartSim coupling functions over a connection that OpenFOAM as a client maintains with the SmartRedis database. This means that OpenFOAM elements (application, solver, function object, boundary condition, etc.) must be able to include SmartRedis source folders and link with a SmartRedis library. To facilitate this, an `./Allwmake` Bash script is provided. 36 | 37 | To build the project, you need to have a working OpenFOAM environment: 38 | 39 | ``` 40 | openfoam-smartsim > ./Allwmake 41 | ``` 42 | 43 | - This will fetch and compile the latest-n-greatest [SmartRedis](https://github.com/CrayLabs/SmartRedis) for you. 44 | - SmartRedis libraries will be installed into `$FOAM_USER_LIBBIN`. 45 | - OpenFOAM+SmartSim libraries and applictaions will also be installed into `$FOAM_USER_LIBBIN`. 46 | 47 | ## Running 48 | 49 | OpenFOAM+SmartSim workflows are implemented in Python programs where SmartSim "governs" the computational workflow. The workflows can be implemented in Jupyter Notebooks or as Python programs. 50 | 51 | Examples that use Jupyter Notebooks set some requirements: 52 | 53 | - Make sure port 8000 is free. `ss -plant | grep 8000` should return nothing! 54 | 55 | Head to one of the tutorials, and run the jupyter notebook or a python program you find there. 56 | 57 | ## Authors / Contributors 58 | 59 | | Name | Affiliation | Email 60 | |------|-------|-----------| 61 | | Alessandro Rigazzi | HPE | | 62 | | Andrew Shao | HPE | | 63 | | Andre Weiner | TU Dresden | | 64 | | Matt Ellis | HPE | | 65 | | Mohammed Elwardi Fadeli | TU Darmstadt | | 66 | | Tomislav Maric | TU Darmstadt | | 67 | 68 | ---- 69 | 70 | [OpenFOAM]: https://www.openfoam.com 71 | [OpenFOAM-v2312]: https://www.openfoam.com/releases/openfoam-v2312/ 72 | [OpenFOAM-git]: https://develop.openfoam.com/Development/openfoam 73 | 74 | [SmartSim]: https://github.com/CrayLabs/SmartSim 75 | [SmartSim-Installation]: https://www.craylabs.org/docs/installation_instructions/basic.html 76 | [SmartRedis]: https://www.craylabs.org/docs/installation_instructions/basic.html 77 | 78 | ## References 79 | 80 | Maric, T., Fadeli, M. E., Rigazzi, A., Shao, A., & Weiner, A. (2024). Combining Machine Learning with Computational Fluid Dynamics using OpenFOAM and SmartSim. arXiv preprint [https://doi.org/10.1007/s11012-024-01797-z](https://doi.org/10.1007/s11012-024-01797-z). 81 | -------------------------------------------------------------------------------- /applications/utilities/foamSmartSimSvd/Make/files: -------------------------------------------------------------------------------- 1 | foamSmartSimSvd.C 2 | 3 | EXE = $(FOAM_USER_APPBIN)/foamSmartSimSvd 4 | -------------------------------------------------------------------------------- /applications/utilities/foamSmartSimSvd/Make/linux64IcxDPInt32Opt/options: -------------------------------------------------------------------------------- 1 | # 0 "Make/options" 2 | # 0 "" 3 | # 0 "" 4 | # 8 "" 5 | # 1 "/usr/include/stdc-predef.h" 1 3 4 6 | 7 | # 17 "/usr/include/stdc-predef.h" 3 4 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | # 45 "/usr/include/stdc-predef.h" 3 4 28 | 29 | # 55 "/usr/include/stdc-predef.h" 3 4 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | # 8 "" 2 40 | # 1 "Make/options" 41 | EXE_INC = -std=c++17 -Wno-old-style-cast -I$(LIB_SRC)/finiteVolume/lnInclude -I$(LIB_SRC)/meshTools/lnInclude -I../../../smartredis/install/include -I../../../src/smartRedis/lnInclude 42 | 43 | 44 | 45 | 46 | 47 | EXE_LIBS = -lfiniteVolume -lmeshTools -L$(FOAM_USER_LIBBIN) -lhiredis -lredis++ -lsmartredis 48 | 49 | # options 50 | -------------------------------------------------------------------------------- /applications/utilities/foamSmartSimSvd/Make/linux64IcxDPInt32Opt/sourceFiles: -------------------------------------------------------------------------------- 1 | SOURCE = \ 2 | foamSmartSimSvd.C \ 3 | 4 | # sources 5 | -------------------------------------------------------------------------------- /applications/utilities/foamSmartSimSvd/Make/linux64IcxDPInt32Opt/variables: -------------------------------------------------------------------------------- 1 | EXE = $(FOAM_USER_APPBIN)/foamSmartSimSvd 2 | -------------------------------------------------------------------------------- /applications/utilities/foamSmartSimSvd/Make/options: -------------------------------------------------------------------------------- 1 | EXE_INC = -std=c++17 -Wno-old-style-cast \ 2 | -I$(LIB_SRC)/finiteVolume/lnInclude \ 3 | -I$(LIB_SRC)/meshTools/lnInclude \ 4 | -I../../../smartredis/install/include \ 5 | -I../../../src/smartRedis/lnInclude 6 | 7 | EXE_LIBS = \ 8 | -lfiniteVolume \ 9 | -lmeshTools \ 10 | -L$(FOAM_USER_LIBBIN) \ 11 | -lhiredis -lredis++ \ 12 | -lsmartredis 13 | -------------------------------------------------------------------------------- /applications/utilities/foamSmartSimSvd/createFields.H: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | www.openfoam.com 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | Copyright (C) 2023 9 | ------------------------------------------------------------------------------- 10 | License 11 | This file is part of OpenFOAM. 12 | 13 | OpenFOAM is free software: you can redistribute it and/or modify it 14 | under the terms of the GNU General Public License as published by 15 | the Free Software Foundation, either version 3 of the License, or 16 | (at your option) any later version. 17 | 18 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 19 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 21 | for more details. 22 | 23 | You should have received a copy of the GNU General Public License 24 | along with OpenFOAM. If not, see . 25 | 26 | Application 27 | foamSmartSimSvd 28 | 29 | Description 30 | 31 | Uses SmartSim/SmartRedis for computing Singular Value Decomposition 32 | of OpenFOAM fields. 33 | 34 | \*---------------------------------------------------------------------------*/ 35 | 36 | #include "regIOobject.H" 37 | 38 | // Initialize empty shared pointers (Foam::tmp) 39 | tmp inputVolScalarFieldTmp(nullptr); 40 | tmp inputVolVectorFieldTmp(nullptr); 41 | 42 | // Create the field header 43 | IOobject fieldHeader 44 | ( 45 | fieldName, 46 | currentTime.name(), 47 | runTime, 48 | IOobject::MUST_READ 49 | ); 50 | 51 | // If the cell centered scalar field is available for reading 52 | if (fieldHeader.typeHeaderOk(true, true, false)) 53 | { 54 | inputVolScalarFieldTmp = new volScalarField(fieldHeader, mesh); 55 | } 56 | // If the cell centered vector field is available for reading 57 | else if (fieldHeader.typeHeaderOk(true, true, false)) 58 | { 59 | inputVolVectorFieldTmp = new volVectorField(fieldHeader, mesh); 60 | } 61 | 62 | // ************************************************************************* // 63 | -------------------------------------------------------------------------------- /applications/utilities/foamSmartSimSvdDBAPI/Make/files: -------------------------------------------------------------------------------- 1 | foamSmartSimSvdDBAPI.C 2 | 3 | EXE = $(FOAM_USER_APPBIN)/foamSmartSimSvdDBAPI 4 | -------------------------------------------------------------------------------- /applications/utilities/foamSmartSimSvdDBAPI/Make/linux64IcxDPInt32Opt/options: -------------------------------------------------------------------------------- 1 | # 0 "Make/options" 2 | # 0 "" 3 | # 0 "" 4 | # 8 "" 5 | # 1 "/usr/include/stdc-predef.h" 1 3 4 6 | 7 | # 17 "/usr/include/stdc-predef.h" 3 4 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | # 45 "/usr/include/stdc-predef.h" 3 4 28 | 29 | # 55 "/usr/include/stdc-predef.h" 3 4 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | # 8 "" 2 40 | # 1 "Make/options" 41 | EXE_INC = -std=c++17 -Wno-old-style-cast -I$(LIB_SRC)/finiteVolume/lnInclude -I$(LIB_SRC)/meshTools/lnInclude -I../../../smartredis/install/include -I../../../src/smartRedis/lnInclude 42 | 43 | 44 | 45 | 46 | 47 | EXE_LIBS = -lfiniteVolume -lmeshTools -L$(FOAM_USER_LIBBIN) -lhiredis -lredis++ -lsmartredis -lsmartRedisClient 48 | 49 | # options 50 | -------------------------------------------------------------------------------- /applications/utilities/foamSmartSimSvdDBAPI/Make/linux64IcxDPInt32Opt/sourceFiles: -------------------------------------------------------------------------------- 1 | SOURCE = \ 2 | foamSmartSimSvdDBAPI.C \ 3 | 4 | # sources 5 | -------------------------------------------------------------------------------- /applications/utilities/foamSmartSimSvdDBAPI/Make/linux64IcxDPInt32Opt/variables: -------------------------------------------------------------------------------- 1 | EXE = $(FOAM_USER_APPBIN)/foamSmartSimSvdDBAPI 2 | -------------------------------------------------------------------------------- /applications/utilities/foamSmartSimSvdDBAPI/Make/options: -------------------------------------------------------------------------------- 1 | EXE_INC = -std=c++17 -Wno-old-style-cast \ 2 | -I$(LIB_SRC)/finiteVolume/lnInclude \ 3 | -I$(LIB_SRC)/meshTools/lnInclude \ 4 | -I../../../smartredis/install/include \ 5 | -I../../../src/smartRedis/lnInclude 6 | 7 | EXE_LIBS = \ 8 | -lfiniteVolume \ 9 | -lmeshTools \ 10 | -L$(FOAM_USER_LIBBIN) \ 11 | -lhiredis -lredis++ \ 12 | -lsmartredis \ 13 | -lsmartRedisClient 14 | -------------------------------------------------------------------------------- /applications/utilities/foamSmartSimSvdDBAPI/createFields.H: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | www.openfoam.com 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | Copyright (C) 2023 9 | ------------------------------------------------------------------------------- 10 | License 11 | This file is part of OpenFOAM. 12 | 13 | OpenFOAM is free software: you can redistribute it and/or modify it 14 | under the terms of the GNU General Public License as published by 15 | the Free Software Foundation, either version 3 of the License, or 16 | (at your option) any later version. 17 | 18 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 19 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 21 | for more details. 22 | 23 | You should have received a copy of the GNU General Public License 24 | along with OpenFOAM. If not, see . 25 | 26 | Application 27 | foamSmartSimSvd 28 | 29 | Description 30 | 31 | Uses SmartSim/SmartRedis for computing Singular Value Decomposition 32 | of OpenFOAM fields. 33 | 34 | \*---------------------------------------------------------------------------*/ 35 | 36 | #include "regIOobject.H" 37 | 38 | // Initialize empty shared pointers (Foam::tmp) 39 | tmp inputVolScalarFieldTmp(nullptr); 40 | tmp inputVolVectorFieldTmp(nullptr); 41 | 42 | // Create the field header 43 | IOobject fieldHeader 44 | ( 45 | fieldName, 46 | currentTime.name(), 47 | mesh, 48 | IOobject::MUST_READ 49 | ); 50 | 51 | // If the cell centered scalar field is available for reading 52 | if (fieldHeader.typeHeaderOk(true, true, false)) 53 | { 54 | Info << "Reading input field " << fieldHeader.objectPath() << endl; 55 | inputVolScalarFieldTmp = new volScalarField(fieldHeader, mesh); 56 | } 57 | // If the cell centered vector field is available for reading 58 | else if (fieldHeader.typeHeaderOk(true, true, false)) 59 | { 60 | Info << "Reading input field " << fieldHeader.objectPath() << endl; 61 | inputVolVectorFieldTmp = new volVectorField(fieldHeader, mesh); 62 | } 63 | 64 | // ************************************************************************* // 65 | -------------------------------------------------------------------------------- /applications/utilities/foamSmartSimSvdDBAPI/foamSmartSimSvdDBAPI.C: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | www.openfoam.com 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | Copyright (C) 2023 9 | ------------------------------------------------------------------------------- 10 | License 11 | This file is part of OpenFOAM. 12 | 13 | OpenFOAM is free software: you can redistribute it and/or modify it 14 | under the terms of the GNU General Public License as published by 15 | the Free Software Foundation, either version 3 of the License, or 16 | (at your option) any later version. 17 | 18 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 19 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 21 | for more details. 22 | 23 | You should have received a copy of the GNU General Public License 24 | along with OpenFOAM. If not, see . 25 | 26 | Application 27 | foamSmartSimSvd 28 | 29 | Description 30 | 31 | Uses SmartSim/SmartRedis for computing Singular Value Decomposition 32 | of OpenFOAM fields. 33 | 34 | \*---------------------------------------------------------------------------*/ 35 | 36 | #include "fvCFD.H" 37 | #include "wordList.H" 38 | #include "timeSelector.H" 39 | #include "smartRedisClient.H" 40 | 41 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 42 | 43 | int main(int argc, char *argv[]) 44 | { 45 | // Selecting the time step folders for the approximated fields. 46 | timeSelector::addOptions(); 47 | 48 | // Add the option to the application for the name of the approximated field. 49 | argList::addOption 50 | ( 51 | "fieldName", 52 | "fieldName", 53 | "Name of the approximated field, e.g. p." 54 | ); 55 | 56 | // OpenFOAM boilerplate: set root folder and options 57 | #include "setRootCase.H" 58 | #include "createTime.H" 59 | #include "createMesh.H" 60 | 61 | // Read the name of the approximated field from the command line option 62 | // foamSmartSimDmd -case cavity -fieldName p 63 | const word fieldName = args.get("fieldName"); 64 | Info << "Approximating field " << fieldName << endl; 65 | 66 | // Create a database connection 67 | dictionary dbDict; 68 | dbDict.set("region", polyMesh::defaultRegion); 69 | dbDict.set("clusterMode", false); 70 | dbDict.set("clientName", "default"); 71 | smartRedisClient db 72 | ( 73 | "foamSmartSimSvdDBAPI", 74 | runTime, 75 | dbDict 76 | ); 77 | 78 | // Create a list of all time step folders from the case folder. 79 | instantList inputTimeDirs = timeSelector::select0(runTime, args); 80 | 81 | // Posting number of processed time steps 82 | db.addToMetadata("NTimes", Foam::name(inputTimeDirs.size())); 83 | 84 | forAll(inputTimeDirs, timeI) 85 | { 86 | const auto currentTime = inputTimeDirs[timeI]; 87 | #include "createFields.H" 88 | wordList fields{fieldName}; 89 | db.sendGeometricFields(fields, wordList{"internal"}); 90 | 91 | if (timeI+1 != inputTimeDirs.size()) 92 | { 93 | runTime.setDeltaT(inputTimeDirs[timeI+1].value() - inputTimeDirs[timeI].value()); 94 | } 95 | ++runTime; 96 | } 97 | 98 | 99 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 100 | 101 | Info<< nl; 102 | Info<< "End\n" << endl; 103 | 104 | return 0; 105 | } 106 | 107 | 108 | // ************************************************************************* // 109 | -------------------------------------------------------------------------------- /applications/utilities/svdToFoam/Make/files: -------------------------------------------------------------------------------- 1 | svdToFoam.C 2 | 3 | EXE = $(FOAM_USER_APPBIN)/svdToFoam 4 | -------------------------------------------------------------------------------- /applications/utilities/svdToFoam/Make/linux64IcxDPInt32Opt/options: -------------------------------------------------------------------------------- 1 | # 0 "Make/options" 2 | # 0 "" 3 | # 0 "" 4 | # 8 "" 5 | # 1 "/usr/include/stdc-predef.h" 1 3 4 6 | 7 | # 17 "/usr/include/stdc-predef.h" 3 4 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | # 45 "/usr/include/stdc-predef.h" 3 4 28 | 29 | # 55 "/usr/include/stdc-predef.h" 3 4 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | # 8 "" 2 40 | # 1 "Make/options" 41 | EXE_INC = -std=c++17 -Wno-old-style-cast -I$(LIB_SRC)/finiteVolume/lnInclude -I$(LIB_SRC)/meshTools/lnInclude -I../../../smartredis/install/include -I../../../src/smartRedis/lnInclude 42 | 43 | 44 | 45 | 46 | 47 | EXE_LIBS = -lfiniteVolume -lmeshTools -L$(FOAM_USER_LIBBIN) -lhiredis -lredis++ -lsmartredis 48 | 49 | # options 50 | -------------------------------------------------------------------------------- /applications/utilities/svdToFoam/Make/linux64IcxDPInt32Opt/sourceFiles: -------------------------------------------------------------------------------- 1 | SOURCE = \ 2 | svdToFoam.C \ 3 | 4 | # sources 5 | -------------------------------------------------------------------------------- /applications/utilities/svdToFoam/Make/linux64IcxDPInt32Opt/variables: -------------------------------------------------------------------------------- 1 | EXE = $(FOAM_USER_APPBIN)/svdToFoam 2 | -------------------------------------------------------------------------------- /applications/utilities/svdToFoam/Make/options: -------------------------------------------------------------------------------- 1 | EXE_INC = -std=c++17 -Wno-old-style-cast \ 2 | -I$(LIB_SRC)/finiteVolume/lnInclude \ 3 | -I$(LIB_SRC)/meshTools/lnInclude \ 4 | -I../../../smartredis/install/include \ 5 | -I../../../src/smartRedis/lnInclude 6 | 7 | EXE_LIBS = \ 8 | -lfiniteVolume \ 9 | -lmeshTools \ 10 | -L$(FOAM_USER_LIBBIN) \ 11 | -lhiredis -lredis++ \ 12 | -lsmartredis 13 | -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG UBUNTU_VERSION # Eg. 22.04 2 | FROM ubuntu:${UBUNTU_VERSION} 3 | # To build this image from this folder with OpenFOAM v2206: 4 | # docker build --build-arg OPENFOAM_VERSION=2206 --build-tag SMARTSIM_VERSION=0.7.0 -t openfoam-smartsim:latest . 5 | 6 | ARG SMARTSIM_VERSION # Eg. 0.6.2 7 | ARG OPENFOAM_VERSION # Eg. 2206 8 | ARG DATABASE_BACKEND=redis # redis or keydb 9 | LABEL maintainer="Mohammed Elwardi Fadeli " 10 | LABEL source="https://github.com/OFDataCommittee/openfoam-smartsim" 11 | 12 | # Install and setup 13 | ENV DEBIAN_FRONTEND=noninteractive 14 | ENV SHELL=/usr/bin/bash 15 | RUN apt update -y && \ 16 | apt install -y --no-install-recommends git-lfs libpython3-dev pip cmake \ 17 | sudo apt-utils vim curl wget software-properties-common \ 18 | git-core cmake openssh-server gcc g++ \ 19 | binutils libopenmpi-dev openmpi-bin openmpi-common openmpi-doc 20 | 21 | # Set up OpenFOAM repositories 22 | RUN sh -c "curl https://dl.openfoam.com/add-debian-repo.sh | bash" 23 | RUN apt update -y && \ 24 | apt install -y --no-install-recommends openfoam${OPENFOAM_VERSION}-default 25 | RUN apt clean && apt purge && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 26 | # Set up smartsim 27 | RUN pip install smartsim==${SMARTSIM_VERSION} && \ 28 | if [ "${DATABASE_BACKEND}" = "keydb" ]; then smart build --device cpu --no_tf --no_pt; else smart build --device cpu --no_tf --no_pt --keydb; fi 29 | ENV USER openfoam 30 | ENV HOME=/home/${USER} 31 | RUN adduser --disabled-password --gecos "" ${USER} -u 1001 && \ 32 | echo "ALL ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers 33 | USER openfoam 34 | RUN echo "source /usr/lib/openfoam/openfoam${OPENFOAM_VERSION}/etc/bashrc" >> ${HOME}/.bashrc 35 | RUN . "/usr/lib/openfoam/openfoam${OPENFOAM_VERSION}/etc/bashrc" && mkdir -p $FOAM_USER_LIBBIN && mkdir -p $FOAM_USER_APPBIN 36 | 37 | 38 | #COPY bin/uid_entrypoint /usr/local/bin/uid_entrypoint 39 | #ENTRYPOINT ["uid_entrypoint"] 40 | -------------------------------------------------------------------------------- /docker/README.md: -------------------------------------------------------------------------------- 1 | # Continuous Integration 2 | 3 | ## Overview 4 | 5 | We continuously test against recent versions of the following software pieces: 6 | - Ubuntu 7 | - OpenFOAM 8 | - SmartSim 9 | - Database backend (redis, or keydb) 10 | 11 | In particular, by testing on multiple versions of Ubuntu distribution, we make sure 12 | things work on the default toolchain versions (Compilers, system OpenMPI, ..., etc) 13 | 14 | We use [Github Container Registry](https://ghcr.io/) to store the Docker images necessary for 15 | CI workflows. 16 | 17 | ## Instructions for automated image builds 18 | 19 | > [!NOTE] 20 | > You will want to install ansible (locally) to build the images easily: `pip install ansible`. 21 | > Each image is a little than 2GB so make sure you have enough disk space. 22 | 23 | 1. In [docker/build.yml](docker/build.yml) file, add the new version in the relevant fact task. 24 | - For example, to add a new version of OpenFOAM, add the version to `openfoam_versions` 25 | - Then run `ansible-playbook build.yml --extra-vars "username=github_user token=$GITHUB_TOKEN` 26 | to build the corresponding image and push it. 27 | - When building the images locally, you can speed the process by removing other software versions 28 | and keeping only the new one 29 | 2. In [.github/workflows/ci.yaml](.github/workflows/ci.yaml) file, add the new version in the relevant 30 | `strategy` section. 31 | - For example, to add a new version of OpenFOAM, add the version to `jobs.build.strategy.matrix.openfoam_version` 32 | - Then commit the changes to the repository. 33 | 34 | ## Instructions for manual image builds 35 | 36 | ```sh 37 | cd docker 38 | docker build \ 39 | --build-arg OPENFOAM_VERSION=2312 \ 40 | --build-arg UBUNTU_VERSION=22.04 \ 41 | --build-arg DATABASE_BACKEND=redis \ 42 | --build-arg SMARTSIM_VERSION=0.7.0 \ 43 | -t ghcr.io//openfoam-smartsim:of-2312-smartsim-0.7.0-redis-ubuntu-22.04 . 44 | ``` 45 | -------------------------------------------------------------------------------- /docker/build.yml: -------------------------------------------------------------------------------- 1 | # ansible-playbook build.yml --extra-vars "username=user token=token" 2 | --- 3 | - name: Build openfoam-smartsim CI infrastructure 4 | hosts: localhost 5 | gather_facts: false 6 | vars: 7 | ansible_python_interpreter: /usr/bin/python3 8 | 9 | tasks: 10 | - name: Install docker python support for ansible 11 | pip: 12 | name: docker 13 | state: present 14 | 15 | - name: Define list of OpenFOAM versions 16 | set_fact: 17 | openfoam_versions: 18 | - "2312" 19 | - "2212" 20 | 21 | - name: Define list of SmartSim versions 22 | set_fact: 23 | smartsim_versions: 24 | - "0.7.0" 25 | - "0.6.2" 26 | 27 | - name: Define list of DB backends 28 | set_fact: 29 | database_backends: 30 | - "redis" 31 | 32 | - name: Define list of Ubuntu versions 33 | set_fact: 34 | ubuntu_versions: 35 | #- "24.04" ## SmartSim not available for Python 3.12 36 | - "22.04" 37 | - "20.04" 38 | 39 | - name: Login to GitHub Container Registry 40 | docker_login: 41 | username: "{{ username }}" 42 | password: "{{ token }}" 43 | registry_url: "https://ghcr.io" 44 | 45 | - name: Build Docker images 46 | docker_image: 47 | name: "ghcr.io/{{ username }}/openfoam-smartsim:of-{{ item.0 }}-smart-{{ item.1 }}-{{ item.2 }}-ubuntu-{{ item.3 }}" 48 | source: "build" 49 | build: 50 | path: "." 51 | dockerfile: "Dockerfile" 52 | pull: yes 53 | args: 54 | OPENFOAM_VERSION: "{{ item.0 }}" 55 | SMARTSIM_VERSION: "{{ item.1 }}" 56 | DATABASE_BACKEND: "{{ item.2 }}" 57 | UBUNTU_VERSION: "{{ item.3 }}" 58 | loop: "{{ openfoam_versions|product(smartsim_versions, database_backends, ubuntu_versions)|list }}" 59 | when: "not (item.1 == '0.7.0' and item.3 == '20.04')" 60 | async: 1200 61 | poll: 0 62 | register: async_result 63 | 64 | - name: Wait for all build tasks to complete 65 | async_status: 66 | jid: "{{ item.ansible_job_id }}" 67 | loop: "{{ async_result.results }}" 68 | when: item.changed 69 | register: async_status_result 70 | until: async_status_result.finished 71 | retries: 20 72 | delay: 60 73 | 74 | - name: Push Docker images to GitHub Container Registry 75 | docker_image: 76 | name: "ghcr.io/ofdatacommittee/openfoam-smartsim:of-{{ item.0 }}-smart-{{ item.1 }}-{{ item.2 }}-ubuntu-{{ item.3 }}" 77 | source: local 78 | push: yes 79 | loop: "{{ openfoam_versions|product(smartsim_versions, database_backends, ubuntu_versions)|list }}" 80 | when: "not (item.1 == '0.7.0' and item.3 == '20.04')" 81 | -------------------------------------------------------------------------------- /docs.md: -------------------------------------------------------------------------------- 1 | # Function Objects for SmartRedis-OpenFOAM interaction 2 | 3 | ## `smartRedisClient` 4 | 5 | This class is the building block for all SmartRedis-OpenFOAM interactions. It provides an interface to SmartRedis 6 | databases in three API levels: 7 | 8 | 1. **Service API calls,** which take only a list of OpenFOAM field names as an argument. Interactions with the DB 9 | are then handled automatically. Examples of these calls are 10 | - `void smartRedisClient::sendGeometricFields(const wordList& fields)` 11 | - `void smartRedisClient::getGeometricFields(const wordList& fields)` 12 | 2. **Developer API calls,** which take at least a `DataSet` object as an argument. These calls only handle local DataSet 13 | objects, and do not interact with the DB. Examples of these calls are 14 | - `void smartRedisClient::packFields(DataSet&, const wordList&)` 15 | - `void smartRedisClient::getFields(DataSet&, const wordList& fields)` 16 | 3. **Generic-interaction API calls,** which deal with send and receiving a `List` of data elements to/from 17 | the database directly, without packing things into datasets. These are great for one-time interactions and are 18 | aware of MPI ranks. Examples of these calls include: 19 | - `void smartRedisClient::sendList(List& lst, const word& newName)` 20 | - `void smartRedisClient::getList(List& lst, const word& name)` 21 | 22 | This class also manages: 23 | 24 | - A naming convention of tensors on the Database which correspond to OpenFOAM fields (or parts of them) 25 | - A shared client between all `smartRedisClient` objects 26 | - A metadata `DataSet` which holds the naming convention templates and any arbitrary data a user 27 | of this class may deem important 28 | 29 | ### Technical notes 30 | 31 | - The metadata dataset is posted to the database at construction of the `smartRedisClient` object 32 | through `postMetadata()` member method. 33 | - This method posts everything it finds in `namingConvention_` member (a `HashTable`). Hence, 34 | Any class inheriting from `smartRedisClient` can add its own/override metadata to the database 35 | by populating `namingConvention_` and calling `postMetadata()`. 36 | - To fetch the name of the dataset, one can 37 | ```cpp 38 | // db is a smartRedisClient object 39 | db.updateNamingConventionState(); 40 | word dsName = db.extractName("dataset", db.namingConventionState()) 41 | ``` 42 | - By default, all field-related methods treat the "internal" field 43 | - But a list of boundary patches can be supplied 44 | - And if an MPI rank does not have the particular patch allocated (size == 0), it will not be 45 | communicated with the database. Clients from other languages need to take this into consideration. 46 | 47 | ## `fieldsToSmartRedisFunctionObject` 48 | 49 | This function object is used to pack and send (one-way communication to DB) selected OpenFOAM fields once per time step. 50 | 51 | To send `p`, `U` and `phi` "internal" fields to the database every time step, one could use: 52 | ``` 53 | functions 54 | { 55 | pUPhiTest 56 | { 57 | type fieldsToSmartRedis; 58 | libs ("libsmartredisFunctionObjects.so"); 59 | clusterMode off; 60 | fields (p U phi); 61 | patches (internal); 62 | } 63 | } 64 | ``` 65 | 66 | ### Technical notes 67 | 68 | - This class defines (and brag about) the following naming conventions, which are found in the `pUPhiTest_metadata` dataset: 69 | ``` 70 | The following Jinja2 templates define the naming convention: 71 | { 72 | field "field_name_{{ name }}_patch_{{ patch }}"; 73 | dataset "pUPhiTest_time_index_{{ time_index }}_mpi_rank_{{ mpi_rank }}"; 74 | } 75 | ``` 76 | - After running the Jinja2 templating engine on these conventions, a full field name on the database for the 77 | following data: 78 | ``` 79 | time_index = 200 80 | name = p 81 | patch = internal 82 | mpi_rank = 0 83 | ``` 84 | would look like `{pUPhiTest_time_index_200_mpi_rank_0}.field_name_p_patch_internal`. 85 | - At the moment, internal and boundary patch parts of volume and surface fields with 86 | components of the following types are supported: 87 | - scalar 88 | - vector 89 | - tensor, symmetric tensor, and spherical tensor 90 | 91 | ## Unit tests 92 | 93 | The Unit Tests present in `tests` folder are meant to be run with [foamUT](https://github.com/FoamScience/foamUT) 94 | as done in corresponding CI jobs. If you want to run them locally, you'll need a RedisAI server running on `localhost:8000` 95 | (or whatever `SSDB` is for you; this is the default value set in `SOURCEME.sh`). 96 | 97 | For example you can simply: 98 | ```bash 99 | docker run -p 8000:6379 --rm redislabs/redisai 100 | ``` 101 | 102 | The unit tests show the intended use of important bits of the library and, in general, what is tested there can be 103 | trusted not to change often (at least in terms of API) during the development of this toolkit. 104 | -------------------------------------------------------------------------------- /src/displacementSmartSimMotionSolver/Make/files: -------------------------------------------------------------------------------- 1 | displacementSmartSimMotionSolver.C 2 | 3 | LIB = $(FOAM_USER_LIBBIN)/libsmartSimMotionSolvers 4 | -------------------------------------------------------------------------------- /src/displacementSmartSimMotionSolver/Make/linux64IcxDPInt32Opt/options: -------------------------------------------------------------------------------- 1 | # 0 "Make/options" 2 | # 0 "" 3 | # 0 "" 4 | # 8 "" 5 | # 1 "/usr/include/stdc-predef.h" 1 3 4 6 | 7 | # 17 "/usr/include/stdc-predef.h" 3 4 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | # 45 "/usr/include/stdc-predef.h" 3 4 28 | 29 | # 55 "/usr/include/stdc-predef.h" 3 4 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | # 8 "" 2 40 | # 1 "Make/options" 41 | EXE_INC = -std=c++17 -Wno-old-style-cast -Wno-non-virtual-dtor -I$(LIB_SRC)/finiteVolume/lnInclude -I$(LIB_SRC)/fileFormats/lnInclude -I$(LIB_SRC)/surfMesh/lnInclude -I$(LIB_SRC)/meshTools/lnInclude -I$(LIB_SRC)/dynamicMesh/lnInclude -I$(LIB_SRC)/functionObjects/forces/lnInclude -I$(LIB_SRC)/fvMotionSolver/lnInclude -I../../smartredis/install/include 42 | # 10 "Make/options" 43 | 44 | LIB_LIBS = -lfiniteVolume -lfvOptions -lfileFormats -lsurfMesh -lmeshTools -ldynamicMesh -lfvMotionSolvers -L$(FOAM_USER_LIBBIN) -lhiredis -lredis++ -lsmartredis 45 | # 20 "Make/options" 46 | 47 | 48 | # options 49 | -------------------------------------------------------------------------------- /src/displacementSmartSimMotionSolver/Make/linux64IcxDPInt32Opt/sourceFiles: -------------------------------------------------------------------------------- 1 | SOURCE = \ 2 | displacementSmartSimMotionSolver.C \ 3 | 4 | # sources 5 | -------------------------------------------------------------------------------- /src/displacementSmartSimMotionSolver/Make/linux64IcxDPInt32Opt/variables: -------------------------------------------------------------------------------- 1 | LIB = $(FOAM_USER_LIBBIN)/libsmartSimMotionSolvers 2 | -------------------------------------------------------------------------------- /src/displacementSmartSimMotionSolver/Make/options: -------------------------------------------------------------------------------- 1 | EXE_INC = -std=c++17 -Wno-old-style-cast -Wno-non-virtual-dtor \ 2 | -I$(LIB_SRC)/finiteVolume/lnInclude \ 3 | -I$(LIB_SRC)/fileFormats/lnInclude \ 4 | -I$(LIB_SRC)/surfMesh/lnInclude \ 5 | -I$(LIB_SRC)/meshTools/lnInclude \ 6 | -I$(LIB_SRC)/dynamicMesh/lnInclude \ 7 | -I$(LIB_SRC)/functionObjects/forces/lnInclude \ 8 | -I$(LIB_SRC)/fvMotionSolver/lnInclude \ 9 | -I../../smartredis/install/include 10 | 11 | LIB_LIBS = \ 12 | -lfiniteVolume \ 13 | -lfvOptions \ 14 | -lfileFormats \ 15 | -lsurfMesh \ 16 | -lmeshTools \ 17 | -ldynamicMesh \ 18 | -lfvMotionSolvers \ 19 | -L$(FOAM_USER_LIBBIN) -lhiredis -lredis++ -lsmartredis 20 | /* -lforces include in controlDict if needed */ 21 | -------------------------------------------------------------------------------- /src/displacementSmartSimMotionSolver/displacementSmartSimMotionSolver.H: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | www.openfoam.com 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | Copyright (C) 2023 Tomislav Maric, TU Darmstadt 9 | ------------------------------------------------------------------------------- 10 | License 11 | This file is part of OpenFOAM. 12 | 13 | OpenFOAM is free software: you can redistribute it and/or modify it 14 | under the terms of the GNU General Public License as published by 15 | the Free Software Foundation, either version 3 of the License, or 16 | (at your option) any later version. 17 | 18 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 19 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 21 | for more details. 22 | 23 | You should have received a copy of the GNU General Public License 24 | along with OpenFOAM. If not, see . 25 | 26 | Class 27 | Foam::displacementSmartSimMotionSolver 28 | 29 | Group 30 | grpMeshMotionSolvers 31 | 32 | Description 33 | 34 | Mesh motion solver for an fvMesh. Globally approximates mesh displacement 35 | using Machine Learning Models. Coupling with ML is done using SmartSim. 36 | 37 | SourceFiles 38 | displacementSmartSimMotionSolver.C 39 | 40 | \*---------------------------------------------------------------------------*/ 41 | 42 | #ifndef displacementSmartSimMotionSolver_H 43 | #define displacementSmartSimMotionSolver_H 44 | 45 | #include "displacementMotionSolver.H" 46 | #include "displacementLaplacianFvMotionSolver.H" 47 | #include "client.h" 48 | #include "mapPolyMesh.H" 49 | 50 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 51 | 52 | namespace Foam 53 | { 54 | 55 | /*---------------------------------------------------------------------------*\ 56 | Class displacementSmartSimMotionSolver Declaration 57 | \*---------------------------------------------------------------------------*/ 58 | 59 | class displacementSmartSimMotionSolver 60 | : 61 | public displacementMotionSolver, 62 | public fvMotionSolver 63 | { 64 | 65 | // Private Member Functions 66 | 67 | ////- Interpolation used to transfer cell displacement to the points 68 | //autoPtr interpolationPtr_; 69 | 70 | //- Set to false if not using a clustered database 71 | bool clusterMode_; 72 | 73 | //- SmartRedis Database Client 74 | SmartRedis::Client client_; 75 | 76 | //- No copy construct 77 | displacementSmartSimMotionSolver 78 | ( 79 | const displacementSmartSimMotionSolver& 80 | ) = delete; 81 | 82 | //- No copy assignment 83 | void operator=(const displacementSmartSimMotionSolver&) = delete; 84 | 85 | public: 86 | 87 | //- Runtime type information 88 | TypeName("displacementSmartSim"); 89 | 90 | 91 | // Constructors 92 | 93 | //- Construct from polyMesh and IOdictionary 94 | displacementSmartSimMotionSolver 95 | ( 96 | const polyMesh&, 97 | const IOdictionary& 98 | ); 99 | 100 | //- Construct from components 101 | displacementSmartSimMotionSolver 102 | ( 103 | const polyMesh& mesh, 104 | const IOdictionary& dict, 105 | const pointVectorField& pointDisplacement, 106 | const pointIOField& points0 107 | ); 108 | 109 | 110 | //- Destructor 111 | ~displacementSmartSimMotionSolver(); 112 | 113 | // Member Functions 114 | 115 | //- Return point location obtained from the current motion field 116 | virtual tmp curPoints() const; 117 | 118 | //- Solve for motion 119 | virtual void solve(); 120 | 121 | }; 122 | 123 | 124 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 125 | 126 | } // End namespace Foam 127 | 128 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 129 | 130 | #endif 131 | 132 | // ************************************************************************* // 133 | -------------------------------------------------------------------------------- /src/functionObjects/Make/files: -------------------------------------------------------------------------------- 1 | fieldsToSmartRedisFunctionObject/fieldsToSmartRedisFunctionObject.C 2 | 3 | LIB = $(FOAM_USER_LIBBIN)/libsmartredisFunctionObjects 4 | -------------------------------------------------------------------------------- /src/functionObjects/Make/linux64IcxDPInt32Opt/options: -------------------------------------------------------------------------------- 1 | # 0 "Make/options" 2 | # 0 "" 3 | # 0 "" 4 | # 8 "" 5 | # 1 "/usr/include/stdc-predef.h" 1 3 4 6 | 7 | # 17 "/usr/include/stdc-predef.h" 3 4 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | # 45 "/usr/include/stdc-predef.h" 3 4 28 | 29 | # 55 "/usr/include/stdc-predef.h" 3 4 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | # 8 "" 2 40 | # 1 "Make/options" 41 | EXE_INC = --std=c++17 -Wno-old-style-cast -I$(LIB_SRC)/finiteVolume/lnInclude -I$(LIB_SRC)/finiteArea/lnInclude -I$(LIB_SRC)/fileFormats/lnInclude -I$(LIB_SRC)/surfMesh/lnInclude -I$(LIB_SRC)/meshTools/lnInclude -I$(LIB_SRC)/sampling/lnInclude -I../../smartredis/install/include -I../smartRedis/lnInclude 42 | # 10 "Make/options" 43 | 44 | LIB_LIBS = -lfiniteVolume -lfiniteArea -lfileFormats -lsurfMesh -lmeshTools -lsampling -L$(FOAM_USER_LIBBIN) -lhiredis -lredis++ -lsmartredis -lsmartRedisClient 45 | 46 | # options 47 | -------------------------------------------------------------------------------- /src/functionObjects/Make/linux64IcxDPInt32Opt/sourceFiles: -------------------------------------------------------------------------------- 1 | SOURCE = \ 2 | fieldsToSmartRedisFunctionObject/fieldsToSmartRedisFunctionObject.C \ 3 | 4 | # sources 5 | -------------------------------------------------------------------------------- /src/functionObjects/Make/linux64IcxDPInt32Opt/variables: -------------------------------------------------------------------------------- 1 | LIB = $(FOAM_USER_LIBBIN)/libsmartredisFunctionObjects 2 | -------------------------------------------------------------------------------- /src/functionObjects/Make/options: -------------------------------------------------------------------------------- 1 | EXE_INC = --std=c++17 -Wno-old-style-cast \ 2 | -I$(LIB_SRC)/finiteVolume/lnInclude \ 3 | -I$(LIB_SRC)/finiteArea/lnInclude \ 4 | -I$(LIB_SRC)/fileFormats/lnInclude \ 5 | -I$(LIB_SRC)/surfMesh/lnInclude \ 6 | -I$(LIB_SRC)/meshTools/lnInclude \ 7 | -I$(LIB_SRC)/sampling/lnInclude \ 8 | -I../../smartredis/install/include \ 9 | -I../smartRedis/lnInclude 10 | 11 | LIB_LIBS = \ 12 | -lfiniteVolume \ 13 | -lfiniteArea \ 14 | -lfileFormats \ 15 | -lsurfMesh \ 16 | -lmeshTools \ 17 | -lsampling \ 18 | -L$(FOAM_USER_LIBBIN) \ 19 | -lhiredis \ 20 | -lredis++ \ 21 | -lsmartredis \ 22 | -lsmartRedisClient 23 | -------------------------------------------------------------------------------- /src/functionObjects/fieldsToSmartRedisFunctionObject/fieldsToSmartRedisFunctionObject.C: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | www.openfoam.com 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | Copyright (C) 2011-2017 OpenFOAM Foundation 9 | Copyright (C) 2019-2021 OpenCFD Ltd. 10 | ------------------------------------------------------------------------------- 11 | License 12 | This file is part of OpenFOAM. 13 | 14 | OpenFOAM is free software: you can redistribute it and/or modify it 15 | under the terms of the GNU General Public License as published by 16 | the Free Software Foundation, either version 3 of the License, or 17 | (at your option) any later version. 18 | 19 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 20 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 21 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 22 | for more details. 23 | 24 | You should have received a copy of the GNU General Public License 25 | along with OpenFOAM. If not, see . 26 | 27 | \*---------------------------------------------------------------------------*/ 28 | 29 | #include "fieldsToSmartRedisFunctionObject.H" 30 | #include "Time.H" 31 | #include "fvMesh.H" 32 | #include "addToRunTimeSelectionTable.H" 33 | #include "smartRedisClient.H" 34 | 35 | // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // 36 | 37 | namespace Foam 38 | { 39 | namespace functionObjects 40 | { 41 | defineTypeNameAndDebug(fieldsToSmartRedisFunctionObject, 0); 42 | addToRunTimeSelectionTable 43 | ( 44 | functionObject, 45 | fieldsToSmartRedisFunctionObject, 46 | dictionary 47 | ); 48 | } 49 | } 50 | 51 | 52 | // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // 53 | 54 | Foam::functionObjects::fieldsToSmartRedisFunctionObject::fieldsToSmartRedisFunctionObject 55 | ( 56 | const word& name, 57 | const Time& runTime, 58 | const dictionary& dict 59 | ) 60 | : 61 | fvMeshFunctionObject(name, runTime, dict), 62 | smartRedisClient(name, runTime, dict), 63 | fields_(dict.lookup("fields")), 64 | patches_(dict.lookupOrDefault("patches", wordList{"internal"})) 65 | {} 66 | 67 | bool 68 | Foam::functionObjects::fieldsToSmartRedisFunctionObject::execute() 69 | { 70 | Info<< "Writing fields to SmartRedis database\n" << endl; 71 | updateNamingConventionState(); 72 | sendGeometricFields(fields_, patches_); 73 | return true; 74 | } 75 | 76 | 77 | bool 78 | Foam::functionObjects::fieldsToSmartRedisFunctionObject::write() 79 | { 80 | return true; 81 | } 82 | 83 | bool 84 | Foam::functionObjects::fieldsToSmartRedisFunctionObject::end() 85 | { 86 | DataSet ds = getMetadata(); 87 | ds.add_meta_string("EndTimeIndex", Foam::name(mesh().time().timeIndex())); 88 | client().put_dataset(ds); 89 | return true; 90 | } 91 | 92 | // ************************************************************************* // 93 | -------------------------------------------------------------------------------- /src/functionObjects/fieldsToSmartRedisFunctionObject/fieldsToSmartRedisFunctionObject.H: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | www.openfoam.com 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | Copyright (C) 2011-2017 OpenFOAM Foundation 9 | Copyright (C) 2019-2021 OpenCFD Ltd. 10 | ------------------------------------------------------------------------------- 11 | License 12 | This file is part of OpenFOAM. 13 | 14 | OpenFOAM is free software: you can redistribute it and/or modify it 15 | under the terms of the GNU General Public License as published by 16 | the Free Software Foundation, either version 3 of the License, or 17 | (at your option) any later version. 18 | 19 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 20 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 21 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 22 | for more details. 23 | 24 | You should have received a copy of the GNU General Public License 25 | along with OpenFOAM. If not, see . 26 | 27 | Class 28 | Foam::functionObjects::fieldsToSmartRedisFunctionObject 29 | 30 | Description 31 | Provides a general interface to interact with SmartRedis databases 32 | from OpenFOAM code. 33 | 34 | Usage 35 | Example of function object specification: 36 | \verbatim 37 | difference 38 | { 39 | type fieldsToSmartRedis; 40 | libs ("libsmartredisFunctionObjects.so"); 41 | 42 | // Unique name for this function object instance 43 | name pU; 44 | 45 | // SmartRedis client mode 46 | clusterMode off; 47 | 48 | // OpenFOAM fields to send to the database 49 | fields (p U phi); 50 | 51 | // OpenFOAM patches to send 52 | // "internal" is a special patch refering to internal field 53 | patches (internal inlet); 54 | } 55 | \endverbatim 56 | 57 | SourceFiles 58 | fieldsToSmartRedisFunctionObject.C 59 | 60 | \*---------------------------------------------------------------------------*/ 61 | 62 | #ifndef functionObjects_fieldsToSmartRedisFunctionObject_H 63 | #define functionObjects_fieldsToSmartRedisFunctionObject_H 64 | 65 | #include "fvMeshFunctionObject.H" 66 | #include "smartRedisClient.H" 67 | 68 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 69 | 70 | namespace Foam 71 | { 72 | 73 | // Forward declaration of classes 74 | class fvMesh; 75 | 76 | namespace functionObjects 77 | { 78 | 79 | /*---------------------------------------------------------------------------*\ 80 | Class fieldsToSmartRedisFunctionObject Declaration 81 | \*---------------------------------------------------------------------------*/ 82 | 83 | class fieldsToSmartRedisFunctionObject 84 | : 85 | public fvMeshFunctionObject, 86 | public smartRedisClient 87 | { 88 | protected: 89 | 90 | // Protected Member Data 91 | 92 | //- list of fields to send 93 | wordList fields_; 94 | 95 | //- list of patches to send 96 | wordList patches_; 97 | 98 | // Protected Member Functions 99 | 100 | //- No copy construct 101 | fieldsToSmartRedisFunctionObject(const fieldsToSmartRedisFunctionObject&) = delete; 102 | 103 | //- No copy assignment 104 | void operator=(const fieldsToSmartRedisFunctionObject&) = delete; 105 | 106 | 107 | public: 108 | 109 | //- Runtime type information 110 | TypeName("fieldsToSmartRedis"); 111 | 112 | 113 | // Constructors 114 | 115 | //- Construct from Time and dictionary 116 | fieldsToSmartRedisFunctionObject 117 | ( 118 | const word& name, 119 | const Time& runTime, 120 | const dictionary& dict 121 | ); 122 | 123 | 124 | //- Destructor 125 | virtual ~fieldsToSmartRedisFunctionObject() = default; 126 | 127 | // Member Functions 128 | 129 | //- Called at each ++ or += of the time-loop. 130 | virtual bool execute(); 131 | 132 | //- Called at each ++ or += of the time-loop. 133 | virtual bool write(); 134 | 135 | //- Called when Time::run() determines that the time-loop exits. 136 | virtual bool end(); 137 | }; 138 | 139 | 140 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 141 | 142 | } // End namespace functionObjects 143 | } // End namespace Foam 144 | 145 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 146 | 147 | #endif 148 | 149 | // ************************************************************************* // 150 | -------------------------------------------------------------------------------- /src/smartRedis/Make/files: -------------------------------------------------------------------------------- 1 | smartRedisAdapter/smartRedisAdapter.C 2 | smartRedisClient/smartRedisClient.C 3 | 4 | LIB = $(FOAM_USER_LIBBIN)/libsmartRedisClient 5 | -------------------------------------------------------------------------------- /src/smartRedis/Make/options: -------------------------------------------------------------------------------- 1 | EXE_INC = -std=c++17 -Wno-old-style-cast \ 2 | -I$(LIB_SRC)/finiteVolume/lnInclude \ 3 | -I$(LIB_SRC)/finiteArea/lnInclude \ 4 | -I$(LIB_SRC)/fileFormats/lnInclude \ 5 | -I$(LIB_SRC)/surfMesh/lnInclude \ 6 | -I$(LIB_SRC)/meshTools/lnInclude \ 7 | -I$(LIB_SRC)/dynamicMesh/lnInclude \ 8 | -I$(LIB_SRC)/conversion/lnInclude \ 9 | -I$(LIB_SRC)/sampling/lnInclude \ 10 | -I../../smartredis/install/include 11 | 12 | LIB_LIBS = \ 13 | -lfiniteVolume \ 14 | -lfiniteArea \ 15 | -lfileFormats \ 16 | -lsurfMesh \ 17 | -lmeshTools \ 18 | -ldynamicMesh \ 19 | -lconversion \ 20 | -lsampling \ 21 | -L$(FOAM_USER_LIBBIN) \ 22 | -lhiredis \ 23 | -lredis++ \ 24 | -lsmartredis 25 | -------------------------------------------------------------------------------- /src/smartRedis/smartRedisAdapter/Make/files: -------------------------------------------------------------------------------- 1 | smartRedisAdapter.C 2 | 3 | LIB = $(FOAM_USER_LIBBIN)/libclientWrapper 4 | -------------------------------------------------------------------------------- /src/smartRedis/smartRedisAdapter/Make/options: -------------------------------------------------------------------------------- 1 | EXE_INC = -std=c++17 \ 2 | -I$(LIB_SRC)/finiteVolume/lnInclude \ 3 | -I$(LIB_SRC)/finiteArea/lnInclude \ 4 | -I$(LIB_SRC)/fileFormats/lnInclude \ 5 | -I$(LIB_SRC)/surfMesh/lnInclude \ 6 | -I$(LIB_SRC)/meshTools/lnInclude \ 7 | -I$(LIB_SRC)/dynamicMesh/lnInclude \ 8 | -I$(LIB_SRC)/conversion/lnInclude \ 9 | -I$(SMARTREDIS_INCLUDE) \ 10 | -I$(LIB_SRC)/sampling/lnInclude 11 | 12 | LIB_LIBS = \ 13 | -lfiniteVolume \ 14 | -lfiniteArea \ 15 | -lfileFormats \ 16 | -lsurfMesh \ 17 | -lmeshTools \ 18 | -ldynamicMesh \ 19 | -lconversion \ 20 | -L$(SMARTREDIS_LIB) \ 21 | -lhiredis \ 22 | -lredis++ \ 23 | -lsmartredis \ 24 | -lsampling 25 | -------------------------------------------------------------------------------- /src/smartRedis/smartRedisAdapter/smartRedisAdapter.C: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | www.openfoam.com 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | Copyright (C) 2023 AUTHOR,AFFILIATION 9 | ------------------------------------------------------------------------------- 10 | License 11 | This file is part of OpenFOAM. 12 | 13 | OpenFOAM is free software: you can redistribute it and/or modify it 14 | under the terms of the GNU General Public License as published by 15 | the Free Software Foundation, either version 3 of the License, or 16 | (at your option) any later version. 17 | 18 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 19 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 21 | for more details. 22 | 23 | You should have received a copy of the GNU General Public License 24 | along with OpenFOAM. If not, see . 25 | 26 | \*---------------------------------------------------------------------------*/ 27 | 28 | #include "smartRedisAdapter.H" 29 | #include "Time.H" 30 | 31 | 32 | // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // 33 | 34 | namespace Foam 35 | { 36 | defineTypeNameAndDebug(smartRedisAdapter, 0); 37 | } 38 | 39 | 40 | // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // 41 | 42 | Foam::smartRedisAdapter::smartRedisAdapter 43 | ( 44 | const IOobject& io, 45 | const dictionary& dict 46 | ) 47 | : 48 | regIOobject(io), 49 | refCount(), 50 | clusterMode_(dict.getOrDefault("clusterMode", true)), 51 | client_(clusterMode_, io.name()) // deprecated constructor though 52 | { 53 | } 54 | 55 | Foam::smartRedisAdapter::smartRedisAdapter 56 | ( 57 | smartRedisAdapter* ptr 58 | ) 59 | : 60 | regIOobject(*ptr), 61 | refCount(), 62 | clusterMode_(ptr->clusterMode_), 63 | client_(std::move(ptr->client_)) // no copy of the client 64 | { 65 | } 66 | 67 | 68 | // ************************************************************************* // 69 | -------------------------------------------------------------------------------- /src/smartRedis/smartRedisAdapter/smartRedisAdapter.H: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | www.openfoam.com 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | Copyright (C) 2023 AUTHOR, AFFILIATION 9 | ------------------------------------------------------------------------------- 10 | License 11 | This file is part of OpenFOAM. 12 | 13 | OpenFOAM is free software: you can redistribute it and/or modify it 14 | under the terms of the GNU General Public License as published by 15 | the Free Software Foundation, either version 3 of the License, or 16 | (at your option) any later version. 17 | 18 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 19 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 21 | for more details. 22 | 23 | You should have received a copy of the GNU General Public License 24 | along with OpenFOAM. If not, see . 25 | 26 | Class 27 | Foam::smartRedisAdapter 28 | 29 | Description 30 | 31 | \*---------------------------------------------------------------------------*/ 32 | 33 | #ifndef smartRedisAdapter_H 34 | #define smartRedisAdapter_H 35 | 36 | #include "regIOobject.H" 37 | #include "client.h" 38 | 39 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 40 | 41 | namespace Foam 42 | { 43 | 44 | /*---------------------------------------------------------------------------*\ 45 | Class smartRedisAdapter Declaration 46 | \*---------------------------------------------------------------------------*/ 47 | 48 | class smartRedisAdapter 49 | : 50 | public regIOobject, 51 | public refCount 52 | { 53 | protected: 54 | 55 | // Protected Data 56 | 57 | //- cluster mode 58 | bool clusterMode_; 59 | 60 | //- SmartRedis Database Client 61 | SmartRedis::Client client_; 62 | 63 | public: 64 | 65 | //- Runtime type information 66 | TypeName("smartRedisAdapter"); 67 | 68 | 69 | // Constructors 70 | 71 | //- Construct from Time and dictionary 72 | smartRedisAdapter 73 | ( 74 | const IOobject& io, 75 | const dictionary& dict 76 | ); 77 | 78 | //- Construct from a pointer by moving the client 79 | explicit smartRedisAdapter 80 | ( 81 | smartRedisAdapter* ptr 82 | ); 83 | 84 | //- No copy construct 85 | smartRedisAdapter(const smartRedisAdapter&) = delete; 86 | 87 | //- No copy assignment 88 | void operator=(const smartRedisAdapter&) = delete; 89 | 90 | 91 | //- Destructor 92 | virtual ~smartRedisAdapter() = default; 93 | 94 | 95 | // Member Functions 96 | 97 | //- return the client's instance 98 | SmartRedis::Client& client() { return client_; }; 99 | 100 | //- return a const-ref to the client 101 | const SmartRedis::Client& client() const { return client_; }; 102 | 103 | //- Implement writing to ostream from regIOobject 104 | virtual bool writeData(Ostream&) const { return true; } 105 | }; 106 | 107 | 108 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 109 | 110 | } // End namespace Foam 111 | 112 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 113 | 114 | #endif 115 | 116 | // ************************************************************************* // 117 | -------------------------------------------------------------------------------- /tests/Make/files: -------------------------------------------------------------------------------- 1 | $(FOAM_FOAMUT)/tests/testDriver.C 2 | 3 | smartRedisClientTests.C 4 | 5 | EXE = ./testDriver 6 | -------------------------------------------------------------------------------- /tests/Make/options: -------------------------------------------------------------------------------- 1 | EXE_INC = -std=c++17 \ 2 | -Wno-old-style-cast \ 3 | -I$(LIB_SRC)/finiteVolume/lnInclude \ 4 | -I$(LIB_SRC)/meshTools/lnInclude \ 5 | -I../smartredis/install/include \ 6 | -I$(FOAM_FOAMUT)/smartSimFunctionObject/lnInclude \ 7 | -I$(FOAM_USER_LIBBIN)/catch2/include \ 8 | -I$(LIB_SRC)/Pstream/lnInclude \ 9 | -I../src/smartRedis/lnInclude 10 | 11 | EXE_LIBS = \ 12 | -lfiniteVolume \ 13 | -lmeshTools \ 14 | -L$(FOAM_USER_LIBBIN) -L$(FOAM_LIBBIN)/$(FOAM_MPI) \ 15 | -L$(FOAM_USER_LIBBIN)/catch2/lib -l:libCatch2.a \ 16 | -lPstream \ 17 | -L$(FOAM_USER_LIBBIN) -lhiredis -lredis++ \ 18 | -lsmartredis -lsmartRedisClient 19 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/chip_cooling_with_new_boundaries/0/U: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2312 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volVectorField; 13 | object U; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | dimensions [0 1 -1 0 0 0 0]; 18 | 19 | internalField uniform (0 0 0); 20 | 21 | boundaryField 22 | { 23 | inlet 24 | { 25 | //type flowRateInletVelocity; 26 | //volumetricFlowRate 5e-05; 27 | //value $internalField; 28 | type fixedValue; 29 | value uniform (0 1.5 0); 30 | } 31 | 32 | outlet 33 | { 34 | type inletOutlet; 35 | inletValue uniform (0 0 0); 36 | value $internalField; 37 | } 38 | 39 | top 40 | { 41 | type noSlip; 42 | } 43 | 44 | bottom 45 | { 46 | type noSlip; 47 | } 48 | 49 | side1 50 | { 51 | type noSlip; 52 | } 53 | side2 54 | { 55 | type noSlip; 56 | } 57 | solid 58 | { 59 | type noSlip; 60 | } 61 | } 62 | 63 | // ************************************************************************* // 64 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/chip_cooling_with_new_boundaries/0/k: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2312 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volScalarField; 13 | object k; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | dimensions [0 2 -2 0 0 0 0]; 18 | 19 | internalField uniform 0.008438; 20 | 21 | boundaryField 22 | { 23 | inlet 24 | { 25 | type fixedValue; 26 | value $internalField; 27 | } 28 | 29 | outlet 30 | { 31 | type zeroGradient; 32 | } 33 | 34 | top 35 | { 36 | type kqRWallFunction; 37 | value uniform 0; 38 | } 39 | 40 | bottom 41 | { 42 | type kqRWallFunction; 43 | value uniform 0; 44 | } 45 | 46 | side1 47 | { 48 | type kqRWallFunction; 49 | value uniform 0; 50 | } 51 | side2 52 | { 53 | type kqRWallFunction; 54 | value uniform 0; 55 | } 56 | solid 57 | { 58 | type kqRWallFunction; 59 | value uniform 0; 60 | } 61 | } 62 | 63 | 64 | // ************************************************************************* // 65 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/chip_cooling_with_new_boundaries/0/nut: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2312 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volScalarField; 13 | object nut; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | dimensions [0 2 -1 0 0 0 0]; 18 | 19 | internalField uniform 0.000282; 20 | 21 | boundaryField 22 | { 23 | inlet 24 | { 25 | type calculated; 26 | value $internalField; 27 | } 28 | 29 | outlet 30 | { 31 | type zeroGradient; 32 | } 33 | 34 | top 35 | { 36 | type nutkWallFunction; 37 | value uniform 0; 38 | } 39 | 40 | bottom 41 | { 42 | type nutkWallFunction; 43 | value uniform 0; 44 | } 45 | 46 | side1 47 | { 48 | type nutkWallFunction; 49 | value uniform 0; 50 | } 51 | side2 52 | { 53 | type nutkWallFunction; 54 | value uniform 0; 55 | } 56 | solid 57 | { 58 | type nutkWallFunction; 59 | value uniform 0; 60 | } 61 | } 62 | 63 | 64 | // ************************************************************************* // 65 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/chip_cooling_with_new_boundaries/0/omega: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2312 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volScalarField; 13 | object omega; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | dimensions [0 0 -1 0 0 0 0]; 18 | 19 | internalField uniform 29.94734; 20 | 21 | boundaryField 22 | { 23 | inlet 24 | { 25 | type fixedValue; 26 | value $internalField; 27 | } 28 | 29 | outlet 30 | { 31 | type zeroGradient; 32 | } 33 | 34 | top 35 | { 36 | type omegaWallFunction; 37 | value uniform 0; 38 | } 39 | 40 | bottom 41 | { 42 | type omegaWallFunction; 43 | value uniform 0; 44 | } 45 | 46 | side1 47 | { 48 | type omegaWallFunction; 49 | value uniform 0; 50 | } 51 | side2 52 | { 53 | type omegaWallFunction; 54 | value uniform 0; 55 | } 56 | solid 57 | { 58 | type omegaWallFunction; 59 | value uniform 0; 60 | } 61 | } 62 | 63 | 64 | // ************************************************************************* // 65 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/chip_cooling_with_new_boundaries/0/p: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2312 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volScalarField; 13 | object p; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | dimensions [0 2 -2 0 0 0 0]; 18 | 19 | internalField uniform 0; 20 | 21 | boundaryField 22 | { 23 | inlet 24 | { 25 | type zeroGradient; 26 | } 27 | 28 | outlet 29 | { 30 | type fixedValue; 31 | value $internalField; 32 | } 33 | 34 | top 35 | { 36 | type zeroGradient; 37 | } 38 | 39 | bottom 40 | { 41 | type zeroGradient; 42 | } 43 | 44 | side1 45 | { 46 | type zeroGradient; 47 | } 48 | 49 | side2 50 | { 51 | type zeroGradient; 52 | } 53 | solid 54 | { 55 | type zeroGradient; 56 | } 57 | } 58 | 59 | 60 | // ************************************************************************* // 61 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/chip_cooling_with_new_boundaries/0/p_rgh: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | foam-extend: Open Source CFD | 4 | | \\ / O peration | Version: 4.0 | 5 | | \\ / A nd | Web: http://www.foam-extend.org | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volScalarField; 13 | location "0/fluid"; 14 | object p_rgh; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | dimensions [ 0 2 -2 0 0 0 0 ]; 19 | 20 | internalField uniform 101325; 21 | 22 | boundaryField 23 | { 24 | inlet 25 | { 26 | type fixedFluxPressure; 27 | value $internalField; 28 | } 29 | 30 | outlet 31 | { 32 | type fixedValue; 33 | value $internalField; 34 | } 35 | top 36 | { 37 | type fixedFluxPressure; 38 | value $internalField; 39 | } 40 | 41 | bottom 42 | { 43 | type fixedFluxPressure; 44 | value $internalField; 45 | } 46 | 47 | side1 48 | { 49 | type fixedFluxPressure; 50 | value $internalField; 51 | } 52 | 53 | side2 54 | { 55 | type fixedFluxPressure; 56 | value $internalField; 57 | } 58 | solid 59 | { 60 | type fixedFluxPressure; 61 | value $internalField; 62 | } 63 | 64 | } 65 | 66 | 67 | // ************************************************************************* // 68 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/chip_cooling_with_new_boundaries/0/vorticity: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: 2312 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | arch "LSB;label=32;scalar=64"; 13 | class volVectorField; 14 | location "0"; 15 | object vorticity; 16 | } 17 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 18 | 19 | dimensions [0 0 -1 0 0 0 0]; 20 | 21 | internalField uniform (0 -0 0); 22 | 23 | boundaryField 24 | { 25 | solid 26 | { 27 | type calculated; 28 | value uniform (0 -0 0); 29 | } 30 | side2 31 | { 32 | type calculated; 33 | value uniform (0 -0 0); 34 | } 35 | side1 36 | { 37 | type calculated; 38 | value uniform (0 -0 0); 39 | } 40 | outlet 41 | { 42 | type calculated; 43 | value uniform (0 -0 0); 44 | } 45 | inlet 46 | { 47 | type calculated; 48 | value uniform (0 -0 0); 49 | } 50 | top 51 | { 52 | type calculated; 53 | value uniform (0 -0 0); 54 | } 55 | bottom 56 | { 57 | type calculated; 58 | value uniform (0 -0 0); 59 | } 60 | } 61 | 62 | 63 | // ************************************************************************* // 64 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/chip_cooling_with_new_boundaries/Allclean: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd ${0%/*} || exit 1 # Run from this directory 3 | . $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions 4 | 5 | cleanCase 6 | rmdir constant 2>/dev/null 7 | 8 | #------------------------------------------------------------------------------ 9 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/chip_cooling_with_new_boundaries/Allrun.pre: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd ${0%/*} || exit 1 # Run from this directory 3 | /work/groups/da_mma_b/christian/squashfs-root/usr/bin/freecadcmd ./obstacles_with_new_parameters.py; 4 | cat obstacles.stl channel.stl > chip_cooling_mm.stl; 5 | surfaceTransformPoints -scale 0.001 chip_cooling_mm.stl chip_cooling_m.stl 6 | surfaceFeatureEdges chip_cooling_m.stl chip_cooling_m.fms; 7 | cartesianMesh; 8 | checkMesh -constant; 9 | topoSet; 10 | decomposePar; 11 | touch foam.foam 12 | #------------------------------------------------------------------------------ 13 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/chip_cooling_with_new_boundaries/channel.stl: -------------------------------------------------------------------------------- 1 | solid xMin 2 | facet normal -1 0 0 3 | outer loop 4 | vertex 0 0 0 5 | vertex 0 90 3 6 | vertex 0 90 0 7 | endloop 8 | endfacet 9 | facet normal -1 0 0 10 | outer loop 11 | vertex 0 0 0 12 | vertex 0 0 3 13 | vertex 0 90 3 14 | endloop 15 | endfacet 16 | endsolid xMin 17 | solid xMax 18 | facet normal 1 0 0 19 | outer loop 20 | vertex 38 0 0 21 | vertex 38 90 0 22 | vertex 38 90 3 23 | endloop 24 | endfacet 25 | facet normal 1 0 0 26 | outer loop 27 | vertex 38 0 0 28 | vertex 38 90 3 29 | vertex 38 0 3 30 | endloop 31 | endfacet 32 | endsolid xMax 33 | solid yMin 34 | facet normal 0 -1 0 35 | outer loop 36 | vertex 0 0 0 37 | vertex 38 0 0 38 | vertex 38 0 3 39 | endloop 40 | endfacet 41 | facet normal 0 -1 0 42 | outer loop 43 | vertex 0 0 0 44 | vertex 38 0 3 45 | vertex 0 0 3 46 | endloop 47 | endfacet 48 | endsolid yMin 49 | solid yMax 50 | facet normal 0 1 0 51 | outer loop 52 | vertex 0 90 0 53 | vertex 38 90 3 54 | vertex 38 90 0 55 | endloop 56 | endfacet 57 | facet normal 0 1 0 58 | outer loop 59 | vertex 0 90 0 60 | vertex 0 90 3 61 | vertex 38 90 3 62 | endloop 63 | endfacet 64 | endsolid yMax 65 | solid zMin 66 | facet normal 0 0 -1 67 | outer loop 68 | vertex 0 0 0 69 | vertex 0 90 0 70 | vertex 38 90 0 71 | endloop 72 | endfacet 73 | facet normal 0 0 -1 74 | outer loop 75 | vertex 0 0 0 76 | vertex 38 90 0 77 | vertex 38 0 0 78 | endloop 79 | endfacet 80 | endsolid zMin 81 | solid zMax 82 | facet normal 0 0 1 83 | outer loop 84 | vertex 0 0 3 85 | vertex 38 90 3 86 | vertex 0 90 3 87 | endloop 88 | endfacet 89 | facet normal 0 0 1 90 | outer loop 91 | vertex 0 0 3 92 | vertex 38 0 3 93 | vertex 38 90 3 94 | endloop 95 | endfacet 96 | endsolid zMax 97 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/chip_cooling_with_new_boundaries/constant/transportProperties: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2312 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object transportProperties; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | transportModel Newtonian; 18 | 19 | nu 3.5e-06; 20 | 21 | rho 1070; 22 | 23 | 24 | Pr 24; 25 | 26 | 27 | // ************************************************************************* // 28 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/chip_cooling_with_new_boundaries/foam.foam: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OFDataCommittee/openfoam-smartsim/e7b3a57088ee59784e52307d10b75d04f083d967/tutorials/bayesianOptimization/chip_cooling_with_new_boundaries/foam.foam -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/chip_cooling_with_new_boundaries/system/Allclean: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd ${0%/*} || exit 1 # Run from this directory 3 | . $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions 4 | 5 | cleanCase 6 | rmdir constant 2>/dev/null 7 | 8 | #------------------------------------------------------------------------------ 9 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/chip_cooling_with_new_boundaries/system/Allrun: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd ${0%/*} || exit 1 # Run from this directory 3 | . $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions 4 | 5 | runApplication cartesianMesh 6 | runApplication checkMesh -constant 7 | 8 | #------------------------------------------------------------------------------ 9 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/chip_cooling_with_new_boundaries/system/decomposeParDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2312 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object decomposeParDict; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | numberOfSubdomains 16; 18 | 19 | method scotch; 20 | 21 | 22 | // ************************************************************************* // 23 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/chip_cooling_with_new_boundaries/system/fvSchemes: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2312 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object fvSchemes; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | ddtSchemes 18 | { 19 | default steadyState; 20 | } 21 | 22 | gradSchemes 23 | { 24 | default Gauss linear; 25 | } 26 | 27 | divSchemes 28 | { 29 | default none; 30 | div(phi,U) Gauss linearUpwind grad(U); 31 | div(phi,k) Gauss linearUpwind grad(omega); 32 | div(phi,epsilon) Gauss linearUpwind grad(epsilo); 33 | div(phi,omega) Gauss linearUpwind grad(omega); 34 | div(phi,R) Gauss upwind; 35 | div(R) Gauss linear; 36 | div(phi,nuTilda) Gauss upwind; 37 | div((nuEff*dev2(T(grad(U))))) Gauss linear; 38 | } 39 | 40 | laplacianSchemes 41 | { 42 | default Gauss linear corrected; 43 | } 44 | 45 | interpolationSchemes 46 | { 47 | default linear; 48 | } 49 | 50 | snGradSchemes 51 | { 52 | default corrected; 53 | } 54 | 55 | wallDist 56 | { 57 | method meshWave; 58 | } 59 | 60 | 61 | // ************************************************************************* // 62 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/chip_cooling_with_new_boundaries/system/fvSolution: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2312 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object fvSolution; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | solvers 18 | { 19 | p 20 | { 21 | solver GAMG; 22 | tolerance 1e-06; 23 | relTol 1e-06; 24 | smoother GaussSeidel; 25 | nPreSweeps 0; 26 | nPostSweeps 2; 27 | cacheAgglomeration on; 28 | agglomeration faceAreaPair; 29 | nCellsInCoarsestLevel 1000; 30 | mergeLevels 1; 31 | } 32 | 33 | "(U|k|epsilon|omega|f|v2)" 34 | { 35 | solver PBiCGStab; 36 | preconditioner DILU; 37 | tolerance 1e-08; 38 | relTol 0.0; 39 | } 40 | } 41 | 42 | SIMPLE 43 | { 44 | //nCorrector 3; 45 | nNonOrthogonalCorrectors 10; 46 | consistent yes; 47 | 48 | residualControl 49 | { 50 | p 1e-5; 51 | U 1e-5; 52 | //"(k|epsilon|omega|f|v2)" 1e-3; 53 | //"k2" 1e-4; 54 | } 55 | } 56 | 57 | relaxationFactors 58 | { 59 | fields 60 | { 61 | p 0.3; 62 | p_rgh 0.3; 63 | } 64 | equations 65 | { 66 | U 0.7; 67 | k 0.7; 68 | epsilon 0.7; 69 | R 0.7; 70 | nuTilda 0.7; 71 | omega 0.7; 72 | } 73 | } 74 | // ************************************************************************* // 75 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/chip_cooling_with_new_boundaries/system/meshDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | cfMesh: A library for mesh generation | 4 | | \\ / O peration | | 5 | | \\ / A nd | Author: Franjo Juretic | 6 | | \\/ M anipulation | E-mail: franjo.juretic@c-fields.com | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | location "system"; 14 | object meshDict; 15 | } 16 | 17 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 18 | 19 | surfaceFile "chip_cooling_m.fms"; 20 | 21 | maxCellSize 0.0015; 22 | 23 | //boundaryLayers 24 | //{ 25 | // patchBoundaryLayers 26 | // { 27 | // xMin 28 | // { 29 | // nLayers 5; 30 | // thicknessRatio 1.1; 31 | // firstLayerThickness 7.9e-4; 32 | // } 33 | // xMax 34 | // { 35 | // nLayers 5; 36 | // thicknessRatio 1.1; 37 | // firstLayerThickness 7.9e-4; 38 | // } 39 | // zMin 40 | // { 41 | // nLayers 5; 42 | // thicknessRatio 1.1; 43 | // firstLayerThickness 7.9e-4; 44 | // } 45 | // zMax 46 | // { 47 | // nLayers 5; 48 | // thicknessRatio 1.1; 49 | // firstLayerThickness 7.9e-4; 50 | // } 51 | // solid 52 | // { 53 | // nLayers 5; 54 | // thicknessRatio 1.1; 55 | // firstLayerThickness 6.6e-4; 56 | // } 57 | // } 58 | //} 59 | 60 | localRefinement 61 | { 62 | solid 63 | { 64 | additionalRefinementLevels 3; 65 | refinementThickness 6.6e-4; 66 | } 67 | xMin 68 | { 69 | additionalRefinementLevels 3; 70 | refinementThickness 7.9e-4; 71 | } 72 | xMax 73 | { 74 | additionalRefinementLevels 3; 75 | refinementThickness 7.9e-4; 76 | } 77 | zMin 78 | { 79 | additionalRefinementLevels 3; 80 | refinementThickness 7.9e-4; 81 | } 82 | zMax 83 | { 84 | additionalRefinementLevels 3; 85 | refinementThickness 7.9e-4; 86 | } 87 | } 88 | 89 | renameBoundary 90 | { 91 | defaultName fixedWalls; 92 | defaultType wall; 93 | 94 | newPatchNames 95 | { 96 | "xMin" { newName side1 ; type wall ; inGroups 1(wall); } 97 | "xMax" { newName side2 ; type wall ; inGroups 1(wall); } 98 | "yMin" { newName inlet ; type patch ; } 99 | "yMax" { newName outlet ; type patch ; } 100 | "zMin" { newName bottom ; type wall ; inGroups 1(wall); } 101 | "zMax" { newName top ; type wall ; inGroups 1(wall); } 102 | } 103 | } 104 | 105 | 106 | // ************************************************************************* // -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/chip_cooling_with_new_boundaries/system/topoSetDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2312 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object topoSetDict; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | actions 18 | ( 19 | { 20 | name box1; 21 | type cellSet; 22 | action new; 23 | source boxToCell; 24 | min (0 0.02 0); 25 | max (0.038 0.07 0.003); 26 | } 27 | { 28 | name box; 29 | type cellZoneSet; 30 | action new; 31 | source setToCellZone; 32 | set box1; 33 | } 34 | 35 | ); 36 | 37 | 38 | // ************************************************************************* // 39 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/pitzDaily/0/.ipynb_checkpoints/epsilon-checkpoint: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2306 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volScalarField; 13 | object epsilon; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | dimensions [0 2 -3 0 0 0 0]; 18 | 19 | internalField uniform !epsilon!; 20 | 21 | boundaryField 22 | { 23 | inlet 24 | { 25 | type fixedValue; 26 | value uniform !epsilon!; 27 | } 28 | 29 | outlet 30 | { 31 | type zeroGradient; 32 | } 33 | 34 | upperWall 35 | { 36 | type epsilonWallFunction; 37 | value uniform !epsilon!; 38 | } 39 | 40 | lowerWall 41 | { 42 | type epsilonWallFunction; 43 | value uniform !epsilon!; 44 | } 45 | 46 | frontAndBack 47 | { 48 | type empty; 49 | } 50 | } 51 | 52 | 53 | // ************************************************************************* // 54 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/pitzDaily/0/.ipynb_checkpoints/k-checkpoint: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2306 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volScalarField; 13 | object k; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | dimensions [0 2 -2 0 0 0 0]; 18 | 19 | internalField uniform 0.375; 20 | 21 | boundaryField 22 | { 23 | inlet 24 | { 25 | type fixedValue; 26 | value uniform 0.375; 27 | } 28 | 29 | outlet 30 | { 31 | type zeroGradient; 32 | } 33 | 34 | upperWall 35 | { 36 | type kqRWallFunction; 37 | value uniform 0.375; 38 | } 39 | 40 | lowerWall 41 | { 42 | type kqRWallFunction; 43 | value uniform 0.375; 44 | } 45 | 46 | frontAndBack 47 | { 48 | type empty; 49 | } 50 | } 51 | 52 | 53 | // ************************************************************************* // 54 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/pitzDaily/0/U: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2306 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volVectorField; 13 | object U; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | dimensions [0 1 -1 0 0 0 0]; 18 | 19 | internalField uniform (0 0 0); 20 | 21 | boundaryField 22 | { 23 | inlet 24 | { 25 | type fixedValue; 26 | value uniform (10 0 0); 27 | } 28 | 29 | outlet 30 | { 31 | type zeroGradient; 32 | } 33 | 34 | upperWall 35 | { 36 | type noSlip; 37 | } 38 | 39 | lowerWall 40 | { 41 | type noSlip; 42 | } 43 | 44 | frontAndBack 45 | { 46 | type empty; 47 | } 48 | } 49 | 50 | 51 | // ************************************************************************* // 52 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/pitzDaily/0/epsilon: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2306 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volScalarField; 13 | object epsilon; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | dimensions [0 2 -3 0 0 0 0]; 18 | 19 | internalField uniform !epsilon!; 20 | 21 | boundaryField 22 | { 23 | inlet 24 | { 25 | type fixedValue; 26 | value uniform !epsilon!; 27 | } 28 | 29 | outlet 30 | { 31 | type zeroGradient; 32 | } 33 | 34 | upperWall 35 | { 36 | type epsilonWallFunction; 37 | value uniform !epsilon!; 38 | } 39 | 40 | lowerWall 41 | { 42 | type epsilonWallFunction; 43 | value uniform !epsilon!; 44 | } 45 | 46 | frontAndBack 47 | { 48 | type empty; 49 | } 50 | } 51 | 52 | 53 | // ************************************************************************* // 54 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/pitzDaily/0/k: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2306 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volScalarField; 13 | object k; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | dimensions [0 2 -2 0 0 0 0]; 18 | 19 | internalField uniform 0.375; 20 | 21 | boundaryField 22 | { 23 | inlet 24 | { 25 | type fixedValue; 26 | value uniform 0.375; 27 | } 28 | 29 | outlet 30 | { 31 | type zeroGradient; 32 | } 33 | 34 | upperWall 35 | { 36 | type kqRWallFunction; 37 | value uniform 0.375; 38 | } 39 | 40 | lowerWall 41 | { 42 | type kqRWallFunction; 43 | value uniform 0.375; 44 | } 45 | 46 | frontAndBack 47 | { 48 | type empty; 49 | } 50 | } 51 | 52 | 53 | // ************************************************************************* // 54 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/pitzDaily/0/nuTilda: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2306 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volScalarField; 13 | object nuTilda; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | dimensions [0 2 -1 0 0 0 0]; 18 | 19 | internalField uniform 0; 20 | 21 | boundaryField 22 | { 23 | inlet 24 | { 25 | type fixedValue; 26 | value uniform 0; 27 | } 28 | 29 | outlet 30 | { 31 | type zeroGradient; 32 | } 33 | 34 | upperWall 35 | { 36 | type zeroGradient; 37 | } 38 | 39 | lowerWall 40 | { 41 | type zeroGradient; 42 | } 43 | 44 | frontAndBack 45 | { 46 | type empty; 47 | } 48 | } 49 | 50 | 51 | // ************************************************************************* // 52 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/pitzDaily/0/nut: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2306 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volScalarField; 13 | object nut; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | dimensions [0 2 -1 0 0 0 0]; 18 | 19 | internalField uniform 0; 20 | 21 | boundaryField 22 | { 23 | inlet 24 | { 25 | type calculated; 26 | value uniform 0; 27 | } 28 | 29 | outlet 30 | { 31 | type calculated; 32 | value uniform 0; 33 | } 34 | 35 | upperWall 36 | { 37 | type nutkWallFunction; 38 | value uniform 0; 39 | } 40 | 41 | lowerWall 42 | { 43 | type nutkWallFunction; 44 | value uniform 0; 45 | } 46 | 47 | frontAndBack 48 | { 49 | type empty; 50 | } 51 | } 52 | 53 | 54 | // ************************************************************************* // 55 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/pitzDaily/0/omega: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2306 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volScalarField; 13 | object omega; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | dimensions [0 0 -1 0 0 0 0]; 18 | 19 | internalField uniform 440.15; 20 | 21 | boundaryField 22 | { 23 | inlet 24 | { 25 | type fixedValue; 26 | value $internalField; 27 | } 28 | 29 | outlet 30 | { 31 | type zeroGradient; 32 | } 33 | 34 | upperWall 35 | { 36 | type omegaWallFunction; 37 | value $internalField; 38 | } 39 | 40 | lowerWall 41 | { 42 | type omegaWallFunction; 43 | value $internalField; 44 | } 45 | 46 | frontAndBack 47 | { 48 | type empty; 49 | } 50 | } 51 | 52 | 53 | // ************************************************************************* // 54 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/pitzDaily/0/p: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2306 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volScalarField; 13 | object p; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | dimensions [0 2 -2 0 0 0 0]; 18 | 19 | internalField uniform 0; 20 | 21 | boundaryField 22 | { 23 | inlet 24 | { 25 | type zeroGradient; 26 | } 27 | 28 | outlet 29 | { 30 | type fixedValue; 31 | value uniform 0; 32 | } 33 | 34 | upperWall 35 | { 36 | type zeroGradient; 37 | } 38 | 39 | lowerWall 40 | { 41 | type zeroGradient; 42 | } 43 | 44 | frontAndBack 45 | { 46 | type empty; 47 | } 48 | } 49 | 50 | 51 | // ************************************************************************* // 52 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/pitzDaily/constant/polyMesh/boundary: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: 2306 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | arch "LSB;label=32;scalar=64"; 13 | class polyBoundaryMesh; 14 | location "constant/polyMesh"; 15 | object boundary; 16 | } 17 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 18 | 19 | 5 20 | ( 21 | inlet 22 | { 23 | type patch; 24 | nFaces 30; 25 | startFace 24170; 26 | } 27 | outlet 28 | { 29 | type patch; 30 | nFaces 57; 31 | startFace 24200; 32 | } 33 | upperWall 34 | { 35 | type wall; 36 | inGroups 1(wall); 37 | nFaces 223; 38 | startFace 24257; 39 | } 40 | lowerWall 41 | { 42 | type wall; 43 | inGroups 1(wall); 44 | nFaces 250; 45 | startFace 24480; 46 | } 47 | frontAndBack 48 | { 49 | type empty; 50 | inGroups 1(empty); 51 | nFaces 24450; 52 | startFace 24730; 53 | } 54 | ) 55 | 56 | // ************************************************************************* // 57 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/pitzDaily/constant/transportProperties: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2306 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object transportProperties; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | transportModel Newtonian; 18 | 19 | nu 1e-05; 20 | 21 | 22 | // ************************************************************************* // 23 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/pitzDaily/constant/turbulenceProperties: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2306 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object turbulenceProperties; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | simulationType RAS; 18 | 19 | RAS 20 | { 21 | // Tested with kEpsilon, realizableKE, kOmega, kOmegaSST, 22 | // ShihQuadraticKE, LienCubicKE. 23 | RASModel kEpsilon; 24 | 25 | turbulence on; 26 | 27 | printCoeffs on; 28 | 29 | Cmu !Cmu!; 30 | C1 !C1!; 31 | C2 !C2!; 32 | sigmaEps !sigmaEps!; 33 | } 34 | 35 | 36 | // ************************************************************************* // 37 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/pitzDaily/system/blockMeshDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2306 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object blockMeshDict; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | scale 0.001; 18 | 19 | vertices 20 | ( 21 | (-20.6 0 -0.5) 22 | (-20.6 25.4 -0.5) 23 | (0 -25.4 -0.5) 24 | (0 0 -0.5) 25 | (0 25.4 -0.5) 26 | (206 -25.4 -0.5) 27 | (206 0 -0.5) 28 | (206 25.4 -0.5) 29 | (290 -16.6 -0.5) 30 | (290 0 -0.5) 31 | (290 16.6 -0.5) 32 | 33 | (-20.6 0 0.5) 34 | (-20.6 25.4 0.5) 35 | (0 -25.4 0.5) 36 | (0 0 0.5) 37 | (0 25.4 0.5) 38 | (206 -25.4 0.5) 39 | (206 0 0.5) 40 | (206 25.4 0.5) 41 | (290 -16.6 0.5) 42 | (290 0 0.5) 43 | (290 16.6 0.5) 44 | ); 45 | 46 | negY 47 | ( 48 | (2 4 1) 49 | (1 3 0.3) 50 | ); 51 | 52 | posY 53 | ( 54 | (1 4 2) 55 | (2 3 4) 56 | (2 4 0.25) 57 | ); 58 | 59 | posYR 60 | ( 61 | (2 1 1) 62 | (1 1 0.25) 63 | ); 64 | 65 | 66 | blocks 67 | ( 68 | hex (0 3 4 1 11 14 15 12) 69 | (18 30 1) 70 | simpleGrading (0.5 $posY 1) 71 | 72 | hex (2 5 6 3 13 16 17 14) 73 | (180 27 1) 74 | edgeGrading (4 4 4 4 $negY 1 1 $negY 1 1 1 1) 75 | 76 | hex (3 6 7 4 14 17 18 15) 77 | (180 30 1) 78 | edgeGrading (4 4 4 4 $posY $posYR $posYR $posY 1 1 1 1) 79 | 80 | hex (5 8 9 6 16 19 20 17) 81 | (25 27 1) 82 | simpleGrading (2.5 1 1) 83 | 84 | hex (6 9 10 7 17 20 21 18) 85 | (25 30 1) 86 | simpleGrading (2.5 $posYR 1) 87 | ); 88 | 89 | edges 90 | ( 91 | ); 92 | 93 | boundary 94 | ( 95 | inlet 96 | { 97 | type patch; 98 | faces 99 | ( 100 | (0 1 12 11) 101 | ); 102 | } 103 | outlet 104 | { 105 | type patch; 106 | faces 107 | ( 108 | (8 9 20 19) 109 | (9 10 21 20) 110 | ); 111 | } 112 | upperWall 113 | { 114 | type wall; 115 | faces 116 | ( 117 | (1 4 15 12) 118 | (4 7 18 15) 119 | (7 10 21 18) 120 | ); 121 | } 122 | lowerWall 123 | { 124 | type wall; 125 | faces 126 | ( 127 | (0 3 14 11) 128 | (3 2 13 14) 129 | (2 5 16 13) 130 | (5 8 19 16) 131 | ); 132 | } 133 | frontAndBack 134 | { 135 | type empty; 136 | faces 137 | ( 138 | (0 3 4 1) 139 | (2 5 6 3) 140 | (3 6 7 4) 141 | (5 8 9 6) 142 | (6 9 10 7) 143 | (11 14 15 12) 144 | (13 16 17 14) 145 | (14 17 18 15) 146 | (16 19 20 17) 147 | (17 20 21 18) 148 | ); 149 | } 150 | ); 151 | 152 | 153 | // ************************************************************************* // 154 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/pitzDaily/system/controlDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2306 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object controlDict; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | application simpleFoam; 18 | 19 | startFrom startTime; 20 | 21 | startTime 0; 22 | 23 | stopAt endTime; 24 | 25 | endTime 2000; 26 | 27 | deltaT 1; 28 | 29 | writeControl timeStep; 30 | 31 | writeInterval 100; 32 | 33 | purgeWrite 0; 34 | 35 | writeFormat ascii; 36 | 37 | writePrecision 6; 38 | 39 | writeCompression off; 40 | 41 | timeFormat general; 42 | 43 | timePrecision 6; 44 | 45 | runTimeModifiable true; 46 | 47 | functions 48 | { 49 | #includeFunc streamlines 50 | avgInlets 51 | { 52 | type surfaceFieldValue; 53 | functionObjectLibs (fieldFunctionObjects); 54 | fields (p); 55 | operation areaAverage; 56 | regionType patch; 57 | name inlet; 58 | writeFields true; 59 | surfaceFormat none; 60 | } 61 | } 62 | 63 | 64 | // ************************************************************************* // 65 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/pitzDaily/system/fvSchemes: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2306 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object fvSchemes; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | ddtSchemes 18 | { 19 | default steadyState; 20 | } 21 | 22 | gradSchemes 23 | { 24 | default Gauss linear; 25 | } 26 | 27 | divSchemes 28 | { 29 | default none; 30 | 31 | div(phi,U) bounded Gauss linearUpwind grad(U); 32 | 33 | turbulence bounded Gauss limitedLinear 1; 34 | div(phi,k) $turbulence; 35 | div(phi,epsilon) $turbulence; 36 | div(phi,omega) $turbulence; 37 | 38 | div(nonlinearStress) Gauss linear; 39 | div((nuEff*dev2(T(grad(U))))) Gauss linear; 40 | } 41 | 42 | laplacianSchemes 43 | { 44 | default Gauss linear corrected; 45 | } 46 | 47 | interpolationSchemes 48 | { 49 | default linear; 50 | } 51 | 52 | snGradSchemes 53 | { 54 | default corrected; 55 | } 56 | 57 | wallDist 58 | { 59 | method meshWave; 60 | } 61 | 62 | 63 | // ************************************************************************* // 64 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/pitzDaily/system/fvSolution: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2306 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object fvSolution; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | solvers 18 | { 19 | p 20 | { 21 | solver GAMG; 22 | tolerance 1e-06; 23 | relTol 0.1; 24 | smoother GaussSeidel; 25 | } 26 | 27 | "(U|k|epsilon|omega|f|v2)" 28 | { 29 | solver smoothSolver; 30 | smoother symGaussSeidel; 31 | tolerance 1e-05; 32 | relTol 0.1; 33 | } 34 | } 35 | 36 | SIMPLE 37 | { 38 | nNonOrthogonalCorrectors 0; 39 | consistent yes; 40 | 41 | residualControl 42 | { 43 | p 1e-2; 44 | U 1e-3; 45 | "(k|epsilon|omega|f|v2)" 1e-3; 46 | } 47 | } 48 | 49 | relaxationFactors 50 | { 51 | equations 52 | { 53 | U 0.9; // 0.9 is more stable but 0.95 more convergent 54 | ".*" 0.9; // 0.9 is more stable but 0.95 more convergent 55 | } 56 | } 57 | 58 | 59 | // ************************************************************************* // 60 | -------------------------------------------------------------------------------- /tutorials/bayesianOptimization/pitzDaily/system/streamlines: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | nLines 10; 4 | start (-0.0205 0.001 0.00001); 5 | end (-0.0205 0.0251 0.00001); 6 | fields (p k U); 7 | U U; 8 | 9 | // Must be last entry 10 | #includeEtc "caseDicts/postProcessing/visualization/streamlines.cfg" 11 | 12 | 13 | // ************************************************************************* // 14 | -------------------------------------------------------------------------------- /tutorials/functionObject/README.md: -------------------------------------------------------------------------------- 1 | ## Computing the SVD of OpenFOAM fields 2 | 3 | Running `openfoam-svd.py` will perform an SVD on OpenFOAM fields that results off 4 | of a `pitzDaily` case. The case runs with `simpleFoam` and communicates its fields 5 | to the `smartRedis` database through a `fieldsToSmartRedis` function object. 6 | 7 | ## Usage of the Function Object with SmartSim ensembles 8 | 9 | The same function object is used in an ensemble setting to showcase a dummy parameter 10 | variation. The only requirement is that the solver has access to an environment variable: 11 | ```bash 12 | export SSKEYIN=${SSKEYOUT} 13 | ``` 14 | This ensures each ensemble member reads and writes fields to a prefixed datasets to prevent 15 | race conditions and members reading data from each other. 16 | -------------------------------------------------------------------------------- /tutorials/functionObject/openfoam-ensemble.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | # This script sets up a smartsim experiment that runs the simpleFoam solver 4 | # on the pitzDaily case with an ensemble of parameters. 5 | # The experiment involves the use of the fieldToSmartRedis function objects, 6 | # which writes a set of OpenFOAM fields to the SmartRedis database. The SmartRedis client 7 | # then reads these fields 8 | 9 | # Adapted from: 10 | # https://github.com/OFDataCommittee/OFMLHackathon/tree/main/2023-01/smartsim/smartsim_function_object 11 | 12 | from smartsim import Experiment 13 | import jinja2 as jj 14 | 15 | env = jj.Environment() 16 | 17 | def get_field_name(fn_name, field_name, processor=0, timestep=None): 18 | """ 19 | Get the name of the field from the database. This function uses 20 | a metadata dataset posted by the function object itself to determine 21 | how things are named through Jinja2 templates 22 | 23 | Args: 24 | fn_name (str): The name of the function object 25 | field_name (str): The name of the OpenFOAM field 26 | processor (int): The MPI rank 27 | timestep (int): The target timestep index 28 | """ 29 | client.poll_dataset(fn_name+"_metadata", 10, 1000) 30 | meta = client.get_dataset(fn_name+"_metadata") 31 | ds_naming = env.from_string(str(meta.get_meta_strings("dataset")[0])) 32 | ds_name = ds_naming.render(time_index=timestep, mpi_rank=processor) 33 | f_naming = env.from_string(str(meta.get_meta_strings("field")[0])) 34 | f_name = f_naming.render(name=field_name, patch="internal") 35 | return f"{{{ds_name}}}.{f_name}" 36 | 37 | of_case_name = "pitzDaily" 38 | fn_name = "pUPhiTest" 39 | ens_name = "pitzDaily" 40 | 41 | # Set up the OpenFOAM parameter variation as a SmartSim Experiment 42 | exp = Experiment("smartsim-openfoam-function-object", launcher="local") 43 | 44 | # Assumes SSDB="localhost:8000" 45 | db = exp.create_database(port=8000, interface="lo") 46 | params = { 47 | "dummy": [1, 2] 48 | } 49 | exp.start(db) 50 | 51 | blockMesh_settings = exp.create_run_settings(exe="./pitzDaily/Allrun") 52 | blockMesh_model = exp.create_model(name="blockMesh", run_settings=blockMesh_settings) 53 | ens = exp.create_ensemble(ens_name, params, None, blockMesh_settings) 54 | ens.attach_generator_files( 55 | to_copy=[f"./{of_case_name}"], 56 | to_configure=[]) 57 | exp.generate(ens, overwrite=True) 58 | exp.start(ens) 59 | exp.stop(db) 60 | -------------------------------------------------------------------------------- /tutorials/functionObject/openfoam-svd.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | # This script sets up a smartsim experiment that runs the simpleFoam solver 4 | # on the pitzDaily case. 5 | # The experiment involves the use of the fieldToSmartRedis function objects, 6 | # which writes a set of OpenFOAM fields to the SmartRedis database. The SmartRedis client 7 | # then reads these fields, initiating a process of Singular Value Decomposition. 8 | 9 | # Adapted from: 10 | # https://github.com/OFDataCommittee/OFMLHackathon/tree/main/2023-01/smartsim/smartsim_function_object 11 | 12 | # PyFoam for OpenFOAM input file and folder manipulation 13 | from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile 14 | import os 15 | from smartsim import Experiment 16 | from smartredis import Client 17 | import numpy as np 18 | import jinja2 as jj 19 | 20 | env = jj.Environment() 21 | 22 | def get_field_name(fn_name, field_name, processor=0, timestep=None): 23 | """ 24 | Get the name of the field from the database. This function uses 25 | a metadata dataset posted by the function object itself to determine 26 | how things are named through Jinja2 templates 27 | 28 | Args: 29 | fn_name (str): The name of the function object 30 | field_name (str): The name of the OpenFOAM field 31 | processor (int): The MPI rank 32 | timestep (int): The target timestep index 33 | """ 34 | client.poll_dataset(fn_name+"_metadata", 10, 1000) 35 | meta = client.get_dataset(fn_name+"_metadata") 36 | ds_naming = env.from_string(str(meta.get_meta_strings("dataset")[0])) 37 | ds_name = ds_naming.render(time_index=timestep, mpi_rank=processor) 38 | f_naming = env.from_string(str(meta.get_meta_strings("field")[0])) 39 | f_name = f_naming.render(name=field_name, patch="internal") 40 | return f"{{{ds_name}}}.{f_name}" 41 | 42 | def calc_svd(input_tensor): 43 | """ 44 | Applies the SVD (Singular Value Decomposition) function to the input tensor 45 | using the TorchScript API. 46 | """ 47 | return input_tensor.svd() 48 | 49 | of_case_name = "pitzDaily" 50 | fn_name = "pUPhiTest" 51 | 52 | # Set up the OpenFOAM parameter variation as a SmartSim Experiment 53 | exp = Experiment("smartsim-openfoam-function-object", launcher="local") 54 | 55 | # Assumes SSDB="localhost:8000" 56 | db = exp.create_database(port=8000, interface="lo") 57 | exp.start(db) 58 | 59 | # blockMesh settings & model 60 | blockMesh_settings = exp.create_run_settings(exe="blockMesh", exe_args=f"-case {of_case_name}") 61 | blockMesh_model = exp.create_model(name="blockMesh", run_settings=blockMesh_settings) 62 | # Mesh with blockMesh, and wait for meshing to finish before running the next model 63 | exp.start(blockMesh_model, summary=True, block=True) 64 | 65 | # simpleFoam settings & model 66 | simpleFoam_settings = exp.create_run_settings(exe="simpleFoam", exe_args=f"-case {of_case_name}") 67 | simpleFoam_model = exp.create_model(name="simpleFoam", run_settings=simpleFoam_settings) 68 | # Run simpleFoam solver 69 | exp.start(simpleFoam_model, summary=True, block=True) 70 | 71 | # Get the names of OpenFOAM fiels from controlDict.functionObject 72 | control_dict = ParsedParameterFile(os.path.join(of_case_name, "system/controlDict")) 73 | field_names = list(control_dict["functions"][fn_name]["fields"]) 74 | 75 | # Open a connection to the SmartRedis database 76 | client = Client(address=db.get_address()[0], cluster=False) 77 | client.set_function("svd", calc_svd) 78 | 79 | # Get last timestep index from the metadata dataset 80 | end_ts = int(client.get_dataset(fn_name+"_metadata").get_meta_strings("EndTimeIndex")[0]) 81 | 82 | # Apply SVD to fields 83 | print(f"SVD will be performed on OpenFOAM fields: {field_names}") 84 | for field_name in field_names: 85 | print (f"SVD decomposition of field: {field_name}...") 86 | db_field_name = get_field_name(fn_name, field_name, processor=0, timestep=end_ts) 87 | print(f"Using {db_field_name} from the database") 88 | client.run_script("svd", "calc_svd", [db_field_name], ["U", "S", "V"]) 89 | U = client.get_tensor("U") 90 | S = client.get_tensor("S") 91 | V = client.get_tensor("V") 92 | 93 | # Compute the Singular Value Decomposition of the field 94 | field_svd = np.dot(U, np.dot(S, V)) 95 | field_svd = field_svd[:, np.newaxis] 96 | 97 | # Compute the mean error of the SVD 98 | field = client.get_tensor(db_field_name) 99 | svd_rmse = np.sqrt(np.mean((field - field_svd) ** 2)) 100 | print (f"RMSE({field_name}, SVD({field_name})): {svd_rmse}") 101 | 102 | exp.stop(db) 103 | -------------------------------------------------------------------------------- /tutorials/functionObject/pitzDaily/0/U: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2206 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volVectorField; 13 | object U; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | dimensions [0 1 -1 0 0 0 0]; 18 | 19 | internalField uniform (0 0 0); 20 | 21 | boundaryField 22 | { 23 | inlet 24 | { 25 | type fixedValue; 26 | value uniform (10 0 0); 27 | } 28 | 29 | outlet 30 | { 31 | type zeroGradient; 32 | } 33 | 34 | upperWall 35 | { 36 | type noSlip; 37 | } 38 | 39 | lowerWall 40 | { 41 | type noSlip; 42 | } 43 | 44 | frontAndBack 45 | { 46 | type empty; 47 | } 48 | } 49 | 50 | 51 | // ************************************************************************* // 52 | -------------------------------------------------------------------------------- /tutorials/functionObject/pitzDaily/0/epsilon: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2206 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volScalarField; 13 | object epsilon; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | dimensions [0 2 -3 0 0 0 0]; 18 | 19 | internalField uniform 14.855; 20 | 21 | boundaryField 22 | { 23 | inlet 24 | { 25 | type fixedValue; 26 | value uniform 14.855; 27 | } 28 | 29 | outlet 30 | { 31 | type zeroGradient; 32 | } 33 | 34 | upperWall 35 | { 36 | type epsilonWallFunction; 37 | value uniform 14.855; 38 | } 39 | 40 | lowerWall 41 | { 42 | type epsilonWallFunction; 43 | value uniform 14.855; 44 | } 45 | 46 | frontAndBack 47 | { 48 | type empty; 49 | } 50 | } 51 | 52 | 53 | // ************************************************************************* // 54 | -------------------------------------------------------------------------------- /tutorials/functionObject/pitzDaily/0/k: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2206 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volScalarField; 13 | object k; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | dimensions [0 2 -2 0 0 0 0]; 18 | 19 | internalField uniform 0.375; 20 | 21 | boundaryField 22 | { 23 | inlet 24 | { 25 | type fixedValue; 26 | value uniform 0.375; 27 | } 28 | 29 | outlet 30 | { 31 | type zeroGradient; 32 | } 33 | 34 | upperWall 35 | { 36 | type kqRWallFunction; 37 | value uniform 0.375; 38 | } 39 | 40 | lowerWall 41 | { 42 | type kqRWallFunction; 43 | value uniform 0.375; 44 | } 45 | 46 | frontAndBack 47 | { 48 | type empty; 49 | } 50 | } 51 | 52 | 53 | // ************************************************************************* // 54 | -------------------------------------------------------------------------------- /tutorials/functionObject/pitzDaily/0/nuTilda: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2206 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volScalarField; 13 | object nuTilda; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | dimensions [0 2 -1 0 0 0 0]; 18 | 19 | internalField uniform 0; 20 | 21 | boundaryField 22 | { 23 | inlet 24 | { 25 | type fixedValue; 26 | value uniform 0; 27 | } 28 | 29 | outlet 30 | { 31 | type zeroGradient; 32 | } 33 | 34 | upperWall 35 | { 36 | type zeroGradient; 37 | } 38 | 39 | lowerWall 40 | { 41 | type zeroGradient; 42 | } 43 | 44 | frontAndBack 45 | { 46 | type empty; 47 | } 48 | } 49 | 50 | 51 | // ************************************************************************* // 52 | -------------------------------------------------------------------------------- /tutorials/functionObject/pitzDaily/0/nut: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2206 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volScalarField; 13 | object nut; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | dimensions [0 2 -1 0 0 0 0]; 18 | 19 | internalField uniform 0; 20 | 21 | boundaryField 22 | { 23 | inlet 24 | { 25 | type calculated; 26 | value uniform 0; 27 | } 28 | 29 | outlet 30 | { 31 | type calculated; 32 | value uniform 0; 33 | } 34 | 35 | upperWall 36 | { 37 | type nutkWallFunction; 38 | value uniform 0; 39 | } 40 | 41 | lowerWall 42 | { 43 | type nutkWallFunction; 44 | value uniform 0; 45 | } 46 | 47 | frontAndBack 48 | { 49 | type empty; 50 | } 51 | } 52 | 53 | 54 | // ************************************************************************* // 55 | -------------------------------------------------------------------------------- /tutorials/functionObject/pitzDaily/0/omega: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2206 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volScalarField; 13 | object omega; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | dimensions [0 0 -1 0 0 0 0]; 18 | 19 | internalField uniform 440.15; 20 | 21 | boundaryField 22 | { 23 | inlet 24 | { 25 | type fixedValue; 26 | value $internalField; 27 | } 28 | 29 | outlet 30 | { 31 | type zeroGradient; 32 | } 33 | 34 | upperWall 35 | { 36 | type omegaWallFunction; 37 | value $internalField; 38 | } 39 | 40 | lowerWall 41 | { 42 | type omegaWallFunction; 43 | value $internalField; 44 | } 45 | 46 | frontAndBack 47 | { 48 | type empty; 49 | } 50 | } 51 | 52 | 53 | // ************************************************************************* // 54 | -------------------------------------------------------------------------------- /tutorials/functionObject/pitzDaily/0/p: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2206 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volScalarField; 13 | object p; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | dimensions [0 2 -2 0 0 0 0]; 18 | 19 | internalField uniform 0; 20 | 21 | boundaryField 22 | { 23 | inlet 24 | { 25 | type zeroGradient; 26 | } 27 | 28 | outlet 29 | { 30 | type fixedValue; 31 | value uniform 0; 32 | } 33 | 34 | upperWall 35 | { 36 | type zeroGradient; 37 | } 38 | 39 | lowerWall 40 | { 41 | type zeroGradient; 42 | } 43 | 44 | frontAndBack 45 | { 46 | type empty; 47 | } 48 | } 49 | 50 | 51 | // ************************************************************************* // 52 | -------------------------------------------------------------------------------- /tutorials/functionObject/pitzDaily/Allrun: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | export SSKEYIN=$SSKEYOUT 3 | blockMesh 4 | simpleFoam 5 | -------------------------------------------------------------------------------- /tutorials/functionObject/pitzDaily/constant/transportProperties: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2206 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object transportProperties; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | transportModel Newtonian; 18 | 19 | nu 1e-05; 20 | 21 | 22 | // ************************************************************************* // 23 | -------------------------------------------------------------------------------- /tutorials/functionObject/pitzDaily/constant/turbulenceProperties: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2206 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object turbulenceProperties; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | simulationType RAS; 18 | 19 | RAS 20 | { 21 | // Tested with kEpsilon, realizableKE, kOmega, kOmegaSST, 22 | // ShihQuadraticKE, LienCubicKE. 23 | RASModel kEpsilon; 24 | 25 | turbulence on; 26 | 27 | printCoeffs on; 28 | } 29 | 30 | 31 | // ************************************************************************* // 32 | -------------------------------------------------------------------------------- /tutorials/functionObject/pitzDaily/system/blockMeshDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2206 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object blockMeshDict; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | scale 0.001; 18 | 19 | vertices 20 | ( 21 | (-20.6 0 -0.5) 22 | (-20.6 25.4 -0.5) 23 | (0 -25.4 -0.5) 24 | (0 0 -0.5) 25 | (0 25.4 -0.5) 26 | (206 -25.4 -0.5) 27 | (206 0 -0.5) 28 | (206 25.4 -0.5) 29 | (290 -16.6 -0.5) 30 | (290 0 -0.5) 31 | (290 16.6 -0.5) 32 | 33 | (-20.6 0 0.5) 34 | (-20.6 25.4 0.5) 35 | (0 -25.4 0.5) 36 | (0 0 0.5) 37 | (0 25.4 0.5) 38 | (206 -25.4 0.5) 39 | (206 0 0.5) 40 | (206 25.4 0.5) 41 | (290 -16.6 0.5) 42 | (290 0 0.5) 43 | (290 16.6 0.5) 44 | ); 45 | 46 | negY 47 | ( 48 | (2 4 1) 49 | (1 3 0.3) 50 | ); 51 | 52 | posY 53 | ( 54 | (1 4 2) 55 | (2 3 4) 56 | (2 4 0.25) 57 | ); 58 | 59 | posYR 60 | ( 61 | (2 1 1) 62 | (1 1 0.25) 63 | ); 64 | 65 | 66 | blocks 67 | ( 68 | hex (0 3 4 1 11 14 15 12) 69 | (18 30 1) 70 | simpleGrading (0.5 $posY 1) 71 | 72 | hex (2 5 6 3 13 16 17 14) 73 | (180 27 1) 74 | edgeGrading (4 4 4 4 $negY 1 1 $negY 1 1 1 1) 75 | 76 | hex (3 6 7 4 14 17 18 15) 77 | (180 30 1) 78 | edgeGrading (4 4 4 4 $posY $posYR $posYR $posY 1 1 1 1) 79 | 80 | hex (5 8 9 6 16 19 20 17) 81 | (25 27 1) 82 | simpleGrading (2.5 1 1) 83 | 84 | hex (6 9 10 7 17 20 21 18) 85 | (25 30 1) 86 | simpleGrading (2.5 $posYR 1) 87 | ); 88 | 89 | edges 90 | ( 91 | ); 92 | 93 | boundary 94 | ( 95 | inlet 96 | { 97 | type patch; 98 | faces 99 | ( 100 | (0 1 12 11) 101 | ); 102 | } 103 | outlet 104 | { 105 | type patch; 106 | faces 107 | ( 108 | (8 9 20 19) 109 | (9 10 21 20) 110 | ); 111 | } 112 | upperWall 113 | { 114 | type wall; 115 | faces 116 | ( 117 | (1 4 15 12) 118 | (4 7 18 15) 119 | (7 10 21 18) 120 | ); 121 | } 122 | lowerWall 123 | { 124 | type wall; 125 | faces 126 | ( 127 | (0 3 14 11) 128 | (3 2 13 14) 129 | (2 5 16 13) 130 | (5 8 19 16) 131 | ); 132 | } 133 | frontAndBack 134 | { 135 | type empty; 136 | faces 137 | ( 138 | (0 3 4 1) 139 | (2 5 6 3) 140 | (3 6 7 4) 141 | (5 8 9 6) 142 | (6 9 10 7) 143 | (11 14 15 12) 144 | (13 16 17 14) 145 | (14 17 18 15) 146 | (16 19 20 17) 147 | (17 20 21 18) 148 | ); 149 | } 150 | ); 151 | 152 | 153 | // ************************************************************************* // 154 | -------------------------------------------------------------------------------- /tutorials/functionObject/pitzDaily/system/controlDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2206 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object controlDict; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | application simpleFoam; 18 | 19 | startFrom startTime; 20 | 21 | startTime 0; 22 | 23 | stopAt endTime; 24 | 25 | endTime 2000; 26 | 27 | deltaT 1; 28 | 29 | writeControl timeStep; 30 | 31 | writeInterval 100; 32 | 33 | purgeWrite 0; 34 | 35 | writeFormat ascii; 36 | 37 | writePrecision 6; 38 | 39 | writeCompression off; 40 | 41 | timeFormat general; 42 | 43 | timePrecision 6; 44 | 45 | runTimeModifiable true; 46 | 47 | functions 48 | { 49 | pUPhiTest 50 | { 51 | type fieldsToSmartRedis; 52 | libs ("libsmartredisFunctionObjects.so"); 53 | clusterMode off; 54 | fields (p U phi); 55 | patches (internal); 56 | } 57 | } 58 | 59 | // ************************************************************************* // 60 | -------------------------------------------------------------------------------- /tutorials/functionObject/pitzDaily/system/decomposeParDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2206 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object decomposeParDict; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | numberOfSubdomains 4; 18 | 19 | method simple; 20 | 21 | coeffs 22 | { 23 | n (4 1 1); 24 | } 25 | 26 | 27 | // ************************************************************************* // 28 | -------------------------------------------------------------------------------- /tutorials/functionObject/pitzDaily/system/fvSchemes: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2206 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object fvSchemes; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | ddtSchemes 18 | { 19 | default steadyState; 20 | } 21 | 22 | gradSchemes 23 | { 24 | default Gauss linear; 25 | } 26 | 27 | divSchemes 28 | { 29 | default none; 30 | 31 | div(phi,U) bounded Gauss linearUpwind grad(U); 32 | 33 | turbulence bounded Gauss limitedLinear 1; 34 | div(phi,k) $turbulence; 35 | div(phi,epsilon) $turbulence; 36 | div(phi,omega) $turbulence; 37 | 38 | div(nonlinearStress) Gauss linear; 39 | div((nuEff*dev2(T(grad(U))))) Gauss linear; 40 | } 41 | 42 | laplacianSchemes 43 | { 44 | default Gauss linear corrected; 45 | } 46 | 47 | interpolationSchemes 48 | { 49 | default linear; 50 | } 51 | 52 | snGradSchemes 53 | { 54 | default corrected; 55 | } 56 | 57 | wallDist 58 | { 59 | method meshWave; 60 | } 61 | 62 | 63 | // ************************************************************************* // 64 | -------------------------------------------------------------------------------- /tutorials/functionObject/pitzDaily/system/fvSolution: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2206 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object fvSolution; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | solvers 18 | { 19 | p 20 | { 21 | solver GAMG; 22 | tolerance 1e-06; 23 | relTol 0.1; 24 | smoother GaussSeidel; 25 | } 26 | 27 | "(U|k|epsilon|omega|f|v2)" 28 | { 29 | solver smoothSolver; 30 | smoother symGaussSeidel; 31 | tolerance 1e-05; 32 | relTol 0.1; 33 | } 34 | } 35 | 36 | SIMPLE 37 | { 38 | nNonOrthogonalCorrectors 0; 39 | consistent yes; 40 | 41 | residualControl 42 | { 43 | p 1e-2; 44 | U 1e-3; 45 | "(k|epsilon|omega|f|v2)" 1e-3; 46 | } 47 | } 48 | 49 | relaxationFactors 50 | { 51 | equations 52 | { 53 | U 0.9; // 0.9 is more stable but 0.95 more convergent 54 | ".*" 0.9; // 0.9 is more stable but 0.95 more convergent 55 | } 56 | } 57 | 58 | 59 | // ************************************************************************* // 60 | -------------------------------------------------------------------------------- /tutorials/functionObject/pitzDaily/system/streamlines: -------------------------------------------------------------------------------- 1 | // -*- C++ -*- 2 | 3 | nLines 10; 4 | start (-0.0205 0.001 0.00001); 5 | end (-0.0205 0.0251 0.00001); 6 | fields (p k U); 7 | U U; 8 | 9 | // Must be last entry 10 | #includeEtc "caseDicts/postProcessing/visualization/streamlines.cfg" 11 | 12 | 13 | // ************************************************************************* // 14 | -------------------------------------------------------------------------------- /tutorials/meshMotion/spinningDisk/0.orig/pointDisplacement: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2206 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class pointVectorField; 13 | object pointDisplacement; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | dimensions [0 1 0 0 0 0 0]; 18 | 19 | internalField uniform (0 0 0); 20 | 21 | boundaryField 22 | { 23 | 24 | cylinder 25 | { 26 | type solidBodyMotionDisplacement; 27 | solidBodyMotionFunction oscillatingRotatingMotion; 28 | multiMotionCoeffs 29 | { 30 | translation 31 | { 32 | solidBodyMotionFunction linearMotion; 33 | linearMotionCoeffs 34 | { 35 | velocity (1 0 0); 36 | } 37 | } 38 | rotation 39 | { 40 | solidBodyMotionFunction rotatingMotion; 41 | rotatingMotionCoeffs 42 | { 43 | origin (0 0 0); 44 | axis (0 0 1); 45 | omega 1; // rad/s, 1rad/s=9.5rpm 46 | } 47 | } 48 | } 49 | oscillatingRotatingMotionCoeffs 50 | { 51 | origin (0 0 0); 52 | axis (0 0 1); 53 | omega 1.5; // rad/s, 1rad/s=9.5rpm 54 | amplitude (0 0 30); // max amplitude (degrees) 55 | } 56 | } 57 | 58 | inlet 59 | { 60 | type fixedValue; 61 | value uniform (0 0 0); 62 | } 63 | 64 | outlet 65 | { 66 | type fixedValue; 67 | value uniform (0 0 0); 68 | } 69 | 70 | walls 71 | { 72 | type fixedValue; 73 | value uniform (0 0 0); 74 | } 75 | 76 | frontAndBack 77 | { 78 | type empty; 79 | } 80 | 81 | } 82 | 83 | 84 | // ************************************************************************* // 85 | -------------------------------------------------------------------------------- /tutorials/meshMotion/spinningDisk/Allclean: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd "${0%/*}" || exit # Run from this directory 3 | . ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions # Tutorial clean functions 4 | #------------------------------------------------------------------------------ 5 | 6 | cleanCase0 7 | 8 | #------------------------------------------------------------------------------ 9 | -------------------------------------------------------------------------------- /tutorials/meshMotion/spinningDisk/Allrun.post: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd "${0%/*}" || exit # Run from this directory 3 | . ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions 4 | #------------------------------------------------------------------------------ 5 | 6 | runApplication checkMesh -constant -writeAllFields 7 | 8 | #------------------------------------------------------------------------------ 9 | -------------------------------------------------------------------------------- /tutorials/meshMotion/spinningDisk/Allrun.pre: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd "${0%/*}" || exit # Run from this directory 3 | . ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions 4 | #------------------------------------------------------------------------------ 5 | 6 | restore0Dir 7 | 8 | runApplication blockMesh 9 | 10 | runApplication decomposePar 11 | 12 | #------------------------------------------------------------------------------ 13 | -------------------------------------------------------------------------------- /tutorials/meshMotion/spinningDisk/constant/dynamicMeshDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2206 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object dynamicMeshDict; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | 18 | dynamicFvMesh dynamicMotionSolverFvMesh; 19 | 20 | // SmartSim mesh motion 21 | motionSolverLibs (smartSimMotionSolvers); 22 | solver displacementSmartSim; 23 | displacementSmartSimCoeffs 24 | { 25 | clusterMode off; 26 | } 27 | 28 | // OpenFOAM mesh motion 29 | //motionSolverLibs (fvMotionSolvers); 30 | //motionSolver displacementLaplacian; 31 | //displacementLaplacianCoeffs 32 | //{ 33 | // diffusivity inverseDistance (cylinder); 34 | //} 35 | 36 | // ************************************************************************* // 37 | -------------------------------------------------------------------------------- /tutorials/meshMotion/spinningDisk/constant/g: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2206 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class uniformDimensionedVectorField; 13 | object g; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | dimensions [0 1 -2 0 0 0 0]; 18 | value (0 0 -9.8); 19 | 20 | 21 | // ************************************************************************* // 22 | -------------------------------------------------------------------------------- /tutorials/meshMotion/spinningDisk/constant/transportProperties: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2206 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object transportProperties; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | transportModel Newtonian; 18 | 19 | nu 1e-05; 20 | 21 | rhoInf 1.2; 22 | 23 | 24 | // ************************************************************************* // 25 | -------------------------------------------------------------------------------- /tutorials/meshMotion/spinningDisk/constant/turbulenceProperties: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2206 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object turbulenceProperties; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | simulationType laminar; 18 | 19 | 20 | // ************************************************************************* // 21 | -------------------------------------------------------------------------------- /tutorials/meshMotion/spinningDisk/system/blockMeshDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2206 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object blockMeshDict; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | scale 1; 18 | 19 | r 1; 20 | a #eval{1./sqrt(2)*$r}; 21 | b #eval{3*$r}; 22 | 23 | n 16; 24 | 25 | vertices 26 | ( 27 | (-$b -$b 0) // 0 28 | ( $b -$b 0) // 1 29 | (-$a -$a 0) // 2 30 | ( $a -$a 0) // 3 31 | (-$a $a 0) // 4 32 | ( $a $a 0) // 5 33 | (-$b $b 0) // 6 34 | ( $b $b 0) // 7 35 | 36 | (-$b -$b 1) // 8 37 | ( $b -$b 1) // 9 38 | (-$a -$a 1) // 10 39 | ( $a -$a 1) // 11 40 | (-$a $a 1) // 12 41 | ( $a $a 1) // 13 42 | (-$b $b 1) // 14 43 | ( $b $b 1) // 15 44 | ); 45 | 46 | blocks 47 | ( 48 | hex (0 1 3 2 8 9 11 10) ($n $n 1) simpleGrading (1 1 1) 49 | hex (1 7 5 3 9 15 13 11) ($n $n 1) simpleGrading (1 1 1) 50 | hex (7 6 4 5 15 14 12 13) ($n $n 1) simpleGrading (1 1 1) 51 | hex (6 0 2 4 14 8 10 12) ($n $n 1) simpleGrading (1 1 1) 52 | ); 53 | 54 | edges 55 | ( 56 | arc 2 3 origin (0 0 0) 57 | arc 3 5 origin (0 0 0) 58 | arc 5 4 origin (0 0 0) 59 | arc 4 2 origin (0 0 0) 60 | 61 | arc 10 11 origin (0 0 1) 62 | arc 11 13 origin (0 0 1) 63 | arc 13 12 origin (0 0 1) 64 | arc 12 10 origin (0 0 1) 65 | ); 66 | 67 | boundary 68 | ( 69 | walls 70 | { 71 | type wall; 72 | faces 73 | ( 74 | (0 2) 75 | (2 2) 76 | ); 77 | } 78 | cylinder 79 | { 80 | type wall; 81 | faces 82 | ( 83 | (0 3) 84 | (1 3) 85 | (2 3) 86 | (3 3) 87 | ); 88 | } 89 | outlet 90 | { 91 | type patch; 92 | faces 93 | ( 94 | (1 2) 95 | ); 96 | } 97 | inlet 98 | { 99 | type patch; 100 | faces 101 | ( 102 | (3 2) 103 | ); 104 | } 105 | ); 106 | 107 | defaultPatch 108 | { 109 | type empty; 110 | name frontAndBack; 111 | } 112 | 113 | 114 | // ************************************************************************* // 115 | -------------------------------------------------------------------------------- /tutorials/meshMotion/spinningDisk/system/controlDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2206 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object controlDict; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | application moveDynamicMesh; 18 | 19 | startFrom startTime; 20 | 21 | startTime 0; 22 | 23 | stopAt endTime; 24 | 25 | endTime 20e-01; 26 | 27 | deltaT 1e-01; 28 | 29 | //writeControl adjustable; 30 | //writeInterval 0.05; 31 | 32 | writeControl timeStep; 33 | writeInterval 1; 34 | 35 | purgeWrite 0; 36 | 37 | writeFormat ascii; 38 | 39 | writePrecision 6; 40 | 41 | writeCompression off; 42 | 43 | timeFormat general; 44 | 45 | timePrecision 6; 46 | 47 | runTimeModifiable yes; 48 | 49 | adjustTimeStep yes; 50 | 51 | maxCo 0.9; 52 | 53 | maxDeltaT 0.1; 54 | 55 | DebugSwitches 56 | { 57 | displacementLaplacian 1; 58 | } 59 | 60 | // ************************************************************************* // 61 | -------------------------------------------------------------------------------- /tutorials/meshMotion/spinningDisk/system/decomposeParDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2206 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object decomposeParDict; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | numberOfSubdomains 4; 18 | 19 | method simple; 20 | 21 | coeffs 22 | { 23 | n ( 2 2 1 ); 24 | } 25 | 26 | 27 | // ************************************************************************* // 28 | -------------------------------------------------------------------------------- /tutorials/meshMotion/spinningDisk/system/fvSchemes: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2206 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object fvSchemes; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | ddtSchemes 18 | { 19 | default Euler; 20 | } 21 | 22 | gradSchemes 23 | { 24 | default Gauss linear; 25 | grad(p) Gauss linear; 26 | grad(U) Gauss linear; 27 | } 28 | 29 | divSchemes 30 | { 31 | default none; 32 | 33 | div(phi,U) Gauss upwind; 34 | 35 | div((nuEff*dev2(T(grad(U))))) Gauss linear; 36 | } 37 | 38 | laplacianSchemes 39 | { 40 | default Gauss linear corrected; 41 | } 42 | 43 | interpolationSchemes 44 | { 45 | default linear; 46 | } 47 | 48 | snGradSchemes 49 | { 50 | default corrected; 51 | } 52 | 53 | 54 | // ************************************************************************* // 55 | -------------------------------------------------------------------------------- /tutorials/meshMotion/spinningDisk/system/fvSolution: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2206 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object fvSolution; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | solvers 18 | { 19 | p 20 | { 21 | solver PBiCGStab; 22 | tolerance 0; 23 | relTol 0.1; 24 | smoother GaussSeidel; 25 | preconditioner DIC; 26 | } 27 | 28 | pFinal 29 | { 30 | $p; 31 | tolerance 1e-06; 32 | relTol 0; 33 | } 34 | 35 | U 36 | { 37 | solver smoothSolver; 38 | smoother GaussSeidel; 39 | tolerance 1e-05; 40 | relTol 0.01; 41 | } 42 | 43 | UFinal 44 | { 45 | $U; 46 | tolerance 1e-06; 47 | relTol 0; 48 | } 49 | 50 | cellDisplacement 51 | { 52 | solver GAMG; 53 | tolerance 1e-5; 54 | relTol 0; 55 | smoother GaussSeidel; 56 | cacheAgglomeration true; 57 | nCellsInCoarsestLevel 10; 58 | agglomerator faceAreaPair; 59 | mergeLevels 1; 60 | } 61 | 62 | cellDisplacementFinal 63 | { 64 | $cellDisplacement; 65 | tolerance 1e-06; 66 | relTol 0; 67 | } 68 | } 69 | 70 | PIMPLE 71 | { 72 | momentumPredictor yes; 73 | nOuterCorrectors 1; 74 | nCorrectors 2; 75 | nNonOrthogonalCorrectors 0; 76 | } 77 | 78 | 79 | // ************************************************************************* // 80 | -------------------------------------------------------------------------------- /tutorials/postProcessing/foamSmartSimSvd/Allclean: -------------------------------------------------------------------------------- 1 | rm -rf *.out *.err smartsim_db.dat partitioned-svd-cylinder 2 | ./cylinder2D/Allclean -------------------------------------------------------------------------------- /tutorials/postProcessing/foamSmartSimSvd/README.md: -------------------------------------------------------------------------------- 1 | # Computing the SVD of OpenFOAM fields 2 | 3 | This folder contains several workflows to compute the singular value decomposition (SVD) of OpenFOAM field data: 4 | 5 | 1. **foam-smartsim-svd.ipynb**: works with pre-computed snapshots; requires the *foamSmartSimSvd* utility; requires running the *cavity* test case before starting the notebook 6 | 2. **foam-smartsim-svd-db-api.ipynb**: same as *foam-smartsim-svd.ipynb* but with alternative SmartRedis API usage 7 | 3. **partitioned-svd-cylinder.ipynb**: employs the *fieldsToSmartRedis* function object to write OpenFOAM data directly into SmartRedis; requires the *svdToFoam* utility 8 | 9 | ## Requirements 10 | 11 | For general dependencies, refer to the [README.md](/README.md) in the top-level folder. 12 | To compile all utilities and function objects, go to the top-level folder and run: 13 | ``` 14 | source SOURCEME.sh 15 | ``` 16 | 17 | ## Executing the notebooks 18 | 19 | All notebooks are executed locally and expect port 8000 to be free. To run workflows 1. or 2., first go to the *cavity* folder and execute the *Allrun* script. To run any of the notebooks, open Jupyter Lab and click on *Run->Run all cells*. To reset workflow 3., use the *Allclean* script located in this folder. 20 | 21 | ## Additional information 22 | 23 | The notebook *foam-smartsim-svd.ipynb* and the corresponding OpenFOAM application *foamSmartSimSvd* use the [standard SmartRedis API](https://www.craylabs.org/docs/smartredis.html), while the notebook *foam-smartsim-svd-db-api.ipynb* and the corresponding application *foamSmartSimSvdDBAPI* use the OpenFOAM-SmartRedis database API from [src/smartRedis](/src/smartRedis) to interact with the SmartRedis database. -------------------------------------------------------------------------------- /tutorials/postProcessing/foamSmartSimSvd/cavity/0/U: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2212 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volVectorField; 13 | object U; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | dimensions [0 1 -1 0 0 0 0]; 18 | 19 | internalField uniform (0 0 0); 20 | 21 | boundaryField 22 | { 23 | movingWall 24 | { 25 | type fixedValue; 26 | value uniform (1 0 0); 27 | } 28 | 29 | fixedWalls 30 | { 31 | type noSlip; 32 | } 33 | 34 | frontAndBack 35 | { 36 | type empty; 37 | } 38 | } 39 | 40 | 41 | // ************************************************************************* // 42 | -------------------------------------------------------------------------------- /tutorials/postProcessing/foamSmartSimSvd/cavity/0/p: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2212 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volScalarField; 13 | object p; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | dimensions [0 2 -2 0 0 0 0]; 18 | 19 | internalField uniform 0; 20 | 21 | boundaryField 22 | { 23 | movingWall 24 | { 25 | type zeroGradient; 26 | } 27 | 28 | fixedWalls 29 | { 30 | type zeroGradient; 31 | } 32 | 33 | frontAndBack 34 | { 35 | type empty; 36 | } 37 | } 38 | 39 | 40 | // ************************************************************************* // 41 | -------------------------------------------------------------------------------- /tutorials/postProcessing/foamSmartSimSvd/cavity/Allrun: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd "${0%/*}" || exit # Run from this directory 3 | . ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions 4 | #------------------------------------------------------------------------------ 5 | 6 | . ./Allrun.pre 7 | 8 | runParallel $(getApplication) 9 | 10 | #------------------------------------------------------------------------------ 11 | -------------------------------------------------------------------------------- /tutorials/postProcessing/foamSmartSimSvd/cavity/Allrun.pre: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd "${0%/*}" || exit # Run from this directory 3 | . ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions 4 | #------------------------------------------------------------------------------ 5 | 6 | rm -rf log.blockMesh log.decomposePar log.icoFoam 7 | 8 | restore0Dir 9 | 10 | runApplication blockMesh 11 | 12 | runApplication decomposePar 13 | 14 | #------------------------------------------------------------------------------ 15 | -------------------------------------------------------------------------------- /tutorials/postProcessing/foamSmartSimSvd/cavity/case.foam: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OFDataCommittee/openfoam-smartsim/e7b3a57088ee59784e52307d10b75d04f083d967/tutorials/postProcessing/foamSmartSimSvd/cavity/case.foam -------------------------------------------------------------------------------- /tutorials/postProcessing/foamSmartSimSvd/cavity/constant/transportProperties: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2212 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object transportProperties; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | nu 0.01; 18 | 19 | 20 | // ************************************************************************* // 21 | -------------------------------------------------------------------------------- /tutorials/postProcessing/foamSmartSimSvd/cavity/system/PDRblockMeshDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2212 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object PDRblockMeshDict; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | scale 0.1; 18 | 19 | x 20 | { 21 | points (0 1); 22 | nCells (20); 23 | ratios (1); 24 | } 25 | 26 | y 27 | { 28 | points (0 1); 29 | nCells (20); 30 | ratios (1); 31 | } 32 | 33 | z 34 | { 35 | points (0 0.1); 36 | nCells (1); 37 | ratios (1); 38 | } 39 | 40 | 41 | boundary 42 | ( 43 | movingWall 44 | { 45 | type wall; 46 | faces (3); 47 | } 48 | fixedWalls 49 | { 50 | type wall; 51 | faces (0 1 2); 52 | } 53 | frontAndBack 54 | { 55 | type empty; 56 | faces (4 5); 57 | } 58 | ); 59 | 60 | 61 | // ************************************************************************* // 62 | -------------------------------------------------------------------------------- /tutorials/postProcessing/foamSmartSimSvd/cavity/system/blockMeshDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2212 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object blockMeshDict; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | scale 0.1; 18 | 19 | vertices 20 | ( 21 | (0 0 0) 22 | (1 0 0) 23 | (1 1 0) 24 | (0 1 0) 25 | (0 0 0.1) 26 | (1 0 0.1) 27 | (1 1 0.1) 28 | (0 1 0.1) 29 | ); 30 | 31 | blocks 32 | ( 33 | hex (0 1 2 3 4 5 6 7) (20 20 1) simpleGrading (1 1 1) 34 | ); 35 | 36 | edges 37 | ( 38 | ); 39 | 40 | boundary 41 | ( 42 | movingWall 43 | { 44 | type wall; 45 | faces 46 | ( 47 | (3 7 6 2) 48 | ); 49 | } 50 | fixedWalls 51 | { 52 | type wall; 53 | faces 54 | ( 55 | (0 4 7 3) 56 | (2 6 5 1) 57 | (1 5 4 0) 58 | ); 59 | } 60 | frontAndBack 61 | { 62 | type empty; 63 | faces 64 | ( 65 | (0 3 2 1) 66 | (4 5 6 7) 67 | ); 68 | } 69 | ); 70 | 71 | 72 | // ************************************************************************* // 73 | -------------------------------------------------------------------------------- /tutorials/postProcessing/foamSmartSimSvd/cavity/system/controlDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2212 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object controlDict; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | application icoFoam; 18 | 19 | startFrom startTime; 20 | 21 | startTime 0; 22 | 23 | stopAt endTime; 24 | 25 | endTime 0.05; 26 | 27 | deltaT 0.001; 28 | 29 | writeControl timeStep; 30 | 31 | writeInterval 1; 32 | 33 | purgeWrite 0; 34 | 35 | writeFormat ascii; 36 | 37 | writePrecision 6; 38 | 39 | writeCompression off; 40 | 41 | timeFormat general; 42 | 43 | timePrecision 6; 44 | 45 | runTimeModifiable true; 46 | 47 | 48 | // ************************************************************************* // 49 | -------------------------------------------------------------------------------- /tutorials/postProcessing/foamSmartSimSvd/cavity/system/decomposeParDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2212 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object decomposeParDict; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | numberOfSubdomains 4; 18 | 19 | method hierarchical; 20 | 21 | coeffs 22 | { 23 | n (2 2 1); 24 | } 25 | 26 | 27 | // ************************************************************************* // 28 | -------------------------------------------------------------------------------- /tutorials/postProcessing/foamSmartSimSvd/cavity/system/fvSchemes: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2212 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object fvSchemes; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | ddtSchemes 18 | { 19 | default Euler; 20 | } 21 | 22 | gradSchemes 23 | { 24 | default Gauss linear; 25 | grad(p) Gauss linear; 26 | } 27 | 28 | divSchemes 29 | { 30 | default none; 31 | div(phi,U) Gauss linear; 32 | } 33 | 34 | laplacianSchemes 35 | { 36 | default Gauss linear orthogonal; 37 | } 38 | 39 | interpolationSchemes 40 | { 41 | default linear; 42 | } 43 | 44 | snGradSchemes 45 | { 46 | default orthogonal; 47 | } 48 | 49 | 50 | // ************************************************************************* // 51 | -------------------------------------------------------------------------------- /tutorials/postProcessing/foamSmartSimSvd/cavity/system/fvSolution: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2212 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object fvSolution; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | solvers 18 | { 19 | p 20 | { 21 | solver PCG; 22 | preconditioner DIC; 23 | tolerance 1e-06; 24 | relTol 0.05; 25 | } 26 | 27 | pFinal 28 | { 29 | $p; 30 | relTol 0; 31 | } 32 | 33 | U 34 | { 35 | solver smoothSolver; 36 | smoother symGaussSeidel; 37 | tolerance 1e-05; 38 | relTol 0; 39 | } 40 | } 41 | 42 | PISO 43 | { 44 | nCorrectors 2; 45 | nNonOrthogonalCorrectors 0; 46 | pRefCell 0; 47 | pRefValue 0; 48 | } 49 | 50 | 51 | // ************************************************************************* // 52 | -------------------------------------------------------------------------------- /tutorials/postProcessing/foamSmartSimSvd/cylinder2D/0.org/U: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: com | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volVectorField; 13 | arch "LSB;label=32;scalar=64"; 14 | location "0"; 15 | object U; 16 | } 17 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 18 | 19 | dimensions [ 0 1 -1 0 0 0 0 ]; 20 | 21 | internalField uniform ( 0 0 0 ); 22 | 23 | boundaryField 24 | { 25 | inlet 26 | { 27 | type fixedValue; 28 | value uniform (1 0 0); 29 | } 30 | 31 | outlet 32 | { 33 | type zeroGradient; 34 | } 35 | 36 | "(cylinder|top|bottom)" 37 | { 38 | type noSlip; 39 | } 40 | 41 | "(front|back)" 42 | { 43 | type empty; 44 | } 45 | } 46 | 47 | 48 | // ************************************************************************* // 49 | -------------------------------------------------------------------------------- /tutorials/postProcessing/foamSmartSimSvd/cylinder2D/0.org/p: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v1912 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volScalarField; 13 | object p; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | dimensions [0 2 -2 0 0 0 0]; 18 | 19 | internalField uniform 0; 20 | 21 | boundaryField 22 | { 23 | "(inlet|cylinder|top|bottom)" 24 | { 25 | type zeroGradient; 26 | } 27 | 28 | outlet 29 | { 30 | type fixedValue; 31 | value $internalField; 32 | } 33 | 34 | "(front|back)" 35 | { 36 | type empty; 37 | } 38 | } 39 | 40 | 41 | // ************************************************************************* // 42 | -------------------------------------------------------------------------------- /tutorials/postProcessing/foamSmartSimSvd/cylinder2D/Allclean: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd "${0%/*}" || exit # Run from this directory 3 | . ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions # Tutorial run functions 4 | #------------------------------------------------------------------------------ 5 | 6 | cleanCase 7 | rm -rf 0 8 | 9 | #------------------------------------------------------------------------------ 10 | -------------------------------------------------------------------------------- /tutorials/postProcessing/foamSmartSimSvd/cylinder2D/Allrun: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd "${0%/*}" || exit # Run from this directory 3 | . ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions 4 | #------------------------------------------------------------------------------ 5 | 6 | # dummy file for post-processing with paraview 7 | touch post.foam 8 | 9 | # mesh creation 10 | runApplication blockMesh 11 | 12 | # set inlet velocity 13 | cp -r 0.org 0 14 | runApplication setExprBoundaryFields 15 | 16 | # decompose and run case 17 | runApplication decomposePar 18 | runParallel renumberMesh -overwrite 19 | runParallel $(getApplication) 20 | 21 | #------------------------------------------------------------------------------ 22 | -------------------------------------------------------------------------------- /tutorials/postProcessing/foamSmartSimSvd/cylinder2D/constant/transportProperties: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v1912 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | location "constant"; 14 | object transportProperties; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | transportModel Newtonian; 19 | 20 | nu 1.0e-3; 21 | 22 | 23 | // ************************************************************************* // 24 | -------------------------------------------------------------------------------- /tutorials/postProcessing/foamSmartSimSvd/cylinder2D/constant/turbulenceProperties: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v1912 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | location "constant"; 14 | object turbulenceProperties; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | simulationType laminar; 19 | 20 | 21 | // ************************************************************************* // 22 | -------------------------------------------------------------------------------- /tutorials/postProcessing/foamSmartSimSvd/cylinder2D/system/blockMeshDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v1912 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object blockMeshDict; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | lengthX 2.2; 18 | lengthY 0.41; 19 | cylinderX 0.2; 20 | cylinderY 0.2; 21 | radius 0.05; 22 | thickness 0.01; 23 | xPartOfR #eval{ sqrt(2)/2 * $radius}; 24 | blocks 50; 25 | blocks2 #eval{ round((($lengthX-$cylinderX * 2)) / ($cylinderX * 2) * $blocks)}; 26 | 27 | scale 1; 28 | 29 | vertices #codeStream 30 | { 31 | codeInclude 32 | #{ 33 | #include "pointField.H" 34 | #}; 35 | 36 | code 37 | #{ 38 | pointField points({ 39 | /* 0*/ {0, 0, 0}, 40 | /* 1*/ {$cylinderX * 2, 0, 0}, 41 | /* 2*/ {$lengthX, 0, 0}, 42 | /* 3*/ {$lengthX, $lengthY, 0}, 43 | /* 4*/ {$cylinderX * 2, $lengthY, 0}, 44 | /* 5*/ {0, $lengthY, 0}, 45 | /* 6*/ {$cylinderX - $xPartOfR, $cylinderY - $xPartOfR, 0}, 46 | /* 7*/ {$cylinderX + $xPartOfR, $cylinderY - $xPartOfR, 0}, 47 | /* 8*/ {$cylinderX - $xPartOfR, $cylinderY + $xPartOfR, 0}, 48 | /* 9*/ {$cylinderX + $xPartOfR, $cylinderY + $xPartOfR, 0} 49 | }); 50 | 51 | // Duplicate z points for thickness 52 | const label sz = points.size(); 53 | points.resize(2*sz); 54 | for (label i = 0; i < sz; ++i) 55 | { 56 | const point& pt = points[i]; 57 | points[i + sz] = point(pt.x(), pt.y(), $thickness); 58 | } 59 | 60 | os << points; 61 | #}; 62 | }; 63 | 64 | blocks 65 | ( 66 | hex (0 1 7 6 10 11 17 16) ($blocks $blocks 1) simpleGrading (1 0.5 1) 67 | hex (1 4 9 7 11 14 19 17) ($blocks $blocks 1) simpleGrading (1 0.5 1) 68 | hex (4 5 8 9 14 15 18 19) ($blocks $blocks 1) simpleGrading (1 0.5 1) 69 | hex (5 0 6 8 15 10 16 18) ($blocks $blocks 1) simpleGrading (1 0.5 1) 70 | hex (1 2 3 4 11 12 13 14) ($blocks2 $blocks 1) simpleGrading (4 1 1) 71 | ); 72 | 73 | edges 74 | ( 75 | arc 6 7 ($cylinderX #eval{$cylinderY-$radius} 0) 76 | arc 7 9 (#eval{$cylinderX+$radius} $cylinderY 0) 77 | arc 9 8 ($cylinderX #eval{$cylinderY+$radius} 0) 78 | arc 8 6 (#eval{$cylinderX-$radius} $cylinderY 0) 79 | arc 16 17 ($cylinderX #eval{$cylinderY-$radius} $thickness) 80 | arc 17 19 (#eval{$cylinderX+$radius} $cylinderY $thickness) 81 | arc 19 18 ($cylinderX #eval{$cylinderY+$radius} $thickness) 82 | arc 18 16 (#eval{$cylinderX-$radius} $cylinderY $thickness) 83 | ); 84 | 85 | boundary 86 | ( 87 | top 88 | { 89 | type patch; 90 | faces 91 | ( 92 | (4 5 15 14) 93 | (3 4 14 13) 94 | ); 95 | } 96 | bottom 97 | { 98 | type patch; 99 | faces 100 | ( 101 | (0 1 11 10) 102 | (1 2 12 11) 103 | ); 104 | } 105 | inlet 106 | { 107 | type patch; 108 | faces 109 | ( 110 | (5 0 10 15) 111 | ); 112 | } 113 | outlet 114 | { 115 | type patch; 116 | faces 117 | ( 118 | (2 3 13 12) 119 | ); 120 | } 121 | back 122 | { 123 | type empty; 124 | faces 125 | ( 126 | (0 1 7 6) 127 | (1 4 9 7) 128 | (4 5 8 9) 129 | (5 0 6 8) 130 | (1 2 3 4) 131 | ); 132 | } 133 | front 134 | { 135 | type empty; 136 | faces 137 | ( 138 | (10 11 17 16) 139 | (11 14 19 17) 140 | (14 15 18 19) 141 | (15 10 16 18) 142 | (11 12 13 14) 143 | ); 144 | } 145 | cylinder 146 | { 147 | type patch; 148 | faces 149 | ( 150 | (6 7 17 16) 151 | (7 9 19 17) 152 | (9 8 18 19) 153 | (8 6 16 18) 154 | ); 155 | } 156 | ); 157 | 158 | mergePatchPairs 159 | ( 160 | ); 161 | 162 | // ************************************************************************* // 163 | -------------------------------------------------------------------------------- /tutorials/postProcessing/foamSmartSimSvd/cylinder2D/system/controlDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v1912 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | location "system"; 14 | object controlDict; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | application pimpleFoam; 19 | 20 | startFrom startTime; 21 | 22 | startTime 0; 23 | 24 | stopAt endTime; 25 | 26 | endTime 4.0; 27 | 28 | deltaT 1.0e-3; 29 | 30 | writeControl runTime; 31 | 32 | writeInterval 0.01; 33 | 34 | purgeWrite 1; 35 | 36 | writeFormat binary; 37 | 38 | writePrecision 8; 39 | 40 | timeFormat general; 41 | 42 | timePrecision 8; 43 | 44 | runTimeModifiable false; 45 | 46 | functions 47 | { 48 | forces 49 | { 50 | type forceCoeffs; 51 | libs (forces); 52 | writeControl timeStep; 53 | writeInterval 1; 54 | log false; 55 | 56 | patches 57 | ( 58 | cylinder 59 | ); 60 | 61 | rhoInf 1; 62 | rho rhoInf; 63 | 64 | CofR (0.2 0.2 0.005); 65 | liftDir (0 1 0); 66 | dragDir (1 0 0); 67 | magUInf 1.0; 68 | lRef 0.1; 69 | Aref 0.001; 70 | } 71 | 72 | dataToSmartRedis 73 | { 74 | type fieldsToSmartRedis; 75 | libs ("libsmartredisFunctionObjects.so"); 76 | 77 | // Unique name for this function object instance 78 | name Udata; 79 | 80 | // SmartRedis client mode 81 | clusterMode off; 82 | 83 | // OpenFOAM fields to send to the database 84 | fields (U); 85 | 86 | // OpenFOAM patches to send 87 | patches (internal); 88 | 89 | // when to start sending data 90 | executeControl writeTime; 91 | executeInterval 1; 92 | writeControl writeTime; 93 | writeInterval 1; 94 | timeStart 0.0; 95 | } 96 | } 97 | 98 | // ************************************************************************* // 99 | -------------------------------------------------------------------------------- /tutorials/postProcessing/foamSmartSimSvd/cylinder2D/system/decomposeParDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v1912 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | location "system"; 14 | object decomposeParDict; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | numberOfSubdomains 4; 19 | 20 | method hierarchical; 21 | 22 | coeffs 23 | { 24 | n (4 1 1); 25 | } 26 | 27 | 28 | // ************************************************************************* // 29 | -------------------------------------------------------------------------------- /tutorials/postProcessing/foamSmartSimSvd/cylinder2D/system/fvSchemes: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v1912 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | location "system"; 14 | object fvSchemes; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | ddtSchemes 19 | { 20 | default Euler; 21 | } 22 | 23 | gradSchemes 24 | { 25 | default Gauss linear; 26 | } 27 | 28 | divSchemes 29 | { 30 | default Gauss linear; 31 | div((nuEff*dev(T(grad(U))))) Gauss linear; 32 | } 33 | 34 | laplacianSchemes 35 | { 36 | default Gauss linear corrected; 37 | } 38 | 39 | interpolationSchemes 40 | { 41 | default linear; 42 | } 43 | 44 | snGradSchemes 45 | { 46 | default corrected; 47 | } 48 | 49 | fluxRequired 50 | { 51 | default no; 52 | p ; 53 | } 54 | 55 | 56 | // ************************************************************************* // 57 | -------------------------------------------------------------------------------- /tutorials/postProcessing/foamSmartSimSvd/cylinder2D/system/fvSolution: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v1912 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | location "system"; 14 | object fvSolution; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | solvers 19 | { 20 | p 21 | { 22 | solver GAMG; 23 | smoother nonBlockingGaussSeidel; 24 | tolerance 1e-6; 25 | relTol 0.01; 26 | } 27 | 28 | pFinal 29 | { 30 | $p; 31 | relTol 0; 32 | } 33 | 34 | U 35 | { 36 | solver smoothSolver; 37 | smoother symGaussSeidel; 38 | tolerance 1e-05; 39 | relTol 0.1; 40 | } 41 | 42 | UFinal 43 | { 44 | $U; 45 | relTol 0; 46 | } 47 | } 48 | 49 | PIMPLE 50 | { 51 | momentumPredictor yes; 52 | transonic no; 53 | nOuterCorrectors 50; 54 | nCorrectors 1; 55 | nNonOrthogonalCorrectors 1; 56 | consistent yes; 57 | 58 | residualControl 59 | { 60 | "(U|p)" 61 | { 62 | relTol 0; 63 | tolerance 0.0001; 64 | } 65 | } 66 | } 67 | 68 | 69 | // ************************************************************************* // 70 | -------------------------------------------------------------------------------- /tutorials/postProcessing/foamSmartSimSvd/cylinder2D/system/setExprBoundaryFieldsDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v2006 | 5 | | \\ / A nd | Website: www.openfoam.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object setExprBoundaryFieldsDict; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | U_inlet 18 | { 19 | field U; 20 | 21 | expressions 22 | ( 23 | { 24 | patch inlet; 25 | target value; 26 | // Um 1.5; - maximum velocity at the center of the channel 27 | // H 0.41; - channel height 28 | vel { dir (1 0 0); } 29 | expression #{ 4*1.5*pos().y()*(0.41-pos().y())/(0.41*0.41)*$[(vector)vel.dir] #}; 30 | } 31 | ); 32 | } 33 | 34 | // ************************************************************************* // 35 | 36 | -------------------------------------------------------------------------------- /tutorials/postProcessing/foamSmartSimSvd/foam-smartsim-svd-db-api.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "id": "92a3898a-9fed-41eb-9463-2c9d559f8c0c", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "from smartsim import Experiment\n", 11 | "from smartredis import Client\n", 12 | "import torch\n", 13 | "import torch.nn as nn\n", 14 | "from sklearn.preprocessing import MinMaxScaler\n", 15 | "from sklearn.model_selection import train_test_split\n", 16 | "import torch.optim as optim\n", 17 | "from sklearn.metrics import mean_squared_error\n", 18 | "import numpy as np\n", 19 | "from matplotlib import pyplot as plt\n", 20 | "\n", 21 | "import io, os, jinja2\n", 22 | "\n", 23 | "env = jinja2.Environment()\n", 24 | "def get_field_name(fn_name, field_name, processor=0, timestep=None):\n", 25 | " \"\"\"\n", 26 | " Get the name of the field from the database. This function uses\n", 27 | " a metadata dataset posted by the function object itself to determine\n", 28 | " how things are named through Jinja2 templates\n", 29 | "\n", 30 | " Args:\n", 31 | " fn_name (str): The name of the submitting entity, the database name in this case\n", 32 | " field_name (str): The name of the OpenFOAM field\n", 33 | " processor (int): The MPI rank\n", 34 | " timestep (int): The target timestep index\n", 35 | " \"\"\"\n", 36 | " client.poll_dataset(fn_name+\"_metadata\", 10, 1000)\n", 37 | " meta = client.get_dataset(fn_name+\"_metadata\")\n", 38 | " ds_naming = env.from_string(str(meta.get_meta_strings(\"dataset\")[0]))\n", 39 | " ds_name = ds_naming.render(time_index=timestep, mpi_rank=processor)\n", 40 | " f_naming = env.from_string(str(meta.get_meta_strings(\"field\")[0]))\n", 41 | " f_name = f_naming.render(name=field_name, patch=\"internal\")\n", 42 | " return f\"{{{ds_name}}}.{f_name}\"\n", 43 | "\n", 44 | "\n", 45 | "# Set up the execution of the foamSmartSimMapField application \n", 46 | "# as a SmartSim Experiment. \n", 47 | "exp = Experiment(\"foam-smartsim-svd\", launcher=\"local\")\n", 48 | "\n", 49 | "db = exp.create_database(port=8000, # database port\n", 50 | " interface=\"lo\") # network interface to use\n", 51 | "exp.start(db)\n", 52 | "\n", 53 | "# Connect the python client to the smartredis database\n", 54 | "client = Client(address=db.get_address()[0], cluster=False)\n", 55 | "\n", 56 | "run_settings_prepare = exp.create_run_settings(exe=f\"{os.getcwd()}/cavity/Allrun\")\n", 57 | "openfoam_prepare_model = exp.create_model(name=\"prepare\", run_settings=run_settings_prepare)\n", 58 | "\n", 59 | "# MPI parallel run settings for foamSmartSimSvD\n", 60 | "num_mpi_ranks = 4\n", 61 | "run_settings_parallel = exp.create_run_settings(exe=\"foamSmartSimSvdDBAPI\", \n", 62 | " exe_args=\"-case cavity -fieldName p -parallel\", \n", 63 | " run_command=\"mpirun\", \n", 64 | " run_args={\"np\": f\"{num_mpi_ranks}\"})\n", 65 | "\n", 66 | "openfoam_svd_model = exp.create_model(name=\"foamSmartSimSvdDBAPI\", run_settings=run_settings_parallel)\n", 67 | "\n", 68 | "try:\n", 69 | " torch.set_default_dtype(torch.float64)\n", 70 | "\n", 71 | " exp.start(openfoam_prepare_model, block=True)\n", 72 | " # Run foamSmartSimSvd and do not block.\n", 73 | " exp.start(openfoam_svd_model, block=True)\n", 74 | "\n", 75 | " # Perform SVD for each MPI rank in SmartRedis - this should be distributed.\n", 76 | " nTimes = int(client.get_dataset(\"foamSmartSimSvdDBAPI_metadata\").get_meta_strings(\"NTimes\")[0])\n", 77 | " for proc in range(4):\n", 78 | " for i in range(nTimes):\n", 79 | " field_name = get_field_name(\"foamSmartSimSvdDBAPI\", \"p\", processor=proc, timestep=i)\n", 80 | " print(f\"{field_name}: {client.get_tensor(field_name).size}\")\n", 81 | "except Exception as e:\n", 82 | " print(\"Caught an exception: \", str(e))\n", 83 | " \n", 84 | "finally:\n", 85 | " exp.stop(db)" 86 | ] 87 | } 88 | ], 89 | "metadata": { 90 | "kernelspec": { 91 | "display_name": "Python 3 (ipykernel)", 92 | "language": "python", 93 | "name": "python3" 94 | }, 95 | "language_info": { 96 | "codemirror_mode": { 97 | "name": "ipython", 98 | "version": 3 99 | }, 100 | "file_extension": ".py", 101 | "mimetype": "text/x-python", 102 | "name": "python", 103 | "nbconvert_exporter": "python", 104 | "pygments_lexer": "ipython3", 105 | "version": "3.8.10" 106 | } 107 | }, 108 | "nbformat": 4, 109 | "nbformat_minor": 5 110 | } 111 | -------------------------------------------------------------------------------- /tutorials/postProcessing/foamSmartSimSvd/partial_svd.py: -------------------------------------------------------------------------------- 1 | """Assemble partial data matrix and compute SVD. 2 | """ 3 | 4 | import numpy as np 5 | from smartredis import Client 6 | 7 | # setting coming from driver program 8 | mpi_rank = ;mpi_rank; 9 | 10 | # settings to fetch data from database 11 | time_indices = list(range(10, 4001, 10)) 12 | fo_name = "dataToSmartRedis" 13 | field_name = "U" 14 | 15 | # connect to database 16 | client = Client(cluster=False) 17 | 18 | # assemble partial data matrix 19 | def fetch_snapshot(time_index): 20 | dataset_name = f"{fo_name}_time_index_{time_index}_mpi_rank_{mpi_rank}" 21 | if client.dataset_exists(dataset_name): 22 | dataset = client.get_dataset(dataset_name) 23 | return dataset.get_tensor(f"field_name_{field_name}_patch_internal").flatten() 24 | else: 25 | return None 26 | 27 | data_matrix = np.vstack([fetch_snapshot(ti) for ti in time_indices]).T 28 | 29 | # compute and store the partial SVD 30 | U, s, VT = np.linalg.svd(data_matrix, full_matrices=False) 31 | client.put_tensor(f"partSVD_U_mpi_rank_{mpi_rank}", U) 32 | client.put_tensor(f"partSVD_VT_mpi_rank_{mpi_rank}", VT) 33 | client.put_tensor(f"partSVD_s_mpi_rank_{mpi_rank}", s) 34 | 35 | -------------------------------------------------------------------------------- /tutorials/postProcessing/foamSmartSimSvd/reconstruction.py: -------------------------------------------------------------------------------- 1 | """Assemble global left singular vectors and compute reconstruction. 2 | """ 3 | 4 | import numpy as np 5 | from smartredis import Client, Dataset 6 | 7 | # setting coming from driver program 8 | mpi_rank = ;mpi_rank; 9 | svd_rank = ;svd_rank; 10 | 11 | # settings to fetch data from database 12 | time_indices = list(range(10, 4001, 10)) 13 | field_name = "U" 14 | 15 | # connect to database 16 | client = Client(cluster=False) 17 | 18 | # compute global left singular vectors 19 | Ui = client.get_tensor(f"svd_ensemble_{mpi_rank}.partSVD_U_mpi_rank_{mpi_rank}") 20 | Uy = client.get_tensor(f"partSVD_Uy") 21 | n_times = Ui.shape[1] 22 | U = (Ui @ Uy[mpi_rank*n_times:(mpi_rank+1)*n_times])[:, :svd_rank] 23 | 24 | # optional: delete Ui from the database to save space 25 | client.delete_tensor(f"svd_ensemble_{mpi_rank}.partSVD_U_mpi_rank_{mpi_rank}") 26 | 27 | # compute and save rank-r reconstruction 28 | s = client.get_tensor(f"partSVD_sy")[:svd_rank] 29 | VT = client.get_tensor(f"partSVD_VTy")[:svd_rank] 30 | rec = U @ np.diag(s) @ VT 31 | 32 | n_points = rec.shape[0] // 3 33 | for i, ti in enumerate(time_indices): 34 | name = f"rank_{svd_rank}_field_name_{field_name}_mpi_rank_{mpi_rank}_time_index_{ti}" 35 | client.put_tensor(name, np.copy(rec[:, i].reshape((n_points, 3)))) 36 | 37 | # optional: save global U into database for visualization 38 | for i in range(svd_rank): 39 | name = f"global_U_mpi_rank_{mpi_rank}_mode_{i}" 40 | client.put_tensor(name, np.copy(U[:, i].reshape((n_points, 3)))) 41 | 42 | 43 | --------------------------------------------------------------------------------