Better bounding on topo change
[foam-extend-3.2.git] / bin / foamUpgradeTurbulenceProperties
blob796c5ab49043fa41363a4c87e972f2503e74cfa5
1 #!/bin/sh
2 #------------------------------------------------------------------------------
3 # ========= |
4 # \\ / F ield | foam-extend: Open Source CFD
5 # \\ / O peration |
6 # \\ / A nd | For copyright notice see file Copyright
7 # \\/ M anipulation |
8 #------------------------------------------------------------------------------
9 # License
10 # This file is part of foam-extend.
12 # foam-extend is free software: you can redistribute it and/or modify it
13 # under the terms of the GNU General Public License as published by the
14 # Free Software Foundation, either version 3 of the License, or (at your
15 # option) any later version.
17 # foam-extend is distributed in the hope that it will be useful, but
18 # WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 # General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
25 # Script
26 # foamUpgradeTurbulenceProperties
28 # Description
29 # Upgrade the turbulenceProperties dictionary to the new format employed
30 # in OpenFOAM version 1.5-dev
31 # - RAS turbulence models now defined by the RASProperties dictionary,
32 # and RASModel keyword.
33 # - LES turbulence models now defined by the LESProperties dictionary,
34 # and LESModel keyword.
36 #------------------------------------------------------------------------------
38 usage() {
39 cat<<USAGE
41 usage: ${0##*/} <turbulenceProperties>
43 Where <turbulenceProperties> is the full path to the
44 turbulenceProperties dictionary
46 Note: can upgrade several files at once
48 USAGE
49 exit 1
53 # $1: turbulence model
54 # $2: new properties type
55 # $3: original dictionary
57 convertDict()
59 echo "Identified $1 turbulence model in '$3'"
60 outputPath=`dirname $3`
62 if [ -e "$outputPath/$1Properties" ]
63 then
64 echo "Error: file already exists $outputPath/$1Properties'" 1>&2
65 else
66 sed -e "s/turbulenceProperties/$1Properties/" \
67 -e "s/$2/$1Model/" \
68 -e "s/[a-zA-Z0-9]* [ ]*\[[0-9 ]*\]//" \
69 $3 > "$outputPath/$1Properties"
71 echo " wrote $outputPath/$1Properties"
75 [ $# -ge 1 ] || usage
77 for turbDict
79 # Identify type of turbulence model and convert
80 if [ -f $turbDict ]
81 then
82 if grep turbulenceModel $turbDict >/dev/null 2>&1
83 then
84 convertDict RAS turbulenceModel $turbDict
85 elif grep LESmodel $turbDict >/dev/null 2>&1
86 then
87 convertDict LES LESmodel $turbDict
88 else
89 echo "Unable to determine turbulence model type in '$turbDict'" 1>&2
90 echo " - nothing changed" 1>&2
92 else
93 echo "Error: file '$turbDict' does not exist" 1>&2
95 done
97 #------------------------------------------------------------------------------