
[Sponsors] 
simpleFoam tutorial PitzDaily using Reynolds stress tensor (LRR RASModel) 

LinkBack  Thread Tools  Search this Thread  Display Modes 
May 28, 2020, 04:45 
simpleFoam tutorial PitzDaily using Reynolds stress tensor (LRR RASModel)

#1 
Senior Member

Abstract
The objective of this humble endeavor is to describe how the celebrated PitzDaily incompressible tutorial (or any its variants) for simpleFoam can be extended with a Reynold stress tensor model for turbulence. This endeavor has been pursued by many (including the giants in this community) in the past and is by no means new. Our endeavor can in fact be stated as reproducing the tutorial [1,2] (among possible various others). Our motivation for stirring in this old pot once again is contribute to the documentation on how to setup the case. We wish to complement existing tutorials with our insights. The Reynolds stress model solves for the six (in 2D four) components of the symmetric stress tensor R and the turbulent dissipation epsilon. The magnitude of the tensor R is equal to epsilon. Our biggest takeaway lessons is that the overrelaxation of the equation (should this field?) for epsilon is essential to obtain convergence of the model. 1/ Introduction We aim at extending the PitzDaily incompressible tutorial for simpleFoam with a Reynold Stress Tensor Model (RSM) for turbulent flow closure. Motivation for this endeavor is to be able to increase resolution in modeling flow with large recirculation. The Reynolds stress model is a six turbulence equation model for the six components of the symmetric Reynolds stress tensor. The Launders, Reece and Rodi variant of this model [3,4] is implemented as the LRR model in OpenFoam. Previous discussions on the use of the LRR model in this forum include [5,6]. Below we outline features of the the PitzDaily test case in Section 2, our understanding on how the model should be set up starting from the tutorial model in Section 3 and on how the model converges with the LRR RASModel activated. 2/ PitzDaily out of the box in OpenFoamv1906 The PitzDaily test case as defined in OpenFoamv1906 converges in 283 iterations (run simpleFoam) and meet the criterium for y+ on the mesh (run simpleFoam postProcess func yPlus latestTime). The 283 iterations differs significantly from the tutorial [2]. This difference is likely due to different settings used. 3/ Case SetUp In this section we explain how the PitzDaily tutorial can be modified to run with the LRR RASModel in three steps. Step 1/3: Setting up the systemfolder In the first step we set up the systemfolder by editting the systemfolder/fvSolutionfile and the systemfolder/fvSchemesfile. We edit the systemfolder/fvSolutionfile and add settings to solve for R including relaxation as described in e.g. [5]. We edit the systemfolder/fvSchemesfile and add setting to discretize div(R) and div(phi,R) and settings for the wallDist dictionary. Sample settings for div(R) and div(phi,R) can be copied from other tutorials. To find such setting, use e.g. for i in `find /opt/OpenFOAM/OpenFOAMv1906/tutorials/ name fvSchemes`; do echo $i; grep $i "div(R)" ; done . Step 2/3: Setting up the 0folder In the second step we edit the 0folder. We do *not* define the boundary conditions for the components of the tensor R for inlet, outlet and wall patches directly. Instead, we resort to a twosubstep procedure in which in the first substep, a simulation using a twoequation turbulence model runs for a number of iterations. In the second substep, the stress tensor R is computed in postprocessing stage for the latest iteration. This computed stress tensor is used as boundary value setting for the simulation using the LRR model. More specifically, in the first substep, we run simpleFoam on the outofthebox tutorial. At the last iteration (iteration 283 in our case) we compute the stress tensor R by postprocessing computed results and running simpleFoam postProcess func R latestTime. This command produce a file called turbulenceProperties: R in the latest time folder (folder 283). This file can be renamed to R and copied to the 0folder. Observe that the settings for the turbulence equation used in the first run is used as input to compute R. One can thus *not* modify the constantfolder/turbulencePropertiesfile prior to computing R. One can visualize components and magnitude of the tensor R in paraview. Step 3/3: Running the simulations In the third third we (prepare to) run simpleFoam with the LRR model. We edit the constantfolder/turbulencePropertiesfile to change RASModel from current value into LRR. We edit the systemfolder/fvSolution file and choose sufficiently low relaxation parameters for R and epsilon. We can now run simpleFoam with LRR. Alternatively, we can avoid copying the 283folder/Rfile to the 0folder and run simpleFoam with LRR and startTime equal to the latestTime of the previous simulation. 4/ Discussion and Conclusions We discussed how the incompressible tutorial PitzDaily for simpleFoam can be modified to include the Reynolds stress tensor wonder. We wonder whether the preprocessing using a twoequation turbulence model can be avoided. The above description is likely to be incomplete and fragile as time evolves. We theferore wonder whether a tutorial using the LRR model can be made available as tutorial in the OpenFoam distribution. References [1]: Turbulence Steady State, Tutorial Six of TU Vienna: https://www.cfd.at/sites/default/fil...xampleSix.pdf: shows change divSchemes in fvSchemes to take R into account: no settings explained for fvSolution: decrease in turbulent viscosity is shown; [2]: Introduction to Stationary Turbulence Modeling, Jozsef Nagy, https://www.youtube.com/watch?v=46pgYQYER8. The LRR model is discussed from minute 18 of 26 onwards [3]: NASA Langley Turbulence Modeling Resource on Launders, Reece and Rodi model: https://turbmodels.larc.nasa.gov/rsmssglrr.html ; [4]: Ansys Fluent Manual online [5] Jasak on cfd.online.com on how to use the LRR Model: details of how to run the LRR model and showing convergence of the residual for the stress tensor components: Problems with the RSM in simpleFoam , 2006. [6]: discussion regarding the LRR RASModel on cfdonline.com: settings for volSymmTensorField R in fvSolution are shown. No settings for fvSchemes are given unfortunately: Usage of R and LRR , 2010. 

May 28, 2020, 17:43 

#2 
Senior Member
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 932
Rep Power: 12 
Hi,
 Finally a nicelooking thread unlike some of the questions here. Thanks.  Could you please clarify if there is a question from your side, though? I didn't quite get the purpose of the post? Thank you.
__________________
The OpenFOAM community is the biggest contributor to OpenFOAM: User guide/Wiki1/Wiki2/Code guide/Code Wiki/Journal Nilsson/Guerrero/Holzinger/Holzmann/Nagy/Santos/Nozaki/Jasak/Primer Governance Bugs/Features: OpenFOAM (ESIOpenCFDTrademark) Bugs/Features: FOAMExtend (WikkiFSB) Bugs: OpenFOAM.org How to create a MWE New: Forkable OpenFOAM mirror 

May 29, 2020, 16:35 

#3 
Senior Member

Hi,
Thank you for your words of appreciation. These words come as an encouragement that I much appreciate. I indeed failed to phrase questions explicitly. I am wondering though: 1/ It took me a while to realize that the stress tensor model was indeed available. Can documentation be improved, e.g., by subdividing the documentation for RAS models into oneequation, twoequation and stresstensor model? 2/ It took me a while to realize how to set up the model. Can documentation be improved, e.g., by providing in the OpenFoam release an Allrun script that performs all of the above via scripting? 3/ Can running the twoequation model to in the setup phase be avoided? Does this require implementing wall functions for the stress tensor? Thanks again and kind wishes. Domenico Lahaye 

May 31, 2020, 15:30 

#4 
Senior Member
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 932
Rep Power: 12 
My apologies for my English skills, yet I still couldn't fully grasp what you mean by your questions, e.g.:
>> Can documentation be improved, e.g., by subdividing the documentation for RAS models into oneequation, twoequation and stresstensor model? Do you suggest/wish to improve the header file or extended code guide documentation on these models?
__________________
The OpenFOAM community is the biggest contributor to OpenFOAM: User guide/Wiki1/Wiki2/Code guide/Code Wiki/Journal Nilsson/Guerrero/Holzinger/Holzmann/Nagy/Santos/Nozaki/Jasak/Primer Governance Bugs/Features: OpenFOAM (ESIOpenCFDTrademark) Bugs/Features: FOAMExtend (WikkiFSB) Bugs: OpenFOAM.org How to create a MWE New: Forkable OpenFOAM mirror 

September 20, 2020, 21:26 

#5 
New Member
Vitor Geraldes
Join Date: Dec 2009
Location: Lisbon, Portugal
Posts: 26
Rep Power: 16 
Can you explain why "The magnitude of the tensor R is equal to epsilon." . The units of R (in fact R/rho) are m2/s2 and the units of epsilon are m2/s3.


December 30, 2020, 19:45 

#6 
New Member
Join Date: Jan 2019
Posts: 11
Rep Power: 7 
Hi, I have tried to use your steps to try and use LRR. However, I am facing the below issue:
Code:
> FOAM FATAL ERROR: [2] cannot be called for a calculatedFvPatchField on patch airfoil of field R in file "airfoil_aoa0/processor2/200/R" You are probably trying to solve for a field with a default boundary condition. Thank you. 

December 31, 2020, 04:33 

#7  
Senior Member

Quote:
Sincere thanks for pointing out an ambiguity. Should be: "The trace of the tensor R divided by 2 is equal to k." See e.g. book Versteeg 2007, Section 3.7.3. 

December 31, 2020, 04:36 

#8  
Senior Member

Quote:


December 31, 2020, 04:48 

#9  
New Member
Join Date: Jan 2019
Posts: 11
Rep Power: 7 
Quote:
fvSchemes: Code:
/** C++ **\ =========  \\ / F ield  OpenFOAM: The Open Source CFD Toolbox \\ / O peration  Website: https://openfoam.org \\ / A nd  Version: 8 \\/ M anipulation  \**/ FoamFile { version 2.0; format ascii; class dictionary; object fvSchemes; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ddtSchemes { default steadyState; } gradSchemes { default Gauss linear; grad(U) cellLimited Gauss linear 1; } divSchemes { default none; div(phi,U) Gauss linearUpwind grad(U); div(phi,k) Gauss upwind; div(phi,omega) Gauss upwind; div(phi,nuTilda) Gauss upwind; div(phi,epsilon) Gauss upwind; div((nuEff*dev2(T(grad(U))))) Gauss linear; div((nu*dev2(T(grad(U))))) Gauss linear; div(R) Gauss linear; div(phi,R) Gauss upwind; } laplacianSchemes { default Gauss linear corrected; } interpolationSchemes { default linear; } snGradSchemes { default corrected; } wallDist { method meshWave; } // ************************************************************************* // Code:
/** C++ **\ =========  \\ / F ield  OpenFOAM: The Open Source CFD Toolbox \\ / O peration  Website: https://openfoam.org \\ / A nd  Version: 8 \\/ M anipulation  \**/ FoamFile { version 2.0; format ascii; class dictionary; object fvSolution; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // solvers { p { solver GAMG; tolerance 1e7; relTol 0.1; smoother GaussSeidel; } "(UomeganuTildaepsilonR)" { solver smoothSolver; smoother symGaussSeidel; tolerance 1e8; relTol 0.01; } k { solver smoothSolver; smoother symGaussSeidel; tolerance 1e9; relTol 0.01; } /* pFinal { solver GAMG; tolerance 1e04; relTol 0.1; smoother GaussSeidel; } pcorrFinal { solver GAMG; tolerance 1e04; relTol 0.1; smoother GaussSeidel; } "(Ukomega)Final" { $U; tolerance 1e04; relTol 0; } */ } SIMPLE { nNonOrthogonalCorrectors 2; consistent yes; residualControl { /* p 1e6; U 1e6; "(omegafv2)" 1e6; k 1e6; nuTilda 1e6; epsilon 1e6; */ } } /*{ nOuterCorrectors 2; nCorrectors 3; nNonOrthogonalCorrectors 3; pRefCell 0; pRefValue 0; } PISO { nCorrectors 2; nOuterCorrectors 3; nNonOrthogonalCorrectors 2; pRefCell 0; pRefValue 0; residualControl { p 1e5; U 1e5; "(kepsilonomegafv2)" 1e5; } } potentialFlow { nNonOrthogonalCorrectors 0; } */ relaxationFactors { fields { p 0.9; R 0.3; } equations { U 0.9; k 0.8; omega 0.65; nuTilda 0.7; epsilon 0.7; } } // ************************************************************************* // 

December 31, 2020, 07:28 

#11 
New Member
Join Date: Jan 2019
Posts: 11
Rep Power: 7 

January 3, 2021, 09:10 

#13 
New Member
Join Date: Jan 2019
Posts: 11
Rep Power: 7 

January 3, 2021, 11:46 

#14 
Senior Member

Pls. elaborate. What happens in case of lowering relaxation factors?
Also, pls. explain the starting guess for the LRR model. Did you run the towequation model to full convergence as a starting guess? Furthermore, do the results for the Reynolds stress model obtained from postprocessing the twoequation model look reasonable? 

April 8, 2021, 06:17 

#15  
Senior Member
Agustín Villa
Join Date: Apr 2013
Location: Alcorcón
Posts: 313
Rep Power: 15 
Quote:
The calculated BC is applied on a wall? Have you tried to use another BC there? The R utility calculates values on the mesh, but at the walls it uses calculated (from nut, k and U fields, I think). A fixed value equal to zero should be a good approach. What are the values you get on this patch? 

September 22, 2021, 06:12 

#16 
Senior Member
Carlos Rubio Abujas
Join Date: Jan 2018
Location: Spain
Posts: 127
Rep Power: 9 
Thank you Domenico for the initiative. I also think it is extrange that no example with LRR is included in the tutorials. Indeed, I've found your post looking for a precise way to understand this model and its implementation in OpenFOAM, so I think the post is quite valuable.
However, I've not been able to replicate the results satisfactorily and I found the tutorial quite vague in some specific details that may be critical to successfully complete the simulation. First of all I want to say I've tried the model in OF7, so many details may be different on other versions, but I think the essentials are preserved. Please correct me if I',m wrong in that assumption. Stage 1/3: system/fvSolution: I've followed the link to the e.g [5], but it is not specifically clear which example to use. The blend case link is dead so no information can be extracted for the original question. Some years later some users post settings for another case "blayer.tar.gz" which is indeed accessible, but as the user received no response to his problem I'm not sure if the values are safe to use. As you said in the beginning of the post Under relaxation factors are a critical point, so I think a more solid recommendation should be present for the tutorial. Finally I've used the following values: Code:
fields { p 0.3; R 0.3; } equations { U 0.6; epsilon 0.1; } You mention that settings for wallDist dictionaries are required, but you did not mention any specific setting or how to deal with it. Moreover this dictionary is already defined in the pitzDaily settings so no further modification shall be required, right? In the tutorials the only method employed is meshWave, although two other models are available (Poisson and advectionDiffusion). I've used the following command to explore the schemes used in other tutorials. Code:
grep rh "div(R)" include fvSchemes $FOAM_TUTORIALS  sort u grep rh "div(phi, R)" include fvSchemes $FOAM_TUTORIALS  sort u For div(phi,R) there are 5 options:
When I tried to solve the case it complained about lacking a scheme for div((nu*dev2(T(grad(U))))). I don't know if you forgot to mention in the tutorial or was not required for your case. Anyway I used Gauss linear as well for this field. Stage 2/3: Here the follow up is quite straight. I was glad with the comment on not changing the RASModel prematurely to avoid problems with the postProcessing comment State 3/3: This is also a straightforward step. The simulation runs 2000 iterations, but the residuals don't look so good. I've tried to extend it to 5000 iterations but I seem to be stuck. I've checked the velocity profile and it seems like a transient behaviour is occurring. I don't think this is the expected behavior. It may be something about the URF that is limiting it for fully converging or other point that I'm missing, but I really think that a tutorial covering a difficult converging model should have more details concerning its numerics configuration. It would be great if you can share the specific configuration of the case and some of the results so it can be checked that the model is ok and I'm not missing something essential. For those who are interested in replicating my exact steps I've written an Allrun file to do so. Just remind you that I'm using OF7, so it may not work in other OF versions. PD: The forum don't let me attach the Allrun file, so I share it here as a code extract. Allrun Code:
#!/bin/bash # Using OpenFOAM v7 # Run from this directory cd ${0%/*}  exit 1 echo "Creating case pitzDailyKE" cp r $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily pitzDailyKE echo "Meshing pitzDailyKE" blockMesh case pitzDailyKE > pitzDailyKE/log.blockMesh echo "Running simpleFoam on pitzDailyKE" simpleFoam case pitzDailyKE > pitzDailyKE/log.simpleFoam echo "Postprocessing pitzDailyKE" simpleFoam case pitzDailyKE \ postProcess latestTime func yPlus > pitzDailyKE/log.postyPlus simpleFoam case pitzDailyKE \ postProcess latestTime func R > pitzDailyKE/log.postR echo "Creating case pitzDailyLRR" cp r $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily pitzDailyLRR echo "Setting pitzDailyLRR" echo " * Setting fvSolution" foamDictionary \ entry "solvers.R" set "{ solver PBiCG; preconditioner DILU; tolerante 1e6; relRol 0.1; }" pitzDailyLRR/system/fvSolution; foamDictionary \ entry "relaxationFactors" set " { fields { p 0.3; R 0.3; } equations { U 0.6; epsilon 0.1; } } " \ pitzDailyLRR/system/fvSolution echo " * Setting fvSchemes" foamDictionary \ entry "divSchemes.div(R)" set "Gauss linear" \ pitzDailyLRR/system/fvSchemes echo " * Setting fvSchemes" foamDictionary \ entry "divSchemes.div(R)" set "Gauss linear" \ pitzDailyLRR/system/fvSchemes foamDictionary \ entry "divSchemes.div(phi,R)" set "bounded Gauss upwind" \ pitzDailyLRR/system/fvSchemes foamDictionary \ entry "divSchemes.div((nu*dev2(T(grad(U)))))" set "Gauss linear" \ pitzDailyLRR/system/fvSchemes foamDictionary \ entry "wallDist.method" set "meshWave" \ pitzDailyLRR/system/fvSchemes echo " * Setting initial conditions" latestTime=$(foamListTimes case pitzDailyKE latestTime) cp r pitzDailyKE/$latestTime/{U,p,R,epsilon,nut} pitzDailyLRR/0 echo " * Adding more simulation time" foamDictionary \ entry "endTime" set "2000" \ pitzDailyLRR/system/controlDict echo " * Setting turbulence Model" foamDictionary \ entry "RAS.RASModel" set "LRR" \ pitzDailyLRR/constant/turbulenceProperties echo "Meshing pitzDailyLRR" blockMesh case pitzDailyLRR > pitzDailyLRR/log.blockMesh echo "Solving case pitzDailyLRR" simpleFoam case pitzDailyLRR > pitzDailyLRR/log.simpleFoam 

September 27, 2021, 09:38 

#17 
Senior Member

Dear Carlos,
Thank you much for your wonderful input. 1/ I have tried using OpenFoamv1906 only. I agree that particular details might be version dependent; 2/ For the underrelaxation, I suggest to use values closer to 0 than to 1 in initial runs. Once the model runs fine, you can increase the underrelaxation factors to increase the speed of convergence. Possibly it is beneficial to lower the overrelazation factor for the velocity from 0.6 to even lower values; 3/ Possibly it is valuable to check whether the model does converge with the kepsilon model; Kind wishes, Domenico. 

March 1, 2022, 07:55 

#18 
New Member
SunTime
Join Date: Nov 2020
Posts: 14
Rep Power: 5 
Thank you very much!


March 1, 2022, 07:56 

#19 
New Member
SunTime
Join Date: Nov 2020
Posts: 14
Rep Power: 5 
Why the results are unsteady?


March 2, 2022, 04:32 

#20  
New Member
SunTime
Join Date: Nov 2020
Posts: 14
Rep Power: 5 
Quote:
Thank you in advance! 

Thread Tools  Search this Thread 
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Calculating Reynolds stress in steady RANS  tjhkenneth  SU2  0  February 9, 2020 14:36 
simpleFoam: Reynolds Stress, turbulenceProperties:R, no output  FoamingSimon  OpenFOAM  16  October 10, 2019 07:24 
Turbulent DFSEM reynolds stress calculation  ssa_cfd  OpenFOAM Running, Solving & CFD  0  February 1, 2019 08:23 
Modified simpleFOAM using given Reynolds stress field  K62  OpenFOAM Running, Solving & CFD  2  March 24, 2017 03:41 
Reynolds Stress Models  Roued  Main CFD Forum  20  February 8, 2000 02:58 