How to add temperature to icoFoam
Contents
1 How to add temperature transport to icoFoam
This HOWTO will cover rudimentary methods for altering an existing solver (icoFoam) to solve thermal transport. The main items to be accomplished are first, to copy and test that your installation of OpenFOAM can compile the existing solver correctly. Once that is accomplished, various small changes are necessary to the solver files themselves and these will be detailed below. Finally, new fields have to be added to the initial and boundary conditions and alterations to the fvSchemes file.
2 Copy and recompile icoFoam
//This will go through the steps of creating a personal version of icoFoam in the user's subdirectory. The first step is to insure that your installation of OpenFOAM works properly and compiles the unedited solver. First, bring up a console and move to your OpenFOAM installation folder.
cd OpenFOAM
Your particular OpenFOAM installation folder will have a version number following it such as:
cd OpenFOAM-1.4.1-dev
OpenFOAM has organized the solvers as separate from the source code of OpenFOAM calling them 'applications'. Inside the 'applications' folder, there are subdirectories including one for solvers. Have a look around, but this tutorial goes for icoFoam which we will copy to our own location:
cd applications/solvers/incompressible cp -r icoFoam $FOAM_USER_APPBIN/../../solvers/my_icoFoam cd $FOAM_USER_APPBIN/../../solvers/my_icoFoam
Now, a couple of alterations need to be made to the make files in order for everything to compile and not overwrite the original solver. First, rename the primary file to your new solver name and delete the old dependency file:
mv icoFoam.C my_icoFoam.C rm icoFoam.dep
Now go into the Make subdirectory and open the 'files' file with your favorite editor. Change it to read:
my_icoFoam.C EXE = $(FOAM_USER_APPBIN)/my_icoFoam
No changes are necessary for the 'options' file. Delete the old binaries subdirectory:
rm -rf linuxGccDP0pt cd ..
Now, test that the renamed solver (and your installation of OpenFOAM) works:
wmake
If everything worked correctly, your new solver binary should appear in the FOAM_USER_APPBIN directory. check this with:
ls $FOAM_USER_APPBIN
3 Adding the temperature field
This will show the steps to add another field variable to a solver. Open the my_icoFoam.C (or whatever you have named it) with your favorite text editor.
First, edit the 'Application' to reflect the new name.
Following the flow of the program, one notices that the header file 'createField.H' is called prior to the solution loop. This file was copied with the solver and has the specific information pertaining to what variables will be solved.
Open createFields.H in your favorite editor.
The first items loaded is the kinematic viscosity from the transportProperties dictionary file. We will add a new transport property related to the thermal diffusion which will be denoted as DT. Make the following edits:
dimensionedScalar nu ( transportProperties.lookup("nu") ); //Add here... dimensionedScalar DT ( transportProperties.lookup("DT") ); //Done for now...
Later on, we will need to edit the dictionary file to reflect this change.
Following this in the file there are lines which pertain to the creation of the pressure (p) and velocity (U) fields. Wie will add a new field for temperature (T). The fastest way to do this is to copy and paste the pressure lines and then edit them appropriately like so:
Info<< "Reading field T\n" <<endl; volScalarField T ( IOobject ( "T", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh );
Save these changes. You've completed adding a new field variable, which will be called 'T' to the solver.
4 Adding a new equation to solve
This will show the steps to adding a new equation.
5 Add a new file for initial and boundary conditions
This will show the steps to modifying the t=0 files.
6 What to add in fvSchemes
How to modify fvSchemes for your new solver.
7 Benchmarking your new solver
This may end up being a different page, but it will show a case study of the Blasius flat-plate flow problem. --Mike Jaworski 07:05, 22 February 2008 (CET)