|
[Sponsors] |
Call external code (functionObject execute() like) within pimple.loop() |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
January 28, 2014, 13:53 |
Call external code (functionObject execute() like) within pimple.loop()
|
#1 |
Senior Member
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 22 |
Hello OpenFOAM colleagues,
I'm looking for a way to call code defined (as e.g. functionObject) in the controlDict (ideally a python function using pythonIntegration in swak4Foam) from within the pimple.loop() in a transient solver. Or in (hopefully) simple words: Call a function after each iteration of the outer corrector loop within one time step. functionObjects or pythonIntegrationFunctionObjects are only called once per time step. What is the easiest way to achieve this? Ideally I do not want to overwrite the pimpleControl class but add something (a call to functionObject.execute() ???) to the solver or even better use something already build in. Thank you for any hints/help. Joachim Last edited by jherb; January 28, 2014 at 18:27. |
|
January 30, 2014, 07:40 |
|
#2 |
Senior Member
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 22 |
I found a way to do this: Add the following code to (within) the pimple.loop():
Code:
functionObjectList& fol = runTime.functionObjects(); fol.execute(false); Add the following to your controlDict and the executeCode is called during each step of your pimple.loop: Code:
functions { pythonSimple { type pythonIntegration; // debugPythonWrapper 1; // switching on startCode "print 'Starting';a=0; print dir()"; executeCode "a+=1; print 'a:',a"; endCode "print 'Never been here'"; // tolerateExceptions true; parallelMasterOnly false; isParallelized true; useNumpy false; useIPython true; } pythonOutput { type pythonIntegration; startCode ""; executeCode "print 'timeName :',timeName,'outputTime:',outputTime"; endCode "print 'timeName :',timeName,'outputTime:',outputTime"; // tolerateExceptions true; parallelMasterOnly true; useNumpy false; useIPython true; } } libs ( "libgroovyBC.so" "libswakPythonIntegration.so" "libswakFunctionObjects.so" ); |
|
January 30, 2014, 18:01 |
|
#3 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Greetings Joachim,
I noticed your feature request on the bug tracker: http://www.openfoam.org/mantisbt/view.php?id=1145 Just to let you know that a very similar feature request was asked about back in August 2012: http://www.openfoam.org/mantisbt/view.php?id=641 Best regards, Bruno |
|
January 30, 2014, 18:24 |
|
#4 |
Senior Member
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 22 |
Thank you for the information. Indeed the old bug looks somehow similar to what I would like to do. The final goal is to couple OpenFOAM with an external solver (for 1-d thermohydraulics). For the stability of the coupling it is necessary to exchange information on the boundaries more than once per time step.
|
|
January 31, 2014, 10:21 |
|
#6 |
Senior Member
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 22 |
Thank you for your hint. I would like to avoid the exchange via file system but yes, I was able to run this example and also the "hot room" of the buoyantPimpleFoam tutorials and the data are exchanged after each step of the outer corrector loop within a time step.
|
|
February 1, 2014, 18:33 |
|
#7 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Hi Joachim,
Have a look into this thread: http://www.cfd-online.com/Forums/ope...lue-facei.html - the idea given there is that you can use that tutorial and the associated boundary condition as a basis for your connection between applications. In other words, you would have to copy-paste-modify the source code of the boundary condition to suit your needs. Nonetheless, now I'm looking into the source code for the boundary condition, it does feel that the solution you're using with Python is somewhat easier to implement. Best regards, Bruno |
|
Tags |
functionobjects, pimple, swak4foam |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
What is the Better Way to Do CFD? | John C. Chien | Main CFD Forum | 54 | April 23, 2001 09:10 |
Open source CFD code development, possible? | Dr. Yazid Bindar | Main CFD Forum | 27 | July 18, 2000 01:18 |
State of the art in CFD technology | Juan Carlos GARCIA SALAS | Main CFD Forum | 39 | November 1, 1999 15:34 |
Who's ok for an Open Source CFD project ? | Viet | Main CFD Forum | 16 | July 26, 1999 16:57 |
What kind of Cmmercial CFD code you feel well? | Lans | Main CFD Forum | 13 | October 27, 1998 11:20 |