diff --git a/Project.toml b/Project.toml index 012b64bcf3..f7e203158b 100644 --- a/Project.toml +++ b/Project.toml @@ -103,7 +103,7 @@ StaticArrays = "1.5" StrideArrays = "0.1.26" StructArrays = "0.6.11" SummationByPartsOperators = "0.5.41" -T8code = "0.7" +T8code = "0.6, 0.7" TimerOutputs = "0.5.7" Triangulate = "2.2" TriplotBase = "0.1" diff --git a/examples/t8code_2d_fv/elixir_advection_basic.jl b/examples/t8code_2d_fv/elixir_advection_basic.jl index 092cb8c5e7..49d32d9706 100644 --- a/examples/t8code_2d_fv/elixir_advection_basic.jl +++ b/examples/t8code_2d_fv/elixir_advection_basic.jl @@ -65,11 +65,18 @@ function f(cmesh, gtreeid, ref_coords, num_coords, out_coords, tree_data, user_d return nothing end +function f_c() + @cfunction($f, Cvoid, + (t8_cmesh_t, t8_gloidx_t, Ptr{Cdouble}, Csize_t, + Ptr{Cdouble}, Ptr{Cvoid}, Ptr{Cvoid})) +end + trees_per_dimension = (2, 2) eclass = T8_ECLASS_QUAD mesh = T8codeMesh(trees_per_dimension, eclass, - mapping = @t8_analytic_callback(f), + # mapping = Trixi.trixi_t8_mapping_c(mapping), + mapping = f_c(), # Plan is to use either # coordinates_max = coordinates_max, coordinates_min = coordinates_min, # or at least diff --git a/src/auxiliary/t8code.jl b/src/auxiliary/t8code.jl index 8327a61873..5200d483f7 100644 --- a/src/auxiliary/t8code.jl +++ b/src/auxiliary/t8code.jl @@ -192,18 +192,24 @@ function trixi_t8_adapt!(mesh, indicators) end # Note and TODO: -# This routine seems to work for most of the mappings. -# Somehow, when using `coordinates_min/max` and then `coordinates2mapping`, -# I get SegFault errors. -# This happens when running this in a new julia session or after some runs when I ran simulations -# with other mappings before. -# Cannot figure out why. For now, I will leave this auxiliary mapping within the elixir -# and comment this one out. +# This routine seems to work with a "standard" mapping, but not with `coordinates2mapping`. +# Now, even when called directly within the elixir. +# - Is the function called with the correct parameters? Memory location correct? +# - Life time issue for the GC tracked Julia object used in C? # function trixi_t8_mapping_c(mapping) # function f(cmesh, gtreeid, ref_coords, num_coords, out_coords, tree_data, user_data) +# @T8_ASSERT(cmesh isa Ptr{t8_cmesh}) +# @T8_ASSERT(gtreeid isa t8_gloidx_t) +# @T8_ASSERT(ref_coords isa Ptr{Cdouble}) +# @T8_ASSERT(num_coords isa Csize_t) +# @T8_ASSERT(out_coords isa Ptr{Cdouble}) +# @T8_ASSERT(tree_data isa Ptr{Cvoid}) +# @T8_ASSERT(user_data isa Ptr{Cvoid}) + # ltreeid = t8_cmesh_get_local_id(cmesh, gtreeid) # eclass = t8_cmesh_get_tree_class(cmesh, ltreeid) -# T8code.t8_geom_compute_linear_geometry(eclass, tree_data, ref_coords, num_coords, out_coords) +# T8code.t8_geom_compute_linear_geometry(eclass, tree_data, +# ref_coords, num_coords, out_coords) # for i in 1:num_coords # offset_3d = 3 * (i - 1) + 1 @@ -219,5 +225,7 @@ end # return nothing # end -# return @cfunction($f, Cvoid, (t8_cmesh_t, t8_gloidx_t, Ptr{Cdouble}, Csize_t, Ptr{Cdouble}, Ptr{Cvoid}, Ptr{Cvoid})) +# return @cfunction($f, Cvoid, +# (t8_cmesh_t, t8_gloidx_t, Ptr{Cdouble}, Csize_t, Ptr{Cdouble}, +# Ptr{Cvoid}, Ptr{Cvoid})) # end