|
[Sponsors] |
Why isn't there a #include in the createField.H header file? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 19, 2019, 09:13 |
Why isn't there a #include in the createField.H header file?
|
#1 |
Senior Member
Mandeep Shetty
Join Date: Apr 2016
Posts: 188
Rep Power: 10 |
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) IOobject and objectRegistry 2) https://stackoverflow.com/questions/...g-code-example 3) Explained: http://openfoamwiki.net/index.php/Ho..._with_OpenFOAM Last edited by granzer; November 21, 2019 at 01:40. |
|
November 20, 2019, 05:12 |
|
#2 |
Senior Member
Gerhard Holzinger
Join Date: Feb 2012
Location: Austria
Posts: 342
Rep Power: 28 |
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" #include "pisoControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) { #include "setRootCaseLists.H" #include "createTime.H" #include "createMesh.H" pisoControl piso(mesh); #include "createFields.H" |
|
November 20, 2019, 08:24 |
|
#3 | |
Senior Member
Mandeep Shetty
Join Date: Apr 2016
Posts: 188
Rep Power: 10 |
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'. |
||
November 21, 2019, 06:28 |
|
#4 | ||
Senior Member
Gerhard Holzinger
Join Date: Feb 2012
Location: Austria
Posts: 342
Rep Power: 28 |
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. |
|||
Tags |
icofoam |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Using PengRobinsonGas EoS with sprayFoam | Jabo | OpenFOAM Running, Solving & CFD | 36 | July 16, 2024 04:52 |
Custom Thermophysical Properties | wsmith02 | OpenFOAM | 4 | June 1, 2023 15:30 |
[swak4Foam] swak4foam for OpenFOAM 4.0 | mnikku | OpenFOAM Community Contributions | 80 | May 17, 2022 09:06 |
[swak4Foam] swak4foam building problem | GGerber | OpenFOAM Community Contributions | 54 | April 24, 2015 17:02 |
OpenFoam install script Error during paraFoam installation | SePe | OpenFOAM Installation | 10 | June 19, 2010 16:15 |