CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Create an script for a Local Application of OpenFOAM (https://www.cfd-online.com/Forums/openfoam-programming-development/125947-create-script-local-application-openfoam.html)

RTom November 5, 2013 00:11

Create an script for a Local Application of OpenFOAM
 
Dear All,
I'm looking for how to create an script (OpenFOAM 2.2.2 local application) which can run the following applications:
blockMesh
simpleFoam
paraFoam

My goal is to create an script for any solver so I can use it in CAESES software for the case directory. CAESES just executes the executable files.

Also I was wondering if is possible to make an srcipt which can run the "blockMesh", the solver (any solver) and generate or transform the results in VTK format or FLUENT format or .foam format

Any help is wellcome. Thanks!

Bernhard November 5, 2013 04:17

Yes, this is easy

Call your script "run"
Code:

#!/bin/bash
blockMesh
$1
foamToVTK
paraFoam

Which you can run with "run simpleFoam"

Is this what you need?

BenZ November 7, 2013 10:54

1 Attachment(s)
Hi Tom,

Actually you can combine different Software Connectors in CAESES to set up such a chain of tools. If you do so you wouldn't need a script.

Create a Software Connector for each tool.
Add a result file in the first Software Connector. The result file is here the output of the application, e.g. a produced mesh file.
Then add an input file for this very same file in the Software Connector of the next application in line.
Now you have to replace the file name of the input file with the following command:
computationName.getResults().getResultFileName("nameOfTheInputFile")
-> see attached image

So, what you basically do is setting the output file of the first application as input for the second application.

I guess that is what you are trying to achieve?

Cheers
Ben

naval November 11, 2013 06:36

Hi RTom,

there are two nice ways of doing this:

a) a script which takes the solver as an argument (or you may use the getapplication command to extract that information from the control.dict). Use the one Bernhard gave you (except for parafoam, much of the post-processing can also be done in CAESES)

b) the way I prefer: a script that executes one of your CAESES template files, i.e. a file named Allrun. Pretty much the way it is done in the CAESES sample for the ahmed body.
Solver and specific settings can be managed from within CAESES, the executable runOpenFOAM.sh basically just runs this script.
This is not completely ready for any case, but since you can make all the changes within CAESES, it's quite efficient.

runOpenFOAM.sh
Code:

#!/bin/bash
chmod +x Allrun
./Allrun

The template file within CAESES (Allrun):
Code:

#!/bin/bash
touch case.foam
blockmesh
simpleFoam
foamToVTK

Of course you can use the solver as an argument somewhere in the process chain.


Cheers,
naval

edit:
To clarify this: runOpenFOAM can be used for any case, this should be the executable for your Local Application for all OpenFOAM projects. Only Allrun should be unique for every case. With this method you can also easily open and run the OF tutorials, since they use such an Allrun file.


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