CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Post-Processing

how to add my FunctionObject in the list of available configured functionObjects

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By olesen

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 8, 2020, 11:23
Default 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
cedric_duprat is on a distinguished road
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)
give me the following error message:

Code:
Cannot find functionObject file toto
and indeed, typing
Code:
postProcess -list
I cannot find my toto either.


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
cedric_duprat is offline   Reply With Quote

Old   December 8, 2020, 16:34
Default
  #2
Senior Member
 
Join Date: Aug 2015
Posts: 494
Rep Power: 15
clapointe is on a distinguished road
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
clapointe is offline   Reply With Quote

Old   December 9, 2020, 02:52
Default
  #3
Senior Member
 
Cedric DUPRAT
Join Date: Mar 2009
Location: Nantes, France
Posts: 195
Rep Power: 17
cedric_duprat is on a distinguished road
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)"
without any success.

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'
the last two lead to a error in french.


Thank you in advance for your help,


Cédric
cedric_duprat is offline   Reply With Quote

Old   December 9, 2020, 16:47
Default
  #4
Senior Member
 
Join Date: Aug 2015
Posts: 494
Rep Power: 15
clapointe is on a distinguished road
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
clapointe is offline   Reply With Quote

Old   December 13, 2020, 06:22
Default
  #5
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by cedric_duprat View Post
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)"
without any success.
The -libs option expects a list of names, but you must remember that parentheses also have a special meaning in shell syntax, so your last example is the one that should work.
olesen is offline   Reply With Quote

Old   December 13, 2020, 06:56
Default
  #6
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Did you remember to have an addTo.. statement in your .C file to register your new function with the runtime lookup table?
olesen is offline   Reply With Quote

Old   December 14, 2020, 05:45
Default
  #7
Senior Member
 
Cedric DUPRAT
Join Date: Mar 2009
Location: Nantes, France
Posts: 195
Rep Power: 17
cedric_duprat is on a distinguished road
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
(
cedric_duprat is offline   Reply With Quote

Old   December 14, 2020, 05:57
Default
  #8
Senior Member
 
Cedric DUPRAT
Join Date: Mar 2009
Location: Nantes, France
Posts: 195
Rep Power: 17
cedric_duprat is on a distinguished road
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)"
I have the following error message:
HTML Code:
wrong token type - expected string, found on line 0 the word 'mylibfieldFunctionObjects'
I've tryed only with OpenFOAM8 because the -libs argument doesn't seems to exist in OpenFOAM6.

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
cedric_duprat is offline   Reply With Quote

Old   December 14, 2020, 06:52
Default
  #9
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by cedric_duprat View Post
...

Code:
postProcess -func myQ -libs "(mylibfieldFunctionObjects)"
I have the following error message:
Code:
wrong token type - expected string, found on line 0 the word 'mylibfieldFunctionObjects'
I've tryed only with OpenFOAM8 because the -libs argument doesn't seems to exist in OpenFOAM6.

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" )'
Normally you could use \( .. \) for arglist capturing, but since you still need double quotes around the names (for them to be recognized as fileName), it doesn't help that much.

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" )'
 ...
cedric_duprat likes this.
olesen is offline   Reply With Quote

Old   December 14, 2020, 10:29
Default
  #10
Senior Member
 
Cedric DUPRAT
Join Date: Mar 2009
Location: Nantes, France
Posts: 195
Rep Power: 17
cedric_duprat is on a distinguished road
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
I've tryed this for myQ:
Code:
simpleFoam -postProcess -func myQ -libs "( "libfieldMyFunctionObjects.so" )"
And I have the following output:
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
If I understand correctly, the good point is that OpenFOAM now read my library. However, the bad one is ... OpenFOAM can't

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\" )"
and
Code:
simpleFoam -postProcess -func myQ -libs '( "libfieldMyFunctionObjects.so" )'
getting the same warning/error message


any idea ? thanks in advance
cedric_duprat is offline   Reply With Quote

Old   December 15, 2020, 03:39
Default
  #11
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
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" )'
BTW: any particular reason you don't use the openfoam.com version?
olesen is offline   Reply With Quote

Old   December 15, 2020, 03:42
Default
  #12
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by cedric_duprat View Post
Notice that I've tryed with both
Code:
simpleFoam -postProcess -func myQ -libs "( \"libfieldMyFunctionObjects.so\" )"
and
Code:
simpleFoam -postProcess -func myQ -libs '( "libfieldMyFunctionObjects.so" )'
getting the same warning/error message

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.
olesen is offline   Reply With Quote

Old   December 15, 2023, 19:13
Default
  #13
Senior Member
 
Charles
Join Date: Aug 2016
Location: Vancouver, Canada
Posts: 150
Rep Power: 10
Marpole is on a distinguished road
Hi Cedric,

I have a same problem. Have you resolved the problem? How to link the library?

Thanks in advance,
__________________
Charles L.
Marpole is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 15:49.