OpenFOAM Directories
1 OpenFOAM directory conventions
In order to work efficiently with OpenFOAM we have to understand the file system structure of OpenFOAM itself and of OpenFOAM cases.
Make sure you understand the basics of Linux/Unix file systems and have mastered basic Linux commands given in the tutorial before doing any of the advanced work.
1.1 Your home directory
Your home directory is placed in /home/userName, where userName is your user name on the system (chosen at installation or when creating the user. Every user of a Linux system will have their own home directory.
The home directory has a shortcut, which is the “tilde” character ~
You can change to your home directory with:
cd
That is, the cd command without any argument, or
cd ~
You can also use the ~ to refer to the home directory in most commands:
cd ~/OpenFOAM
will change into the OpenFOAM directory in your home directory from wherever you are.
1.2 The OpenFOAM directories
OpenFOAM has its own directory structure, which looks like this:
OpenFOAM ├── userName-v1912 │ ├── applications │ ├── platforms │ ├── run
where userName is your username.
The userName-v1912 (for version 19.12 of OpenFOAM, if you have more than one version installed, you may have more than one of these directories) is the base.
In that you have:
applicationscontaining your own code. Most of you won’t need that until you start writing your own solvers or libraries, e.g. for boundary conditions.platformscontains the compiled executables and libraries of the code inapplications. On your system that should contain two directoriesbinandlibcontaining the libraries forhaemoFOAMandswak4FOAM, (SWiss Army Knife 4 FOAM) an extension to OpenFOAM, that provides, amongst other things theGroovy Boundary Condition,groovyBC, that we are going to use.run, the directory where you should keep your cases. While the former two directories have to be in their fixed locations, you can run cases in any directory you like, but this one is the recommended one.
1.3 OpenFOAM case structure
Typically OpenFOAM will be located in the run directory above. You can, however, place them anywhere on the file system (only where you have write access, of course), e.g. if your system has a workspace for larger cases (many cluster systems will have such a directory).
The important thing is that the case is a collection of files that are in a directory structure. This means that there is no single file that you can copy, but you need to copy the whole directory. This can be done by archiving the case using either the Linux command tar, or (if you need to use the case on a Windows system) the zip command, or by creating an archive using the pyFoamArchive.py command (this will also delete most of the results, so use with care).
A case named casename will have a structure like this:
casename ├── 0 ├── constant ├── casename.foam └── system
0, constant=, and system are directories that contain:
0: initial conditions and boundary conditions are described by files in this directory. See OpenFOAM Boundary Condition Files. The0directory is the first (zero-th) of the time directories. The other time directories will contain the results and are named by theirrunTime, i.e. a directory named1.5will contain the result after 1.5 seconds.constant: contains the parameters and settings that remain constant throughout the run. This will be the physical parameters for the fluid (or solid), turbulence models, etc. This directory will also contain the (initial) mesh in thepolyMeshsub-directory.system: contains the controlling files, most importantlycontrolDict.
Also see OpenFOAM v7 User Guide: 4.1 Structure of OpenFOAM cases
- tags OpenFOAM, CFD course