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

Input data from Fortran into OpenFOAM

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 9, 2012, 19:15
Default Input data from Fortran into OpenFOAM
  #1
New Member
 
Ryan Sanders
Join Date: Jun 2012
Posts: 2
Rep Power: 0
rsanders20 is on a distinguished road
Hey,

I have an initial turbulence condition that I generated in FORTRAN, and I want to make it the initial condition for a run of boxTurb16. I have already made sure that the mesh in Fortran and the mesh in OpenFoam are the same, but I can't figure out how to get OpenFoam to read the Fortran binary, and replace the initial conditions in /0/u and /0/p. Does OpenFoam have a built in function to read data from Fortran?

Thank you for your time.
rsanders20 is offline   Reply With Quote

Old   June 10, 2012, 13:51
Default
  #2
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,980
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings Ryan and welcome to the forum!

Quote:
Originally Posted by rsanders20 View Post
Hey,

I have an initial turbulence condition that I generated in FORTRAN, and I want to make it the initial condition for a run of boxTurb16. I have already made sure that the mesh in Fortran and the mesh in OpenFoam are the same, but I can't figure out how to get OpenFoam to read the Fortran binary, and replace the initial conditions in /0/u and /0/p. Does OpenFoam have a built in function to read data from Fortran?

Thank you for your time.
Your description is a bit vague... so here are a few questions:
  1. What exactly are you trying to accomplish by using OpenFOAM to "read the Fortran binary"?
  2. And what's the level of initial condition you're trying to set? More specifically, is it just for the boundary walls and patches or for the internal field as well?
Best regards,
Bruno

PS: I renamed the title of this thread, since MATLAB isn't anywhere mentioned on the first post...
__________________
wyldckat is offline   Reply With Quote

Old   June 10, 2012, 16:41
Default
  #3
New Member
 
Ryan Sanders
Join Date: Jun 2012
Posts: 2
Rep Power: 0
rsanders20 is on a distinguished road
Answering your questions in order:

1) The reason I need to input data taken from a FORTRAN program into OpenFOAM is because I have a program in FORTRAN that models in-compressible turbulent flow using large eddy simulation, and i want to test it against a DNS to make sure that it is working correctly. I did not originally write this code, but whoever did built it so that it reads a FORTRAN binary file in order to set the initial conditions.

2) I already set the boundary conditions to be the same, I need now to input the data taken from FORTRAN into the files found at ~/0/u and ~/0/p, where currently a different turbulent initial condition is specified.

Thank you for your quick reply, and for renaming the thread.

Ryan.
rsanders20 is offline   Reply With Quote

Old   June 11, 2012, 03:01
Default
  #4
Senior Member
 
Christian Lucas
Join Date: Aug 2009
Location: Braunschweig, Germany
Posts: 202
Rep Power: 18
Chris Lucas is on a distinguished road
Hi,

you can compile the FORTRAN code as a dynamic library and link this library into your OpenFOAM solver

Best Regards,
Christian
Chris Lucas is offline   Reply With Quote

Old   June 12, 2012, 17:36
Default
  #5
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,980
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings to all!

Ryan: This is a bit ambiguous at first, so here's an attempt at making it more explicit - correct me if I'm wrong:
  1. You have a FORTRAN application that generates the initial turbulence data.
  2. The same FORTRAN application then writes this data into a binary file.
  3. Then another or the same FORTRAN application can read the data back from the binary file.
  4. You want to convert/import/export this data to OpenFOAM formatted data, more specifically put the respective data to the U and p fields, saving those fields in their respective files.
Like Chris wrote, and if this is the case, you can build FORTRAN code as a library, then link the library to a customized OpenFOAM utility for loading the data from your binary file. Basically the OpenFOAM based utility would call a function or group of functions coded in FORTRAN, to do the tasks at hand.

The other possibility is to write the customized OpenFOAM utility to directly load the data from the binary file onto the OpenFOAM formatted fields in memory and then save them to their files.

Either way, I vaguely remember an application that might partially fit the description - fluentDataToFoam: http://openfoam-extend.git.sourcefor...ToFoam;hb=HEAD

For more, you can try using the search function on this forum and search for what people have been able to do with FORTRAN and OpenFOAM

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   August 28, 2017, 08:58
Default
  #6
New Member
 
Kun Zheng
Join Date: May 2017
Location: Harbin, China
Posts: 20
Rep Power: 9
Kun_zheng is on a distinguished road
Hi Bruno,

I am new in OpenFOAM, now I use the OpenFOAM-3.0.

Could you explain how to link the dynamic lib into OpenFOAM, Is there any example ?
Is it possible to call subroutines of Fortran code in OpenFOAM ?

Thank you for your time !

Kun
Kun_zheng is offline   Reply With Quote

Reply

Tags
boxturb16, data, fortran, initial condition, openfoam

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
how to convert Openfoam data to fluent .cas and .msh files sachinlb FLUENT 4 December 8, 2023 16:27
Coupling OpenFoam with Fortran codes anfho OpenFOAM Programming & Development 3 October 29, 2015 14:21
Comparison between C/C++ and Fortran? rick Main CFD Forum 45 September 6, 2011 00:52
Velocity vector data in OpenFOAM and ParaView mismatch tekky OpenFOAM 9 December 21, 2009 11:26
input vertex data file format Rick FLUENT 3 March 6, 2006 02:39


All times are GMT -4. The time now is 12:38.