|
1 | 1 | #! /usr/bin/env python |
2 | 2 |
|
3 | 3 | # *********************************************************************************** |
4 | | -# * Copyright 2010 - 2016 Paulo A. Herrera. All rights reserved * |
| 4 | +# * Copyright 2010 - 2016 Paulo A. Herrera. All rights reserved * |
5 | 5 | # * * |
6 | 6 | # * Redistribution and use in source and binary forms, with or without * |
7 | 7 | # * modification, are permitted provided that the following conditions are met: * |
|
34 | 34 |
|
35 | 35 | nx, ny, nz = 6, 6, 2 |
36 | 36 | lx, ly, lz = 1.0, 1.0, 1.0 |
37 | | -dx, dy, dz = lx/nx, ly/ny, lz/nz |
| 37 | +dx, dy, dz = lx / nx, ly / ny, lz / nz |
38 | 38 | ncells = nx * ny * nz |
39 | 39 | npoints = (nx + 1) * (ny + 1) * (nz + 1) |
40 | | -x = np.arange(0, lx + 0.1*dx, dx, dtype='float64') |
41 | | -y = np.arange(0, ly + 0.1*dy, dy, dtype='float64') |
42 | | -z = np.arange(0, lz + 0.1*dz, dz, dtype='float64') |
43 | | -start, end = (0,0,0), (nx, ny, nz) |
| 40 | +x = np.arange(0, lx + 0.1 * dx, dx, dtype="float64") |
| 41 | +y = np.arange(0, ly + 0.1 * dy, dy, dtype="float64") |
| 42 | +z = np.arange(0, lz + 0.1 * dz, dz, dtype="float64") |
| 43 | +start, end = (0, 0, 0), (nx, ny, nz) |
44 | 44 |
|
45 | 45 | w = VtkFile("./evtk_test", VtkRectilinearGrid) |
46 | | -w.openGrid(start = start, end = end) |
47 | | -w.openPiece( start = start, end = end) |
| 46 | +w.openGrid(start=start, end=end) |
| 47 | +w.openPiece(start=start, end=end) |
48 | 48 |
|
49 | 49 | # Point data |
50 | 50 | temp = np.random.rand(npoints) |
51 | | -vx = vy = vz = np.zeros([nx + 1, ny + 1, nz + 1], dtype="float64", order = 'F') |
52 | | -w.openData("Point", scalars = "Temperature", vectors = "Velocity") |
| 51 | +vx = vy = vz = np.zeros([nx + 1, ny + 1, nz + 1], dtype="float64", order="F") |
| 52 | +w.openData("Point", scalars="Temperature", vectors="Velocity") |
53 | 53 | w.addData("Temperature", temp) |
54 | | -w.addData("Velocity", (vx,vy,vz)) |
| 54 | +w.addData("Velocity", (vx, vy, vz)) |
55 | 55 | w.closeData("Point") |
56 | 56 |
|
57 | 57 | # Cell data |
58 | | -pressure = np.zeros([nx, ny, nz], dtype="float64", order='F') |
59 | | -w.openData("Cell", scalars = "Pressure") |
| 58 | +pressure = np.zeros([nx, ny, nz], dtype="float64", order="F") |
| 59 | +w.openData("Cell", scalars="Pressure") |
60 | 60 | w.addData("Pressure", pressure) |
61 | 61 | w.closeData("Cell") |
62 | 62 |
|
63 | 63 | # Coordinates of cell vertices |
64 | 64 | w.openElement("Coordinates") |
65 | | -w.addData("x_coordinates", x); |
66 | | -w.addData("y_coordinates", y); |
67 | | -w.addData("z_coordinates", z); |
68 | | -w.closeElement("Coordinates"); |
| 65 | +w.addData("x_coordinates", x) |
| 66 | +w.addData("y_coordinates", y) |
| 67 | +w.addData("z_coordinates", z) |
| 68 | +w.closeElement("Coordinates") |
69 | 69 |
|
70 | 70 | w.closePiece() |
71 | 71 | w.closeGrid() |
72 | 72 |
|
73 | | -w.appendData(data = temp) |
74 | | -w.appendData(data = (vx,vy,vz)) |
75 | | -w.appendData(data = pressure) |
| 73 | +w.appendData(data=temp) |
| 74 | +w.appendData(data=(vx, vy, vz)) |
| 75 | +w.appendData(data=pressure) |
76 | 76 | w.appendData(x).appendData(y).appendData(z) |
77 | 77 | w.save() |
78 | | - |
0 commit comments