Setting up a Computational Fluid Dynamics (CFD) simulation for your problem requires attention to details and careful consideration of several factors to ensure accurate and meaningful results. In this post, I will remind you with the things you must be careful about when using CFD, whether or not it’s open-source, commercial or in-house code.
Basically, we have 5 topics to discuss:
- Know thy Physics
- Clear the geometry
- Have a good mesh
- Set proper boundary conditions
- Document everything
1. Know thy Physics
It is extremely important that you know the physical phenomena of your problem! You need to understand and visualize what flow phenomena involve in your simulation or what is happening inside your computational domain.
The first reason is for verification of your results. For example, when you simulate the flow around a circular cylinder, you need to make sure the Reynolds number range of your flow and whether flow separation and vortex shedding occur or not. If you are not sure about the flow regime of your simulation, you won’t even be able to verify whether your simulation results are physically meaningful or not. Another example is when you use laminar flow solver for turbulent flows, you may get VERY wrong results, and vice versa is true, too. One more example, if you simulate transient flows using a steady state solver, your simulation may never converge or even converged, your solution may be very different from actual phenomena.
Another reason is to properly create and refine your computational mesh. You need to refine your mesh in regions where complex flows occur in order to capture these complex flow features. For example, several hydrodynamics and aerodynamics problems involve a wake behind the body of interest, and you need a fine mesh behind the body if you want to calculate such flows with high accuracy.
2. Clear the Geometry
Having to clean up your geometry is cumbersome and time consuming, but this is hard truth. You need to clean up your geometry for reliable, robust and accurate results. Around 60~80% of the human hours for industrial CFD simulations is spent on geometry preparation and meshing, and it is necessary.
Most of the time, the initial CAD data of your model is a mess. CAD designers do not need to care about whether their CAD model has defective edges and faces or suitable for CFD. They only need to care about the accuracy of their 3D model for visualization and drawing purposes. It is our job as a CFD engineer to generate a high quality mesh for our CFD simulations and cleaning and defeaturing the initial geometry is inevitable for this purpose.
Meanwhile, you also need to be careful about over-defeaturing. You need to make sure your removed parts do not have significant effect on the flow field.
3. Have a good mesh
Professor Hrvoje Jasak, one of the creators of the most popular open-source CFD code OpenFOAM said, “Who owns the mesh owns the solution”. It is very important to generate a high quality mesh whether you use commercial mesh generators such as ICEM CFD or Pointwise or the humble open source snappyHexMesh (You would need some tips and tricks to get a good mesh and these are here)https://cfdmonkey.com/tips-and-tricks-for-significantly-improving-your-snappyhexmesh/
First mesh metric is the quality. Your mesh should have as little maximum skewness and non-orthogonality because these add numerical diffusion leading to less accurate results at best. At the worst scenario, you may get very wrong results or your simulation blows up. High aspect ratio cells are OK when used as a boundary layer mesh but in other areas, be careful.
Secondly, your mesh need to be able to resolve all flow features. If your flow involves turbulent boundary layers, your mesh should be able to model it properly whether you use wall functions or not. If your flow has areas with large gradients, you need to refine your mesh inside these areas. If you are simulating a free-surface flows, you should have enough cells near the free-surface. Remember Rule 1. Know thy Physics!
Lastly, your mesh should be efficient. Of course, you need to refine your mesh around important areas where you want to capture the flow features well. However, it is not good if you refine too much, especially if you refine the whole domain because you are not sure where to refine. Your mesh size will skyrocket and your simulation will run very slowly, especially if your machine is not strong enough.
4. Set proper boundary conditions
Your boundary conditions need to reflect the real physical phenomena you are modeling. They do not need to fully represent the real conditions. When simulating an automobile, the vehicle speed and wind speeds are not constant, of course. But you can assume uniform flow velocities for certain case scenarios.
On the other hand, your boundary conditions need to be set properly both for mimicking the flow physics and for numerical stability. For example, your pressure outlet should be placed far away from your object of interest in order to avoid unnecessary back flows.
For most incompressible problems, boundary conditions are simple and straightforward. You have inlets and outlets. Their mass balance/continuity should be maintained. But for compressible problems, you need to be much more careful. Even if you know the average speed of your body, things are not as simple as incompressible flows anymore. Consult with documentations and similar papers and probably with professors.
5. Document everything
You need to document your simulation setup, physical parameters for your simulation, boundary conditions, assumptions you made and the reasons behind your assumptions and decisions. You may want this documentation to improve your CFD knowledge as well as for later use. I have so much experience of not remembering the details of my previous simulations and doing something very differently in later simulations. Documentation helped me out of this very serious problem.
Again, documentation facilitates transparency, reproducibility and robustness for your simulation, especially when you submit your peer review journal paper.
Summary
Setting up simulation, running and adjusting detail controls is a tedious work and often iterative. And your time is the most important! Following the above pieces of advice can greatly improve your CFD job efficiency and help you accumulate knowledge and experience for your later career. And Remember! Always know the phenomena involving with your simulation!