Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/src/solvers/dgsem_t8code/containers_2d.jl
5590 views
1
# By default, Julia/LLVM does not use fused multiply-add operations (FMAs).
2
# Since these FMAs can increase the performance of many numerical algorithms,
3
# we need to opt-in explicitly.
4
# See https://ranocha.de/blog/Optimizing_EC_Trixi for further details.
5
@muladd begin
6
#! format: noindent
7
8
# Interpolate tree_node_coordinates to each quadrant at the specified nodes.
9
function calc_node_coordinates!(node_coordinates,
10
mesh::T8codeMesh{2, RealT},
11
nodes::AbstractVector) where {RealT <: Real}
12
# We use `StrideArray`s here since these buffers are used in performance-critical
13
# places and the additional information passed to the compiler makes them faster
14
# than native `Array`s.
15
tmp1 = StrideArray(undef, real(mesh),
16
StaticInt(2), static_length(nodes), static_length(mesh.nodes))
17
matrix1 = StrideArray(undef, real(mesh),
18
static_length(nodes), static_length(mesh.nodes))
19
matrix2 = similar(matrix1)
20
baryweights_in = barycentric_weights(mesh.nodes)
21
22
num_local_trees = t8_forest_get_num_local_trees(mesh.forest)
23
24
current_index = 0
25
for itree in 0:(num_local_trees - 1)
26
tree_class = t8_forest_get_tree_class(mesh.forest, itree)
27
eclass_scheme = t8_forest_get_eclass_scheme(mesh.forest, tree_class)
28
num_elements_in_tree = t8_forest_get_tree_num_elements(mesh.forest, itree)
29
global_itree = t8_forest_global_tree_id(mesh.forest, itree)
30
31
for ielement in 0:(num_elements_in_tree - 1)
32
element = t8_forest_get_element_in_tree(mesh.forest, itree, ielement)
33
element_level = t8_element_level(eclass_scheme, element)
34
35
# Note, `t8_quad_len` is encoded as an integer (Morton encoding) in
36
# relation to `t8_quad_root_len`. This line transforms the
37
# "integer" length to a float in relation to the unit interval [0,1].
38
element_length = t8_quad_len(element_level) / t8_quad_root_len
39
40
element_coords = Array{RealT}(undef, 3)
41
t8_element_vertex_reference_coords(eclass_scheme, element, 0,
42
pointer(element_coords))
43
44
nodes_out_x = 2 *
45
(element_length * 1 / 2 * (nodes .+ 1) .+ element_coords[1]) .-
46
1
47
nodes_out_y = 2 *
48
(element_length * 1 / 2 * (nodes .+ 1) .+ element_coords[2]) .-
49
1
50
51
polynomial_interpolation_matrix!(matrix1, mesh.nodes, nodes_out_x,
52
baryweights_in)
53
polynomial_interpolation_matrix!(matrix2, mesh.nodes, nodes_out_y,
54
baryweights_in)
55
56
multiply_dimensionwise!(view(node_coordinates, :, :, :, current_index += 1),
57
matrix1, matrix2,
58
view(mesh.tree_node_coordinates, :, :, :,
59
global_itree + 1),
60
tmp1)
61
end
62
end
63
64
return node_coordinates
65
end
66
67
function init_mortar_neighbor_ids!(mortars::P4estMortarContainer{2}, my_face,
68
other_face, orientation, neighbor_ielements,
69
mortar_id)
70
if orientation == 0
71
mortars.neighbor_ids[1, mortar_id] = neighbor_ielements[1] + 1
72
mortars.neighbor_ids[2, mortar_id] = neighbor_ielements[2] + 1
73
else
74
mortars.neighbor_ids[1, mortar_id] = neighbor_ielements[2] + 1
75
mortars.neighbor_ids[2, mortar_id] = neighbor_ielements[1] + 1
76
end
77
end
78
end # @muladd
79
80