├── .gitignore ├── .vscode └── settings.json ├── LICENSE.md ├── README.md ├── example └── openTerrain │ ├── 0 │ ├── U │ ├── nut │ └── p │ ├── constant │ ├── DFSRTurbDict │ ├── boundaryData │ │ └── windProfile │ │ │ ├── profile │ │ │ └── sampledData │ │ │ └── samplingPoints │ ├── transportProperties │ └── turbulenceProperties │ ├── setUp │ └── system │ ├── blockMeshDict │ ├── controlDict │ ├── decomposeParDict │ ├── fvSchemes │ ├── fvSolution │ ├── probes1 │ └── probes2 ├── files ├── velocityContour.svg └── velocityPlots.png └── src ├── .vscode └── settings.json └── DFSRTurb ├── Allwclean ├── Allwmake ├── DFSRTurb.C ├── Make ├── files └── options ├── correctDivergence.H ├── createInletFields.H ├── createInletMesh.H ├── decomposeMatrix.H ├── extrudedPatch ├── Make │ ├── files │ └── options ├── extrudedPatch.C ├── extrudedPatch.H └── extrudedPatchTemplates.C ├── functions.H ├── generateInflow.H ├── initialize.H ├── readDFSRTurbDict.H ├── setupWritePaths.H ├── windProfile ├── Make │ ├── files │ └── options ├── windProfile.C └── windProfile.H └── write.H /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | [Ll]ogs/ 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | # Uncomment if you have tasks that create the project's static files in wwwroot 37 | #wwwroot/ 38 | 39 | # Visual Studio 2017 auto generated files 40 | Generated\ Files/ 41 | 42 | # MSTest test Results 43 | [Tt]est[Rr]esult*/ 44 | [Bb]uild[Ll]og.* 45 | 46 | # NUnit 47 | *.VisualState.xml 48 | TestResult.xml 49 | nunit-*.xml 50 | 51 | # Build Results of an ATL Project 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | 56 | # Benchmark Results 57 | BenchmarkDotNet.Artifacts/ 58 | 59 | # .NET Core 60 | project.lock.json 61 | project.fragment.lock.json 62 | artifacts/ 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.vspscc 90 | *.vssscc 91 | .builds 92 | *.pidb 93 | *.svclog 94 | *.scc 95 | 96 | # Chutzpah Test files 97 | _Chutzpah* 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opendb 104 | *.opensdf 105 | *.sdf 106 | *.cachefile 107 | *.VC.db 108 | *.VC.VC.opendb 109 | 110 | # Visual Studio profiler 111 | *.psess 112 | *.vsp 113 | *.vspx 114 | *.sap 115 | 116 | # Visual Studio Trace Files 117 | *.e2e 118 | 119 | # TFS 2012 Local Workspace 120 | $tf/ 121 | 122 | # Guidance Automation Toolkit 123 | *.gpState 124 | 125 | # ReSharper is a .NET coding add-in 126 | _ReSharper*/ 127 | *.[Rr]e[Ss]harper 128 | *.DotSettings.user 129 | 130 | # TeamCity is a build add-in 131 | _TeamCity* 132 | 133 | # DotCover is a Code Coverage Tool 134 | *.dotCover 135 | 136 | # AxoCover is a Code Coverage Tool 137 | .axoCover/* 138 | !.axoCover/settings.json 139 | 140 | # Visual Studio code coverage results 141 | *.coverage 142 | *.coveragexml 143 | 144 | # NCrunch 145 | _NCrunch_* 146 | .*crunch*.local.xml 147 | nCrunchTemp_* 148 | 149 | # MightyMoose 150 | *.mm.* 151 | AutoTest.Net/ 152 | 153 | # Web workbench (sass) 154 | .sass-cache/ 155 | 156 | # Installshield output folder 157 | [Ee]xpress/ 158 | 159 | # DocProject is a documentation generator add-in 160 | DocProject/buildhelp/ 161 | DocProject/Help/*.HxT 162 | DocProject/Help/*.HxC 163 | DocProject/Help/*.hhc 164 | DocProject/Help/*.hhk 165 | DocProject/Help/*.hhp 166 | DocProject/Help/Html2 167 | DocProject/Help/html 168 | 169 | # Click-Once directory 170 | publish/ 171 | 172 | # Publish Web Output 173 | *.[Pp]ublish.xml 174 | *.azurePubxml 175 | # Note: Comment the next line if you want to checkin your web deploy settings, 176 | # but database connection strings (with potential passwords) will be unencrypted 177 | *.pubxml 178 | *.publishproj 179 | 180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 181 | # checkin your Azure Web App publish settings, but sensitive information contained 182 | # in these scripts will be unencrypted 183 | PublishScripts/ 184 | 185 | # NuGet Packages 186 | *.nupkg 187 | # NuGet Symbol Packages 188 | *.snupkg 189 | # The packages folder can be ignored because of Package Restore 190 | **/[Pp]ackages/* 191 | # except build/, which is used as an MSBuild target. 192 | !**/[Pp]ackages/build/ 193 | # Uncomment if necessary however generally it will be regenerated when needed 194 | #!**/[Pp]ackages/repositories.config 195 | # NuGet v3's project.json files produces more ignorable files 196 | *.nuget.props 197 | *.nuget.targets 198 | 199 | # Microsoft Azure Build Output 200 | csx/ 201 | *.build.csdef 202 | 203 | # Microsoft Azure Emulator 204 | ecf/ 205 | rcf/ 206 | 207 | # Windows Store app package directories and files 208 | AppPackages/ 209 | BundleArtifacts/ 210 | Package.StoreAssociation.xml 211 | _pkginfo.txt 212 | *.appx 213 | *.appxbundle 214 | *.appxupload 215 | 216 | # Visual Studio cache files 217 | # files ending in .cache can be ignored 218 | *.[Cc]ache 219 | # but keep track of directories ending in .cache 220 | !?*.[Cc]ache/ 221 | 222 | # Others 223 | ClientBin/ 224 | ~$* 225 | *~ 226 | *.dbmdl 227 | *.dbproj.schemaview 228 | *.jfm 229 | *.pfx 230 | *.publishsettings 231 | orleans.codegen.cs 232 | 233 | # Including strong name files can present a security risk 234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 235 | #*.snk 236 | 237 | # Since there are multiple workflows, uncomment next line to ignore bower_components 238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 239 | #bower_components/ 240 | 241 | # RIA/Silverlight projects 242 | Generated_Code/ 243 | 244 | # Backup & report files from converting an old project file 245 | # to a newer Visual Studio version. Backup files are not needed, 246 | # because we have git ;-) 247 | _UpgradeReport_Files/ 248 | Backup*/ 249 | UpgradeLog*.XML 250 | UpgradeLog*.htm 251 | ServiceFabricBackup/ 252 | *.rptproj.bak 253 | 254 | # SQL Server files 255 | *.mdf 256 | *.ldf 257 | *.ndf 258 | 259 | # Business Intelligence projects 260 | *.rdl.data 261 | *.bim.layout 262 | *.bim_*.settings 263 | *.rptproj.rsuser 264 | *- [Bb]ackup.rdl 265 | *- [Bb]ackup ([0-9]).rdl 266 | *- [Bb]ackup ([0-9][0-9]).rdl 267 | 268 | # Microsoft Fakes 269 | FakesAssemblies/ 270 | 271 | # GhostDoc plugin setting file 272 | *.GhostDoc.xml 273 | 274 | # Node.js Tools for Visual Studio 275 | .ntvs_analysis.dat 276 | node_modules/ 277 | 278 | # Visual Studio 6 build log 279 | *.plg 280 | 281 | # Visual Studio 6 workspace options file 282 | *.opt 283 | 284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 285 | *.vbw 286 | 287 | # Visual Studio LightSwitch build output 288 | **/*.HTMLClient/GeneratedArtifacts 289 | **/*.DesktopClient/GeneratedArtifacts 290 | **/*.DesktopClient/ModelManifest.xml 291 | **/*.Server/GeneratedArtifacts 292 | **/*.Server/ModelManifest.xml 293 | _Pvt_Extensions 294 | 295 | # Paket dependency manager 296 | .paket/paket.exe 297 | paket-files/ 298 | 299 | # FAKE - F# Make 300 | .fake/ 301 | 302 | # CodeRush personal settings 303 | .cr/personal 304 | 305 | # Python Tools for Visual Studio (PTVS) 306 | __pycache__/ 307 | *.pyc 308 | 309 | # Cake - Uncomment if you are using it 310 | # tools/** 311 | # !tools/packages.config 312 | 313 | # Tabs Studio 314 | *.tss 315 | 316 | # Telerik's JustMock configuration file 317 | *.jmconfig 318 | 319 | # BizTalk build output 320 | *.btp.cs 321 | *.btm.cs 322 | *.odx.cs 323 | *.xsd.cs 324 | 325 | # OpenCover UI analysis results 326 | OpenCover/ 327 | 328 | # Azure Stream Analytics local run output 329 | ASALocalRun/ 330 | 331 | # MSBuild Binary and Structured Log 332 | *.binlog 333 | 334 | # NVidia Nsight GPU debugger configuration file 335 | *.nvuser 336 | 337 | # MFractors (Xamarin productivity tool) working folder 338 | .mfractor/ 339 | 340 | # Local History for Visual Studio 341 | .localhistory/ 342 | 343 | # BeatPulse healthcheck temp database 344 | healthchecksdb 345 | 346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 347 | MigrationBackup/ 348 | 349 | # Ionide (cross platform F# VS Code tools) working folder 350 | .ionide/ 351 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "correctDivergence.H": "cpp", 4 | "generateInflow.H": "cpp" 5 | } 6 | } -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | DFSR 2 | 3 | Copyright (C) 2021 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the [GNU General Public License](http://www.gnu.org/licenses/gpl-3.0.html) 7 | as published by the Free Software Foundation; either version 2 of the 8 | License, or(at your option) any later version. 9 | 10 | Over and above the legal restrictions imposed by this license, if you 11 | use this software for an academic publication then you are expected to 12 | provide proper attribution. This can be to this code directly, 13 | 14 | A.F. Melaku and G.T. Bitsuamlak, DFSR, v1.0 (2021). https://zenodo.org/badge/latestdoi/300517389. 15 | 16 | or the original article 17 | 18 | A.F. Melaku and G.T. Bitsuamlak. https://doi.org/10.1016/j.jweia.2021.104580. 19 | 20 | This program is distributed in the hope that it will be useful, 21 | but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | GNU General Public License for more details. 24 | 25 | You should have received a copy of the GNU General Public License 26 | along with this program; if not, write to the Free Software 27 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DFSR 2 | 3 | [![DOI](https://zenodo.org/badge/300517389.svg)](https://zenodo.org/badge/latestdoi/300517389) 4 | 5 | Divergence-free Spectral Representation (DFSR) method is an inflow/inlet turbulence generation method developed for large-eddy simulation of the atmospheric boundary layer(ABL) flows. The technique uses the spectral representation method to generate ABL-like turbulence with prescribed two-point flow statistics. The code is developed as a utility application using OpenFOAM's framework. DFSR offers the following key features: 6 | 7 | - Capable of running on **unstructured** meshes 8 | - Uses **LAPACK** subroutine for efficient matrix factorization 9 | - Employes the **FFT** technique for faster time-series computation 10 | - Parallel implementation using **OpenMPI** 11 | 12 | In this version of the code, the divergence-free condition is imposed on the generated turbulence by adding a gradient of a velocity potential, following the procedure developed by *Shirani et al.(1981)*(similar to approach used in the paper). The final velocity field is written for each time step in the corresponding case directory. Mathematical details of the implemented procedure can be found in [Melaku and Bitsuamlak(2021)](https://www.sciencedirect.com/science/article/pii/S0167610521000660). If you find this work useful in your research and use the DFSR method or parts of it in your work, please do not forget to cite the paper. 13 | 14 | ![screenShot](files/velocityPlots.png) 15 | 16 | ## Installing DFSR 17 | ### Requirements 18 | Before compiling the source code, you need to have the following packages already installed. 19 | - **OpenFOAM**, preferably v8 20 | - Intel's oneAPI MKL package or **LAPACK** library 21 | 22 | Download the installer here: https://www.intel.com/content/www/us/en/developer/tools/oneapi/base-toolkit-download.html?operatingsystem=linux&distributions=webdownload&options=online 23 | 24 | Follow the Command Line Download and Installation instructions (`sudo` is not required, but we only selected the MKL package to install - 7.3 GB) \ 25 | And make sure to follow these instructions: https://www.intel.com/content/www/us/en/develop/documentation/get-started-with-dpcpp-compiler/top.html \ 26 | i.e. source the environment settings script (in our case that worked with `$ source $HOME/intel/oneapi/setvars.sh intel64` but might be dependent on where you installed it - also, you might want to add this line to the end of your `~/.bashrc` file, as it needs to be sourced every time you open a new terminal window) 27 | 28 | - Fastest Fourier Transform in the West(**FFTW**) package 29 | 30 | Download the source code from here: `wget https://www.fftw.org/fftw-3.3.10.tar.gz` 31 | and in the un-zipped folder run the following: 32 | 33 | `$ ./configure`\ 34 | `$ make`\ 35 | `$ sudo make install` 36 | 37 | ### Build from source 38 | 39 | Follow the following procedure to compile the source code. 40 | 41 | - Clone the code to your computer: 42 | 43 | `$ git clone https://github.com/abiyfantaye/DFSR.git DFSR` 44 | 45 | - Copy the `DFSR/src/DFSRTurb` directory to `$WM_PROJECT_USER_DIR/applications/utilities/preProcessing/`: 46 | 47 | `$ mkdir -p $WM_PROJECT_USER_DIR/applications/utilities/preProcessing`\ 48 | `$ cp -r DFSR/src/DFSRTurb $WM_PROJECT_USER_DIR/applications/utilities/preProcessing/` 49 | 50 | - Compile the code in `$WM_PROJECT_USER_DIR/applications/utilities/preProcessing/DFSRTurb` directory: 51 | 52 | `$ cd $WM_PROJECT_USER_DIR/applications/utilities/preProcessing/DFSRTurb`\ 53 | `$ chmod +x Allwclean`\ 54 | `$ chmod +x Allwmake`\ 55 | `$ sh ./Allwclean`\ 56 | `$ sh ./Allwmake` 57 | 58 | The turbulence generator is now fully embedded in OpenFOAM and can be launched as `DFSRTurb` in serial or parallel. If you have trouble installing this application, please drop an email to afmelaku@berkeley.edu cc·'ing to Prof. Girma Bitsuamlak at gbitsuam@uwo.ca. 59 | 60 | ## Simulation Example 61 | Directory tree of `example/openTerrain`: 62 | ```bash 63 | ├── 0 64 | │   ├── nut 65 | │   ├── p 66 | │   └── U 67 | ├── constant 68 | │   ├── boundaryData 69 | │   │   └── windProfile 70 | │   │   ├── profile 71 | │   │   └── sampledData 72 | │   │   ├── samplingPoints 73 | │   │   └── vtkSlices 74 | │   ├── DFSRTurbDict 75 | │   ├── transportProperties 76 | │   └── turbulenceProperties 77 | ├── setUp 78 | └── system 79 | ├── blockMeshDict 80 | ├── controlDict 81 | ├── decomposeParDict 82 | ├── fvSchemes 83 | ├── fvSolution 84 | ├── probes1 85 | └── probes2 86 | ``` 87 | ### Input parameters 88 | 89 | The directory `example/openTerrain` contains an empty domain LES case configured for open terrain conditions. The basic parameters for the DFSR method are defined in `constant/DFSRTurbDict`. The method reads the ABL profile from `constant/boundaryData/windProfile/profile` file. This file specifies the variation of the mean velocity, turbulence intensities, and length scales over the height in the following tabular format: 90 | 91 | | z[m] | Uav[m/s] | Iu | Iv | Iw | Lu [m] | Lv[m] | Lw[m] | 92 | | ----- | -------- | ----- | ------ | ------ | ------ | ------ | ------ | 93 | | 0.02 | 14.56 | 0.160 | 0.120 | 0.120 | 0.750 | 0.500 | 0.300 | 94 | | ..... | ....... | ..... | ..... | ..... | ..... | ..... | ..... | 95 | | ..... | ....... | ..... | ..... | ..... | ..... | ..... | ..... | 96 | 97 | The parameters that need to be defined in `constant/DFSRTurbDict` dictionary are: 98 | 99 | | Parameter | Description | Optional | Default | 100 | | --- | --- | --- | --- | 101 | | `patchName` | Name of the patch to apply the inflow | no | -- | 102 | | `startTime` | Starting time of the generated turbulence | yes | 0.0| 103 | | `endTime` | Ending time of the generated turbulence | no | --| 104 | | `timeStep` | Time step of the inflow, can be different from the solver time step. It should be `1/(2*fMax)` to take advantage of the FFT algorithm. | no | --| 105 | | `fMax` | The cut-off frequency | no | --| 106 | | `nFreq` | The number of frequency steps/segments | no | 1024 | 107 | | `nInterp` | Number of spectral interpolation frequencies | no | 50 | 108 | | `seed` | Seed of the random number generator used to sample random phase angles. | yes | -- | 109 | | `C` | Coherency decay coefficients. | no | --| 110 | | `cohUav` | Mean velocity used to define the coherency function | yes | --| 111 | | `scaleI` | A factor to scale turbulence intensity profiles in each direction to account for the decay of turbulence downstream in the CFD simulation. | yes |(1 1 1)| 112 | | `scaleL` | A factor to scale integral length scale profiles in each direction. | yes | (1 1 1) | 113 | | `correctDivergence` | Apply div-free corrections or not | yes | off | 114 | | `writeSamples` | Write data for selected sampling points or not | yes | on | 115 | | `writeInflow` | Write the final inflow data or not| yes | on | 116 | 117 | ### Output 118 | Finally, if the controle `writeInflow` is turned on, the whole inflow data is saved in `constant/boundaryData//` directory. This inflow data is later read by the solver with `timeVaryingMappedFixedValue` velocity boundary condition at the inlet. Please check the OpenFOAM test case in `example/openTerrain` directory for the details. 119 | 120 | If `writeSamples` is turned on, the code reads sampling points from `constant/boundaryData/windProfile/sampledData/samplingPoints`. Then, the time-series of the generated velocity components for each point in `samplingPoints` are written into `Ux`,`Uy`, and `Uz` files in the same directory. In addition, the velocity field over the inflow patch is written to VTK slices for selected time instances in the same directory. 121 | 122 | 123 | ### Excuting the test case 124 | 125 | Follow the following procedure to run the test case in `example/openTerrain` directory: 126 | 127 | - Generate block mesh: 128 | 129 | `$ blockMesh` 130 | 131 | - Decompose the case: 132 | 133 | `$ decomposePar` 134 | 135 | - Run the DFSR inflow generator in parallel: 136 | 137 | `$ mpirun -np 4 DFSRTurb -parallel` 138 | 139 | - Check the generated samples on paraview: 140 | 141 | `$ paraview constant/boundaryData/windProfile/sampledData/vtkSlices/Ut_*` 142 | 143 | - Finally run the LES case: 144 | 145 | `$ mpirun -np 4 pisoFoam -parallel` 146 | 147 | ## Reference 148 | [1] Melaku, A.F. and Bitsuamlak, G.T., 2021. A divergence-free inflow turbulence generator using spectral representation method for large-eddy simulation of ABL flows. Journal of Wind Engineering and Industrial Aerodynamics, 212, p.104580. 149 | 150 | [2] Shirani, E., Ferziger, J.H. and Reynolds, W.C., 1981. Mixing of a passive scalar in isotropic and sheared homogeneous turbulence. Mosciences Division, Department of Mechanical Engineering, Stanford University. 151 | -------------------------------------------------------------------------------- /example/openTerrain/0/U: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: 5.0 | 5 | | \\ / A nd | Web: www.OpenFOAM.org | 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 | #include "../setUp" 19 | 20 | dimensions [ 0 1 -1 0 0 0 0 ]; 21 | 22 | internalField uniform ( 10 0 0 ); 23 | 24 | boundaryField 25 | { 26 | inlet 27 | { 28 | type timeVaryingMappedFixedValue; 29 | value uniform ( 10 0 0 ); 30 | } 31 | outlet 32 | { 33 | type inletOutlet; 34 | inletValue uniform ( 0 0 0 ); 35 | value uniform ( 0 0 0 ); 36 | } 37 | 38 | top 39 | { 40 | type symmetry; 41 | } 42 | 43 | ground 44 | { 45 | type uniformFixedValue; 46 | value uniform (0 0 0); 47 | uniformValue constant (0 0 0); 48 | } 49 | 50 | front 51 | { 52 | type symmetry; 53 | } 54 | 55 | back 56 | { 57 | type symmetry; 58 | } 59 | } 60 | 61 | 62 | // ************************************************************************* // 63 | -------------------------------------------------------------------------------- /example/openTerrain/0/nut: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: 5.0 | 5 | | \\ / A nd | Web: www.OpenFOAM.org | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volScalarField; 13 | location "0"; 14 | object nut; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | #include "../setUp" 19 | 20 | dimensions [ 0 2 -1 0 0 0 0 ]; 21 | 22 | internalField uniform 0; 23 | 24 | boundaryField 25 | { 26 | inlet 27 | { 28 | type zeroGradient; 29 | } 30 | outlet 31 | { 32 | type zeroGradient; 33 | } 34 | top 35 | { 36 | type symmetry; 37 | } 38 | ground 39 | { 40 | type nutkAtmRoughWallFunction; 41 | z0 $z0; 42 | value uniform 0.0; 43 | } 44 | front 45 | { 46 | type symmetry; 47 | } 48 | back 49 | { 50 | type symmetry; 51 | } 52 | } 53 | 54 | // ************************************************************************* // 55 | -------------------------------------------------------------------------------- /example/openTerrain/0/p: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: 5.0 | 5 | | \\ / A nd | Web: www.OpenFOAM.org | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class volScalarField; 13 | location "0"; 14 | object p; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | dimensions [ 0 2 -2 0 0 0 0 ]; 19 | 20 | internalField uniform 0; 21 | 22 | boundaryField 23 | { 24 | inlet 25 | { 26 | type zeroGradient; 27 | } 28 | outlet 29 | { 30 | type fixedValue; 31 | value uniform 0; 32 | } 33 | top 34 | { 35 | type symmetry; 36 | } 37 | ground 38 | { 39 | type zeroGradient; 40 | } 41 | front 42 | { 43 | type symmetry; 44 | } 45 | back 46 | { 47 | type symmetry; 48 | } 49 | } 50 | 51 | 52 | // ************************************************************************* // 53 | -------------------------------------------------------------------------------- /example/openTerrain/constant/DFSRTurbDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: 5 | 5 | | \\ / A nd | Web: www.OpenFOAM.org | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | location "constant"; 14 | object DFSRTurbDict; 15 | } 16 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 17 | 18 | #include "../setUp" 19 | 20 | //Name of the inflow patch 21 | patchName "inlet"; 22 | 23 | //Start time of the simulation 24 | startTime 0.0; 25 | 26 | //End time of the simulation 27 | endTime 5.0; 28 | 29 | //Time step for the inflow generation Should be 1/(2*fmax) 30 | //to take advantage of the FFT algorithm. 31 | timeStep 0.002; 32 | 33 | //Upper cut off frequency 34 | fMax 250; 35 | 36 | //The number of frequency steps 37 | nFreq 1024; 38 | 39 | //Number of spectral interpolation frequencies 40 | nInterp 50; 41 | 42 | //Constant mean velocity for coherency function 43 | cohUav $Uref; 44 | 45 | //Seed of the random number generator used to sample random phase angles 46 | seed 1234; 47 | 48 | //Coherency decay coefficients 49 | C (//x y z 50 | 3.00 10.0 10.0 //u 51 | 3.00 5.00 5.50 //v 52 | 3.00 5.50 5.00 //w 53 | ); 54 | 55 | //Factors to scale turbulence intensities and length scale profiles 56 | //in each direction helps to account for decay of turbulence 57 | scaleI (1.0 1.0 1.0); 58 | scaleL (1.0 1.0 1.0); 59 | 60 | //Apply div-free corrections or not 61 | correctDivergence off; 62 | 63 | //Write the time-series for sampled points 64 | writeSamples on; 65 | 66 | //Write the final inflow data 67 | writeInflow on; 68 | // ************************************************************************* // 69 | -------------------------------------------------------------------------------- /example/openTerrain/constant/boundaryData/windProfile/profile: -------------------------------------------------------------------------------- 1 | 0.004939 8.508891 0.197640 0.159284 0.098553 0.701335 0.410374 0.015156 2 | 0.017502 8.662375 0.190517 0.153544 0.095001 0.725088 0.405303 0.028156 3 | 0.030065 9.046421 0.175054 0.141081 0.087290 0.747991 0.400381 0.040733 4 | 0.042627 9.406131 0.167252 0.134717 0.083395 0.770054 0.395607 0.052891 5 | 0.055190 9.742734 0.165719 0.132132 0.082532 0.791290 0.390978 0.064637 6 | 0.067753 10.057414 0.163405 0.126983 0.081139 0.811711 0.386492 0.075977 7 | 0.080316 10.351318 0.153981 0.116454 0.076227 0.831327 0.382148 0.086918 8 | 0.092879 10.625552 0.150991 0.111213 0.074577 0.850150 0.377943 0.097465 9 | 0.105442 10.881183 0.150440 0.109161 0.074647 0.868193 0.373874 0.107625 10 | 0.118004 11.119241 0.146507 0.106888 0.073896 0.885465 0.369941 0.117404 11 | 0.130567 11.340719 0.138728 0.101789 0.071164 0.901980 0.366140 0.126808 12 | 0.143130 11.546570 0.136152 0.100437 0.071030 0.917749 0.362470 0.135843 13 | 0.155693 11.737714 0.140317 0.103681 0.074131 0.932783 0.358929 0.144515 14 | 0.168256 11.915035 0.137824 0.101360 0.073258 0.947094 0.355514 0.152832 15 | 0.180818 12.079381 0.134776 0.098673 0.072097 0.960693 0.352224 0.160798 16 | 0.193381 12.231567 0.129974 0.094832 0.070023 0.973593 0.349057 0.168419 17 | 0.205944 12.372373 0.125906 0.091749 0.068438 0.985804 0.346009 0.175703 18 | 0.218507 12.502549 0.124466 0.091380 0.068599 0.997338 0.343080 0.182656 19 | 0.231070 12.622809 0.123105 0.091030 0.068794 1.008207 0.340267 0.189282 20 | 0.243632 12.733838 0.122061 0.090761 0.069133 1.018422 0.337568 0.195590 21 | 0.256195 12.836291 0.120923 0.090227 0.069330 1.027996 0.334982 0.201584 22 | 0.268758 12.930790 0.119335 0.088442 0.068866 1.036939 0.332505 0.207271 23 | 0.281321 13.017929 0.117747 0.086658 0.068401 1.045263 0.330136 0.212657 24 | 0.293884 13.098273 0.116160 0.084873 0.067936 1.052980 0.327872 0.217749 25 | 0.306447 13.172360 0.114790 0.083295 0.067548 1.060102 0.325713 0.222552 26 | 0.319009 13.240698 0.114870 0.083086 0.067670 1.066639 0.323655 0.227073 27 | 0.331572 13.303770 0.114949 0.082877 0.067791 1.072604 0.321696 0.231318 28 | 0.344135 13.362032 0.115028 0.082668 0.067913 1.078008 0.319835 0.235292 29 | 0.356698 13.415914 0.115015 0.082390 0.068023 1.082862 0.318070 0.239003 30 | 0.369261 13.465824 0.114046 0.081380 0.068019 1.087179 0.316397 0.242456 31 | 0.381823 13.512141 0.113076 0.080371 0.068016 1.090970 0.314816 0.245658 32 | 0.394386 13.555223 0.112107 0.079361 0.068012 1.094246 0.313324 0.248615 33 | 0.406949 13.595407 0.111130 0.078385 0.068002 1.097020 0.311918 0.251332 34 | 0.419512 13.633005 0.109998 0.078127 0.067869 1.099302 0.310598 0.253816 35 | 0.432075 13.668307 0.108865 0.077869 0.067736 1.101104 0.309361 0.256074 36 | 0.444637 13.701585 0.107733 0.077612 0.067603 1.102438 0.308204 0.258111 37 | 0.457200 13.733087 0.106600 0.077354 0.067469 1.103316 0.307126 0.259934 38 | 0.469763 13.763046 0.105401 0.076212 0.066947 1.103748 0.306125 0.261548 39 | 0.482326 13.791672 0.104201 0.075071 0.066425 1.103747 0.305198 0.262961 40 | 0.494889 13.819158 0.103002 0.073929 0.065903 1.103324 0.304344 0.264177 41 | 0.507452 13.845680 0.101802 0.072787 0.065381 1.102491 0.303560 0.265204 42 | 0.520014 13.871397 0.101343 0.073503 0.065238 1.101260 0.302844 0.266047 43 | 0.532577 13.896451 0.100918 0.074304 0.065113 1.099641 0.302195 0.266713 44 | 0.545140 13.920969 0.100779 0.074798 0.065243 1.097647 0.301609 0.267208 45 | 0.557703 13.945062 0.100660 0.075270 0.065389 1.095289 0.301086 0.267538 46 | 0.570266 13.968829 0.099558 0.074205 0.065000 1.092579 0.300622 0.267708 47 | 0.582828 13.992353 0.098361 0.072992 0.064559 1.089528 0.300217 0.267727 48 | 0.595391 14.015704 0.097164 0.071779 0.064118 1.086148 0.299867 0.267598 49 | 0.607954 14.038943 0.095967 0.070567 0.063676 1.082450 0.299571 0.267330 50 | 0.620517 14.062114 0.096223 0.070798 0.064182 1.078447 0.299326 0.266927 51 | 0.633080 14.085256 0.096697 0.071248 0.064830 1.074149 0.299131 0.266396 52 | 0.645643 14.108392 0.097172 0.071697 0.065478 1.069568 0.298984 0.265743 53 | 0.658205 14.131539 0.097647 0.072146 0.066127 1.064716 0.298882 0.264975 54 | 0.670768 14.154705 0.098122 0.072596 0.066775 1.059605 0.298823 0.264097 55 | 0.683331 14.177887 0.098597 0.073045 0.067423 1.054246 0.298805 0.263116 56 | 0.695894 14.201076 0.099071 0.073494 0.068071 1.048650 0.298826 0.262038 57 | 0.708457 14.224257 0.099546 0.073943 0.068720 1.042830 0.298885 0.260869 58 | 0.721019 14.247407 0.098792 0.074271 0.068982 1.036796 0.298978 0.259616 59 | 0.733582 14.270498 0.097694 0.074564 0.069136 1.030560 0.299104 0.258283 60 | 0.746145 14.293497 0.096596 0.074857 0.069290 1.024135 0.299261 0.256878 61 | 0.758708 14.316367 0.095498 0.075150 0.069444 1.017531 0.299447 0.255407 62 | 0.771271 14.339065 0.094400 0.075443 0.069599 1.010760 0.299659 0.253876 63 | 0.783833 14.361548 0.093302 0.075737 0.069753 1.003834 0.299896 0.252291 64 | 0.796396 14.383770 0.092204 0.076030 0.069907 0.996765 0.300156 0.250659 65 | 0.808959 14.405681 0.091106 0.076323 0.070061 0.989563 0.300435 0.248984 66 | 0.821522 14.427233 0.090668 0.076314 0.070094 0.982240 0.300733 0.247275 67 | 0.834085 14.448376 0.090522 0.076171 0.070074 0.974809 0.301047 0.245536 68 | 0.846648 14.469060 0.090375 0.076029 0.070054 0.967281 0.301376 0.243774 69 | 0.859210 14.489237 0.090229 0.075886 0.070034 0.959666 0.301716 0.241996 70 | 0.871773 14.508859 0.090082 0.075744 0.070013 0.951978 0.302066 0.240206 71 | 0.884336 14.527882 0.089936 0.075601 0.069993 0.944227 0.302425 0.238412 72 | 0.896899 14.546264 0.089789 0.075459 0.069973 0.936425 0.302788 0.236620 73 | 0.909462 14.563968 0.089642 0.075316 0.069953 0.928583 0.303156 0.234836 74 | 0.922024 14.580958 0.089496 0.075174 0.069933 0.922432 0.303642 0.239754 75 | 0.934587 14.597205 0.089910 0.075644 0.070523 0.916302 0.303644 0.239039 76 | 0.947150 14.612687 0.088423 0.074607 0.069729 0.910172 0.303646 0.238325 77 | 0.959713 14.627385 0.088633 0.075008 0.070284 0.904043 0.303648 0.237610 78 | 0.972276 14.641287 0.088162 0.074826 0.070290 0.897913 0.303651 0.236896 79 | 0.984838 14.654385 0.087904 0.074833 0.070478 0.891783 0.303653 0.236181 80 | 0.997401 14.666677 0.089381 0.076282 0.072025 0.885653 0.303655 0.235467 81 | 1.009964 14.678164 0.089826 0.076722 0.072617 0.879523 0.303657 0.234752 82 | 1.022527 14.688853 0.087705 0.074879 0.071041 0.873394 0.303659 0.234038 83 | 1.035090 14.698755 0.084945 0.072493 0.068945 0.867264 0.303662 0.233324 84 | 1.047653 14.707884 0.085006 0.072514 0.069136 0.861134 0.303664 0.232609 85 | 1.060215 14.716258 0.085684 0.073061 0.069828 0.855004 0.303666 0.231895 86 | 1.072778 14.723897 0.085322 0.072722 0.069677 0.848874 0.303668 0.231180 87 | 1.085341 14.730826 0.085075 0.072479 0.069620 0.842745 0.303670 0.230466 88 | 1.097904 14.737071 0.084987 0.072441 0.069658 0.836615 0.303672 0.229751 89 | 1.110467 14.742662 0.085091 0.072649 0.069813 0.830485 0.303675 0.229037 90 | 1.123029 14.747630 0.085317 0.072992 0.070053 0.824355 0.303677 0.228322 91 | 1.135592 14.752009 0.085703 0.073512 0.070406 0.818225 0.303679 0.227608 92 | 1.148155 14.755833 0.084513 0.072675 0.069463 0.812096 0.303681 0.226894 93 | 1.160718 14.759138 0.081061 0.069887 0.066660 0.805966 0.303683 0.226179 94 | 1.173281 14.761964 0.078638 0.068008 0.064751 0.799836 0.303686 0.225465 95 | 1.185844 14.764347 0.077834 0.067560 0.064250 0.793706 0.303688 0.224750 96 | 1.198406 14.766326 0.077030 0.067111 0.063748 0.787576 0.303690 0.224036 97 | 1.210969 14.767942 0.076227 0.066663 0.063246 0.781447 0.303692 0.223321 98 | 1.223532 14.769232 0.076149 0.066903 0.063433 0.775317 0.303694 0.222607 99 | 1.236095 14.770237 0.077453 0.068453 0.064927 0.769187 0.303696 0.221893 100 | 1.248658 14.770995 0.078756 0.070002 0.066422 0.763057 0.303699 0.221178 101 | 1.261220 14.771544 0.080059 0.071552 0.067916 0.756927 0.303701 0.220464 102 | 1.273783 14.771920 0.081062 0.072802 0.069127 0.750798 0.303703 0.219749 103 | 1.286346 14.772159 0.081366 0.073359 0.069680 0.744668 0.303705 0.219035 104 | 1.298909 14.772296 0.081670 0.073916 0.070233 0.738538 0.303707 0.218320 105 | 1.311472 14.772361 0.081974 0.074473 0.070786 0.732408 0.303710 0.217606 106 | 1.324034 14.772386 0.081945 0.074671 0.070998 0.726278 0.303712 0.216891 107 | 1.336597 14.772397 0.080956 0.073835 0.070223 0.720149 0.303714 0.216177 108 | 1.349160 14.772420 0.079967 0.072999 0.069449 0.714019 0.303716 0.215463 109 | 1.361723 14.772478 0.078978 0.072163 0.068675 0.707889 0.303718 0.214748 110 | 1.374286 14.772588 0.078187 0.071501 0.068064 0.701759 0.303721 0.214034 111 | 1.386849 14.772767 0.078125 0.071481 0.068057 0.695629 0.303723 0.213319 112 | 1.399411 14.773026 0.078063 0.071462 0.068050 0.689500 0.303725 0.212605 113 | 1.411974 14.773373 0.078001 0.071442 0.068043 0.683370 0.303727 0.211890 114 | 1.424537 14.773812 0.077786 0.071275 0.067893 0.677240 0.303729 0.211176 115 | 1.437100 14.774342 0.076821 0.070391 0.067051 0.671110 0.303731 0.210462 116 | 1.449663 14.774957 0.076215 0.069835 0.066522 0.664980 0.303734 0.209747 117 | 1.462225 14.775647 0.077664 0.071163 0.067787 0.658851 0.303736 0.209033 118 | 1.474788 14.776396 0.078960 0.072350 0.068918 0.652721 0.303738 0.208318 119 | 1.487351 14.777181 0.079195 0.072566 0.069123 0.646591 0.303740 0.207604 120 | 1.499914 14.777975 0.079430 0.072781 0.069328 0.640461 0.303742 0.206889 121 | 1.512477 14.778746 0.079665 0.072996 0.069533 0.634331 0.303745 0.206175 122 | 1.525040 14.779452 0.079843 0.073160 0.069689 0.628202 0.303747 0.205460 123 | 1.537602 14.780047 0.079395 0.072750 0.069298 0.622072 0.303749 0.204746 124 | 1.550165 14.780479 0.078948 0.072339 0.068907 0.615942 0.303751 0.204032 125 | 1.562728 14.780685 0.078500 0.071929 0.068517 0.609812 0.303753 0.203317 126 | 1.575291 14.780598 0.078053 0.071519 0.068126 0.603682 0.303755 0.202603 127 | 1.587854 14.780142 0.077605 0.071109 0.067735 0.597553 0.303758 0.201888 128 | 1.600416 14.779233 0.077157 0.070699 0.067345 0.591423 0.303760 0.201174 129 | 1.612979 14.777779 0.076710 0.070289 0.066954 0.585293 0.303762 0.200459 130 | 1.625542 14.775679 0.076262 0.069879 0.066563 0.579163 0.303764 0.199745 131 | 1.638105 14.772824 0.076602 0.070190 0.066860 0.573033 0.303766 0.199030 132 | 1.650668 14.769094 0.076946 0.070505 0.067160 0.566903 0.303769 0.198316 133 | 1.663230 14.764364 0.077290 0.070820 0.067460 0.560774 0.303771 0.197602 134 | 1.675793 14.758494 0.077633 0.071135 0.067760 0.554644 0.303773 0.196887 135 | 1.688356 14.751337 0.077977 0.071450 0.068060 0.548514 0.303775 0.196173 136 | 1.700919 14.742736 0.078321 0.071765 0.068360 0.542384 0.303777 0.195458 137 | 1.713482 14.732524 0.078665 0.072080 0.068660 0.536254 0.303780 0.194744 138 | 1.726045 14.720521 0.079008 0.072395 0.068960 0.530125 0.303782 0.194029 139 | 1.738607 14.706538 0.079668 0.072999 0.069536 0.523995 0.303784 0.193315 140 | 1.751170 14.690374 0.080359 0.073633 0.070139 0.517865 0.303786 0.192601 141 | 1.763733 14.671817 0.081050 0.074266 0.070743 0.511735 0.303788 0.191886 142 | 1.776296 14.650644 0.081742 0.074900 0.071346 0.505605 0.303790 0.191172 143 | 1.788859 14.626618 0.082433 0.075533 0.071949 0.499476 0.303793 0.190457 144 | 1.801421 14.599491 0.083124 0.076167 0.072553 0.493346 0.303795 0.189743 145 | 1.813984 14.569002 0.083816 0.076800 0.073156 0.487216 0.303797 0.189028 146 | 1.826547 14.534878 0.084507 0.077433 0.073760 0.481086 0.303799 0.188314 147 | 1.839110 14.496831 0.085198 0.078067 0.074363 0.474956 0.303801 0.187599 148 | 1.851673 14.489124 0.085330 0.078187 0.074478 0.468827 0.303804 0.186885 149 | 1.864235 14.489124 0.085330 0.078187 0.074478 0.462697 0.303806 0.186171 150 | 1.876798 14.489124 0.085330 0.078187 0.074478 0.456567 0.303808 0.185456 151 | 1.889361 14.489124 0.085330 0.078187 0.074478 0.450437 0.303810 0.184742 152 | 1.901924 14.489124 0.085330 0.078187 0.074478 0.444307 0.303812 0.184027 153 | 1.914487 14.489124 0.085330 0.078187 0.074478 0.438178 0.303814 0.183313 154 | 1.927050 14.489124 0.085330 0.078187 0.074478 0.432048 0.303817 0.182598 155 | 1.939612 14.489124 0.085330 0.078187 0.074478 0.425918 0.303819 0.181884 156 | 1.952175 14.489124 0.085330 0.078187 0.074478 0.419788 0.303821 0.181169 157 | 1.964738 14.489124 0.085330 0.078187 0.074478 0.413658 0.303823 0.180455 158 | 1.977301 14.489124 0.085330 0.078187 0.074478 0.407529 0.303825 0.179741 159 | 1.989864 14.489124 0.085330 0.078187 0.074478 0.401399 0.303828 0.179026 160 | 2.002426 14.489124 0.085330 0.078187 0.074478 0.395269 0.303830 0.178312 161 | 2.014989 14.489124 0.085330 0.078187 0.074478 0.389139 0.303832 0.177597 162 | 2.027552 14.489124 0.085330 0.078187 0.074478 0.383009 0.303834 0.176883 163 | 2.040115 14.489124 0.085330 0.078187 0.074478 0.376880 0.303836 0.176168 164 | 2.052678 14.489124 0.085330 0.078187 0.074478 0.370750 0.303838 0.175454 165 | 2.065241 14.489124 0.085330 0.078187 0.074478 0.364620 0.303841 0.174740 166 | 2.077803 14.489124 0.085330 0.078187 0.074478 0.358490 0.303843 0.174025 167 | 2.090366 14.489124 0.085330 0.078187 0.074478 0.352360 0.303845 0.173311 168 | 2.102929 14.489124 0.085330 0.078187 0.074478 0.346231 0.303847 0.172596 169 | 2.115492 14.489124 0.085330 0.078187 0.074478 0.340101 0.303849 0.171882 170 | 2.128055 14.489124 0.085330 0.078187 0.074478 0.333971 0.303852 0.171167 171 | 2.140617 14.489124 0.085330 0.078187 0.074478 0.327841 0.303854 0.170453 172 | 2.153180 14.489124 0.085330 0.078187 0.074478 0.321711 0.303856 0.169738 173 | 2.165743 14.489124 0.085330 0.078187 0.074478 0.315582 0.303858 0.169024 174 | 2.178306 14.489124 0.085330 0.078187 0.074478 0.309452 0.303860 0.168310 175 | 2.190869 14.489124 0.085330 0.078187 0.074478 0.303322 0.303863 0.167595 176 | 2.203431 14.489124 0.085330 0.078187 0.074478 0.297192 0.303865 0.166881 177 | 2.215994 14.489124 0.085330 0.078187 0.074478 0.291062 0.303867 0.166166 178 | 2.228557 14.489124 0.085330 0.078187 0.074478 0.284933 0.303869 0.165452 179 | 2.241120 14.489124 0.085330 0.078187 0.074478 0.278803 0.303871 0.164737 180 | 2.253683 14.489124 0.085330 0.078187 0.074478 0.272673 0.303873 0.164023 181 | 2.266246 14.489124 0.085330 0.078187 0.074478 0.266543 0.303876 0.163308 182 | 2.278808 14.489124 0.085330 0.078187 0.074478 0.260413 0.303878 0.162594 183 | 2.291371 14.489124 0.085330 0.078187 0.074478 0.254284 0.303880 0.161880 184 | 2.303934 14.489124 0.085330 0.078187 0.074478 0.248154 0.303882 0.161165 185 | 2.316497 14.489124 0.085330 0.078187 0.074478 0.242024 0.303884 0.160451 186 | 2.329060 14.489124 0.085330 0.078187 0.074478 0.235894 0.303887 0.159736 187 | 2.341622 14.489124 0.085330 0.078187 0.074478 0.229764 0.303889 0.159022 188 | 2.354185 14.489124 0.085330 0.078187 0.074478 0.223635 0.303891 0.158307 189 | 2.366748 14.489124 0.085330 0.078187 0.074478 0.217505 0.303893 0.157593 190 | 2.379311 14.489124 0.085330 0.078187 0.074478 0.211375 0.303895 0.156879 191 | 2.391874 14.489124 0.085330 0.078187 0.074478 0.205245 0.303897 0.156164 192 | 2.404436 14.489124 0.085330 0.078187 0.074478 0.199115 0.303900 0.155450 193 | 2.416999 14.489124 0.085330 0.078187 0.074478 0.192986 0.303902 0.154735 194 | 2.429562 14.489124 0.085330 0.078187 0.074478 0.186856 0.303904 0.154021 195 | 2.442125 14.489124 0.085330 0.078187 0.074478 0.180726 0.303906 0.153306 196 | 2.454688 14.489124 0.085330 0.078187 0.074478 0.174596 0.303908 0.152592 197 | 2.467251 14.489124 0.085330 0.078187 0.074478 0.168466 0.303911 0.151877 198 | 2.479813 14.489124 0.085330 0.078187 0.074478 0.162337 0.303913 0.151163 199 | 2.492376 14.489124 0.085330 0.078187 0.074478 0.156207 0.303915 0.150449 200 | 2.504939 14.489124 0.085330 0.078187 0.074478 0.150077 0.303917 0.149734 201 | -------------------------------------------------------------------------------- /example/openTerrain/constant/boundaryData/windProfile/sampledData/samplingPoints: -------------------------------------------------------------------------------- 1 | 50 2 | ( 3 | (0.000000 0.000000 0.025000) 4 | (0.000000 0.000000 0.075510) 5 | (0.000000 0.000000 0.126020) 6 | (0.000000 0.000000 0.176531) 7 | (0.000000 0.000000 0.227041) 8 | (0.000000 0.000000 0.277551) 9 | (0.000000 0.000000 0.328061) 10 | (0.000000 0.000000 0.378571) 11 | (0.000000 0.000000 0.429082) 12 | (0.000000 0.000000 0.479592) 13 | (0.000000 0.000000 0.530102) 14 | (0.000000 0.000000 0.580612) 15 | (0.000000 0.000000 0.631122) 16 | (0.000000 0.000000 0.681633) 17 | (0.000000 0.000000 0.732143) 18 | (0.000000 0.000000 0.782653) 19 | (0.000000 0.000000 0.833163) 20 | (0.000000 0.000000 0.883673) 21 | (0.000000 0.000000 0.934184) 22 | (0.000000 0.000000 0.984694) 23 | (0.000000 0.000000 1.035204) 24 | (0.000000 0.000000 1.085714) 25 | (0.000000 0.000000 1.136224) 26 | (0.000000 0.000000 1.186735) 27 | (0.000000 0.000000 1.237245) 28 | (0.000000 0.000000 1.287755) 29 | (0.000000 0.000000 1.338265) 30 | (0.000000 0.000000 1.388776) 31 | (0.000000 0.000000 1.439286) 32 | (0.000000 0.000000 1.489796) 33 | (0.000000 0.000000 1.540306) 34 | (0.000000 0.000000 1.590816) 35 | (0.000000 0.000000 1.641327) 36 | (0.000000 0.000000 1.691837) 37 | (0.000000 0.000000 1.742347) 38 | (0.000000 0.000000 1.792857) 39 | (0.000000 0.000000 1.843367) 40 | (0.000000 0.000000 1.893878) 41 | (0.000000 0.000000 1.944388) 42 | (0.000000 0.000000 1.994898) 43 | (0.000000 0.000000 2.045408) 44 | (0.000000 0.000000 2.095918) 45 | (0.000000 0.000000 2.146429) 46 | (0.000000 0.000000 2.196939) 47 | (0.000000 0.000000 2.247449) 48 | (0.000000 0.000000 2.297959) 49 | (0.000000 0.000000 2.348469) 50 | (0.000000 0.000000 2.398980) 51 | (0.000000 0.000000 2.449490) 52 | (0.000000 0.000000 2.500000) 53 | ); 54 | -------------------------------------------------------------------------------- /example/openTerrain/constant/transportProperties: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: 4.1 | 5 | | \\ / A nd | Web: www.OpenFOAM.org | 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 | #include "../setUp" 19 | 20 | transportModel Newtonian; 21 | 22 | nu [0 2 -1 0 0 0 0] $nu; 23 | 24 | // ************************************************************************* // 25 | -------------------------------------------------------------------------------- /example/openTerrain/constant/turbulenceProperties: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: 4.1 | 5 | | \\ / A nd | Web: www.OpenFOAM.org | 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 LES; 19 | 20 | LES 21 | { 22 | LESModel Smagorinsky; 23 | 24 | turbulence on; 25 | 26 | printCoeffs on; 27 | 28 | delta cubeRootVol; 29 | 30 | dynamicKEqnCoeffs 31 | { 32 | filter simple; 33 | } 34 | 35 | cubeRootVolCoeffs 36 | { 37 | deltaCoeff 1; 38 | } 39 | 40 | PrandtlCoeffs 41 | { 42 | delta cubeRootVol; 43 | cubeRootVolCoeffs 44 | { 45 | deltaCoeff 1; 46 | } 47 | 48 | smoothCoeffs 49 | { 50 | delta cubeRootVol; 51 | cubeRootVolCoeffs 52 | { 53 | deltaCoeff 1; 54 | } 55 | 56 | maxDeltaRatio 1.1; 57 | } 58 | 59 | Cdelta 0.158; 60 | } 61 | 62 | vanDriestCoeffs 63 | { 64 | delta cubeRootVol; 65 | cubeRootVolCoeffs 66 | { 67 | deltaCoeff 1; 68 | } 69 | 70 | smoothCoeffs 71 | { 72 | delta cubeRootVol; 73 | cubeRootVolCoeffs 74 | { 75 | deltaCoeff 1; 76 | } 77 | 78 | maxDeltaRatio 1.1; 79 | } 80 | 81 | Aplus 26; 82 | Cdelta 0.158; 83 | } 84 | 85 | smoothCoeffs 86 | { 87 | delta cubeRootVol; 88 | cubeRootVolCoeffs 89 | { 90 | deltaCoeff 1; 91 | } 92 | 93 | maxDeltaRatio 1.1; 94 | } 95 | } 96 | 97 | 98 | // ************************************************************************* // 99 | -------------------------------------------------------------------------------- /example/openTerrain/setUp: -------------------------------------------------------------------------------- 1 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 2 | // ABL wind simulation in 1:400 scale 3 | // Domain size = 10m x 5m x 2.5m (x-, y-, z-directions ) 4 | 5 | // Domain size and number of cells. 6 | xMin 0.0; // Minimum x-extent of domain (m). 7 | yMin -2.5; // Minimum y-extent of domain (m). 8 | zMin 0.0; // Minimum z-extent of domain (m). 9 | 10 | xMax 10.0; // Maximum x-extent of domain (m). 11 | yMax 2.5; // Maximum y-extent of domain (m). 12 | zMax 2.5; // Maximum z-extent of domain (m). 13 | 14 | nx 100; // Number of cells in x-direction for the whole tunnel. 15 | ny 50; // Number of cells in y-direction side prism layers. 16 | nz 25; // Number of cells in z-direction for top prism layers. 17 | 18 | // Number of cores and domain decomposition information. 19 | nCores 4; // Number of cores on which to run this case. 20 | 21 | // General conditions and parameters. 22 | nu 1.5E-5; // Molecular viscosity (m^2/s). 23 | Uref 13.73; // Reference velocity 24 | z0 7.5E-5; // Surface roughness height 25 | // ************************************************************************* // 26 | -------------------------------------------------------------------------------- /example/openTerrain/system/blockMeshDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: 4.1 | 5 | | \\ / A nd | Web: www.OpenFOAM.org | 6 | | \\/ M anipulation | | 7 | \*---------------------------------------------------------------------------*/ 8 | FoamFile 9 | { 10 | version 2.0; 11 | format ascii; 12 | class dictionary; 13 | object blockMeshDict; 14 | } 15 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 16 | 17 | #include "../setUp" 18 | 19 | convertToMeters 1.0; 20 | 21 | vertices 22 | ( 23 | //Vertices on the ground 24 | ($xMin $yMin $zMin) 25 | ($xMax $yMin $zMin) 26 | ($xMax $yMax $zMin) 27 | ($xMin $yMax $zMin) 28 | 29 | //Vertices on the top surface 30 | ($xMin $yMin $zMax) 31 | ($xMax $yMin $zMax) 32 | ($xMax $yMax $zMax) 33 | ($xMin $yMax $zMax) 34 | ); 35 | 36 | blocks 37 | ( 38 | hex (0 1 2 3 4 5 6 7) ($nx $ny $nz) simpleGrading (1 1 1) 39 | ); 40 | 41 | edges 42 | ( 43 | ); 44 | 45 | boundary 46 | ( 47 | inlet 48 | { 49 | type patch; 50 | faces 51 | ( 52 | (0 4 7 3) 53 | ); 54 | } 55 | outlet 56 | { 57 | type patch; 58 | faces 59 | ( 60 | (2 1 5 6) 61 | ); 62 | } 63 | top 64 | { 65 | type symmetry; 66 | faces 67 | ( 68 | (4 5 6 7) 69 | ); 70 | } 71 | ground 72 | { 73 | type wall; 74 | faces 75 | ( 76 | (0 1 2 3) 77 | ); 78 | } 79 | 80 | front 81 | { 82 | type symmetry; 83 | faces 84 | ( 85 | (0 1 5 4) 86 | ); 87 | } 88 | 89 | back 90 | { 91 | type symmetry; 92 | faces 93 | ( 94 | (3 2 6 7) 95 | ); 96 | } 97 | ); 98 | 99 | mergePatchPairs 100 | ( 101 | ); 102 | 103 | // ************************************************************************* // 104 | -------------------------------------------------------------------------------- /example/openTerrain/system/controlDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: 4.1 | 5 | | \\ / A nd | Web: www.OpenFOAM.org | 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 | 19 | #include "../setUp" 20 | 21 | application pisoFoam; 22 | 23 | startFrom latestTime; 24 | 25 | startTime 0.0; 26 | 27 | stopAt endTime; 28 | 29 | endTime 5.00; 30 | 31 | deltaT 2e-3; 32 | 33 | writeControl timeStep; 34 | 35 | writeInterval 1000; 36 | 37 | purgeWrite 0; 38 | 39 | writeFormat ascii; 40 | 41 | writePrecision 7; 42 | 43 | writeCompression off; 44 | 45 | timeFormat general; 46 | 47 | timePrecision 6; 48 | 49 | runTimeModifiable true; 50 | 51 | libs ("libatmosphericModels.so"); 52 | 53 | functions 54 | { 55 | #includeFunc probes1 56 | #includeFunc probes2 57 | } 58 | 59 | // ************************************************************************* // 60 | -------------------------------------------------------------------------------- /example/openTerrain/system/decomposeParDict: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: 4.1 | 5 | | \\ / A nd | Web: www.OpenFOAM.org | 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 | 19 | #include "../setUp" 20 | 21 | numberOfSubdomains $nCores; 22 | 23 | //Decomposition used for actual simulation. 24 | method scotch; 25 | 26 | //Decomposition used for snappyHexMesh 27 | //method hierarchical; 28 | 29 | hierarchicalCoeffs 30 | { 31 | n (4 8 2); 32 | delta 0.001; 33 | order xyz; 34 | } 35 | // ************************************************************************* // 36 | -------------------------------------------------------------------------------- /example/openTerrain/system/fvSchemes: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: 4.1 | 5 | | \\ / A nd | Web: www.OpenFOAM.org | 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 | 21 | default backward; 22 | //default CrankNicolson 0.9; 23 | } 24 | 25 | gradSchemes 26 | { 27 | default Gauss linear; 28 | } 29 | 30 | divSchemes 31 | { 32 | default none; //Gauss LUST grad(U); 33 | div(phi,U) Gauss LUST grad(U); 34 | div(phi,k) Gauss limitedLinear 1; 35 | div(phi,s) bounded Gauss limitedLinear 1; 36 | div(U) Gauss linear; 37 | div(phi) Gauss linear; 38 | div((nuEff*dev2(T(grad(U))))) Gauss linear; 39 | } 40 | 41 | laplacianSchemes 42 | { 43 | default Gauss linear corrected; 44 | } 45 | 46 | interpolationSchemes 47 | { 48 | default linear; 49 | interpolate(U) linear; 50 | } 51 | 52 | snGradSchemes 53 | { 54 | default corrected; 55 | } 56 | 57 | fluxRequired 58 | { 59 | Phi; 60 | } 61 | 62 | fluxRequired 63 | { 64 | p; 65 | } 66 | 67 | 68 | // ************************************************************************* // 69 | -------------------------------------------------------------------------------- /example/openTerrain/system/fvSolution: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | | ========= | | 3 | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | 4 | | \\ / O peration | Version: 4.1 | 5 | | \\ / A nd | Web: www.OpenFOAM.org | 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 | tolerance 1e-06; 24 | relTol 0.05; 25 | smoother GaussSeidel; 26 | } 27 | 28 | Phi 29 | { 30 | $p 31 | } 32 | 33 | 34 | pFinal 35 | { 36 | $p; 37 | smoother DICGaussSeidel; 38 | relTol 0; 39 | } 40 | 41 | "(U|k|nuTilda)" 42 | { 43 | solver smoothSolver; 44 | smoother symGaussSeidel; 45 | tolerance 1e-05; 46 | relTol 0.1; 47 | } 48 | 49 | "(U|k|nuTilda)Final" 50 | { 51 | $U; 52 | tolerance 1e-05; 53 | relTol 0; 54 | } 55 | } 56 | 57 | PIMPLE 58 | { 59 | nOuterCorrectors 1; 60 | nCorrectors 2; 61 | nNonOrthogonalCorrectors 1; 62 | pRefCell 1001; 63 | pRefValue 0; 64 | } 65 | 66 | PISO 67 | { 68 | nCorrectors 2; 69 | nNonOrthogonalCorrectors 1; 70 | pRefCell 1001; 71 | pRefValue 0; 72 | } 73 | 74 | potentialFlow 75 | { 76 | nNonOrthogonalCorrectors 1; 77 | } 78 | 79 | // ************************************************************************* // 80 | -------------------------------------------------------------------------------- /example/openTerrain/system/probes1: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | Web: www.OpenFOAM.org 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | Description 9 | Writes out values of fields from cells nearest to specified locations. 10 | 11 | \*---------------------------------------------------------------------------*/ 12 | 13 | #includeEtc "caseDicts/postProcessing/probes/probes.cfg" 14 | 15 | type probes; 16 | libs ("libsampling.so"); 17 | writeControl timeStep; 18 | writeInterval 1; 19 | 20 | fields 21 | ( 22 | U 23 | ); 24 | 25 | probeLocations 26 | ( 27 | (0.000000 0.000000 0.025000) 28 | (0.000000 0.000000 0.075510) 29 | (0.000000 0.000000 0.126020) 30 | (0.000000 0.000000 0.176531) 31 | (0.000000 0.000000 0.227041) 32 | (0.000000 0.000000 0.277551) 33 | (0.000000 0.000000 0.328061) 34 | (0.000000 0.000000 0.378571) 35 | (0.000000 0.000000 0.429082) 36 | (0.000000 0.000000 0.479592) 37 | (0.000000 0.000000 0.530102) 38 | (0.000000 0.000000 0.580612) 39 | (0.000000 0.000000 0.631122) 40 | (0.000000 0.000000 0.681633) 41 | (0.000000 0.000000 0.732143) 42 | (0.000000 0.000000 0.782653) 43 | (0.000000 0.000000 0.833163) 44 | (0.000000 0.000000 0.883673) 45 | (0.000000 0.000000 0.934184) 46 | (0.000000 0.000000 0.984694) 47 | (0.000000 0.000000 1.035204) 48 | (0.000000 0.000000 1.085714) 49 | (0.000000 0.000000 1.136224) 50 | (0.000000 0.000000 1.186735) 51 | (0.000000 0.000000 1.237245) 52 | (0.000000 0.000000 1.287755) 53 | (0.000000 0.000000 1.338265) 54 | (0.000000 0.000000 1.388776) 55 | (0.000000 0.000000 1.439286) 56 | (0.000000 0.000000 1.489796) 57 | (0.000000 0.000000 1.540306) 58 | (0.000000 0.000000 1.590816) 59 | (0.000000 0.000000 1.641327) 60 | (0.000000 0.000000 1.691837) 61 | (0.000000 0.000000 1.742347) 62 | (0.000000 0.000000 1.792857) 63 | (0.000000 0.000000 1.843367) 64 | (0.000000 0.000000 1.893878) 65 | (0.000000 0.000000 1.944388) 66 | (0.000000 0.000000 1.994898) 67 | (0.000000 0.000000 2.045408) 68 | (0.000000 0.000000 2.095918) 69 | (0.000000 0.000000 2.146429) 70 | (0.000000 0.000000 2.196939) 71 | (0.000000 0.000000 2.247449) 72 | (0.000000 0.000000 2.297959) 73 | (0.000000 0.000000 2.348469) 74 | (0.000000 0.000000 2.398980) 75 | (0.000000 0.000000 2.449490) 76 | (0.000000 0.000000 2.500000) 77 | ); 78 | 79 | // ************************************************************************* // 80 | -------------------------------------------------------------------------------- /example/openTerrain/system/probes2: -------------------------------------------------------------------------------- 1 | /*--------------------------------*- C++ -*----------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | Web: www.OpenFOAM.org 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | Description 9 | Writes out values of fields from cells nearest to specified locations. 10 | 11 | \*---------------------------------------------------------------------------*/ 12 | 13 | #includeEtc "caseDicts/postProcessing/probes/probes.cfg" 14 | 15 | type probes; 16 | libs ("libsampling.so"); 17 | writeControl timeStep; 18 | writeInterval 1; 19 | 20 | fields 21 | ( 22 | U 23 | ); 24 | 25 | probeLocations 26 | ( 27 | (2.500000 0.000000 0.025000) 28 | (2.500000 0.000000 0.075510) 29 | (2.500000 0.000000 0.126020) 30 | (2.500000 0.000000 0.176531) 31 | (2.500000 0.000000 0.227041) 32 | (2.500000 0.000000 0.277551) 33 | (2.500000 0.000000 0.328061) 34 | (2.500000 0.000000 0.378571) 35 | (2.500000 0.000000 0.429082) 36 | (2.500000 0.000000 0.479592) 37 | (2.500000 0.000000 0.530102) 38 | (2.500000 0.000000 0.580612) 39 | (2.500000 0.000000 0.631122) 40 | (2.500000 0.000000 0.681633) 41 | (2.500000 0.000000 0.732143) 42 | (2.500000 0.000000 0.782653) 43 | (2.500000 0.000000 0.833163) 44 | (2.500000 0.000000 0.883673) 45 | (2.500000 0.000000 0.934184) 46 | (2.500000 0.000000 0.984694) 47 | (2.500000 0.000000 1.035204) 48 | (2.500000 0.000000 1.085714) 49 | (2.500000 0.000000 1.136224) 50 | (2.500000 0.000000 1.186735) 51 | (2.500000 0.000000 1.237245) 52 | (2.500000 0.000000 1.287755) 53 | (2.500000 0.000000 1.338265) 54 | (2.500000 0.000000 1.388776) 55 | (2.500000 0.000000 1.439286) 56 | (2.500000 0.000000 1.489796) 57 | (2.500000 0.000000 1.540306) 58 | (2.500000 0.000000 1.590816) 59 | (2.500000 0.000000 1.641327) 60 | (2.500000 0.000000 1.691837) 61 | (2.500000 0.000000 1.742347) 62 | (2.500000 0.000000 1.792857) 63 | (2.500000 0.000000 1.843367) 64 | (2.500000 0.000000 1.893878) 65 | (2.500000 0.000000 1.944388) 66 | (2.500000 0.000000 1.994898) 67 | (2.500000 0.000000 2.045408) 68 | (2.500000 0.000000 2.095918) 69 | (2.500000 0.000000 2.146429) 70 | (2.500000 0.000000 2.196939) 71 | (2.500000 0.000000 2.247449) 72 | (2.500000 0.000000 2.297959) 73 | (2.500000 0.000000 2.348469) 74 | (2.500000 0.000000 2.398980) 75 | (2.500000 0.000000 2.449490) 76 | (2.500000 0.000000 2.500000) 77 | ); 78 | 79 | // ************************************************************************* // 80 | -------------------------------------------------------------------------------- /files/velocityPlots.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/abiyfantaye/DFSR/6a4ac43dd315db71a4cbd980e19be15d31433cb0/files/velocityPlots.png -------------------------------------------------------------------------------- /src/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "DFSRTurb.C": "cpp" 4 | } 5 | } -------------------------------------------------------------------------------- /src/DFSRTurb/Allwclean: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | wclean libso windProfile 4 | wclean libso extrudedPatch 5 | wclean 6 | 7 | -------------------------------------------------------------------------------- /src/DFSRTurb/Allwmake: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd ${0%/*} || exit 1 # Run from this directory 3 | 4 | # Parse arguments for library compilation 5 | . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments 6 | 7 | wmake $targetType windProfile 8 | wmake $targetType extrudedPatch 9 | wmake $targetType 10 | 11 | #------------------------------------------------------------------------------ 12 | -------------------------------------------------------------------------------- /src/DFSRTurb/DFSRTurb.C: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | 5 | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is part of OpenFOAM. 10 | 11 | OpenFOAM is free software: you can redistribute it and/or modify it 12 | under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 17 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 18 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 19 | for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with OpenFOAM. If not, see . 23 | 24 | Application 25 | SRFGTurb 26 | 27 | Description 28 | DFSR is a synthetic inflow turbulence generation method tailored to 29 | computational wind engineering applications. The technique uses the 30 | spectral representation method to generate ABL-like turbulence with 31 | prescribed two-point flow statistics. Once the turbulence is generated, 32 | the method performs a posteriori divergence-free operation on it so 33 | that the continuity equation is satisfied. 34 | 35 | Reference: 36 | \verbatim 37 | Melaku, A.F. and Bitsuamlak, G.T., 2021. 38 | A divergence-free inflow turbulence generator using spectral 39 | representation method for large-eddy simulation of ABL flows. 40 | 41 | Journal of Wind Engineering and Industrial Aerodynamics, 212, p.104580. 42 | \endverbatim 43 | 44 | \*---------------------------------------------------------------------------*/ 45 | 46 | #include "argList.H" 47 | #include "fvCFD.H" 48 | #include "nonOrthogonalSolutionControl.H" 49 | #include "OFstream.H" 50 | #include "IFstream.H" 51 | #include "windProfile.H" 52 | #include "extrudedPatch.H" 53 | #include "IPstream.H" 54 | #include "OPstream.H" 55 | #include "fftw3.h" 56 | #include "mkl.h" 57 | #include "Pstream.H" 58 | #include "PrimitivePatch.H" 59 | #include "PatchTools.H" 60 | #include "surfaceWriter.H" 61 | #include "mathematicalConstants.H" 62 | #include "fixedGradientFvPatchFields.H" 63 | #include "pointToPointPlanarInterpolation.H" 64 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 65 | 66 | using namespace Foam; 67 | 68 | #include "functions.H" 69 | 70 | int main(int argc, char *argv[]) 71 | { 72 | #include "setRootCase.H" 73 | #include "createTime.H" 74 | #include "createMesh.H" 75 | #include "readDFSRTurbDict.H" 76 | 77 | //Initialize the necessary parameters. 78 | #include "initialize.H" 79 | 80 | //Generate the turbulence for each componet separately 81 | while(cmpt < nCmpt) 82 | { 83 | // Perform the Cholesky decomposition of the CPSD matrix. 84 | #include "decomposeMatrix.H" 85 | 86 | // Perform the time series generation. 87 | #include "generateInflow.H" 88 | 89 | cmpt++; 90 | } 91 | //Setup files to write the output 92 | #include "setupWritePaths.H" 93 | 94 | //Create temporary inlet mesh for div-free correction 95 | #include "createInletMesh.H" 96 | 97 | // Create fields needed for div-free correction 98 | #include "createInletFields.H" 99 | 100 | 101 | while (runTime.run()) 102 | { 103 | Info<< "Time = " << runTime.timeName() << nl << endl; 104 | 105 | //Applies the divergence free corrections. 106 | #include "correctDivergence.H" 107 | 108 | //Writes the generated turbulence 109 | #include "write.H" 110 | 111 | Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" 112 | << " ClockTime = " << runTime.elapsedClockTime() << " s" 113 | << nl << endl; 114 | 115 | runTime++; 116 | } 117 | 118 | Info<<"\nEnd "<< nl << nl; 119 | 120 | return 0; 121 | } 122 | 123 | // ************************************************************************* // 124 | 125 | 126 | -------------------------------------------------------------------------------- /src/DFSRTurb/Make/files: -------------------------------------------------------------------------------- 1 | DFSRTurb.C 2 | 3 | EXE = $(FOAM_USER_APPBIN)/DFSRTurb 4 | -------------------------------------------------------------------------------- /src/DFSRTurb/Make/options: -------------------------------------------------------------------------------- 1 | EXE_INC = \ 2 | -I/usr/local/include \ 3 | -I./windProfile/lnInclude \ 4 | -I./extrudedPatch/lnInclude \ 5 | -I$(LIB_SRC)/finiteVolume/lnInclude \ 6 | -I$(LIB_SRC)/meshTools/lnInclude \ 7 | -I$(LIB_SRC)/sampling/lnInclude \ 8 | -I$(LIB_SRC)/surfMesh/lnInclude \ 9 | -I$(MKLROOT)/include 10 | 11 | EXE_LIBS = \ 12 | -L/usr/local/include \ 13 | -lwindProfile \ 14 | -lextrudedPatch \ 15 | -lmeshTools \ 16 | -lsampling \ 17 | -lsurfMesh \ 18 | -lfiniteVolume \ 19 | -lfftw3 \ 20 | -L$(MKLROOT)/lib/intel64 -lmkl_intel_lp64 \ 21 | -L$(MKLROOT)/lib/intel64 -lmkl_core \ 22 | -L$(MKLROOT)/lib/intel64 -lmkl_sequential \ 23 | -lm \ 24 | -ldl 25 | -------------------------------------------------------------------------------- /src/DFSRTurb/correctDivergence.H: -------------------------------------------------------------------------------- 1 | Ut = vector::zero; 2 | 3 | forAll(facesIndx, i) 4 | { 5 | Ut[facesIndx[i]] = allU[runTime.timeIndex()][i]; 6 | } 7 | 8 | reduce(Ut, sumOp()); 9 | 10 | //Free-up previous time-step 11 | //incase more memory is needed 12 | allU[runTime.timeIndex()].clear(); 13 | 14 | if(correctDivergence) 15 | { 16 | Ut -= flowDir*(sum(Ut*faceAreas).x()/totArea); 17 | 18 | if(runTime.timeIndex() == 1) 19 | { 20 | Ut0 = Ut; 21 | } 22 | 23 | forAll(mergedFaces, celli) 24 | { 25 | U[celli] = Ut[celli]; 26 | } 27 | 28 | U.boundaryFieldRef()[0] == U.boundaryField()[0].patchInternalField(); 29 | U.boundaryFieldRef()[1] == inletMapper.interpolate((0.5*(Ut0 + Ut))()); 30 | 31 | //BC for Phi on the side faces. 32 | ////Used to set the gradient to specific values so that wall-normal flow is suppressed 33 | fixedGradientFvPatchScalarField& PhiSidesFvPatch = refCast(Phi.boundaryFieldRef()[0]); 34 | 35 | PhiSidesFvPatch.gradient() = U.boundaryField()[0] & sidesPatch.faceNormals(); 36 | 37 | phi = fvc::flux(U); 38 | 39 | adjustPhi(phi, U, p); 40 | 41 | Info<< "DFSR: Applying divergence-free corrections..." << nl; 42 | 43 | // Non-orthogonal velocity potential corrector loop 44 | while (potentialFlow.correctNonOrthogonal()) 45 | { 46 | fvScalarMatrix PhiEqn 47 | ( 48 | fvm::laplacian(dimensionedScalar(dimless, 1), Phi) 49 | == 50 | fvc::div(phi) 51 | ); 52 | 53 | PhiEqn.setReference(PhiRefCell, PhiRefValue); 54 | 55 | PhiEqn.solve(); 56 | 57 | if(potentialFlow.finalNonOrthogonalIter()) 58 | { 59 | phi -= PhiEqn.flux(); 60 | } 61 | } 62 | 63 | Info<< "Continuity error = " 64 | << mag(fvc::div(phi))().weightedAverage(inletMesh.V()).value() 65 | << endl; 66 | 67 | //Reconstruct velocity back from 68 | //corrected face fluxes 69 | U = fvc::reconstruct(phi); 70 | 71 | 72 | forAll(mergedFaces, celli) 73 | { 74 | Ut[celli] = U[celli]; 75 | } 76 | 77 | Ut0 = Ut; 78 | } 79 | 80 | //Add mean to the fluctuations 81 | Ut += allUav; 82 | 83 | -------------------------------------------------------------------------------- /src/DFSRTurb/createInletFields.H: -------------------------------------------------------------------------------- 1 | //Create fields at the inlet needed for div-free operation 2 | //Boundary conditions for Phi and U 3 | wordList PhiBCTypes(3); 4 | wordList UBCTypes(3); 5 | 6 | //Boundary condition for Phi and 7 | PhiBCTypes[0] = "fixedGradient"; //sides dl/dx = 0, dl/dy = -Uy, dl/dz = -Uz 8 | PhiBCTypes[1] = "zeroGradient"; //inlet 9 | PhiBCTypes[2] = "fixedValue"; //outlet 10 | 11 | UBCTypes[0] = "slip"; //sides dl/dx = 0, dl/dy = -Uy, dl/dz = -Uz 12 | UBCTypes[1] = "fixedValue"; //inlet 13 | UBCTypes[2] = "zeroGradient"; //outlet 14 | 15 | //Constructing velocity potential field Phi 16 | volScalarField Phi 17 | ( 18 | IOobject 19 | ( 20 | "Phi", 21 | runTime.timeName(), 22 | inletMesh, 23 | IOobject::NO_READ, 24 | IOobject::NO_WRITE 25 | ), 26 | inletMesh, 27 | dimensionedScalar("Phi", dimLength*dimVelocity, 0.0), 28 | PhiBCTypes 29 | ); 30 | 31 | //Instantaneous velocity on all the cell/face centers 32 | volVectorField U 33 | ( 34 | IOobject 35 | ( 36 | "U", 37 | runTime.timeName(), 38 | inletMesh, 39 | IOobject::NO_READ, 40 | IOobject::NO_WRITE 41 | ), 42 | inletMesh, 43 | dimensionedVector("U", dimVelocity, vector::zero), 44 | UBCTypes 45 | ); 46 | 47 | //Creating face fluxes. 48 | surfaceScalarField phi 49 | ( 50 | IOobject 51 | ( 52 | "phi", 53 | runTime.timeName(), 54 | inletMesh, 55 | IOobject::NO_READ, 56 | IOobject::NO_WRITE 57 | ), 58 | fvc::flux(U) 59 | ); 60 | 61 | //Create pressure field 62 | volScalarField p 63 | ( 64 | IOobject 65 | ( 66 | "p", 67 | runTime.timeName(), 68 | inletMesh, 69 | IOobject::NO_READ, 70 | IOobject::NO_WRITE 71 | ), 72 | inletMesh, 73 | dimensionedScalar("p", sqr(dimVelocity), 0.0), 74 | PhiBCTypes 75 | ); 76 | 77 | label PhiRefCell = -Pstream::myProcNo(); 78 | scalar PhiRefValue = 0; 79 | 80 | 81 | //Instantaneous velocity at time t and t_(n-1) 82 | vectorField Ut(n, vector::zero); 83 | vectorField Ut0(n, vector::zero); 84 | -------------------------------------------------------------------------------- /src/DFSRTurb/createInletMesh.H: -------------------------------------------------------------------------------- 1 | //Reverse face normals so that the extruded mesh 2 | //extends in the positive x-direction 3 | forAll(mergedFaces, facei) 4 | { 5 | mergedFaces[facei] = reverseList(mergedFaces[facei]); 6 | } 7 | 8 | //Create a primitive patch for the inlet 9 | const PrimitivePatch inletPatch 10 | ( 11 | mergedFaces, 12 | mergedPoints 13 | ); 14 | 15 | const IOobject io 16 | ( 17 | Foam::fvMesh::defaultRegion, 18 | runTime.timeName(), 19 | runTime, 20 | Foam::IOobject::MUST_READ 21 | ); 22 | 23 | //Mean velocity at all face centers 24 | const vectorField allUav = prof.getUav(faceCentres); 25 | 26 | dimensionedVector Ubar("Ubar", dimVelocity, sum(faceAreas*allUav)/totArea); 27 | 28 | //Approximate mesh size in x-direction 29 | const scalar dx = dt*mag(Ubar).value(); 30 | 31 | //Number of layers for the temp mesh 32 | const label nLayers = 1; 33 | 34 | //Created extruded mesh geometry 35 | extrudedPatch infExtrude(io, inletPatch, nLayers, dx); 36 | 37 | fvMesh inletMesh 38 | ( 39 | io, 40 | pointField(infExtrude.points()), 41 | faceList(infExtrude.faces()), 42 | cellList(infExtrude.cells()), 43 | false 44 | ); 45 | 46 | //Add fvPatchs 47 | inletMesh.addFvPatches(infExtrude.patches(inletPatch, nLayers)); 48 | 49 | //Poly mesh at each face 50 | const polyPatch& sidesPatch = inletMesh.boundaryMesh()["sides"]; 51 | const polyPatch& inflowPatch = inletMesh.boundaryMesh()["inflowPatch"]; 52 | 53 | //Interplation method 54 | const bool nearestOnly = true; 55 | 56 | const scalar perturbation = 1.0e-6; 57 | 58 | // Allocate the interpolator at the inlet 59 | pointToPointPlanarInterpolation inletMapper 60 | ( 61 | faceCentres, 62 | inflowPatch.faceCentres(), 63 | perturbation, 64 | nearestOnly 65 | ); 66 | 67 | nonOrthogonalSolutionControl potentialFlow(mesh, "potentialFlow"); 68 | 69 | -------------------------------------------------------------------------------- /src/DFSRTurb/decomposeMatrix.H: -------------------------------------------------------------------------------- 1 | //The Cholesky decomposition is done using the following simplified form 2 | /* 3 | CPSD = diag(S)*Coh*diag(S) 4 | = diag(S)*Lc*Lc^T*diag(S) 5 | 6 | Where: 7 | Lc: is the Cholesky factorization of the coherency matrix Coh 8 | S: is the auto-power spectrum at each point(size = n) 9 | diag(S) is a diagonal matrix created from S. 10 | 11 | Thus, the Cholesky factorization of the CPSD matrix is computed as: 12 | 13 | L = diag(sqrt(S))*Lc 14 | 15 | Note: This approach prevents the Cholesky factorization from failing due to 16 | non-positive semi-defnitness of the CPSD matrix caused by the inhomogeneity 17 | in the coherency/covariance matrix 18 | */ 19 | 20 | //Compute each entry of the coherency matrix. 21 | 22 | forAll(fInterp, f) 23 | { 24 | //Form and decompose the coherency matrix in 25 | //the master processor. 26 | 27 | if(Pstream::master()) 28 | { 29 | forAll(faceCentres, i) 30 | { 31 | for (int j=0; j <= i; j++) 32 | { 33 | Lc[j + i*(i+1)/2] = Coh(fInterp[f], cohUav, C, faceCentres[j] - faceCentres[i], cmpt); 34 | } 35 | } 36 | 37 | //Compute the Cholesky factorization using LAPACKE subroutine 38 | //Uses a packed matrix storage. 39 | int info = LAPACKE_dpptrf(LAPACK_ROW_MAJOR, 'L', n , Lc.data()); 40 | 41 | //If decomposition fail, show error message and exit. 42 | if(info) 43 | { 44 | FatalErrorInFunction 45 | << "ERROR: Cholesky decomposition failed for component: " << cmpt << nl 46 | << exit(FatalError); 47 | } 48 | } 49 | 50 | Pstream::scatter(Lc); 51 | 52 | //Copy the decomposed matrix to H matrix in each processor. 53 | forAll(facesIndx, i) 54 | { 55 | scalar sqrtOfS = ::sqrt(vonK(fInterp[f], mag(Uav[i]), I[i][cmpt], L[i][cmpt], cmpt)); 56 | for (int j=0; j <= facesIndx[i]; j++) 57 | { 58 | H[i*n + j][f] = Lc[j + facesIndx[i]*(facesIndx[i]+1)/2]*sqrtOfS; 59 | } 60 | } 61 | 62 | 63 | Info << "Cholesky decomposition for " << cmptName[cmpt] << " : " << 100*(f + 1.0)/nInterp << "\% completed" << ", f = " << fInterp[f] << nl 64 | << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" 65 | << " ClockTime = " << runTime.elapsedClockTime() << " s" 66 | << nl << endl; 67 | } 68 | 69 | //Free up some space 70 | if(cmpt==nCmpt-1) 71 | { 72 | Lc.clear(); 73 | I.clear(); 74 | L.clear(); 75 | } 76 | -------------------------------------------------------------------------------- /src/DFSRTurb/extrudedPatch/Make/files: -------------------------------------------------------------------------------- 1 | extrudedPatch.C 2 | 3 | LIB = $(FOAM_USER_LIBBIN)/libextrudedPatch 4 | -------------------------------------------------------------------------------- /src/DFSRTurb/extrudedPatch/Make/options: -------------------------------------------------------------------------------- 1 | EXE_INC = \ 2 | -I$(LIB_SRC)/finiteVolume/lnInclude \ 3 | -I$(LIB_SRC)/meshTools/lnInclude \ 4 | -I$(LIB_SRC)/sampling/lnInclude \ 5 | -I$(LIB_SRC)/surfMesh/lnInclude \ 6 | -I$(SCINET_FFTW_BASE)/include 7 | 8 | EXE_LIBS = \ 9 | -lmeshTools \ 10 | -lsampling \ 11 | -lsurfMesh \ 12 | -lfiniteVolume \ 13 | -lfftw3 \ 14 | -L$(SCINET_FFTW_BASE)/lib -lfftw3 -lm 15 | -------------------------------------------------------------------------------- /src/DFSRTurb/extrudedPatch/extrudedPatch.C: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | Website: https://openfoam.org 5 | \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is part of OpenFOAM. 10 | 11 | OpenFOAM is free software: you can redistribute it and/or modify it 12 | under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 17 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 18 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 19 | for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with OpenFOAM. If not, see . 23 | 24 | \*---------------------------------------------------------------------------*/ 25 | 26 | #include "extrudedPatch.H" 27 | 28 | // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // 29 | 30 | bool Foam::extrudedPatch::sameOrder(const face& f, const edge& e) 31 | { 32 | label i = findIndex(f, e[0]); 33 | 34 | label nextI = (i == f.size()-1 ? 0 : i+1); 35 | 36 | return f[nextI] == e[1]; 37 | } 38 | 39 | // ************************************************************************* // 40 | -------------------------------------------------------------------------------- /src/DFSRTurb/extrudedPatch/extrudedPatch.H: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | Website: https://openfoam.org 5 | \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is part of OpenFOAM. 10 | 11 | OpenFOAM is free software: you can redistribute it and/or modify it 12 | under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 17 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 18 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 19 | for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with OpenFOAM. If not, see . 23 | 24 | Class 25 | Foam::extrudedPatch 26 | 27 | Description 28 | 29 | SourceFiles 30 | extrudedPatch.C 31 | extrudedPatchTemplates.C 32 | 33 | \*---------------------------------------------------------------------------*/ 34 | 35 | #ifndef extrudedPatch_H 36 | #define extrudedPatch_H 37 | 38 | #include "polyMesh.H" 39 | 40 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 41 | 42 | namespace Foam 43 | { 44 | 45 | /*---------------------------------------------------------------------------*\ 46 | Class extrudedPatch Declaration 47 | \*---------------------------------------------------------------------------*/ 48 | 49 | class extrudedPatch 50 | : 51 | public polyMesh 52 | { 53 | // Private Member Functions 54 | 55 | //- Do edge and face use points in same order? 56 | static bool sameOrder(const face&, const edge&); 57 | 58 | //- Construct and return the extruded mesh points 59 | template 60 | pointField extrudedPoints 61 | ( 62 | const PrimitivePatch& extrudePatch, 63 | const label nLayers, 64 | const scalar dx 65 | ); 66 | 67 | //- Construct and return the extruded mesh faces 68 | template 69 | faceList extrudedFaces 70 | ( 71 | const PrimitivePatch& extrudePatch, 72 | const label nLayers 73 | ); 74 | 75 | //- Construct and return the extruded mesh cells 76 | template 77 | cellList extrudedCells 78 | ( 79 | const PrimitivePatch& extrudePatch, 80 | const label nLayers 81 | ); 82 | 83 | 84 | public: 85 | 86 | // Constructors 87 | 88 | //- Construct from the primitivePatch to extrude 89 | template 90 | extrudedPatch 91 | ( 92 | const IOobject&, 93 | const PrimitivePatch& extrudePatch, 94 | const label nLayers, 95 | const scalar dx 96 | ); 97 | 98 | //- Disallow default bitwise copy construction 99 | extrudedPatch(const extrudedPatch&) = delete; 100 | 101 | 102 | // Member Operators 103 | 104 | //- Disallow default bitwise assignment 105 | void operator=(const extrudedPatch&) = delete; 106 | 107 | template 108 | List patches 109 | ( 110 | const PrimitivePatch& extrudePatch, 111 | const label nLayers 112 | ); 113 | }; 114 | 115 | 116 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 117 | 118 | } // End namespace Foam 119 | 120 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 121 | 122 | #ifdef NoRepository 123 | #include "extrudedPatchTemplates.C" 124 | #endif 125 | 126 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 127 | 128 | #endif 129 | 130 | // ************************************************************************* // 131 | -------------------------------------------------------------------------------- /src/DFSRTurb/extrudedPatch/extrudedPatchTemplates.C: -------------------------------------------------------------------------------- 1 | /*---------------------------------------------------------------------------*\ 2 | ========= | 3 | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 4 | \\ / O peration | Website: https://openfoam.org 5 | \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation 6 | \\/ M anipulation | 7 | ------------------------------------------------------------------------------- 8 | License 9 | This file is part of OpenFOAM. 10 | 11 | OpenFOAM is free software: you can redistribute it and/or modify it 12 | under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 17 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 18 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 19 | for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with OpenFOAM. If not, see . 23 | 24 | \*---------------------------------------------------------------------------*/ 25 | 26 | #include "extrudedPatch.H" 27 | #include "wallPolyPatch.H" 28 | 29 | // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // 30 | template 31 | Foam::pointField Foam::extrudedPatch::extrudedPoints 32 | ( 33 | const PrimitivePatch& extrudePatch, 34 | const label nLayers, 35 | const scalar dx 36 | ) 37 | { 38 | const pointField& surfacePoints = extrudePatch.localPoints(); 39 | const vectorField& surfaceNormals = extrudePatch.pointNormals(); 40 | 41 | // const label nLayers = 1; 42 | 43 | pointField ePoints((nLayers + 1)*surfacePoints.size()); 44 | 45 | for (label layer=0; layer<=nLayers; layer++) 46 | { 47 | label offset = layer*surfacePoints.size(); 48 | 49 | forAll(surfacePoints, i) 50 | { 51 | ePoints[offset + i] = surfacePoints[i] + dx*layer*surfaceNormals[i]; 52 | } 53 | } 54 | 55 | return ePoints; 56 | } 57 | 58 | template 59 | Foam::faceList Foam::extrudedPatch::extrudedFaces 60 | ( 61 | const PrimitivePatch& extrudePatch, 62 | const label nLayers 63 | 64 | ) 65 | { 66 | const pointField& surfacePoints = extrudePatch.localPoints(); 67 | const List& surfaceFaces = extrudePatch.localFaces(); 68 | const edgeList& surfaceEdges = extrudePatch.edges(); 69 | const label nInternalEdges = extrudePatch.nInternalEdges(); 70 | 71 | // const label nLayers = 1; 72 | 73 | label nFaces = 74 | (nLayers + 1)*surfaceFaces.size() + nLayers*surfaceEdges.size(); 75 | 76 | faceList eFaces(nFaces); 77 | 78 | labelList quad(4); 79 | label facei = 0; 80 | 81 | // Internal faces 82 | for (label layer=0; layer 184 | Foam::cellList Foam::extrudedPatch::extrudedCells 185 | ( 186 | const PrimitivePatch& extrudePatch, 187 | const label nLayers 188 | ) 189 | { 190 | const List& surfaceFaces = extrudePatch.localFaces(); 191 | const edgeList& surfaceEdges = extrudePatch.edges(); 192 | const label nInternalEdges = extrudePatch.nInternalEdges(); 193 | 194 | // const label nLayers = 1; 195 | 196 | cellList eCells(nLayers*surfaceFaces.size()); 197 | 198 | 199 | // Size the cells 200 | forAll(surfaceFaces, i) 201 | { 202 | const face& f = surfaceFaces[i]; 203 | 204 | for (label layer=0; layer 289 | Foam::List Foam::extrudedPatch::patches 290 | ( 291 | const PrimitivePatch& extrudePatch, 292 | const label nLayers 293 | 294 | ) 295 | { 296 | List patches(3); 297 | 298 | label facei = nInternalFaces(); 299 | 300 | label sz = nLayers*(extrudePatch.nEdges() - extrudePatch.nInternalEdges()); 301 | 302 | patches[0] = new polyPatch 303 | ( 304 | "sides", 305 | sz, 306 | facei, 307 | 0, 308 | boundaryMesh(), 309 | polyPatch::typeName 310 | ); 311 | 312 | facei += sz; 313 | 314 | patches[1] = new polyPatch 315 | ( 316 | "inflowPatch", 317 | extrudePatch.size(), 318 | facei, 319 | 1, 320 | boundaryMesh(), 321 | polyPatch::typeName 322 | ); 323 | 324 | facei += extrudePatch.size(); 325 | 326 | patches[2] = new polyPatch 327 | ( 328 | "outflowPatch", 329 | extrudePatch.size(), 330 | facei, 331 | 2, 332 | boundaryMesh(), 333 | polyPatch::typeName 334 | ); 335 | 336 | 337 | return patches; 338 | } 339 | 340 | // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // 341 | template 342 | Foam::extrudedPatch::extrudedPatch 343 | ( 344 | const IOobject& io, 345 | const PrimitivePatch& extrudePatch, 346 | const label nLayers, 347 | const scalar dx 348 | ) 349 | : 350 | polyMesh 351 | ( 352 | io, 353 | extrudedPoints(extrudePatch, nLayers, dx), 354 | extrudedFaces(extrudePatch, nLayers), 355 | extrudedCells(extrudePatch, nLayers) 356 | ) 357 | { 358 | 359 | addPatches(patches(extrudePatch, nLayers)); 360 | } 361 | 362 | 363 | // ************************************************************************* // 364 | -------------------------------------------------------------------------------- /src/DFSRTurb/functions.H: -------------------------------------------------------------------------------- 1 | //- Returns the von Karman spectrum for component: cmpt 2 | // mean velocity(Uav), turbulence intensity(I) and length scales(L) 3 | inline scalar vonK 4 | ( 5 | const scalar f, 6 | const scalar Uav, 7 | const scalar I, 8 | const scalar L, 9 | const label cmpt 10 | 11 | ) 12 | { 13 | if(cmpt==0) 14 | { 15 | return 4*::pow(I*Uav, 2)*(L/Uav)/::pow(1 + 70.8*::pow(f*L/Uav, 2), 5.0/6.0); 16 | } 17 | else 18 | { 19 | return 4*::pow(I*Uav, 2)*(L/Uav)*(1 + 188.4*::pow(2*f*L/Uav, 2))/::pow(1.0 + 70.8*::pow(2*f*L/Uav, 2), 11.0/6.0); 20 | } 21 | } 22 | 23 | 24 | //- Returns the coherency vector for a given freqquency, 25 | // coherency decay coefficient(C), mean velocity(Uav), and deference between points(p1, p2). 26 | inline scalar Coh 27 | ( 28 | const scalar f, 29 | const scalar Uav, 30 | const tensor& C, 31 | const vector& dp, 32 | const label cmpt 33 | ) 34 | { 35 | return ::exp(-f*::mag(cmptMultiply(C.vectorComponent(cmpt), dp))/Uav); 36 | } 37 | 38 | //Interplates a given vectorField with cubic splines 39 | scalar interpolateSpline 40 | ( 41 | scalar x, 42 | scalarField& xOld, 43 | scalarField& yOld 44 | ) 45 | { 46 | label n = xOld.size(); 47 | 48 | // early exit if out of bounds or only one value 49 | if (n == 1 || x < xOld[0]) 50 | { 51 | return yOld[0]; 52 | } 53 | if (x > xOld[n - 1]) 54 | { 55 | return yOld[n - 1]; 56 | } 57 | 58 | // linear interpolation if only two values 59 | if (n == 2) 60 | { 61 | return (x - xOld[0])/(xOld[1] - xOld[0])*(yOld[1] - yOld[0]) + yOld[0]; 62 | } 63 | 64 | // find bounding knots 65 | label hi = 0; 66 | while (hi < n && xOld[hi] < x) 67 | { 68 | hi++; 69 | } 70 | 71 | label lo = hi - 1; 72 | 73 | const scalar y1 = yOld[lo]; 74 | const scalar y2 = yOld[hi]; 75 | 76 | scalar y0; 77 | if (lo == 0) 78 | { 79 | y0 = 2*y1 - y2; 80 | } 81 | else 82 | { 83 | y0 = yOld[lo - 1]; 84 | } 85 | 86 | scalar y3; 87 | if (hi + 1 == n) 88 | { 89 | y3 = 2*y2 - y1; 90 | } 91 | else 92 | { 93 | y3 = yOld[hi + 1]; 94 | } 95 | 96 | // weighting 97 | scalar mu = (x - xOld[lo])/(xOld[hi] - xOld[lo]); 98 | 99 | // interpolate 100 | return 101 | 0.5 102 | *( 103 | 2*y1 104 | + mu 105 | *( 106 | -y0 + y2 107 | + mu*((2*y0 - 5*y1 + 4*y2 - y3) + mu*(-y0 + 3*y1 - 3*y2 + y3)) 108 | ) 109 | ); 110 | } 111 | -------------------------------------------------------------------------------- /src/DFSRTurb/generateInflow.H: -------------------------------------------------------------------------------- 1 | //Fill the double indexed phase angles 2 | if(Pstream::master()) 3 | { 4 | //Pick a random phase angels from a uniform distribution 5 | //in the interval [0.0, 2*pi] 6 | for(int m = 0; m < n ; m++) 7 | { 8 | for(int l = 0; l < nFreq ; l++) 9 | { 10 | sinPhi[m*nFreq + l] = twopi*rand.sample01(); 11 | 12 | cosPhi[m*nFreq + l] = ::cos(sinPhi[m*nFreq + l]); 13 | sinPhi[m*nFreq + l] = ::sin(sinPhi[m*nFreq + l]); 14 | } 15 | } 16 | } 17 | 18 | Pstream::scatter(sinPhi); 19 | Pstream::scatter(cosPhi); 20 | 21 | //Simulate the velocity at each point using FFT 22 | for (label i = 0; i < nLoc; i++) 23 | { 24 | label j = facesIndx[i]; 25 | 26 | for (label m = 0; m <= j; m++) 27 | { 28 | for(label l = 0; l < M; l++) 29 | { 30 | if(l < nFreq) 31 | { 32 | Hjm = sqrt2df*interpolateSpline((l + (m + 1.0)/n)*df, fInterp, H[i*n + m]); 33 | 34 | B[l][0] = Hjm*cosPhi[l*n + m]; 35 | B[l][1] = Hjm*sinPhi[l*n + m]; 36 | 37 | } 38 | else 39 | { 40 | B[l][0] = 0.0; 41 | B[l][1] = 0.0; 42 | } 43 | } 44 | 45 | pln = fftw_plan_dft_1d(M, B, D, FFTW_BACKWARD, FFTW_ESTIMATE); 46 | 47 | fftw_execute(pln); 48 | 49 | fftw_destroy_plan(pln); 50 | 51 | freq = dt*twopi*(m + 1.0)*df/n; 52 | 53 | //It's assumed that Nt < M*N 54 | for (label t = 0; t < Nt; t++) 55 | { 56 | allU[t][i][cmpt] += (D[t%M][0]*::cos(t*freq) - D[t%M][1]*::sin(t*freq)); 57 | } 58 | } 59 | 60 | Info << "Generating for " << cmptName[cmpt] << " : "<< (i + 1)*Pstream::nProcs() << " points out of " << n << nl 61 | << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" 62 | << " ClockTime = " << runTime.elapsedClockTime() << " s" 63 | << nl << endl; 64 | 65 | } 66 | 67 | if(cmpt == nCmpt-1) 68 | { 69 | //Clear variables that are not needed anymore 70 | cosPhi.clear(); 71 | sinPhi.clear(); 72 | H.clear(); 73 | 74 | //Free FFTW space 75 | fftw_free(B); 76 | fftw_free(D); 77 | 78 | // //Add meant to the fluctuation 79 | // for(label t = 0; t < Nt; t++) 80 | // { 81 | // allU[t] += Uav; 82 | // } 83 | } -------------------------------------------------------------------------------- /src/DFSRTurb/initialize.H: -------------------------------------------------------------------------------- 1 | //Flow direction 2 | const vector flowDir(1.0, 0.0, 0.0); 3 | 4 | //Get reference of the polyPatch at the inlet 5 | const polyPatch& pPatch = mesh.boundaryMesh()[patchName]; 6 | 7 | const PrimitivePatch priPatch 8 | ( 9 | pPatch.localFaces(), 10 | pPatch.localPoints() 11 | ); 12 | 13 | //The big mesh file is not needed anymore, 14 | //clear it out to save memory 15 | mesh.clearOut(); 16 | 17 | const scalar mergeDist = 1.0e-10; 18 | pointField mergedPoints; 19 | faceList mergedFaces; 20 | labelList pointMap; 21 | 22 | //Merge faces and points in the master 23 | Foam::PatchTools::gatherAndMerge 24 | ( 25 | mergeDist, 26 | priPatch, 27 | mergedPoints, 28 | mergedFaces, 29 | pointMap 30 | ); 31 | 32 | pointField faceCentres; 33 | scalarField faceAreas; 34 | 35 | if(Pstream::master()) 36 | { 37 | //Calculate face centers and areas 38 | faceCentres = pointField(mergedFaces.size()); 39 | faceAreas = scalarField(mergedFaces.size()); 40 | 41 | forAll(mergedFaces, facei) 42 | { 43 | faceCentres[facei] = mergedFaces[facei].centre(mergedPoints); 44 | faceAreas[facei] = mergedFaces[facei].mag(mergedPoints); 45 | } 46 | 47 | //Sort points by distance from the first point 48 | //Helps to make the CPSD matrix diagonally dominant 49 | SortableList distance(mag(faceCentres-faceCentres[0])); 50 | 51 | faceList facesCopy = mergedFaces; 52 | pointField centresCopy = faceCentres; 53 | scalarField areasCopy = faceAreas; 54 | 55 | 56 | //Fill sorted cells; 57 | forAll(faceCentres, i) 58 | { 59 | faceCentres[i] = centresCopy[distance.indices()[i]]; 60 | faceAreas[i] = areasCopy[distance.indices()[i]]; 61 | mergedFaces[i] = facesCopy[distance.indices()[i]]; 62 | } 63 | } 64 | 65 | Pstream::scatter(faceCentres); 66 | Pstream::scatter(faceAreas); 67 | 68 | //Total face area 69 | const scalar totArea = sum(faceAreas); 70 | 71 | const label n = faceCentres.size(); 72 | Info << "\nNumber of faces on the patch = " << n << nl << nl; 73 | 74 | //Local points on the processor 75 | vectorField locCenters(0); 76 | 77 | //Local face centers on the processor 78 | labelList facesIndx(0); 79 | 80 | //Fill the local face centers 81 | forAll(faceCentres, i) 82 | { 83 | if(i%Pstream::nProcs() == Pstream::myProcNo()) 84 | { 85 | locCenters.append(faceCentres[i]); 86 | facesIndx.append(i); 87 | } 88 | } 89 | 90 | //Number of points on local processor 91 | const label nLoc = locCenters.size(); 92 | 93 | //Get mean U, I, L from the ABL profile. 94 | vectorField Uav = prof.getUav(locCenters); 95 | vectorField I = prof.getI(locCenters); 96 | vectorField L = prof.getL(locCenters); 97 | 98 | //Scale the turbulence intensity and length scales 99 | //by the desired factors to account for the 100 | //decay of turbulence downstream. 101 | for(label i=0; iH(n*nLoc, scalarField(nInterp, 0.0)); 159 | 160 | //List to store the generated time series 161 | List allU(Nt, vectorField(nLoc, vector::zero)); 162 | 163 | //Number of frequencies in the FFT 164 | label M(2*nFreq); 165 | 166 | //Arrays to hold inverse FFT variables. 167 | fftw_complex *B, *D; 168 | 169 | B = static_cast(fftw_malloc(sizeof(fftw_complex) * M)); 170 | D = static_cast(fftw_malloc(sizeof(fftw_complex) * M)); 171 | 172 | //FFTW plans 173 | fftw_plan pln; 174 | 175 | //Other params needed in the FFT 176 | scalar sqrt2df = ::sqrt(2.0*df); 177 | scalar Hjm, freq; 178 | 179 | -------------------------------------------------------------------------------- /src/DFSRTurb/readDFSRTurbDict.H: -------------------------------------------------------------------------------- 1 | Info<< "Reading DFSRTurbDict\n" << endl; 2 | 3 | // IO object to read the DFSRTurb Dictionary 4 | IOdictionary DFSRTurbDict 5 | ( 6 | IOobject 7 | ( 8 | "DFSRTurbDict", 9 | runTime.constant(), 10 | runTime, 11 | IOobject::MUST_READ, 12 | IOobject::NO_WRITE 13 | ) 14 | ); 15 | 16 | //Maximum frequency of the simulation. 17 | const scalar fMax(DFSRTurbDict.lookup("fMax")); 18 | 19 | //Time step for the inflow. 20 | scalar dt (DFSRTurbDict.lookup("timeStep")); 21 | 22 | //Start time of the inflow. 23 | const scalar startTime (DFSRTurbDict.lookupOrDefault("startTime", 0.0)); 24 | 25 | //End time for the inflow. 26 | const scalar endTime (DFSRTurbDict.lookup("endTime")); 27 | 28 | if(dt != 1.0/(2*fMax)) 29 | { 30 | dt = 1.0/(2*fMax); 31 | 32 | Info << "Warning: timeStep must be 1/(2*fMax) to use FFT! \n" 33 | << "\t timeStep set to: " << dt << nl << endl; 34 | } 35 | 36 | //Number of time steps, 2 is added to include begining and end times. 37 | const label Nt = round((endTime - startTime)/dt) + 1; 38 | 39 | //Set run time based on DFSRTurbDict 40 | runTime.setTime(startTime, 0); 41 | runTime.setDeltaT(dt); 42 | runTime.setEndTime(endTime); 43 | 44 | //Number of frequency segments 45 | const label nFreq(DFSRTurbDict.lookup