From 6e0c8f5acd460d20eee95986adebf31e8fcf63b3 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Mon, 11 Nov 2024 08:47:30 +0100 Subject: [PATCH] Make T8CodeMesh fully type general --- src/meshes/t8code_mesh.jl | 9 +++++---- src/solvers/dgsem_t8code/containers_2d.jl | 6 +++--- src/solvers/dgsem_t8code/containers_3d.jl | 6 +++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/meshes/t8code_mesh.jl b/src/meshes/t8code_mesh.jl index a7d7b0313d6..0d16101257f 100644 --- a/src/meshes/t8code_mesh.jl +++ b/src/meshes/t8code_mesh.jl @@ -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 @@ -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 diff --git a/src/solvers/dgsem_t8code/containers_2d.jl b/src/solvers/dgsem_t8code/containers_2d.jl index ce525bfdf65..4c136441386 100644 --- a/src/solvers/dgsem_t8code/containers_2d.jl +++ b/src/solvers/dgsem_t8code/containers_2d.jl @@ -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. @@ -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)) diff --git a/src/solvers/dgsem_t8code/containers_3d.jl b/src/solvers/dgsem_t8code/containers_3d.jl index 1375782631a..981dabc397f 100644 --- a/src/solvers/dgsem_t8code/containers_3d.jl +++ b/src/solvers/dgsem_t8code/containers_3d.jl @@ -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. @@ -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))