Important notice! Before compiling your own solver, utility etc, first initialize OpenFOAM environment, see Initialization of OpenFOAM.
A good choice for creation of a new solver, is to start modifying an existing solver. In this example we choose existing icoFoam solver.
First, move to the user application directory. if the directory does not exist, create it (with mkdir command)
cd $WRKDIR/OpenFOAM/$USER-2.1.x/applications/
and create a directory solvers, i.e.
mkdir solvers
Copy existing icoFoam solver's source files, and move to the new directory consisting the source files to be modified.
cp -r $FOAM_SOLVERS/incompressible/icoFoam/ solvers/own_icoFoam
cd solvers/own_icoFoam
Rename icoFoam.C to own_icoFoam.C, i.e.
mv icoFoam.C own_icoFoam.C
and make your modification of the solver.
Start compilation, first editing (with emacs, vi, etc) the files file in the Make directory, i.e.
emacs Make/files
After edition, the file should look like this:
own_icoFoam.C
EXE = $(FOAM_USER_APPBIN)/own_icoFoam
Save the file, and in the own_icoFoam directory, give the compilation command
wmake
New executable is created. You may then move to your run directory and use the new solver executable, for example to run the cavity case with the existing input files, i.e.
cd $FOAM_RUN/cavity
$FOAM_USER_APPBIN/own_icoFoam