Skip to content

Commit

Permalink
Add low-level Julia test
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Aug 10, 2023
1 parent 3b1b37c commit 1918464
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,14 @@ if(openPMD_HAVE_JULIA)
POSITION_INDEPENDENT_CODE ON
WINDOWS_EXPORT_ALL_SYMBOLS ON
)

add_test(NAME CLI.julia_lowlevel
COMMAND julia
${openPMD_SOURCE_DIR}/test/julia/lowlevel_test.jl
${openPMD_LIBRARY_OUTPUT_DIRECTORY}/libopenPMD.jl.so
WORKING_DIRECTORY
${openPMD_RUNTIME_OUTPUT_DIRECTORY}
)
endif()

# python bindings
Expand Down
35 changes: 35 additions & 0 deletions test/julia/lowlevel_test.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import Base

# pass as first argument the path to libopenPMD.jl.so

module openPMD
using CxxWrap
@wrapmodule(ARGS[1])

function __init__()
@initcxx
end
end

s = openPMD.CXX_Series(
"../samples/lowlevel_julia_test.json", openPMD.ACCESS_CREATE)

function Base.getindex(
cont::Cont,
index,
) where
{
A,
B,
Cont<:openPMD.CXX_Container{A,B}
}
return openPMD.cxx_getindex(cont, index)
end

iteration = openPMD.cxx_iterations(s)[100]
mesh = openPMD.cxx_meshes(iteration)
# empty brackets to dereference CxxRef
# automatic dereferencing works only for Int types since CxxRwap.jl defines
# Base.getindex(x::CxxBaseRef, i::Int) = Base.getindex(x[], i)
mesh[]["E"][]["x"]
openPMD.cxx_flush(s, "{}")

0 comments on commit 1918464

Please sign in to comment.