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

Linking Error: undefined reference to `Foam::viscoelasticLaw::New(..

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 20, 2019, 06:50
Default Linking Error: undefined reference to `Foam::viscoelasticLaw::New(..
  #1
New Member
 
Join Date: Apr 2019
Posts: 12
Rep Power: 7
yummigummi is on a distinguished road
Hello everyone,


when compiling my solver I get an linking error and I couldn't find a solution yet. Maybe you can help. I get the following error:


Code:
/home/pauls/foam/pauls-4.0/lib/linux64GccDPOpt/libviscoFreeSurface.so: undefined reference to `Foam::viscoelasticLaw::New(Foam::word const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&, Foam::GeometricField<Foam::Vector<double>, Foam::faPatchField, Foam::areaMesh> const&, Foam::GeometricField<double, Foam::faePatchField, Foam::edgeMesh> const&, Foam::dictionary const&)'
collect2: error: ld returned 1 exit status
I am working with the bubbleInterTrackFoam solver in foam-extend 4.0 to simulate a free rising bubble. I'm try to implement a viscoelastic fluid model. To do so, I use the src/transportModels/viscoelastic library which has several transport models I can modify due to my needs. The original viscoelasticModel class is constructed with a lawPtr which is used to do a runtime selection of the model. The original code looks as follows:


Code:
viscoelasticModel::viscoelasticModel
(
    const volVectorField& U,
    const surfaceScalarField& phi
)
:
    IOdictionary
    (
        IOobject
        (
            "viscoelasticProperties",
            U.time().constant(),
            U.db(),
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        )
    ),
    lawPtr_(viscoelasticLaw::New(word::null, U, phi, subDict("rheology")))
{}

The core feature of the bubbleInterTrackFoam is calculation exact conditions at the bubble Interface. I am using this interface velocity Us and interface flux Phis data to calculate a surface stress term and predict viscoelastic behaviour.
All interface related calculations are done in a class called freeSurface in which I implemented the lawPtr. Since the interface data is calculated after constructing the class I initialize with a lawPtrPtr pointer, that I later return dereferenced when I access the lawPtr.




Code:
freeSurface::freeSurface
(
    dynamicFvMesh& m,
    const volScalarField& rho,
    volVectorField& Ub,
    volScalarField& Pb,
    const surfaceScalarField& sfPhi                                                                   
)
:
 .
 .
 .

    mesh_(m),
    rho_(rho),
    U_(Ub),
    p_(Pb),
    phi_(sfPhi),
  .
  .
  .
    lawPtrPtr_(NULL)
{}
Code:
void freeSurface::makeLawPtr() const                 
{
    if (debug)
    {
        Info<< "freeSurface::makeLawPtr() : "
            << "making viscosity law pointer"
            << endl;
    }


    // It is an error to attempt to recalculate
    // if the pointer is already set
    if (lawPtrPtr_)
    {
        FatalErrorIn("freeSurface::makeLawPtr()")
            << "viscosity LawPtr alreay exists"
            << abort(FatalError);
    }

    const areaVectorField& Us_ = Us();
    const edgeScalarField& phis_ = Phis();

    IOdictionary freeSurfaceProperties
    (
        IOobject
        (
            "freeSurfaceProperties",
            U_.mesh().time().constant(),
            U_.mesh(),
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        )
    );


    lawPtrPtr_ = new autoPtr<viscoelasticLaw>
    (        
        viscoelasticLaw::New(word::null, U_, phi_, Us_, phis_, freeSurfaceProperties.subDict("rheology"))
    );
}
Code:
autoPtr<viscoelasticLaw>& freeSurface::lawPtr()
{
    if (!lawPtrPtr_)
    {
        makeLawPtr();
    }

    return *lawPtrPtr_;
}

const autoPtr<viscoelasticLaw>& freeSurface::lawPtr() const
{
    if (!lawPtrPtr_)
    {
        makeLawPtr();
    }

    return *lawPtrPtr_;
}
All my libraries compile well but I do get an linking error, when compiling the solver. I read a couple of threads here having a similar problem but I coudn't really figure out whats the problem in my case. I deleted all custom libraries and recompiled them. My files folder should be correct, right?



Code:
EXE_INC = \
    -I$(WM_PROJECT_USER_DIR)/src/viscoelasticTransportModels \
    -I$(WM_PROJECT_USER_DIR)/src/viscoelasticTransportModels/viscoelastic/lnInclude \
    -I$(WM_PROJECT_USER_DIR)/src/finiteArea/lnInclude \
    -I../include \
    -I../freeSurface/lnInclude \
    -I$(LIB_SRC)/dynamicMesh/dynamicFvMesh/lnInclude \
    -I$(LIB_SRC)/meshTools/lnInclude \
    -I$(LIB_SRC)/finiteVolume/lnInclude 

EXE_LIBS = \
    -L$(FOAM_USER_LIBBIN) \
    -lviscoelasticTransportModels \
    -lviscoFreeSurface \
    -lfiniteAreaMod \
    -L$(FOAM_LIBBIN) \
    -ldynamicFvMesh \
    -ldynamicMesh \
    -lmeshTools \
    -lfiniteVolume \
    -llduSolvers \
    -L$(MESQUITE_LIB_DIR) -lmesquite
I hope someone understands these cryptic linking error. Thanks in advance for you help!


Cheers
Paul
yummigummi is offline   Reply With Quote

Old   December 3, 2019, 06:57
Default
  #2
New Member
 
Join Date: Apr 2019
Posts: 12
Rep Power: 7
yummigummi is on a distinguished road
Well guys, in the end I still don't know what caused the error but I was able to fix it with a different work around.


I am using a


Code:
mutable viscoelasticModel* modelPtr_
now to create a create a placeholder for my viscoealstic model. I later use



Code:
void freeSurface::makeModelPtr() const
{
    if (debug)
    {
        Info<< "freeSurface::makeModelPtr() : "
            << "making viscosity law pointer"
            << endl;
    }


    // It is an error to attempt to recalculate
    // if the pointer is already set
    if (modelPtr_)
    {
        FatalErrorIn("freeSurface::makeModelPtr()")
            << "viscosity ModelPtr alreay exists"
            << abort(FatalError);
    }


     modelPtr_= new viscoelasticModel(U_, phi_, Us(), Phis());
}
to create the object.


The Object is returned by this method:


Code:
viscoelasticModel& freeSurface::modelPtr()
{
    if (!modelPtr_)
    {
        makeModelPtr();
    }

    return *modelPtr_;

}
And then I can simply call it like this:


Code:
tmp<volSymmTensorField> freeSurface::tau()
{
    return modelPtr().tau();
}

Hope this helps you, if youre running in the same problem.


Paul
yummigummi 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
Second Derivative Zero - Boundary Condition fu-ki-pa OpenFOAM 11 March 27, 2021 04:28
LEMOS InflowGenerator r_gordon OpenFOAM Running, Solving & CFD 103 December 18, 2018 00:58
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
G95 + CGNS Bruno Main CFD Forum 1 January 30, 2007 00:34


All times are GMT -4. The time now is 00:10.