intersection with triangle plane for miss
[OpenFOAM-1.5.x.git] / bin / foamUpdateCaseFileHeader
blob6b7aa8439ff85426d5aa82012978712ee8b0583e
1 #!/bin/sh
2 #------------------------------------------------------------------------------
3 # ========= |
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / O peration |
6 # \\ / A nd | Copyright (C) 1991-2008 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 "<version>" specifies the version to be written in the header
45 -h help
47 Updates the header of application files.
48 By default, writes current version in the header.
49 Alternatively version can be specified with -v option.
50 Also removes consecutive blank lines from file.
52 USAGE
53 exit 1
57 printHeader() {
58 cat<<HEADER
59 /*--------------------------------*- C++ -*----------------------------------*\\
60 | ========= | |
61 | \\\\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
62 | \\\\ / O peration | Version: ${foamVersion} |
63 | \\\\ / A nd | Web: http://www.OpenFOAM.org |
64 | \\\\/ M anipulation | |
65 \\*---------------------------------------------------------------------------*/
66 FoamFile
68 version 2.0;
69 format ${1};
70 class ${2};
71 object ${3};
73 HEADER
78 # extract attribute '$1' from file '$2'
80 FoamFileAttribute() {
81 sed -n -e 's/[ ;]*$//' -e "s/^ *$1 *//p" $2
86 # OPTIONS
88 OPTS=`getopt hv: $*`
89 if [ $? -ne 0 ]
90 then
91 echo "Aborting due to invalid option"
92 usage
94 eval set -- '$OPTS'
95 while [ "$1" != "--" ]
97 case $1 in
98 -v)
99 foamVersion=$2
100 shift
103 usage
105 esac
106 shift
107 done
108 shift
110 [ $# -ge 1 ] || usage
113 # constant width for version
114 foamVersion=`printf %-36s $foamVersion`
117 # MAIN
119 for caseFile
121 if grep FoamFile $caseFile >/dev/null 2>&1
122 then
123 echo "Updating case file: $caseFile"
124 sed -n '/FoamFile/,/}/p' $caseFile > FoamFile
126 CLASS=`FoamFileAttribute class FoamFile`
127 OBJECT=`FoamFileAttribute object FoamFile`
128 FORMAT=`FoamFileAttribute format FoamFile`
130 printHeader $FORMAT $CLASS $OBJECT $NOTE > FoamFile.tmp
131 sed '1,/}/d' $caseFile | sed '/./,/^$/!d' >> FoamFile.tmp
133 mv FoamFile.tmp $caseFile
134 rm FoamFile
135 else
136 echo " Invalid case file: $caseFile"
138 done
140 #------------------------------------------------------------------------------