├── processing └── processings.txt ├── Supplementary Materials ├── Supplementary Material 1.pdf └── Supplementary Material 2.pdf ├── sample_openfoam ├── 0 │ ├── p │ └── U ├── 1 │ └── uniform │ │ ├── functionObjects │ │ └── functionObjectProperties │ │ └── time ├── constant │ ├── polyMesh │ │ ├── cellZones │ │ ├── faceZones │ │ ├── pointZones │ │ └── boundary │ ├── turbulenceProperties │ ├── g │ └── transportProperties ├── 0.1 │ └── uniform │ │ ├── functionObjects │ │ └── functionObjectProperties │ │ └── time ├── 0.5 │ └── uniform │ │ ├── functionObjects │ │ └── functionObjectProperties │ │ └── time └── system │ ├── decomposeParDict │ ├── controlDict │ ├── fvSchemes │ └── fvSolution ├── LICENSE ├── README.md ├── .gitignore ├── data_processing_main.py ├── paraview_state_M1.py └── paraview_state_M2.py /processing/processings.txt: -------------------------------------------------------------------------------- 1 | # sample directory -------------------------------------------------------------------------------- /Supplementary Materials/Supplementary Material 1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sersolmaz/CFD_AR_VR/HEAD/Supplementary Materials/Supplementary Material 1.pdf -------------------------------------------------------------------------------- /Supplementary Materials/Supplementary Material 2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sersolmaz/CFD_AR_VR/HEAD/Supplementary Materials/Supplementary Material 2.pdf -------------------------------------------------------------------------------- /sample_openfoam/constant/polyMesh/cellZones: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v1612+ | 5 | | \\ / A nd | Web: www.OpenFOAM.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class regIOobject; 13 | location "constant/polyMesh"; 14 | object cellZones; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | 0 19 | () 20 | 21 | // ************************************************************************* // 22 | -------------------------------------------------------------------------------- /sample_openfoam/constant/polyMesh/faceZones: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v1612+ | 5 | | \\ / A nd | Web: www.OpenFOAM.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class regIOobject; 13 | location "constant/polyMesh"; 14 | object faceZones; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | 0 19 | () 20 | 21 | // ************************************************************************* // 22 | -------------------------------------------------------------------------------- /sample_openfoam/constant/polyMesh/pointZones: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v1612+ | 5 | | \\ / A nd | Web: www.OpenFOAM.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class regIOobject; 13 | location "constant/polyMesh"; 14 | object pointZones; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | 0 19 | () 20 | 21 | // ************************************************************************* // 22 | -------------------------------------------------------------------------------- /sample_openfoam/constant/turbulenceProperties: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: plus | 5 | | \\ / A nd | Web: 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 | -------------------------------------------------------------------------------- /sample_openfoam/1/uniform/functionObjects/functionObjectProperties: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v1612+ | 5 | | \\ / A nd | Web: www.OpenFOAM.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | location "1/uniform/functionObjects"; 14 | object functionObjectProperties; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | 19 | 20 | // ************************************************************************* // 21 | -------------------------------------------------------------------------------- /sample_openfoam/0.1/uniform/functionObjects/functionObjectProperties: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v1612+ | 5 | | \\ / A nd | Web: www.OpenFOAM.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | location "0.1/uniform/functionObjects"; 14 | object functionObjectProperties; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | 19 | 20 | // ************************************************************************* // 21 | -------------------------------------------------------------------------------- /sample_openfoam/0.5/uniform/functionObjects/functionObjectProperties: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v1612+ | 5 | | \\ / A nd | Web: www.OpenFOAM.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | location "0.5/uniform/functionObjects"; 14 | object functionObjectProperties; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | 19 | 20 | // ************************************************************************* // 21 | -------------------------------------------------------------------------------- /sample_openfoam/constant/g: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: plus | 5 | | \\ / A nd | Web: www.OpenFOAM.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class uniformDimensionedVectorField; 13 | location "constant"; 14 | object g; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | dimensions [0 1 -2 0 0 0 0]; 19 | value (0 0 0); 20 | 21 | 22 | // ************************************************************************* // 23 | -------------------------------------------------------------------------------- /sample_openfoam/constant/transportProperties: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: plus | 5 | | \\ / A nd | Web: 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 | nu [0 2 -1 0 0 0 0] 1e-06; 19 | rho [1 -3 0 0 0 0 0] 1000; 20 | 21 | 22 | // ************************************************************************* // 23 | -------------------------------------------------------------------------------- /sample_openfoam/1/uniform/time: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v1612+ | 5 | | \\ / A nd | Web: www.OpenFOAM.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | location "1/uniform"; 14 | object time; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | value 0.999999999999950484; 19 | 20 | name "1"; 21 | 22 | index 10000; 23 | 24 | deltaT 0.0001; 25 | 26 | deltaT0 0.0001; 27 | 28 | 29 | // ************************************************************************* // 30 | -------------------------------------------------------------------------------- /sample_openfoam/0.1/uniform/time: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v1612+ | 5 | | \\ / A nd | Web: www.OpenFOAM.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | location "0.1/uniform"; 14 | object time; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | value 0.100000000000001837; 19 | 20 | name "0.1"; 21 | 22 | index 1000; 23 | 24 | deltaT 0.0001; 25 | 26 | deltaT0 0.0001; 27 | 28 | 29 | // ************************************************************************* // 30 | -------------------------------------------------------------------------------- /sample_openfoam/0.5/uniform/time: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v1612+ | 5 | | \\ / A nd | Web: www.OpenFOAM.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | location "0.5/uniform"; 14 | object time; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | value 0.499999999999961253; 19 | 20 | name "0.5"; 21 | 22 | index 5000; 23 | 24 | deltaT 0.0001; 25 | 26 | deltaT0 0.0001; 27 | 28 | 29 | // ************************************************************************* // 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Serkan Solmaz 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /sample_openfoam/0/p: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: plus | 5 | | \\ / A nd | Web: 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 | walls 35 | { 36 | type zeroGradient; 37 | } 38 | 39 | frontAndBack 40 | { 41 | type empty; 42 | } 43 | } 44 | 45 | // ************************************************************************* // 46 | -------------------------------------------------------------------------------- /sample_openfoam/system/decomposeParDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: plus | 5 | | \\ / A nd | Web: 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 simple; 21 | 22 | simpleCoeffs 23 | { 24 | n (2 2 1); 25 | delta 0.001; 26 | } 27 | 28 | hierarchicalCoeffs 29 | { 30 | n (1 1 1); 31 | delta 0.001; 32 | order xyz; 33 | } 34 | 35 | manualCoeffs 36 | { 37 | dataFile ""; 38 | } 39 | 40 | distributed no; 41 | 42 | roots ( ); 43 | 44 | 45 | // ************************************************************************* // 46 | -------------------------------------------------------------------------------- /sample_openfoam/system/controlDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: plus | 5 | | \\ / A nd | Web: 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 icoFoam; 19 | 20 | startFrom startTime; 21 | 22 | startTime 1; 23 | 24 | stopAt endTime; 25 | 26 | endTime 3; 27 | 28 | deltaT 0.0001; 29 | 30 | writeControl timeStep; 31 | 32 | writeInterval 500; 33 | 34 | purgeWrite 0; 35 | 36 | writeFormat ascii; 37 | 38 | writePrecision 6; 39 | 40 | writeCompression off; 41 | 42 | timeFormat general; 43 | 44 | timePrecision 6; 45 | 46 | runTimeModifiable true; 47 | 48 | 49 | // ************************************************************************* // 50 | -------------------------------------------------------------------------------- /sample_openfoam/system/fvSchemes: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: plus | 5 | | \\ / A nd | Web: 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 | grad(p) Gauss linear; 27 | } 28 | 29 | divSchemes 30 | { 31 | default none; 32 | div(phi,U) Gauss linear; 33 | } 34 | 35 | laplacianSchemes 36 | { 37 | default Gauss linear orthogonal; 38 | } 39 | 40 | interpolationSchemes 41 | { 42 | default linear; 43 | } 44 | 45 | snGradSchemes 46 | { 47 | default orthogonal; 48 | } 49 | 50 | 51 | // ************************************************************************* // 52 | -------------------------------------------------------------------------------- /sample_openfoam/0/U: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: plus | 5 | | \\ / A nd | Web: www.OpenFOAM.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volVectorField; 13 | location "0"; 14 | object U; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | dimensions [0 1 -1 0 0 0 0]; 19 | 20 | internalField uniform (0.5 0 0); 21 | 22 | boundaryField 23 | { 24 | inlet 25 | { 26 | type fixedValue; 27 | value uniform (0.5 0 0); 28 | } 29 | 30 | outlet 31 | { 32 | type pressureInletOutletVelocity; 33 | value $internalField; 34 | } 35 | 36 | walls 37 | { 38 | type fixedValue; 39 | value uniform (0 0 0); 40 | } 41 | 42 | frontAndBack 43 | { 44 | type empty; 45 | } 46 | } 47 | 48 | // ************************************************************************* // 49 | -------------------------------------------------------------------------------- /sample_openfoam/system/fvSolution: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: plus | 5 | | \\ / A nd | Web: 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 PCG; 23 | preconditioner DIC; 24 | tolerance 1e-06; 25 | relTol 0.05; 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; 40 | } 41 | } 42 | 43 | PISO 44 | { 45 | nCorrectors 2; 46 | nNonOrthogonalCorrectors 0; 47 | pRefCell 0; 48 | pRefValue 0; 49 | } 50 | 51 | 52 | // ************************************************************************* // 53 | -------------------------------------------------------------------------------- /sample_openfoam/constant/polyMesh/boundary: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: v1612+ | 5 | | \\ / A nd | Web: www.OpenFOAM.com | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class polyBoundaryMesh; 13 | location "constant/polyMesh"; 14 | object boundary; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | 4 19 | ( 20 | inlet 21 | { 22 | type patch; 23 | nFaces 117; 24 | startFace 225094; 25 | } 26 | outlet 27 | { 28 | type patch; 29 | nFaces 226; 30 | startFace 225211; 31 | } 32 | walls 33 | { 34 | type wall; 35 | inGroups 1(wall); 36 | nFaces 1545; 37 | startFace 225437; 38 | } 39 | frontAndBackPlanes 40 | { 41 | type empty; 42 | inGroups 1(empty); 43 | nFaces 226050; 44 | startFace 226982; 45 | } 46 | ) 47 | 48 | // ************************************************************************* // 49 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CFD with AR/VR 2 | **Multiplatform processing of CFD simulations with AR/VR** 3 | 4 | 5 | ---------------- 6 | **UPDATE (02.08.2023): [CFD_AR_VR](https://github.com/sersolmaz/CFD_AR_VR/tree/master) is an exploratory tool to examine different data processing pipelines between CFD solvers and game engines. It fundamentally focuses on data formats, processing performance and interoperability. Based on this preliminary work, a toolkit is developed and now available providing robust modules to integrate CFD data into game engines at [Acrossim](https://github.com/sersolmaz/Acrossim).** 7 | ---------------- 8 | 9 | 10 | The provided code processes steady-state and transient CFD simulation data from multiple solvers (e.g. OpenFOAM, Ansys Fluent and COMSOL) to integrate extract-based CFD results in cross-platform development environments such as game engines. It creates a bridge among multiple platforms to enable one-way coupled data processing between CFD dataset and game engine. It is written in Python using ParaView and Blender APIs. The main script comprises the following part in sequence: 11 | - Post- and data processing of CFD dataset with ParaView 12 | - Data processing with Blender 13 | - Data import & update in Unity game engine 14 | - Data processing performance for assessment 15 | 16 | The goal herewith is to provide a simple, modular, easy-to-implement and free-to-use data processor to utilize CFD results in AR/VR environments. The code provides samples of existing CFD datasets from OpenFOAM (state M1) and COMSOL (state M2). Minor customizations might be required. 17 | 18 | ## Prerequisites and execution 19 | 20 | To execute the code, an Anaconda application with Spyder must be compiled with ParaView and Blender packages. 21 | 22 | Input(s): 23 | - CFD dataset either in native format (OpenFOAM) or extracts (COMSOL) 24 | - Python state of the post-processing 25 | - Number of timesteps 26 | - Input and output directories 27 | 28 | Output(s): 29 | - Visual representations of CFD results 30 | - Supporting multimedia files; colormap and graphs (image, video, etc.) 31 | - Analytic data 32 | - Data processing performance 33 | 34 | ## License 35 | Please see the file ./LICENSE for details. 36 | 37 | ## Contact 38 | Serkan Solmaz (https://www.kuleuven.be/wieiswie/en/person/00127798) 39 | * Department of Chemical Engineering, KU Leuven, Celestijnenlaan 200F, B-3001 Leuven, Belgium 40 | 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /data_processing_main.py: -------------------------------------------------------------------------------- 1 | import os 2 | import subprocess 3 | from paraview.simple import * 4 | import bpy 5 | import timeit 6 | import shutil 7 | 8 | 9 | 10 | """Processing in ParaView via state file""" 11 | # timer for data processing performance 12 | start1 = timeit.default_timer() 13 | 14 | # import user-defined paraview_state 15 | # M1 for data processing from native CFD files (OpenFOAM, Ansys Fluent) 16 | # M2 for data processing from extracts (COMSOL) 17 | exec(open('paraview_state_M1.py').read()) 18 | renderView1.Update() 19 | stop1 = timeit.default_timer() 20 | """Processing in ParaView via state file""" 21 | 22 | 23 | 24 | """Data processing: ParaView and Blender""" 25 | start2 = timeit.default_timer() 26 | # export data format ParaView 27 | export_format_paraview = '.x3d' 28 | # directory to save export of ParaView (example) 29 | path_paraview='C:/Users/Desktop/processing/' 30 | # import data format Blender 31 | import_format_blender = '.x3d' 32 | # export data format Blender 33 | export_format_blender = '.fbx' 34 | # directory to save export of Blender (example) 35 | path_blender='C:/Users/Desktop/processing/' 36 | # define total number of timesteps 37 | timestep_sim = 2; 38 | for x in range(0, timestep_sim): 39 | # paraview supporting data export 40 | ExportView(path_paraview + str(x) + export_format_paraview, view=renderView1, ExportColorLegends=1) 41 | SaveData(path_paraview + str(x) + '.csv') 42 | SaveScreenshot(path_paraview + str(x) + '.png', renderView1, ImageResolution=[1025, 782]) 43 | animationScene1 = GetAnimationScene() 44 | animationScene1.GoToNext() 45 | # blender starts metadata import & export 46 | path_to_obj_dir = os.path.join(path_blender) 47 | # get list of all files in directory 48 | file_list = sorted(os.listdir(path_to_obj_dir)) 49 | # get a list of files 50 | obj_list = [item for item in file_list if item.endswith(import_format_blender)] 51 | # loop through the strings in obj_list and add the files to the scene 52 | for item in obj_list: 53 | path_to_file = os.path.join(path_to_obj_dir, item) 54 | bpy.ops.import_scene.x3d(filepath = path_to_file) 55 | # get the current path and make a new folder for the exported meshes 56 | path_blender = bpy.path.abspath(path_blender) 57 | for object in bpy.context.selected_objects: 58 | # deselect all meshes 59 | bpy.ops.object.select_all(action='DESELECT') 60 | # select the object 61 | object.select = True 62 | # export object with its name as file name 63 | bpy.ops.export_scene.fbx(filepath=path_blender + object.name + export_format_blender,use_selection=True,) 64 | stop2 = timeit.default_timer() 65 | """Data processing: ParaView and Blender""" 66 | 67 | 68 | 69 | """Unity""" 70 | # Deactivate this -Unity- part if files transferred manually. 71 | start3 = timeit.default_timer() 72 | 73 | # asset directory of the Unity project 74 | path_unity='C:/Users/Documents/Unityproject/Assets/CFD' 75 | 76 | # update the Unity project directory with 77 | shutil.copytree(path_blender, path_unity) 78 | 79 | # execture the Unity game engine 80 | path_to_gameengine= 'C:/Program Files/Unity/Hub/Editor/2019.1.0f2/Editor/Unity.exe' 81 | subprocess.call([path_to_gameengine]) 82 | stop3 = timeit.default_timer() 83 | """Unity""" 84 | 85 | 86 | 87 | """Data processing performance""" 88 | b_x3d = os.path.getsize(path_blender + '0.x3d') 89 | print('*****Data processing performance*****') 90 | print('Time_ParaView: ', stop1 - start1) 91 | print('X3D file size in bytes:',b_x3d) 92 | print('Time_ParaView_Blender: ', stop2 - start2) 93 | path_to_obj_dir = os.path.join(path_blender) 94 | file_list = sorted(os.listdir(path_to_obj_dir)) 95 | obj_list = [item for item in file_list if item.endswith('.fbx')] 96 | size_file_blender = [] 97 | for item in obj_list: 98 | path_to_file = os.path.join(path_to_obj_dir, item) 99 | size_processing_blender=os.path.getsize(path_to_file) 100 | print('FBX file sizes in bytes:',size_processing_blender) 101 | size_file_blender.append(size_processing_blender) 102 | #print("The maximum is {:.1f}".format(max(size_file_blender))) 103 | print('Time_Unity (sec): ', stop3 - start3) 104 | print('Time_Integration (sec): ', stop3 - start3 + stop2 - start2 + stop1 - start1) 105 | print('Data size compression ratio X3D/FBX:', b_x3d/max(size_file_blender)) 106 | """END""" -------------------------------------------------------------------------------- /paraview_state_M1.py: -------------------------------------------------------------------------------- 1 | """M1 for data processing from native CFD files (OpenFOAM, Ansys Fluent)""" 2 | # an example of post-processing state file from ParaView 3 | 4 | # trace generated using paraview version 5.8.0 5 | # 6 | # To ensure correct image size when batch processing, please search 7 | # for and uncomment the line `# renderView*.ViewSize = [*,*]` 8 | 9 | #### import the simple module from the paraview 10 | from paraview.simple import * 11 | #### disable automatic camera reset on 'Show' 12 | paraview.simple._DisableFirstRenderCameraReset() 13 | 14 | # create a new 'OpenFOAMReader' 15 | davincifoam = OpenFOAMReader(FileName='D:\\Engineering\\PhD\\Charming\\Charming_Prototypes_AR\\davinci\\davinci\\davinci.foam') 16 | davincifoam.MeshRegions = ['internalMesh'] 17 | davincifoam.CellArrays = ['U', 'p'] 18 | 19 | # get animation scene 20 | animationScene1 = GetAnimationScene() 21 | 22 | # get the time-keeper 23 | timeKeeper1 = GetTimeKeeper() 24 | 25 | # update animation scene based on data timesteps 26 | animationScene1.UpdateAnimationUsingDataTimeSteps() 27 | 28 | # get active view 29 | renderView1 = GetActiveViewOrCreate('RenderView') 30 | # uncomment following to set a specific view size 31 | # renderView1.ViewSize = [972, 755] 32 | 33 | # get layout 34 | layout1 = GetLayout() 35 | 36 | # show data in view 37 | davincifoamDisplay = Show(davincifoam, renderView1, 'UnstructuredGridRepresentation') 38 | 39 | # get color transfer function/color map for 'p' 40 | pLUT = GetColorTransferFunction('p') 41 | pLUT.RGBPoints = [-0.5069754719734192, 0.231373, 0.298039, 0.752941, -0.21636215969920158, 0.865003, 0.865003, 0.865003, 0.07425115257501602, 0.705882, 0.0156863, 0.14902] 42 | pLUT.ScalarRangeInitialized = 1.0 43 | 44 | # get opacity transfer function/opacity map for 'p' 45 | pPWF = GetOpacityTransferFunction('p') 46 | pPWF.Points = [-0.5069754719734192, 0.0, 0.5, 0.0, 0.07425115257501602, 1.0, 0.5, 0.0] 47 | pPWF.ScalarRangeInitialized = 1 48 | 49 | # trace defaults for the display properties. 50 | davincifoamDisplay.Representation = 'Surface' 51 | davincifoamDisplay.ColorArrayName = ['POINTS', 'p'] 52 | davincifoamDisplay.LookupTable = pLUT 53 | davincifoamDisplay.OSPRayScaleArray = 'p' 54 | davincifoamDisplay.OSPRayScaleFunction = 'PiecewiseFunction' 55 | davincifoamDisplay.SelectOrientationVectors = 'U' 56 | davincifoamDisplay.ScaleFactor = 0.0620999988168478 57 | davincifoamDisplay.SelectScaleArray = 'p' 58 | davincifoamDisplay.GlyphType = 'Arrow' 59 | davincifoamDisplay.GlyphTableIndexArray = 'p' 60 | davincifoamDisplay.GaussianRadius = 0.0031049999408423903 61 | davincifoamDisplay.SetScaleArray = ['POINTS', 'p'] 62 | davincifoamDisplay.ScaleTransferFunction = 'PiecewiseFunction' 63 | davincifoamDisplay.OpacityArray = ['POINTS', 'p'] 64 | davincifoamDisplay.OpacityTransferFunction = 'PiecewiseFunction' 65 | davincifoamDisplay.DataAxesGrid = 'GridAxesRepresentation' 66 | davincifoamDisplay.PolarAxes = 'PolarAxesRepresentation' 67 | davincifoamDisplay.ScalarOpacityFunction = pPWF 68 | davincifoamDisplay.ScalarOpacityUnitDistance = 0.013615136748910905 69 | davincifoamDisplay.ExtractedBlockIndex = 1 70 | 71 | # init the 'PiecewiseFunction' selected for 'OSPRayScaleFunction' 72 | davincifoamDisplay.OSPRayScaleFunction.Points = [0.008018268893823101, 0.0, 0.5, 0.0, 2.3, 1.0, 0.5, 0.0] 73 | 74 | # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' 75 | davincifoamDisplay.ScaleTransferFunction.Points = [-0.5069754719734192, 0.0, 0.5, 0.0, 0.07425115257501602, 1.0, 0.5, 0.0] 76 | 77 | # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' 78 | davincifoamDisplay.OpacityTransferFunction.Points = [-0.5069754719734192, 0.0, 0.5, 0.0, 0.07425115257501602, 1.0, 0.5, 0.0] 79 | 80 | # reset view to fit data 81 | renderView1.ResetCamera() 82 | 83 | # get the material library 84 | materialLibrary1 = GetMaterialLibrary() 85 | 86 | # show color bar/color legend 87 | davincifoamDisplay.SetScalarBarVisibility(renderView1, True) 88 | 89 | # update the view to ensure updated data information 90 | renderView1.Update() 91 | 92 | # Properties modified on animationScene1 93 | animationScene1.AnimationTime = 1.5 94 | 95 | # Properties modified on timeKeeper1 96 | timeKeeper1.Time = 1.5 97 | 98 | # set scalar coloring 99 | ColorBy(davincifoamDisplay, ('POINTS', 'U', 'Magnitude')) 100 | 101 | # Hide the scalar bar for this color map if no visible data is colored by it. 102 | HideScalarBarIfNotNeeded(pLUT, renderView1) 103 | 104 | # rescale color and/or opacity maps used to include current data range 105 | davincifoamDisplay.RescaleTransferFunctionToDataRange(True, False) 106 | 107 | # show color bar/color legend 108 | davincifoamDisplay.SetScalarBarVisibility(renderView1, True) 109 | 110 | # get color transfer function/color map for 'U' 111 | uLUT = GetColorTransferFunction('U') 112 | uLUT.RGBPoints = [0.0, 0.231373, 0.298039, 0.752941, 0.6065344050780321, 0.865003, 0.865003, 0.865003, 1.2130688101560643, 0.705882, 0.0156863, 0.14902] 113 | uLUT.ScalarRangeInitialized = 1.0 114 | 115 | # get opacity transfer function/opacity map for 'U' 116 | uPWF = GetOpacityTransferFunction('U') 117 | uPWF.Points = [0.0, 0.0, 0.5, 0.0, 1.2130688101560643, 1.0, 0.5, 0.0] 118 | uPWF.ScalarRangeInitialized = 1 119 | 120 | #### saving camera placements for all active views 121 | 122 | # current camera placement for renderView1 123 | renderView1.CameraPosition = [0.27849999256432056, -0.110999999451451, 1.2717076584814735] 124 | renderView1.CameraFocalPoint = [0.27849999256432056, -0.110999999451451, 0.0] 125 | renderView1.CameraParallelScale = 0.32914216181773753 126 | 127 | #### uncomment the following to render all views 128 | # RenderAllViews() 129 | # alternatively, if you want to write images, you can use SaveScreenshot(...). -------------------------------------------------------------------------------- /paraview_state_M2.py: -------------------------------------------------------------------------------- 1 | """M2 for data processing from extracts (COMSOL)""" 2 | # an example of post-processing state file from ParaView 3 | 4 | # state file generated using paraview version 5.8.0 5 | 6 | # ---------------------------------------------------------------- 7 | # setup views used in the visualization 8 | # ---------------------------------------------------------------- 9 | 10 | # trace generated using paraview version 5.8.0 11 | # 12 | # To ensure correct image size when batch processing, please search 13 | # for and uncomment the line `# renderView*.ViewSize = [*,*]` 14 | 15 | #### import the simple module from the paraview 16 | from paraview.simple import * 17 | #### disable automatic camera reset on 'Show' 18 | paraview.simple._DisableFirstRenderCameraReset() 19 | 20 | # get the material library 21 | materialLibrary1 = GetMaterialLibrary() 22 | 23 | # Create a new 'Render View' 24 | renderView1 = CreateView('RenderView') 25 | renderView1.ViewSize = [972, 755] 26 | renderView1.InteractionMode = '2D' 27 | renderView1.AxesGrid = 'GridAxes3DActor' 28 | renderView1.StereoType = 'Crystal Eyes' 29 | renderView1.CameraPosition = [0.0, 0.0, 10000.0] 30 | renderView1.CameraFocalDisk = 1.0 31 | renderView1.CameraParallelScale = 0.7071057629520495 32 | renderView1.BackEnd = 'OSPRay raycaster' 33 | renderView1.OSPRayMaterialLibrary = materialLibrary1 34 | 35 | SetActiveView(None) 36 | 37 | # ---------------------------------------------------------------- 38 | # setup view layouts 39 | # ---------------------------------------------------------------- 40 | 41 | # create new layout object 'Layout #1' 42 | layout1 = CreateLayout(name='Layout #1') 43 | layout1.AssignView(0, renderView1) 44 | 45 | # ---------------------------------------------------------------- 46 | # restore active view 47 | SetActiveView(renderView1) 48 | # ---------------------------------------------------------------- 49 | 50 | # ---------------------------------------------------------------- 51 | # setup the data processing pipelines 52 | # ---------------------------------------------------------------- 53 | 54 | # create a new 'XML Unstructured Grid Reader' 55 | velocityc51vtu = XMLUnstructuredGridReader(FileName="""'D:\\Engineering\\PhD\\Charming\\Publishing\\1_MANUSCRIPT_framework\\A_Manuscript\\5_revision_3\ 56 | ew_submit\\A_submission\\Supporting_information\\sample_comsol_v.vtu'""") 57 | velocityc51vtu.PointArrayStatus = ['IsoLevel'] 58 | 59 | # ---------------------------------------------------------------- 60 | # setup the visualization in view 'renderView1' 61 | # ---------------------------------------------------------------- 62 | 63 | # show data from velocityc51vtu 64 | velocityc51vtuDisplay = Show(velocityc51vtu, renderView1, 'UnstructuredGridRepresentation') 65 | 66 | # get color transfer function/color map for 'IsoLevel' 67 | isoLevelLUT = GetColorTransferFunction('IsoLevel') 68 | isoLevelLUT.RGBPoints = [2.5612799973882074e-05, 0.231373, 0.298039, 0.752941, 1.04736280639947, 0.865003, 0.865003, 0.865003, 2.094699999998966, 0.705882, 0.0156863, 0.14902] 69 | isoLevelLUT.ScalarRangeInitialized = 1.0 70 | 71 | # get opacity transfer function/opacity map for 'IsoLevel' 72 | isoLevelPWF = GetOpacityTransferFunction('IsoLevel') 73 | isoLevelPWF.Points = [2.5612799973882074e-05, 0.0, 0.5, 0.0, 2.094699999998966, 1.0, 0.5, 0.0] 74 | isoLevelPWF.ScalarRangeInitialized = 1 75 | 76 | # trace defaults for the display properties. 77 | velocityc51vtuDisplay.Representation = 'Surface' 78 | velocityc51vtuDisplay.ColorArrayName = ['POINTS', 'IsoLevel'] 79 | velocityc51vtuDisplay.LookupTable = isoLevelLUT 80 | velocityc51vtuDisplay.OSPRayScaleArray = 'IsoLevel' 81 | velocityc51vtuDisplay.OSPRayScaleFunction = 'PiecewiseFunction' 82 | velocityc51vtuDisplay.SelectOrientationVectors = 'IsoLevel' 83 | velocityc51vtuDisplay.ScaleFactor = 0.1 84 | velocityc51vtuDisplay.SelectScaleArray = 'IsoLevel' 85 | velocityc51vtuDisplay.GlyphType = 'Arrow' 86 | velocityc51vtuDisplay.GlyphTableIndexArray = 'IsoLevel' 87 | velocityc51vtuDisplay.GaussianRadius = 0.005 88 | velocityc51vtuDisplay.SetScaleArray = ['POINTS', 'IsoLevel'] 89 | velocityc51vtuDisplay.ScaleTransferFunction = 'PiecewiseFunction' 90 | velocityc51vtuDisplay.OpacityArray = ['POINTS', 'IsoLevel'] 91 | velocityc51vtuDisplay.OpacityTransferFunction = 'PiecewiseFunction' 92 | velocityc51vtuDisplay.DataAxesGrid = 'GridAxesRepresentation' 93 | velocityc51vtuDisplay.PolarAxes = 'PolarAxesRepresentation' 94 | velocityc51vtuDisplay.ScalarOpacityFunction = isoLevelPWF 95 | velocityc51vtuDisplay.ScalarOpacityUnitDistance = 0.03261513739238651 96 | 97 | # init the 'PiecewiseFunction' selected for 'OSPRayScaleFunction' 98 | velocityc51vtuDisplay.OSPRayScaleFunction.Points = [0.008018268893823101, 0.0, 0.5, 0.0, 2.3, 1.0, 0.5, 0.0] 99 | 100 | # init the 'PiecewiseFunction' selected for 'ScaleTransferFunction' 101 | velocityc51vtuDisplay.ScaleTransferFunction.Points = [2.5612799973882074e-05, 0.0, 0.5, 0.0, 2.094699999998966, 1.0, 0.5, 0.0] 102 | 103 | # init the 'PiecewiseFunction' selected for 'OpacityTransferFunction' 104 | velocityc51vtuDisplay.OpacityTransferFunction.Points = [2.5612799973882074e-05, 0.0, 0.5, 0.0, 2.094699999998966, 1.0, 0.5, 0.0] 105 | 106 | # setup the color legend parameters for each legend in this view 107 | 108 | # get color legend/bar for isoLevelLUT in view renderView1 109 | isoLevelLUTColorBar = GetScalarBar(isoLevelLUT, renderView1) 110 | isoLevelLUTColorBar.WindowLocation = 'AnyLocation' 111 | isoLevelLUTColorBar.Title = 'IsoLevel' 112 | isoLevelLUTColorBar.ComponentTitle = '' 113 | isoLevelLUTColorBar.ScalarBarLength = 0.7008439897698198 114 | 115 | # set color bar visibility 116 | isoLevelLUTColorBar.Visibility = 1 117 | 118 | # show color legend 119 | velocityc51vtuDisplay.SetScalarBarVisibility(renderView1, True) 120 | 121 | # ---------------------------------------------------------------- 122 | # setup color maps and opacity mapes used in the visualization 123 | # note: the Get..() functions create a new object, if needed 124 | # ---------------------------------------------------------------- 125 | 126 | # ---------------------------------------------------------------- 127 | # finally, restore active source 128 | SetActiveSource(velocityc51vtu) 129 | # ---------------------------------------------------------------- 130 | --------------------------------------------------------------------------------