CFD Online Logo CFD Online URL
Home > Forums > OpenFOAM Running, Solving & CFD

Macros TypeName() , ClassName(), defineTypeNameAndDebug()...

Register Blogs Members List Search Today's Posts Mark Forums Read

LinkBack Thread Tools Display Modes
Old   March 23, 2009, 08:01
Default Macros TypeName() , ClassName(), defineTypeNameAndDebug()...
Senior Member
Join Date: Mar 2009
Posts: 248
Rep Power: 9
jaswi is on a distinguished road
Dear Forum Users

Greetings to Everybody....

I have some doubt about how the macros ClassName, TypeName and defineTypeNameAndDebug have been defined. Here is what I have found...

1st the Macro ClassName("TypeNameString");

    static const char* typeName_() { return TypeNameString; }        \
    static const ::Foam::word typeName;                                       \
    static int debug
Based on its call in primitiveMesh - ClassName("primitiveMesh"), it does 3 things:
  • declare and define an inline function "typeName_()" , which simply returns the TypeNameString i.e. primitiveMesh;
  • declare a static constant variable of type word in the global namespace (some please confirm this , as I am not sure)
  • declare an integer variable for the debug flag (used later in another macro)
Now the defineTypeNameAndDebug(Type, DebugSwitch)

               const ::Foam::word Type::typeName            \
                (                                                           \
                  Type::typeName_()                                \
                );                                                         \
int Type::debug(                                                      \
                ::Foam::debug::debugSwitch                      \
                  (                                                         \
                   Type::typeName_(),                               \
                   DebugSwitch                                         \
                   )                                                         \
Based on its call, again in class primitiveMesh -
it will call two functions , namely:

  • typeName()
substituting for the primitiveMesh, this inline function will read
const ::Foam::word primitiveMesh::typeName          
It will ultimately return the string "primitiveMesh"
  • debug()
int primitiveMesh::debug(                                           
this is basically a call to the function debugSwitch() defined in the nameSpace debug. The arguments are clear i.e. String returned by the function typeName_() and the integer value 0

The problematic Macro is the macro TypeName(TypeNameString)

defined in the typeInfo.H, it reads:

ClassName(TypeNameString);                                \
virtual const word& type() const { return typeName; }
This macro first invokes the macro ClassName and further implements an inline virtual function type(). If we substitute for the macro ClassName and expand the macro for the class polyMesh i.e TypeName("polyMesh") , it reads:
static const char* typeName_() { return polyMesh; }        \
static const ::Foam::word typeName;                                       \
static int debug;
virtual const word& type() const { return typeName; }
The question is related to this function type(). It returns the static const variable typeName declared in the macro ClassName. But where does the initialization of this keyword takes place.

Please share it with the forum if anybody knows about this.

Thanks for the attention


Last edited by jaswi; March 23, 2009 at 14:50. Reason: The question was not well formulated initially
jaswi is offline   Reply With Quote


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
help with macros F_ID and C_ID Jack Martinez FLUENT 0 August 19, 2007 08:27
Problems with Airpak - Copy Macros, diffuser Nelson FLUENT 0 May 20, 2007 22:56
What are UDF macros C_T_S , C_T_AP,...???? Asghari FLUENT 0 January 28, 2007 11:54
udf error in some macros Asghari FLUENT 0 August 7, 2006 01:10
Orientation of Face Variable Macros hirokata FLUENT 0 February 17, 2006 01:12

All times are GMT -4. The time now is 20:30.