From 4377d96e6b64271b7c706e64363e6a445fdafbf8 Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Mon, 25 Nov 2024 13:37:08 +0100 Subject: [PATCH 1/5] change all indexing symbols to enum members --- .../elixir_advection_coupled.jl | 33 ++++---- .../elixir_advection_meshview.jl | 10 +-- .../structured_2d_dgsem/elixir_mhd_coupled.jl | 8 +- .../semidiscretization_coupled.jl | 6 +- src/solvers/dg.jl | 28 ++++++- src/solvers/dgsem_p4est/containers.jl | 28 +++---- src/solvers/dgsem_p4est/containers_2d.jl | 32 ++++---- src/solvers/dgsem_p4est/containers_3d.jl | 78 +++++++++---------- .../dgsem_p4est/containers_parallel.jl | 10 +-- .../dgsem_p4est/containers_parallel_2d.jl | 12 +-- .../dgsem_p4est/containers_parallel_3d.jl | 34 ++++---- src/solvers/dgsem_p4est/dg_2d.jl | 16 ++-- src/solvers/dgsem_p4est/dg_2d_parabolic.jl | 4 +- src/solvers/dgsem_p4est/dg_2d_parallel.jl | 4 +- src/solvers/dgsem_p4est/dg_3d.jl | 32 ++++---- 15 files changed, 181 insertions(+), 154 deletions(-) diff --git a/examples/structured_2d_dgsem/elixir_advection_coupled.jl b/examples/structured_2d_dgsem/elixir_advection_coupled.jl index 50cee1a071e..e842c6185d9 100644 --- a/examples/structured_2d_dgsem/elixir_advection_coupled.jl +++ b/examples/structured_2d_dgsem/elixir_advection_coupled.jl @@ -1,5 +1,6 @@ using OrdinaryDiffEq using Trixi +import Trixi.Indexing ############################################################################### # Coupled semidiscretization of four linear advection systems using converter functions such that @@ -61,13 +62,13 @@ coupling_function12 = (x, u, equations_other, equations_own) -> u coupling_function13 = (x, u, equations_other, equations_own) -> u # Define the coupling boundary conditions and the system it is coupled to. -boundary_conditions_x_neg1 = BoundaryConditionCoupled(2, (:end, :i_forward), Float64, +boundary_conditions_x_neg1 = BoundaryConditionCoupled(2, (Indexing.last, Indexing.i_forward), Float64, coupling_function12) -boundary_conditions_x_pos1 = BoundaryConditionCoupled(2, (:begin, :i_forward), Float64, +boundary_conditions_x_pos1 = BoundaryConditionCoupled(2, (Indexing.first, Indexing.i_forward), Float64, coupling_function12) -boundary_conditions_y_neg1 = BoundaryConditionCoupled(3, (:i_forward, :end), Float64, +boundary_conditions_y_neg1 = BoundaryConditionCoupled(3, (Indexing.i_forward, Indexing.last), Float64, coupling_function13) -boundary_conditions_y_pos1 = BoundaryConditionCoupled(3, (:i_forward, :begin), Float64, +boundary_conditions_y_pos1 = BoundaryConditionCoupled(3, (Indexing.i_forward, Indexing.first), Float64, coupling_function13) # A semidiscretization collects data structures and functions for the spatial discretization @@ -93,13 +94,13 @@ coupling_function21 = (x, u, equations_other, equations_own) -> u coupling_function24 = (x, u, equations_other, equations_own) -> u # Define the coupling boundary conditions and the system it is coupled to. -boundary_conditions_x_neg2 = BoundaryConditionCoupled(1, (:end, :i_forward), Float64, +boundary_conditions_x_neg2 = BoundaryConditionCoupled(1, (Indexing.last, Indexing.i_forward), Float64, coupling_function21) -boundary_conditions_x_pos2 = BoundaryConditionCoupled(1, (:begin, :i_forward), Float64, +boundary_conditions_x_pos2 = BoundaryConditionCoupled(1, (Indexing.first, Indexing.i_forward), Float64, coupling_function21) -boundary_conditions_y_neg2 = BoundaryConditionCoupled(4, (:i_forward, :end), Float64, +boundary_conditions_y_neg2 = BoundaryConditionCoupled(4, (Indexing.i_forward, Indexing.last), Float64, coupling_function24) -boundary_conditions_y_pos2 = BoundaryConditionCoupled(4, (:i_forward, :begin), Float64, +boundary_conditions_y_pos2 = BoundaryConditionCoupled(4, (Indexing.i_forward, Indexing.first), Float64, coupling_function24) # A semidiscretization collects data structures and functions for the spatial discretization @@ -125,13 +126,13 @@ coupling_function34 = (x, u, equations_other, equations_own) -> u coupling_function31 = (x, u, equations_other, equations_own) -> u # Define the coupling boundary conditions and the system it is coupled to. -boundary_conditions_x_neg3 = BoundaryConditionCoupled(4, (:end, :i_forward), Float64, +boundary_conditions_x_neg3 = BoundaryConditionCoupled(4, (Indexing.last, Indexing.i_forward), Float64, coupling_function34) -boundary_conditions_x_pos3 = BoundaryConditionCoupled(4, (:begin, :i_forward), Float64, +boundary_conditions_x_pos3 = BoundaryConditionCoupled(4, (Indexing.first, Indexing.i_forward), Float64, coupling_function34) -boundary_conditions_y_neg3 = BoundaryConditionCoupled(1, (:i_forward, :end), Float64, +boundary_conditions_y_neg3 = BoundaryConditionCoupled(1, (Indexing.i_forward, Indexing.last), Float64, coupling_function31) -boundary_conditions_y_pos3 = BoundaryConditionCoupled(1, (:i_forward, :begin), Float64, +boundary_conditions_y_pos3 = BoundaryConditionCoupled(1, (Indexing.i_forward, Indexing.first), Float64, coupling_function31) # A semidiscretization collects data structures and functions for the spatial discretization @@ -157,13 +158,13 @@ coupling_function43 = (x, u, equations_other, equations_own) -> u coupling_function42 = (x, u, equations_other, equations_own) -> u # Define the coupling boundary conditions and the system it is coupled to. -boundary_conditions_x_neg4 = BoundaryConditionCoupled(3, (:end, :i_forward), Float64, +boundary_conditions_x_neg4 = BoundaryConditionCoupled(3, (Indexing.last, Indexing.i_forward), Float64, coupling_function43) -boundary_conditions_x_pos4 = BoundaryConditionCoupled(3, (:begin, :i_forward), Float64, +boundary_conditions_x_pos4 = BoundaryConditionCoupled(3, (Indexing.first, Indexing.i_forward), Float64, coupling_function43) -boundary_conditions_y_neg4 = BoundaryConditionCoupled(2, (:i_forward, :end), Float64, +boundary_conditions_y_neg4 = BoundaryConditionCoupled(2, (Indexing.i_forward, Indexing.last), Float64, coupling_function42) -boundary_conditions_y_pos4 = BoundaryConditionCoupled(2, (:i_forward, :begin), Float64, +boundary_conditions_y_pos4 = BoundaryConditionCoupled(2, (Indexing.i_forward, Indexing.first), Float64, coupling_function42) # A semidiscretization collects data structures and functions for the spatial discretization diff --git a/examples/structured_2d_dgsem/elixir_advection_meshview.jl b/examples/structured_2d_dgsem/elixir_advection_meshview.jl index 33e36a39f2c..5208da33e6c 100644 --- a/examples/structured_2d_dgsem/elixir_advection_meshview.jl +++ b/examples/structured_2d_dgsem/elixir_advection_meshview.jl @@ -51,21 +51,21 @@ mesh2 = StructuredMeshView(parent_mesh; indices_min = (9, 1), indices_max = (16, coupling_function = (x, u, equations_other, equations_own) -> u # Define the coupled boundary conditions -# The indices (:end, :i_forward) and (:begin, :i_forward) denote the interface indexing. +# The indices (Indexing.last, Indexing.i_forward) and (Indexing.first, Indexing.i_forward) denote the interface indexing. # For a system with coupling in x and y see examples/structured_2d_dgsem/elixir_advection_coupled.jl. boundary_conditions1 = ( # Connect left boundary with right boundary of left mesh - x_neg = BoundaryConditionCoupled(2, (:end, :i_forward), Float64, + x_neg = BoundaryConditionCoupled(2, (Indexing.last, Indexing.i_forward), Float64, coupling_function), - x_pos = BoundaryConditionCoupled(2, (:begin, :i_forward), Float64, + x_pos = BoundaryConditionCoupled(2, (Indexing.first, Indexing.i_forward), Float64, coupling_function), y_neg = boundary_condition_periodic, y_pos = boundary_condition_periodic) boundary_conditions2 = ( # Connect left boundary with right boundary of left mesh - x_neg = BoundaryConditionCoupled(1, (:end, :i_forward), Float64, + x_neg = BoundaryConditionCoupled(1, (Indexing.last, Indexing.i_forward), Float64, coupling_function), - x_pos = BoundaryConditionCoupled(1, (:begin, :i_forward), Float64, + x_pos = BoundaryConditionCoupled(1, (Indexing.first, Indexing.i_forward), Float64, coupling_function), y_neg = boundary_condition_periodic, y_pos = boundary_condition_periodic) diff --git a/examples/structured_2d_dgsem/elixir_mhd_coupled.jl b/examples/structured_2d_dgsem/elixir_mhd_coupled.jl index de274248b45..7baa17a0776 100644 --- a/examples/structured_2d_dgsem/elixir_mhd_coupled.jl +++ b/examples/structured_2d_dgsem/elixir_mhd_coupled.jl @@ -49,9 +49,9 @@ mesh1 = StructuredMesh(cells_per_dimension, periodicity = (false, true)) coupling_function1 = (x, u, equations_other, equations_own) -> u -boundary_conditions1 = (x_neg = BoundaryConditionCoupled(2, (:end, :i_forward), Float64, +boundary_conditions1 = (x_neg = BoundaryConditionCoupled(2, (Indexing.last, Indexing.i_forward), Float64, coupling_function1), - x_pos = BoundaryConditionCoupled(2, (:begin, :i_forward), Float64, + x_pos = BoundaryConditionCoupled(2, (Indexing.first, Indexing.i_forward), Float64, coupling_function1), y_neg = boundary_condition_periodic, y_pos = boundary_condition_periodic) @@ -72,9 +72,9 @@ mesh2 = StructuredMesh(cells_per_dimension, periodicity = (false, true)) coupling_function2 = (x, u, equations_other, equations_own) -> u -boundary_conditions2 = (x_neg = BoundaryConditionCoupled(1, (:end, :i_forward), Float64, +boundary_conditions2 = (x_neg = BoundaryConditionCoupled(1, (Indexing.last, Indexing.i_forward), Float64, coupling_function2), - x_pos = BoundaryConditionCoupled(1, (:begin, :i_forward), Float64, + x_pos = BoundaryConditionCoupled(1, (Indexing.first, Indexing.i_forward), Float64, coupling_function2), y_neg = boundary_condition_periodic, y_pos = boundary_condition_periodic) diff --git a/src/semidiscretization/semidiscretization_coupled.jl b/src/semidiscretization/semidiscretization_coupled.jl index 745a8d3f6f8..4456c81ae19 100644 --- a/src/semidiscretization/semidiscretization_coupled.jl +++ b/src/semidiscretization/semidiscretization_coupled.jl @@ -452,11 +452,11 @@ mutable struct BoundaryConditionCoupled{NDIMS, NDIMS = length(indices) u_boundary = Array{uEltype, NDIMS * 2 - 1}(undef, ntuple(_ -> 0, NDIMS * 2 - 1)) - if indices[1] in (:begin, :end) + if indices[1] in (Indexing.first, Indexing.last) other_orientation = 1 - elseif indices[2] in (:begin, :end) + elseif indices[2] in (Indexing.first, Indexing.last) other_orientation = 2 - else # indices[3] in (:begin, :end) + else # indices[3] in (Indexing.first, Indexing.last) other_orientation = 3 end diff --git a/src/solvers/dg.jl b/src/solvers/dg.jl index a0fb0d95079..fae5b6e02be 100644 --- a/src/solvers/dg.jl +++ b/src/solvers/dg.jl @@ -752,6 +752,33 @@ function compute_coefficients!(u, func, t, mesh::AbstractMesh{3}, equations, dg: end end +end # @muladd; put it up here because module definition below needs to be at top level + +# For some mesh types, elements next to a surface may have local coordinate systems +# that are not aligned so the nodes may have to be indexed differently. +# `IndexInfo` is used to describe how the nodes should be indexed. +# For example, in 2d a `Tuple` with two `IndexInfo` objects, one for each dimension, +# would be used. +# `first` or `last` indicates that the corresponding index is constant and is either +# the first or the last one. This effectively encodes the position of the surface +# with respect to the local coordinate system. The other `IndexInfo` object(s) +# encode if the index in the corresponding dimension is running forward or backward. +# +# The Enum is wrapped in a module and exported so that the enum values do not pollute +# the global namespace and can only be accessed via `Indexing.value`. +module Indexing +@enum IndexInfo begin + first + last + i_forward + i_backward + j_forward + j_backward +end +export IndexInfo +end +using .Indexing + # Discretizations specific to each mesh type of Trixi.jl # If some functionality is shared by multiple combinations of meshes/solvers, # it is defined in the directory of the most basic mesh and solver type. @@ -765,4 +792,3 @@ include("dgsem_structured/dg.jl") include("dgsem_unstructured/dg.jl") include("dgsem_p4est/dg.jl") include("dgsem_t8code/dg.jl") -end # @muladd diff --git a/src/solvers/dgsem_p4est/containers.jl b/src/solvers/dgsem_p4est/containers.jl index 3ef9cb2a421..728e8b25565 100644 --- a/src/solvers/dgsem_p4est/containers.jl +++ b/src/solvers/dgsem_p4est/containers.jl @@ -131,12 +131,12 @@ mutable struct P4estInterfaceContainer{NDIMS, uEltype <: Real, NDIMSP2} <: AbstractContainer u::Array{uEltype, NDIMSP2} # [primary/secondary, variable, i, j, interface] neighbor_ids::Matrix{Int} # [primary/secondary, interface] - node_indices::Matrix{NTuple{NDIMS, Symbol}} # [primary/secondary, interface] + node_indices::Matrix{NTuple{NDIMS, IndexInfo}} # [primary/secondary, interface] # internal `resize!`able storage _u::Vector{uEltype} _neighbor_ids::Vector{Int} - _node_indices::Vector{NTuple{NDIMS, Symbol}} + _node_indices::Vector{NTuple{NDIMS, IndexInfo}} end @inline function ninterfaces(interfaces::P4estInterfaceContainer) @@ -184,7 +184,7 @@ function init_interfaces(mesh::Union{P4estMesh, T8codeMesh}, equations, basis, e _neighbor_ids = Vector{Int}(undef, 2 * n_interfaces) neighbor_ids = unsafe_wrap(Array, pointer(_neighbor_ids), (2, n_interfaces)) - _node_indices = Vector{NTuple{NDIMS, Symbol}}(undef, 2 * n_interfaces) + _node_indices = Vector{NTuple{NDIMS, IndexInfo}}(undef, 2 * n_interfaces) node_indices = unsafe_wrap(Array, pointer(_node_indices), (2, n_interfaces)) interfaces = P4estInterfaceContainer{NDIMS, uEltype, NDIMS + 2}(u, neighbor_ids, @@ -207,7 +207,7 @@ mutable struct P4estBoundaryContainer{NDIMS, uEltype <: Real, NDIMSP1} <: AbstractContainer u::Array{uEltype, NDIMSP1} # [variables, i, j, boundary] neighbor_ids::Vector{Int} # [boundary] - node_indices::Vector{NTuple{NDIMS, Symbol}} # [boundary] + node_indices::Vector{NTuple{NDIMS, IndexInfo}} # [boundary] name::Vector{Symbol} # [boundary] # internal `resize!`able storage @@ -257,7 +257,7 @@ function init_boundaries(mesh::Union{P4estMesh, T8codeMesh}, equations, basis, e n_boundaries)) neighbor_ids = Vector{Int}(undef, n_boundaries) - node_indices = Vector{NTuple{NDIMS, Symbol}}(undef, n_boundaries) + node_indices = Vector{NTuple{NDIMS, IndexInfo}}(undef, n_boundaries) names = Vector{Symbol}(undef, n_boundaries) boundaries = P4estBoundaryContainer{NDIMS, uEltype, NDIMS + 1}(u, neighbor_ids, @@ -338,12 +338,12 @@ mutable struct P4estMortarContainer{NDIMS, uEltype <: Real, NDIMSP1, NDIMSP3} <: AbstractContainer u::Array{uEltype, NDIMSP3} # [small/large side, variable, position, i, j, mortar] neighbor_ids::Matrix{Int} # [position, mortar] - node_indices::Matrix{NTuple{NDIMS, Symbol}} # [small/large, mortar] + node_indices::Matrix{NTuple{NDIMS, IndexInfo}} # [small/large, mortar] # internal `resize!`able storage _u::Vector{uEltype} _neighbor_ids::Vector{Int} - _node_indices::Vector{NTuple{NDIMS, Symbol}} + _node_indices::Vector{NTuple{NDIMS, IndexInfo}} end @inline nmortars(mortars::P4estMortarContainer) = size(mortars.neighbor_ids, 2) @@ -391,7 +391,7 @@ function init_mortars(mesh::Union{P4estMesh, T8codeMesh}, equations, basis, elem neighbor_ids = unsafe_wrap(Array, pointer(_neighbor_ids), (2^(NDIMS - 1) + 1, n_mortars)) - _node_indices = Vector{NTuple{NDIMS, Symbol}}(undef, 2 * n_mortars) + _node_indices = Vector{NTuple{NDIMS, IndexInfo}}(undef, 2 * n_mortars) node_indices = unsafe_wrap(Array, pointer(_node_indices), (2, n_mortars)) mortars = P4estMortarContainer{NDIMS, uEltype, NDIMS + 1, NDIMS + 3}(u, @@ -706,17 +706,17 @@ end # Return direction of the face, which is indexed by node_indices @inline function indices2direction(indices) - if indices[1] === :begin + if indices[1] === Indexing.first return 1 - elseif indices[1] === :end + elseif indices[1] === Indexing.last return 2 - elseif indices[2] === :begin + elseif indices[2] === Indexing.first return 3 - elseif indices[2] === :end + elseif indices[2] === Indexing.last return 4 - elseif indices[3] === :begin + elseif indices[3] === Indexing.first return 5 - else # if indices[3] === :end + else # if indices[3] === Indexing.last return 6 end end diff --git a/src/solvers/dgsem_p4est/containers_2d.jl b/src/solvers/dgsem_p4est/containers_2d.jl index 6af6fd6d90e..f306a42d853 100644 --- a/src/solvers/dgsem_p4est/containers_2d.jl +++ b/src/solvers/dgsem_p4est/containers_2d.jl @@ -95,24 +95,24 @@ end # relative to the interface. if side == 1 || orientation == 0 # Forward indexing - i = :i_forward + i = Indexing.i_forward else # Backward indexing - i = :i_backward + i = Indexing.i_backward end if faces[side] == 0 # Index face in negative x-direction - interfaces.node_indices[side, interface_id] = (:begin, i) + interfaces.node_indices[side, interface_id] = (Indexing.first, i) elseif faces[side] == 1 # Index face in positive x-direction - interfaces.node_indices[side, interface_id] = (:end, i) + interfaces.node_indices[side, interface_id] = (Indexing.last, i) elseif faces[side] == 2 # Index face in negative y-direction - interfaces.node_indices[side, interface_id] = (i, :begin) + interfaces.node_indices[side, interface_id] = (i, Indexing.first) else # faces[side] == 3 # Index face in positive y-direction - interfaces.node_indices[side, interface_id] = (i, :end) + interfaces.node_indices[side, interface_id] = (i, Indexing.last) end end @@ -124,16 +124,16 @@ end face, boundary_id) if face == 0 # Index face in negative x-direction - boundaries.node_indices[boundary_id] = (:begin, :i_forward) + boundaries.node_indices[boundary_id] = (Indexing.first, Indexing.i_forward) elseif face == 1 # Index face in positive x-direction - boundaries.node_indices[boundary_id] = (:end, :i_forward) + boundaries.node_indices[boundary_id] = (Indexing.last, Indexing.i_forward) elseif face == 2 # Index face in negative y-direction - boundaries.node_indices[boundary_id] = (:i_forward, :begin) + boundaries.node_indices[boundary_id] = (Indexing.i_forward, Indexing.first) else # face == 3 # Index face in positive y-direction - boundaries.node_indices[boundary_id] = (:i_forward, :end) + boundaries.node_indices[boundary_id] = (Indexing.i_forward, Indexing.last) end return boundaries @@ -148,24 +148,24 @@ end # relative to the mortar. if side == 1 || orientation == 0 # Forward indexing for small side or orientation == 0 - i = :i_forward + i = Indexing.i_forward else # Backward indexing for large side with reversed orientation - i = :i_backward + i = Indexing.i_backward end if faces[side] == 0 # Index face in negative x-direction - mortars.node_indices[side, mortar_id] = (:begin, i) + mortars.node_indices[side, mortar_id] = (Indexing.first, i) elseif faces[side] == 1 # Index face in positive x-direction - mortars.node_indices[side, mortar_id] = (:end, i) + mortars.node_indices[side, mortar_id] = (Indexing.last, i) elseif faces[side] == 2 # Index face in negative y-direction - mortars.node_indices[side, mortar_id] = (i, :begin) + mortars.node_indices[side, mortar_id] = (i, Indexing.first) else # faces[side] == 3 # Index face in positive y-direction - mortars.node_indices[side, mortar_id] = (i, :end) + mortars.node_indices[side, mortar_id] = (i, Indexing.last) end end diff --git a/src/solvers/dgsem_p4est/containers_3d.jl b/src/solvers/dgsem_p4est/containers_3d.jl index 7e383924ba7..88bbc693a2a 100644 --- a/src/solvers/dgsem_p4est/containers_3d.jl +++ b/src/solvers/dgsem_p4est/containers_3d.jl @@ -81,11 +81,11 @@ end faces, orientation, interface_id) # Iterate over primary and secondary element for side in 1:2 - # Align interface at the primary element (primary element has surface indices (:i_forward, :j_forward)). + # Align interface at the primary element (primary element has surface indices (Indexing.i_forward, Indexing.j_forward)). # The secondary element needs to be indexed differently. if side == 1 - surface_index1 = :i_forward - surface_index2 = :j_forward + surface_index1 = Indexing.i_forward + surface_index2 = Indexing.j_forward else surface_index1, surface_index2 = orientation_to_indices_p4est(faces[2], faces[1], @@ -94,28 +94,28 @@ end if faces[side] == 0 # Index face in negative x-direction - interfaces.node_indices[side, interface_id] = (:begin, surface_index1, + interfaces.node_indices[side, interface_id] = (Indexing.first, surface_index1, surface_index2) elseif faces[side] == 1 # Index face in positive x-direction - interfaces.node_indices[side, interface_id] = (:end, surface_index1, + interfaces.node_indices[side, interface_id] = (Indexing.last, surface_index1, surface_index2) elseif faces[side] == 2 # Index face in negative y-direction - interfaces.node_indices[side, interface_id] = (surface_index1, :begin, + interfaces.node_indices[side, interface_id] = (surface_index1, Indexing.first, surface_index2) elseif faces[side] == 3 # Index face in positive y-direction - interfaces.node_indices[side, interface_id] = (surface_index1, :end, + interfaces.node_indices[side, interface_id] = (surface_index1, Indexing.last, surface_index2) elseif faces[side] == 4 # Index face in negative z-direction interfaces.node_indices[side, interface_id] = (surface_index1, - surface_index2, :begin) + surface_index2, Indexing.first) else # faces[side] == 5 # Index face in positive z-direction interfaces.node_indices[side, interface_id] = (surface_index1, - surface_index2, :end) + surface_index2, Indexing.last) end end @@ -127,22 +127,22 @@ end face, boundary_id) if face == 0 # Index face in negative x-direction - boundaries.node_indices[boundary_id] = (:begin, :i_forward, :j_forward) + boundaries.node_indices[boundary_id] = (Indexing.first, Indexing.i_forward, Indexing.j_forward) elseif face == 1 # Index face in positive x-direction - boundaries.node_indices[boundary_id] = (:end, :i_forward, :j_forward) + boundaries.node_indices[boundary_id] = (Indexing.last, Indexing.i_forward, Indexing.j_forward) elseif face == 2 # Index face in negative y-direction - boundaries.node_indices[boundary_id] = (:i_forward, :begin, :j_forward) + boundaries.node_indices[boundary_id] = (Indexing.i_forward, Indexing.first, Indexing.j_forward) elseif face == 3 # Index face in positive y-direction - boundaries.node_indices[boundary_id] = (:i_forward, :end, :j_forward) + boundaries.node_indices[boundary_id] = (Indexing.i_forward, Indexing.last, Indexing.j_forward) elseif face == 4 # Index face in negative z-direction - boundaries.node_indices[boundary_id] = (:i_forward, :j_forward, :begin) + boundaries.node_indices[boundary_id] = (Indexing.i_forward, Indexing.j_forward, Indexing.first) else # face == 5 # Index face in positive z-direction - boundaries.node_indices[boundary_id] = (:i_forward, :j_forward, :end) + boundaries.node_indices[boundary_id] = (Indexing.i_forward, Indexing.j_forward, Indexing.last) end return boundaries @@ -156,8 +156,8 @@ end # Align mortar at small side. # The large side needs to be indexed differently. if side == 1 - surface_index1 = :i_forward - surface_index2 = :j_forward + surface_index1 = Indexing.i_forward + surface_index2 = Indexing.j_forward else surface_index1, surface_index2 = orientation_to_indices_p4est(faces[2], faces[1], @@ -166,28 +166,28 @@ end if faces[side] == 0 # Index face in negative x-direction - mortars.node_indices[side, mortar_id] = (:begin, surface_index1, + mortars.node_indices[side, mortar_id] = (Indexing.first, surface_index1, surface_index2) elseif faces[side] == 1 # Index face in positive x-direction - mortars.node_indices[side, mortar_id] = (:end, surface_index1, + mortars.node_indices[side, mortar_id] = (Indexing.last, surface_index1, surface_index2) elseif faces[side] == 2 # Index face in negative y-direction - mortars.node_indices[side, mortar_id] = (surface_index1, :begin, + mortars.node_indices[side, mortar_id] = (surface_index1, Indexing.first, surface_index2) elseif faces[side] == 3 # Index face in positive y-direction - mortars.node_indices[side, mortar_id] = (surface_index1, :end, + mortars.node_indices[side, mortar_id] = (surface_index1, Indexing.last, surface_index2) elseif faces[side] == 4 # Index face in negative z-direction mortars.node_indices[side, mortar_id] = (surface_index1, surface_index2, - :begin) + Indexing.first) else # faces[side] == 5 # Index face in positive z-direction mortars.node_indices[side, mortar_id] = (surface_index1, surface_index2, - :end) + Indexing.last) end end @@ -228,8 +228,8 @@ function orientation_to_indices_p4est(my_face, other_face, orientation_code) # ↑ ↑ # │ │ # └───> ξ └───> ξ - surface_index1 = :i_forward - surface_index2 = :j_forward + surface_index1 = Indexing.i_forward + surface_index2 = Indexing.j_forward elseif ((lower && orientation_code == 2) # Corner 0 of my side matches corner 2 of other side || (!lower && orientation_code == 1)) # Corner 0 of other side matches corner 1 of my side @@ -241,8 +241,8 @@ function orientation_to_indices_p4est(my_face, other_face, orientation_code) # ↑ │ # │ ↓ # └───> ξ ξ - surface_index1 = :j_backward - surface_index2 = :i_forward + surface_index1 = Indexing.j_backward + surface_index2 = Indexing.i_forward elseif ((lower && orientation_code == 1) # Corner 0 of my side matches corner 1 of other side || (!lower && orientation_code == 2)) # Corner 0 of other side matches corner 2 of my side @@ -254,8 +254,8 @@ function orientation_to_indices_p4est(my_face, other_face, orientation_code) # ↑ ↑ # │ │ # └───> ξ η <───┘ - surface_index1 = :j_forward - surface_index2 = :i_backward + surface_index1 = Indexing.j_forward + surface_index2 = Indexing.i_backward else # orientation_code == 3 # Corner 0 of my side matches corner 3 of other side and # corner 0 of other side matches corner 3 of my side. @@ -267,8 +267,8 @@ function orientation_to_indices_p4est(my_face, other_face, orientation_code) # ↑ │ # │ ↓ # └───> ξ η - surface_index1 = :i_backward - surface_index2 = :j_backward + surface_index1 = Indexing.i_backward + surface_index2 = Indexing.j_backward end else # flipped if orientation_code == 0 @@ -281,8 +281,8 @@ function orientation_to_indices_p4est(my_face, other_face, orientation_code) # ↑ ↑ # │ │ # └───> ξ └───> η - surface_index1 = :j_forward - surface_index2 = :i_forward + surface_index1 = Indexing.j_forward + surface_index2 = Indexing.i_forward elseif orientation_code == 2 # Corner 0 of my side matches corner 2 of other side and # corner 0 of other side matches corner 2 of my side. @@ -294,8 +294,8 @@ function orientation_to_indices_p4est(my_face, other_face, orientation_code) # ↑ │ # │ ↓ # └───> ξ η - surface_index1 = :i_forward - surface_index2 = :j_backward + surface_index1 = Indexing.i_forward + surface_index2 = Indexing.j_backward elseif orientation_code == 1 # Corner 0 of my side matches corner 1 of other side and # corner 0 of other side matches corner 1 of my side. @@ -307,8 +307,8 @@ function orientation_to_indices_p4est(my_face, other_face, orientation_code) # ↑ ↑ # │ │ # └───> ξ ξ <───┘ - surface_index1 = :i_backward - surface_index2 = :j_forward + surface_index1 = Indexing.i_backward + surface_index2 = Indexing.j_forward else # orientation_code == 3 # Corner 0 of my side matches corner 3 of other side and # corner 0 of other side matches corner 3 of my side. @@ -320,8 +320,8 @@ function orientation_to_indices_p4est(my_face, other_face, orientation_code) # ↑ │ # │ ↓ # └───> ξ ξ - surface_index1 = :j_backward - surface_index2 = :i_backward + surface_index1 = Indexing.j_backward + surface_index2 = Indexing.i_backward end end diff --git a/src/solvers/dgsem_p4est/containers_parallel.jl b/src/solvers/dgsem_p4est/containers_parallel.jl index 676b37efff3..627a2ef47a0 100644 --- a/src/solvers/dgsem_p4est/containers_parallel.jl +++ b/src/solvers/dgsem_p4est/containers_parallel.jl @@ -9,7 +9,7 @@ mutable struct P4estMPIInterfaceContainer{NDIMS, uEltype <: Real, NDIMSP2} <: AbstractContainer u::Array{uEltype, NDIMSP2} # [primary/secondary, variable, i, j, interface] local_neighbor_ids::Vector{Int} # [interface] - node_indices::Vector{NTuple{NDIMS, Symbol}} # [interface] + node_indices::Vector{NTuple{NDIMS, IndexInfo}} # [interface] local_sides::Vector{Int} # [interface] # internal `resize!`able storage @@ -60,7 +60,7 @@ function init_mpi_interfaces(mesh::Union{ParallelP4estMesh, ParallelT8codeMesh}, local_neighbor_ids = Vector{Int}(undef, n_mpi_interfaces) - node_indices = Vector{NTuple{NDIMS, Symbol}}(undef, n_mpi_interfaces) + node_indices = Vector{NTuple{NDIMS, IndexInfo}}(undef, n_mpi_interfaces) local_sides = Vector{Int}(undef, n_mpi_interfaces) @@ -92,11 +92,11 @@ mutable struct P4estMPIMortarContainer{NDIMS, uEltype <: Real, RealT <: Real, ND u::Array{uEltype, NDIMSP3} # [small/large side, variable, position, i, j, mortar] local_neighbor_ids::Vector{Vector{Int}} # [mortar][ids] local_neighbor_positions::Vector{Vector{Int}} # [mortar][positions] - node_indices::Matrix{NTuple{NDIMS, Symbol}} # [small/large, mortar] + node_indices::Matrix{NTuple{NDIMS, IndexInfo}} # [small/large, mortar] normal_directions::Array{RealT, NDIMSP2} # [dimension, i, j, position, mortar] # internal `resize!`able storage _u::Vector{uEltype} - _node_indices::Vector{NTuple{NDIMS, Symbol}} + _node_indices::Vector{NTuple{NDIMS, IndexInfo}} _normal_directions::Vector{RealT} end @@ -153,7 +153,7 @@ function init_mpi_mortars(mesh::Union{ParallelP4estMesh, ParallelT8codeMesh}, eq local_neighbor_ids = fill(Vector{Int}(), n_mpi_mortars) local_neighbor_positions = fill(Vector{Int}(), n_mpi_mortars) - _node_indices = Vector{NTuple{NDIMS, Symbol}}(undef, 2 * n_mpi_mortars) + _node_indices = Vector{NTuple{NDIMS, IndexInfo}}(undef, 2 * n_mpi_mortars) node_indices = unsafe_wrap(Array, pointer(_node_indices), (2, n_mpi_mortars)) _normal_directions = Vector{RealT}(undef, diff --git a/src/solvers/dgsem_p4est/containers_parallel_2d.jl b/src/solvers/dgsem_p4est/containers_parallel_2d.jl index d531d33821b..198b3280742 100644 --- a/src/solvers/dgsem_p4est/containers_parallel_2d.jl +++ b/src/solvers/dgsem_p4est/containers_parallel_2d.jl @@ -14,24 +14,24 @@ # relative to the interface. if local_side == 1 || orientation == 0 # Forward indexing - i = :i_forward + i = Indexing.i_forward else # Backward indexing - i = :i_backward + i = Indexing.i_backward end if faces[local_side] == 0 # Index face in negative x-direction - mpi_interfaces.node_indices[mpi_interface_id] = (:begin, i) + mpi_interfaces.node_indices[mpi_interface_id] = (Indexing.first, i) elseif faces[local_side] == 1 # Index face in positive x-direction - mpi_interfaces.node_indices[mpi_interface_id] = (:end, i) + mpi_interfaces.node_indices[mpi_interface_id] = (Indexing.last, i) elseif faces[local_side] == 2 # Index face in negative y-direction - mpi_interfaces.node_indices[mpi_interface_id] = (i, :begin) + mpi_interfaces.node_indices[mpi_interface_id] = (i, Indexing.first) else # faces[local_side] == 3 # Index face in positive y-direction - mpi_interfaces.node_indices[mpi_interface_id] = (i, :end) + mpi_interfaces.node_indices[mpi_interface_id] = (i, Indexing.last) end return mpi_interfaces diff --git a/src/solvers/dgsem_p4est/containers_parallel_3d.jl b/src/solvers/dgsem_p4est/containers_parallel_3d.jl index 56f0a543b97..37cbc6bb236 100644 --- a/src/solvers/dgsem_p4est/containers_parallel_3d.jl +++ b/src/solvers/dgsem_p4est/containers_parallel_3d.jl @@ -9,11 +9,11 @@ @inline function init_mpi_interface_node_indices!(mpi_interfaces::P4estMPIInterfaceContainer{3}, faces, local_side, orientation, mpi_interface_id) - # Align interface at the primary element (primary element has surface indices (:i_forward, :j_forward)). + # Align interface at the primary element (primary element has surface indices (Indexing.i_forward, Indexing.j_forward)). # The secondary element needs to be indexed differently. if local_side == 1 - surface_index1 = :i_forward - surface_index2 = :j_forward + surface_index1 = Indexing.i_forward + surface_index2 = Indexing.j_forward else # local_side == 2 surface_index1, surface_index2 = orientation_to_indices_p4est(faces[2], faces[1], @@ -22,28 +22,28 @@ if faces[local_side] == 0 # Index face in negative x-direction - mpi_interfaces.node_indices[mpi_interface_id] = (:begin, surface_index1, + mpi_interfaces.node_indices[mpi_interface_id] = (Indexing.first, surface_index1, surface_index2) elseif faces[local_side] == 1 # Index face in positive x-direction - mpi_interfaces.node_indices[mpi_interface_id] = (:end, surface_index1, + mpi_interfaces.node_indices[mpi_interface_id] = (Indexing.last, surface_index1, surface_index2) elseif faces[local_side] == 2 # Index face in negative y-direction - mpi_interfaces.node_indices[mpi_interface_id] = (surface_index1, :begin, + mpi_interfaces.node_indices[mpi_interface_id] = (surface_index1, Indexing.first, surface_index2) elseif faces[local_side] == 3 # Index face in positive y-direction - mpi_interfaces.node_indices[mpi_interface_id] = (surface_index1, :end, + mpi_interfaces.node_indices[mpi_interface_id] = (surface_index1, Indexing.last, surface_index2) elseif faces[local_side] == 4 # Index face in negative z-direction mpi_interfaces.node_indices[mpi_interface_id] = (surface_index1, surface_index2, - :begin) + Indexing.first) else # faces[local_side] == 5 # Index face in positive z-direction mpi_interfaces.node_indices[mpi_interface_id] = (surface_index1, surface_index2, - :end) + Indexing.last) end return mpi_interfaces @@ -57,8 +57,8 @@ end # Align mortar at small side. # The large side needs to be indexed differently. if side == 1 - surface_index1 = :i_forward - surface_index2 = :j_forward + surface_index1 = Indexing.i_forward + surface_index2 = Indexing.j_forward else surface_index1, surface_index2 = orientation_to_indices_p4est(faces[2], faces[1], @@ -67,28 +67,28 @@ end if faces[side] == 0 # Index face in negative x-direction - mortars.node_indices[side, mortar_id] = (:begin, surface_index1, + mortars.node_indices[side, mortar_id] = (Indexing.first, surface_index1, surface_index2) elseif faces[side] == 1 # Index face in positive x-direction - mortars.node_indices[side, mortar_id] = (:end, surface_index1, + mortars.node_indices[side, mortar_id] = (Indexing.last, surface_index1, surface_index2) elseif faces[side] == 2 # Index face in negative y-direction - mortars.node_indices[side, mortar_id] = (surface_index1, :begin, + mortars.node_indices[side, mortar_id] = (surface_index1, Indexing.first, surface_index2) elseif faces[side] == 3 # Index face in positive y-direction - mortars.node_indices[side, mortar_id] = (surface_index1, :end, + mortars.node_indices[side, mortar_id] = (surface_index1, Indexing.last, surface_index2) elseif faces[side] == 4 # Index face in negative z-direction mortars.node_indices[side, mortar_id] = (surface_index1, surface_index2, - :begin) + Indexing.first) else # faces[side] == 5 # Index face in positive z-direction mortars.node_indices[side, mortar_id] = (surface_index1, surface_index2, - :end) + Indexing.last) end end diff --git a/src/solvers/dgsem_p4est/dg_2d.jl b/src/solvers/dgsem_p4est/dg_2d.jl index 1b38eaa2d40..a7101580fcf 100644 --- a/src/solvers/dgsem_p4est/dg_2d.jl +++ b/src/solvers/dgsem_p4est/dg_2d.jl @@ -24,7 +24,7 @@ function create_cache(mesh::Union{P4estMesh{2}, T8codeMesh{2}}, equations, u_threaded) end -# index_to_start_step_2d(index::Symbol, index_range) +# index_to_start_step_2d(index::IndexInfo, index_range) # # Given a symbolic `index` and an `indexrange` (usually `eachnode(dg)`), # return `index_start, index_step`, i.e., a tuple containing @@ -45,17 +45,17 @@ end # i_volume += i_volume_step # j_volume += j_volume_step # end -@inline function index_to_start_step_2d(index::Symbol, index_range) +@inline function index_to_start_step_2d(index::IndexInfo, index_range) index_begin = first(index_range) index_end = last(index_range) - if index === :begin + if index === Indexing.first return index_begin, 0 - elseif index === :end + elseif index === Indexing.last return index_end, 0 - elseif index === :i_forward + elseif index === Indexing.i_forward return index_begin, 1 - else # if index === :i_backward + else # if index === Indexing.i_backward return index_end, -1 end end @@ -149,7 +149,7 @@ function calc_interface_flux!(surface_flux_values, # Initiate the secondary index to be used in the surface for loop. # This index on the primary side will always run forward but # the secondary index might need to run backwards for flipped sides. - if :i_backward in secondary_indices + if Indexing.i_backward in secondary_indices node_secondary = index_end node_secondary_step = -1 else @@ -615,7 +615,7 @@ end large_indices = node_indices[2, mortar] large_direction = indices2direction(large_indices) - if :i_backward in large_indices + if Indexing.i_backward in large_indices for i in eachnode(dg) for v in eachvariable(equations) surface_flux_values[v, end + 1 - i, large_direction, large_element] = u_buffer[v, diff --git a/src/solvers/dgsem_p4est/dg_2d_parabolic.jl b/src/solvers/dgsem_p4est/dg_2d_parabolic.jl index baa9f7bf516..3810d7091b1 100644 --- a/src/solvers/dgsem_p4est/dg_2d_parabolic.jl +++ b/src/solvers/dgsem_p4est/dg_2d_parabolic.jl @@ -428,7 +428,7 @@ end large_indices = node_indices[2, mortar] large_direction = indices2direction(large_indices) - if :i_backward in large_indices + if Indexing.i_backward in large_indices for i in eachnode(dg) for v in eachvariable(equations) surface_flux_values[v, end + 1 - i, large_direction, large_element] = u_buffer[v, @@ -637,7 +637,7 @@ function calc_interface_flux!(surface_flux_values, # Initiate the secondary index to be used in the surface for loop. # This index on the primary side will always run forward but # the secondary index might need to run backwards for flipped sides. - if :i_backward in secondary_indices + if Indexing.i_backward in secondary_indices node_secondary = index_end node_secondary_step = -1 else diff --git a/src/solvers/dgsem_p4est/dg_2d_parallel.jl b/src/solvers/dgsem_p4est/dg_2d_parallel.jl index 633c6f1d067..003c7830901 100644 --- a/src/solvers/dgsem_p4est/dg_2d_parallel.jl +++ b/src/solvers/dgsem_p4est/dg_2d_parallel.jl @@ -71,7 +71,7 @@ function calc_mpi_interface_flux!(surface_flux_values, # Initiate the node index to be used in the surface for loop, # the surface flux storage must be indexed in alignment with the local element indexing - if :i_backward in local_indices + if Indexing.i_backward in local_indices surface_node = index_end surface_node_step = -1 else @@ -308,7 +308,7 @@ end # correct orientation. # Note that the index of the small sides will always run forward but # the index of the large side might need to run backwards for flipped sides. - if :i_backward in large_indices + if Indexing.i_backward in large_indices for i in eachnode(dg) for v in eachvariable(equations) surface_flux_values[v, end + 1 - i, large_direction, element] = u_buffer[v, diff --git a/src/solvers/dgsem_p4est/dg_3d.jl b/src/solvers/dgsem_p4est/dg_3d.jl index 0632e3d3d8e..5413cacce16 100644 --- a/src/solvers/dgsem_p4est/dg_3d.jl +++ b/src/solvers/dgsem_p4est/dg_3d.jl @@ -29,9 +29,9 @@ function create_cache(mesh::Union{P4estMesh{3}, T8codeMesh{3}}, equations, (; fstar_primary_threaded, fstar_secondary_threaded, fstar_tmp_threaded, u_threaded) end -# index_to_start_step_3d(index::Symbol, index_range) +# index_to_start_step_3d(index::IndexInfo, index_range) # -# Given a symbolic `index` and an `indexrange` (usually `eachnode(dg)`), +# Given an `index` and an `indexrange` (usually `eachnode(dg)`), # return `index_start, index_step_i, index_step_j`, i.e., a tuple containing # - `index_start`, an index value to begin a loop # - `index_step_i`, an index step to update during an `i` loop @@ -41,9 +41,9 @@ end # !!! warning # This assumes that loops using the return values are written as # -# i_volume_start, i_volume_step_i, i_volume_step_j = index_to_start_step_3d(symbolic_index_i, index_range) -# j_volume_start, j_volume_step_i, j_volume_step_j = index_to_start_step_3d(symbolic_index_j, index_range) -# k_volume_start, k_volume_step_i, k_volume_step_j = index_to_start_step_3d(symbolic_index_k, index_range) +# i_volume_start, i_volume_step_i, i_volume_step_j = index_to_start_step_3d(index_info_i, index_range) +# j_volume_start, j_volume_step_i, j_volume_step_j = index_to_start_step_3d(index_info_j, index_range) +# k_volume_start, k_volume_step_i, k_volume_step_j = index_to_start_step_3d(index_info_k, index_range) # # i_volume, j_volume, k_volume = i_volume_start, j_volume_start, k_volume_start # for j_surface in index_range @@ -58,36 +58,36 @@ end # j_volume += j_volume_step_j # k_volume += k_volume_step_j # end -@inline function index_to_start_step_3d(index::Symbol, index_range) +@inline function index_to_start_step_3d(index::IndexInfo, index_range) index_begin = first(index_range) index_end = last(index_range) - if index === :begin + if index === Indexing.first return index_begin, 0, 0 - elseif index === :end + elseif index === Indexing.last return index_end, 0, 0 - elseif index === :i_forward + elseif index === Indexing.i_forward return index_begin, 1, index_begin - index_end - 1 - elseif index === :i_backward + elseif index === Indexing.i_backward return index_end, -1, index_end + 1 - index_begin - elseif index === :j_forward + elseif index === Indexing.j_forward return index_begin, 0, 1 - else # if index === :j_backward + else # if index === Indexing.j_backward return index_end, 0, -1 end end # Extract the two varying indices from a symbolic index tuple. -# For example, `surface_indices((:i_forward, :end, :j_forward)) == (:i_forward, :j_forward)`. +# For example, `surface_indices((Indexing.i_forward, Indexing.last, Indexing.i_forward)) == (Indexing.i_forward, Indexing.i_forward)`. @inline function surface_indices(indices::NTuple{3, Symbol}) i1, i2, i3 = indices index = i1 - (index === :begin || index === :end) && return (i2, i3) + (index === Indexing.first || index === Indexing.last) && return (i2, i3) index = i2 - (index === :begin || index === :end) && return (i1, i3) + (index === Indexing.first || index === Indexing.last) && return (i1, i3) - # i3 in (:begin, :end) + # i3 in (Indexing.first, Indexing.last) return (i1, i2) end From 0c63b8eed3be637d51d692e05fffa8b12d734d43 Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Mon, 25 Nov 2024 14:40:58 +0100 Subject: [PATCH 2/5] missing import --- examples/structured_2d_dgsem/elixir_advection_meshview.jl | 1 + examples/structured_2d_dgsem/elixir_mhd_coupled.jl | 1 + 2 files changed, 2 insertions(+) diff --git a/examples/structured_2d_dgsem/elixir_advection_meshview.jl b/examples/structured_2d_dgsem/elixir_advection_meshview.jl index 5208da33e6c..e26c818afd8 100644 --- a/examples/structured_2d_dgsem/elixir_advection_meshview.jl +++ b/examples/structured_2d_dgsem/elixir_advection_meshview.jl @@ -1,5 +1,6 @@ using OrdinaryDiffEq using Trixi +import Trixi.Indexing ############################################################################### # Coupled semidiscretization of two linear advection systems using converter functions diff --git a/examples/structured_2d_dgsem/elixir_mhd_coupled.jl b/examples/structured_2d_dgsem/elixir_mhd_coupled.jl index 7baa17a0776..511640c1dac 100644 --- a/examples/structured_2d_dgsem/elixir_mhd_coupled.jl +++ b/examples/structured_2d_dgsem/elixir_mhd_coupled.jl @@ -1,5 +1,6 @@ using OrdinaryDiffEq using Trixi +import Trixi.Indexing ############################################################################### # Two semidiscretizations of the ideal GLM-MHD systems using converter functions such that From e1d56512852ce7cd15839a02a2b51cc374433a70 Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Mon, 25 Nov 2024 14:41:36 +0100 Subject: [PATCH 3/5] missed Symbol --- src/solvers/dgsem_p4est/dg_3d.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/solvers/dgsem_p4est/dg_3d.jl b/src/solvers/dgsem_p4est/dg_3d.jl index 5413cacce16..81c36300444 100644 --- a/src/solvers/dgsem_p4est/dg_3d.jl +++ b/src/solvers/dgsem_p4est/dg_3d.jl @@ -79,7 +79,7 @@ end # Extract the two varying indices from a symbolic index tuple. # For example, `surface_indices((Indexing.i_forward, Indexing.last, Indexing.i_forward)) == (Indexing.i_forward, Indexing.i_forward)`. -@inline function surface_indices(indices::NTuple{3, Symbol}) +@inline function surface_indices(indices::NTuple{3, IndexInfo}) i1, i2, i3 = indices index = i1 (index === Indexing.first || index === Indexing.last) && return (i2, i3) From 9b374158a9e91825041e2801c75a0af3d6986225 Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Mon, 25 Nov 2024 14:42:07 +0100 Subject: [PATCH 4/5] explicitly skip Trixi.Indexing --- test/test_aqua.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test_aqua.jl b/test/test_aqua.jl index 04c4a533d26..af9cdfb6e99 100644 --- a/test/test_aqua.jl +++ b/test/test_aqua.jl @@ -16,7 +16,8 @@ include("test_trixi.jl") Trixi.StartUpDG.MeshData],)) @test isnothing(check_no_implicit_imports(Trixi, skip = (Core, Base, Trixi.P4est, Trixi.T8code, - Trixi.EllipsisNotation))) + Trixi.EllipsisNotation, + Trixi.Indexing))) @test isnothing(check_no_stale_explicit_imports(Trixi, ignore = (:derivative_operator, :periodic_derivative_operator, From 9a467c9fd64ac87ab3bf602901a6f76b1201a74a Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Mon, 25 Nov 2024 14:43:25 +0100 Subject: [PATCH 5/5] formatter --- .../elixir_advection_coupled.jl | 64 ++++++++++++++----- .../elixir_advection_meshview.jl | 16 +++-- .../structured_2d_dgsem/elixir_mhd_coupled.jl | 16 +++-- src/solvers/dg.jl | 1 - src/solvers/dgsem_p4est/containers_3d.jl | 36 +++++++---- 5 files changed, 96 insertions(+), 37 deletions(-) diff --git a/examples/structured_2d_dgsem/elixir_advection_coupled.jl b/examples/structured_2d_dgsem/elixir_advection_coupled.jl index e842c6185d9..6eb8e22a5c1 100644 --- a/examples/structured_2d_dgsem/elixir_advection_coupled.jl +++ b/examples/structured_2d_dgsem/elixir_advection_coupled.jl @@ -62,13 +62,21 @@ coupling_function12 = (x, u, equations_other, equations_own) -> u coupling_function13 = (x, u, equations_other, equations_own) -> u # Define the coupling boundary conditions and the system it is coupled to. -boundary_conditions_x_neg1 = BoundaryConditionCoupled(2, (Indexing.last, Indexing.i_forward), Float64, +boundary_conditions_x_neg1 = BoundaryConditionCoupled(2, + (Indexing.last, Indexing.i_forward), + Float64, coupling_function12) -boundary_conditions_x_pos1 = BoundaryConditionCoupled(2, (Indexing.first, Indexing.i_forward), Float64, +boundary_conditions_x_pos1 = BoundaryConditionCoupled(2, + (Indexing.first, Indexing.i_forward), + Float64, coupling_function12) -boundary_conditions_y_neg1 = BoundaryConditionCoupled(3, (Indexing.i_forward, Indexing.last), Float64, +boundary_conditions_y_neg1 = BoundaryConditionCoupled(3, + (Indexing.i_forward, Indexing.last), + Float64, coupling_function13) -boundary_conditions_y_pos1 = BoundaryConditionCoupled(3, (Indexing.i_forward, Indexing.first), Float64, +boundary_conditions_y_pos1 = BoundaryConditionCoupled(3, + (Indexing.i_forward, Indexing.first), + Float64, coupling_function13) # A semidiscretization collects data structures and functions for the spatial discretization @@ -94,13 +102,21 @@ coupling_function21 = (x, u, equations_other, equations_own) -> u coupling_function24 = (x, u, equations_other, equations_own) -> u # Define the coupling boundary conditions and the system it is coupled to. -boundary_conditions_x_neg2 = BoundaryConditionCoupled(1, (Indexing.last, Indexing.i_forward), Float64, +boundary_conditions_x_neg2 = BoundaryConditionCoupled(1, + (Indexing.last, Indexing.i_forward), + Float64, coupling_function21) -boundary_conditions_x_pos2 = BoundaryConditionCoupled(1, (Indexing.first, Indexing.i_forward), Float64, +boundary_conditions_x_pos2 = BoundaryConditionCoupled(1, + (Indexing.first, Indexing.i_forward), + Float64, coupling_function21) -boundary_conditions_y_neg2 = BoundaryConditionCoupled(4, (Indexing.i_forward, Indexing.last), Float64, +boundary_conditions_y_neg2 = BoundaryConditionCoupled(4, + (Indexing.i_forward, Indexing.last), + Float64, coupling_function24) -boundary_conditions_y_pos2 = BoundaryConditionCoupled(4, (Indexing.i_forward, Indexing.first), Float64, +boundary_conditions_y_pos2 = BoundaryConditionCoupled(4, + (Indexing.i_forward, Indexing.first), + Float64, coupling_function24) # A semidiscretization collects data structures and functions for the spatial discretization @@ -126,13 +142,21 @@ coupling_function34 = (x, u, equations_other, equations_own) -> u coupling_function31 = (x, u, equations_other, equations_own) -> u # Define the coupling boundary conditions and the system it is coupled to. -boundary_conditions_x_neg3 = BoundaryConditionCoupled(4, (Indexing.last, Indexing.i_forward), Float64, +boundary_conditions_x_neg3 = BoundaryConditionCoupled(4, + (Indexing.last, Indexing.i_forward), + Float64, coupling_function34) -boundary_conditions_x_pos3 = BoundaryConditionCoupled(4, (Indexing.first, Indexing.i_forward), Float64, +boundary_conditions_x_pos3 = BoundaryConditionCoupled(4, + (Indexing.first, Indexing.i_forward), + Float64, coupling_function34) -boundary_conditions_y_neg3 = BoundaryConditionCoupled(1, (Indexing.i_forward, Indexing.last), Float64, +boundary_conditions_y_neg3 = BoundaryConditionCoupled(1, + (Indexing.i_forward, Indexing.last), + Float64, coupling_function31) -boundary_conditions_y_pos3 = BoundaryConditionCoupled(1, (Indexing.i_forward, Indexing.first), Float64, +boundary_conditions_y_pos3 = BoundaryConditionCoupled(1, + (Indexing.i_forward, Indexing.first), + Float64, coupling_function31) # A semidiscretization collects data structures and functions for the spatial discretization @@ -158,13 +182,21 @@ coupling_function43 = (x, u, equations_other, equations_own) -> u coupling_function42 = (x, u, equations_other, equations_own) -> u # Define the coupling boundary conditions and the system it is coupled to. -boundary_conditions_x_neg4 = BoundaryConditionCoupled(3, (Indexing.last, Indexing.i_forward), Float64, +boundary_conditions_x_neg4 = BoundaryConditionCoupled(3, + (Indexing.last, Indexing.i_forward), + Float64, coupling_function43) -boundary_conditions_x_pos4 = BoundaryConditionCoupled(3, (Indexing.first, Indexing.i_forward), Float64, +boundary_conditions_x_pos4 = BoundaryConditionCoupled(3, + (Indexing.first, Indexing.i_forward), + Float64, coupling_function43) -boundary_conditions_y_neg4 = BoundaryConditionCoupled(2, (Indexing.i_forward, Indexing.last), Float64, +boundary_conditions_y_neg4 = BoundaryConditionCoupled(2, + (Indexing.i_forward, Indexing.last), + Float64, coupling_function42) -boundary_conditions_y_pos4 = BoundaryConditionCoupled(2, (Indexing.i_forward, Indexing.first), Float64, +boundary_conditions_y_pos4 = BoundaryConditionCoupled(2, + (Indexing.i_forward, Indexing.first), + Float64, coupling_function42) # A semidiscretization collects data structures and functions for the spatial discretization diff --git a/examples/structured_2d_dgsem/elixir_advection_meshview.jl b/examples/structured_2d_dgsem/elixir_advection_meshview.jl index e26c818afd8..e05e4eca1f3 100644 --- a/examples/structured_2d_dgsem/elixir_advection_meshview.jl +++ b/examples/structured_2d_dgsem/elixir_advection_meshview.jl @@ -56,17 +56,25 @@ coupling_function = (x, u, equations_other, equations_own) -> u # For a system with coupling in x and y see examples/structured_2d_dgsem/elixir_advection_coupled.jl. boundary_conditions1 = ( # Connect left boundary with right boundary of left mesh - x_neg = BoundaryConditionCoupled(2, (Indexing.last, Indexing.i_forward), Float64, + x_neg = BoundaryConditionCoupled(2, + (Indexing.last, + Indexing.i_forward), Float64, coupling_function), - x_pos = BoundaryConditionCoupled(2, (Indexing.first, Indexing.i_forward), Float64, + x_pos = BoundaryConditionCoupled(2, + (Indexing.first, + Indexing.i_forward), Float64, coupling_function), y_neg = boundary_condition_periodic, y_pos = boundary_condition_periodic) boundary_conditions2 = ( # Connect left boundary with right boundary of left mesh - x_neg = BoundaryConditionCoupled(1, (Indexing.last, Indexing.i_forward), Float64, + x_neg = BoundaryConditionCoupled(1, + (Indexing.last, + Indexing.i_forward), Float64, coupling_function), - x_pos = BoundaryConditionCoupled(1, (Indexing.first, Indexing.i_forward), Float64, + x_pos = BoundaryConditionCoupled(1, + (Indexing.first, + Indexing.i_forward), Float64, coupling_function), y_neg = boundary_condition_periodic, y_pos = boundary_condition_periodic) diff --git a/examples/structured_2d_dgsem/elixir_mhd_coupled.jl b/examples/structured_2d_dgsem/elixir_mhd_coupled.jl index 511640c1dac..77e68292e79 100644 --- a/examples/structured_2d_dgsem/elixir_mhd_coupled.jl +++ b/examples/structured_2d_dgsem/elixir_mhd_coupled.jl @@ -50,9 +50,13 @@ mesh1 = StructuredMesh(cells_per_dimension, periodicity = (false, true)) coupling_function1 = (x, u, equations_other, equations_own) -> u -boundary_conditions1 = (x_neg = BoundaryConditionCoupled(2, (Indexing.last, Indexing.i_forward), Float64, +boundary_conditions1 = (x_neg = BoundaryConditionCoupled(2, + (Indexing.last, + Indexing.i_forward), Float64, coupling_function1), - x_pos = BoundaryConditionCoupled(2, (Indexing.first, Indexing.i_forward), Float64, + x_pos = BoundaryConditionCoupled(2, + (Indexing.first, + Indexing.i_forward), Float64, coupling_function1), y_neg = boundary_condition_periodic, y_pos = boundary_condition_periodic) @@ -73,9 +77,13 @@ mesh2 = StructuredMesh(cells_per_dimension, periodicity = (false, true)) coupling_function2 = (x, u, equations_other, equations_own) -> u -boundary_conditions2 = (x_neg = BoundaryConditionCoupled(1, (Indexing.last, Indexing.i_forward), Float64, +boundary_conditions2 = (x_neg = BoundaryConditionCoupled(1, + (Indexing.last, + Indexing.i_forward), Float64, coupling_function2), - x_pos = BoundaryConditionCoupled(1, (Indexing.first, Indexing.i_forward), Float64, + x_pos = BoundaryConditionCoupled(1, + (Indexing.first, + Indexing.i_forward), Float64, coupling_function2), y_neg = boundary_condition_periodic, y_pos = boundary_condition_periodic) diff --git a/src/solvers/dg.jl b/src/solvers/dg.jl index fae5b6e02be..4abc3c950c5 100644 --- a/src/solvers/dg.jl +++ b/src/solvers/dg.jl @@ -751,7 +751,6 @@ function compute_coefficients!(u, func, t, mesh::AbstractMesh{3}, equations, dg: end end end - end # @muladd; put it up here because module definition below needs to be at top level # For some mesh types, elements next to a surface may have local coordinate systems diff --git a/src/solvers/dgsem_p4est/containers_3d.jl b/src/solvers/dgsem_p4est/containers_3d.jl index 88bbc693a2a..fa788797cdd 100644 --- a/src/solvers/dgsem_p4est/containers_3d.jl +++ b/src/solvers/dgsem_p4est/containers_3d.jl @@ -94,28 +94,34 @@ end if faces[side] == 0 # Index face in negative x-direction - interfaces.node_indices[side, interface_id] = (Indexing.first, surface_index1, + interfaces.node_indices[side, interface_id] = (Indexing.first, + surface_index1, surface_index2) elseif faces[side] == 1 # Index face in positive x-direction - interfaces.node_indices[side, interface_id] = (Indexing.last, surface_index1, + interfaces.node_indices[side, interface_id] = (Indexing.last, + surface_index1, surface_index2) elseif faces[side] == 2 # Index face in negative y-direction - interfaces.node_indices[side, interface_id] = (surface_index1, Indexing.first, + interfaces.node_indices[side, interface_id] = (surface_index1, + Indexing.first, surface_index2) elseif faces[side] == 3 # Index face in positive y-direction - interfaces.node_indices[side, interface_id] = (surface_index1, Indexing.last, + interfaces.node_indices[side, interface_id] = (surface_index1, + Indexing.last, surface_index2) elseif faces[side] == 4 # Index face in negative z-direction interfaces.node_indices[side, interface_id] = (surface_index1, - surface_index2, Indexing.first) + surface_index2, + Indexing.first) else # faces[side] == 5 # Index face in positive z-direction interfaces.node_indices[side, interface_id] = (surface_index1, - surface_index2, Indexing.last) + surface_index2, + Indexing.last) end end @@ -127,22 +133,28 @@ end face, boundary_id) if face == 0 # Index face in negative x-direction - boundaries.node_indices[boundary_id] = (Indexing.first, Indexing.i_forward, Indexing.j_forward) + boundaries.node_indices[boundary_id] = (Indexing.first, Indexing.i_forward, + Indexing.j_forward) elseif face == 1 # Index face in positive x-direction - boundaries.node_indices[boundary_id] = (Indexing.last, Indexing.i_forward, Indexing.j_forward) + boundaries.node_indices[boundary_id] = (Indexing.last, Indexing.i_forward, + Indexing.j_forward) elseif face == 2 # Index face in negative y-direction - boundaries.node_indices[boundary_id] = (Indexing.i_forward, Indexing.first, Indexing.j_forward) + boundaries.node_indices[boundary_id] = (Indexing.i_forward, Indexing.first, + Indexing.j_forward) elseif face == 3 # Index face in positive y-direction - boundaries.node_indices[boundary_id] = (Indexing.i_forward, Indexing.last, Indexing.j_forward) + boundaries.node_indices[boundary_id] = (Indexing.i_forward, Indexing.last, + Indexing.j_forward) elseif face == 4 # Index face in negative z-direction - boundaries.node_indices[boundary_id] = (Indexing.i_forward, Indexing.j_forward, Indexing.first) + boundaries.node_indices[boundary_id] = (Indexing.i_forward, Indexing.j_forward, + Indexing.first) else # face == 5 # Index face in positive z-direction - boundaries.node_indices[boundary_id] = (Indexing.i_forward, Indexing.j_forward, Indexing.last) + boundaries.node_indices[boundary_id] = (Indexing.i_forward, Indexing.j_forward, + Indexing.last) end return boundaries