CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   Calling an external function beforeafter each time step (https://www.cfd-online.com/Forums/openfoam/60723-calling-external-function-beforeafter-each-time-step.html)

alesch December 12, 2008 13:35

Hi everybody: I need to mak
 
Hi everybody:

I need to make a call to an external function before and after each time step of the solver.
This is to be able to interact with other software.

I've seen I can compile my own library (foamUser) so my new functions are available for all applications.

But I don't know where to go from here. Any pointers are appreciated.

Thanks in advance!

gschaider December 12, 2008 14:46

Hi Alex! What you're lookin
 
Hi Alex!

What you're looking for is called a functionObject. For an example of the usage of those look at $FOAM_TUTORIASL/oodles/pitzDaily/system/controlDict. For examples on the programming of those look at the doxygen or http://openfoamwiki.net/index.php/Co...unctionObjects

Bernhard

alesch December 15, 2008 13:30

Thank you Bernhard for your an
 
Thank you Bernhard for your answer.

I've looked a bit into Contrib_simpleFunctionObjetcs but I don't get any smarter, =(

The README references the script prepareForCompilation.sh, but I cannot find that script.
That script is needed for building simpleFunctionObjects, right?

I guess I need to create my own functionObject, and I could use your contributed module as a starting point, right?

In other words: HELP, I'm still lost!

Thank you for you time!

alesch December 15, 2008 14:26

Ok, let's see If I'm getting t
 
Ok, let's see If I'm getting this right:

1) I need to subclass functionObject or, even better, simpleFunctionObject.

2) Overriding the write() method I can (in some way) extract data after the solver is ready with a time step.

3) I could use the flush() method to block, and wait for my external function to return some value. Then OF could continue with the next time step.


God!, I'm making progress here, :-)

olesen December 16, 2008 02:41

Hi Alex, Since it would app
 
Hi Alex,

Since it would appear that you are trying to achieve a specific task, why not just reassemble your own solver? Take whichever existing solver, copy it under a new name and within the main time-loop just add in your external calls directly.

At a later stage you can rework it all to use functionObjects (if desired), but this would get you going very quickly and is a good bit easier to implement.

alesch December 16, 2008 07:27

Mark, thanks for your input!
 
Mark, thanks for your input!

The tool I'm trying to build should, ideally, work with minimal modifications to standard installs.
This tool should work for other people than me, and then I cannot tell which solver they will choose.

gschaider December 16, 2008 13:08

Hi Alex! That is definitely
 
Hi Alex!

That is definitely the definition of a functionObject. But (especially if it is your first FO) Mark's suggestion is good practise: make sure that the functionality works, then rework it into a function object. That way you'll know whether the problems you're experiencing are "functionObject problems" or "other problems"

Bernhard

alesch December 16, 2008 13:47

Thanks Bernhard! I was thin
 
Thanks Bernhard!

I was thinking on adding a functionObject to the cavity tutorial, to be sure that the application works.

What about the script prepareForCompilation.sh?
Where can I find it?

Thanks!

gschaider December 17, 2008 04:57

Hi Alex! You're on 1.5 aren
 
Hi Alex!

You're on 1.5 aren't you? You don't need it there. The README was not properly updated when that code was ported to 1.5 (the functionality it was needed for - surface-plots triggered by a function object - is now part of the distribution)

But I'll update the README. Thanks for the hint (and it's nice to know that somebody actually reads READMEs ;) )

Bernhard


All times are GMT -4. The time now is 00:39.