Skip to content

Commit

Permalink
Make T8CodeMesh fully type general (#2154)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielDoehring authored Nov 11, 2024
1 parent e1950ac commit 7f6a860
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
9 changes: 5 additions & 4 deletions src/meshes/t8code_mesh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ mutable struct T8codeMesh{NDIMS, RealT <: Real, IsParallel, NDIMSP2, NNODES} <:

function T8codeMesh{NDIMS}(forest::Ptr{t8_forest}, tree_node_coordinates, nodes,
boundary_names,
current_filename) where {NDIMS}
current_filename,
RealT = Float64) where {NDIMS}
is_parallel = mpi_isparallel() ? True() : False()

mesh = new{NDIMS, Float64, typeof(is_parallel), NDIMS + 2, length(nodes)}(forest,
is_parallel)
mesh = new{NDIMS, RealT, typeof(is_parallel), NDIMS + 2, length(nodes)}(forest,
is_parallel)

mesh.nodes = nodes
mesh.boundary_names = boundary_names
Expand Down Expand Up @@ -272,7 +273,7 @@ function T8codeMesh{NDIMS, RealT}(forest::Ptr{t8_forest}, boundary_names; polyde
ntuple(_ -> length(nodes), NDIMS)...,
number_of_trees)

reference_coordinates = Vector{Float64}(undef, 3)
reference_coordinates = Vector{RealT}(undef, 3)

# Calculate node coordinates of reference mesh.
if NDIMS == 2
Expand Down
6 changes: 3 additions & 3 deletions src/solvers/dgsem_t8code/containers_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

# Interpolate tree_node_coordinates to each quadrant at the specified nodes.
function calc_node_coordinates!(node_coordinates,
mesh::T8codeMesh{2},
nodes::AbstractVector)
mesh::T8codeMesh{2, RealT},
nodes::AbstractVector) where {RealT <: Real}
# We use `StrideArray`s here since these buffers are used in performance-critical
# places and the additional information passed to the compiler makes them faster
# than native `Array`s.
Expand Down Expand Up @@ -37,7 +37,7 @@ function calc_node_coordinates!(node_coordinates,
# "integer" length to a float in relation to the unit interval [0,1].
element_length = t8_quad_len(element_level) / t8_quad_root_len

element_coords = Array{Float64}(undef, 3)
element_coords = Array{RealT}(undef, 3)
t8_element_vertex_reference_coords(eclass_scheme, element, 0,
pointer(element_coords))

Expand Down
6 changes: 3 additions & 3 deletions src/solvers/dgsem_t8code/containers_3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

# Interpolate tree_node_coordinates to each quadrant at the specified nodes
function calc_node_coordinates!(node_coordinates,
mesh::T8codeMesh{3},
nodes::AbstractVector)
mesh::T8codeMesh{3, RealT},
nodes::AbstractVector) where {RealT <: Real}
# We use `StrideArray`s here since these buffers are used in performance-critical
# places and the additional information passed to the compiler makes them faster
# than native `Array`s.
Expand Down Expand Up @@ -39,7 +39,7 @@ function calc_node_coordinates!(node_coordinates,
# "integer" length to a float in relation to the unit interval [0,1].
element_length = t8_hex_len(element_level) / t8_hex_root_len

element_coords = Vector{Float64}(undef, 3)
element_coords = Vector{RealT}(undef, 3)
t8_element_vertex_reference_coords(eclass_scheme, element, 0,
pointer(element_coords))

Expand Down

0 comments on commit 7f6a860

Please sign in to comment.