From 11e7319765ca33bbd1a88d5cece390d1c81d5d12 Mon Sep 17 00:00:00 2001 From: "Craig M. Hamel" Date: Sat, 27 Jun 2026 13:56:27 -0400 Subject: [PATCH] Major reworks to internals. --- Project.toml | 2 +- lib/IncludeMe.jl | 8 +-- lib/LibExodus.jl | 7 ++- lib/generator.toml | 21 +++---- lib/make.jl | 17 +++++- src/Blocks.jl | 118 +++++++++++++++--------------------- src/Coordinates.jl | 99 +++++++++++++++--------------- src/ExodusTypes.jl | 137 +++++++++++++++++++----------------------- src/Info.jl | 23 +++---- src/Maps.jl | 25 +++----- src/ParallelExodus.jl | 126 +++++++++++++++++++------------------- src/QA.jl | 45 ++++++++------ src/Sets.jl | 115 +++++++++++++++++------------------ src/Times.jl | 18 +++--- src/Variables.jl | 93 ++++++++++++++-------------- 15 files changed, 413 insertions(+), 441 deletions(-) diff --git a/Project.toml b/Project.toml index faf4999..76efbeb 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "Exodus" uuid = "f57ae99e-f805-4780-bdca-96e224be1e5a" -version = "0.14.4" +version = "0.15.0" authors = ["cmhamel "] [deps] diff --git a/lib/IncludeMe.jl b/lib/IncludeMe.jl index 996513e..7d99627 100644 --- a/lib/IncludeMe.jl +++ b/lib/IncludeMe.jl @@ -1,11 +1,9 @@ include("LibExodus.jl") # TODO make below constants not hardcoded. Read from LibExodus. -const cpu_word_size = Int32(sizeof(Float64)) # TODO make parametric so we can have float models -const IO_word_size = Int32(8) # This was what we did before +const cpu_word_size = Int32(sizeof(Float64)) # TODO make parametric so we can have float models +const IO_word_size = Int32(8) # This was what we did before const version_number = LibExodus.EX_API_VERS import .LibExodus: - ex_entity_type, - ex_inquiry, EX_ABORT, EX_API_VERS_NODOT, EX_BULK_INT64_API, @@ -27,4 +25,4 @@ import .LibExodus: EX_WRITE, EX_VERBOSE, MAX_LINE_LENGTH, - MAX_STR_LENGTH \ No newline at end of file + MAX_STR_LENGTH diff --git a/lib/LibExodus.jl b/lib/LibExodus.jl index 6fef6ed..21d3118 100644 --- a/lib/LibExodus.jl +++ b/lib/LibExodus.jl @@ -5,6 +5,11 @@ export Exodus_jll using CEnum: CEnum, @cenum +to_c_type(t::Type) = t +to_c_type_pairs(va_list) = map(enumerate(to_c_type.(va_list))) do (ind, type) + :(va_list[$ind]::$type) +end + function interface(nvtxs, start, adjacency, vwgts, ewgts, x, y, z, outassignname, outfilename, assignment, architecture, ndims_tot, mesh_dims, goal, global_method, local_method, rqi_flag, vmax, ndims, eigtol, seed) @ccall libexodus.interface(nvtxs::Cint, start::Ptr{Cint}, adjacency::Ptr{Cint}, vwgts::Ptr{Cint}, ewgts::Ptr{Cfloat}, x::Ptr{Cfloat}, y::Ptr{Cfloat}, z::Ptr{Cfloat}, outassignname::Cstring, outfilename::Cstring, assignment::Ptr{Cint}, architecture::Cint, ndims_tot::Cint, mesh_dims::Ptr{Cint}, goal::Ptr{Cdouble}, global_method::Cint, local_method::Cint, rqi_flag::Cint, vmax::Cint, ndims::Cint, eigtol::Cdouble, seed::Clong)::Cint end @@ -2258,8 +2263,6 @@ const CHACO_VERSION_MINOR = 0 const CHACO_VERSION_PATCH = 0 -# const EX_MAX_NAME = NC_MAX_NAME - const EXODUS_VERSION = "9.04" const EXODUS_VERSION_MAJOR = 9 diff --git a/lib/generator.toml b/lib/generator.toml index ef0e1cc..ee49b4b 100644 --- a/lib/generator.toml +++ b/lib/generator.toml @@ -46,17 +46,9 @@ epilogue_file_path = "" # node with an id in the `output_ignorelist` will be ignored in the printing passes. # this is very useful for custom editing. -# output_ignorelist = [ -# "CINDEX_EXPORTS", -# "CINDEX_VERSION", -# "CINDEX_VERSION_STRING", -# "CINDEX_LINKAGE", -# "CINDEX_DEPRECATED", -# "LLVM_CLANG_C_STRICT_PROTOTYPES_BEGIN", -# "LLVM_CLANG_C_STRICT_PROTOTYPES_END", -# "LLVM_CLANG_C_EXTERN_C_BEGIN", -# "LLVM_CLANG_C_EXTERN_C_END" -# ] +output_ignorelist = [ + "EX_MAX_NAME" +] # Julia's `@enum` do not allow duplicated values, so by default, C enums are translated to # CEnum.jl's `@cenum`. @@ -176,7 +168,7 @@ opaque_as_mutable_struct = true use_ccall_macro = true # if true, variadic functions are wrapped with `@ccall` macro. Otherwise variadic functions are ignored. -wrap_variadic_function = false +wrap_variadic_function = true # Generate getproperty/setproperty! methods for the types in the following list. # Warning: the generated methods will only work on the architecture that they @@ -213,4 +205,7 @@ ignore_header_guards = true ignore_header_guards_with_suffixes = [] # if true, ignore those pure definition macros in the C code -ignore_pure_definition = true \ No newline at end of file +ignore_pure_definition = true + +[codegen.typemap] +"Ptr{Cvoid}" = "Ptr{Cfloat}" \ No newline at end of file diff --git a/lib/make.jl b/lib/make.jl index 78f6c5b..d508bc6 100644 --- a/lib/make.jl +++ b/lib/make.jl @@ -1,7 +1,22 @@ using Clang.Generators -# using Clang.LibClang.Clang_unified_jll using Exodus_jll +function patch!(ctx) + Clang.Generators.walk!(ctx.dag) do node + if node isa Clang.Generators.FunctionDecl + for arg in node.args + if arg.type == :(Ptr{Cvoid}) + arg.type = :(Ptr{Cfloat}) + end + end + + if node.rettype == :(Ptr{Cvoid}) + node.rettype = :(Ptr{Cfloat}) + end + end + end +end + cd(@__DIR__) include_dir = normpath(Exodus_jll.artifact_dir, "include") diff --git a/src/Blocks.jl b/src/Blocks.jl index b613c94..099d0ea 100644 --- a/src/Blocks.jl +++ b/src/Blocks.jl @@ -6,10 +6,8 @@ TODO fix this to not use void_int... use a proper type function read_block_id_map(exo::ExodusDatabase{M, I, B, F}, block_id) where {M, I, B, F} _, num_elem, _, _, _, _ = read_block_parameters(exo, block_id) block_id_map = Vector{get_map_int_type(exo)}(undef, num_elem) - error_code = @ccall libexodus.ex_get_block_id_map( - get_file_id(exo)::Cint, EX_ELEM_BLOCK::ex_entity_type, block_id::ex_entity_id, block_id_map::Ptr{B} - )::Cint - exodus_error_check(exo, error_code, "Exodus.read_element_block_id_map -> libexodus.ex_get_block_id_map") + error_code = LibExodus.ex_get_block_id_map(get_file_id(exo), EX_ELEM_BLOCK, block_id, block_id_map) + exodus_error_check(exo, error_code, "Exodus.read_element_block_id_map -> LibExodus.ex_get_block_id_map") return block_id_map end @@ -17,21 +15,20 @@ end $(TYPEDSIGNATURES) """ function read_block_parameters(exo::ExodusDatabase{M, I, B, F}, block_id::Integer) where {M, I, B, F} - num_elem = Ref{B}(0) - num_nodes = Ref{B}(0) - num_edges = Ref{B}(0) - num_faces = Ref{B}(0) - num_attributes = Ref{B}(0) - - element_type = Vector{UInt8}(undef, MAX_STR_LENGTH) - - error_code = @ccall libexodus.ex_get_block( - get_file_id(exo)::Cint, EX_ELEM_BLOCK::ex_entity_type, block_id::ex_entity_id, - element_type::Ptr{UInt8}, - num_elem::Ptr{B}, num_nodes::Ptr{B}, num_edges::Ptr{B}, - num_faces::Ptr{B}, num_attributes::Ptr{B} - )::Cint - exodus_error_check(exo, error_code, "Exodus.read_element_block_parameters -> libexodus.ex_get_block") + num_elem = Base.RefValue{B}(0) + num_nodes = Base.RefValue{B}(0) + num_edges = Base.RefValue{B}(0) + num_faces = Base.RefValue{B}(0) + num_attributes = Base.RefValue{B}(0) + element_type = Vector{Cchar}(undef, MAX_STR_LENGTH) + + error_code = LibExodus.ex_get_block( + get_file_id(exo), EX_ELEM_BLOCK, block_id, + pointer(element_type), + num_elem, num_nodes, num_edges, + num_faces, num_attributes + ) + exodus_error_check(exo, error_code, "Exodus.read_element_block_parameters -> LibExodus.ex_get_block") element_type_out = unsafe_string(pointer(element_type)) return element_type_out, num_elem[], num_nodes[], num_edges[], num_faces[], num_attributes[] end @@ -41,11 +38,11 @@ $(TYPEDSIGNATURES) """ function read_block_connectivity(exo::ExodusDatabase{M, I, B, F}, block_id::Integer, conn_length::Integer) where {M, I, B, F} conn = Vector{B}(undef, conn_length) - error_code = @ccall libexodus.ex_get_conn( - get_file_id(exo)::Cint, EX_ELEM_BLOCK::ex_entity_type, block_id::ex_entity_id, - conn::Ptr{B}, C_NULL::Ptr{Cvoid}, C_NULL::Ptr{Cvoid} - )::Cint - exodus_error_check(exo, error_code, "Exodus.read_element_block_connectivity -> libexodus.ex_get_conn") + error_code = LibExodus.ex_get_conn( + get_file_id(exo), EX_ELEM_BLOCK, block_id, + conn, C_NULL, C_NULL + ) + exodus_error_check(exo, error_code, "Exodus.read_element_block_connectivity -> LibExodus.ex_get_conn") return conn end @@ -60,11 +57,11 @@ function write_block_connectivity(exo::ExodusDatabase, block_id::Integer, conn:: # TODO currently not using face or edges, should probably be there own methods maybe? conn_face = C_NULL # Not using these currently conn_edge = C_NULL # Not using these currently - error_code = @ccall libexodus.ex_put_conn( - get_file_id(exo)::Cint, EX_ELEM_BLOCK::ex_entity_type, block_id::ex_entity_id, - conn::Ptr{void_int}, conn_face::Ptr{void_int}, conn_edge::Ptr{void_int} - )::Cint - exodus_error_check(exo, error_code, "Exodus_write_block_connectivity -> libexodus.ex_put_conn") + error_code = LibExodus.ex_put_conn( + get_file_id(exo), EX_ELEM_BLOCK, block_id, + conn, conn_face, conn_edge + ) + exodus_error_check(exo, error_code, "Exodus_write_block_connectivity -> LibExodus.ex_put_conn") end """ @@ -76,12 +73,12 @@ function read_partial_block_connectivity(exo::ExodusDatabase, block_id::I, start conn = Vector{get_bulk_int_type(exo)}(undef, num_nodes * num_ent) conn_face = Vector{get_bulk_int_type(exo)}(undef, num_nodes * num_ent) # Not using these currently conn_edge = Vector{get_bulk_int_type(exo)}(undef, num_nodes * num_ent) # Not using these currently - error_code = @ccall libexodus.ex_get_partial_conn( - get_file_id(exo)::Cint, EX_ELEM_BLOCK::ex_entity_type, block_id::ex_entity_id, - start_num::Clonglong, num_ent::Clonglong, - conn::Ptr{void_int}, conn_face::Ptr{void_int}, conn_edge::Ptr{void_int} - )::Cint - exodus_error_check(exo, error_code, "Exodus.read_partial_element_block_connectivity -> libexodus.ex_get_partial_conn") + error_code = LibExodus.ex_get_partial_conn( + get_file_id(exo), EX_ELEM_BLOCK, block_id, + start_num, num_ent, + conn, conn_face, conn_edge + ) + exodus_error_check(exo, error_code, "Exodus.read_partial_element_block_connectivity -> LibExodus.ex_get_partial_conn") return conn end @@ -89,11 +86,9 @@ end $(TYPEDSIGNATURES) """ function read_element_type(exo::ExodusDatabase, block_id::I) where I <: Integer - element_type = Vector{UInt8}(undef, MAX_STR_LENGTH) - error_code = @ccall libexodus.ex_get_elem_type( - get_file_id(exo)::Cint, block_id::ex_entity_id, element_type::Ptr{UInt8} - )::Cint - exodus_error_check(exo, error_code, "Exodus.read_element_type -> libexodus.ex_get_elem_type") + element_type = Vector{Cchar}(undef, MAX_STR_LENGTH) + error_code = LibExodus.ex_get_elem_type(get_file_id(exo), block_id, pointer(element_type)) + exodus_error_check(exo, error_code, "Exodus.read_element_type -> LibExodus.ex_get_elem_type") return unsafe_string(pointer(element_type)) end @@ -144,13 +139,13 @@ WARNING: currently does not support edges, faces and attributes """ function write_block(exo::ExodusDatabase, block::Block) - error_code = @ccall libexodus.ex_put_block( - get_file_id(exo)::Cint, EX_ELEM_BLOCK::ex_entity_type, block.id::ex_entity_id, - block.elem_type::Ptr{UInt8}, - block.num_elem::Clonglong, block.num_nodes_per_elem::Clonglong, - 0::Clonglong, 0::Clonglong, 0::Clonglong - )::Cint - exodus_error_check(exo, error_code, "Exodus.write_element_block -> libexodus.ex_put_block") + error_code = LibExodus.ex_put_block( + get_file_id(exo), EX_ELEM_BLOCK, block.id, + block.elem_type, + block.num_elem, block.num_nodes_per_elem, + 0, 0, 0 + ) + exodus_error_check(exo, error_code, "Exodus.write_element_block -> LibExodus.ex_put_block") write_block_connectivity(exo, block.id, block.conn) end @@ -160,13 +155,13 @@ $(TYPEDSIGNATURES) function write_block(exo::ExodusDatabase, block_id::Integer, elem_type::String, conn::Matrix{I}) where I <: Integer num_nodes_per_elem, num_elem = size(conn) elem_type = uppercase(elem_type) - error_code = @ccall libexodus.ex_put_block( - get_file_id(exo)::Cint, EX_ELEM_BLOCK::ex_entity_type, block_id::ex_entity_id, - elem_type::Ptr{UInt8}, - num_elem::Clonglong, num_nodes_per_elem::Clonglong, - 0::Clonglong, 0::Clonglong, 0::Clonglong - )::Cint - exodus_error_check(exo, error_code, "Exodus.write_element_block -> libexodus.ex_put_block") + error_code = LibExodus.ex_put_block( + get_file_id(exo), EX_ELEM_BLOCK, block_id, + elem_type, + num_elem, num_nodes_per_elem, + 0, 0, 0 + ) + exodus_error_check(exo, error_code, "Exodus.write_element_block -> LibExodus.ex_put_block") write_block_connectivity(exo, block_id, conn) end @@ -178,18 +173,3 @@ function write_blocks(exo::ExodusDatabase, blocks::Vector{<:Block}) write_block(exo, block) end end - -# # some tools below -# """ -# TODO reduce allocations and check for type instabilities -# """ -# function collect_block_connectivities(exo::ExodusDatabase, block_ids::Vector{<:Integer}) -# blocks = Block.((exo,), block_ids) -# conns = [block.conn for block in blocks] -# return mapreduce(permutedims, vcat, conns)' |> collect -# end - -# """ -# """ -# collect_block_connectivities(exo::ExodusDatabase) = -# collect_block_connectivities(exo, read_ids(exo, Block)) diff --git a/src/Coordinates.jl b/src/Coordinates.jl index bc466c2..77250a1 100644 --- a/src/Coordinates.jl +++ b/src/Coordinates.jl @@ -13,23 +13,23 @@ function read_coordinates(exo::ExodusDatabase) x_coords = Vector{float_type}(undef, n_nodes) y_coords = C_NULL z_coords = C_NULL - error_code = @ccall libexodus.ex_get_coord(exo.exo::Cint, x_coords::Ptr{Cvoid}, y_coords::Ptr{Cvoid}, z_coords::Ptr{Cvoid})::Cint - exodus_error_check(exo, error_code, "Exodus.read_coordinates -> libexodus.ex_get_coord") + error_code = LibExodus.ex_get_coord(get_file_id(exo), x_coords, y_coords, z_coords) + exodus_error_check(exo, error_code, "Exodus.read_coordinates -> LibExodus.ex_get_coord") coords[1, :] = x_coords elseif num_dimensions(exo.init) == 2 x_coords = Vector{float_type}(undef, n_nodes) y_coords = Vector{float_type}(undef, n_nodes) z_coords = C_NULL - error_code = @ccall libexodus.ex_get_coord(exo.exo::Cint, x_coords::Ptr{Cvoid}, y_coords::Ptr{Cvoid}, z_coords::Ptr{Cvoid})::Cint - exodus_error_check(exo, error_code, "Exodus.read_coordinates -> libexodus.ex_get_coord") + error_code = LibExodus.ex_get_coord(get_file_id(exo), x_coords, y_coords, z_coords) + exodus_error_check(exo, error_code, "Exodus.read_coordinates -> LibExodus.ex_get_coord") coords[1, :] = x_coords coords[2, :] = y_coords elseif num_dimensions(exo.init) == 3 x_coords = Vector{float_type}(undef, n_nodes) y_coords = Vector{float_type}(undef, n_nodes) z_coords = Vector{float_type}(undef, n_nodes) - error_code = @ccall libexodus.ex_get_coord(exo.exo::Cint, x_coords::Ptr{Cvoid}, y_coords::Ptr{Cvoid}, z_coords::Ptr{Cvoid})::Cint - exodus_error_check(exo, error_code, "Exodus.read_coordinates -> libexodus.ex_get_coord") + error_code = LibExodus.ex_get_coord(get_file_id(exo), x_coords, y_coords, z_coords) + exodus_error_check(exo, error_code, "Exodus.read_coordinates -> LibExodus.ex_get_coord") coords[1, :] = x_coords coords[2, :] = y_coords coords[3, :] = z_coords @@ -52,32 +52,36 @@ function read_partial_coordinates(exo::ExodusDatabase, start_node_num::I, n_node x_coords = Vector{float_type}(undef, n_nodes) y_coords = C_NULL z_coords = C_NULL - error_code = @ccall libexodus.ex_get_partial_coord( - get_file_id(exo)::Cint, start_node_num::Clonglong, n_nodes::Clonglong, - x_coords::Ptr{Cvoid}, y_coords::Ptr{Cvoid}, z_coords::Ptr{Cvoid} - )::Cint - exodus_error_check(exo, error_code, "Exodus.read_partial_coordinates -> libexodus.read_partial_coordinates") + error_code = LibExodus.ex_get_partial_coord( + get_file_id(exo), start_node_num, n_nodes, + x_coords, y_coords, z_coords + ) + error_code = LibExodus.ex_get_partial_coord( + get_file_id(exo), start_node_num, n_nodes, + x_coords, y_coords, z_coords + ) + exodus_error_check(exo, error_code, "Exodus.read_partial_coordinates -> LibExodus.read_partial_coordinates") coords[1, :] = x_coords elseif num_dim == 2 x_coords = Vector{float_type}(undef, n_nodes) y_coords = Vector{float_type}(undef, n_nodes) z_coords = C_NULL - error_code = @ccall libexodus.ex_get_partial_coord( - get_file_id(exo)::Cint, start_node_num::Clonglong, n_nodes::Clonglong, - x_coords::Ptr{Cvoid}, y_coords::Ptr{Cvoid}, z_coords::Ptr{Cvoid} - )::Cint - exodus_error_check(exo, error_code, "Exodus.read_partial_coordinates -> libexodus.read_partial_coordinates") + error_code = LibExodus.ex_get_partial_coord( + get_file_id(exo), start_node_num, n_nodes, + x_coords, y_coords, z_coords + ) + exodus_error_check(exo, error_code, "Exodus.read_partial_coordinates -> LibExodus.read_partial_coordinates") coords[1, :] = x_coords coords[2, :] = y_coords elseif num_dim == 3 x_coords = Vector{float_type}(undef, n_nodes) y_coords = Vector{float_type}(undef, n_nodes) z_coords = Vector{float_type}(undef, n_nodes) - error_code = @ccall libexodus.ex_get_partial_coord( - get_file_id(exo)::Cint, start_node_num::Clonglong, n_nodes::Clonglong, - x_coords::Ptr{Cvoid}, y_coords::Ptr{Cvoid}, z_coords::Ptr{Cvoid} - )::Cint - exodus_error_check(exo, error_code, "Exodus.read_partial_coordinates -> libexodus.read_partial_coordinates") + error_code = LibExodus.ex_get_partial_coord( + get_file_id(exo), start_node_num, n_nodes, + x_coords, y_coords, z_coords + ) + exodus_error_check(exo, error_code, "Exodus.read_partial_coordinates -> LibExodus.read_partial_coordinates") coords[1, :] = x_coords coords[2, :] = y_coords coords[3, :] = z_coords @@ -96,12 +100,12 @@ function read_partial_coordinates_component(exo::ExodusDatabase, start_node_num: coords = Vector{get_float_type(exo)}(undef, n_nodes) start_node_num = convert(Clonglong, start_node_num) - n_nodes = convert(Clonglong, n_nodes) + n_nodes = convert(Clonglong, n_nodes) component = convert(Cint, component) - error_code = @ccall libexodus.ex_get_partial_coord_component( - get_file_id(exo)::Cint, start_node_num::Clonglong, n_nodes::Clonglong, component::Cint, coords::Ptr{Cvoid} - )::Cint - exodus_error_check(exo, error_code, "Exodus.read_partial_coordinates_component -> libexodus.ex_get_partial_coord_component") + error_code = LibExodus.ex_get_partial_coord_component( + get_file_id(exo), start_node_num, n_nodes, component, coords + ) + exodus_error_check(exo, error_code, "Exodus.read_partial_coordinates_component -> LibExodus.ex_get_partial_coord_component") return coords end @@ -126,12 +130,13 @@ Returns a vector of strings """ function read_coordinate_names(exo::ExodusDatabase) num_dim = num_dimensions(exo.init) - coord_names = Vector{Vector{UInt8}}(undef, num_dim) - for n in 1:num_dim - coord_names[n] = Vector{UInt8}(undef, MAX_LINE_LENGTH) + coord_names_strs = [Vector{Cchar}(undef, MAX_LINE_LENGTH) for _ in 1:num_dim] + coord_names = Vector{Cstring}(undef, num_dim) + for n in eachindex(coord_names) + coord_names[n] = pointer(coord_names_strs[n]) end - error_code = @ccall libexodus.ex_get_coord_names(get_file_id(exo)::Cint, coord_names::Ptr{Ptr{UInt8}})::Cint - exodus_error_check(exo, error_code, "Exodus.read_coordinate_names -> libexodus.ex_get_coord_names") + error_code = LibExodus.ex_get_coord_names(get_file_id(exo), coord_names) + exodus_error_check(exo, error_code, "Exodus.read_coordinate_names -> LibExodus.ex_get_coord_names") new_coord_names = Vector{String}(undef, num_dimensions(exo.init)) for n in 1:num_dimensions(exo.init) new_coord_names[n] = unsafe_string(pointer(coord_names[n])) @@ -175,10 +180,10 @@ function write_coordinates(exo::ExodusDatabase, coords::VecOrMat{F}) where {F <: y_coords = coords[2, :] z_coords = coords[3, :] end - error_code = @ccall libexodus.ex_put_coord( - get_file_id(exo)::Cint, x_coords::Ptr{Cvoid}, y_coords::Ptr{Cvoid}, z_coords::Ptr{Cvoid} - )::Cint - exodus_error_check(exo, error_code, "Exodus.write_coordinates -> libexodus.ex_put_coord") + error_code = LibExodus.ex_put_coord( + get_file_id(exo), x_coords, y_coords, z_coords + ) + exodus_error_check(exo, error_code, "Exodus.write_coordinates -> LibExodus.ex_put_coord") end """ @@ -186,8 +191,9 @@ $(TYPEDSIGNATURES) Method to write coordinate names, e.g. x, y, z """ function write_coordinate_names(exo::ExodusDatabase, coord_names::Vector{String}) - error_code = @ccall libexodus.ex_put_coord_names(get_file_id(exo)::Cint, coord_names::Ptr{Ptr{UInt8}})::Cint - exodus_error_check(exo, error_code, "Exodus.write_coordinate_names -> libexodus.ex_put_coord_names") + # error_code = @ccall LibExodus.ex_put_coord_names(get_file_id(exo)::Cint, coord_names::Ptr{Ptr{UInt8}})::Cint + error_code = LibExodus.ex_put_coord_names(get_file_id(exo), coord_names) + exodus_error_check(exo, error_code, "Exodus.write_coordinate_names -> LibExodus.ex_put_coord_names") end """ @@ -211,11 +217,11 @@ function write_partial_coordinates(exo::ExodusDatabase, start_node_num::I, coord z_coords = coords[3, :] n_nodes = size(coords, 2) end - error_code = @ccall libexodus.ex_put_partial_coord( - get_file_id(exo)::Cint, start_node_num::Clonglong, n_nodes::Clonglong, - x_coords::Ptr{Cvoid}, y_coords::Ptr{Cvoid}, z_coords::Ptr{Cvoid} - )::Cint - exodus_error_check(exo, error_code, "Exodus.write_partial_coordinates -> libexodus.ex_put_partial_coord") + error_code = LibExodus.ex_put_partial_coord( + get_file_id(exo), start_node_num, n_nodes, + x_coords, y_coords, z_coords + ) + exodus_error_check(exo, error_code, "Exodus.write_partial_coordinates -> LibExodus.ex_put_partial_coord") end """ @@ -223,11 +229,10 @@ $(TYPEDSIGNATURES) """ function write_partial_coordinates_component(exo::ExodusDatabase, start_node_num::I, component::I, coords::Vector{F}) where {I <: Integer, F <: AbstractFloat} coords = convert(Vector{get_float_type(exo)}, coords) - error_code = @ccall libexodus.ex_put_partial_coord_component( - get_file_id(exo)::Cint, start_node_num::Clonglong, length(coords)::Clonglong, component::Cint, - coords::Ptr{Cvoid} - )::Cint - exodus_error_check(exo, error_code, "Exodus.write_partial_coordinates_component -> libexodus.ex_put_partial_coord_component") + error_code = LibExodus.ex_put_partial_coord_component( + get_file_id(exo), start_node_num, length(coords), component, coords + ) + exodus_error_check(exo, error_code, "Exodus.write_partial_coordinates_component -> LibExodus.ex_put_partial_coord_component") end """ diff --git a/src/ExodusTypes.jl b/src/ExodusTypes.jl index 9afa3f8..08cf177 100644 --- a/src/ExodusTypes.jl +++ b/src/ExodusTypes.jl @@ -1,28 +1,15 @@ -# types for convenience -# -""" - void_int = Cvoid -""" -const void_int = Cvoid - -""" -""" -const ex_entity_id = Clonglong - """ """ function set_exodus_options(options::T) where T - error_code = @ccall libexodus.ex_opts(options::Cint)::Cint - exodus_error_check(error_code, "Exodus.set_exodus_options -> libexodus.ex_opts") + error_code = LibExodus.ex_opts(options) + exodus_error_check(error_code, "Exodus.set_exodus_options -> LibExodus.ex_opts") end """ $(TYPEDSIGNATURES) """ function set_exodus_max_name_length(exoid::Cint, len::Cint) - error_code = @ccall libexodus.ex_set_max_name_length( - exoid::Cint, len::Cint - )::Cint + error_code = LibExodus.ex_set_max_name_length(exoid, len) exodus_error_check(exoid, error_code, "ex_set_max_name_length") end @@ -31,7 +18,7 @@ end $(TYPEDSIGNATURES) """ function map_int_mode(exo::Cint) - int64_status = @ccall libexodus.ex_int64_status(exo::Cint)::UInt32 + int64_status = LibExodus.ex_int64_status(exo) if int64_status == 0x00000000 M, I, B = Cint, Cint, Cint elseif int64_status == EX_MAPS_INT64_API @@ -56,7 +43,7 @@ end $(TYPEDSIGNATURES) """ function id_int_mode(exo::Cint) - int64_status = @ccall libexodus.ex_int64_status(exo::Cint)::UInt32 + int64_status = LibExodus.ex_int64_status(exo) if int64_status == 0x00000000 M, I, B = Cint, Cint, Cint elseif int64_status == EX_MAPS_INT64_API @@ -81,7 +68,7 @@ end $(TYPEDSIGNATURES) """ function bulk_int_mode(exo::Cint) - int64_status = @ccall libexodus.ex_int64_status(exo::Cint)::UInt32 + int64_status = LibExodus.ex_int64_status(exo) if int64_status == 0x00000000 M, I, B = Cint, Cint, Cint elseif int64_status == EX_MAPS_INT64_API @@ -106,7 +93,7 @@ end $(TYPEDSIGNATURES) """ function float_mode(exo::Cint) - float_size = @ccall libexodus.ex_inquire_int(exo::Cint, EX_INQ_DB_FLOAT_SIZE::ex_inquiry)::Cint + float_size = LibExodus.ex_inquire_int(exo, EX_INQ_DB_FLOAT_SIZE) if float_size == 4 F = Cfloat elseif float_size == 8 @@ -140,21 +127,20 @@ end $(TYPEDSIGNATURES) """ function Initialization(exo::Cint, ::Type{B}) where B - num_dim = Ref{B}(0) - num_nodes = Ref{B}(0) - num_elems = Ref{B}(0) - num_elem_blks = Ref{B}(0) - num_node_sets = Ref{B}(0) - num_side_sets = Ref{B}(0) - title = Vector{UInt8}(undef, MAX_LINE_LENGTH) - - error_code = @ccall libexodus.ex_get_init( - exo::Cint, - title::Ptr{UInt8}, - num_dim::Ptr{B}, num_nodes::Ptr{B}, num_elems::Ptr{B}, - num_elem_blks::Ptr{B}, num_node_sets::Ptr{B}, num_side_sets::Ptr{B} - )::Cint - exodus_error_check(exo, error_code, "Exodus.Initialization -> libexodus.ex_get_init") + num_dim = Base.RefValue{B}(0) + num_nodes = Base.RefValue{B}(0) + num_elems = Base.RefValue{B}(0) + num_elem_blks = Base.RefValue{B}(0) + num_node_sets = Base.RefValue{B}(0) + num_side_sets = Base.RefValue{B}(0) + title = Vector{Cchar}(undef, MAX_LINE_LENGTH) + + error_code = LibExodus.ex_get_init( + exo, pointer(title), + num_dim, num_nodes, num_elems, + num_elem_blks, num_node_sets, num_side_sets + ) + exodus_error_check(exo, error_code, "Exodus.Initialization -> LibExodus.ex_get_init") title = unsafe_string(pointer(title)) @@ -208,13 +194,13 @@ Used to set up a exodus database in write mode The ccall signatures should reall be B (bulk int type of exo) instead of Clonglong """ function write_initialization!(exoid::Cint, init::Initialization) - title = Vector{UInt8}(undef, MAX_LINE_LENGTH) - error_code = @ccall libexodus.ex_put_init( - exoid::Cint, title::Ptr{UInt8}, - num_dimensions(init)::Clonglong, num_nodes(init)::Clonglong, num_elements(init)::Clonglong, - num_element_blocks(init)::Clonglong, num_node_sets(init)::Clonglong, num_side_sets(init)::Clonglong - )::Cint - exodus_error_check(exoid, error_code, "Exodus.write_initialization! -> libexodus.ex_put_init") + title = Vector{Cchar}(undef, MAX_LINE_LENGTH) + error_code = LibExodus.ex_put_init( + exoid, pointer(title), + num_dimensions(init), num_nodes(init), num_elements(init), + num_element_blocks(init), num_node_sets(init), num_side_sets(init) + ) + exodus_error_check(exoid, error_code, "Exodus.write_initialization! -> LibExodus.ex_put_init") end # sets and blocks @@ -514,19 +500,19 @@ function open_exodus_file(file_name::String, mode) end if mode == "w" && !isfile(file_name) - exo = @ccall libexodus.ex_create_int( - file_name::Cstring, EX_WRITE::Cint, - cpu_word_size::Ref{Cint}, IO_word_size::Ref{Cint}, - EX_API_VERS_NODOT::Cint - )::Cint - exodus_error_check(exo, "Exodus.ExodusDatabase -> libexodus.ex_create_int") + exo = LibExodus.ex_create_int( + file_name, EX_WRITE, + Base.RefValue(cpu_word_size), Base.RefValue(IO_word_size), + EX_API_VERS_NODOT + ) + exodus_error_check(exo, "Exodus.ExodusDatabase -> LibExodus.ex_create_int") else - exo = @ccall libexodus.ex_open_int( - file_name::Cstring, ex_mode::Cint, - cpu_word_size::Ref{Cint}, IO_word_size::Ref{Cint}, - version_number::Ref{Cfloat}, EX_API_VERS_NODOT::Cint - )::Cint - exodus_error_check(exo, "Exodus.ExodusDatabase -> libexodus.ex_open_int") + exo = LibExodus.ex_open_int( + file_name, ex_mode, + Base.RefValue(cpu_word_size), Base.RefValue(IO_word_size), + Base.RefValue(version_number), EX_API_VERS_NODOT + ) + exodus_error_check(exo, "Exodus.ExodusDatabase -> LibExodus.ex_open_int") end return exo end @@ -599,12 +585,12 @@ function ExodusDatabase{M, I, B, F}( end # trying out different float sizes - exo = @ccall libexodus.ex_create_int( - file_name::Cstring, EX_WRITE::Cint, - cpu_word_size::Ref{Cint}, sizeof(F)::Ref{Cint}, - EX_API_VERS_NODOT::Cint - )::Cint - exodus_error_check(exo, "Exodus.ExodusDatabase -> libexodus.ex_create_int") + exo = LibExodus.ex_create_int( + file_name, EX_WRITE, + Base.RefValue(cpu_word_size), Base.RefValue(Int32(sizeof(F))), + EX_API_VERS_NODOT + ) + exodus_error_check(exo, "Exodus.ExodusDatabase -> LibExodus.ex_create_int") int_modes = 0x00000000 if M == Int64 @@ -620,8 +606,8 @@ function ExodusDatabase{M, I, B, F}( end if int_modes != 0x00000000 - err = @ccall libexodus.ex_set_int64_status(exo::Cint, int_modes::Cint)::Cint - exodus_error_check(exo, err, "Exodus.ExodusDatabase -> libexodus.ex_set_int64_status") + err = LibExodus.ex_set_int64_status(exo, int_modes) + exodus_error_check(exo, err, "Exodus.ExodusDatabase -> LibExodus.ex_set_int64_status") end write_initialization!(exo, init) @@ -691,8 +677,8 @@ $(TYPEDSIGNATURES) Used to close and ExodusDatabase. """ function Base.close(exo::ExodusDatabase) - error_code = @ccall libexodus.ex_close(get_file_id(exo)::Cint)::Cint - exodus_error_check(exo, error_code, "Exodus.close -> libexodus.ex_close") + error_code = LibExodus.ex_close(get_file_id(exo)) + exodus_error_check(exo, error_code, "Exodus.close -> LibExodus.ex_close") end """ @@ -702,20 +688,23 @@ for output. Not all of the put methods have been wrapped and properly tested. Th """ function Base.copy(exo::E, new_file_name::String; mesh_only_flag::Bool=true) where {E <: ExodusDatabase} mesh_only = mesh_only_flag |> Cint - int64_status = @ccall libexodus.ex_int64_status(get_file_id(exo)::Cint)::UInt32 + int64_status = LibExodus.ex_int64_status(get_file_id(exo)) # TODO maybe make options an optional argument options = EX_CLOBBER | int64_status - new_exo_id = @ccall libexodus.ex_create_int( - new_file_name::Cstring, options::Cint, cpu_word_size::Ref{Cint}, IO_word_size::Ref{Cint}, EX_API_VERS_NODOT::Cint - )::Cint - exodus_error_check(exo, new_exo_id, "Exodus.copy -> libexodus.ex_create_int") + new_exo_id = LibExodus.ex_create_int( + new_file_name, options, + Base.RefValue(cpu_word_size), Base.RefValue(IO_word_size), + EX_API_VERS_NODOT + ) + exodus_error_check(exo, new_exo_id, "Exodus.copy -> LibExodus.ex_create_int") # first make a copy - # error_code = @ccall libexodus.ex_copy(get_file_id(exo)::Cint, new_exo_id::Cint)::Cint + # TODO + # NOTE this one is weridly not being generated in the wrapper... error_code = @ccall libexodus.ex_copy(get_file_id(exo)::Cint, new_exo_id::Cint, mesh_only::Cint)::Cint exodus_error_check(exo, error_code, "Exodus.copy -> libexodus.ex_copy") # now close the exodus file - error_code = @ccall libexodus.ex_close(new_exo_id::Cint)::Cint - exodus_error_check(new_exo_id, error_code, "Exodus.close -> libexodus.ex_close") + error_code = LibExodus.ex_close(new_exo_id) + exodus_error_check(new_exo_id, error_code, "Exodus.close -> LibExodus.ex_close") end """ @@ -915,7 +904,6 @@ function Block(exo::ExodusDatabase, block_id::Integer) conn_out[:, e] = @views conn[(e - 1) * num_nodes + 1:e * num_nodes] end - # return Block{get_id_int_type(exo), get_bulk_int_type(exo)}(block_id, num_elem, num_nodes, element_type, conn_out) return Block{get_id_int_type(exo), typeof(conn_out)}(block_id, num_elem, num_nodes, element_type, conn_out) end @@ -950,8 +938,6 @@ function NodeSet(exo::ExodusDatabase{M, I, B, F}, id::Integer) where {M, I, B, F nodes = copy(nodes) # need to copy here to be safe - # return NodeSet{I, B}(id, nodes) - # return NodeSet{I, typeof(nodes)}(id, nodes) return NodeSet(id, nodes) end @@ -996,7 +982,6 @@ function SideSet(exo::ExodusDatabase{M, I, B, F}, id::Integer) where {M, I, B, F elements = copy(elements) sides = copy(sides) - # return SideSet{I, B}(id, elements, sides) return SideSet{I, typeof(elements)}(id, elements, sides, num_nodes_per_side, side_nodes) end diff --git a/src/Info.jl b/src/Info.jl index 9cd55e8..1682659 100644 --- a/src/Info.jl +++ b/src/Info.jl @@ -2,17 +2,14 @@ $(TYPEDSIGNATURES) """ function read_info(exo::ExodusDatabase) - num_info = @ccall libexodus.ex_inquire_int( - get_file_id(exo)::Cint, EX_INQ_INFO::ex_inquiry - )::Cint - info = Vector{Vector{UInt8}}(undef, num_info) - for n in eachindex(info) - info[n] = Vector{UInt8}(undef, MAX_LINE_LENGTH) + num_info = LibExodus.ex_inquire_int(get_file_id(exo), EX_INQ_INFO) + info_strs = [Vector{Cchar}(undef, MAX_LINE_LENGTH) for _ in 1:num_info] + info = Vector{Cstring}(undef, num_info) + for n in eachindex(info_strs) + info[n] = pointer(info_strs[n]) end - error_code = @ccall libexodus.ex_get_info( - get_file_id(exo)::Cint, info::Ptr{Ptr{UInt8}} - )::Cint - exodus_error_check(exo, error_code, "Exodus.read_info -> libexodus.ex_get_info") + error_code = LibExodus.ex_get_info(get_file_id(exo), info) + exodus_error_check(exo, error_code, "Exodus.read_info -> LibExodus.ex_get_info") new_info = Vector{String}(undef, num_info) for n in eachindex(info) new_info[n] = unsafe_string(pointer(info[n])) @@ -24,8 +21,6 @@ end $(TYPEDSIGNATURES) """ function write_info(exo::ExodusDatabase, info::Vector{String}) - error_code = @ccall libexodus.ex_put_info( - get_file_id(exo)::Cint, length(info)::Cint, info::Ptr{Ptr{UInt8}} - )::Cint - exodus_error_check(exo, error_code, "Exodus.write_info -> libexodus.ex_put_info") + error_code = LibExodus.ex_put_info(get_file_id(exo), length(info), info) + exodus_error_check(exo, error_code, "Exodus.write_info -> LibExodus.ex_put_info") end diff --git a/src/Maps.jl b/src/Maps.jl index 61ccaac..3ebf16f 100644 --- a/src/Maps.jl +++ b/src/Maps.jl @@ -4,8 +4,8 @@ TODO change to not use void_int """ function read_map(exo::ExodusDatabase{M, I, B, F}) where {M, I, B, F} elem_map = Vector{M}(undef, num_elements(exo.init)) - error_code = @ccall libexodus.ex_get_map(get_file_id(exo)::Cint, elem_map::Ptr{void_int})::Cint - exodus_error_check(exo, error_code, "Exodus.read_element_map -> libexodus.ex_get_map") + error_code = LibExodus.ex_get_map(get_file_id(exo), elem_map) + exodus_error_check(exo, error_code, "Exodus.read_element_map -> LibExodus.ex_get_map") return elem_map end @@ -22,32 +22,27 @@ function read_id_map( num_ids = num_elements(exo.init) end - map = Vector{M}(undef, num_ids) - - error = @ccall libexodus.ex_get_id_map( - exo.exo::Cint, entity_type(type)::ex_entity_type, map::Ptr{M} - )::Cint + id_map = Vector{M}(undef, num_ids) + error = LibExodus.ex_get_id_map(get_file_id(exo), entity_type(type), id_map) exodus_error_check(exo, error, "read_id_map -> ex_get_id_map") - return map + return id_map end """ $(TYPEDSIGNATURES) """ function write_id_map( - exo::ExodusDatabase{M, I, B, F}, type::Type{MAP}, map::Vector{M} + exo::ExodusDatabase{M, I, B, F}, type::Type{MAP}, id_map::Vector{M} ) where {M, I, B, F, MAP <: AbstractExodusMap} if type <: NodeMap - @assert length(map) == num_nodes(exo.init) + @assert length(id_map) == num_nodes(exo.init) elseif type <: ElementMap - @assert length(map) == num_elements(exo.init) + @assert length(id_map) == num_elements(exo.init) end - error = @ccall libexodus.ex_put_id_map( - exo.exo::Cint, entity_type(type)::ex_entity_type, map::Ptr{M} - )::Cint + error = LibExodus.ex_put_id_map(get_file_id(exo), entity_type(type), id_map) exodus_error_check(exo, error, "write_id_map -> ex_put_id_map") end @@ -69,7 +64,7 @@ end # # map = Vector{M}(undef, 1) # map = Vector{Int64}(undef, num_vals) -# error = @ccall libexodus.ex_get_num_map( +# error = @ccall LibExodus.ex_get_num_map( # exo.exo::Cint, entity_type(type)::ex_entity_type, id::ex_entity_id, # # map::Ptr{void_int} # map::Ptr{Int64} diff --git a/src/ParallelExodus.jl b/src/ParallelExodus.jl index 0c2735d..62f27a6 100644 --- a/src/ParallelExodus.jl +++ b/src/ParallelExodus.jl @@ -2,13 +2,13 @@ $(TYPEDSIGNATURES) """ function read_init_info(exo::ExodusDatabase) - num_proc = Ref{Cint}(0) - num_proc_in_f = Ref{Cint}(0) - ftype = Vector{UInt8}(undef, MAX_STR_LENGTH) - error_code = @ccall libexodus.ex_get_init_info( - get_file_id(exo)::Cint, num_proc::Ptr{Cint}, num_proc_in_f::Ptr{Cint}, ftype::Ptr{UInt8} - )::Cint - exodus_error_check(exo, error_code, "Exodus.ParallelExodusDatabase -> libexodus.ex_get_init_info") + num_proc = Base.RefValue{Cint}(0) + num_proc_in_f = Base.RefValue{Cint}(0) + ftype = Vector{Cchar}(undef, MAX_STR_LENGTH) + error_code = LibExodus.ex_get_init_info( + get_file_id(exo), num_proc, num_proc_in_f, pointer(ftype) + ) + exodus_error_check(exo, error_code, "Exodus.ParallelExodusDatabase -> LibExodus.ex_get_init_info") return num_proc[], num_proc_in_f[], unsafe_string(pointer(ftype)) end @@ -16,16 +16,16 @@ end $(TYPEDSIGNATURES) """ function InitializationGlobal(exo::ExodusDatabase{M, I, B, F}) where {M, I, B, F} - num_nodes = Ref{B}(0) - num_elem = Ref{B}(0) - num_elem_blk = Ref{B}(0) - num_node_sets = Ref{B}(0) - num_side_sets = Ref{B}(0) - error_code = @ccall libexodus.ex_get_init_global( - get_file_id(exo)::Cint, num_nodes::Ptr{Cint}, num_elem::Ptr{Cint}, - num_elem_blk::Ptr{Cint}, num_node_sets::Ptr{Cint}, num_side_sets::Ptr{Cint} - )::Cint - exodus_error_check(exo, error_code, "Exodus.read_init_global -> libexodus.ex_get_init_global") + num_nodes = Base.RefValue{B}(0) + num_elem = Base.RefValue{B}(0) + num_elem_blk = Base.RefValue{B}(0) + num_node_sets = Base.RefValue{B}(0) + num_side_sets = Base.RefValue{B}(0) + error_code = LibExodus.ex_get_init_global( + get_file_id(exo), num_nodes, num_elem, + num_elem_blk, num_node_sets, num_side_sets + ) + exodus_error_check(exo, error_code, "Exodus.read_init_global -> LibExodus.ex_get_init_global") return Initialization{B}( num_dimensions(exo.init), num_nodes[], num_elem[], num_elem_blk[], num_node_sets[], num_side_sets[] @@ -66,21 +66,21 @@ print( $(TYPEDSIGNATURES) """ function LoadBalanceParameters(exo::ExodusDatabase{M, I, B, F}, processor::Itype) where {M, I, B, F, Itype <: Integer} - num_int_nodes = Ref{B}(0) - num_bor_nodes = Ref{B}(0) - num_ext_nodes = Ref{B}(0) - num_int_elems = Ref{B}(0) - num_bor_elems = Ref{B}(0) - num_node_cmaps = Ref{B}(0) - num_elem_cmaps = Ref{B}(0) - error_code = @ccall libexodus.ex_get_loadbal_param( - get_file_id(exo)::Cint, - num_int_nodes::Ptr{B}, num_bor_nodes::Ptr{B}, num_ext_nodes::Ptr{B}, - num_int_elems::Ptr{B}, num_bor_elems::Ptr{B}, - num_node_cmaps::Ptr{B}, num_elem_cmaps::Ptr{B}, - processor::Cint - )::Cint - exodus_error_check(exo, error_code, "Exodus.LoadBalanceParameters -> libexodus.ex_get_loadbal_param") + num_int_nodes = Base.RefValue{B}(0) + num_bor_nodes = Base.RefValue{B}(0) + num_ext_nodes = Base.RefValue{B}(0) + num_int_elems = Base.RefValue{B}(0) + num_bor_elems = Base.RefValue{B}(0) + num_node_cmaps = Base.RefValue{B}(0) + num_elem_cmaps = Base.RefValue{B}(0) + error_code = LibExodus.ex_get_loadbal_param( + get_file_id(exo), + num_int_nodes, num_bor_nodes, num_ext_nodes, + num_int_elems, num_bor_elems, + num_node_cmaps, num_elem_cmaps, + processor + ) + exodus_error_check(exo, error_code, "Exodus.LoadBalanceParameters -> LibExodus.ex_get_loadbal_param") return LoadBalanceParameters{B}( num_int_nodes[], num_bor_nodes[], num_ext_nodes[], num_int_elems[], num_bor_elems[], @@ -119,13 +119,13 @@ function CommunicationMapParameters(exo::ExodusDatabase{M, I, B, F}, lb_params:: node_cmap_node_cnts = Vector{B}(undef, lb_params.num_node_cmaps) elem_cmap_ids = Vector{B}(undef, lb_params.num_elem_cmaps) elem_cmap_elem_cnts = Vector{B}(undef, lb_params.num_elem_cmaps) - error_code = @ccall libexodus.ex_get_cmap_params( - get_file_id(exo)::Cint, - node_cmap_ids::Ptr{B}, node_cmap_node_cnts::Ptr{B}, - elem_cmap_ids::Ptr{B}, elem_cmap_elem_cnts::Ptr{B}, - processor::Cint - )::Cint - exodus_error_check(exo, error_code, "Exodus.CommunicationMapParameters -> libexodus.ex_get_cmap_params") + error_code = LibExodus.ex_get_cmap_params( + get_file_id(exo), + node_cmap_ids, node_cmap_node_cnts, + elem_cmap_ids, elem_cmap_elem_cnts, + processor + ) + exodus_error_check(exo, error_code, "Exodus.CommunicationMapParameters -> LibExodus.ex_get_cmap_params") return CommunicationMapParameters{B}( node_cmap_ids .+ 1, node_cmap_node_cnts, elem_cmap_ids .+ 1, elem_cmap_elem_cnts @@ -150,12 +150,11 @@ function NodeCommunicationMap(exo::ExodusDatabase{M, I, B, F}, node_map_id, node node_ids = Vector{B}(undef, node_cnt) proc_ids = Vector{B}(undef, node_cnt) - error_code = @ccall libexodus.ex_get_node_cmap( - get_file_id(exo)::Cint, (node_map_id - 1)::Clonglong, # really ex_entity_id - node_ids::Ptr{B}, proc_ids::Ptr{B}, - processor::Cint - )::Cint - exodus_error_check(exo, error_code, "Exodus.NodeCommunicationMap -> libexodus.ex_get_node_cmap") + error_code = LibExodus.ex_get_node_cmap( + get_file_id(exo), (node_map_id - 1), + node_ids, proc_ids, processor + ) + exodus_error_check(exo, error_code, "Exodus.NodeCommunicationMap -> LibExodus.ex_get_node_cmap") return NodeCommunicationMap{B}(node_ids, proc_ids .+ 1) # note adding 1 to proc ids to make them julia indexed end @@ -179,12 +178,12 @@ function ElementCommunicationMap(exo::ExodusDatabase{M, I, B, F}, elem_map_id::I side_ids = Vector{B}(undef, elem_cnt) proc_ids = Vector{B}(undef, elem_cnt) - error_code = @ccall libexodus.ex_get_elem_cmap( - get_file_id(exo)::Cint, (elem_map_id - 1)::Clonglong, # really ex_entity_id - elem_ids::Ptr{B}, side_ids::Ptr{B}, proc_ids::Ptr{B}, - processor::Cint - )::Cint - exodus_error_check(exo, error_code, "Exodus.ElementCommunicationMap -> libexodus.ex_get_elem_cmap") + error_code = LibExodus.ex_get_elem_cmap( + get_file_id(exo), (elem_map_id - 1), + elem_ids, side_ids, proc_ids, + processor + ) + exodus_error_check(exo, error_code, "Exodus.ElementCommunicationMap -> LibExodus.ex_get_elem_cmap") return ElementCommunicationMap{B}(elem_ids, side_ids, proc_ids .+ 1) # note adding 1 to proc ids to make them julia indexed end @@ -207,13 +206,13 @@ function ProcessorNodeMaps(exo::ExodusDatabase{M, I, B, F}, processor::Itype) wh node_map_internal = Vector{B}(undef, lb_params.num_int_nodes) node_map_border = Vector{B}(undef, lb_params.num_bor_nodes) node_map_external = Vector{B}(undef, lb_params.num_ext_nodes) - - error_code = @ccall libexodus.ex_get_processor_node_maps( - get_file_id(exo)::Cint, - node_map_internal::Ptr{B}, node_map_border::Ptr{B}, node_map_external::Ptr{B}, - processor::Cint - )::Cint - exodus_error_check(exo, error_code, "Exodus.ProcessorNodeMap -> libexodus.ex_get_processor_node_maps") + + error_code = LibExodus.ex_get_processor_node_maps( + get_file_id(exo), + node_map_internal, node_map_border, node_map_external, + processor + ) + exodus_error_check(exo, error_code, "Exodus.ProcessorNodeMap -> LibExodus.ex_get_processor_node_maps") return ProcessorNodeMaps{B}(node_map_internal, node_map_border, node_map_external) end @@ -235,11 +234,10 @@ function ProcessorElementMaps(exo::ExodusDatabase{M, I, B, F}, processor::Itype) elem_map_internal = Vector{B}(undef, lb_params.num_int_elems) elem_map_border = Vector{B}(undef, lb_params.num_bor_elems) - error_code = @ccall libexodus.ex_get_processor_elem_maps( - get_file_id(exo)::Cint, - elem_map_internal::Ptr{B}, elem_map_border::Ptr{B}, - processor::Cint - )::Cint - exodus_error_check(exo, error_code, "Exodus.ProcessorElementMaps -> libexodus.ex_get_processor_elem_maps") + error_code = LibExodus.ex_get_processor_elem_maps( + get_file_id(exo), + elem_map_internal, elem_map_border, processor + ) + exodus_error_check(exo, error_code, "Exodus.ProcessorElementMaps -> LibExodus.ex_get_processor_elem_maps") return ProcessorElementMaps{B}(elem_map_internal, elem_map_border) end diff --git a/src/QA.jl b/src/QA.jl index 474f011..a2b9e52 100644 --- a/src/QA.jl +++ b/src/QA.jl @@ -2,24 +2,25 @@ $(TYPEDSIGNATURES) """ function read_qa(exo::ExodusDatabase) - num_qa_rec = @ccall libexodus.ex_inquire_int( - get_file_id(exo)::Cint, EX_INQ_QA::ex_inquiry - )::Cint - qa_record = Matrix{Vector{UInt8}}(undef, num_qa_rec, 4) - for i in 1:num_qa_rec - for j in 1:4 - qa_record[i, j] = Vector{UInt8}(undef, MAX_STR_LENGTH) - end + num_qa_rec = LibExodus.ex_inquire_int(get_file_id(exo), EX_INQ_QA) + qa_record = Vector{NTuple{4, Cstring}}(undef, num_qa_rec) + for n in eachindex(qa_record) + qa_record[n] = ( + pointer(Vector{Cchar}(undef, MAX_STR_LENGTH)), + pointer(Vector{Cchar}(undef, MAX_STR_LENGTH)), + pointer(Vector{Cchar}(undef, MAX_STR_LENGTH)), + pointer(Vector{Cchar}(undef, MAX_STR_LENGTH)) + ) end - error_code = @ccall libexodus.ex_get_qa( - get_file_id(exo)::Cint, qa_record::Ptr{Ptr{UInt8}} - )::Cint - exodus_error_check(exo, error_code, "Exodus.read_qa -> libexodus.ex_get_qa") + error_code = LibExodus.ex_get_qa( + get_file_id(exo), qa_record + ) + exodus_error_check(exo, error_code, "Exodus.read_qa -> LibExodus.ex_get_qa") new_qa_record = Matrix{String}(undef, num_qa_rec, 4) for i in 1:num_qa_rec for j in 1:4 - new_qa_record[i, j] = unsafe_string(pointer(qa_record[i, j])) + new_qa_record[i, j] = unsafe_string(qa_record[i][j]) end end return new_qa_record @@ -30,8 +31,18 @@ $(TYPEDSIGNATURES) """ function write_qa(exo::ExodusDatabase, qa_record::Matrix{String}) num_qa_records = size(qa_record, 1) - error_code = @ccall libexodus.ex_put_qa( - get_file_id(exo)::Cint, num_qa_records::Cint, qa_record::Ptr{Ptr{UInt8}} - )::Cint - exodus_error_check(exo, error_code, "Exodus.write_qa -> libexodus.ex_put_qa") + qa_ptrs = Vector{NTuple{4, Cstring}}(undef, num_qa_records) + for i in 1:num_qa_records + qa_ptrs[i] = ( + pointer(qa_record[i,1]), + pointer(qa_record[i,2]), + pointer(qa_record[i,3]), + pointer(qa_record[i,4]), + ) + end + + error_code = LibExodus.ex_put_qa( + get_file_id(exo), num_qa_records, qa_ptrs + ) + exodus_error_check(exo, error_code, "Exodus.write_qa -> LibExodus.ex_put_qa") end diff --git a/src/Sets.jl b/src/Sets.jl index 715d51e..de44af5 100644 --- a/src/Sets.jl +++ b/src/Sets.jl @@ -4,10 +4,8 @@ $(TYPEDSIGNATURES) function read_ids(exo::ExodusDatabase{M, I, B, F}, ::Type{S}) where {M, I, B, F, S <: AbstractExodusSet} num_entries = num_sets(exo, S)::B ids = Vector{B}(undef, num_entries) - error_code = @ccall libexodus.ex_get_ids( - get_file_id(exo)::Cint, entity_type(S)::ex_entity_type, ids::Ptr{B} - )::Cint - exodus_error_check(exo, error_code, "Exodus.read_set_ids -> libexodus.ex_get_ids") + error_code = LibExodus.ex_get_ids(get_file_id(exo), entity_type(S), ids) + exodus_error_check(exo, error_code, "Exodus.read_set_ids -> LibExodus.ex_get_ids") return ids end @@ -15,12 +13,9 @@ end $(TYPEDSIGNATURES) """ function read_name(exo::ExodusDatabase, ::Type{S}, id::Integer) where S <: AbstractExodusSet - name = Vector{UInt8}(undef, MAX_STR_LENGTH) - error_code = @ccall libexodus.ex_get_name( - get_file_id(exo)::Cint, entity_type(S)::ex_entity_type, - id::ex_entity_id, name::Ptr{UInt8} - )::Cint - exodus_error_check(exo, error_code, "Exodus.read_name -> libexodus.ex_get_name") + name = Vector{Cchar}(undef, MAX_STR_LENGTH) + error_code = LibExodus.ex_get_name(get_file_id(exo), entity_type(S), id, pointer(name)) + exodus_error_check(exo, error_code, "Exodus.read_name -> LibExodus.ex_get_name") return unsafe_string(pointer(name)) end @@ -45,13 +40,13 @@ function read_set_parameters( set_id::Integer, ::Type{S} ) where {M, I, B, F, S <: Union{NodeSet, SideSet}} # TODO there's other sets this method can support - num_entries = Ref{I}(0) - num_df = Ref{I}(0) - error_code = @ccall libexodus.ex_get_set_param( - get_file_id(exo)::Cint, entity_type(S)::ex_entity_type, set_id::Clonglong, # set_id is really an ex_entity_id but that is weirdly causing a type instability - num_entries::Ptr{I}, num_df::Ptr{I} - )::Cint - exodus_error_check(exo, error_code, "Exodus.read_set_parameters -> libexodus.ex_get_set_param") + num_entries = Base.RefValue{I}(0) + num_df = Base.RefValue{I}(0) + error_code = LibExodus.ex_get_set_param( + get_file_id(exo), entity_type(S), + set_id, num_entries, num_df + ) + exodus_error_check(exo, error_code, "Exodus.read_set_parameters -> LibExodus.ex_get_set_param") return num_entries[], num_df[] end @@ -62,11 +57,11 @@ function read_node_set_nodes(exo::ExodusDatabase{M, I, B, F}, set_id::Integer) w num_entries, _ = read_set_parameters(exo, set_id, NodeSet) entries = Vector{B}(undef, num_entries) extras = C_NULL - error_code = @ccall libexodus.ex_get_set( - get_file_id(exo)::Cint, EX_NODE_SET::ex_entity_type, set_id::Clonglong, # set id is really a ex_entity_id but it's weirldy throwing a type instability - entries::Ptr{B}, extras::Ptr{Cvoid} - )::Cint - exodus_error_check(exo, error_code, "Exodus.read_node_set_nodes -> libexodus.ex_get_set") + error_code = LibExodus.ex_get_set( + get_file_id(exo), EX_NODE_SET, set_id, + entries, extras + ) + exodus_error_check(exo, error_code, "Exodus.read_node_set_nodes -> LibExodus.ex_get_set") return entries end @@ -77,11 +72,11 @@ function read_side_set_elements_and_sides(exo::ExodusDatabase{M, I, B, F}, set_i num_entries, _ = read_set_parameters(exo, set_id, SideSet) entries = Vector{B}(undef, num_entries) extras = Vector{B}(undef, num_entries) - error_code = @ccall libexodus.ex_get_set( - get_file_id(exo)::Cint, EX_SIDE_SET::ex_entity_type, set_id::Clonglong, # set id is really a ex_entity_id but it's weirldy throwing a type instability - entries::Ptr{B}, extras::Ptr{B} - )::Cint - exodus_error_check(exo, error_code, "Exodus.read_side_set_elements_and_sides -> libexodus.ex_get_set") + error_code = LibExodus.ex_get_set( + get_file_id(exo), EX_SIDE_SET, set_id, + entries, extras + ) + exodus_error_check(exo, error_code, "Exodus.read_side_set_elements_and_sides -> LibExodus.ex_get_set") return entries, extras end @@ -90,21 +85,21 @@ $(TYPEDSIGNATURES) UNTESTED """ function read_side_set_node_list(exo::ExodusDatabase{M, I, B, F}, side_set_id::Integer) where {M, I, B, F} - side_set_node_list_len = Ref{Cint}(0) - error_code = @ccall libexodus.ex_get_side_set_node_list_len( - get_file_id(exo)::Cint, side_set_id::Clonglong, side_set_node_list_len::Ptr{Cint} # side_set-Id should really be ex_entity_id but it's weirdly causing a type instability - )::Cint - exodus_error_check(exo, error_code, "Exodus.read_side_set_node_list -> libexodus.ex_get_side_set_node_list_len") + side_set_node_list_len = Base.RefValue{Cint}(0) + error_code = LibExodus.ex_get_side_set_node_list_len( + get_file_id(exo), side_set_id, side_set_node_list_len + ) + exodus_error_check(exo, error_code, "Exodus.read_side_set_node_list -> LibExodus.ex_get_side_set_node_list_len") num_sides, _ = read_set_parameters(exo, side_set_id, SideSet) side_set_node_cnt_list = Vector{B}(undef, num_sides) side_set_node_list = Vector{B}(undef, side_set_node_list_len[]) - error_code = @ccall libexodus.ex_get_side_set_node_list( - get_file_id(exo)::Cint, side_set_id::Clonglong, # should really be ex_entity_id but it's weirdly causing a type instability - side_set_node_cnt_list::Ptr{B}, side_set_node_list::Ptr{B} - )::Cint - exodus_error_check(exo, error_code, "Exodus.read_side_set_node_list -> libexodus.ex_get_side_set_node_list") + error_code = LibExodus.ex_get_side_set_node_list( + get_file_id(exo), side_set_id, + side_set_node_cnt_list, side_set_node_list + ) + exodus_error_check(exo, error_code, "Exodus.read_side_set_node_list -> LibExodus.ex_get_side_set_node_list") return side_set_node_cnt_list, side_set_node_list end @@ -156,11 +151,11 @@ currently doesn't support distance factors """ function write_set_parameters(exo::ExodusDatabase{M, I, B, F}, set::T) where {M, I, B, F, T <: AbstractExodusSet} num_dist_fact_in_set = 0 # TODO not using distance - error_code = @ccall libexodus.ex_put_set_param( - get_file_id(exo)::Cint, entity_type(T)::ex_entity_type, set.id::Clonglong, # should be ex_entity_id - length(set)::Clonglong, num_dist_fact_in_set::Clonglong - )::Cint - exodus_error_check(exo, error_code, "Exodus.write_node_set_parameters -> libexodus.ex_put_set_param") + error_code = LibExodus.ex_put_set_param( + get_file_id(exo), entity_type(T), set.id, + length(set), num_dist_fact_in_set + ) + exodus_error_check(exo, error_code, "Exodus.write_node_set_parameters -> LibExodus.ex_put_set_param") end """ @@ -170,11 +165,11 @@ to the exodus file. """ function write_set(exo::ExodusDatabase{M, I, B, F}, set::T) where {T <: AbstractExodusSet, M, I, B, F} write_set_parameters(exo, set) - error_code = @ccall libexodus.ex_put_set( - get_file_id(exo)::Cint, entity_type(T)::ex_entity_type, set.id::Clonglong, # should be ex_entity_id - entries(set)::Ptr{B}, extras(set)::Ptr{Union{Cvoid, B}} - )::Cint - exodus_error_check(exo, error_code, "Exodus.write_set -> libexodus.ex_put_set") + error_code = LibExodus.ex_put_set( + get_file_id(exo), entity_type(T), set.id, + entries(set), extras(set) + ) + exodus_error_check(exo, error_code, "Exodus.write_set -> LibExodus.ex_put_set") end """ @@ -199,11 +194,10 @@ function write_name(exo::ExodusDatabase{M, I, B, F}, ::Type{S}, set_id::Integer, exo.sset_name_dict[name] = set_id end - error_code = @ccall libexodus.ex_put_name( - get_file_id(exo)::Cint, entity_type(S)::ex_entity_type, set_id::Clonglong, # should really be ex_entity_id - name::Ptr{UInt8} - )::Cint - exodus_error_check(exo, error_code, "Exodus.write_set_name -> libexodus.ex_put_name") + error_code = LibExodus.ex_put_name( + get_file_id(exo), entity_type(S), set_id, name + ) + exodus_error_check(exo, error_code, "Exodus.write_set_name -> LibExodus.ex_put_name") end """ @@ -218,11 +212,10 @@ function write_name(exo::ExodusDatabase{M, I, B, F}, set::S, name::String) where exo.sset_name_dict[name] = set.id end - error_code = @ccall libexodus.ex_put_name( - get_file_id(exo)::Cint, entity_type(S)::ex_entity_type, set.id::Clonglong, # should really be ex_entity_id - name::Ptr{UInt8} - )::Cint - exodus_error_check(exo, error_code, "Exodus.write_set_name -> libexodus.ex_put_name") + error_code = LibExodus.ex_put_name( + get_file_id(exo), entity_type(S), set.id, name + ) + exodus_error_check(exo, error_code, "Exodus.write_set_name -> LibExodus.ex_put_name") end """ @@ -230,8 +223,8 @@ $(TYPEDSIGNATURES) WARNING: this methods likely does not have good safe guards """ function write_names(exo::ExodusDatabase, ::Type{S}, names::Vector{String}) where S <: AbstractExodusSet - error_code = @ccall libexodus.ex_put_names( - get_file_id(exo)::Cint, entity_type(S)::ex_entity_type, names::Ptr{Ptr{UInt8}} - )::Cint - exodus_error_check(exo, error_code, "Exodus.write_set_names -> libexodus.ex_put_names") + error_code = LibExodus.ex_put_names( + get_file_id(exo), entity_type(S), names + ) + exodus_error_check(exo, error_code, "Exodus.write_set_names -> LibExodus.ex_put_names") end diff --git a/src/Times.jl b/src/Times.jl index 60a8c7f..0fc3864 100644 --- a/src/Times.jl +++ b/src/Times.jl @@ -2,8 +2,8 @@ $(TYPEDSIGNATURES) """ function read_number_of_time_steps(exo::ExodusDatabase) - num_steps = @ccall libexodus.ex_inquire_int(get_file_id(exo)::Cint, EX_INQ_TIME::ex_inquiry)::UInt32 - exodus_error_check(exo, num_steps, "Exodus.ex_inquite_int -> libexodus.ex_inquire_int") + num_steps = LibExodus.ex_inquire_int(get_file_id(exo), EX_INQ_TIME) + exodus_error_check(exo, num_steps, "Exodus.ex_inquite_int -> LibExodus.ex_inquire_int") return num_steps end @@ -13,10 +13,8 @@ TODO figure out how to make this not use a vector of length 1 - either a ref or """ function read_time(exo::ExodusDatabase, time_step::I) where I <: Integer time = Vector{get_float_type(exo)}(undef, 1) - error_code = @ccall libexodus.ex_get_time( - get_file_id(exo)::Cint, time_step::Cint, time::Ptr{Cvoid} - )::Cint - exodus_error_check(exo, error_code, "Exodus.read_time -> libexodus.ex_get_time") + error_code = LibExodus.ex_get_time(get_file_id(exo), time_step, time) + exodus_error_check(exo, error_code, "Exodus.read_time -> LibExodus.ex_get_time") return time[1] end @@ -26,8 +24,8 @@ $(TYPEDSIGNATURES) function read_times(exo::ExodusDatabase) num_steps = read_number_of_time_steps(exo) times = Vector{get_float_type(exo)}(undef, num_steps) - error_code = @ccall libexodus.ex_get_all_times(get_file_id(exo)::Cint, times::Ptr{Cvoid})::Cint - exodus_error_check(exo, error_code, "Exodus.read_times -> libexodus.read_times") + error_code = LibExodus.ex_get_all_times(get_file_id(exo), times) + exodus_error_check(exo, error_code, "Exodus.read_times -> LibExodus.read_times") return times end @@ -35,6 +33,6 @@ end $(TYPEDSIGNATURES) """ function write_time(exo::ExodusDatabase, time_step::I, time_value::F) where {I <: Integer, F <: AbstractFloat} - error_code = @ccall libexodus.ex_put_time(get_file_id(exo)::Cint, time_step::Cint, time_value::Ref{F})::Cint - exodus_error_check(exo, error_code, "Exodus.write_time -> libexodus.ex_put_time") + error_code = LibExodus.ex_put_time(get_file_id(exo), time_step, Base.RefValue(time_value)) + exodus_error_check(exo, error_code, "Exodus.write_time -> LibExodus.ex_put_time") end diff --git a/src/Variables.jl b/src/Variables.jl index dd82776..7bedbbe 100644 --- a/src/Variables.jl +++ b/src/Variables.jl @@ -19,11 +19,11 @@ julia> read_number_of_variables(exo, SideSetVariable) 6 """ function read_number_of_variables(exo::ExodusDatabase, ::Type{V}) where V <: AbstractExodusVariable - num_vars = Ref{Cint}(0) - error_code = @ccall libexodus.ex_get_variable_param( - get_file_id(exo)::Cint, entity_type(V)::ex_entity_type, num_vars::Ptr{Cint} - )::Cint - exodus_error_check(exo, error_code, "Exodus.read_number_of_variables -> libexodus.ex_get_variable_param") + num_vars = Base.RefValue{Cint}(0) + error_code = LibExodus.ex_get_variable_param( + get_file_id(exo), entity_type(V), num_vars + ) + exodus_error_check(exo, error_code, "Exodus.read_number_of_variables -> LibExodus.ex_get_variable_param") return num_vars[] end @@ -51,11 +51,11 @@ julia> read_name(exo, SideSetVariable, 1) function read_name( exo::ExodusDatabase, ::Type{V}, var_index::Integer ) where V <: AbstractExodusVariable - var_name = Vector{UInt8}(undef, MAX_STR_LENGTH) - error_code = @ccall libexodus.ex_get_variable_name( - get_file_id(exo)::Cint, entity_type(V)::ex_entity_type, var_index::Cint, var_name::Ptr{UInt8} - )::Cint - exodus_error_check(exo, error_code, "Exodus.read_variable_name -> libexodus.ex_get_variable_name") + var_name = Vector{Cchar}(undef, MAX_STR_LENGTH) + error_code = LibExodus.ex_get_variable_name( + get_file_id(exo), entity_type(V), var_index, pointer(var_name) + ) + exodus_error_check(exo, error_code, "Exodus.read_variable_name -> LibExodus.ex_get_variable_name") return unsafe_string(pointer(var_name)) end @@ -126,8 +126,6 @@ function read_values( return values end - - """ $(TYPEDSIGNATURES) Method to read global variables @@ -260,10 +258,11 @@ function read_values( exo::ExodusDatabase, ::Type{V}, time_step::Integer, set_name::String, var_name::String ) where V <: Union{ElementVariable, NodeSetVariable, SideSetVariable} - - read_values(exo, V, time_step, - set_name_index(exo, set_equivalent(V), set_name), - var_name_index(exo, V, var_name)) + read_values( + exo, V, time_step, + set_name_index(exo, set_equivalent(V), set_name), + var_name_index(exo, V, var_name) + ) end """ @@ -275,11 +274,11 @@ function read_values!( exo::ExodusDatabase{M, I, B, F}, ::Type{V}, timestep::Integer, id::Integer, var_index::Integer, ) where {M, I, B, F, V <: AbstractExodusVariable} - error_code = @ccall libexodus.ex_get_var( - get_file_id(exo)::Cint, timestep::Cint, entity_type(V)::ex_entity_type, - var_index::Cint, id::ex_entity_id, length(values)::Clonglong, values::Ptr{Cvoid} - )::Cint - exodus_error_check(exo, error_code, "Exodus.read_values -> libexodus.ex_get_var") + error_code = LibExodus.ex_get_var( + get_file_id(exo), timestep, entity_type(V), + var_index, id, length(values), values + ) + exodus_error_check(exo, error_code, "Exodus.read_values -> LibExodus.ex_get_var") return values end @@ -293,13 +292,13 @@ end # ) where {M, I, B, F, V <: AbstractExodusVariable} # values = Vector{F}(undef, num_nodes) -# error_code = @ccall libexodus.ex_get_partial_var( +# error_code = @ccall LibExodus.ex_get_partial_var( # get_file_id(exo)::Cint, time_step::Cint, entity_type(V)::ex_entity_type, # var_index::Cint, id::Cint, # start_node::Clonglong, num_nodes::Clonglong, # values::Ptr{Cvoid} # )::Cint -# exodus_error_check(error_code, "Exodus.read_partial_nodal_variable_values -> libexodus.ex_get_partial_var") +# exodus_error_check(error_code, "Exodus.read_partial_nodal_variable_values -> LibExodus.ex_get_partial_var") # return values # end @@ -336,10 +335,10 @@ julia> write_number_of_variables(exo, NodeSetVariable, 3) julia> write_number_of_variables(exo, SideSetVariable, 6) """ function write_number_of_variables(exo::ExodusDatabase, ::Type{V}, num_vars::Integer) where V <: AbstractExodusVariable - error_code = @ccall libexodus.ex_put_variable_param( - get_file_id(exo)::Cint, entity_type(V)::ex_entity_type, num_vars::Cint - )::Cint - exodus_error_check(exo, error_code, "Exodus.write_number_of_variables -> libexodus.ex_put_variable_param") + error_code = LibExodus.ex_put_variable_param( + get_file_id(exo), entity_type(V), num_vars + ) + exodus_error_check(exo, error_code, "Exodus.write_number_of_variables -> LibExodus.ex_put_variable_param") end """ @@ -350,10 +349,10 @@ function write_name(exo::ExodusDatabase, ::Type{V}, var_index::Integer, var_name set_var_name_index(exo, V, var_index, var_name) - error_code = @ccall libexodus.ex_put_variable_name( - get_file_id(exo)::Cint, entity_type(V)::ex_entity_type, var_index::Cint, var_name::Ptr{UInt8} - )::Cint - exodus_error_check(exo, error_code, "Exodus.write_variable_name -> libexodus.ex_put_variable_name") + error_code = LibExodus.ex_put_variable_name( + get_file_id(exo), entity_type(V), var_index, var_name + ) + exodus_error_check(exo, error_code, "Exodus.write_variable_name -> LibExodus.ex_put_variable_name") end """ @@ -372,11 +371,11 @@ function write_names(exo::ExodusDatabase, type::Type{V}, var_names::Vector{Strin set_var_name_index(exo, V, n, name) end - error_code = @ccall libexodus.ex_put_variable_names( - get_file_id(exo)::Cint, entity_type(V)::ex_entity_type, length(var_names)::Cint, - var_names::Ptr{Ptr{UInt8}} - )::Cint - exodus_error_check(exo, error_code, "Exodus.write_variable_names -> libexodus.ex_put_variable_names") + error_code = LibExodus.ex_put_variable_names( + get_file_id(exo), entity_type(V), + length(var_names), var_names + ) + exodus_error_check(exo, error_code, "Exodus.write_variable_names -> LibExodus.ex_put_variable_names") end """ @@ -390,12 +389,12 @@ function write_values( ) where {M, I, B, F, V <: AbstractExodusVariable} num_nodes = size(var_values, 1) - error_code = @ccall libexodus.ex_put_var( - get_file_id(exo)::Cint, timestep::Cint, entity_type(V)::ex_entity_type, - var_index::Cint, id::ex_entity_id, - num_nodes::Clonglong, var_values::Ptr{Cvoid} - )::Cint - exodus_error_check(exo, error_code, "Exodus.write_variable_values -> libexodus.ex_put_var") + error_code = LibExodus.ex_put_var( + get_file_id(exo), timestep, entity_type(V), + var_index, id, + num_nodes, var_values + ) + exodus_error_check(exo, error_code, "Exodus.write_variable_values -> LibExodus.ex_put_var") end """ @@ -462,8 +461,10 @@ function write_values( var_value::Vector{F} ) where {M, I, B, F, V <: AbstractExodusVariable} - write_values(exo, V, time_step, - set_name_index(exo, set_equivalent(V), set_name), - var_name_index(exo, V, var_name), - var_value) + write_values( + exo, V, time_step, + set_name_index(exo, set_equivalent(V), set_name), + var_name_index(exo, V, var_name), + var_value + ) end