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

Calling an external function beforeafter each time step

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 12, 2008, 14:35
Default Hi everybody: I need to mak
  #1
New Member
 
Alex Schenkman
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 13
Rep Power: 17
alesch is on a distinguished road
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!
alesch is offline   Reply With Quote

Old   December 12, 2008, 15:46
Default Hi Alex! What you're lookin
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
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
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   December 15, 2008, 14:30
Default Thank you Bernhard for your an
  #3
New Member
 
Alex Schenkman
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 13
Rep Power: 17
alesch is on a distinguished road
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 is offline   Reply With Quote

Old   December 15, 2008, 15:26
Default Ok, let's see If I'm getting t
  #4
New Member
 
Alex Schenkman
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 13
Rep Power: 17
alesch is on a distinguished road
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, :-)
alesch is offline   Reply With Quote

Old   December 16, 2008, 03:41
Default Hi Alex, Since it would app
  #5
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,679
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
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.
olesen is offline   Reply With Quote

Old   December 16, 2008, 08:27
Default Mark, thanks for your input!
  #6
New Member
 
Alex Schenkman
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 13
Rep Power: 17
alesch is on a distinguished road
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.
alesch is offline   Reply With Quote

Old   December 16, 2008, 14:08
Default Hi Alex! That is definitely
  #7
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
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
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   December 16, 2008, 14:47
Default Thanks Bernhard! I was thin
  #8
New Member
 
Alex Schenkman
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 13
Rep Power: 17
alesch is on a distinguished road
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!
alesch is offline   Reply With Quote

Old   December 17, 2008, 05:57
Default Hi Alex! You're on 1.5 aren
  #9
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
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
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Time step size and max iterations per time step pUl| FLUENT 33 October 23, 2020 23:50
SELECTING TIME STEP SIZE, NUMBER OF TIME STEP NITUL KALITA FLUENT 2 November 22, 2012 09:28
Long time CHT transient simulation time step.... JP CFX 0 May 9, 2008 04:36
time step size in Custom Field Function Tong FLUENT 0 May 2, 2008 16:51
start external programm every time step Ingolf FLUENT 0 March 3, 2003 05:59


All times are GMT -4. The time now is 10:31.