Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/src/solvers/dgsem_p4est/containers_parallel_2d.jl
5616 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
# Initialize node_indices of MPI interface container
9
@inline function init_mpi_interface_node_indices!(mpi_interfaces::P4estMPIInterfaceContainer{2},
10
faces, local_side, orientation,
11
mpi_interface_id)
12
# Align interface in positive coordinate direction of primary element.
13
# For orientation == 1, the secondary element needs to be indexed backwards
14
# relative to the interface.
15
if local_side == 1 || orientation == 0
16
# Forward indexing
17
i = :i_forward
18
else
19
# Backward indexing
20
i = :i_backward
21
end
22
23
if faces[local_side] == 0
24
# Index face in negative x-direction
25
mpi_interfaces.node_indices[mpi_interface_id] = (:begin, i)
26
elseif faces[local_side] == 1
27
# Index face in positive x-direction
28
mpi_interfaces.node_indices[mpi_interface_id] = (:end, i)
29
elseif faces[local_side] == 2
30
# Index face in negative y-direction
31
mpi_interfaces.node_indices[mpi_interface_id] = (i, :begin)
32
else # faces[local_side] == 3
33
# Index face in positive y-direction
34
mpi_interfaces.node_indices[mpi_interface_id] = (i, :end)
35
end
36
37
return mpi_interfaces
38
end
39
40
# Normal directions of small element surfaces are needed to calculate the mortar fluxes. Initialize
41
# them for locally available small elements.
42
function init_normal_directions!(mpi_mortars::P4estMPIMortarContainer{2},
43
basis, elements)
44
@unpack local_neighbor_ids, local_neighbor_positions, node_indices = mpi_mortars
45
@unpack contravariant_vectors = elements
46
index_range = eachnode(basis)
47
48
@threaded for mortar in 1:nmpimortars(mpi_mortars)
49
small_indices = node_indices[1, mortar]
50
small_direction = indices2direction(small_indices)
51
52
i_small_start, i_small_step = index_to_start_step_2d(small_indices[1],
53
index_range)
54
j_small_start, j_small_step = index_to_start_step_2d(small_indices[2],
55
index_range)
56
57
for (element, position) in zip(local_neighbor_ids[mortar],
58
local_neighbor_positions[mortar])
59
# ignore large elements
60
if position == 3
61
continue
62
end
63
64
i_small = i_small_start
65
j_small = j_small_start
66
for node in eachnode(basis)
67
# Get the normal direction on the small element.
68
# Note, contravariant vectors at interfaces in negative coordinate direction
69
# are pointing inwards. This is handled by `get_normal_direction`.
70
normal_direction = get_normal_direction(small_direction,
71
contravariant_vectors,
72
i_small, j_small, element)
73
@views mpi_mortars.normal_directions[:, node, position, mortar] .= normal_direction
74
75
i_small += i_small_step
76
j_small += j_small_step
77
end
78
end
79
end
80
81
return nothing
82
end
83
end # muladd
84
85