|
[Sponsors] |
collect2: error: ld returned 1 exit status |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
February 10, 2017, 14:20 |
collect2: error: ld returned 1 exit status
|
#1 |
New Member
Join Date: Sep 2012
Posts: 23
Rep Power: 14 |
Hi All
I am compiling a solver (which is initially made for OF-2.2.2) in a recent version of OF-V1606+. Compiling states below error: Code:
Make/linux64GccDPInt32Opt/efficiencyFunction.o: In function `Foam::efficiencyFunction::efficiencyFunction(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, double c onst&)': efficiencyFunction.C:(.text+0x24e5): undefined reference to `Foam::LESdelta::New(Foam::word const&, Foam::fvMesh const&, Foam::dictionary const&)' collect2: error: ld returned 1 exit status make: *** [/home/ofuser/OpenFOAM/ofuser-v1606+/platforms/linux64GccDPInt32Opt/bin/TFM-Foam] Error 1 |
|
February 10, 2017, 14:52 |
|
#2 |
Senior Member
|
Hi,
Your code used LESDelta::New with the following set of arguments: Code:
Foam::word const&, Foam::fvMesh const&, Foam::dictionary const& Code:
//- Return a reference to the selected LES delta static autoPtr<LESdelta> New ( const word& name, const turbulenceModel& turbulence, const dictionary& dict ); //- Return a reference to the selected LES delta static autoPtr<LESdelta> New ( const word& name, const turbulenceModel& turbulence, const dictionary& dict, const dictionaryConstructorTable& ); |
|
February 11, 2017, 17:08 |
|
#3 |
New Member
Join Date: Sep 2012
Posts: 23
Rep Power: 14 |
Thank you alexeym for your reply.
These are my efficiencyFunction.C : Code:
#include "efficiencyFunction.H" namespace Foam { defineTypeNameAndDebug(efficiencyFunction, 0); defineRunTimeSelectionTable(efficiencyFunction, dictionary); autoPtr<efficiencyFunction> efficiencyFunction::New ( const volVectorField& U, const scalar& TF ) { word typeName; // Enclose the creation of the dictionary to ensure it is // deleted before the model is created otherwise the dictionary // is entered in the database twice { IOdictionary propertiesDict ( IOobject ( "efficiencyFunctionProperties", U.time().constant(), U.db(), IOobject::MUST_READ, IOobject::NO_WRITE ) ); propertiesDict.lookup("efficiencyFunction") >> typeName; } dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTablePtr_->find(typeName); if (cstrIter == dictionaryConstructorTablePtr_->end()) { FatalErrorIn ( "efficiencyFunction::New()" ) << "Unknown efficiency function " << typeName << endl << endl << "Valid efficiency functions are :" << endl << dictionaryConstructorTablePtr_->toc() << exit(FatalError); } return autoPtr<efficiencyFunction>(cstrIter()(U, TF)); } efficiencyFunction::efficiencyFunction ( const volVectorField& U, const scalar& TF ) : IOdictionary ( IOobject ( "efficiencyFunctionProperties", U.time().constant(), U.db(), IOobject::MUST_READ, IOobject::NO_WRITE ) ), U_(U), TF_(TF), efficiency_ ( IOobject ( "efficiency", U.time().timeName(), U.mesh(), IOobject::NO_READ, IOobject::AUTO_WRITE ), U.mesh(), dimensionedScalar("", dimless, 1.0) ), delta_(LESdelta::New("delta", U.mesh(), *this)) { } efficiencyFunction::~efficiencyFunction() { } } Code:
#ifndef EFFICIENCYFUNCTION_H #define EFFICIENCYFUNCTION_H #include "fvCFD.H" #include "LESdelta.H" #include "runTimeSelectionTables.H" namespace Foam { class efficiencyFunction : public IOdictionary { protected: const volVectorField& U_; const scalar& TF_; volScalarField efficiency_; autoPtr<LESdelta> delta_; public: TypeName("efficiencyFunction"); declareRunTimeSelectionTable ( autoPtr, efficiencyFunction, dictionary, ( const volVectorField& U, const scalar& TF ), (U, TF) ); //- Return a reference to the selected LES model static autoPtr<efficiencyFunction> New ( const volVectorField& U, const scalar& TF ); efficiencyFunction(const volVectorField& U, const scalar& TF); ~efficiencyFunction(); inline const volScalarField& eff() const { return efficiency_; } //- Access function to filter width inline const volScalarField& delta() const { return delta_(); } virtual void correct() =0; }; } #endif As the first solution, I tried to copy the old version of LESdelta.C and LESdelta.H files in my solver folder and compiled it. It worked fine. But when I was trying to run a test case I got the below error: Code:
#0 Foam::error::printStack(Foam::Ostream&) in "/opt/OpenFOAM/OpenFOAM-v1606+/platforms/linux64GccDPInt32Opt/lib/libOpenFOAM.so" #1 Foam::sigSegv::sigHandler(int) in "/opt/OpenFOAM/OpenFOAM-v1606+/platforms/linux64GccDPInt32Opt/lib/libOpenFOAM.so" #2 ? in "/lib64/libc.so.6" #3 Foam::LESdelta::LESdelta(Foam::word const&, Foam::turbulenceModel const&) in "/opt/OpenFOAM/OpenFOAM-v1606+/platforms/linux64GccDPInt32Opt/lib/libturbulenceModels.so" #4 Foam::LESModels::cubeRootVolDelta::cubeRootVolDelta(Foam::word const&, Foam::turbulenceModel const&, Foam::dictionary const&) in "/opt/OpenFOAM/OpenFOAM-v1606+/platforms/linux64GccDPInt32Opt/lib/l ibturbulenceModels.so" #5 Foam::LESdelta::adddictionaryConstructorToTable<Foam::LESModels::cubeRootVolDelta>::New(Foam::word const&, Foam::turbulenceModel const&, Foam::dictionary const&) in "/opt/OpenFOAM/OpenFOAM-v1606+/ platforms/linux64GccDPInt32Opt/lib/libturbulenceModels.so" #6 ? in "/home/ofuser/OpenFOAM/ofuser-v1606+/platforms/linux64GccDPInt32Opt/bin/TFM-Foam" #7 ? in "/home/ofuser/OpenFOAM/ofuser-v1606+/platforms/linux64GccDPInt32Opt/bin/TFM-Foam" #8 ? in "/home/ofuser/OpenFOAM/ofuser-v1606+/platforms/linux64GccDPInt32Opt/bin/TFM-Foam" #9 Foam::efficiencyFunction::adddictionaryConstructorToTable<Foam::colinWrinkling>::New(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, double const&) in "/home/ ofuser/OpenFOAM/ofuser-v1606+/platforms/linux64GccDPInt32Opt/bin/TFM-Foam" #10 ? in "/home/ofuser/OpenFOAM/ofuser-v1606+/platforms/linux64GccDPInt32Opt/bin/TFM-Foam" #11 ? in "/home/ofuser/OpenFOAM/ofuser-v1606+/platforms/linux64GccDPInt32Opt/bin/TFM-Foam" #12 __libc_start_main in "/lib64/libc.so.6" #13 ? in "/home/ofuser/OpenFOAM/ofuser-v1606+/platforms/linux64GccDPInt32Opt/bin/TFM-Foam" Segmentation fault |
|
February 11, 2017, 17:23 |
|
#4 |
Senior Member
|
LESDeltas developed using new API (cubeRootVolDelta in you output) can not live with old LESDelta API. Hence, segmentation fault.
Modification should be made here (efficiencyFunction.C): Code:
delta_(LESdelta::New("delta", U.mesh(), *this)) |
|
February 12, 2017, 14:58 |
|
#5 |
New Member
Join Date: Sep 2012
Posts: 23
Rep Power: 14 |
Thank you alexeym for your help.
I am getting a little bit confused by employing of your suggestion in : Code:
delta_(LESdelta::New("delta", U.mesh(), *this)) |
|
February 12, 2017, 15:28 |
|
#6 |
Senior Member
|
Unfortunately now I am not quite getting your question. Instead of U.mesh(), which has type const fvMesh&, you have to pass something with type turbulenceModel& (guess you have turbulence model in your solver).
You have several choices: 1. You have turbulence model variable at the place of LESDelta creation, pass this variable as the second parameter to LESDelta::New. 2. You do not have turbulence model variable at the place of LESDelta creation. Since turbulenceModel has IOdictionary as parent, it is registered in object registry, and you can look it up by a) name using lookupObject<turbulenceModel>(name), b) look it up by class using lookupClass<turbulenceModel>(). And then pass result as a second parameter to LESDelta::New. |
|
February 14, 2017, 12:59 |
|
#7 |
New Member
Join Date: Sep 2012
Posts: 23
Rep Power: 14 |
I am sorry if my question makes you confused. That's probably because I have never done that before and my question is more fundamental!
I prefer to look it up in turbulenceProperties dictionary. I tried two different ways. I added below lines to my C file : Code:
const turbulenceModel& turbModel = db().lookupObject<turbulenceModel>(turbName); delta_(LESdelta::New("delta", turbName, *this)) Code:
{ word typeTurb; IOdictionary propertiesDict ( IOobject ( "turbulenceProperties", U.time().constant(), U.db(), IOobject::MUST_READ, IOobject::NO_WRITE ) ); propertiesDict.lookup("simulationType") >> typeTurb; } delta_(LESdelta::New("delta", typeTurb, *this)) |
|
February 14, 2017, 15:56 |
|
#8 |
Senior Member
|
Fancier and fancier...
As I said the second parameter of LESdelta::New should have type turbulenceModel. I do not know what is turbName in your first example and I do not know why you have decided to pass word instead of turbulenceModel. Here are two examples of how you can construct LESdelta using only fvMesh: Code:
void strange_function_creating_les_delta(const fvMesh& mesh) { const turbulenceModel& turbulence_model = mesh.lookupObject<turbulenceModel>("turbulenceProperties"); dictionary dict; dict.add("delta", "vanDriest"); dictionary coeffs; coeffs.add("delta", "cubeRootVol"); dictionary crv_coeffs; coeffs.add("cubeRootVolCoeffs", crv_coeffs); dict.add("vanDriestCoeffs", coeffs); autoPtr<LESdelta> delta( LESdelta::New("delta", turbulence_model, dict)); } Output Code:
Selecting LES delta type vanDriest Selecting LES delta type cubeRootVol Code:
class DeltaGetter : public LESModel<incompressible::turbulenceModel> { public: DeltaGetter( const word& type, const alphaField& alpha, const rhoField& rho, const volVectorField& U, const surfaceScalarField& alphaRhoPhi, const surfaceScalarField& phi, const transportModel& transport, const word& propertiesName) : LESModel<incompressible::turbulenceModel>( type, alpha, rho, U, alphaRhoPhi, phi, transport, propertiesName) {} ~DeltaGetter() {} LESdelta& delta() { return const_cast<LESdelta&>(delta_()); } }; void strange_function_getting_reference_to_les_delta(const fvMesh& mesh) { void* model = static_cast<void*>( &(const_cast<turbulenceModel&>( mesh.lookupObject<turbulenceModel>("turbulenceProperties")))); DeltaGetter* dg = static_cast<DeltaGetter*>(model); LESdelta& delta = dg->delta(); Info << delta.type() << endl; } Output (in $FOAM_TUTORIALS/incompressible/pisoFoam/les/pitzDaily): Code:
cubeRootVol |
|
February 15, 2017, 01:34 |
|
#9 |
New Member
Join Date: Sep 2012
Posts: 23
Rep Power: 14 |
Hands up !!! Unfortunately I couldn't fix it! I attached the files. Could you pls fix it for me ?!
|
|
February 15, 2017, 03:40 |
|
#10 |
Senior Member
|
You can fix it in many ways, for example:
Code:
efficiencyFunction::efficiencyFunction( const volVectorField& U, const scalar& TF) : IOdictionary( IOobject( "efficiencyFunctionProperties", U.time().constant(), U.db(), IOobject::MUST_READ)), U_(U), TF_(TF), efficiency_( IOobject( "efficiency", U.time().timeName(), U.mesh(), IOobject::NO_READ, IOobject::AUTO_WRITE), U.mesh(), dimensionedScalar("efficiency", dimless, 1.0)), delta_( LESdelta::New( "delta", U.mesh().lookupObject<turbulenceModel>("turbulenceProperties"), *this)) {} Code:
efficiencyFunction::efficiencyFunction( const volVectorField& U, const scalar& TF) : ... delta_() // default nullptr value for pointer { // Here we can put code to look up turbulence model and create delta // For example: const turbulenceModel& turbulence_model = U.mesh().lookupObject<turbulenceModel>("turbulenceProperties"); delta_ = LESdelta::New("delta", turbulence_model, *this); } Last edited by alexeym; February 16, 2017 at 05:22. Reason: U.mesh() instead of just mesh |
|
February 16, 2017, 13:20 |
|
#11 |
New Member
Join Date: Sep 2012
Posts: 23
Rep Power: 14 |
It is working now! I appreciate for your help.
|
|
August 29, 2018, 12:57 |
|
#12 |
Member
Join Date: Feb 2014
Posts: 63
Rep Power: 12 |
Hi Zack, Alexey,
I am also having the same problem with same code, unlike Zack I am trying to use this solver with OpenFOAM-dev version. When I looked at the LESdelta.H files between v1606 and OF-dev there is no difference at all. So the solution methods by Alexey should ideally work on my case. But I still get the following error for both method Code:
efficiencyFunction.C: In constructor 'Foam::efficiencyFunction::efficiencyFunction(const volVectorField&, Foam::volScalarField&)': efficiencyFunction.C:91:65: error: no matching function for call to 'Foam::LESdelta::New(const char [6], const Foam::turbulenceModel&, Foam::efficiencyFunction&)' delta_ = LESdelta::New("delta", turbulence_model, *this); ^ If you guys could help me here, I would be very thankful. |
|
August 29, 2018, 16:22 |
|
#13 |
Member
Join Date: Feb 2014
Posts: 63
Rep Power: 12 |
Hi,
Sorry to bother you guys, I fixed it. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
when running tutorial: Permission denied collect2: ld returned 1 exit status | semaviso | OpenFOAM Running, Solving & CFD | 3 | December 12, 2019 11:03 |
[swak4Foam] Error bulding swak4Foam | sfigato | OpenFOAM Community Contributions | 18 | August 22, 2013 13:41 |
[swak4Foam] Installing swak4Foam to OpenFOAM in mac | Kaquesang | OpenFOAM Community Contributions | 22 | January 21, 2013 12:51 |
OpenFOAM 1.6-ext git installation on Ubuntu 11.10 x64 | Attesz | OpenFOAM Installation | 45 | January 13, 2012 13:38 |
Errors running allwmake in OpenFOAM141dev with WM_COMPILE_OPTION%3ddebug | unoder | OpenFOAM Installation | 11 | January 30, 2008 21:30 |