CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

member function [value()] of dimensioned<Type> class

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 8, 2010, 02:02
Default member function [value()] of dimensioned<Type> class
  #1
New Member
 
Sang Bong Lee
Join Date: Nov 2009
Posts: 5
Rep Power: 17
sblee1977 is on a distinguished road
I tried to understand the code of OpenFOAM, specifically simplefoam, but I met a small obstacle in the usage of value() function which is a memeber function of dimensioned<Type> class.

In the constructor of Time class, setControls() is executed and setControls calls the function of setTime(starTime_, 0). In the function of setTime, value()=newTime is not clear.

Let me take a similar example.
#include <iostream>
using namespace std;
template<class Type>
class dimensioned {
Type value_;
public:
Type& value() { return value_;}
};
int main() {
int Rvalue=1;
dimensioned<int> myType;
myType.value()=Rvalue;
return 0;
}
In the above examle, the member function of value() cannot be used without class name. But in the function of setTime it was called without class name. I am looking forward to your kind reply because I am a beginner of C++.
sblee1977 is offline   Reply With Quote

Old   November 9, 2010, 03:57
Default
  #2
Senior Member
 
Stefan Herbert
Join Date: Dec 2009
Location: Darmstadt, Germany
Posts: 129
Rep Power: 17
herbert is on a distinguished road
Hi,

I think value() can be used in this way, because it is a member of the class itself, even it is not defined in Time explicitly. But this class seems to be somehow derived form dimensionedType and therefore it is known.

It just the same as setControls() is used. (without object because it should work on object itself).

Regards,
Stefan
herbert is offline   Reply With Quote

Old   November 9, 2010, 04:52
Default Re_questions
  #3
New Member
 
Sang Bong Lee
Join Date: Nov 2009
Posts: 5
Rep Power: 17
sblee1977 is on a distinguished road
Quote:
Originally Posted by herbert View Post
Hi,

I think value() can be used in this way, because it is a member of the class itself, even it is not defined in Time explicitly. But this class seems to be somehow derived form dimensionedType and therefore it is known.

It just the same as setControls() is used. (without object because it should work on object itself).

Regards,
Stefan
Thank you for your reply.
My limited knowledge of C++ does not makes me fully understand your reply yet. It is clear that both setControls() and setTime() are used without instance because they are defined inside Time class. But value() is defined in dimensioned<Type> class (not in Time class), so I think that value() could be called in Time class with instance as following
dimensioned<scalar> myType;
myType.value();

Thank you for your reply in advance...

Last edited by sblee1977; November 9, 2010 at 20:31.
sblee1977 is offline   Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compile problem ivanyao OpenFOAM Running, Solving & CFD 1 October 12, 2012 10:31
latest OpenFOAM-1.6.x from git failed to compile phsieh2005 OpenFOAM Bugs 25 February 9, 2010 05:37
Version 15 on Mac OS X gschaider OpenFOAM Installation 113 December 2, 2009 11:23
Errors running allwmake in OpenFOAM141dev with WM_COMPILE_OPTION%3ddebug unoder OpenFOAM Installation 11 January 30, 2008 21:30
[blockMesh] Axisymmetrical mesh Rasmus Gjesing (Gjesing) OpenFOAM Meshing & Mesh Conversion 10 April 2, 2007 15:00


All times are GMT -4. The time now is 11:47.