Difference between revisions of "HowTo use Doxygen with OpenFOAM"

From OpenFOAMWiki
(Specific Example 1: IOdictionary in icoFoam)
 
Line 94: Line 94:
  
 
[[How_to_add_temperature_to_icoFoam|Return to How to add temperature to icoFoam]]
 
[[How_to_add_temperature_to_icoFoam|Return to How to add temperature to icoFoam]]
 +
 +
[[Category:Tutorials]]

Latest revision as of 11:18, 21 October 2013

1 Using Doxygen to learn how OpenFOAM works

This page is an attempt to describe how to use the Doxygen file system to learn how OpenFOAM functions work. It is written for beginners, though also from a beginner's perspective.

2 Specific Example 1: IOdictionary in icoFoam

The icoFoam solver contains code which reads in the kinematic viscosity. This will provide the first example of using the Doxygen system to understand how OpenFOAM functions work.

The relevant code in the icoFoam file: createFields.H is as follows:

    Info<< "Reading transportProperties\n" << endl;

    IOdictionary transportProperties
    (
        IOobject
        (
            "transportProperties",
            runTime.constant(),
            mesh,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        )
    );

    dimensionedScalar nu
    (
        transportProperties.lookup("nu")
    );

There are several functions and objects in use in this example. Overall, what this set of code is saying is to do the following items:

  • Display a string of text to output informing the user that the transportProperties file is being read.
  • Create a new IOdictionary object called "transportProperties" by reading an IOobject of specific type and name
  • Create a new dimensionedScalar, "nu", by using the "lookup" function on the IOdictionary, "transportProperties"


The first item is to determine what the IOdictionary class does. Either by using the online documentation, or the one provided with your distribution of OpenFOAM, select the "Classes" option. This will bring up an extensive list of all the classes available in OpenFOAM. Scroll through the list to find "IOdictionary" and select it. IOdictionary inheritance diagram

The inheritance diagram indicates the the IOdictionary class inherits from both the "dictionary" class and the "regIOobject" class. A number of other classes inherit from the IOdictionary and these are shown in the diagram.

In the list of "public member functions" there are several options:

  • Two constructors are given:
    • A constructor which relies on only an IOobject class
    • A constructor which relies on an IOobject and a dictionary.
  • the "name" function
  • the "readData" function
  • the "writeData" function, and
  • an "operator=" function

This article will only discuss those functions needed to describe the code above.

Since this code creates an instance of the IOdictionary class, calling it "transportProperties", the constructor functions are the important ones. In this example, the first constructor, the one needing only the IOobject for its creation is utilized.

It is now necessary to examine the IOobject class. One can easily do this by clicking on the "IOobject" link inside of the constructor function description. Online Doxygen page for IOobject.

In this case, the constructor needs at least the following items:

  • name,
    • class type: word
    • class type word can be constructed from a simple string, among other options
    • this case uses the word: "transportProperties"
  • instance,
    • class type: filename
    • class type filename can be constructed from a string or word, amongst other options
    • this case uses the instance: "runTime.constant()"
  • registry,
    • class type: objectRegistry
    • class type objectRegistry is constructed from a time
    • this case uses the time given by: "mesh", defined earlier
  • io options
    • Read option is given first, and then the write option
    • these options are defined in the IOobject class
    • in this case, MUST_READ and NO_WRITE are used

Therefore, we see that the file named "transportProperties" found in the "constant" subdirectory is found. The file must be read and is not written over. The data is identified with the "mesh" created elsewhere. All these items can be examined in more detail by clicking on them in the Doxygen page.

Returning to this specific example, we see that this results in a new IOdictionary item being created from a base file.

Now, the next line makes use of the "lookup" function to return an actual parameter from the file just specified. One notices that this function is not defined in the IOdictionary class. Rather, this function is inherited from the base class, "dictionary". This can be accessed by clicking on the box labeled "dictionary" in the inheritance diagram. Within the class is found function "lookup" which takes a "word" data type and returns a value.

Return to How to add temperature to icoFoam