Code Saturne Stability and Performance tips
Posted: Mon Jun 15, 2015 2:43 pm
Hello.
I'm continuing to test and learn Code Saturne on my PC. The basic level target is to be able to perform "pure aerodynamic" calculations on arbitrary, not very simple geometry (not a cube or cylinder) with adequate speed.
For test cases I chose an existing geometry of "tangential" boiler furnace (see attachment). Naturally, in tests it's just an isothermal cold flow with constant properties (defaults), but this flow is not very simple (not a flow in a tube e.t.c.).
Inlets are arranged in 3 tiers, each tier has 4 groups of inlets on two opposite walls. Inlet velocity is 20 m/s. At the top of the "furnace" is a pressure outlet PC (ambient). Other boundaries are smooth walls.
Code Saturne settings are almost defaults. Unsteady flow. Time step is 0.01 s.
Tetrahedral Mesh is built with Salome NetGen plugin that is easy to set up (important for engineering).
The first test case is based on mesh with ~1 million elements. There is mesh issue reported by Saturne's solver concerning Least Square gradient calculation method, but I don't use this method. The calculation ran for 500+ iterations on 4 Intel 2600K cores without problems (default partitioner, no Metis or Scotch yet installed). Increasing time step to 0.05 s for tens of iterations not rises any problems.
OK, I switch to 5.7-millions mesh (reduced min/max sizes and growth rate). It's also tetra with moderate growth rate (less than 0.2 in NetGen parameters). Calculation with time step 0.03 s diverges around 70th iteration (unreal velocity maximum). Calculation with time step 0.01 was almost OK up to 125 iterations (then needed to turn off my PC), no any unreal velocity peaks (maximum velocity magnitude ~24 m/s, monitoring with grep), solution in ParaView seems to be normal, but incomplete (that is expected).
But there is a problem. Average iteration duration in this case is 300...500 s (4 Intel 2600K cores, without HT). Not very fast, but it's unsteady and only 4 cores. The problem is some iterations that took about an order of magnitude more time to complete (up to 5500 s). I looked at listing and found that it's due to enormous linear solver iterations for velocity, and, on some iterations, for k. First part of calculation was with default linear solvers, maximum number of "fast" iterations in sequence was 7. Then I switched to Jacobi for Velocity, k and epsilon. After restart Saturne ran until iteration 122 with maximum time 1066 s per iteration. At that moment I thought that this issue is solved but... Iteration 123 was the long one, 4000+ s, and it was again too many "linear sub-iterations" for velocity.
Therefore, I encountered two problems. The first is "long iterations" (slow linear convergence) and second is a time per "normal" iteration (due to "unsteady" option).
I searched the forum and found several recomendations about stability. They are in various topics so I decided to combine them in a single list. IMHO, it's good for newbies like me.
1. Use Upwind 1st order spatial discretisation scheme (default is centered) for first estimation (then it's important for accuracy to switch to a 2nd order scheme, Centered or SOLU in case of Saturne).
2. Disable Flow reconstruction, at least for k and epsilon, for first estimation. I think it should then be enabled again for better precision.
3. Set gradient reconstruction method to "Iterative handling of non-orthogonalities" (default) or "Least squares method over partial extended cell neighborhood" in case of poor mesh quality. There are several Least Squares methods for gradient in Saturne, first in GUI list is definitely less stable in my test case than default (non-orthogonalities) on large timesteps (Courant number 60...100). I found Least squares ... partial ... neighborhood much more stable than default (non-orthogonalities) on mesh with prism layers.
4. Check mesh quality. Important criteria are Face and 3D Aspect ratio (was less then 5 in my "relatively good" cases), non-orthogonality and growth ratio (usually limited to max 1.2 for CFD). Particulary, NetGen may produde meshes with 3D Aspect ratio of hundreds that "crashes" solver (leads to velocity divergence on first iterations).
5. Check Courant and Fourier numbers. Courant number must be less than 20 (desired 1...5) for Saturne due to limitation of SIMPLEC velocity-pressure coupling algorythm. IMHO, this is the reason why commercial solvers like CFX are more robust with Coupled algorythms on big time steps.
Is this list complete?
I think, my case is Courant number (about 70), need to decrease time step (max 0.003 s). I also going to check effects of Upwind (1st order) discretisation for velocity and disabling flow reconstruction. It's in the same GUI table, am I right?
Also, many useful tips for stability described in official Best Practice Guides:
http://code-saturne.org/cms/documentation/BPG
Now about the second problem, performance. The only thing I know now from the forum is a linear solver precision than can be reduced from 10^-8 to 10^-5, apparently, without lack of solution precition.
I tried to turn to steady calculation, but surprisingly the time per iteration remained almost the same! What am I doing wrong? I understand that for unsteady flow performance obtained in my test is expected, but why does it not increase with "steady" option? Compared to CFX (steady) it's very slow, I can't get why...
Another performance issue is dependence of time per iteration on time step. I decreased time step form 0.01 s to 0.001 s in my "5.7-million tetra" test case and didn't see any sufficient speed-up. Is it normal?
Sorry for the long post, needed to describe details.
Thanks for your answers.
I attached the Saturne's listing for 5.7-million case, the case directory and a picture of streamlines from inlets (ParaView). Picture is for ~1-million mesh.
Additional info
OS: Ubuntu 12.04 with updates.
Code_Saturne 4.0.0 (compiled from official sources with SALOME option).
Salome Platform 7 (official distribution for Ubuntu).
OpenMPI
I'm continuing to test and learn Code Saturne on my PC. The basic level target is to be able to perform "pure aerodynamic" calculations on arbitrary, not very simple geometry (not a cube or cylinder) with adequate speed.
For test cases I chose an existing geometry of "tangential" boiler furnace (see attachment). Naturally, in tests it's just an isothermal cold flow with constant properties (defaults), but this flow is not very simple (not a flow in a tube e.t.c.).
Inlets are arranged in 3 tiers, each tier has 4 groups of inlets on two opposite walls. Inlet velocity is 20 m/s. At the top of the "furnace" is a pressure outlet PC (ambient). Other boundaries are smooth walls.
Code Saturne settings are almost defaults. Unsteady flow. Time step is 0.01 s.
Tetrahedral Mesh is built with Salome NetGen plugin that is easy to set up (important for engineering).
The first test case is based on mesh with ~1 million elements. There is mesh issue reported by Saturne's solver concerning Least Square gradient calculation method, but I don't use this method. The calculation ran for 500+ iterations on 4 Intel 2600K cores without problems (default partitioner, no Metis or Scotch yet installed). Increasing time step to 0.05 s for tens of iterations not rises any problems.
OK, I switch to 5.7-millions mesh (reduced min/max sizes and growth rate). It's also tetra with moderate growth rate (less than 0.2 in NetGen parameters). Calculation with time step 0.03 s diverges around 70th iteration (unreal velocity maximum). Calculation with time step 0.01 was almost OK up to 125 iterations (then needed to turn off my PC), no any unreal velocity peaks (maximum velocity magnitude ~24 m/s, monitoring with grep), solution in ParaView seems to be normal, but incomplete (that is expected).
But there is a problem. Average iteration duration in this case is 300...500 s (4 Intel 2600K cores, without HT). Not very fast, but it's unsteady and only 4 cores. The problem is some iterations that took about an order of magnitude more time to complete (up to 5500 s). I looked at listing and found that it's due to enormous linear solver iterations for velocity, and, on some iterations, for k. First part of calculation was with default linear solvers, maximum number of "fast" iterations in sequence was 7. Then I switched to Jacobi for Velocity, k and epsilon. After restart Saturne ran until iteration 122 with maximum time 1066 s per iteration. At that moment I thought that this issue is solved but... Iteration 123 was the long one, 4000+ s, and it was again too many "linear sub-iterations" for velocity.
Therefore, I encountered two problems. The first is "long iterations" (slow linear convergence) and second is a time per "normal" iteration (due to "unsteady" option).
I searched the forum and found several recomendations about stability. They are in various topics so I decided to combine them in a single list. IMHO, it's good for newbies like me.
1. Use Upwind 1st order spatial discretisation scheme (default is centered) for first estimation (then it's important for accuracy to switch to a 2nd order scheme, Centered or SOLU in case of Saturne).
2. Disable Flow reconstruction, at least for k and epsilon, for first estimation. I think it should then be enabled again for better precision.
3. Set gradient reconstruction method to "Iterative handling of non-orthogonalities" (default) or "Least squares method over partial extended cell neighborhood" in case of poor mesh quality. There are several Least Squares methods for gradient in Saturne, first in GUI list is definitely less stable in my test case than default (non-orthogonalities) on large timesteps (Courant number 60...100). I found Least squares ... partial ... neighborhood much more stable than default (non-orthogonalities) on mesh with prism layers.
4. Check mesh quality. Important criteria are Face and 3D Aspect ratio (was less then 5 in my "relatively good" cases), non-orthogonality and growth ratio (usually limited to max 1.2 for CFD). Particulary, NetGen may produde meshes with 3D Aspect ratio of hundreds that "crashes" solver (leads to velocity divergence on first iterations).
5. Check Courant and Fourier numbers. Courant number must be less than 20 (desired 1...5) for Saturne due to limitation of SIMPLEC velocity-pressure coupling algorythm. IMHO, this is the reason why commercial solvers like CFX are more robust with Coupled algorythms on big time steps.
Is this list complete?
I think, my case is Courant number (about 70), need to decrease time step (max 0.003 s). I also going to check effects of Upwind (1st order) discretisation for velocity and disabling flow reconstruction. It's in the same GUI table, am I right?
Also, many useful tips for stability described in official Best Practice Guides:
http://code-saturne.org/cms/documentation/BPG
Now about the second problem, performance. The only thing I know now from the forum is a linear solver precision than can be reduced from 10^-8 to 10^-5, apparently, without lack of solution precition.
I tried to turn to steady calculation, but surprisingly the time per iteration remained almost the same! What am I doing wrong? I understand that for unsteady flow performance obtained in my test is expected, but why does it not increase with "steady" option? Compared to CFX (steady) it's very slow, I can't get why...
Another performance issue is dependence of time per iteration on time step. I decreased time step form 0.01 s to 0.001 s in my "5.7-million tetra" test case and didn't see any sufficient speed-up. Is it normal?
Sorry for the long post, needed to describe details.
Thanks for your answers.
I attached the Saturne's listing for 5.7-million case, the case directory and a picture of streamlines from inlets (ParaView). Picture is for ~1-million mesh.
Additional info
OS: Ubuntu 12.04 with updates.
Code_Saturne 4.0.0 (compiled from official sources with SALOME option).
Salome Platform 7 (official distribution for Ubuntu).
OpenMPI