Why isn't there a #include in the createField.H header file?
Hello, Why isnt there a #include in the createField.H header file of the icoFoam solver?
# Info<< "Reading transportProperties\n" << endl; IOdictionary transportProperties ( IOobject ( "transportProperties", runTime.constant(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ) ); dimensionedScalar nu ( transportProperties.lookup("nu") ); # It's my understanding that here an object named "transportProperties" of class "IOdictionary" is created. But where is the class declaration for IOdictionary?. Shouldn't there be a header file having the declaration for the IOdictionary be included here? informative: 1) https://www.cfd-online.com/Forums/op...tregistry.html 2) https://stackoverflow.com/questions/...g-code-example 3) Explained: http://openfoamwiki.net/index.php/Ho..._with_OpenFOAM |
You shouldn't look at these files individually. The file createFields is part of the solver icoFoam. Take a look at how the C/C++ compilation process works. There is the concept of a compilation unit, and createFields is part of the compilation unit icoFoam. Thus, all the includes that define types, such as IOdictionary, have been included somewhere in icoFoam.
Below, are all the lines of icoFoam up to the point, where createFields gets included. Code:
#include "fvCFD.H" |
Quote:
Can you please tell me about the way in which IOdictionary class is used here? there is no object name next to the class name. Instead, am I right in thinking, the object name 'transportProperties' is given as an argument in the IOobject constructor? Why not give it something like: IOobject transportProperties ( runTime.constant(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ) ? I thought it could be an anonymous class object but it does have object name 'transportProperties'. |
Quote:
If you compare multiple solvers, e.g. icoFoam, simpleFoam and pimpleFoam, you will find many similarities between them. Furthermore, compare an incompressible with a compressible solver, you will commonalities and differences. As you have said, it is best to define/implement things that are often used just once, and reuse this unique implementation. Quote:
Think of the #include statements as a formalized copy&paste, the compiler pastes the content of the header file where the include statement is found. This also works recursively, i.e. a header can include another header. gcc has an option to write the final product of the preprocesser, i.e. the result of all includes The best way to learn about OpenFOAM is to study its code. |
All times are GMT -4. The time now is 15:14. |