CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   casename.foam file creation for Paraview (manually) (http://www.cfd-online.com/Forums/openfoam/90926-casename-foam-file-creation-paraview-manually.html)

max_sph July 25, 2011 11:23

casename.foam file creation for Paraview (manually)
 
Hey guys,

Please can anyone help me on a small issue. I am trying to create a single command or maybe a small program that I can run using terminal in a unix based system (mac os in this case, because paraFoam command doesn't quite work properly.)

Ok, so basically, I need to create the casename.foam file via terminal, so that I can open that with Paraview. This is simple enough using "touch casename.foam", then opening that with Paraview, which loads the files 0, 0.1, 0.2 etc etc to be viewed.

So my questions are:
How do I get the working directory into, say, an export command,
eg. export WORKING="pwd" in my .bashrc file... the problem is that I can't get the working directory to export properly to a global variable which I could use in a command to create the casename.foam file without having to type the case directory/name manually.

Secondly, I had a perusal of the Paraview source code, but I'm stuck with another small thing...
Is there an argument I can add (to a command that opens Paraview.app) to load a file automatically in Paraview?

Many thanks in advance :-)

Regards,

Max

joel.lehikoinen July 26, 2011 02:07

Quote:

Originally Posted by max_sph (Post 317401)
Hey guys,

Please can anyone help me on a small issue. I am trying to create a single command or maybe a small program that I can run using terminal in a unix based system (mac os in this case, because paraFoam command doesn't quite work properly.)

Ok, so basically, I need to create the casename.foam file via terminal, so that I can open that with Paraview. This is simple enough using "touch casename.foam", then opening that with Paraview, which loads the files 0, 0.1, 0.2 etc etc to be viewed.

So my questions are:
How do I get the working directory into, say, an export command,
eg. export WORKING="pwd" in my .bashrc file... the problem is that I can't get the working directory to export properly to a global variable which I could use in a command to create the casename.foam file without having to type the case directory/name manually.

Secondly, I had a perusal of the Paraview source code, but I'm stuck with another small thing...
Is there an argument I can add (to a command that opens Paraview.app) to load a file automatically in Paraview?

Many thanks in advance :-)

Regards,

Max

Putting it in your .bashrc file wouldn't work. That file is sourced when you start a new terminal: your global variable would be whatever happens to be the working directory then (probably your home folder). I guess if you really wanted you could create a script that does the trick for you, but you really have to ask yourself how much time would that save vs. how much time you'd need to write the script. By the way, the .OpenFOAM -files don't have to have the same name as the case, although it is of course a good practice.

olesen July 26, 2011 02:23

Quote:

Originally Posted by max_sph (Post 317401)
Hey guys,

Please can anyone help me on a small issue. I am trying to create a single command or maybe a small program that I can run using terminal in a unix based system (mac os in this case, because paraFoam command doesn't quite work properly.)

Ok, so basically, I need to create the casename.foam file via terminal, so that I can open that with Paraview. This is simple enough using "touch casename.foam", then opening that with Paraview, which loads the files 0, 0.1, 0.2 etc etc to be viewed.

So my questions are:
How do I get the working directory into, say, an export command,
eg. export WORKING="pwd" in my .bashrc file... the problem is that I can't get the working directory to export properly to a global variable which I could use in a command to create the casename.foam file without having to type the case directory/name manually.


Although generally I would have thought that the following should always work:
Code:


paraFoam -builtin -touch

you could also try something simple like this:
Code:


touch "${PWD##*/}.foam"


max_sph July 26, 2011 13:06

Thanks guys :-)

I just took a peek inside the paraFoam application that comes with openfoam, and created a .bat file for which there is an alias to, with contents:

caseName=${PWD##*/}
caseFile="$caseName.OpenFOAM"
touch $caseFile

This works good in any directory.

Still unsure how to get the .OpenFOAM file loaded automatically. This is because on my mac os, I required a standalone binary of Paraview, so I have to open this then load up the .OpenFOAM file.
I guess I'll get by with a few extra mouse clicks in the meantime :p

Thanks again :)

wyldckat July 26, 2011 16:31

Greetings to all!

Max_sph, in the last lines of paraFoam you would find the solution you are looking for ;) (at least on OpenFOAM 2.0.0/x):
Code:

paraview --data="case.foam"
Keep in mind that the ".OpenFOAM" extension is for official reader that comes with OpenFOAM. The ".foam" is for the internal reader. Well, that is if you don't have to bother having to select from the list of possible readers in ParaView :)

I haven't yet quite understood what you are trying to do, but you could simply use the already existing paraFoam script to do what you need! At least the one from OpenFOAM 2.0.

Anyway, I suppose that either way, you should now know everything you need for your minimalist script :)

Best regards,
Bruno

max_sph July 28, 2011 11:10

Thanks Bruno :)

I did indeed take a quick peek at paraFoam. On a linux system it will work properly, but on a mac os the paraview application is "Paraview.app"... I'm no expert on this, but perhaps someone can't load ".app" applications with a --data argument.
Anyway, the standalone ParaView.app for Mac works good, it's just I have to load the data in manually! (All those clicks... Laziness has got me you see) :P
Anyway, its only a small issue and doesn't matter too much :)

Thanks for all the support!


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