Week 5 Challenge- Creating a test case in OpenFOAM
Aim:
Copy the cavity problem from $FOAM_TUTORIALS/incompressible/icoFoam. Find the value assigned to: transportModel & kinematic viscosity (nu) stored in a dictionary file transportProperties.
Rename the file transportProperties to thermalProperties
- Add variable Tin the dictionary and assign a value to it
- Print the value of all the constituent variables in thermalProperties file.
Step 1:
Copy cavity case from tutorial icoFoam to runfolder.
Now we create a new cpp file will be as follow with the name mythermal.cpp and write the program in it which wiil be as follows.
Mythermal.cpp:
#include"fvCFD.H"
int main (int argc, char *argv[])
{
Foam::argList::noBanner();
Foam::argList args(argc,argv);
Foam::Time runtime
(
Foam::Time::controlDictName,
args.rootPath(),
args.caseName()
);
Info<<"current time ="<<runtime.timeName()<<nl<<endl;
Info<<"start time ="<<runtime.startTime()<<nl<<endl;
Info<<"end time ="<<runtime.endTime()<<nl<<endl;
IOdictionary ioDictObj
(
IOobject
(
"thermalProperties",
"system",
runtime,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
vector Temp_1 = vector(ioDictObj.lookup("Temp_1") );
Info<< Temp_1 <<"\n";
return 0;
}
Thermal properties:
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object thermalProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Temp_1 (100.0 200.0 300.0);
// ************************************************************************* //
Make files:
Now we need to compile this. We create a make folder and create 2 files in it with names.
Files:
mythermal.cpp
EXE = mythermal
Options:
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-g
EXE_LIBS = \
-lfiniteVolume \