Skip to content

Commit 4e45706

Browse files
committed
Merge branch 'feature'
2 parents 0b52cf4 + 5c396db commit 4e45706

File tree

136 files changed

+5608
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+5608
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ postProcessing
55
processor*
66
[0-9]*
77
[0-9]*.[0-9]*
8+
!0
89
!0.org
910
!0.orig
1011
!0/

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# OpenFOAM Tutorials Plus
2-
This repository contains several OpenFOAM cases and notes related to my blog [OpenFOAM Studio [in Chinese]](https://zhuanlan.zhihu.com/openfoam).
2+
This repository contains several OpenFOAM tutorials, cases and notes.
33

44
Here's a brief description:
5+
56
* **linuxCheatSheet**
67

78
OpenFOAM Linux Cheat Sheet.
@@ -22,4 +23,8 @@ Here's a brief description:
2223

2324
Two-phase open channel flow. It's a fork of the original interFoam tutorial *waterChannel*. The *surfaces* function is configured to generate water surfaces (namely, the isosurfaces where *alpha.water* is equal to 0.5).
2425

26+
* **programmingTutorials**
27+
28+
Basic tutorials to show how to programme within the framework of OpenFOAM. Refer to the README file within the folder.
29+
2530
Pull requests are welcome! Happy foaming!
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# git-ls-files --others --exclude-from=.git/info/exclude
2+
# Lines that start with '#' are comments.
3+
4+
5+
# Case files
6+
*.gz
7+
postProcessing
8+
*~
9+
processor*
10+
[0-9]*
11+
[0-9]*.[0-9]*
12+
!0.org
13+
!0.orig
14+
!0
15+
*.eMesh
16+
polyMesh/
17+
*.OpenFOAM
18+
dynamicCode
19+
20+
# Log files - anywhere
21+
log.*
22+
23+
# Editor and misc backup files - anywhere
24+
*~
25+
.*~
26+
*.bak
27+
*.bak[0-9][0-9]
28+
\#*\#
29+
30+
# File-browser settings - anywhere
31+
.directory
32+
33+
# CVS recovered versions - anywhere
34+
.#*
35+
36+
# Objects and archives - anywhere
37+
*.[oa]
38+
*.la
39+
*.so
40+
41+
# Derived files
42+
lex.yy.c
43+
44+
# Corefiles
45+
core
46+
47+
# Dependency files - anywhere
48+
*.dep
49+
50+
# lnInclude (symlink) directories - anywhere
51+
lnInclude
52+
53+
# Build directories - anywhere
54+
linux*Clang*/
55+
linux*Gcc*/
56+
linux*Icc*/
57+
solaris*Gcc*/
58+
SunOS*Gcc*/
59+
platforms/
60+
61+
# Reinstate wmake/rules that might look like build directories
62+
!wmake/rules/*/
63+
64+
# doxygen generated documentation
65+
doc/Doxygen/html
66+
doc/Doxygen/latex
67+
doc/Doxygen/man
68+
doc/Doxygen/DTAGS
69+
70+
# Generated files in the main directory (e.g. ReleaseNotes-?.?.html)
71+
# and in the doc directory
72+
/*.html
73+
/doc/*.html
74+
75+
# Untracked configuration files
76+
/etc/prefs.csh
77+
/etc/prefs.sh
78+
/etc/config.csh/prefs.csh
79+
/etc/config.sh/prefs.sh
80+
81+
# Source packages - anywhere
82+
*.tar.bz2
83+
*.tar.gz
84+
*.tar
85+
*.tgz
86+
*.gtgz
87+
88+
# Ignore the persistent .build tag in the main directory
89+
/.build
90+
91+
# Ignore .timeStamp in the main directory
92+
/.timeStamp
93+
94+
# Ignore .tags in the main directory
95+
/.tags
96+
97+
# Ignore project files in the main directory
98+
/.cproject
99+
/.project
100+
/.dir-locals.el
101+
102+
# Ignore the test directory
103+
/tutorialsTest
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
## Basic OpenFOAM programming tutorials
2+
3+
These tutorials show beginners how to programme within the framework of OpenFOAM.
4+
5+
The original edition is created by Artur K Lidtke. The current branch was forked from [BasicOpenFOAMProgrammingTutorials](https://github.com/UnnamedMoose/BasicOpenFOAMProgrammingTutorials) and integrated with [OpenFOAM Tutorials Plus](https://github.com/phresher/OpenFOAM_Tutorials_Plus).
6+
7+
The tutorials have been most recently tested on the official OpenFOAM 5.0 version.
8+
9+
### Tutorial 0 - helloWorld
10+
11+
Presents a basic OpenFOAM executable which prints a simple, yet important,
12+
message.
13+
14+
### Tutorial 1 - basicIO
15+
16+
Shows how to read information from dictionaries and output it into files.
17+
18+
### Tutorial 2 - understandingTheMesh
19+
20+
Discusses how the OpenFOAM mesh description works and introduces the code
21+
interface used to interact with the grid.
22+
23+
### Tutorial 3 - basicFieldOperations
24+
25+
Introduces the idea of a field object, reading values from OF-native files
26+
using built-in operators, as well as calculating field values by hand.
27+
28+
### Tutorial 4 - basicParallelComputing
29+
30+
Gives a crash-course introduction to parallel computing with OpenFOAM and
31+
OpenMPI based on the example "solver" developed in Tutorial 2. The way
32+
OpenFOAM handles parallel domain decomposition is described, basic operators
33+
used for communication between parallel nodes are shown, and the basic solver
34+
is upgraded to work in parallel.
35+
36+
### Tutorial 5 - customClasses
37+
38+
Shows how a new class may be added to expand OpenFOAM functionality, as well
39+
as gives an example implementation of a class derived from and OpenFOAM
40+
object. This is done by extending from the IOdictionary, with the aim of
41+
adding a custom method which lists the contents of the dict file, while keeping
42+
all of the baseline functionality.
43+
44+
### Tutorial 6 - customLibraries
45+
46+
Shows how an external library may be compiled and added to OpenFOAM. This is
47+
done by moving the key functionality of the "solver" from Tutorials 2 and 3
48+
into an independent library, and then linking that against the rest of the
49+
solver code.
50+
51+
### Tutorial 7 - customBC
52+
53+
Shows how a custom boundary condition may be implemented.
54+
It does not introduce a bespoke utility, but instead only implements a
55+
library. This defines an inlet condition that allows a boundary layer
56+
profile to be prescribed at the inlet of a pipe.
57+
58+
The BC is implemented as a class derived from the fixedValue boundary
59+
condition, adding several control parameters allowing the inlet profile
60+
to be customised. Key elements of the code are highlighted with the keyword
61+
NOTE:. Key methods to pay attention to are the two constructors, default
62+
and one constructing the BC from string, and .updateCoeffs().
63+
64+
The test case is a straight pipe, flow through which gets solved with the
65+
basic simpleFoam solver. Key things to note are the definition of the
66+
BC in 0.org/U and the incorporation of a custom library in system/controlDict.
67+
The simulation is 3D RANS on a coarse mesh so it takes a few minutes on
68+
a low-end machine. The effect of the boundary condition may be visualised
69+
by plotting the x-velocity through the pipe and noting the incident boundary
70+
layer profile at the inlet and how it affects the solution.
71+
72+
### Tutorial 8 - transportEquation
73+
74+
Introduces the concepts behind solving a simple scalar transport equation.
75+
76+
The solver sets up the transport problem by importing a fixed velocity field
77+
from the last time step and solving the transport of a scalar, beta, in the
78+
presence of the velocity, beta being also subject to diffusion characterised
79+
by a fixed proportionality constant, gamma. The solver is conceptually similar
80+
to the built-in scalarTransportFoam, except it solves a steady-state problem.
81+
Key things to note are 1) the syntax behind the scalar transport equation
82+
2) how OpenFOAM translates the syntax into specific operations and associates
83+
them with entries in system/fvSolution and system/fvSchemes dictionaries
84+
3) inclusion of the boundary condition definitions in 0/beta into the equation
85+
4) units of the equations being solved and how OpenFOAM handles them.
86+
87+
The test case is a simple 2D square domain with fixed scalar inlets at the bottom
88+
and the left-hand side. Transport takes place in the presence of a velocity
89+
field convecting away from the beta inlets. Once the case is run, it is best
90+
to visualise the initial conditions in the "beta" field and the solution to the
91+
transport equation saved as the "result" field.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
wmake app > log.wmake
4+
blockMesh -case case > log.blockMesh
5+
$FOAM_USER_APPBIN/basicFieldOperations -case case | tee log.basicFieldOperations
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
basicFieldOperations.C
2+
3+
EXE = $(FOAM_USER_APPBIN)/basicFieldOperations
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
EXE_INC = \
2+
-I$(LIB_SRC)/finiteVolume/lnInclude \
3+
-I$(LIB_SRC)/meshTools/lnInclude
4+
5+
EXE_LIBS = \
6+
-lfiniteVolume \
7+
-lmeshTools

0 commit comments

Comments
 (0)