Possibility of coupling OpenFOAM + Python Solver without meshes and no requirement for mapping

Hi all,

I would like to know the possibility of coupling OpenFOAM with a Python based solver, where the coupled data (data to be transferred between the participants) is not defined on a mesh and hence there is no requirement for mapping. Stated briefly, I would like to communicate a few variables (around 6 - 8) between OpenFOAM and my python based solver and would like to know how to go about doing this.

I have my own solver in OpenFOAM that solves for the lubricant flow in journal bearings and the like. I have another solver that solves for the rotordynamics of a rotating shaft based on shaft-line modeling through finite elements. The bearing is modelled as located at a single node on the shaft. From the OpenFOAM solver, I required to extract the forces that act on the shaft in the x, y and z directions (these three forces are calculated from an integral over the entire pressure field of the lubricant flow). The OpenFOAM solver send these three forces to the python solver to alter the dynamics of the rotating shaft. From the rotordynamics solver, I require to extract the displacements (x,y,z and angular displacements) of the particular node on which the bearing is located and send it to the OpenFOAM solver. The OpenFOAM solver then uses this data to set a few of its fields.

As it can be seen, none of the data that requires to be communicated between the participants depend on a mesh, and hence none of the data needs to be mapped from one mesh onto another. As far as I can tell, I require to develop my own module within the openfoam-adapter (which I have partly done), and well as find a means to communicate a few variables without having preCICE mapping it or requiring to extract mesh-ID’s etc.

How might I go about doing this? Is there a simple approach already present within preCICE to do this, as it seems much simpler than having to map data between meshes? A rather dull coupling in comparison really.

The only workaround I could think of is to write my own mapping within the preCICE source code that doesn’t do any mapping, and just passes the data along. I could use a patch from OpenFOAM side to serve as this “dummy” mesh and define arbitrary coordinates to serve as a mesh on the side of my python solver. Is that sensible?

P.S. Forgive my ignorance, what kind of a coupling is this? Is it loosely coupled, tightly/strongly coupled, etc.?

Hi @Erin,

this sounds like an interesting case. In order to solve your issue, I see two options:

  1. Considering that you only want to transfer a single vector-valued variable, you can just define a single point on each mesh, say (0,0,0), and afterwards use a nearest-neighbor mapping in preCICE in order to handle the dummy mapping. The nearest-neighbor mapping will simply assign the (only) received vertex to the (only) available vertex, so that nothing is really happening in between.

  2. You can use direct mesh access in order to let preCICE send the data without any mapping. This would still require you to define some dummy mesh.

I think the first option is easy to implement yourself in the openfoam-adapter as it is more common. You simply have a buffer of size 1 taking care of this single value you want to couple.

This depends on your configuration: implicit coupling is more of a strongly coupled case, explicit coupling (which can be configured as well) refers to a loosely coupled setup.

Best regards
David

David,

Thank you very much for you response. Direct access to mesh seems like what I was and am looking for. Both the options that you mention seem viable and shall try whichever seems to take the least effort to implement after giving direct mesh access a detailed read through.

I shall update this thread with my attempts and hopefully with a final solution methodology to go about doing it.

Have a good one,
Erin

Related issue:

Hello @Erin
Did you continue working on this issue? I am in a similar situation, where I want to transfer data from a custom solver to OpenFOAM. The data will be acceleration data (aX, aY, aZ, omegaX, omegaY, omegaZ). Did you specify multiple exchange values? To me it seems like precice can only do scalars or 2d/3d vectors, right?