Skip to content

Commit

Permalink
Use just @cfunction instead of @t8_analytic_callback
Browse files Browse the repository at this point in the history
  • Loading branch information
bennibolm committed Sep 24, 2024
1 parent 8243750 commit 8d7c2e1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 8 additions & 1 deletion examples/t8code_2d_fv/elixir_advection_basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 17 additions & 9 deletions src/auxiliary/t8code.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 8d7c2e1

Please sign in to comment.