|
[Sponsors] |
April 16, 2013, 06:12 |
Passing ScalarField from OpenFoam to Fortran
|
#1 |
New Member
Ivana
Join Date: Feb 2012
Posts: 16
Rep Power: 14 |
Hello,
I want to couple Fortran code with OpenFoam. From OpenFoam I want to send velocity field to the Fortran code. I found that I can access the entire field using this scalarField u = U.component(0);. But I don't know how to pass scalarFied or volScalarField from OF to Fortran. Can someone please give me advice on this? Thank you very much. Regards, I. |
|
April 16, 2013, 06:52 |
|
#2 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
The method data() returns a raw C-pointer to the actual array with the items. Together with that and size() you've got enough information to google some recipe "calling Fortran-routines with C-arrays" or so. From then on you're on your own. You have my deepest sympathy for having to use Fortran
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request |
||
April 17, 2013, 16:38 |
|
#3 |
Senior Member
Paulo Vatavuk
Join Date: Mar 2009
Location: Campinas, Brasil
Posts: 200
Rep Power: 18 |
Hi Ivana,
A long time ago I did something like this, but not with OpenFOAM. I was able to transfer information between the programs by writing to and reading from a file. This is not a beautiful solution but it worked. Best Regards, Paulo |
|
April 17, 2013, 18:48 |
|
#4 | |
Senior Member
Join Date: Nov 2012
Posts: 171
Rep Power: 14 |
Hello IvanaS,
When you send the velocity field to fortran code, will this "sending" action be performed by the root processor or all the processors if I want to consider the parallel computations? If yes I think we need to also pass the logical variable ROOT and the rank number to the fortran side. So how can we extract the information about the ROOT and the rank number from OF? Thanks. Quote:
|
||
April 17, 2013, 23:44 |
|
#5 |
Member
Dan Kokron
Join Date: Dec 2012
Posts: 33
Rep Power: 14 |
I haven't used the feature myself, but the newer fortran standards (either 2003 or 2008) include some fortran/C interoperability features that may help you.
|
|
April 19, 2013, 10:32 |
|
#6 |
New Member
Ivana
Join Date: Feb 2012
Posts: 16
Rep Power: 14 |
Hi,
I think I found something, I am checking if it works but it looks promising. This helped: http://www.cfd-online.com/Forums/ope...-openfoam.html I am not up to reading and writing from/to the file because I would need to do it every time step and it could be time consuming.... Regarding parallel computations, I am not there yet but indeed I will have to pass information about that as well. Maybe you should check this: UPstream::myProcNo() and UPstream::nProcs(). I don't know if it helps... Thanks. Ivana |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Input data from Fortran into OpenFOAM | rsanders20 | OpenFOAM | 5 | August 28, 2017 09:58 |
Comparison between C/C++ and Fortran? | rick | Main CFD Forum | 45 | September 6, 2011 01:52 |
OpenFOAM 1.6.x, 1.7.0 and 1.7.x are not fully prepared to work with gcc-4.5.x | wyldckat | OpenFOAM Bugs | 18 | October 21, 2010 06:51 |
Cross-compiling OpenFOAM 1.6 on Linux for Windows 32 and 64bits with Mingw-w64 | wyldckat | OpenFOAM Announcements from Other Sources | 7 | January 19, 2010 16:39 |
Fortran 90 faster than C/C++ | B. R. Guirguis | Main CFD Forum | 48 | March 6, 2006 14:49 |