JuliaVTK / WriteVTK.jl

Julia package for writing VTK XML files
Other
151 stars 32 forks source link

Inexact Error: ran out of numbers #105

Closed PetrKryslUCSD closed 2 years ago

PetrKryslUCSD commented 2 years ago

For a large mesh (840M tetrahedra), I got this error:

ERROR: LoadError: InexactError: trunc(Int32, 2147483648)
Stacktrace:
  [1] throw_inexacterror(f::Symbol, #unused#::Type{Int32}, val::Int64)
    @ Core ./boot.jl:612
  [2] checked_trunc_sint
    @ ./boot.jl:634 [inlined]
  [3] toInt32
    @ ./boot.jl:671 [inlined]
  [4] Int32
    @ ./boot.jl:761 [inlined]
  [5] convert
    @ ./number.jl:7 [inlined]
  [6] setindex!
    @ ./array.jl:903 [inlined]
  [7] add_cells!(vtk::WriteVTK.DatasetFile, xml_piece::LightXML.XMLElement, number_attr::String, xml_name::String, cells::Vector{WriteVTK.MeshCell{WriteVTK.VTKCellTypes.VTKCellType, SubArray{Int64, 1, Matrix{Int64}, Tuple{Int64, Base.Slice{Base.OneTo{Int64}}}, true}}}; with_types::Val{true})
    @ WriteVTK ~/.julia/packages/WriteVTK/nNSYd/src/gridtypes/unstructured/unstructured.jl:92
  [8] add_cells!
    @ ~/.julia/packages/WriteVTK/nNSYd/src/gridtypes/unstructured/unstructured.jl:67 [inlined]
  [9] vtk_grid(dtype::WriteVTK.VTKUnstructuredGrid, filename::String, points::Matrix{Float64}, cells::Vector{WriteVTK.MeshCell{WriteVTK.VTKCellTypes.VTKCellType, SubArray{Int64, 1, Matrix{Int64}, Tuple{Int64, Base.Slice{Base.OneTo{Int64}}}, true}}}; kwargs::Base.Pairs{Symbol, Int64, Tuple{Symbol}, NamedTuple{(:compress,), Tuple{Int64}}})
    @ WriteVTK ~/.julia/packages/WriteVTK/nNSYd/src/gridtypes/unstructured/unstructured.jl:196
 [10] vtk_grid(::String, ::Matrix{Float64}, ::Vector{WriteVTK.MeshCell{WriteVTK.VTKCellTypes.VTKCellType, SubArray{Int64, 1, Matrix{Int64}, Tuple{Int64, Base.Slice{Base.OneTo{Int64}}}, true}}}; kwargs::Base.Pairs{Symbol, Int64, Tuple{Symbol}, NamedTuple{(:compress,), Tuple{Int64}}})
    @ WriteVTK ~/.julia/packages/WriteVTK/nNSYd/src/gridtypes/unstructured/unstructured.jl:220
 [11] vtkwrite(theFile::String, Connectivity::Matrix{Int64}, Points::Matrix{Float64}, celltype::WriteVTK.VTKCellTypes.VTKCellType; vectors::Nothing, scalars::Nothing)
    @ FinEtools.MeshExportModule.VTKWrite ~/.julia/packages/FinEtools/4aVZc/src/MeshExportModule.jl:1426
 [12] vtkwrite
    @ ~/.julia/packages/FinEtools/4aVZc/src/MeshExportModule.jl:1412 [inlined]
 [13] vtkwrite(theFile::String, fens::FENodeSet, fes::FESetT4; opts::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})

It is apparently due to the offsets being created as Int32. Is this required by the file format? Could this be changed to Int64?

jipolanco commented 2 years ago

I'm not sure, I'd need to check whether it's a requirement of the file format.

Do you have a minimal example?

jipolanco commented 2 years ago

ParaView doesn't seem to complain when I switch to Int64. I'll push a fix.

PetrKryslUCSD commented 2 years ago

Oh, that would be fantastic! My minimal example is a 24GB mesh file ;-) Many thanks!

PetrKryslUCSD commented 2 years ago

BTW, the documentation refers only to 32-bit integers. I put the question to the technical support on the forum as well.

jipolanco commented 2 years ago

That's strange, I would expect recent versions of VTK to support Int64 as well.

Before merging #106, do you think you would you be able to test your large dataset on that branch, and then check if you can open the result in ParaView or similar? Thanks!

PetrKryslUCSD commented 2 years ago

Will do!

jipolanco commented 2 years ago

From the file format docs:

The attributes of the DataArray elements are described as follows: type — The data type of a single component of the array. This is one of Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64, UInt64, Float32, Float64. Note: the 64-bit integer types are only supported if VTK_USE_64BIT_IDS is on (a CMake variable—see “CMake” on page 8) or the platform is 64-bit.

So I guess Int64 should work just fine!