CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   namespace Foam (http://www.cfd-online.com/Forums/openfoam/93847-namespace-foam.html)

Argen October 27, 2011 20:10

namespace Foam
 
namespace Foam
{
namespace radiation
{
defineTypeNameAndDebug(P1, 0);

addToRunTimeSelectionTable
(
radiationModel,
P1,
dictionary
);
}
}

Anyone can explain the above code line by line?

kathrin_kissling October 28, 2011 02:55

your within namespace Foam
namespace radiation

a typeName is defined

the P1 model is added to the runTime selection table

What is your question? Can you please clarify what is unclear?

Best

Kathrin

marupio October 28, 2011 10:53

The first two lines are namespaces, as kathrin mentioned. If you don't know what those are, they are basic components of C++ created recently to avoid name collisions. If your book is old, it won't mention them - try googling it.

The next two are macros. OpenFOAM is full of macros. Many coding standards forbid all macros (except includes and include guards), but not in OpenFOAM. These make the code more difficult to read for a new-comer... but they also make it easier to work with. Many pros and cons. Anyways...

defineTypeNameAndDebug
OpenFOAM has a type naming convention to help keep track of the types of classes. These macros are in one of the files in src/OpenFOAM/db/typeInfo. Basically, just holds a word with the name of the class.

addToRunTimeSelectionTable
This is part of OpenFOAM's runTime selection mechanism. This is described here: http://openfoamwiki.net/index.php/Op...tion_mechanism
You probably don't want to go too deep into figuring it out - rather, just know it is part of the underlying machinery that other objects use to call its constructors.

Hope that helps.

kathrin_kissling October 31, 2011 03:34

Hi David,

thank you for the typeInfo information. This is very helpful. I really searched for them but it was very hard to find!

Best

Kathrin


All times are GMT -4. The time now is 19:36.