|
[Sponsors] |
April 17, 2007, 06:15 |
Hi,
is there a command (I d
|
#1 |
New Member
Gregoire Hanss
Join Date: Mar 2009
Location: France
Posts: 1
Rep Power: 0 |
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 |
|
May 19, 2007, 15:46 |
You can duplicate the original
|
#2 |
Member
Marco Moscaritolo
Join Date: Mar 2009
Location: Bergamo, Italy
Posts: 33
Rep Power: 17 |
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 |
|
October 8, 2008, 06:13 |
Hi,
is there another way to
|
#3 |
Member
Michael
Join Date: Mar 2009
Posts: 48
Rep Power: 17 |
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 |
|
October 8, 2008, 15:24 |
Hi,
I have a template direc
|
#4 |
Senior Member
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 19 |
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 |
|
October 9, 2008, 03:35 |
If you want the same as Fabian
|
#5 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40 |
If you want the same as Fabian, but without emacs, see if "foamCopySettings -help" does what you want.
|
|
October 9, 2008, 04:15 |
Hi,
foamCopySettings does a
|
#6 |
Senior Member
Håkan Nilsson
Join Date: Mar 2009
Location: Gothenburg, Sweden
Posts: 205
Rep Power: 18 |
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. |
|
October 9, 2008, 04:43 |
I never tried FoamX to discove
|
#7 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40 |
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. |
|
October 9, 2008, 05:33 |
Hi,
This actually looks qui
|
#8 |
Senior Member
Håkan Nilsson
Join Date: Mar 2009
Location: Gothenburg, Sweden
Posts: 205
Rep Power: 18 |
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. |
|
October 9, 2008, 07:04 |
Seconded! I hated FoamX, but a
|
#9 |
Senior Member
Gavin Tabor
Join Date: Mar 2009
Posts: 181
Rep Power: 17 |
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 |
|
October 9, 2008, 08:23 |
PyFoam is another approach. Di
|
#10 |
Senior Member
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 19 |
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 |
|
October 9, 2008, 08:49 |
Hi,
for non huge cases I fi
|
#11 |
Member
Niklas Wikstrom
Join Date: Mar 2009
Posts: 86
Rep Power: 17 |
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 |
|
October 9, 2008, 08:59 |
Now with -compressible availab
|
#12 |
Member
Niklas Wikstrom
Join Date: Mar 2009
Posts: 86
Rep Power: 17 |
||
October 9, 2008, 10:09 |
Splendid Niklas!
A small tu
|
#13 |
Senior Member
Håkan Nilsson
Join Date: Mar 2009
Location: Gothenburg, Sweden
Posts: 205
Rep Power: 18 |
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. |
|
October 9, 2008, 10:57 |
Oh, sorry for not including an
|
#14 |
Member
Niklas Wikstrom
Join Date: Mar 2009
Posts: 86
Rep Power: 17 |
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 |
|
October 9, 2008, 16:13 |
Hi!
Sorry for advertising (
|
#15 |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
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 |
|
October 10, 2008, 04:12 |
Bernhard, I think that you sho
|
#16 |
Senior Member
Håkan Nilsson
Join Date: Mar 2009
Location: Gothenburg, Sweden
Posts: 205
Rep Power: 18 |
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. |
|
October 10, 2008, 06:09 |
Hi Hakan!
Thanks for your k
|
#17 |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
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 |
|
October 10, 2008, 09:27 |
Hi Bernhard,
I have been pl
|
#18 |
Senior Member
Håkan Nilsson
Join Date: Mar 2009
Location: Gothenburg, Sweden
Posts: 205
Rep Power: 18 |
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. |
|
October 17, 2008, 08:04 |
Hi Hakan!
I'm afraid it doe
|
#19 |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
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 |
|
October 21, 2008, 03:49 |
With all possible respect to
|
#20 |
Member
Niklas Wikstrom
Join Date: Mar 2009
Posts: 86
Rep Power: 17 |
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 |
|
|
|
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 |