Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow unstructured grids with more than typemax(Int32) points #106

Merged
merged 3 commits into from
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "WriteVTK"
uuid = "64499a7a-5c06-52f2-abe2-ccb03c286192"
authors = ["Juan Ignacio Polanco <jipolanc@gmail.com>"]
version = "1.14.2"
version = "1.14.3"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Expand Down
23 changes: 11 additions & 12 deletions src/gridtypes/unstructured/unstructured.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,11 @@ cell_type(cell::MeshCell) = cell.ctype

function add_cells!(vtk, xml_piece, number_attr, xml_name, cells;
with_types::Val=Val(true))
Cell = eltype(cells)
Ncls = length(cells)
write_types = with_types === Val(true)

# Create data arrays.
offsets = Array{Int32}(undef, Ncls)
offsets = Array{Int}(undef, Ncls)

# Write `types` array? This must be true for unstructured grids,
# and false for polydata.
Expand All @@ -94,7 +93,7 @@ function add_cells!(vtk, xml_piece, number_attr, xml_name, cells;
end

# Create connectivity array.
conn = Array{Int32}(undef, Nconn)
conn = Array{Int}(undef, Nconn)
n = 1
for c in cells, i in c.connectivity
# We transform to zero-based indexing, required by VTK.
Expand Down Expand Up @@ -122,8 +121,8 @@ end
# This will be the case if there are polyhedron cells (VTK_POLYHEDRON).
function maybe_write_faces(vtk, xnode, cells)
offset = 0
data_faces = Int32[]
data_offsets = Int32[]
data_faces = Int[]
data_offsets = Int[]

for cell in cells
ndata = process_faces!(data_faces, cell, offset)
Expand Down Expand Up @@ -206,9 +205,9 @@ end
cells::AbstractVector{<:AbstractMeshCell};
kwargs...)


Create an unstructured mesh image data (`.vtu`) file.

`X` is a matrix with each column containing the Cartesian coordinates of a point
"""
function vtk_grid(filename::AbstractString, points::AbstractArray{T,2},
Expand Down Expand Up @@ -248,9 +247,9 @@ end
x::AbstractVector{T}, [y::AbstractVector{T}, [z::AbstractVector{T}]],
cells::AbstractVector{<:AbstractMeshCell};
kwargs...) where {T<:Number}
Create an unstructured mesh image data (`.vtu`) file.

Create an unstructured mesh image data (`.vtu`) file.

`x`, `y` and `z` are vectors of containing the corresponding Cartesian coordinates of each point.
"""
function vtk_grid(filename::AbstractString, x::AbstractVector{T},
Expand Down Expand Up @@ -285,9 +284,9 @@ end
xs::AbstractVector,
cells::AbstractVector{<:AbstractMeshCell};
kwargs...)

Create an unstructured mesh image data (`.vtu`) file.

`xs` is a vector of coordinates, such as a vector of `SVector{3}` elements.
"""
function vtk_grid(filename::AbstractString, xs::AbstractVector,
Expand Down
54 changes: 27 additions & 27 deletions test/checksums.sha1
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
da0381aac3753f794e930ac0a7ed3fa11b50ce5a polyhedron_cube.vtu
a3b61f5f190095960342a8be7283648df4f3a7bf polyhedron_cube.vtu
8b2bccaeced8db1f0be93554c7cb7f8f6ee0e771 multiblock.vtm
4b83d44ce2cd0ebc1816e01cd9a7445a8e80facf multiblock_1.vts
271ce2abd35ee0cfa4aff7af5e925176d32c8282 multiblock_2.vtr
343268280766774ba512a7f0acf956be02f2752c multiblock_3.vtu
6f90855f9b87c9c06ba058d42fddda8ba43a496d multiblock_4_volume.vtu
fe1768ae48962747a220dcdbe4f4dbb21cbc7c28 multiblock_4_imin.vtu
c609ec3a84d9eaa6173b01b9778b1519f5593fdd multiblock_4_imax.vtu
d4c50ee9954494de8d262acddcbcfddeaee77980 multiblock_4_jmin.vtu
6139eff14d3841e7e25b639e373b06613735a5b7 multiblock_4_jmax.vtu
e7dd60382031b281df419dab28b73ca90275b114 multiblock_4_kmin.vtu
86deb2dbce8049b2d41cf6bff15dc1cdbefb5b21 multiblock_4_kmax.vtu
c86b48a7844e07a1b21b8ae9ee9b5336889375f5 multiblock_4_8.vtu
734d5cafcdafa7dacfacc19bbef806cf3ce224a7 block4_1.vtu
92c7120b4277720f43189d90bd0e67ccbdf69666 very_nested.vtu
37db532fde5de0c58caf516847de5437b499b860 nested-nested_1.vtu
f0d53a382bcec416d46683d87641076ad11d6bd3 multiblock_3.vtu
a10eaf61bd50f362877dee80aa6fc1f4dae26901 multiblock_4_volume.vtu
17e26bfbab7aad3dfbf14881229f690a11bba1fd multiblock_4_imin.vtu
e9266cc8d01b5db5d397cdc100759fc101dce726 multiblock_4_imax.vtu
6d9d758d284edc8f4027e96837c3076acfc1b4cf multiblock_4_jmin.vtu
dc17a92c9b87ea8ced2780c55ae8b471c51ae740 multiblock_4_jmax.vtu
6b468d70144f7751fc41ef5496499a26c694998e multiblock_4_kmin.vtu
d6b447652cbfdbae70a389d5d0cdc825d9ef4ce6 multiblock_4_kmax.vtu
54be169761c9a215f7ca553640247e0cb7a2f445 multiblock_4_8.vtu
8a952acb4a3d823169d51f69810f84c7e87cd9d6 block4_1.vtu
8d39aaa59e73dad1199ffc1307cbb1fc3194a55d very_nested.vtu
3625c1a3c8805b94263618eb6fb5da3701b335e3 nested-nested_1.vtu
e5e396469b59d25c970ec67172f70fed82fa810d rectilinear_2D.vtr
18e7e3793ec552d60e3f689d4631d48d2f98f9c0 rectilinear_3D.vtr
9e82744afa51ece188c8819349cd206183e9216d imagedata.vti
Expand All @@ -28,19 +28,19 @@ d67bc56bd3aa8f24d368d27643bfa8b8dfdb3cf2 structured_2D_VectorOfSVector.vts
4121e5a6c966a4dba4a55eb958c60fe482562e60 structured_3D_MultipleVectors.vts
4121e5a6c966a4dba4a55eb958c60fe482562e60 structured_3D_SingleArray.vts
4121e5a6c966a4dba4a55eb958c60fe482562e60 structured_3D_VectorOfSVector.vts
469abd27dea107592adb0abcaefbb5ea039ba8a7 unstructured_1D.vtu
469abd27dea107592adb0abcaefbb5ea039ba8a7 unstructured_1D_tuple.vtu
1308ed306780dc0f47878ace582a093e27baa696 unstructured_1D_SVector.vtu
dc1fbc6ff5e7d52a8901944f2b96473e74315129 unstructured_2D.vtu
dc1fbc6ff5e7d52a8901944f2b96473e74315129 unstructured_2D_tuple.vtu
6cf08e49a10860a59a02b0ba6e06d0dee6b6b929 unstructured_2D_SVector.vtu
23e215dbcf01ba81dc7efffdb942c87a6677a8a8 unstructured_3D.vtu
23e215dbcf01ba81dc7efffdb942c87a6677a8a8 unstructured_3D_tuple.vtu
388d5c7681704b89816e0a0f9d1bf2c442e5156c unstructured_3D_SVector.vtu
6e97b631905a99cd62efa2520e7a60800851f6f2 empty_cells.vtp
ba976d6afb5b7763efe2fbc1ca31f6e3176ed474 polydata_2D.vtp
e77534791e43c6ef09b000907802ebc0ece26171 polydata_3D.vtp
29b5b44068ba1ea6df2d9314708ea4e3c4b13fe7 bezier_tetra_quartic_solidSphereOctant.vtu
4c216331f3754c7e946ff3bd73ec8e0f9875cb90 unstructured_1D.vtu
4c216331f3754c7e946ff3bd73ec8e0f9875cb90 unstructured_1D_tuple.vtu
1ea73796ca7240c4b83a55a39eb5ed467c6b577d unstructured_1D_SVector.vtu
2a39f5566559a0f7ce2ef24356a7bf7b1c90be2f unstructured_2D.vtu
2a39f5566559a0f7ce2ef24356a7bf7b1c90be2f unstructured_2D_tuple.vtu
ce49751a8b2cc14806b32e7dee0f7a6a5f2fc4ba unstructured_2D_SVector.vtu
a96c57cd06b71ea2793883224ec08e69c401240c unstructured_3D.vtu
a96c57cd06b71ea2793883224ec08e69c401240c unstructured_3D_tuple.vtu
084079bc4289bce1005ec85fc0b6bcb079070d81 unstructured_3D_SVector.vtu
161a307d963f2ac42caabcc63257caeafec7cde0 empty_cells.vtp
067069b65b73675ed3249418356ac201896d4cc3 polydata_2D.vtp
30c857ba5e9e3f09650fb116aa3f3c4fb731241e polydata_3D.vtp
00b35b76151c72a86ce4d819c4ced934fab3b569 bezier_tetra_quartic_solidSphereOctant.vtu
795a82b363436a80068f7455a8f219017b3285d7 collection.pvd
e041dbdab45b518feee8a974fd93dce15cacd60c collection_00.vtr
40ffa7cef8284404ef2405096b7771607b57d476 collection_01.vtr
Expand All @@ -52,7 +52,7 @@ b20bf14b2531aaf323b891e090d0615d0e943ef6 collection_03.vtr
e0180e5cf18bb7c6f00df0bb9ded769f90b2574e arraydata_3D.vti
9e21f61ebf8641fdcc325836d4bd707e52932441 arrays.vti
2626bef24152fcfe28c810ca68adf473c8fad90c simulation.pvtu
9a0c9ff25c52c807adac85d7fdd1001d18422952 simulation/simulation_1.vtu
4a0be2eaf5c7ffdb60970f0396a11ef2ab3affca simulation/simulation_1.vtu
e23c8f0db331e1db635aa5d98b9f1375132e7ffd pimage.pvti
e581d4824d67655584f573743f42788fb26e162c pimage/pimage_1.vti
150ce17cb8ddbb974344954a3193a3373ee1c3fc pimage/pimage_2.vti
Expand Down