|
[Sponsors] |
Linking error for lagrangian solver: undefined reference to Foam::xxx::typeName |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
July 10, 2024, 12:14 |
Linking error for lagrangian solver: undefined reference to Foam::xxx::typeName
|
#1 |
New Member
Join Date: Dec 2022
Posts: 2
Rep Power: 0 |
Hello dear Foamers!
I am new to solver development in OpenFoam and ran into an issue I can not resolve on my own despite days of trying. I should mention my C++-skills are not that sharpened, so it might be a very obvious mistake from my side. I am using OpenFoamv2106. TL;DR: A solver for particle dissolution and evolution of the dissolved scalar field fails to compile with a linker error despite the individual libraries compiling without a problem. Linker error is of type: "undefined reference to xxx:typeName and ::dictionaryConstructorTablePtr_'". My aim: I am looking into the alloying process in inductively stirred cast iron melts (e.g. with FeMo-particles). For that, I want to take particles with a certain (initial) size distribution and want to very crudely model their dissolution. This is done by estimating their "radius evolution function" r(t) from a known relation to the particle reynolds number. A scalar field "releasedScalar" shall be enriched in proportion to the volume lost in each timestep in the cell where the particle is located. I am mainly interested in the evolution of the scalar field, especially typical homogenization times, not the precise motion of the particles. As I only have 5 alloying elements in my research spectrum right now, my current plan is to hardcode the necessary physical properties of the particles (lamdba, cp, etc.) into r(t) for different libraries and then compile different solvers. My approach right now: Please see the attached archives for a detailed overview of my files. My main approach was to make a template class MyKinematicParcel and add members for a pointer to "releasedScalar" and "dInitial"(which is needed for r(t), as I never track explicitely track the temperature distribution in the particle), as well as updating all the constructors and member functions. Then, I implemented (prototype) methods for calculating the particle size evolution and setting the releasedScalar-Field. The update of the radius happens in the move() method. Code:
//MyKinematicParcel.C template<class ParcelType> template<class TrackCloudType> bool Foam::MyKinematicParcel<ParcelType>::move ( TrackCloudType& cloud, trackingData& td, const scalar trackTime ) { typename TrackCloudType::parcelType& p = static_cast<typename TrackCloudType::parcelType&>(*this); typename TrackCloudType::parcelType::trackingData& ttd = static_cast<typename TrackCloudType::parcelType::trackingData&>(td); // much more, unaltered existing logic here p.releaseScalar(); p.age() += dt; // much more, unaltered existing logic here } template<class ParcelType> void Foam::MyKinematicParcel<ParcelType>::setReleasedScalar ( volScalarField* releasedScalar ) { releasedScalar_ = releasedScalar; } template<class ParcelType> void Foam::MyKinematicParcel<ParcelType>::releaseScalar() { if (this->releasedScalar_) { // Compute the volume change Foam::scalar currentTime = this->age_; Foam::scalar currentDiameter = this->d_; Foam::scalar newDiameter = evolveDiameter(currentTime); Foam::scalar currentRadius = currentDiameter/2.0; Foam::scalar newRadius = newDiameter/2.0; Foam::scalar oldVolume = (4.0 / 3.0) * M_PI * currentRadius * currentRadius * currentRadius; Foam::scalar newVolume = (4.0 / 3.0) * M_PI * newRadius * newRadius * newRadius; Foam::scalar deltaVolume = oldVolume - newVolume; Foam::label nearestCell = this->cell(); // Update the scalar field in the nearest cell if (nearestCell != -1) { (*(this->releasedScalar_))[nearestCell] += deltaVolume*10; } // Update particle diameter this->d_ = newDiameter; } } template<class ParcelType> Foam::scalar Foam::MyKinematicParcel<ParcelType>::evolveDiameter ( scalar age ) const { //More involved logic will follow! scalar t_shelling = this->calculateTShelling(this->dInitial_); scalar t_lifetime = this->calculateTLifetime(this->dInitial_); scalar r_0 = this->dInitial_; if (age < t_shelling) { return r_0; } else if (age < t_lifetime) { return r_0 * (1 - (age - t_shelling) / (t_lifetime - t_shelling)) + SMALL; } else { return SMALL; } } template<class ParcelType> Foam::scalar Foam::MyKinematicParcel<ParcelType>::calculateTShelling(scalar dInit) const { //More involved logic will follow! return 1.0; } template<class ParcelType> Foam::scalar Foam::MyKinematicParcel<ParcelType>::calculateTLifetime(scalar dInit) const { //More involved logic will follow! return 3.0; } Code:
//MyKinematicCloud.C template<class CloudType> void Foam::MyKinematicCloud<CloudType>::setReleasedScalar ( volScalarField* releasedScalar ) { CloudType::setReleasedScalar(releasedScalar); } Code:
//Cloud.C template<class ParticleType> void Foam::Cloud<ParticleType>::setReleasedScalar ( volScalarField* releasedScalar ) { // Loop over all particles for (ParticleType& p : *this) { p.setReleasedScalar(releasedScalar); } } Code:
$WM_PROJECT_USER_DIR/src/lagrangian/intermediate -> libmylagrangianIntermediate.so Code:
$WM_PROJECT_USER_DIR/src/lagrangian/ -> libmylagrangian Then I went on to my (still prototypy) solver solidParticleMeltFoam2. I tried to compile it with the following Make/files and Make/options. Code:
//Make/files solidParticleMeltFoam2.C EXE = $(FOAM_USER_APPBIN)/solidParticleMeltFoam2 Code:
//Make/options EXE_INC = \ -I$(WM_PROJECT_USER_DIR)/src/lagrangian/lnInclude \ -I$(WM_PROJECT_USER_DIR)/src/lagrangian/intermediate/lnInclude \ -I$(LIB_SRC)/lagrangian/intermediate/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/sampling/lnInclude \ -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \ -I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \ -I$(LIB_SRC)/transportModels \ -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \ -I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ -I$(LIB_SRC)/lagrangian/basic/lnInclude \ -I$(LIB_SRC)/lagrangian/solidParticle/lnInclude \ -I$(LIB_SRC)/regionModels/surfaceFilmModels/lnInclude \ -I$(LIB_SRC)/regionModels/regionModel/lnInclude \ EXE_LIBS = \ -L$(FOAM_USER_LIBBIN) \ -L$(FOAM_LIBBIN) \ -lmylagrangian \ -lmylagrangianIntermediate \ -llagrangian \ -llagrangianIntermediate \ -llagrangianFunctionObjects \ -lturbulenceModels \ -lfiniteVolume \ -lsampling \ -lmeshTools \ -lsolidParticle \ -ldynamicMesh \ -ldynamicFvMesh \ -ltopoChangerFvMesh \ -latmosphericModels \ -lincompressibleTransportModels \ -lincompressibleTurbulenceModels \ -lregionModels \ -lsurfaceFilmModels \ -lOpenFOAM \ -ldl Code:
//truncated here -lm -o /home/heunisch/OpenFOAM/heunisch-v2106/platforms/linux64Gcc91DPInt32Opt/bin/solidParticleMeltFoam2 Make/linux64Gcc91DPInt32Opt/solidParticleMeltFoam2.o: In function `Foam::CloudFunctionObject<Foam::MyKinematicCloud<Foam::Cloud<Foam::MyKinematicParcel<Foam::particle> > > >::type() const': solidParticleMeltFoam2.C:(.text._ZNK4Foam19CloudFunctionObjectINS_16MyKinematicCloudINS_5CloudINS_17MyKinematicParcelINS_8particleEEEEEEEE4typeEv[_ZNK4Foam19CloudFunctionObjectINS_16MyKinematicCloudINS_5CloudINS_17MyKinematicParcelINS_8particleEEEEEEEE4typeEv]+0x3): undefined reference to `Foam::CloudFunctionObject<Foam::MyKinematicCloud<Foam::Cloud<Foam::MyKinematicParcel<Foam::particle> > > >::typeName' Make/linux64Gcc91DPInt32Opt/solidParticleMeltFoam2.o: In function `Foam::ParticleForce<Foam::MyKinematicCloud<Foam::Cloud<Foam::MyKinematicParcel<Foam::particle> > > >::type() const': solidParticleMeltFoam2.C:(.text._ZNK4Foam13ParticleForceINS_16MyKinematicCloudINS_5CloudINS_17MyKinematicParcelINS_8particleEEEEEEEE4typeEv[_ZNK4Foam13ParticleForceINS_16MyKinematicCloudINS_5CloudINS_17MyKinematicParcelINS_8particleEEEEEEEE4typeEv]+0x3): undefined reference to `Foam::ParticleForce<Foam::MyKinematicCloud<Foam::Cloud<Foam::MyKinematicParcel<Foam::particle> > > >::typeName' Make/linux64Gcc91DPInt32Opt/solidParticleMeltFoam2.o: In function `Foam::ParticleForce<Foam::MyKinematicCloud<Foam::Cloud<Foam::MyKinematicParcel<Foam::particle> > > >::New(Foam::MyKinematicCloud<Foam::Cloud<Foam::MyKinematicParcel<Foam::particle> > >&, Foam::fvMesh const&, Foam::dictionary const&, Foam::word const&)': solidParticleMeltFoam2.C:(.text._ZN4Foam13ParticleForceINS_16MyKinematicCloudINS_5CloudINS_17MyKinematicParcelINS_8particleEEEEEEEE3NewERS7_RKNS_6fvMeshERKNS_10dictionaryERKNS_4wordE[_ZN4Foam13ParticleForceINS_16MyKinematicCloudINS_5CloudINS_17MyKinematicParcelINS_8particleEEEEEEEE3NewERS7_RKNS_6fvMeshERKNS_10dictionaryERKNS_4wordE]+0x55): undefined reference to `Foam::ParticleForce<Foam::MyKinematicCloud<Foam::Cloud<Foam::MyKinematicParcel<Foam::particle> > > >::dictionaryConstructorTablePtr_' solidParticleMeltFoam2.C:(.text._ZN4Foam13ParticleForceINS_16MyKinematicCloudINS_5CloudINS_17MyKinematicParcelINS_8particleEEEEEEEE3NewERS7_RKNS_6fvMeshERKNS_10dictionaryERKNS_4wordE[_ZN4Foam13ParticleForceINS_16MyKinematicCloudINS_5CloudINS_17MyKinematicParcelINS_8particleEEEEEEEE3NewERS7_RKNS_6fvMeshERKNS_10dictionaryERKNS_4wordE]+0xf6): undefined reference to `Foam::ParticleForce<Foam::MyKinematicCloud<Foam::Cloud<Foam::MyKinematicParcel<Foam::particle> > > >::dictionaryConstructorTablePtr_' Make/linux64Gcc91DPInt32Opt/solidParticleMeltFoam2.o: In function `Foam::CloudFunctionObject<Foam::MyKinematicCloud<Foam::Cloud<Foam::MyKinematicParcel<Foam::particle> > > >::New(Foam::dictionary const&, Foam::MyKinematicCloud<Foam::Cloud<Foam::MyKinematicParcel<Foam::particle> > >&, Foam::word const&, Foam::word const&)': solidParticleMeltFoam2.C:(.text._ZN4Foam19CloudFunctionObjectINS_16MyKinematicCloudINS_5CloudINS_17MyKinematicParcelINS_8particleEEEEEEEE3NewERKNS_10dictionaryERS7_RKNS_4wordESF_[_ZN4Foam19CloudFunctionObjectINS_16MyKinematicCloudINS_5CloudINS_17MyKinematicParcelINS_8particleEEEEEEEE3NewERKNS_10dictionaryERS7_RKNS_4wordESF_]+0x6f): undefined reference to `Foam::CloudFunctionObject<Foam::MyKinematicCloud<Foam::Cloud<Foam::MyKinematicParcel<Foam::particle> > > >::dictionaryConstructorTablePtr_' solidParticleMeltFoam2.C:(.text._ZN4Foam19CloudFunctionObjectINS_16MyKinematicCloudINS_5CloudINS_17MyKinematicParcelINS_8particleEEEEEEEE3NewERKNS_10dictionaryERS7_RKNS_4wordESF_[_ZN4Foam19CloudFunctionObjectINS_16MyKinematicCloudINS_5CloudINS_17MyKinematicParcelINS_8particleEEEEEEEE3NewERKNS_10dictionaryERS7_RKNS_4wordESF_]+0x110): undefined reference to `Foam::CloudFunctionObject<Foam::MyKinematicCloud<Foam::Cloud<Foam::MyKinematicParcel<Foam::particle> > > >::dictionaryConstructorTablePtr_' Make/linux64Gcc91DPInt32Opt/solidParticleMeltFoam2.o: In function `Foam::InjectionModel<Foam::MyKinematicCloud<Foam::Cloud<Foam::MyKinematicParcel<Foam::particle> > > >::New(Foam::dictionary const&, Foam::word const&, Foam::word const&, Foam::MyKinematicCloud<Foam::Cloud<Foam::MyKinematicParcel<Foam::particle> > >&)': solidParticleMeltFoam2.C:(.text._ZN4Foam14InjectionModelINS_16MyKinematicCloudINS_5CloudINS_17MyKinematicParcelINS_8particleEEEEEEEE3NewERKNS_10dictionaryERKNS_4wordESE_RS7_[_ZN4Foam14InjectionModelINS_16MyKinematicCloudINS_5CloudINS_17MyKinematicParcelINS_8particleEEEEEEEE3NewERKNS_10dictionaryERKNS_4wordESE_RS7_]+0x55): undefined reference to `Foam::InjectionModel<Foam::MyKinematicCloud<Foam::Cloud<Foam::MyKinematicParcel<Foam::particle> > > >::dictionaryConstructorTablePtr_' solidParticleMeltFoam2.C:(.text._ZN4Foam14InjectionModelINS_16MyKinematicCloudINS_5CloudINS_17MyKinematicParcelINS_8particleEEEEEEEE3NewERKNS_10dictionaryERKNS_4wordESE_RS7_[_ZN4Foam14InjectionModelINS_16MyKinematicCloudINS_5CloudINS_17MyKinematicParcelINS_8particleEEEEEEEE3NewERKNS_10dictionaryERKNS_4wordESE_RS7_]+0xf6): undefined reference to `Foam::InjectionModel<Foam::MyKinematicCloud<Foam::Cloud<Foam::MyKinematicParcel<Foam::particle> > > >::dictionaryConstructorTablePtr_' Make/linux64Gcc91DPInt32Opt/solidParticleMeltFoam2.o: In function `Foam::DispersionModel<Foam::MyKinematicCloud<Foam::Cloud<Foam::MyKinematicParcel<Foam::particle> > > >::New(Foam::dictionary const&, Foam::MyKinematicCloud<Foam::Cloud<Foam::MyKinematicParcel<Foam::particle> > >&)': solidParticleMeltFoam2.C:(.text._ZN4Foam15DispersionModelINS_16MyKinematicCloudINS_5CloudINS_17MyKinematicParcelINS_8particleEEEEEEEE3NewERKNS_10dictionaryERS7_[_ZN4Foam15DispersionModelINS_16MyKinematicCloudINS_5CloudINS_17MyKinematicParcelINS_8particleEEEEEEEE3NewERKNS_10dictionaryERS7_]+0xb7): undefined reference to `Foam::DispersionModel<Foam::MyKinematicCloud<Foam::Cloud<Foam::MyKinematicParcel<Foam::particle> > > >::dictionaryConstructorTablePtr_' solidParticleMeltFoam2.C:(.text._ZN4Foam15DispersionModelINS_16MyKinematicCloudINS_5CloudINS_17MyKinematicParcelINS_8particleEEEEEEEE3NewERKNS_10dictionaryERS7_[_ZN4Foam15DispersionModelINS_16MyKinematicCloudINS_5CloudINS_17MyKinematicParcelINS_8particleEEEEEEEE3NewERKNS_10dictionaryERS7_]+0x158): undefined reference to `Foam::DispersionModel<Foam::MyKinematicCloud<Foam::Cloud<Foam::MyKinematicParcel<Foam::particle> > > >::dictionaryConstructorTablePtr_' Make/linux64Gcc91DPInt32Opt/solidParticleMeltFoam2.o: In function `Foam::PatchInteractionModel<Foam::MyKinematicCloud<Foam::Cloud<Foam::MyKinematicParcel<Foam::particle> > > >::New(Foam::dictionary const&, Foam::MyKinematicCloud<Foam::Cloud<Foam::MyKinematicParcel<Foam::particle> > >&)': solidParticleMeltFoam2.C:(.text._ZN4Foam21PatchInteractionModelINS_16MyKinematicCloudINS_5CloudINS_17MyKinematicParcelINS_8particleEEEEEEEE3NewERKNS_10dictionaryERS7_[_ZN4Foam21PatchInteractionModelINS_16MyKinematicCloudINS_5CloudINS_17MyKinematicParcelINS_8particleEEEEEEEE3NewERKNS_10dictionaryERS7_]+0xce): undefined reference to `Foam::PatchInteractionModel<Foam::MyKinematicCloud<Foam::Cloud<Foam::MyKinematicParcel<Foam::particle> > > >::dictionaryConstructorTablePtr_' solidParticleMeltFoam2.C:(.text._ZN4Foam21PatchInteractionModelINS_16MyKinematicCloudINS_5CloudINS_17MyKinematicParcelINS_8particleEEEEEEEE3NewERKNS_10dictionaryERS7_[_ZN4Foam21PatchInteractionModelINS_16MyKinematicCloudINS_5CloudINS_17MyKinematicParcelINS_8particleEEEEEEEE3NewERKNS_10dictionaryERS7_]+0x16f): undefined reference to `Foam::PatchInteractionModel<Foam::MyKinematicCloud<Foam::Cloud<Foam::MyKinematicParcel<Foam::particle> > > >::dictionaryConstructorTablePtr_' //truncated here collect2: error: ld returned 1 exit status make: *** [/home/heunisch/OpenFOAM/heunisch-v2106/platforms/linux64Gcc91DPInt32Opt/bin/solidParticleMeltFoam2] Error 1
Best regards Martin |
|
July 13, 2024, 14:16 |
|
#2 |
Member
Ali B.
Join Date: Mar 2020
Location: abzrg.github.io
Posts: 44
Rep Power: 6 |
Hi,
Have you tried the following? 1. copy the whole $FOAM_SRC/lagrangian library into the user src/ directory (or pick the whole sublibraries you need (don't copy intermediate library partially)), 2. add your code, 3. add the necessary flags to the Make/{files,options}. Also let the name be liblagrangian, and liblagrangianIntermediate. the linker will identify your code if you tell it where to look for the them ($FOAM_USER_LIBBIN). I also have a experience like this where I tried to change the name to mylagrangianIntermediate but it gave some strange linker error. |
|
July 16, 2024, 12:06 |
|
#3 | |
New Member
Join Date: Dec 2022
Posts: 2
Rep Power: 0 |
Quote:
Hi reverseila, thank you very much for your advice, which actually helped me getting the thing compiled and running! A little variation on your answer - I left the original class names (so e.g. not MyKinematicParcel but KinematicParcel), but named the libraries libMY2lagrangian and libMY2lagrangianIntermediate, so name conflicts in the Make/options file can never happen. This worked without a problem! I know the "not-renaming" of classes is usually heavily discouraged. But no variation I tried with my own class names failed to compile, even when keeping the whole "intermediate" library. Does anyone know, why this behavior appeared? I still do not really understand. Right now, my code is not producing the results I am expecting, but this a story for another time and I am still in very early test phase Thank you again! Best regards Martin |
||
Tags |
lagrangian solver, linker error, particle dissolution, undefined reference |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Error SIGSEGV using VOF and UDF | JERC_UTFSM | Fluent UDF and Scheme Programming | 14 | November 8, 2021 00:17 |
LEMOS InflowGenerator | r_gordon | OpenFOAM Running, Solving & CFD | 103 | December 18, 2018 01:58 |
Star cd es-ice solver error | ernarasimman | STAR-CD | 2 | September 12, 2014 01:01 |
Error with Wmake | skabilan | OpenFOAM Installation | 3 | July 28, 2009 01:35 |
Parallel processing problem with mpich | nzy102 | OpenFOAM Running, Solving & CFD | 14 | October 18, 2007 01:05 |