ENH: PatchEdgeFaceWave: new wave method
[OpenFOAM-2.0.x.git] / etc / codeTemplates / source / foamNewSource
blob0a9c1b91af0f8cb0ee44b1d1a31625629980ccbf
1 #!/bin/sh
2 #------------------------------------------------------------------------------
3 # ========= |
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / O peration |
6 # \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
14 # the Free Software Foundation, either version 3 of the License, or
15 # (at your 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, see <http://www.gnu.org/licenses/>.
25 # Script
26 # foamNewSource
28 # Description
29 # Create a new standard OpenFOAM source file
31 #------------------------------------------------------------------------------
32 Script=${0##*/}
33 Template="$WM_PROJECT_DIR/etc/codeTemplates/source/_Template"
35 usage() {
36 while [ "$#" -ge 1 ]; do echo "$1"; shift; done
37 cat<<USAGE
38 Usage: $Script [OPTION] <type> <ClassName>
39 options:
40 -help print the usage
42 * create a new standard OpenFOAM source file
44 type: (C|H|I|IO|App)
46 A ClassName starting with '-' will simply display the template
48 USAGE
49 exit 1
53 className="$2"
54 unset subType Type printOpt
56 # for a className starting with '-' simply display the code
57 if [ "${2#-}" != "${2}" ]
58 then
59 printOpt=true
63 # this implicitly covers a lone -help
64 [ "$#" -gt 1 ] || usage
66 case "$1" in
67 (-h | -help)
68 usage
70 (C|H)
71 Type=".$1"
73 (I)
74 Type="$1.H"
76 (IO)
77 Type="$1.C"
79 (app|App)
80 subType=App
81 Type=".C"
83 (*)
84 usage "unknown type '$1'"
86 esac
88 [ "$#" -eq 2 ] || usage "wrong number of arguments"
89 shift 2
92 if [ "${printOpt:-false}" = true ]
93 then
94 cat $Template$subType$Type
95 else
97 fileName="$className$Type"
99 echo "$Script: Creating new interface file $fileName"
100 if [ -e "$fileName" ]
101 then
102 echo " Error: file exists"
103 exit 1
106 # process class name
107 sed "s/CLASSNAME/$className/g" $Template$subType$Type > $fileName
109 if [ "$subType" = App -a ! -d Make ]
110 then
111 wmakeFilesAndOptions
115 #------------------------------------------------------------------------------