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

runTime out of scope in functionObject

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 19, 2012, 04:22
Default runTime out of scope in functionObject
  #1
New Member
 
Sune Niemann
Join Date: Aug 2011
Posts: 18
Rep Power: 14
Sune is on a distinguished road
Hi all,

My situation: I have created a new functionObject by dublicating the existing forceCoeffs functionObject. I modified it to do various averaging functions on the fly, and check if forces have stabilized.

My problem: I want to writeAndEnd (or any equivalent) when a certain criteria is met, but runTime is not in scope.

Another problem: I am new to OF programming.

My setup: I'm running OF-2.1 in parallel, the layout of the code is much like the original forceCoeffs functionObject, so it includes Time.H. The code work as I intend and compiles when I do not include any runTime functions.

Question: I can access time information from the objectRegistry like obr_.time().timeName() but so far as I can see, it does not inherit the member functions I am interested in. Can I include runTime in the functionObject scope or is there another way I can write and stop simulation?

What I have tried so far:
Code:
runTime.writeAndEnd();
//produce the error: runTime is not in scope
and
Code:
obr_.time().writeAndEnd();
//produce the error: class has no member named writeAndEnd
and many more desperate variations.


My feeling is that my main problem is in my programming skills and that I am doing something embarisingly wrong, so I hope someone can give me a pointer to the right solution, thank you in advance.
Sune is offline   Reply With Quote

Old   September 24, 2012, 18:30
Default
  #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
Quote:
Originally Posted by Sune View Post
Hi all,

My situation: I have created a new functionObject by dublicating the existing forceCoeffs functionObject. I modified it to do various averaging functions on the fly, and check if forces have stabilized.

My problem: I want to writeAndEnd (or any equivalent) when a certain criteria is met, but runTime is not in scope.

Another problem: I am new to OF programming.

My setup: I'm running OF-2.1 in parallel, the layout of the code is much like the original forceCoeffs functionObject, so it includes Time.H. The code work as I intend and compiles when I do not include any runTime functions.

Question: I can access time information from the objectRegistry like obr_.time().timeName() but so far as I can see, it does not inherit the member functions I am interested in. Can I include runTime in the functionObject scope or is there another way I can write and stop simulation?

What I have tried so far:
Code:
runTime.writeAndEnd();
//produce the error: runTime is not in scope
and
Code:
obr_.time().writeAndEnd();
//produce the error: class has no member named writeAndEnd
and many more desperate variations.


My feeling is that my main problem is in my programming skills and that I am doing something embarisingly wrong, so I hope someone can give me a pointer to the right solution, thank you in advance.
Either dynamicCast the obr to be a fvMesh (which it actually is) or if you have a field use the mesh()-method of that to get to the same mesh
__________________
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   September 26, 2012, 03:11
Default
  #3
New Member
 
Sune Niemann
Join Date: Aug 2011
Posts: 18
Rep Power: 14
Sune is on a distinguished road
Quote:
Originally Posted by gschaider View Post
Either dynamicCast the obr to be a fvMesh (which it actually is) or if you have a field use the mesh()-method of that to get to the same mesh
Thanks for your answer, I settled on the following solution:

Code:
obr_.time().stopAt(Time::saNextWrite)
the enumerator stopControls in Time.H also gives the other standard stopAt options with saNoWriteNow and saWriteNow.
Sune 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
Compile calcMassFlowC aurore OpenFOAM Programming & Development 13 March 23, 2018 08:43
error compiling modified applications yvyan OpenFOAM Programming & Development 21 March 1, 2016 05:53
checking the system setup and Qt version vivek070176 OpenFOAM Installation 22 June 1, 2010 13:34
Installation OF1.5-dev ttdtud OpenFOAM Installation 46 May 5, 2009 03:32
How to get the max value of the whole field waynezw0618 OpenFOAM Running, Solving & CFD 4 June 17, 2008 06:07


All times are GMT -4. The time now is 12:30.