18
Send an error message to standard error
21
sys.stderr.write(message + "\n")
28
Prints program usage information
31
print "Usage: vtudiff [OPTIONS] ... INPUT1 INPUT2 OUTPUT [FIRST] [LAST]\n" + \
33
"Generates vtus with fields equal to the difference between the corresponding\n" + \
34
"fields in two input vtus (INPUT1 - INPUT2). The fields of INPUT2 are projected\n" + \
35
"onto the cell points of INPUT1.\n" + \
37
"If FIRST is supplied, treats INPUT1 and INPUT2 as project names, and generates\n" + \
38
"a different vtu for the specified range of output files.\n" + \
42
"-s If supplied together with FIRST and LAST, only INPUT1 is treated as a\n" + \
43
" project name. Allows a range of vtus to be diffed against a single vtu."
47
def Error(message, displayHelp = True):
49
Print an error message, usage information and quit
59
opts, args = getopt.getopt(sys.argv[1:], "ms")
65
Error("Invalid argument \"" + args[5] + "\" supplied")
67
diffAgainstSingle = ("-s", "") in opts
70
inputFilename1 = args[0]
71
inputFilename2 = args[1]
72
outputFilename = args[2]
79
firstId = int(args[3])
84
Error("Invalid last ID entered")
88
Error("Invalid first ID entered")
93
inputFilenames1 = [inputFilename1]
94
inputFilenames2 = [inputFilename2]
95
outputFilenames = [outputFilename]
97
inputFilenames1 = [inputFilename1 + "_" + str(i) + ".vtu" for i in range(firstId, lastId + 1)]
99
inputFilenames2 = [inputFilename2 for i in range(firstId, lastId + 1)]
101
inputFilenames2 = [inputFilename2 + "_" + str(i) + ".vtu" for i in range(firstId, lastId + 1)]
103
outputFilenames = [outputFilename + "_" + str(i) + ".vtu" for i in range(firstId, lastId + 1)]
105
for i in range(len(inputFilenames1)):
107
vtu1 = vtktools.vtu(inputFilenames1[i])
109
Error("Unable to read input vtu \"" + inputFilenames1[i] + "\"", False)
111
vtu2 = vtktools.vtu(inputFilenames2[i])
113
Error("Unable to read input vtu \"" + inputFilenames2[i] + "\"", False)
115
diffVtu = vtktools.VtuDiff(vtu1, vtu2, outputFilenames[i])
121
Error("Unable to write output file \"" + outputFilenames[i] + "\"", False)
123
print "Generated vtu diff file \"" + outputFilenames[i] + "\""