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

Creating a new case from command line

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 17, 2007, 06:15
Default Hi, is there a command (I d
  #1
New Member
 
Gregoire Hanss
Join Date: Mar 2009
Location: France
Posts: 1
Rep Power: 0
gregh is on a distinguished road
Hi,

is there a command (I don't want to use the FoamX interface) to create automatically the directory tree and files needed for a new clean case (no mesh, I will convert it from a 3rd party soft, no solution, ...) ?

Thanks

Greg
gregh is offline   Reply With Quote

Old   May 19, 2007, 15:46
Default You can duplicate the original
  #2
Member
 
Marco Moscaritolo
Join Date: Mar 2009
Location: Bergamo, Italy
Posts: 33
Rep Power: 17
mavimo is on a distinguished road
You can duplicate the original case with:
cp -r /original/case /new/case
and after delete the mesh with
rm /new/case/constant/polyMesh/*

Bye
Mavimo
mavimo is offline   Reply With Quote

Old   October 8, 2008, 06:13
Default Hi, is there another way to
  #3
Member
 
Michael
Join Date: Mar 2009
Posts: 48
Rep Power: 17
farbfilm is on a distinguished road
Hi,

is there another way to create a new case from command line without copying an old case or tutorial cases???

I'm using OpenFoam1.5 and want to create a new case with a command that creates automatically the directory tree! Is that possible???

Thanks
farbfilm is offline   Reply With Quote

Old   October 8, 2008, 15:24
Default Hi, I have a template direc
  #4
Senior Member
 
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 19
braennstroem is on a distinguished road
Hi,

I have a template directory and use emacs/dired to create a new case with:

(defun opf_standard_0()
(interactive)
(dired-create-directory "0")
(dired "0")
(copy-file "/home/gcae504/SCR1/Software/Vorlagen/0/k" "k")
(copy-file "/home/gcae504/SCR1/Software/Vorlagen/0/omega" "omega")
(copy-file "/home/gcae504/SCR1/Software/Vorlagen/0/epsilon" "epsilon")
(copy-file "/home/gcae504/SCR1/Software/Vorlagen/0/R" "R")
(copy-file "/home/gcae504/SCR1/Software/Vorlagen/0/p" "p")
(copy-file "/home/gcae504/SCR1/Software/Vorlagen/0/U" "U")
(copy-file "/home/gcae504/SCR1/Software/Vorlagen/0/nuTilda" "nuTilda")
...
...
(revert-buffer)
(remember)
)

A simple menu can look like:

(easy-menu-define cfd-pre-menu dired-mode-map
"'org-mode' menu"
'("CFD-Pre"
["FLUENT Journals isotherm/stationaer" fluent_standard_journals_stationaer t]
"---"
["OpenFOAM New Case" opf_standard_simpleFoam t]
["OpenFOAM Decompose " dummy t]
"---"
["OpenFOAM Standard Randbedingungen Erstellen " opf_boundaries t]
))

Or use some other scripts like python:
import os
import sys
os.chdir(os.path.dirname(sys.argv[1]))
os.system("cp -a /home/gcae504/SCR1/Software/Vorlagen/OpenFOAM_Standard . ")


Obviously you need some more templates, if you are using a lot of different solvers.

Fabian
braennstroem is offline   Reply With Quote

Old   October 9, 2008, 03:35
Default If you want the same as Fabian
  #5
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
If you want the same as Fabian, but without emacs, see if "foamCopySettings -help" does what you want.
olesen is offline   Reply With Quote

Old   October 9, 2008, 04:15
Default Hi, foamCopySettings does a
  #6
Senior Member
 
Håkan Nilsson
Join Date: Mar 2009
Location: Gothenburg, Sweden
Posts: 205
Rep Power: 18
hani is on a distinguished road
Hi,

foamCopySettings does a part of the job. Another part of the job is (when the mesh has been created) to modify the boundary conditions in the 0 directory according to a given 'boundary' file in constant/polyMesh. This was previously done by FoamX, and this was in my opinion the only thing that was useful with FoamX. Is there any script or application that does this in 1.5? I haven't found any yet.

Håkan.
hani is offline   Reply With Quote

Old   October 9, 2008, 04:43
Default I never tried FoamX to discove
  #7
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
I never tried FoamX to discover anything useful in it, but adjusting the boundary conditions to match the polyMesh/boundary was always *really* annoying.

With the new dictionary expansion mechanism, however, it becomes much easier. In this case I would prefer to stick to my favourite editor. Here's a small example example-0.tar.gz

Switching one of the inlets on and all the others off is just a matter of setting a link to the appropriate boundaryField-* file. These files are easily generated with a script.
olesen is offline   Reply With Quote

Old   October 9, 2008, 05:33
Default Hi, This actually looks qui
  #8
Senior Member
 
Håkan Nilsson
Join Date: Mar 2009
Location: Gothenburg, Sweden
Posts: 205
Rep Power: 18
hani is on a distinguished road
Hi,

This actually looks quite useful. Thanks!

Actually, FoamX used the physicalType in the boundary file to generate the time directories automatically. It used configuration files supplied in each solver/FoamX directory so that the boundary conditions were set according to that specific solver (Those FoamX directories are removed in 1.5.x). The solver was chosen in the controlDict. I found this quite useful, although I seldom used it. There is a need for a similar application that does the same thing, but without FoamX. I want to be clear that I do not want FoamX back!

I will try out your new approach.

Thanks!
Håkan.
hani is offline   Reply With Quote

Old   October 9, 2008, 07:04
Default Seconded! I hated FoamX, but a
  #9
Senior Member
 
Gavin Tabor
Join Date: Mar 2009
Posts: 181
Rep Power: 17
grtabor is on a distinguished road
Seconded! I hated FoamX, but a convenient automated case generation mechanism would be useful, even if the actual editing has to be done by hand.

Gavin
grtabor is offline   Reply With Quote

Old   October 9, 2008, 08:23
Default PyFoam is another approach. Di
  #10
Senior Member
 
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 19
braennstroem is on a distinguished road
PyFoam is another approach. Different python scripts could do the job in the old fashion:

PipeWandrb.py

Though, one has to be consistent with the naming...


Fabian
braennstroem is offline   Reply With Quote

Old   October 9, 2008, 08:49
Default Hi, for non huge cases I fi
  #11
Member
 
Niklas Wikstrom
Join Date: Mar 2009
Posts: 86
Rep Power: 17
wikstrom is on a distinguished road
Hi,

for non huge cases I find this utility helpful creating new fields:

createFieldTemplates.tgz

It simply creates a mesh, reads which fields to write from command line, creates them with a default BC and writes them to disk.

What about the "new dictionary expansion"? I fail to understand...

/Niklas
wikstrom is offline   Reply With Quote

Old   October 9, 2008, 08:59
Default Now with -compressible availab
  #12
Member
 
Niklas Wikstrom
Join Date: Mar 2009
Posts: 86
Rep Power: 17
wikstrom is on a distinguished road
Now with -compressible available...
createFieldTemplates.tgz
/Niklas
wikstrom is offline   Reply With Quote

Old   October 9, 2008, 10:09
Default Splendid Niklas! A small tu
  #13
Senior Member
 
Håkan Nilsson
Join Date: Mar 2009
Location: Gothenburg, Sweden
Posts: 205
Rep Power: 18
hani is on a distinguished road
Splendid Niklas!

A small tutorial:
The syntax seems to be:
createFieldTemplates -scalarFields "(p k epsilon)" -vectorFields "(U)"

What is missing is some option to use physicalType from the boundary file, or to list all the possible boundary conditions for each patch and variable. I guess that there is some list of possible boundary conditions that can be reached, and printed out...

Example:
If a variable can use boundary conditions zeroGradient, and fixedValue only, then it would be nice if this code would automatically output something like:

boundaryField
{
examplePatch
{
type zeroGradient;
}
// {
// type fixedValue;
// value 0;
// }
}

Then it would be easy to un-comment the appropriate lines that are wanted instead of the default one.

Håkan.
hani is offline   Reply With Quote

Old   October 9, 2008, 10:57
Default Oh, sorry for not including an
  #14
Member
 
Niklas Wikstrom
Join Date: Mar 2009
Posts: 86
Rep Power: 17
wikstrom is on a distinguished road
Oh, sorry for not including an example command line; thanks Håkan.

It would be nice to have such functionality, although perhaps not through "physicalType" since this key seems on it's way out? (and was a tad confusing anyway, imho.)

However, to create templates for all or some possible BC's increases the complexity of the '5 minute code' I uploaded quite much and I have not the time for that at the moment. When I have something, I'll share it.

/niklas
wikstrom is offline   Reply With Quote

Old   October 9, 2008, 16:13
Default Hi! Sorry for advertising (
  #15
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Hi!

Sorry for advertising (I won't quote the full help here):

-----
pyFoamCreateBoundaryPatches.py [options] <fieldfile>

Takes a field-file. Looks up the polyMesh/boundary-file of the case and adds
the corresponding patches to the boundary field setting it to zeroGradient for
all patches and walls
------

The online-help doesn't say that of course patches like symmetryPlane are set to that type in the field file. Together with the --filter and the --default option a lot can be done if there is a consistent naming for the boundaries. Like

pyFoamCreateBoundaryPatches.py --filter="heated.+" --default="{'type':'fixedValue','value':'uniform 800'}" myCase/0/T

to set all patches that start with "heated" to a fixed temperature of 800

Bernhard
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   October 10, 2008, 04:12
Default Bernhard, I think that you sho
  #16
Senior Member
 
Håkan Nilsson
Join Date: Mar 2009
Location: Gothenburg, Sweden
Posts: 205
Rep Power: 18
hani is on a distinguished road
Bernhard, I think that you should really advertise pyFoam more. I suggest that you propose a talk on pyFoam at the fourth workshop. Then there is also a need for a talk on the other developments you have made. It is an impressive amount of work!

I must admit - I did't have the time to use pyFoam yet, but I just opened your Wiki and started to have a look at it.

Håkan.
hani is offline   Reply With Quote

Old   October 10, 2008, 06:09
Default Hi Hakan! Thanks for your k
  #17
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Hi Hakan!

Thanks for your kind words.

BTW: Fabian. I liked your script as an example for the usage of PyFoam. May I just add one remark. The Functionality of the pyFoam-Utilities is implemented as classes in the PyFoam.Applications-hierarchy that simply get a list with the command line arguments. This means that instead of the os.system("pyFoamCreateBoundary ....") you could use CreateBoundaryPatches(args=["--overwrite",case0k]). Also the os.system("cp ...")s might be replaced with a CloneCase-call

Bernhard
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   October 10, 2008, 09:27
Default Hi Bernhard, I have been pl
  #18
Senior Member
 
Håkan Nilsson
Join Date: Mar 2009
Location: Gothenburg, Sweden
Posts: 205
Rep Power: 18
hani is on a distinguished road
Hi Bernhard,

I have been playing for a while :-)

I guess that you might have a hint on how to reduce the number of commands for the example I show below. In the example I want to run the icoFoam/elbow case with simpleFoam. Is there a way to reduce the number of PyFoam commands?

cp -r $FOAM_TUTORIALS/simpleFoam/pitzDaily $FOAM_RUN/simpleElbow
cp -r $FOAM_TUTORIALS/icoFoam/elbow/elbow.msh $FOAM_RUN/simpleElbow
cd $FOAM_RUN/simpleElbow
fluentMeshToFoam elbow.msh

pyFoamCreateBoundaryPatches.py --verbose --clear-unused 0/U
pyFoamCreateBoundaryPatches.py --verbose --overwrite --filter="wall.+" --default="{'type':'fixedValue','value':'uniform (0 0 0)'}" 0/U
pyFoamCreateBoundaryPatches.py --verbose --overwrite --filter="velocity-inlet-5" --default="{'type':'fixedValue','value':'uniform (1 0 0)'}" 0/U
pyFoamCreateBoundaryPatches.py --verbose --overwrite --filter="velocity-inlet-6" --default="{'type':'fixedValue','value':'uniform (0 3 0)'}" 0/U
pyFoamCreateBoundaryPatches.py --verbose --clear-unused 0/p
pyFoamCreateBoundaryPatches.py --verbose --overwrite --clear-unused --filter="pressure.+" --default="{'type':'fixedValue','value':'uniform 0'}" 0/p
pyFoamCreateBoundaryPatches.py --verbose --clear-unused 0/k
pyFoamCreateBoundaryPatches.py --verbose --overwrite --filter="velocity-inlet.+" --default="{'type':'turbulentIntensityKineticEnergyI nlet','intensity':'0.1', 'value':'uniform 0.375'}" 0/k
pyFoamCreateBoundaryPatches.py --verbose --clear-unused 0/epsilon
pyFoamCreateBoundaryPatches.py --verbose --overwrite --filter="velocity-inlet.+" --default="{'type':'turbulentMixingLengthDissipation RateInlet','mixingLength': '0.05', 'value':'uniform 14.855'}" 0/epsilon

pyFoamWriteDictionary.py system/controlDict endTime 300

rm 0/nuTilda
rm 0/R
simpleFoam

Håkan.
Siemen likes this.
hani is offline   Reply With Quote

Old   October 17, 2008, 08:04
Default Hi Hakan! I'm afraid it doe
  #19
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Hi Hakan!

I'm afraid it doesn't work much simpler than that. The only thing I spotted is that for subsequent calls for a field the --clear-unused option can be omitted (but it doesn't hurt either)

Just as a preview: inspired by this thread I'm working on a util that generates a case using a description file. But I'll need two or three more train-rides to complete it ....

Bernhard
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   October 21, 2008, 03:49
Default With all possible respect to
  #20
Member
 
Niklas Wikstrom
Join Date: Mar 2009
Posts: 86
Rep Power: 17
wikstrom is on a distinguished road
With all possible respect to Python and pyFoam - I love python- I still want to expand the functionality of the createFieldTemplates app above.

I am trying to write a changeDictionaryDict from field and boundaryMesh information. However, I'm lost among dictionaries and entries. Anyone with an example code creating and writing a dictinoary? I allmost got there using IOdictionary, but IOdictionary::writeData does not produce andy line breaks.

The idea is that if all fields are created with default patches along with a corresponding changeDictionaryDict, it's only a matter of editing the dict and run changeDictionary. I'd like that.

/N
wikstrom is offline   Reply With Quote

Reply


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
restart a case with .trn file in command line way? wayne CFX 0 October 10, 2008 10:02
Command line help Omer CFX 0 August 29, 2008 08:44
Cloning a case or creating a new case for 16 processes mellanoxuser OpenFOAM Running, Solving & CFD 0 February 8, 2008 17:52
Backup from the command line Rui CFX 6 February 22, 2005 11:19
Cloning a case from the command line Daniele Panara (Panara) OpenFOAM Pre-Processing 2 February 1, 2005 10:58


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