Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f428374
evtk: reformat with black
MuellerSeb Apr 22, 2020
d59bc12
evtk-subpackage: reformat with black
MuellerSeb Apr 22, 2020
ce2224e
xml: add doc; reformat with black
MuellerSeb Apr 22, 2020
5388d60
vtk: update doc; reformat with black; remove largefile attribute; rem…
MuellerSeb Apr 22, 2020
3b3fcf0
hl: add field_data export option; update doc; reformat with black
MuellerSeb Apr 22, 2020
e10458b
examples: reformat wit black; add field data example
MuellerSeb Apr 22, 2020
dcd0fc1
vtk: reset appended encoding to raw
MuellerSeb Apr 22, 2020
71a9fab
minor doc corrections
MuellerSeb Apr 22, 2020
e4d7287
setup.py: reformat with black
MuellerSeb Apr 22, 2020
fcfc346
[ci] update travis setup
renefritze Apr 23, 2020
5150345
evtk: reformat with black
MuellerSeb Apr 22, 2020
666c780
evtk-subpackage: reformat with black
MuellerSeb Apr 22, 2020
6da811f
xml: add doc; reformat with black
MuellerSeb Apr 22, 2020
ab0b3af
vtk: update doc; reformat with black; remove largefile attribute; rem…
MuellerSeb Apr 22, 2020
4d0cdf2
hl: add field_data export option; update doc; reformat with black
MuellerSeb Apr 22, 2020
1f124ae
examples: reformat wit black; add field data example
MuellerSeb Apr 22, 2020
b61c10e
vtk: reset appended encoding to raw
MuellerSeb Apr 22, 2020
d1f1e33
minor doc corrections
MuellerSeb Apr 22, 2020
6e058a4
setup.py: reformat with black
MuellerSeb Apr 22, 2020
db63f75
add some missing descriptions
MuellerSeb Apr 23, 2020
2dcbedc
solve conflicts; remove accidentally created .vtu
MuellerSeb Apr 23, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion evtk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
from pyevtk import *

import warnings
warnings.warn('the "evtk" package is deprecated, use "pyevtk" instead', DeprecationWarning)

warnings.warn(
'the "evtk" package is deprecated, use "pyevtk" instead',
DeprecationWarning,
)
10 changes: 5 additions & 5 deletions examples/group.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env python

# ***********************************************************************************
# * Copyright 2010 - 2016 Paulo A. Herrera. All rights reserved. *
# * Copyright 2010 - 2016 Paulo A. Herrera. All rights reserved. *
# * *
# * Redistribution and use in source and binary forms, with or without *
# * modification, are permitted provided that the following conditions are met: *
Expand Down Expand Up @@ -33,8 +33,8 @@
from pyevtk.vtk import VtkGroup

g = VtkGroup("./group")
g.addFile(filepath = "sim0000.vtu", sim_time = 0.0)
g.addFile(filepath = "sim0001.vtu", sim_time = 1.0)
g.addFile(filepath = "sim0002.vtu", sim_time = 2.0)
g.addFile(filepath = "sim0003.vtu", sim_time = 3.0)
g.addFile(filepath="sim0000.vtu", sim_time=0.0)
g.addFile(filepath="sim0001.vtu", sim_time=1.0)
g.addFile(filepath="sim0002.vtu", sim_time=2.0)
g.addFile(filepath="sim0003.vtu", sim_time=3.0)
g.save()
26 changes: 14 additions & 12 deletions examples/image.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env python

# ***********************************************************************************
# * Copyright 2010 - 2016 Paulo A. Herrera. All rights reserved. *
# * Copyright 2010 - 2016 Paulo A. Herrera. All rights reserved. *
# * *
# * Redistribution and use in source and binary forms, with or without *
# * modification, are permitted provided that the following conditions are met: *
Expand Down Expand Up @@ -38,19 +38,21 @@
npoints = (nx + 1) * (ny + 1) * (nz + 1)

# Variables
pressure = np.random.rand(ncells).reshape( (nx, ny, nz), order = 'C')
temp = np.random.rand(npoints).reshape( (nx + 1, ny + 1, nz + 1))
pressure = np.random.rand(ncells).reshape((nx, ny, nz), order="C")
temp = np.random.rand(npoints).reshape((nx + 1, ny + 1, nz + 1))

imageToVTK("./image", cellData = {"pressure" : pressure}, pointData = {"temp" : temp} )
imageToVTK(
"./image", cellData={"pressure": pressure}, pointData={"temp": temp}
)

fluxx = np.random.rand(ncells).reshape( (nx, ny, nz), order='F')
fluxy = np.random.rand(ncells).reshape( (nx, ny, nz), order='F')
fluxz = np.random.rand(ncells).reshape( (nx, ny, nz), order='F')
fluxx = np.random.rand(ncells).reshape((nx, ny, nz), order="F")
fluxy = np.random.rand(ncells).reshape((nx, ny, nz), order="F")
fluxz = np.random.rand(ncells).reshape((nx, ny, nz), order="F")
flux = (fluxx, fluxy, fluxz)

Efieldx = np.random.rand(npoints).reshape( (nx + 1, ny + 1, nz + 1), order='F')
Efieldy = np.random.rand(npoints).reshape( (nx + 1, ny + 1, nz + 1), order='F')
Efieldz = np.random.rand(npoints).reshape( (nx + 1, ny + 1, nz + 1), order='F')
Efield = (Efieldx,Efieldy,Efieldz)
Efieldx = np.random.rand(npoints).reshape((nx + 1, ny + 1, nz + 1), order="F")
Efieldy = np.random.rand(npoints).reshape((nx + 1, ny + 1, nz + 1), order="F")
Efieldz = np.random.rand(npoints).reshape((nx + 1, ny + 1, nz + 1), order="F")
Efield = (Efieldx, Efieldy, Efieldz)

imageToVTK("./image", cellData={"flux" : flux}, pointData = {"Efield" : Efieldx} )
imageToVTK("./image", cellData={"flux": flux}, pointData={"Efield": Efieldx})
11 changes: 8 additions & 3 deletions examples/lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
x[2], y[2], z[2] = 0.0, 0.0, 0.0
x[3], y[3], z[3] = -1.0, 1.0, 1.0

linesToVTK("./lines", x, y, z, cellData = {"vel" : vel}, pointData = {"temp" : temp, "pressure" : pressure})


linesToVTK(
"./lines",
x,
y,
z,
cellData={"vel": vel},
pointData={"temp": temp, "pressure": pressure},
)
41 changes: 20 additions & 21 deletions examples/lowlevel.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env python

# ***********************************************************************************
# * Copyright 2010 - 2016 Paulo A. Herrera. All rights reserved *
# * Copyright 2010 - 2016 Paulo A. Herrera. All rights reserved *
# * *
# * Redistribution and use in source and binary forms, with or without *
# * modification, are permitted provided that the following conditions are met: *
Expand Down Expand Up @@ -34,45 +34,44 @@

nx, ny, nz = 6, 6, 2
lx, ly, lz = 1.0, 1.0, 1.0
dx, dy, dz = lx/nx, ly/ny, lz/nz
dx, dy, dz = lx / nx, ly / ny, lz / nz
ncells = nx * ny * nz
npoints = (nx + 1) * (ny + 1) * (nz + 1)
x = np.arange(0, lx + 0.1*dx, dx, dtype='float64')
y = np.arange(0, ly + 0.1*dy, dy, dtype='float64')
z = np.arange(0, lz + 0.1*dz, dz, dtype='float64')
start, end = (0,0,0), (nx, ny, nz)
x = np.arange(0, lx + 0.1 * dx, dx, dtype="float64")
y = np.arange(0, ly + 0.1 * dy, dy, dtype="float64")
z = np.arange(0, lz + 0.1 * dz, dz, dtype="float64")
start, end = (0, 0, 0), (nx, ny, nz)

w = VtkFile("./evtk_test", VtkRectilinearGrid)
w.openGrid(start = start, end = end)
w.openPiece( start = start, end = end)
w.openGrid(start=start, end=end)
w.openPiece(start=start, end=end)

# Point data
temp = np.random.rand(npoints)
vx = vy = vz = np.zeros([nx + 1, ny + 1, nz + 1], dtype="float64", order = 'F')
w.openData("Point", scalars = "Temperature", vectors = "Velocity")
vx = vy = vz = np.zeros([nx + 1, ny + 1, nz + 1], dtype="float64", order="F")
w.openData("Point", scalars="Temperature", vectors="Velocity")
w.addData("Temperature", temp)
w.addData("Velocity", (vx,vy,vz))
w.addData("Velocity", (vx, vy, vz))
w.closeData("Point")

# Cell data
pressure = np.zeros([nx, ny, nz], dtype="float64", order='F')
w.openData("Cell", scalars = "Pressure")
pressure = np.zeros([nx, ny, nz], dtype="float64", order="F")
w.openData("Cell", scalars="Pressure")
w.addData("Pressure", pressure)
w.closeData("Cell")

# Coordinates of cell vertices
w.openElement("Coordinates")
w.addData("x_coordinates", x);
w.addData("y_coordinates", y);
w.addData("z_coordinates", z);
w.closeElement("Coordinates");
w.addData("x_coordinates", x)
w.addData("y_coordinates", y)
w.addData("z_coordinates", z)
w.closeElement("Coordinates")

w.closePiece()
w.closeGrid()

w.appendData(data = temp)
w.appendData(data = (vx,vy,vz))
w.appendData(data = pressure)
w.appendData(data=temp)
w.appendData(data=(vx, vy, vz))
w.appendData(data=pressure)
w.appendData(x).appendData(y).appendData(z)
w.save()

13 changes: 6 additions & 7 deletions examples/points.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env python

# ***********************************************************************************
# * Copyright 2010 - 2016 Paulo A. Herrera. All rights reserved. *
# * Copyright 2010 - 2016 Paulo A. Herrera. All rights reserved. *
# * *
# * Redistribution and use in source and binary forms, with or without *
# * modification, are permitted provided that the following conditions are met: *
Expand Down Expand Up @@ -39,11 +39,10 @@
z = np.random.rand(npoints)
pressure = np.random.rand(npoints)
temp = np.random.rand(npoints)
pointsToVTK("./rnd_points", x, y, z, data = {"temp" : temp, "pressure" : pressure})
pointsToVTK("./rnd_points", x, y, z, data={"temp": temp, "pressure": pressure})

# Example 2
x = np.arange(1.0,10.0,0.1)
y = np.arange(1.0,10.0,0.1)
z = np.arange(1.0,10.0,0.1)
pointsToVTK("./line_points", x, y, z, data = {"elev" : z})

x = np.arange(1.0, 10.0, 0.1)
y = np.arange(1.0, 10.0, 0.1)
z = np.arange(1.0, 10.0, 0.1)
pointsToVTK("./line_points", x, y, z, data={"elev": z})
12 changes: 9 additions & 3 deletions examples/poly_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
vel[0:3] = 1.0
vel[4:6] = 5.0

polyLinesToVTK("./poly_lines", x, y, z, pointsPerLine = pointsPerLine, cellData = {"vel" : vel}, pointData = {"temp" : temp, "pressure" : pressure})


polyLinesToVTK(
"./poly_lines",
x,
y,
z,
pointsPerLine=pointsPerLine,
cellData={"vel": vel},
pointData={"temp": temp, "pressure": pressure},
)
25 changes: 16 additions & 9 deletions examples/rectilinear.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env python

# ***********************************************************************************
# * Copyright 2010 - 2016 Paulo A. Herrera. All rights reserved. *
# * Copyright 2010 - 2016 Paulo A. Herrera. All rights reserved. *
# * *
# * Redistribution and use in source and binary forms, with or without *
# * modification, are permitted provided that the following conditions are met: *
Expand Down Expand Up @@ -36,18 +36,25 @@
# Dimensions
nx, ny, nz = 6, 6, 2
lx, ly, lz = 1.0, 1.0, 1.0
dx, dy, dz = lx/nx, ly/ny, lz/nz
dx, dy, dz = lx / nx, ly / ny, lz / nz

ncells = nx * ny * nz
npoints = (nx + 1) * (ny + 1) * (nz + 1)

# Coordinates
x = np.arange(0, lx + 0.1*dx, dx, dtype='float64')
y = np.arange(0, ly + 0.1*dy, dy, dtype='float64')
z = np.arange(0, lz + 0.1*dz, dz, dtype='float64')
x = np.arange(0, lx + 0.1 * dx, dx, dtype="float64")
y = np.arange(0, ly + 0.1 * dy, dy, dtype="float64")
z = np.arange(0, lz + 0.1 * dz, dz, dtype="float64")

# Variables
pressure = np.random.rand(ncells).reshape( (nx, ny, nz))
temp = np.random.rand(npoints).reshape( (nx + 1, ny + 1, nz + 1))

gridToVTK("./rectilinear", x, y, z, cellData = {"pressure" : pressure}, pointData = {"temp" : temp})
pressure = np.random.rand(ncells).reshape((nx, ny, nz))
temp = np.random.rand(npoints).reshape((nx + 1, ny + 1, nz + 1))

gridToVTK(
"./rectilinear",
x,
y,
z,
cellData={"pressure": pressure},
pointData={"temp": temp},
)
29 changes: 18 additions & 11 deletions examples/structured.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env python

# ***********************************************************************************
# * Copyright 2010 - 2016 Paulo A. Herrera. All rights reserved. *
# * Copyright 2010 - 2016 Paulo A. Herrera. All rights reserved. *
# * *
# * Redistribution and use in source and binary forms, with or without *
# * modification, are permitted provided that the following conditions are met: *
Expand Down Expand Up @@ -37,15 +37,15 @@
# Dimensions
nx, ny, nz = 6, 6, 2
lx, ly, lz = 1.0, 1.0, 1.0
dx, dy, dz = lx/nx, ly/ny, lz/nz
dx, dy, dz = lx / nx, ly / ny, lz / nz

ncells = nx * ny * nz
npoints = (nx + 1) * (ny + 1) * (nz + 1)

# Coordinates
X = np.arange(0, lx + 0.1*dx, dx, dtype='float64')
Y = np.arange(0, ly + 0.1*dy, dy, dtype='float64')
Z = np.arange(0, lz + 0.1*dz, dz, dtype='float64')
X = np.arange(0, lx + 0.1 * dx, dx, dtype="float64")
Y = np.arange(0, ly + 0.1 * dy, dy, dtype="float64")
Z = np.arange(0, lz + 0.1 * dz, dz, dtype="float64")

x = np.zeros((nx + 1, ny + 1, nz + 1))
y = np.zeros((nx + 1, ny + 1, nz + 1))
Expand All @@ -56,12 +56,19 @@
for k in range(nz + 1):
for j in range(ny + 1):
for i in range(nx + 1):
x[i,j,k] = X[i] + (0.5 - rnd.random()) * 0.1 * dx
y[i,j,k] = Y[j] + (0.5 - rnd.random()) * 0.1 * dy
z[i,j,k] = Z[k] + (0.5 - rnd.random()) * 0.1 * dz
x[i, j, k] = X[i] + (0.5 - rnd.random()) * 0.1 * dx
y[i, j, k] = Y[j] + (0.5 - rnd.random()) * 0.1 * dy
z[i, j, k] = Z[k] + (0.5 - rnd.random()) * 0.1 * dz

# Variables
pressure = np.random.rand(ncells).reshape( (nx, ny, nz))
temp = np.random.rand(npoints).reshape( (nx + 1, ny + 1, nz + 1))
pressure = np.random.rand(ncells).reshape((nx, ny, nz))
temp = np.random.rand(npoints).reshape((nx + 1, ny + 1, nz + 1))

gridToVTK("./structured", x, y, z, cellData = {"pressure" : pressure}, pointData = {"temp" : temp})
gridToVTK(
"./structured",
x,
y,
z,
cellData={"pressure": pressure},
pointData={"temp": temp},
)
20 changes: 17 additions & 3 deletions examples/unstructured.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,14 @@
x[4], y[4], z[4] = 1.0, 1.0, 0.0
x[5], y[5], z[5] = 2.0, 1.0, 0.0

point_data = {"test_pd": np.array([1, 2, 3, 4, 5, 6])}
cell_data = {"test_cd": np.array([1, 2, 3])}
field_data = {"test_fd": np.array([1.0, 2.0])}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I added field data to the grid.

# Define connectivity or vertices that belongs to each element
conn = np.zeros(10)

conn[0], conn[1], conn[2] = 0, 1, 3 # first triangle
conn[3], conn[4], conn[5] = 1, 4, 3 # second triangle
conn[0], conn[1], conn[2] = 0, 1, 3 # first triangle
conn[3], conn[4], conn[5] = 1, 4, 3 # second triangle
conn[6], conn[7], conn[8], conn[9] = 1, 2, 5, 4 # rectangle

# Define offset of last vertex of each element
Expand All @@ -67,4 +70,15 @@
ctype[0], ctype[1] = VtkTriangle.tid, VtkTriangle.tid
ctype[2] = VtkQuad.tid

unstructuredGridToVTK("unstructured", x, y, z, connectivity = conn, offsets = offset, cell_types = ctype, cellData = None, pointData = None)
unstructuredGridToVTK(
"unstructured",
x,
y,
z,
connectivity=conn,
offsets=offset,
cell_types=ctype,
cellData=cell_data,
pointData=point_data,
fieldData=field_data,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field data can now simply be added to the call of the export functions.

)
Loading