-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use enum instead of symbols for indexing #2178
base: main
Are you sure you want to change the base?
Conversation
Review checklistThis checklist is meant to assist creators of PRs (to let them know what reviewers will typically look for) and reviewers (to guide them in a structured review process). Items do not need to be checked explicitly for a PR to be eligible for merging. Purpose and scope
Code quality
Documentation
Testing
Performance
Verification
Created with ❤️ by the Trixi.jl community. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2178 +/- ##
=======================================
Coverage 96.36% 96.36%
=======================================
Files 480 480
Lines 38230 38230
=======================================
Hits 36840 36840
Misses 1390 1390
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Thanks for taking care of this! Once you're ready, please mark this PR as ready for review and request one from me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this! Please find below some comments.
@@ -1,5 +1,6 @@ | |||
using OrdinaryDiffEq | |||
using Trixi | |||
import Trixi.Indexing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the coupling stuff becomes non-experimental, we should export this from Trixi.jl.
import Trixi.Indexing | |
using Trixi: Indexing # coupling is an experimental feature |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What not
import Trixi.Indexing | |
using Trixi: Indexing |
Not a big fan of import
and it seems like the Julia community is slowly eschewing import
. But it's not a big deal either IMHO, so we can also just leave it as it is.
@@ -1,5 +1,6 @@ | |||
using OrdinaryDiffEq | |||
using Trixi | |||
import Trixi.Indexing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import Trixi.Indexing | |
using Trixi: Indexing # coupling is an experimental feature |
@@ -1,5 +1,6 @@ | |||
using OrdinaryDiffEq | |||
using Trixi | |||
import Trixi.Indexing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import Trixi.Indexing | |
using Trixi: Indexing # coupling is an experimental feature |
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is basically https://github.com/fredrikekre/EnumX.jl, so I think we should use that package instead. We should also discuss where to move this definition - https://github.com/trixi-framework/Trixi.jl/blob/main/src/basic_types.jl or auxiliary could also make sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tend to agree to use specialized packages wherever sensible. However, does it really improve anything except reducing our code by ~10 lines, at the cost of (ideally) having a comment explain what the @enumx
does?
But I'm fine either way 🤷♂️
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] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sloede will tell you that you should consider using a consistent alignment of the comments here and in the other files below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be great indeed 😍
After speaking with @maleadt in Lausanne and we decided that we might be able to permit Symbols being passed to the GPU JuliaGPU/GPUCompiler.jl#650 |
Some containers in Trixi.jl contain symbols, e.g.
node_indices
inP4estInterfaceContainer
. Symbols are not isbits, which could e.g. prevent GPU offloading.