CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   const volVectorField& U = db().lookupObject<volVectorField>("U") gives runtime error (https://www.cfd-online.com/Forums/openfoam-programming-development/139653-const-volvectorfield-u-db-lookupobject-volvectorfield-u-gives-runtime-error.html)

kumar2 July 28, 2014 17:26

const volVectorField& U = db().lookupObject<volVectorField>("U") gives runtime error
 
Hi All,

I am trying to access the points in the mesh inside the linearSpring class.
So inside the linearSpring.C , (under the restrain member function), I do the
following modifications,
////////////////Mods. to linearSpring.C//
const objectRegistry& db();
const volVectorField& U = db().lookupObject<volVectorField>("U"); //Line2
const fvMesh & mesh = U.mesh(); //Line3
const pointField & pp = mesh.points(); //Line4
/////////////////////////////////////////

The libary compiles with out errors, but when I use this in a solver(waveDyMFoam), it gives the
following run time errors. I also found that if I comment out Lines 2 to 4 , the run time error
disappears.

///////RUN TIME ERROR////
waveDyMFoam: symbol lookup error: /share/gecko/krishnak/OpenFOAM/krishnak-2.1.0/
platforms/linux64GccDPOpt/lib/mylibforcesNEW.so: undefined symbol: _Z2dbv

Any suggestion is welcome

Thanks in advance

Kumar

Jacks July 29, 2014 03:35

What is in your Make/files and Make/options ?

kumar2 July 29, 2014 15:17

Quote:

Originally Posted by Jacks (Post 503521)
What is in your Make/files and Make/options ?

Hi Jacks,

Thanks for your quick reply.

Make/options is :
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/turbulenceModels \
-I$(LIB_SRC)/turbulenceModels/LES/LESdeltas/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude

LIB_LIBS = \
-lincompressibleTransportModels \
-lincompressibleRASModels \
-lincompressibleLESModels \
-lbasicThermophysicalModels \
-lspecie \
-lcompressibleRASModels \
-lcompressibleLESModels \
-lfiniteVolume \
-lmeshTools \
-lsampling
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////
Make/files
////////////////////////////////
forces/forces.C
forces/forcesFunctionObject.C
forceCoeffs/forceCoeffs.C
forceCoeffs/forceCoeffsFunctionObject.C
sDoFRBM = pointPatchFields/derived/sixDoFRigidBodyMotion
$(sDoFRBM)/sixDoFRigidBodyMotion.C
$(sDoFRBM)/sixDoFRigidBodyMotionIO.C
$(sDoFRBM)/sixDoFRigidBodyMotionState.C
$(sDoFRBM)/sixDoFRigidBodyMotionStateIO.C
sDoFRBMR = $(sDoFRBM)/sixDoFRigidBodyMotionRestraint
$(sDoFRBMR)/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint.C
$(sDoFRBMR)/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraintNew.C
$(sDoFRBMR)/linearAxialAngularSpring/linearAxialAngularSpring.C
$(sDoFRBMR)/linearSpring/linearSpring.C
$(sDoFRBMR)/sphericalAngularSpring/sphericalAngularSpring.C
$(sDoFRBMR)/tabulatedAxialAngularSpring/tabulatedAxialAngularSpring.C
sDoFRBMC = $(sDoFRBM)/sixDoFRigidBodyMotionConstraint

$(sDoFRBMC)/sixDoFRigidBodyMotionConstraint/sixDoFRigidBodyMotionConstraint.C
$(sDoFRBMC)/sixDoFRigidBodyMotionConstraint/sixDoFRigidBodyMotionConstraintNew.C
$(sDoFRBMC)/fixedAxis/fixedAxis.C
$(sDoFRBMC)/fixedLine/fixedLine.C
$(sDoFRBMC)/fixedOrientation/fixedOrientation.C
$(sDoFRBMC)/fixedPlane/fixedPlane.C
$(sDoFRBMC)/fixedPoint/fixedPoint.C
pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C
pointPatchFields/derived/uncoupledSixDoFRigidBodyDisplacement/uncoupledSixDoFRigidBodyDisplacementPointPatchVect orField.C
LIB = $(FOAM_USER_LIBBIN)/mylibforcesNEW
//////////////////////////////////////////////////////////

What area your thoughts?

Thanks in advance

Kumar

Jacks July 30, 2014 05:16

I thought it might be due to linking error while compiling waveDyMFoam, so in Make/options file of your waveDyMFoam solver not mentioning correctly your
mylibforcesNEW.so library.

kumar2 July 30, 2014 22:55

Hi Jacks,

I tried out your suggestion, i.e, I recompiled the waveDyMFoam with the library (instead of calling the library at real time in the controlDict of waveDyMFoam, as a dynamic linked library, which I did first) and I get this error.

// ERROR//
/share/gecko/krishnak/OpenFOAM/krishnak-2.1.0/platforms/linux64GccDPOpt/lib/libmylibforcesNEW.so: undefined reference to `db()
//////////////

I implemented the new code starting with, {const objectRegistry& db();
const volVectorField& U = db().lookupObject<volVectorField>("U"); } .., inspired by this post http://www.cfd-online.com/Forums/ope...tml#post254642 , but reading more closely and going through fvPatchField.H, I found that db is already defined in that class and that may be the reason they are able to access it. However in the linearSpring class , no db ( or similar) is defined. Also no db is defined in the class above linearSpring ( sixDoFRigidBodyMotionRestraints ). At this point I am not sure how to proceed. Once again, If you can give any pointers on how to proceed, that would be great.

Thanks a lot

Kumar

tooran March 6, 2020 21:41

Quote:

Originally Posted by kumar2 (Post 503487)
Hi All,

I am trying to access the points in the mesh inside the linearSpring class.
So inside the linearSpring.C , (under the restrain member function), I do the
following modifications,
////////////////Mods. to linearSpring.C//
const objectRegistry& db();
const volVectorField& U = db().lookupObject<volVectorField>("U"); //Line2
const fvMesh & mesh = U.mesh(); //Line3
const pointField & pp = mesh.points(); //Line4
/////////////////////////////////////////

The libary compiles with out errors, but when I use this in a solver(waveDyMFoam), it gives the
following run time errors. I also found that if I comment out Lines 2 to 4 , the run time error
disappears.

///////RUN TIME ERROR////
waveDyMFoam: symbol lookup error: /share/gecko/krishnak/OpenFOAM/krishnak-2.1.0/
platforms/linux64GccDPOpt/lib/mylibforcesNEW.so: undefined symbol: _Z2dbv

Any suggestion is welcome

Thanks in advance

Kumar


use this following line.



const fvMesh& mesh = U_.mesh();

ybapat March 9, 2020 00:01

You need to access db using function in mesh. Check functions in fvMesh for this.


All times are GMT -4. The time now is 08:21.