Home
Navigating OpenFOAM
This section will cover the following:
  1. Where is OpenFOAM located in your computer?
  2. Navigating files
  3. Creating, moving, and removing files and folders
  4. Exercises
Where is OpenFOAM located in your computer?
To navigate OpenFOAM, understanding some Linux commands is necessary. If you have followed my previous tutorial on downloading OpenFOAM, your OpenFOAM folder should be located in the path /usr/lib/openfoam/openfoam2412. If you had not download OpenFOAM, please use this link to go to my page on OpenFOAM download guide.
If you have downloaded OpenFOAM but could not find your OpenFOAM folder, try typing "foam" in the terminal and press "Enter"
If the above fails, go through Navigating files in the below may help you in locating your OpenFOAM installation
Navigating files
1. View folders in "window" format using explorer.exe
explorer.exe .
The dot "." at the end of the command indicate current directory
2. List available folders using ls command
ls
or
l
or to show all subdirectories
ls *
the three commands above is shown in the video below
3. Changing directory / current file location
cd ..
or
cd [filename]
The double dot ".." to indicate previous directory
[filename] to specify the path to change directory to
Files and folders
This section includes creating, copying, moving and deleting files. Differentiating between files and folders:
  • Folders contain other items
  • Files is just a text document i.e: txt files
1. Creating an empty folder
mkdir <folderName>
Creating a new folder named newFolder:
mkdir newFolder
2. Creating a text file
touch <fileName>
Example:
touch helloWorld.txt
3. Moving or renaming files
Renaming file
mv <oldFileName> <newFileName>
Example:
mv helloWorld.txt hiWorld.txt
Moving file
mv <fileName> <newDirectory>/<fileName>
Example:
mv hiWorld.txt ../hiWorld.txt
4. Copying files or folders
Copying file
cp <fileName> <fileName2>
Example:
cp hiWorld.txt helloWorld.txt
Copying folder
cp -r <fileName> <fileName2>
Example:
cp -r newFolder newFolder2
5. Removing files or folders
Removing file
rm <fileName>
Example:
rm helloWorld.txt
Removing folder
rm -r <folderName>
Example:
rm -r newFolder2
Exercises
This is to test your understanding of the above contents by creating user files needed for OpenFOAM.
1. Create a folder for the directory run
Type this:
run
It will show an error, stating there is no path to the run directory
Your task is to create the folder for the run directory. An example solution is shown in the vidoe below.
2. Now try creating a folder for uapp !