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

Linking new class to solver

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 25, 2005, 07:02
Default Hello, I would like write m
  #1
Senior Member
 
Markus Hartinger
Join Date: Mar 2009
Posts: 102
Rep Power: 17
hartinger is on a distinguished road
Hello,

I would like write my own class to extend icoFoam.
The class is defined in deflection.H and deflection.C, which are in the same directory as the solver. I included deflection.C in Make/files.
That works fines and everything compiles as long as I dont want to call any member functions of that class. If i call one of them it returns
> In function 'main':
> :undefined reference to 'main::deflection::test()'

I assume, I need to inclucde some command in Make/options, but I couldn't figure out which one.

thank you
Markus
hartinger is offline   Reply With Quote

Old   April 25, 2005, 07:17
Default Hi again, reading the forum
  #2
Senior Member
 
Markus Hartinger
Join Date: Mar 2009
Posts: 102
Rep Power: 17
hartinger is on a distinguished road
Hi again,

reading the forum helps. See the "namespace" thread.
I was putting the #include "deflection.H" into the main function, which i shouldn't do apparently, dunno why, though.

Sorry for this self-conversation
Markus
hartinger is offline   Reply With Quote

Old   April 25, 2005, 07:25
Default deflection.H contains declarat
  #3
Senior Member
 
Join Date: Mar 2009
Posts: 854
Rep Power: 22
henry is on a distinguished road
deflection.H contains declarations and deflection.C contains definitions which you compile outside the scope of main. Then you wish to use the classes/functions from within main but you need to tell the compiler that they are declared in a different scope which is done my including deflection.H in the file containing the main function but not inside the main function because that would change the scope of the classes/functions and hence give you the linkage error you had before.
henry is offline   Reply With Quote

Old   April 25, 2005, 07:36
Default thank you, i didn't think abou
  #4
Senior Member
 
Markus Hartinger
Join Date: Mar 2009
Posts: 102
Rep Power: 17
hartinger is on a distinguished road
thank you, i didn't think about the scope
hartinger is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
linking several faces Christian F. FLUENT 1 June 6, 2008 07:29
How to access solver fields from fvPatchField%2360Type derived class that defines BC kar OpenFOAM Running, Solving & CFD 0 February 29, 2008 13:41
Problem for linking hsing OpenFOAM Running, Solving & CFD 2 April 19, 2006 05:07
Linking fortran and c vasanth Main CFD Forum 3 January 29, 2005 13:38
linking the script Mavinakere FLUENT 0 September 12, 2002 12:57


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