|
[Sponsors] |
August 17, 2020, 13:14 |
undefined reference_ linking error
|
#1 |
Member
Nikhil
Join Date: May 2020
Location: Freiburg
Posts: 43
Rep Power: 6 |
Hallo Foamers,
I am trying to edit reactingFoam solver, to add porous capability. In the process, i got a error "temporary deallocated error", so, as to clear that error, i did some changes in the code. Now, deallocation error is gone, but getting a new error, which says "undefined reference to `trTU()'". trTu() is a tmp variable created in Ueqn.H. By some research, i came to know its a linker error, but dont know how to resolve it. Please have a look at the UEqn.H code and the error msg, and let me know, your views. Thanks. Code:
MRF.correctBoundaryVelocity(U); tmp<fvVectorMatrix> tUEqn ( fvm::ddt(rho, U) + fvm::div(phi, U) + MRF.DDt(rho, U) + turbulence->divDevTau(U) == fvOptions(rho, U) ); fvVectorMatrix& UEqn = tUEqn.ref(); UEqn.relax(); tmp<volScalarField> trAU(); //trAU; tmp<volTensorField> trTU(); //trTU; if (pressureImplicitPorosity) { tmp<volTensorField> tTU = tensor(I)*UEqn.A(); pZones.addResistance(UEqn, tTU.ref()); trTU() = inv(tTU()); trTU().ref().rename("rAU"); fvOptions.constrain(UEqn); volVectorField gradp(fvc::reconstruct ( ( - ghf*fvc::snGrad(rho) - fvc::snGrad(p_rgh) )*mesh.magSf() ) ); for (int UCorr=0; UCorr<nUCorr; UCorr++) { U = trTU() & (UEqn.H() - gradp); } U.correctBoundaryConditions(); fvOptions.correct(U); K = 0.5*magSqr(U); } else { pZones.addResistance(UEqn); fvOptions.constrain(UEqn); if(pimple.momentumPredictor()) { solve ( UEqn == fvc::reconstruct ( ( - ghf*fvc::snGrad(rho) - fvc::snGrad(p_rgh) )*mesh.magSf() ) ); fvOptions.correct(U); K = 0.5*magSqr(U); trAU() = 1.0/UEqn.A(); trAU().ref().rename("rAU"); "UEqn.H" 88L, 1820C nm. |
|
August 17, 2020, 14:05 |
|
#2 |
Senior Member
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 16 |
Are you creating tmp variables like this directly?
Code:
tmp<volScalarField> trAU(); tmp<volTensorField> trTU(); Code:
trAU() You may want to check out parts of OpenFOAM code where they create and use tmp variables. In your case you probably need to provide a constructor to a volScalarField. |
|
August 17, 2020, 14:39 |
|
#3 |
Member
Nikhil
Join Date: May 2020
Location: Freiburg
Posts: 43
Rep Power: 6 |
Thanks for the reply,
So, the code is supposed to look like this Code:
MRF.correctBoundaryVelocity(U); tmp<fvVectorMatrix> tUEqn ( fvm::ddt(rho, U) + fvm::div(phi, U) + MRF.DDt(rho, U) + turbulence->divDevTau(U) == fvOptions(rho, U) ); fvVectorMatrix& UEqn = tUEqn.ref(); UEqn.relax(); tmp<volScalarField> trAU; tmp<volTensorField> trTU; if (pressureImplicitPorosity) { tmp<volTensorField> tTU = tensor(I)*UEqn.A(); pZones.addResistance(UEqn, tTU.ref()); trTU = inv(tTU()); trTU.ref().rename("rAU"); fvOptions.constrain(UEqn); volVectorField gradp(fvc::reconstruct ( ( - ghf*fvc::snGrad(rho) - fvc::snGrad(p_rgh) )*mesh.magSf() ) ); for (int UCorr=0; UCorr<nUCorr; UCorr++) { U = trTU() & (UEqn.H() - gradp); } U.correctBoundaryConditions(); fvOptions.correct(U); K = 0.5*magSqr(U); } else { pZones.addResistance(UEqn); fvOptions.constrain(UEqn); if(pimple.momentumPredictor()) { solve ( UEqn == fvc::reconstruct ( ( - ghf*fvc::snGrad(rho) - fvc::snGrad(p_rgh) )*mesh.magSf() ) ); fvOptions.correct(U); K = 0.5*magSqr(U); trAU = 1.0/UEqn.A(); trAU.ref().rename("rAU"); Code:
Starting time loop Courant Number mean: 0 max: 0 deltaT = 1.2e-10 Time = 1.2e-10 Selected 0 cells for refinement out of 107994. Selected 0 split points out of a possible 0. diagonal: Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0 DILUPBiCG: Solving for C3H8, Initial residual = 0, Final residual = 0, No Iterations 0 DILUPBiCG: Solving for h, Initial residual = 5.23194e-05, Final residual = 1.20767e-20, No Iterations 1 min/max(T) = 293, 293 --> FOAM FATAL ERROR: tmp<N4Foam14GeometricFieldIdNS_12fvPatchFieldENS_7volMeshEEE> deallocated From function const T& Foam::tmp<T>::operator()() const [with T = Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>] in file /opt/OpenFOAM/OpenFOAM-8/src/OpenFOAM/lnInclude/tmpI.H at line 278. FOAM aborting #0 Foam::error::printStack(Foam::Ostream&) at ??:? #1 Foam::error::abort() at ??:? #2 Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >::operator()() const in "/disk/nmittapa/FOAM_USER_APPBIN/2userFoam" #3 ? in "/disk/nmittapa/FOAM_USER_APPBIN/2userFoam" #4 __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6" #5 ? in "/disk/nmittapa/FOAM_USER_APPBIN/2userFoam" [1]+ Done LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ParaView_LIB_DIR/mesa paraview foam.foam Aborted So, from Temporary deallocated error this post, I changed trTU to trTU(), then i got undefined reference error. Code:
Making dependency list for source file userFoam.C g++ -std=c++11 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes -O3 -DNoRepository -ftemplate-depth-100 -I. -I/opt/OpenFOAM/OpenFOAM-8/applications/solvers/combustion/reactingFoam -I/opt/OpenFOAM/OpenFOAM-8/src/MomentumTransportModels/momentumTransportModels/lnInclude -I/opt/OpenFOAM/OpenFOAM-8/src/MomentumTransportModels/compressible/lnInclude -I/opt/OpenFOAM/OpenFOAM-8/src/ThermophysicalTransportModels/lnInclude -I/opt/OpenFOAM/OpenFOAM-8/src/ThermophysicalTransportModels/rhoReactionThermo/lnInclude -I/opt/OpenFOAM/OpenFOAM-8/src/thermophysicalModels/specie/lnInclude -I/opt/OpenFOAM/OpenFOAM-8/src/thermophysicalModels/reactionThermo/lnInclude -I/opt/OpenFOAM/OpenFOAM-8/src/thermophysicalModels/basic/lnInclude -I/opt/OpenFOAM/OpenFOAM-8/src/thermophysicalModels/chemistryModel/lnInclude -I/opt/OpenFOAM/OpenFOAM-8/src/ODE/lnInclude -I/opt/OpenFOAM/OpenFOAM-8/src/combustionModels/lnInclude -I/opt/OpenFOAM/OpenFOAM-8/src/finiteVolume/lnInclude -I/opt/OpenFOAM/OpenFOAM-8/src/finiteVolume/cfdTools -I/opt/OpenFOAM/OpenFOAM-8/src/meshTools/lnInclude -I/opt/OpenFOAM/OpenFOAM-8/src/sampling/lnInclude -I/opt/OpenFOAM/OpenFOAM-8/src/dynamicFvMesh/lnInclude -IlnInclude -I. -I/opt/OpenFOAM/OpenFOAM-8/src/OpenFOAM/lnInclude -I/opt/OpenFOAM/OpenFOAM-8/src/OSspecific/POSIX/lnInclude -fPIC -c userFoam.C -o Make/linux64GccDPInt32Opt/userFoam.o g++ -std=c++11 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes -O3 -DNoRepository -ftemplate-depth-100 -I. -I/opt/OpenFOAM/OpenFOAM-8/applications/solvers/combustion/reactingFoam -I/opt/OpenFOAM/OpenFOAM-8/src/MomentumTransportModels/momentumTransportModels/lnInclude -I/opt/OpenFOAM/OpenFOAM-8/src/MomentumTransportModels/compressible/lnInclude -I/opt/OpenFOAM/OpenFOAM-8/src/ThermophysicalTransportModels/lnInclude -I/opt/OpenFOAM/OpenFOAM-8/src/ThermophysicalTransportModels/rhoReactionThermo/lnInclude -I/opt/OpenFOAM/OpenFOAM-8/src/thermophysicalModels/specie/lnInclude -I/opt/OpenFOAM/OpenFOAM-8/src/thermophysicalModels/reactionThermo/lnInclude -I/opt/OpenFOAM/OpenFOAM-8/src/thermophysicalModels/basic/lnInclude -I/opt/OpenFOAM/OpenFOAM-8/src/thermophysicalModels/chemistryModel/lnInclude -I/opt/OpenFOAM/OpenFOAM-8/src/ODE/lnInclude -I/opt/OpenFOAM/OpenFOAM-8/src/combustionModels/lnInclude -I/opt/OpenFOAM/OpenFOAM-8/src/finiteVolume/lnInclude -I/opt/OpenFOAM/OpenFOAM-8/src/finiteVolume/cfdTools -I/opt/OpenFOAM/OpenFOAM-8/src/meshTools/lnInclude -I/opt/OpenFOAM/OpenFOAM-8/src/sampling/lnInclude -I/opt/OpenFOAM/OpenFOAM-8/src/dynamicFvMesh/lnInclude -IlnInclude -I. -I/opt/OpenFOAM/OpenFOAM-8/src/OpenFOAM/lnInclude -I/opt/OpenFOAM/OpenFOAM-8/src/OSspecific/POSIX/lnInclude -fPIC -fuse-ld=bfd -Xlinker --add-needed -Xlinker --no-as-needed Make/linux64GccDPInt32Opt/userFoam.o -L/opt/OpenFOAM/OpenFOAM-8/platforms/linux64GccDPInt32Opt/lib \ -lfluidThermophysicalModels -lspecie -lchemistryModel -lODE -lcombustionModels -lreactionThermophysicalModels -lmomentumTransportModels -lfluidThermoMomentumTransportModels -lthermophysicalTransportModels -lrhoReactionThermophysicalTransportModels -lfiniteVolume -ldynamicFvMesh -ltopoChangerFvMesh -lmeshTools -lsampling -lfvOptions -lOpenFOAM -ldl \ -lm -o /disk/nmittapa/FOAM_USER_APPBIN/2userFoam /usr/bin/ld.bfd: Make/linux64GccDPInt32Opt/userFoam.o: in function `main': userFoam.C:(.text.startup+0x635d): undefined reference to `trTU()' /usr/bin/ld.bfd: userFoam.C:(.text.startup+0x6e59): undefined reference to `trTU()' /usr/bin/ld.bfd: userFoam.C:(.text.startup+0x7465): undefined reference to `trAU()' /usr/bin/ld.bfd: userFoam.C:(.text.startup+0x79c9): undefined reference to `trAU()' /usr/bin/ld.bfd: userFoam.C:(.text.startup+0x863d): undefined reference to `trTU()' /usr/bin/ld.bfd: userFoam.C:(.text.startup+0x86c7): undefined reference to `trTU()' /usr/bin/ld.bfd: userFoam.C:(.text.startup+0x88b3): undefined reference to `trTU()' /usr/bin/ld.bfd: userFoam.C:(.text.startup+0x8cf3): undefined reference to `trAU()' /usr/bin/ld.bfd: userFoam.C:(.text.startup+0x8d4e): undefined reference to `trAU()' collect2: error: ld returned 1 exit status make: *** [/opt/OpenFOAM/OpenFOAM-8/wmake/makefiles/general:142: /disk/nmittapa/FOAM_USER_APPBIN/2userFoam] Error 1 So, as you said, if i change the trTU() to trTU, then how to remove deallocation error. Is there a way to deallocate the variables after we use them?. |
|
August 17, 2020, 19:18 |
|
#4 |
Senior Member
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 16 |
I believe you are using tmp incorrectly.
Take a look here: https://openfoamwiki.net/index.php/OpenFOAM_guide/tmp |
|
August 17, 2020, 19:42 |
|
#5 |
Member
Nikhil
Join Date: May 2020
Location: Freiburg
Posts: 43
Rep Power: 6 |
Thanks for the reference, Yah! you are right.
But If i do it in the right way, it causes other problems. Please have a look at this post. This is my actual problem. I am stuck here, please let me know what do you think of this. |
|
Tags |
c++, linking, openfoam, solver compilation |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[swak4Foam] swak4foam openfoam 7 installation problem | Andrea23 | OpenFOAM Community Contributions | 1 | February 17, 2020 19:11 |
[blockMesh] blockMesh with double grading. | spwater | OpenFOAM Meshing & Mesh Conversion | 92 | January 12, 2019 10:00 |
OpenFOAM 1.6-ext git installation on Ubuntu 11.10 x64 | Attesz | OpenFOAM Installation | 45 | January 13, 2012 13:38 |
How to install CGNS under windows xp? | lzgwhy | Main CFD Forum | 1 | January 11, 2011 19:44 |
checking the system setup and Qt version | vivek070176 | OpenFOAM Installation | 22 | June 1, 2010 13:34 |