CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Programming & Development

What is the trigger of the function objects??

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

Like Tree1Likes
  • 1 Post By floquation

Reply
 
LinkBack Thread Tools Display Modes
Old   November 24, 2014, 04:58
Default What is the trigger of the function objects??
  #1
New Member
 
Marcel Vonlanthen
Join Date: Nov 2012
Location: Zurich, Switzerland
Posts: 28
Rep Power: 4
Sylv is on a distinguished road
Dear foamer,

In any solver, one can add some function objects in the controlDict. They are triggered at the end of each solver timestep. In the solvers, I guess that the triggering line of code is "runTime.write()". Is that true?

Is it possible to trigger a function object at a different location in the source code? For example, I want to extract the field average of a LES run just after the prediction loop of pimpleFoam (after UEqu.H). What kind of code can I add to trigger a funcObj call?

Best,
Marcel
Sylv is offline   Reply With Quote

Old   November 26, 2014, 09:35
Default
  #2
Member
 
Kevin van As
Join Date: Sep 2014
Location: TU Delft, The Netherlands
Posts: 30
Rep Power: 3
floquation is on a distinguished road
(Below I take v2.3.x as my version.)

As part of my internship, I duck into the lagrangian library for which I looked into both FunctionObjects and CloudFunctionObjects. Attached you'll find a qualitative UML diagram showing the calling sequence of methods. The top-left of the image is the execution of a FunctionObject.

Tracing FunctionObjects, one may find the following in "OpenFOAM-2.3.x / src / OpenFOAM / db / Time / Time.C."

Code:
bool Foam::Time::run() const
{
   ...
   if (timeIndex_ == startTimeIndex_)
   {
      functionObjects_.start();
   }
   else
   {
      functionObjects_.execute();
   }
   ...
}
So, functionObjects are executed via the runTime.run() command in a solver.

While I have never tried executing them elsewhere, I see that the Time class does have a getter for the functionObjects list, so you should be able to retrieve that list and thus execute functionObjects whenever you want.

So something like...
Code:
runTime.functionObjects().execute();
will execute all functionObjects at that time.

To only execute a specific functionObject, you need to do something like...
Code:
label id = runTime.functionObjects().findObjectID(name); //Warning: returns -1 if "name" does not exist.
runTime.functionobjects()[id].execute(forceWrite); //Warning: fatal error if id is out of bounds (e.g. -1)
which uses the methods from:
OpenFOAM-2.3.x / src / OpenFOAM / db / functionObjects / functionObjectList / functionObjectList.C
and "forceWrite" is an optional boolean with defaults 'false'.


Disclaimer: I did not test the above code (I don't have access to OF right now). I reasoned from the source code. Try it yourself.
Attached Images
File Type: png lpt_codeflow1.png (21.9 KB, 8 views)
Sylv likes this.
floquation is offline   Reply With Quote

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Contribution a new utility: refine wall layer mesh based on yPlus field lakeat OpenFOAM Mesh Utilities 57 February 1, 2015 09:25
channelFoam for a 3D pipe AlmostSurelyRob OpenFOAM 3 June 24, 2011 13:06
latest OpenFOAM-1.6.x from git failed to compile phsieh2005 OpenFOAM Bugs 25 February 9, 2010 05:37
Version 15 on Mac OS X gschaider OpenFOAM Installation 120 December 2, 2009 11:23
Problem with compile the setParabolicInlet ivanyao OpenFOAM Running, Solving & CFD 6 September 5, 2008 20:50


All times are GMT -4. The time now is 14:36.