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

Passing ScalarField from OpenFoam to Fortran

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 16, 2013, 06:12
Default Passing ScalarField from OpenFoam to Fortran
  #1
New Member
 
Ivana
Join Date: Feb 2012
Posts: 16
Rep Power: 14
IvanaS is on a distinguished road
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.
IvanaS is offline   Reply With Quote

Old   April 16, 2013, 06:52
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by IvanaS View Post
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.
How? With caution

Quote:
Originally Posted by IvanaS View Post
Can someone please give me advice on this?
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
gschaider is offline   Reply With Quote

Old   April 17, 2013, 16:38
Default
  #3
Senior Member
 
Paulo Vatavuk
Join Date: Mar 2009
Location: Campinas, Brasil
Posts: 200
Rep Power: 18
vatavuk is on a distinguished road
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
vatavuk is online now   Reply With Quote

Old   April 17, 2013, 18:48
Default
  #4
Senior Member
 
Join Date: Nov 2012
Posts: 171
Rep Power: 14
hz283 is on a distinguished road
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:
Originally Posted by IvanaS View Post
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.
hz283 is offline   Reply With Quote

Old   April 17, 2013, 23:44
Default
  #5
Member
 
Dan Kokron
Join Date: Dec 2012
Posts: 33
Rep Power: 13
dkokron is on a distinguished road
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.
dkokron is offline   Reply With Quote

Old   April 19, 2013, 10:32
Default
  #6
New Member
 
Ivana
Join Date: Feb 2012
Posts: 16
Rep Power: 14
IvanaS is on a distinguished road
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
IvanaS is offline   Reply With Quote

Reply


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
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


All times are GMT -4. The time now is 01:36.