CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Coupling to external code using MPI calls from within a solver

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 31, 2017, 11:50
Default Coupling to external code using MPI calls from within a solver
  #1
New Member
 
Regis
Join Date: Jan 2012
Posts: 24
Rep Power: 14
Regis_ is on a distinguished road
Hi everyone. I'm trying to couple OpenFOAM to an external code but I'm having trouble where exactly to start. My main issue is how to make MPI calls from within a solver

So here's what I'm trying to achieve:
1. An external code will request velocities at certain positions and send forces to be added to the momentum equations (at slightly different positions, also passed to OpenFOAM)
2. OpenFOAM would add the forces to the flowfield and get the velocities requested and send back.
3. Loop. The external code gets the velocities, does its thing, and return external forces to be added and array of new locations of the velocities needed.

So ideally I need this to occur at every timestep, say, after we have runTime.write() within a solver. I do have the source code of the external application but can't modify substantially. The exchange of information needs to be done by means of MPI function calls, like mpi_send() and mpi_recv().

I've been looking into the UPstream class which directly includes mpi.h and have known functions (to me) like MPI_Comm_rank. I was also able to play around how the master process communicates with its slave, but all within a decomposed case. I'm interested in learning the syntax I need to use the 'call' and 'receive' MPI functions because these need to be "connected" to the external code. I would also need to implement the "handshake" between both codes, and I'm not sure if this should be done within the solver (before the main loop) or somewhere else.

I've been looking around and going through the code but I'm still stuck. If anyone have any tips or anything, I'd love to hear. I'm also interested in the big picture of how to make such coupling work, if my approach is not a good one.
Regis_ is offline   Reply With Quote

Reply

Tags
coupling, external application, mpi


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compilation error for OpenFoam FSI solver with third party FEA code danny261083 OpenFOAM Running, Solving & CFD 1 October 6, 2017 10:50
CGNS Compiling Diego Main CFD Forum 17 December 21, 2014 02:40
Coupling code aster with openfoam som87 OpenFOAM Running, Solving & CFD 0 December 11, 2012 10:58
OpenFOAM MPI coupling Ford Prefect OpenFOAM Programming & Development 3 August 25, 2010 04:18
Is Testsuite on the way or not lakeat OpenFOAM Installation 6 April 28, 2008 12:12


All times are GMT -4. The time now is 13:24.