|
[Sponsors] |
OF-2.2.x: Derived class from cellZone and "undefined symbol error" |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
March 18, 2014, 12:10 |
OF-2.2.x: Derived class from cellZone and "undefined symbol error"
|
#1 |
Member
Join Date: Jul 2011
Posts: 54
Rep Power: 15 |
I derived a class from the cellZone class. The most important things of the .H file are:
Code:
namespace Foam { class specialVolume : public cellZone { protected: const cellZone& zone_; ... //Constructor specialVolume(const cellZone& cz); ... } } Code:
... //Constructor Foam::specialVolume::specialVolume ( const cellZone& cz ) : cellZone(cz), //constructor of cellZone (base class) has to be called before attributes zone_(cz) {} ... Code:
const cellZoneMesh& czm(mesh.cellZones()); specialVolume specVol(czm[0]); Code:
interPhaseChangeFoam: symbol lookup error: /home/OpenFOAM/user-2.2.x/platforms/linux64GccDPOpt/lib/libspecial.so: undefined symbol: _ZN4Foam8cellZoneC2ERKS0_ Has anybody an idea what I could be doing wrong in this code? Thank you very much. |
|
March 23, 2014, 16:41 |
|
#2 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Greetings A_Pete,
Knowing the contents of "Make/files" and "Make/options" for your custom library would help. It would also help to know how exactly you've built it (i.e., the commands used). Because without that information, my guess from that error message is that the problem is one of the following:
Bruno
__________________
|
|
March 24, 2014, 10:54 |
|
#3 |
Member
Join Date: Jul 2011
Posts: 54
Rep Power: 15 |
Hi Bruno,
first of all thank you very much for your answer. To complete my post, my "Make/files" looks like this: Code:
cavEroNew/cavEroNew.C cavEroNew/cavEroNewFunctionObject.C erosionPatch/erosionPatch.C erosionPatch/erosionVolume.C //- was called specialVolume.C before LIB = $(FOAM_USER_LIBBIN)/libcaveroTEST And my "Make/options" looks like this: Code:
EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/OpenFOAM/lnInclude LIB_LIBS = \ -lfiniteVolume \ -lOpenFOAM I also had in mind that "-lOpenFOAM" needs to be added, but this didn't help as I had it already in my "Make/options". The error was still the same. To 2): I just have OpenFOAM 2.2.x installed right now. I didn't have any other version on my computer installed. To 3): Thanks for your hint. I think that this is where the problem lies! But I am not sure how to solve it. When I derive a class "erosionVolume" from a base class "cellZone", am I able to call the private constructor of the cellZone class? What I want is this: I want a new class "erosionVolume", that can be constructed by: a) just a cellZone or b) a cellZone and a name/label to identify it. For now, I would like to realize just option a): I want to construct my erosionVolume, by initializing it with a cellZone. The problem is, that in my erosionVolume.C a constructor of the cellZone class has to be called in order to be able to use all its properties in my derived class, right? This is what I have shown in the .C file in my first post: Code:
... : cellZone(cz), //constructor of cellZone (base class) zone_(cz) ... Any further help would be appreciated. Thank you very much. Best regards, Andreas |
|
March 31, 2014, 10:35 |
How to assign a cellZone to derived class?
|
#4 |
Member
Join Date: Jul 2011
Posts: 54
Rep Power: 15 |
I have now edited my code so that I am able to use a constructor of the cellZone class. The header and source file got modified in the following way:
Header: Code:
... protected: const cellZoneMesh& zoneMesh_; ... public: erosionVolume(const cellZoneMesh&); ... Code:
namespace Foam { ... const labelUList emptyList(0, 0); } Foam::erosionVolume::erosionVolume ( const cellZoneMesh& zm ) : cellZone(name, emptyList, 0, zm), zoneMesh_(zm) {} ... The question is now, how I can assign a cellZone to my derived class? Just like erosionVolume = cellZone. |
|
April 5, 2014, 17:59 |
|
#5 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Hi Andreas,
Sorry, I'm a bit short on time for the past and coming weeks, so could you please provide an example test case + source code to make it easier for me to test this and to to try and to figure out the issue? Because OpenFOAM uses C++ in such a way, that only looking at the source code is not enough to figure out the issue, unless one has a lot of experience with the code... and I'm not that good yet with it Best regards, Bruno
__________________
|
|
April 25, 2014, 14:57 |
|
#6 | ||
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
For future readers, here's small report on the information exchanged on this topic, from private messages exchanged with Andreas, just in case someone in the future want to ask about this as well.
The objective was/is to have a class that can manage a keep track of a "cellZone" and do additional operations to that "cellZone", such as calculate equations, do averages, keep a history and so on. On my first iteration of looking into this, the hypothesis was to perhaps use an "fvOption", but: Quote:
Quote:
But then again, as I mentioned before, multi-region capabilities for this case might be overkill and possibly will need more RAM then it should be necessary. Best regards, Bruno
__________________
|
|||
April 28, 2014, 02:53 |
|
#7 | |
Member
Join Date: Jul 2011
Posts: 54
Rep Power: 15 |
Thanks for the update, Bruno.
I will also update this thread given my last message to Bruno. Quote:
Andreas |
||
Tags |
base class, cellzones, constructor, inheritance |
|
|