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

Call OpenFOAM with input files as arguments

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 30, 2022, 05:57
Default Call OpenFOAM with input files as arguments
  #1
New Member
 
Jesus
Join Date: Sep 2021
Posts: 11
Rep Power: 5
jgs55 is on a distinguished road
Dear Foamers,

I would like to modify the Input/Output of OpenFOAM to be able to pass the required inputs as arguments and receive the corresponding outputs as a return of my call.

I would have my input files (constant, system, 0) saved as RAM variables, and I would save the output files (0+dt) also as RAM variables, instead of saving all these data files as hard disk variables.

I need to do so, because my algorithm requires executing a lot of small cases, and it spends the major part of the time reading/writing data files in the hard disk.

Could anyone give me some guidelines/examples/information of how to implement this modification? Thank you in advance!
jgs55 is offline   Reply With Quote

Old   December 8, 2022, 11:34
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by jgs55 View Post
Dear Foamers,

I would like to modify the Input/Output of OpenFOAM to be able to pass the required inputs as arguments and receive the corresponding outputs as a return of my call.

I would have my input files (constant, system, 0) saved as RAM variables, and I would save the output files (0+dt) also as RAM variables, instead of saving all these data files as hard disk variables.

I need to do so, because my algorithm requires executing a lot of small cases, and it spends the major part of the time reading/writing data files in the hard disk.

Could anyone give me some guidelines/examples/information of how to implement this modification? Thank you in advance!

I don't see how you would want this to work (ie, how variables are to be persistent in memory between different applications).
The closest I can think of is a RAM-disk, there are probably various FUSE implementations.
olesen is offline   Reply With Quote

Old   December 9, 2022, 07:08
Default
  #3
New Member
 
Jesus
Join Date: Sep 2021
Posts: 11
Rep Power: 5
jgs55 is on a distinguished road
Quote:
Originally Posted by olesen View Post
I don't see how you would want this to work (ie, how variables are to be persistent in memory between different applications).
The closest I can think of is a RAM-disk, there are probably various FUSE implementations.
Thank you for your reply Mr Olsen. Due to my application, I just need a particular solver (pimpleFoam) running a single time step on each call. So my idea is to modify pimpleFoam.C in order to accept as argument the input files (already done). Then, I need to modify where the variables are read from. For example, in the case of controlDict, I need to change from runTime.system to the variable where I saved the input argument. Summarizing, I would like to have an expresión like this:

Code:
p,U,omega,nut,k = pimpleFoam controlDict fvSchemes fvSolution p U omega nut k transportProperties turbulenceProperties polyMesh
jgs55 is offline   Reply With Quote

Old   December 11, 2022, 09:49
Default
  #4
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by jgs55 View Post
Thank you for your reply Mr Olsen. Due to my application, I just need a particular solver (pimpleFoam) running a single time step on each call. So my idea is to modify pimpleFoam.C in order to accept as argument the input files (already done). Then, I need to modify where the variables are read from. For example, in the case of controlDict, I need to change from runTime.system to the variable where I saved the input argument. Summarizing, I would like to have an expresión like this:

Code:
p,U,omega,nut,k = pimpleFoam controlDict fvSchemes fvSolution p U omega nut k transportProperties turbulenceProperties polyMesh

Even if I don't really understand how you expect things to hang around in memory, but still exit and restart an application each time. It simply does not fit together unless you are using some other mechanism (eg, a RAM disk) to handle the memory persistence for you.


Having said that, it actually sounds like you have something more like an infinite loop of the pimpleFoam solver, with some modification of fields (on disk or in memory) between each loop. The normal description for that would be some time of a functionObject. There are plenty of ones already available but you'll have to code up your own. The external file coupling function object might be a reasonable place for you to start looking. It has a simple semaphore type of state tracking.
olesen is offline   Reply With Quote

Reply

Tags
input output, openfoam, ram variables


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
Any experts on FFTW? jinhua2015 Main CFD Forum 3 May 22, 2022 20:44
Map of the OpenFOAM Forum - Understanding where to post your questions! wyldckat OpenFOAM 10 September 2, 2021 06:29
Compiling User Fortran with CFX 14.0 on Win64 Raijin Thunderkeg CFX 29 March 9, 2016 12:45
OpenFOAM Training, London, Chicago, Munich, Sep-Oct 2015 cfd.direct OpenFOAM Announcements from Other Sources 2 August 31, 2015 14:36
File format - binary? (plot3d) Joachim Main CFD Forum 15 January 14, 2015 19:21


All times are GMT -4. The time now is 09:47.