Path: blob/main/src/solvers/dgsem_t8code/containers_2d.jl
5590 views
# By default, Julia/LLVM does not use fused multiply-add operations (FMAs).1# Since these FMAs can increase the performance of many numerical algorithms,2# we need to opt-in explicitly.3# See https://ranocha.de/blog/Optimizing_EC_Trixi for further details.4@muladd begin5#! format: noindent67# Interpolate tree_node_coordinates to each quadrant at the specified nodes.8function calc_node_coordinates!(node_coordinates,9mesh::T8codeMesh{2, RealT},10nodes::AbstractVector) where {RealT <: Real}11# We use `StrideArray`s here since these buffers are used in performance-critical12# places and the additional information passed to the compiler makes them faster13# than native `Array`s.14tmp1 = StrideArray(undef, real(mesh),15StaticInt(2), static_length(nodes), static_length(mesh.nodes))16matrix1 = StrideArray(undef, real(mesh),17static_length(nodes), static_length(mesh.nodes))18matrix2 = similar(matrix1)19baryweights_in = barycentric_weights(mesh.nodes)2021num_local_trees = t8_forest_get_num_local_trees(mesh.forest)2223current_index = 024for itree in 0:(num_local_trees - 1)25tree_class = t8_forest_get_tree_class(mesh.forest, itree)26eclass_scheme = t8_forest_get_eclass_scheme(mesh.forest, tree_class)27num_elements_in_tree = t8_forest_get_tree_num_elements(mesh.forest, itree)28global_itree = t8_forest_global_tree_id(mesh.forest, itree)2930for ielement in 0:(num_elements_in_tree - 1)31element = t8_forest_get_element_in_tree(mesh.forest, itree, ielement)32element_level = t8_element_level(eclass_scheme, element)3334# Note, `t8_quad_len` is encoded as an integer (Morton encoding) in35# relation to `t8_quad_root_len`. This line transforms the36# "integer" length to a float in relation to the unit interval [0,1].37element_length = t8_quad_len(element_level) / t8_quad_root_len3839element_coords = Array{RealT}(undef, 3)40t8_element_vertex_reference_coords(eclass_scheme, element, 0,41pointer(element_coords))4243nodes_out_x = 2 *44(element_length * 1 / 2 * (nodes .+ 1) .+ element_coords[1]) .-45146nodes_out_y = 2 *47(element_length * 1 / 2 * (nodes .+ 1) .+ element_coords[2]) .-4814950polynomial_interpolation_matrix!(matrix1, mesh.nodes, nodes_out_x,51baryweights_in)52polynomial_interpolation_matrix!(matrix2, mesh.nodes, nodes_out_y,53baryweights_in)5455multiply_dimensionwise!(view(node_coordinates, :, :, :, current_index += 1),56matrix1, matrix2,57view(mesh.tree_node_coordinates, :, :, :,58global_itree + 1),59tmp1)60end61end6263return node_coordinates64end6566function init_mortar_neighbor_ids!(mortars::P4estMortarContainer{2}, my_face,67other_face, orientation, neighbor_ielements,68mortar_id)69if orientation == 070mortars.neighbor_ids[1, mortar_id] = neighbor_ielements[1] + 171mortars.neighbor_ids[2, mortar_id] = neighbor_ielements[2] + 172else73mortars.neighbor_ids[1, mortar_id] = neighbor_ielements[2] + 174mortars.neighbor_ids[2, mortar_id] = neighbor_ielements[1] + 175end76end77end # @muladd787980