CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   Input data from Fortran into OpenFOAM (http://www.cfd-online.com/Forums/openfoam/103063-input-data-fortran-into-openfoam.html)

rsanders20 June 9, 2012 19:15

Input data from Fortran into OpenFOAM
 
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.

wyldckat June 10, 2012 13:51

Greetings Ryan and welcome to the forum!

Quote:

Originally Posted by rsanders20 (Post 365633)
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...

rsanders20 June 10, 2012 16:41

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.

Chris Lucas June 11, 2012 03:01

Hi,

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

Best Regards,
Christian

wyldckat June 12, 2012 17:36

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


All times are GMT -4. The time now is 19:42.