You are on page 1of 6

OpenFoam Setup – Good Practice

Case Directory
|-> system
| |->controlDict : start,end,step,i/o
| |->fvSchemes : discretization params
| |->fvSolution : Solver related stuff
|
|->constant
| |->Material Properties
| |->polyMesh
| |->points
| |->ells
| |->faces
| |->boundaries
|
|->many time_directory
(gzip compression)

StandAlone Excecutables
|->

OpenFOAM Dictionary Format


Used for material properties, model constants, solution fields, initial and BC, discretization
settings etc.
Format (“ keyword value;” )
|-> Foamfile
| {
| version 2.0;
| format asci;
| class dictionary;
| object transportProperties;
| }
|->Properties of “object” depends on the solver being used.
|
|->object properties
|-> keyword value
|->DT |->”dimensioned scalar”
|-> name set_of_dimensions value
DT [0 2 -1 0 0 0 0] 0.01

controlDict
|-> Has a bunch of keyword value pairs
|-> Has time control and write control
fvSchemes
|->fintite volume discretization schemes
|->ddtSchemes
|->gradSchemes
|->divSchemes
|->laplacian
|->Etc…

fvSolutions
|->solvers
| {
| variable_name
| {
| solver solver_name;
| preconditioner name;
| tolerance value;
| reltol value;
| }
| }
|
|->Global_Algorithm_Settings
| {
| …..
| }
|
|->relaxationFactors
| {
| variableName value
| }

Banana Trick : keywords and values for dictionaries for different solvers. Put blank stuff for
getting the list of schemes

Mesh
|->At start of simulation located in constant/polyMesh
|-> Points, Faces, Owner, Neighbour, Boundary

List always defined in


|-> (
| ….
| )
Field : Initial and BC
|->dimension [0 2 -1 0 0 0 0];
|->internalField uniform (0 0 0)
|->boundaryField
| {
| patch_name
| {
| type type_name;
| value value;
| }
| }

Utilities
|-> Based under system

controlDict -> Custom functions – which run once every timestep


|->function
| (
| forces
| {
| type forces;
| functionObjLibs (“precompiled.so”);
| …..
| }
| )

Run checkMesh : Mesh non-orthogonality max < 90 !!Important check


|-> Overall Bounding Box – always in m

Running the code


|-> solvername | tee log_fileName

Residuals
|-> Command : foamLog log_fileName
|-> cd logs/
|-> xmgrace variable_name
OR
|-> Command : pyFoam

Other_Utilities
|->foamCalc – calculate gradients
Source Code
|-> solvers/basic/scalarTransportFoam
|->Make
|->files : name of exec and location
|->options : include & library folders
|-> scalarTransportFoam.C
|-> lnInclude/fvCFD.H
|->foamTime.H : define object of class time
|->fvMesh.H : define mesh object
|->argList.H : contains list of arguments for the certain job
|->createFields.H

Build Commands
|->wmake
|->wclean
|->wmake libso

For new file templates


|->foamNew H exampleclass : header
|->foamNew C exampleclass: implementation file
|->foamNew I exampleclass: inline function file
|->foamNew IO exampleclass: io selection file
|->foamNew App exampleclass: application file

To access variables
|-> T.internalfield()[index]

functionObject
|->system/controlDict
|->function
(
newFunctionObject
{
type hrvsFunctionObject;
functionObjectLibs(“libpost.so”);
}
);

hrvsFunctionObject.H
|->#include ”functionObject.H”
| #include “dictionary.H”
| #include “fvMesh.H”
|
| namespace Foam{
| class hrvsFunctionObject:public functionObject
| {
| const Time& time_;
| word RegionName_;
| wordlist ObjectNames_;
| label intervals_;
| private:
| public:
| TypeName(“hrvsFunctionObject”);
| //Constructors

hrvsFunctionObject.C
//constructors
Foam:: hrvsFunctionObject:: hrvsFunctionObject
( const word& name_;
const Time& T;
const dictionary& dict;
) : functionObjectName(name),time_t(t),regionName_(polyMesh::defaultRegion),…..

bool Foam:: hrvsFunctionObject::excecute()


{

createFields.H
|-> word fieldname(transportProperties.lookup(“field”));
|->label cellindex(readLabel(transportProperties.lookup(“index”)));

This checks for field in constant/transportProperties;


transportProperties
|-> field T;
|->index 164;

Now T.internalField()[cellindex]

Create new folder > system/samplingProperties

Now create readSampling.H


|->IOdictionary sampling Properties
(
IOObject
{

}
|-> word fieldname(smaplingProperties.lookup(“field”));
|->label cellindex(readLabel(samplingProperties.lookup(“index”)));

Now in myscalartransportFoam.c
“# include ‘readSampling.H’”

You might also like