BUG: PointEdgeWave : n cyclics bool instead of label
[OpenFOAM-1.6.x.git] / bin / foamUpdateCaseFileHeader
blob4fbfa20dbbb2307cbd94a348f8ddea5cb00f5109
1 #!/bin/sh
2 #------------------------------------------------------------------------------
3 # ========= |
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / O peration |
6 # \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
7 # \\/ M anipulation |
8 #------------------------------------------------------------------------------
9 # License
10 # This file is part of OpenFOAM.
12 # OpenFOAM 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 2 of the License, or (at your
15 # option) any later version.
17 # OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
18 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 # for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with OpenFOAM; if not, write to the Free Software Foundation,
24 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 # Script
27 # foamUpdateCaseFileHeader
29 # Description
30 # Updates the header of application files.
31 # By default, writes current version in the header.
32 # Alternatively version can be specified with -v option.
33 # Also removes consecutive blank lines from file.
35 #------------------------------------------------------------------------------
36 foamVersion=$WM_PROJECT_VERSION
38 usage() {
39 cat<<USAGE
41 Usage: ${0##*/} [OPTION] <file1> ... <fileN>
43 options:
44 -v VER specifies the version to be written in the header
45 -h help
47 Updates the header of application files and removes consecutive blank lines.
48 By default, writes current OpenFOAM version in the header.
49 An alternative version can be specified with the -v option.
51 USAGE
52 exit 1
56 printHeader() {
57 cat<<HEADER
58 /*--------------------------------*- C++ -*----------------------------------*\\
59 | ========= | |
60 | \\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
61 | \\\\ / O peration | Version: ${foamVersion} |
62 | \\\\ / A nd | Web: www.OpenFOAM.org |
63 | \\\\/ M anipulation | |
64 \\*---------------------------------------------------------------------------*/
65 FoamFile
67 version 2.0;
68 format ${1};
69 class ${2};
70 object ${3};
72 HEADER
77 # extract attribute '$1' from file '$2'
79 FoamFileAttribute() {
80 sed -n -e 's/[ ;]*$//' -e "s/^ *$1 *//p" $2
85 # OPTIONS
87 opts=$(getopt hv: $*)
88 if [ $? -ne 0 ]
89 then
90 echo "Aborting due to invalid option"
91 usage
93 eval set -- '$opts'
94 while [ "$1" != "--" ]
96 case $1 in
97 -v)
98 foamVersion=$2
99 shift
102 usage
104 esac
105 shift
106 done
107 shift
109 [ $# -ge 1 ] || usage
112 # constant width for version
113 foamVersion=$(printf %-36s $foamVersion)
116 # MAIN
118 unset NOTE
120 for caseFile
122 if grep FoamFile $caseFile >/dev/null 2>&1
123 then
124 echo "Updating case file: $caseFile"
125 sed -n '/FoamFile/,/}/p' $caseFile > FoamFile.tmp
127 FORMAT=$(FoamFileAttribute format FoamFile.tmp)
128 CLASS=$(FoamFileAttribute class FoamFile.tmp)
129 OBJECT=$(FoamFileAttribute object FoamFile.tmp)
130 # extract NOTE?
132 printHeader $FORMAT $CLASS $OBJECT $NOTE > FoamFile.tmp
133 sed '1,/}/d' $caseFile | sed '/./,/^$/!d' >> FoamFile.tmp
135 # use cat to avoid removing/replace soft-links
136 [ -s FoamFile.tmp ] && cat FoamFile.tmp >| $caseFile
137 rm -f FoamFile.tmp 2>/dev/null
138 else
139 echo " Invalid case file: $caseFile" 1>&2
141 done
143 #------------------------------------------------------------------------------