Reading OpenFOAM Variables
Hi all,
I am new to OpenFOAM source code. I wanted to know where in OpenFOAM code the variables are read. e.g. if you open the createFields.H for icoFoam you will find Info<< "Reading transportProperties\n" << endl; IOdictionary transportProperties ( IOobject ( "transportProperties", runTime.constant(), mesh, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE ) ); dimensionedScalar nu ( transportProperties.lookup("nu") ); Info<< "Reading field p\n" << endl; volScalarField p ( IOobject ( "p", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); I hope these lines are reading the P, U and transportProperties directory. I tried to debug in createFields.h file but I am not able to reach in source files where the P,U and nu and their respective dimensions are read. Can anybody tell me about the source files where OpenFoAM reads its variables. with regards. |
OpenFOAM reinvents the wheel... it has its own input and output stream classes defined. Not sure why you want to go that deep into the OpenFOAM library.
The two objects you list above are different. transportProperties is an IOdictionary, p is a volScalarField, which is actually a typedef of GeometricField. If you look through these two classes, you will see they have many constructors defined. The ones being used above are "read constructors", although it may not be explicitly mentioned in the source. These constructors find a file in your case directory and look up all the information they need from this file. So, the constructors only require the information necessary to locate the file, and possible references to other objects they may need, such as volScalarField needs the mesh object. I believe most read constructors use operator>>, so you could look at this operator in each class. You might want to read up on the objectRegistry to find out more. http://openfoamwiki.net/index.php/Op...objectRegistry |
Hello,
I am trying to use the forces class to write a mesh motion class. When initializing a forces object, one needs the objectRegistry. The constructor is Code:
forces |
Hello,
The "mesh" object inherits from objectRegistry. So just pass the object "mesh". Actually in Quote:
IOobject ( const word& name, const fileName& instance, const objectRegistry& registry, readOption r=NO_READ, writeOption w=NO_WRITE, bool registerObject=true );Good luck |
Thank you very much for this tip. I cannot pass mesh as argument, because it is not (yet) in my class. When I do
Code:
forces f("forces", mesh, forcesDict); Code:
hppGgiFvMesh.C:358: error: ‘mesh’ was not declared in this scope |
All times are GMT -4. The time now is 11:53. |