Path: blob/main/src/solvers/dgsem_p4est/containers_parallel_2d.jl
5616 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# Initialize node_indices of MPI interface container8@inline function init_mpi_interface_node_indices!(mpi_interfaces::P4estMPIInterfaceContainer{2},9faces, local_side, orientation,10mpi_interface_id)11# Align interface in positive coordinate direction of primary element.12# For orientation == 1, the secondary element needs to be indexed backwards13# relative to the interface.14if local_side == 1 || orientation == 015# Forward indexing16i = :i_forward17else18# Backward indexing19i = :i_backward20end2122if faces[local_side] == 023# Index face in negative x-direction24mpi_interfaces.node_indices[mpi_interface_id] = (:begin, i)25elseif faces[local_side] == 126# Index face in positive x-direction27mpi_interfaces.node_indices[mpi_interface_id] = (:end, i)28elseif faces[local_side] == 229# Index face in negative y-direction30mpi_interfaces.node_indices[mpi_interface_id] = (i, :begin)31else # faces[local_side] == 332# Index face in positive y-direction33mpi_interfaces.node_indices[mpi_interface_id] = (i, :end)34end3536return mpi_interfaces37end3839# Normal directions of small element surfaces are needed to calculate the mortar fluxes. Initialize40# them for locally available small elements.41function init_normal_directions!(mpi_mortars::P4estMPIMortarContainer{2},42basis, elements)43@unpack local_neighbor_ids, local_neighbor_positions, node_indices = mpi_mortars44@unpack contravariant_vectors = elements45index_range = eachnode(basis)4647@threaded for mortar in 1:nmpimortars(mpi_mortars)48small_indices = node_indices[1, mortar]49small_direction = indices2direction(small_indices)5051i_small_start, i_small_step = index_to_start_step_2d(small_indices[1],52index_range)53j_small_start, j_small_step = index_to_start_step_2d(small_indices[2],54index_range)5556for (element, position) in zip(local_neighbor_ids[mortar],57local_neighbor_positions[mortar])58# ignore large elements59if position == 360continue61end6263i_small = i_small_start64j_small = j_small_start65for node in eachnode(basis)66# Get the normal direction on the small element.67# Note, contravariant vectors at interfaces in negative coordinate direction68# are pointing inwards. This is handled by `get_normal_direction`.69normal_direction = get_normal_direction(small_direction,70contravariant_vectors,71i_small, j_small, element)72@views mpi_mortars.normal_directions[:, node, position, mortar] .= normal_direction7374i_small += i_small_step75j_small += j_small_step76end77end78end7980return nothing81end82end # muladd838485