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

At runtime, undefined symbol error from classes derived from Function1 class

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 30, 2018, 12:37
Default At runtime, undefined symbol error from classes derived from Function1 class
  #1
New Member
 
SSSSS
Join Date: Jun 2011
Posts: 28
Rep Power: 14
doctorWho is on a distinguished road
Hi,


I am trying to make classes with template pattern from Function1 class with OpenFOAM 5.
compilation was done without any errors and warnings.


There is an error in runtime as follows:


simpleFoam: symbol lookup error: /home/abs/OpenFOAM/abs-6/platforms/linux64GccDPInt32Opt/lib/libFlowProfile.so: undefined symbol: _ZN4Foam14Function1Types15FlowProfileINS_6VectorId EEEC2ERKNS_4wordERKNS_10dictionaryE


classes are composed as follows:


Function1 <--- FlowProfile <--- uniformProfile


where FlowProfile is a abstract template class and uniformProfile is a derived class with vector binding.


without FlowProfile abstract class, I could make uniformProfile working in my simulation. But I want to make a group of my flow profiles with FlowProfile abstract class.



It is a kind of template class things, so I could not figure out what is going on and how to fix the runtime error. Any help will be appreciated.


FYI, source codes are listed below.



FlowProfile classes read as follows:



#ifndef FlowProfile_H
#define FlowProfile_H

#include "Function1.H"

namespace Foam
{
namespace Function1Types
{

template<class Type>
class FlowProfile
:
public Function1<Type>
{
protected:

scalar uRef_;
scalar zRef_;

vector flowDir_;

private:

void read(const dictionary& coeffs);
void operator=(const FlowProfile<Type>&);

public:

FlowProfile
(
const word& entryName,
const dictionary& dict
);


virtual ~FlowProfile();

virtual Type value(const scalar t) const = 0;

};

} // End namespace Function1Types
} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#define makeVectorFunction1(SS) \
\
defineTypeNameAndDebug(SS, 0); \
\
Function1<vector>::adddictionaryConstructorToTable <FieldFunction1<SS>> \
add##SS##ConstructorToTable_;

#endif

// ************************************************** *********************** //





FlowProfile.C


#include "FlowProfile.H"

// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

template<class Type>
void Foam::Function1Types::FlowProfile::read(const dictionary& coeffs)
{
uRef_ = coeffs.lookup<scalar>("uRef");
zRef_ = coeffs.lookup<scalar>("zRef");
flowDir_ = coeffs.lookupType<vector>("flowDir");
}

template<class Type>
Foam::Function1Types::FlowProfile<Type>::FlowProfi le
(
const word& entryName,
const dictionary& dict
)
:
Function1<Type>(entryName)
{
read(dict);
}


// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

template<class Type>
Foam::Function1Types::FlowProfile<Type>::~FlowProf ile()
{}



uniformProfile classes read as follows:


#ifndef uniformProfile_H
#define uniformProfile_H

#include "FlowProfile.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{
namespace Function1Types
{

class uniformProfile
:
public FlowProfile<vector>
{
void operator=(const uniformProfile&);

public:

TypeName("uniformProfile");

uniformProfile
(
const word& entryName,
const dictionary& dict
);


virtual ~uniformProfile();

virtual inline vector value(const scalar t) const;
virtual void writeData(Ostream& os) const;

};


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace Function1Types
} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#include "uniformProfileI.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif




uniformProfileI.H


#include "uniformProfile.H"

// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

inline Foam::vector Foam::Function1Types::uniformProfile::value
(
const scalar t
) const
{
return uRef_*flowDir_;
}




uniformProfile.C


#include "uniformProfile.H"

// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

namespace Foam
{
namespace Function1Types
{
makeVectorFunction1(uniformProfile);
}
}


// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

Foam::Function1Types::uniformProfile::uniformProfi le
(
const word& entryName,
const dictionary& dict
)
:
FlowProfile(entryName, dict)
{}


// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

Foam::Function1Types::uniformProfile::~uniformProf ile()
{}

// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

void Foam::Function1Types::uniformProfile::writeData(Os tream& os) const
{
Function1<vector>::writeData(os);
os << token::END_STATEMENT << nl;
os << indent << word(this->name() + "Coeffs") << nl;
os << indent << token::BEGIN_BLOCK << incrIndent << nl;
os.writeKeyword("uRef") << uRef_ << token::END_STATEMENT << nl;
os.writeKeyword("zRef") << zRef_ << token::END_STATEMENT << nl;
os.writeKeyword("flowDir") << flowDir_ << token::END_STATEMENT << nl;
os << decrIndent << indent << token::END_BLOCK << endl;
}


Make/files reads as follows:
unction1/FlowProfile/uniformProfile/uniformProfile.C
LIB = $(FOAM_USER_LIBBIN)/libFlowProfile


Make/options reads as follows:
EXE_INC = \
-I$(OBJECTS_DIR) \
-I$(LIB_SRC)/OpenFOAM/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/transportModels/incompressible/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude

LIB_LIBS = \
-lfiniteVolume \
-lmeshTools
doctorWho 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
Caffa 3D code Waliur Rahman Main CFD Forum 0 May 29, 2018 00:53
OpenFOAM 1.6-ext git installation on Ubuntu 11.10 x64 Attesz OpenFOAM Installation 45 January 13, 2012 12:38
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 19:08
Errors running allwmake in OpenFOAM141dev with WM_COMPILE_OPTION%3ddebug unoder OpenFOAM Installation 11 January 30, 2008 20:30
G95 + CGNS Bruno Main CFD Forum 1 January 30, 2007 00:34


All times are GMT -4. The time now is 07:56.