Problem linking library
Dear All,
I am trying to rewrite turbulence models library for multiphase flows. To this end I have created my own library libInterRASModels.so and with its own turbulenceModel definition. I wanted it to be seperate from incompressible and compressible turbulence models so I created my onw namespace: multiphase. The library compiles but for some reason I cannot link it to my customised interFoam. The only part that I changed is: Code:
// Construct incompressible turbulence model Code:
g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O0 -fdefault-inline -ggdb3 -DFULLDEBUG -DNoRepository -ftemplate-depth-40 -I/home/c111269/OpenFOAM/OpenFOAM-1.7.1/src/transportModels -I/home/c111269/OpenFOAM/OpenFOAM-1.7.1/src/transportModels/incompressible/lnInclude -I/home/c111269/OpenFOAM/OpenFOAM-1.7.1/src/transportModels/interfaceProperties/lnInclude -I/home/c111269/OpenFOAM/c111269-1.7.1/src/turbulenceModels/multiphase/turbulenceModel -I/home/c111269/OpenFOAM/OpenFOAM-1.7.1/src/finiteVolume/lnInclude -IlnInclude -I. -I/home/c111269/OpenFOAM/OpenFOAM-1.7.1/src/OpenFOAM/lnInclude -I/home/c111269/OpenFOAM/OpenFOAM-1.7.1/src/OSspecific/POSIX/lnInclude -fPIC Make/linux64GccDPDebug/interFoam.o -L/home/c111269/OpenFOAM/OpenFOAM-1.7.1/lib/linux64GccDPDebug \ |
Hi Robert,
I suppose you must edit your Make/options and add for example -lincompressibleRASModels \ to the LIB_LIBS settings. Martin |
Thanks. I have already edited Make/options. Here's what it looks like:
Code:
EXE_INC = \ |
@MartinB: One more thing: the ldd command for libInterRASModels.so gives:
Code:
linux-vdso.so.1 => (0x00007fff97648000) |
Greetings to all!
@Robert: Two possibilities come to mind:
Best regards, Bruno |
Thank you for your comment. Sorry I didn't reply instantaneously. Temporarily I used a workaround by lumping together the code with the library code. It's not very elegant so I am still interested in sorting it out. So if you can spare the time please let me know what you think.
Quote:
Quote:
Quote:
Therefore, I wish to dampen turbulence by introducing density rho to my incompressible turbulence model but I don't want to use thermo dynamical models. I am using interFoam. Turbulence model is invoked only twice: Initialisation Code:
autoPtr<multiphase::turbulenceModel> turbulence Code:
turbulence->correct(); Code:
tmp<fvScalarMatrix> omegaEqn |
Hi Robert,
This is so funny ;) You did the exact opposite of what I asked you ;) I wanted the modifications to the library without the new turbulence model itself :D OK, if you can, please pack the code of your modified library into a tarball and attach it to your next post. If not, no problem, we'll try to figure it out just the same :) To check if your still linking to the original files, it seems that the only place that there might be some confusion would be in the modified interFoam Make/options file. The original file looks like this: Code:
EXE_INC = \ Another thing that might be making things difficult is if there are any left overs from the original objects. In other words, when you copied the source code folder, did you run: Code:
wclean all Best regards, Bruno |
2 Attachment(s)
Hello,
and thanks again for your comments. Quote:
Anyway, thanks for your patience. :) Quote:
Quote:
I have double double checked by running wclean all on both library and application. Alas, it didn't help. Please find the sources attached. |
Hi Robert,
I was worried about confidentiality issues about the code changes you were making. That's why I was asking for only the stuff that you changed, without the modelling changes themselves. Quote:
OK, what I sometimes do is run ./Allwmake or wmake all two times in a row, because the second run will give me the summary of what went wrong or right. And I got this when running for the library folder: Code:
'/home/me/OpenFOAM/me-1.7.x/lib/linux64GccDPOpt/libInterRASModels.so' is up to date. So I went to check things in the "Make/files" and both RAS and turbulenceModel have: Code:
LIB = $(FOAM_USER_LIBBIN)/libInterRASModels I haven't checked the rest of the code, because I'm guessing this was the only problem. Best regards, Bruno |
Hello!
Thank you. Your last comment set me on the right track. I was separately compiling two different sets of C files to the same library. So instead of making, say libmultiphaseTurbulenceModels.so and libinterTurbulenceModels.so, and then linking the former to the latter through LIB_LIBS, I was making libinterTurbulenceModels.so twice! That was not very brilliant of me but you've shown me the light (pun intended ;)). Also, I was not concerned with confidentiality issues since the things I implemented so far are in the public domain. Actually, now I have a much more convenient framework to start writings more original things. Many, many thanks! |
Hi Robert,
I'm glad I could help :) Best regards, Bruno |
Hello,
@Robert: currently I'm implementing quite similar turbulence models for two-phase flows. Regarding your statement below, do you have any papers come out? That'll be a good reference for me. "The standard incompressible models give a very large values of turbulence at the interface due to large sheer stress (production term large). This effect is artificially caused by inadequately chosen equations. Therefore, I wish to dampen turbulence by introducing density rho to my incompressible turbulence model but I don't want to use thermo dynamical models." @ Bruno: When implementing my own turbulence models, the wall functions related classes will also have to be changed. Otherwise it will complain while lookupObject<RASModel>... If I'm not correct, please correct me. Thanks. Regards, Jason |
Greetings Jason,
Quote:
I checked this page I saw today: http://openfoamwiki.net/index.php/Ho..._wall_function - and it pointed to this thread: http://www.cfd-online.com/Forums/ope...-function.html - but the instructions there are for OpenFOAM 1.1... so I can only guess that this has changed a lot since 2005/2006. Best regards, Bruno |
Hi Bruno,
I adapted only those wall functions I need, like epsilon, omega, nut. I use of211. I guess the source code directories for RAS and wall functions has changed a lot. Actually I think whether or not to change the wall functions depends on how you implement your own turbulence models. In my case, I renamed RASModel as myRASModel. So every time a lookupObject<RASModel> is called, I have to rename the class name. Regards, Jason |
Hi Jason,
Quote:
I suggest that in this case, you take the easy road: hack directly on OpenFOAM's source code. In addition, I advise you to use OpenFOAM 2.1.x and to learn how to use git: http://git-scm.com/docs/gittutorial The reason for these two suggestions is simple:
On the other hand, if you truly want to use only OpenFOAM 2.1.1, then have both the Deb/RPM version installed and the source code version installed as well, in order to compare results of simulations. Then use git for keeping track of your changes to the source code. As for having more than one OpenFOAM version around, read this blog post of mine: Advanced tips for working with the OpenFOAM shell environment Best regards, Bruno |
Quote:
That's a very easy to alter the code. Thanks for pointing that out for me, as I just try to alter the source code by myself. I mainly use OF 211 now. It will be a lot easier to compare simulations if the code is altered in the corresponding version of 2.1.x. But do you think is there any need to use OF 2.2.x instead, since this is the newest version? Thanks Regards, Jason |
Hi Jason,
The advantage of using the latest 2.2.x version are three-fold, as far as I can imagine:
Bruno |
Same problem with LES deltas...
2 Attachment(s)
Dear All,
I'm just facing a similar problem when implementing an extension to the incompressibleLESModels library which I hope to link to my custom solver. I attach here both folders. Since my solver needs an additional member function from the turbulenceModel class, I copy/edited the turbulenceModel files and built a custom library called 'libextIncompressibleTurbulenceModel' (and BTW this is a good way to practice library implementation in OF...). :cool: Then I copy/edited the LESModel folder, now keeping only Smagorinsky for simplicity, and built another custom library 'libextIncompressibleLESModels' by linking the one above via LIB_LIBS. Everything seems fine up to this point, and 'ldd' returns a complete list of dependencies, including 'libLESdeltas.so' and 'libLESfilters.so'. Additionally by 'nm -D libextIncompressibleLESModels.so | grep LESdelta' I have Code:
U _ZN4Foam14incompressible8LESdelta3NewERKNS_4wordERKNS_6fvMeshERKNS_10dictionaryE Code:
/home/ale/OpenFOAM/ale-2.3.x/platforms/linux64GccDPOpt/lib/libextIncompressibleLESModels.so: undefined reference to `Foam::incompressible::LESdelta::New(Foam::word const&, Foam::fvMesh const&, Foam::dictionary const&)' -> I would be happy to receive your suggestions! Thanks for your help, a quite confused Alex. |
What exactly is the error you are given?
"ld returned exit status 1" is not the error. The real error is above it. If the error is "undefined symbol", which I assume it is, as you are giving us 'nm' output, then I have recently had a similar problem. This was not related to a turbulence model, and I don't think it was related to RTS either. This problem arose because I declared a virtual destructor in the .H file, but I did not implement it in the .C file (in a class that was going to be instantiated). For a library, this did not give a compilation error, but linking couldn't be done. (If I recall correctly.) |
Hi Kevin,
and thanks for your quick reply! :) Actually you pointed me in the right direction... Problem solved: the issue arising from LESdelta::New was connected to the fact that I incorrectly assumed that LESdelta object would be constructed by using the corresponding libraries... which is NOT what actually happens inside incompressible::LESmodel. An additional class incompressible::LESdelta is derived from LESdelta (note the nested namespaces) which actually renders the RTS machinery from libLESdeltas available inside libincompressibleLESModels. It is by this mechanism that the "virtual" constructor in the factory are completed in all the details, including the selector for autoPtr<LESdelta> data member inside LESModel. :D Thanks again!! :cool: Ciao, Alex |
All times are GMT -4. The time now is 20:02. |