|
[Sponsors] |
How to detect if PIMPLE has converged from inside fvOption? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
February 1, 2015, 10:24 |
How to detect if PIMPLE has converged from inside fvOption?
|
#1 |
Senior Member
Pete Bachant
Join Date: Jun 2012
Location: Boston, MA
Posts: 173
Rep Power: 14 |
I am writing an fvOption that needs to write some data to CSV, but only when PIMPLE has converged. Is there a clever use of OpenFOAM's Time with which I can detect this? Right now I can detect when the time value has changed, but not when it's about to change.
Source code for reference |
|
February 1, 2015, 10:59 |
|
#2 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Greetings Pete,
Well, if you only wanted to know when it's an iteration in which the solver will save the fields, then you can rely on the method "outputTime()": Code:
if(time_.outputTime()) { // do stuff here whenever it's a time step where the solver will save } As for knowing when it has converged... that's a tricky one. Wait, you want only when it's the last PIMPLE loop. Mmm... this requires access to the PIMPLE object... technically, access to the instance of the class "pimpleControl". OK, let's see:
I took a look and rhoPimpleFoam does call fvOption in the "pEqn.H", but pimpleFoam does not. Therefore, you need to be careful about this. Sorry for not providing the actual piece of code that does the access to the registered object, but I would need to test it first and I've got a lot I would like to take care of today... Best regards, Bruno
__________________
|
|
February 1, 2015, 11:12 |
|
#3 |
Senior Member
Pete Bachant
Join Date: Jun 2012
Location: Boston, MA
Posts: 173
Rep Power: 14 |
Bruno,
Thanks for your reply. As you guessed, I don't want to wait until a time when fields are written--I want to write every timestep. What I want to do is very similar to what the forces function object does, but now I'm wondering if forces are written on the first PIMPLE loop in that... The numbers are very close to each other in my case, so it's not a big problem so far, but I am just trying to be as correct as possible. |
|
February 1, 2015, 12:00 |
|
#4 | |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Quote:
As for the "run()" method, that is called whenever it's called directly be the solver or indirectly by the "simpleControl"/"pimpleControl", e.g.: Code:
while (simple.loop()) { //.... } |
||
May 6, 2015, 14:25 |
|
#5 |
Senior Member
Pete Bachant
Join Date: Jun 2012
Location: Boston, MA
Posts: 173
Rep Power: 14 |
I have been trying to access the pimple object with
Code:
// Write performance data if last PIMPLE iteration const solutionControl& pimple = mesh_.lookupObject<solutionControl>("pimple"); if (pimple.finalNonOrthogonalIter() and Pstream::master()) { writePerf(); } Code:
--> FOAM FATAL ERROR: request for solutionControl pimple from objectRegistry region0 failed available objects of type solutionControl are 0() From function objectRegistry::lookupObject<Type>(const word&) const in file /home/pete/OpenFOAM/OpenFOAM-2.3.x/src/OpenFOAM/lnInclude/objectRegistryTemplates.C at line 198. |
|
September 21, 2015, 18:34 |
|
#6 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Hi Pete,
I had this on my to-do list and only today did I manage to look into this. The problem is that the "solutionControl" class derives from "IOobject" and not from "regIOobject", which is why it's not possible to get an instance of this object through the object database. As far as I can figure out, there are roughly only two major solutions:
As for making "solutionControl" class derive from "regIOobject" in OpenFOAM itself, I don't know if this makes much sense, since this is only useful in a few situations. Best regards, Bruno
__________________
|
|
September 24, 2015, 20:49 |
|
#7 |
Senior Member
Pete Bachant
Join Date: Jun 2012
Location: Boston, MA
Posts: 173
Rep Power: 14 |
Hi Bruno,
Thanks for your tireless efforts as usual! Both solutions seem over my head, and may not be desirable, since I want to be compatible with the standard OpenFOAM. For now, I am writing every loop, and taking the last value in post-processing, which is quite easy with the Python Pandas library anyway. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Help for the small implementation in turbulence model | shipman | OpenFOAM Programming & Development | 25 | March 19, 2014 11:08 |
New sixDoFRigidBody BC working with laplaceFaceDecomposition | Ya_Squall2010 | OpenFOAM Running, Solving & CFD | 13 | April 17, 2013 03:04 |
OpenFOAM on MinGW crosscompiler hosted on Linux | allenzhao | OpenFOAM Installation | 127 | January 30, 2009 20:08 |
Modelling the Heat flow inside the curing oven | Marios Vlad | CFX | 1 | February 6, 2008 08:11 |
meshing F1 front wing | Steve | FLUENT | 0 | April 17, 2003 13:37 |