|
[Sponsors] |
how to add my FunctionObject in the list of available configured functionObjects |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
December 8, 2020, 11:23 |
how to add my FunctionObject in the list of available configured functionObjects
|
#1 |
Senior Member
Cedric DUPRAT
Join Date: Mar 2009
Location: Nantes, France
Posts: 195
Rep Power: 17 |
Dear Foamers,
tiny question related to functionObjet. I'm working on OF8. I've implemented a functionObject to do some post-processing in my local work space. I can use this functionObject during the running of my simulation meaning that implementation/compilation is correct. however, conventional post-processing (after the simulation has run) is not possible. Code:
postProcess -func toto (where toto is my functionObject) Code:
Cannot find functionObject file toto Code:
postProcess -list Here is my question, how to add my functionObject "toto" in the list of available configured functionObjects ? Thank you in advance for your help. Cedric |
|
December 8, 2020, 16:34 |
|
#2 |
Senior Member
Join Date: Aug 2015
Posts: 494
Rep Power: 15 |
Is the new function object compiled as a separate library? If so, my first thought would be to try with the -libs flag and try to load the library for the postProcess utility.
Caelan |
|
December 9, 2020, 02:52 |
|
#3 |
Senior Member
Cedric DUPRAT
Join Date: Mar 2009
Location: Nantes, France
Posts: 195
Rep Power: 17 |
Good morning Caelan,
Thank you for your reply. Yes, my new function object is compiled as a separate library (libmyFunctionObject.so) You're right about the -libs flag, I've never used this flag before. Could you write me how to use this flag please ? I've tryed the following lines: Code:
postProcess -func toto -libs libmyFunctionObject.so postProcess -func toto -libs "libmyFunctionObject.so" postProcess -func toto -libs ("libmyFunctionObject.so") postProcess -func toto -libs "(libmyFunctionObject.so)" the first two try lead to : Code:
--> FOAM FATAL IO ERROR: incorrect first token, expected <int> or '(', found on line 0 the word 'libmyFunctionObject.so' Thank you in advance for your help, Cédric |
|
December 9, 2020, 16:47 |
|
#4 |
Senior Member
Join Date: Aug 2015
Posts: 494
Rep Power: 15 |
Unfortunately, I've never used this flag either. For lack of a better idea at the moment, what if you recompiled the (original) function object lib to include your new function? Then it would be recognized.
Caelan |
|
December 13, 2020, 06:22 |
|
#5 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
Quote:
|
||
December 13, 2020, 06:56 |
|
#6 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
Did you remember to have an addTo.. statement in your .C file to register your new function with the runtime lookup table?
|
|
December 14, 2020, 05:45 |
|
#7 |
Senior Member
Cedric DUPRAT
Join Date: Mar 2009
Location: Nantes, France
Posts: 195
Rep Power: 17 |
Thank you both for your help.
to avoid any issue in my implementation, I've just copied an existing functionObject Q and create a a new function "myQ" in my local work space. I've changed the "Q" by myQ in the *.C and *.H file. Hence, I'm sure I've the following statement which is suposed to add "myQ" in the runTimeSelectionTable: addToRunTimeSelectionTable ( |
|
December 14, 2020, 05:57 |
|
#8 |
Senior Member
Cedric DUPRAT
Join Date: Mar 2009
Location: Nantes, France
Posts: 195
Rep Power: 17 |
oups, the end of my email is missing.
well you got the idea, the sources is the same in the original Q functionObject and my myQ functionObject (except the name of the functionObject of course) compilation is fine. When I try to use my fonctionObject (which doesn't appear in postProcess -list) typing: HTML Code:
postProcess -func myQ -libs "(mylibfieldFunctionObjects)" HTML Code:
wrong token type - expected string, found on line 0 the word 'mylibfieldFunctionObjects' I can run 1 more iteration on my calculation to apply my functionObject. It's just too bad that I cannot use it as conventional post-processing. Best regards, Cédric |
|
December 14, 2020, 06:52 |
|
#9 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
Quote:
OK that explains somethings, I missed that you are using the openfoam.org version. For that version, it doesn't seem to manage the transition of word to fileName at all, so you need to quote these. Depending on how you are calling this (eg, in a script), you have a few options for quoting. Added some spaces for readability (which you can keep or discard as you like) and a fictitious second library (for illustration): Code:
-libs "( \"libmyfieldFunctionObjects.so\" \"libother.so\" )" # or -libs '( "libmyfieldFunctionObjects.so" "libother.so" )' For completeness, if you or someone else is using the openfoam.com version, note that there the option is "-lib" (not "-libs") and behaves somewhat differently. - can be stacked numerous times - can contain individual or multiple library names - additional quotes are unneeded - handles system-specific library endings (.so, .dynlib etc) - prefixes regular 'lib' if needed to resolve the name. Eg, Code:
-lib myfieldFunctionObjects -lib other -lib \( myfieldFunctionObjects other \) -lib '( myfieldFunctionObjects other )' -lib '( "myfieldFunctionObjects" "other" )' -lib '( "myfieldFunctionObjects.so" other.so )' -lib '( libmyfieldFunctionObjects "other.so" )' ... |
||
December 14, 2020, 10:29 |
|
#10 |
Senior Member
Cedric DUPRAT
Join Date: Mar 2009
Location: Nantes, France
Posts: 195
Rep Power: 17 |
Thank you Mark for your help.
I've tryed many different ways of writting my postProcess shell line but, you got the correct one !! however, I still have an issu with my functionObject "myQ". To run the original Q functionObject, one need to type: Code:
simpleFoam -postProcess -func Q Code:
simpleFoam -postProcess -func myQ -libs "( "libfieldMyFunctionObjects.so" )" Code:
--> FOAM Warning : From function void* Foam:dlOpen(cons Foam::fileName&, bool) in file POSIX.C at line 1251 dlopen error: /home/ ..... /lib/libfieldMyFunctionObjects.so: undefined symbol: _ZTIN4Foam15functionObjects15fieldExpressionE after the warning, OpenFOAM run the executable but at the end; "cannot find functionObject file myQ". Notice that I've tryed with both Code:
simpleFoam -postProcess -func myQ -libs "( \"libfieldMyFunctionObjects.so\" )" Code:
simpleFoam -postProcess -func myQ -libs '( "libfieldMyFunctionObjects.so" )' any idea ? thanks in advance |
|
December 15, 2020, 03:39 |
|
#11 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
If you read the messages, you'll see the problem. You have instructed it to load your library, but nowhere does it yet know that your library also requires libfieldFunctions !
Code:
-lib fieldFunctions -lib fieldMyFunctionObjects # or -libs '( "libfieldFunctions.so" "libfieldMyFunctionObjects.so" )' |
|
December 15, 2020, 03:42 |
|
#12 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
Quote:
Note that these both are actually identical, after the shell has gone through them. In the first, you send everything in as a single argument, but need to backslash escape the double quotes since you are already in a double quoted string. In the second, you also send everything in as a single argument, but since it is surrounded in single quotes, the embedded double quote doesn't need any escaping. |
||
December 15, 2023, 19:13 |
|
#13 |
Senior Member
Charles
Join Date: Aug 2016
Location: Vancouver, Canada
Posts: 150
Rep Power: 10 |
Hi Cedric,
I have a same problem. Have you resolved the problem? How to link the library? Thanks in advance,
__________________
Charles L. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Other] How to use finite area method in official OpenFOAM 2.2.0? | Detian Liu | OpenFOAM Meshing & Mesh Conversion | 4 | November 3, 2015 03:04 |
[foam-extend.org] problem when installing foam-extend-1.6 | Thomas pan | OpenFOAM Installation | 7 | September 9, 2015 21:53 |
Problem compiling a custom Lagrangian library | brbbhatti | OpenFOAM Programming & Development | 2 | July 7, 2014 11:32 |
[OpenFOAM] how to add fields in list as default? | immortality | ParaView | 10 | June 28, 2013 17:49 |
How to add a new variable in the list of variables for MESH ADAPTATION ?? | Tramery | CFX | 3 | September 28, 2011 10:27 |