CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   Accessing OpenFOAM shared memory (https://www.cfd-online.com/Forums/openfoam/173323-accessing-openfoam-shared-memory.html)

jbcourt June 17, 2016 05:42

Accessing OpenFOAM shared memory
 
I'm working to develop a two-way co-simulation between OF and another program, and I think that I've identified the use of shared memory as the best (most economical) means of communication between the two at run time. The other program simulates a system (with losses) that takes force and position output from the OF simulation and applies a user-identified control strategy to establish the resistance that the external system applies to any motion - this is then fed back to OF for the next time step. EDIT: The OF simulation is a numerical wave tank, with motion being calculated from wave-structure interaction.

What I wanted to ask is what would be the best way of implementing this from the OpenFOAM side? Should I be looking to customise a solver to include interaction with the external model; using the shared memory to provide information on the OF simulation to the external program and then using the output of that to update the OF simulation parameters (it would be a restraint in dynamicMeshDict that it would edit at each time step); or something else?

I've already managed to get a non-continuous version of this working, at least in principle, by using OF's system.call run-time function object to trigger execution of the external model - reading the necessary OF run-time postProcessing output - with a duration of the time step length and then using the output to write a restraint for #include-ing in dynamicMeshDict, but there are transient effects in the external model that are left unaccounted for between time steps by this approach.

This is my first post on here, so sorry if it's at all vague or confusing. I should point out that I'm still learning cpp and am relatively new to OF, so it could well be the case that there's something obvious that I'm missing.
Thanks in advance for your advice!

gkarlsen June 19, 2016 03:51

There is new functionality for co-simulation in OpenFoam 3.0. It sounds like that would be suitable for your case?

http://openfoam.com/version-v3.0+/so...-co-simulation

Unfortunately, I have never used it myself... but maybe you will find some usefull pointers in the tutorial they refer to?

jbcourt June 20, 2016 05:43

Thanks Geir, I've had a bit of a look at the externalCoupled boundary condition mentioned on that link: it seems to me that it would work well for passing temperatures at a boundary/patch (as done in the tutorial that is used there). Similarly that would work well if I wanted the other model to take, as an input, the pressure or a velocity component at a patch. However, I'm looking to use the force on a body within the simulation as the information transferred between the two - since OF already calculates the force on that body due to the pressure difference between two patches I'm loath to get my external model to replicate that postprocessing itself.

That being said, one very good thing that I've noticed about the externalCoupled BC is that it gets OF to write a lock file while it's calculating, so I could use that functionality to make the other model wait for OF to finish doing its bit before running. That would at least allow me to get a form of synchronised interaction going, with the other application reading the forces.dat postprocessing file that OF produces to sort out the input that it needs.
Thanks again for your suggestion.


All times are GMT -4. The time now is 22:53.