Call external code (functionObject execute() like) within pimple.loop()
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 |
I found a way to do this: Add the following code to (within) the pimple.loop():
Code:
functionObjectList& fol = runTime.functionObjects(); Add the following to your controlDict and the executeCode is called during each step of your pimple.loop: Code:
functions { |
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 |
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.
|
Have you checked the tutorial "./heatTransfer/buoyantSimpleFoam/externalCoupledCavity" in OpenFOAM 2.2, to see if it would work for you?
|
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.
Quote:
|
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 |
All times are GMT -4. The time now is 19:24. |