CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM

problems with compiling self defined class

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

Reply
 
LinkBack Thread Tools Display Modes
Old   June 15, 2010, 03:51
Unhappy problems with compiling self defined class
  #1
New Member
 
Victor Fleischer
Join Date: Nov 2009
Posts: 21
Rep Power: 8
Victor is on a distinguished road
Hi at all,

i tried to implement my own class(class Tracing) which follows the flameFront and writes the current position of the flame to a file.
So i wrote two files:

Tracing.H

Tracing.C

After including flameTrace.H in my solver and creating an Object of this class by
...
Tracing flameTip;
...
and using the two methods for following the flame and write the position to the file, by:

flameTip.follow();
...
flameTip.write();

I allways get this error message while compiling the solver:


Make/linux64GccDPOpt/reactingTotalFoamFE2.o: In function `main':
reactingTotalFoamFE2.C.text+0x338f): undefined reference to `main::Tracing::Tracing()'
reactingTotalFoamFE2.C.text+0x9bdf): undefined reference to `main::Tracing::~Tracing()'
reactingTotalFoamFE2.C.text+0xa74b): undefined reference to `main::Tracing::follow()'
reactingTotalFoamFE2.C.text+0xa79e): undefined reference to `main::Tracing::writeToFile()'
reactingTotalFoamFE2.C.text+0xdb2a): undefined reference to `main::Tracing::~Tracing()'
collect2: ld returned 1 exit status
make: *** [/nfs/home/fleischer/OpenFOAM/fleischer-1.6.x/applications/bin/linux64GccDPOpt/reactingTotalFoamFE2] Error 1

I don't know what "undefined reference to main::Tracing::....." shoud mean!?

Can anybody help me please!

Thanks a lot in advance!

Victor
Victor is offline   Reply With Quote

Old   June 15, 2010, 04:19
Default
  #2
Senior Member
 
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 15
l_r_mcglashan will become famous soon enough
That seems odd. Have you changed Make/options and/or Make/files as well? Is this part of a library or are you compiling it with the solver?

And are you sure you meant flameTrace.H instead of Tracing.H:

Quote:
After including flameTrace.H in my solver and creating an Object of this class by
__________________
Laurence R. McGlashan :: Website
l_r_mcglashan is offline   Reply With Quote

Old   June 15, 2010, 05:02
Default
  #3
New Member
 
Victor Fleischer
Join Date: Nov 2009
Posts: 21
Rep Power: 8
Victor is on a distinguished road
Thank you l_r_mcglashan, I think there are different problems but the basic one is that i didn't know that i need a make-folder for compiling the header file correctly.
I think i will try the whole thing in a easier way....but thanks a lot for your help!
Victor is offline   Reply With Quote

Old   June 15, 2010, 05:07
Default
  #4
Senior Member
 
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 15
l_r_mcglashan will become famous soon enough
Grabbing an example from the sources, have a look at the application heatTransfer/chtMultiRegionFoam. See how the regionProperties class is used.
__________________
Laurence R. McGlashan :: Website
l_r_mcglashan is offline   Reply With Quote

Old   June 15, 2010, 05:38
Default
  #5
New Member
 
Victor Fleischer
Join Date: Nov 2009
Posts: 21
Rep Power: 8
Victor is on a distinguished road
Thank you, the regionProperties helps a lot. The problem I have at the moment is that my class Tracing needs the mesh information for calculating the flame position. For example I have to use mesh.C(). I don't know how to handle this, because I don't know how to deliver the mesh Information to my header file.
I tried to use a genererell objectRegistry in the the constructor Tracing(objectRegistry reg0,...), but there doesn't exist a .C() data.
Perhaps you know an example of an header-file that uses the mesh data in any way!?
Something i also do not understand is the declaration of a namespace
namespace Foam
{.....
...}

before the declaration of the class. Could you explain to me, why this is necessary?
Thanks a lot in advance!

Victor
Victor is offline   Reply With Quote

Old   June 15, 2010, 06:11
Default
  #6
Senior Member
 
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 15
l_r_mcglashan will become famous soon enough
Pass the mesh as an argument to the constructor:

header file:

Code:
        
class Tracing
{
    const fvMesh& mesh_;

    Tracing
    (
        const fvMesh& mesh
    );
}
source file:
Code:
Foam::Tracing::Tracing
(
    const fvMesh& mesh
)
:
    mesh_(mesh)
{}
Then you can use mesh_ in that class.

The Foam namespace isn't declared before the class,. The class is part of the namespace Foam. So Foam::regionProperties is its full name. In chtMultiRegionFoam.C you'll see:

regionProperties rp(runTime);

The full type would be Foam::regionProperties rp(runTime); but in the fvCFD.H file there's a using namespace Foam declaration.
__________________
Laurence R. McGlashan :: Website
l_r_mcglashan is offline   Reply With Quote

Old   June 21, 2010, 02:54
Default
  #7
New Member
 
Victor Fleischer
Join Date: Nov 2009
Posts: 21
Rep Power: 8
Victor is on a distinguished road
Oh, thank you really much! This is exactly I was looking for!
Victor is offline   Reply With Quote

Reply

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
OpenFOAM13 for Mac OSX Darwin 104 hjasak OpenFOAM Installation 70 September 24, 2010 05:06
Problems compiling under 14 grtabor OpenFOAM Running, Solving & CFD 9 July 17, 2007 22:34
User Defined Scalars - Returning Values Carlos V. FLUENT 0 April 19, 2006 18:18
Some problems with Star CD Micha CD-adapco 0 August 6, 2003 13:55
Compiling MON FLUENT 0 October 20, 2002 20:48


All times are GMT -4. The time now is 16:48.