21_simpleSol
Important
Visit https://aerosand.cc for the latest updates.
0. Preface
In the previous discussion, we examined the SIMPLE algorithm in detail and briefly looked at some code snippets of the SIMPLE algorithm in OpenFOAM.
Here, we will implement the code based on our discussion of the algorithm and understand the usage of some code.
This section primarily discusses:
- Implementation of the SIMPLE algorithm
- Computing the cavity test case
1. Governing Equations
The governing equations are as follows:
Continuity equation (mass equation):
Momentum equation:
The following assumptions are still applied:
- Steady state
- Viscous term is simplified
- Gravity is neglected
- Density has been accounted for
2. Project Preparation
Run the following commands in the terminal to create the project:
ofsp
foamNewApp ofsp_21_simpleSol
cd ofsp_21_simpleSol
cp -r $FOAM_TUTORIALS/incompressible/icoFoam/cavity/cavity debug_case
code .2.1. Documentation File
Provide a documentation file for the project:
## About
A solver that simply reproduces the SIMPLE algorithm.
## Bio
aerosand @ aerosand
## Caution
Pay attention to the OpenFOAM version.
## Deploy
Ensure the solver files are complete and include the debug_case folder
Enter the following commands in the terminal:
./Allclean
./Allrun
## Event
@20260312
- Added scripts #done2.2. Script Files
We will streamline the previous scripts.
Run the following command in the terminal to create the scripts:
code {Allclean,Allrun}The cleaning script Allclean is as follows:
| |
The run script Allrun is as follows:
| |
Do not worry about the scripts; as the discussion deepens, we will continuously expand the script content and try different writing styles.
Note
Use chmod +x {Allclean,Allrun} to grant execution permissions to the scripts.
These scripts can continue to be used in the future unless otherwise noted.
3. Project Implementation
We will implement the SIMPLE algorithm with the simplest code possible.
3.1. Main Source Code
Considering the discussion in 20_simple, implement the main framework of the SIMPLE algorithm in the main source code:
| |
It can be seen that the main algorithm framework is the same as discussed in the previous section.
3.2. Field Inclusion
The field inclusion createFields.H is as follows:
| |
3.3. Momentum Predictor
The momentum predictor is in UEqn.H, with the following code:
| |
Regarding the relaxation of the momentum equation, this will be discussed later. Readers can comment out this relaxation code and compare the differences in calculation results.
3.4. Pressure and Momentum Correction
The pressure and momentum correction is in pEqn.H, with the following code:
| |
Pressure also undergoes relaxation, which will be discussed later. Readers can try commenting it out to observe the differences in calculation results.
Tip
Note that for ease of understanding, non-orthogonal correction is not performed here. Since the cavity test case used later has a simple mesh, this has no impact.
3.5. Project Make
As discussed above, this solver does not use additional libraries, so no extra linking specifications are needed in the project Make.
The Make/files content is as follows:
| |
The Make/options content is as follows:
| |
3.6. Compilation
Run the following command in the terminal to compile the entire project:
wclean
wmakeCompilation is successful with no issues.
3.7. Test Case
We adjust the copied test case to test the above solver.
Modify the control dictionary controlDict as follows:
| |
Modify the solution dictionary fvSolution as follows:
| |
Other files remain unchanged.
3.7. Execution
Since the solver project compiles without issues, it can be run directly using the scripts.
Run the project:
./Allclean
./AllrunPost-process visualization:
paraFoam -case debug_caseThe calculation results can be viewed in ParaView.
Readers can modify parts of the code to explore the effects of different statements.
4. Summary
Through the implementation and discussion of the solver project, I believe we now have a relatively comprehensive understanding of the SIMPLE algorithm and solver implementation.
In the next section, we will discuss the PISO algorithm.
This section has completed the following discussions:
- Implementation of the SIMPLE algorithm
- Computing the cavity test case
Support us
Tip
Hopefully, the sharing here can be helpful to you.
If you find this content helpful, your comments or donations would be greatly appreciated. Your support helps ensure the ongoing updates, corrections, refinements, and improvements to this and future series, ultimately benefiting new readers as well.
The information and message provided during donation will be displayed as an acknowledgment of your support.
Copyright @ 2026 Aerosand
- Course (text, images, etc.):CC BY-NC-SA 4.0
- Code derived from OpenFOAM:GPL v3
- Other code:MIT License
