-
Notifications
You must be signed in to change notification settings - Fork 44
Pack on virtual fields #1322
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
Pack on virtual fields #1322
Changes from all commits
8aae9ed
8fbfddc
4da3098
db4c866
c146a44
1daa5bc
8f59278
98d6640
4c08d6a
889af25
c0c0a5b
6e8a034
f4f0e71
183dde1
6b2c3a5
a997ab4
ebdda2f
e0508a7
713ae91
b071c5a
c828c9a
dd1cbab
0129de7
086c4bb
8638342
0d6b6a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,12 @@ | |
| #include <utility> | ||
| #include <vector> | ||
|
|
||
| #include <Kokkos_Core.hpp> | ||
|
|
||
| #include "basic_types.hpp" | ||
| #include "utils/concepts_lite.hpp" | ||
| #include "utils/error_checking.hpp" | ||
| #include "utils/type_list.hpp" | ||
|
|
||
| // SFINAE for block iter so that Sparse/SwarmPacks can work for MeshBlockData and MeshData | ||
| namespace { | ||
|
|
@@ -161,6 +166,65 @@ struct any_nonautoflux : public base_t<true> { | |
| } | ||
| }; | ||
| using any = any_nonautoflux; | ||
|
|
||
| // Concept to state that a typed-field is dependent on other | ||
| // fields, and is not itself an actual indexable field. | ||
|
Comment on lines
+170
to
+171
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should the concepts stuff be in concepts_lite or should it be here?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seemed specialized enough to the pack types that I put it here, but if the convention is to have all concepts in concepts_lite I'm happy to move it |
||
| template <typename T> | ||
| concept DependentVariable = | ||
| requires { typename T::independent_vars; }; // NOLINT(readability/braces) | ||
|
|
||
| template <typename... Ts> | ||
| struct virtual_variable_t { | ||
| using type = virtual_variable_t<Ts...>; | ||
| using independent_vars = TypeList<Ts...>; | ||
| }; | ||
|
|
||
| // Concept to check that a type shares an ancestor with virtual_variable_t | ||
| template <typename T> | ||
| concept VirtualVariable = requires { | ||
| typename T::type; | ||
| requires is_specialization_of<typename T::type, virtual_variable_t>::value; | ||
| }; // NOLINT(readability/braces) | ||
|
|
||
| // Concept to check that a type wants a subpack to evaluate the virtual field | ||
| template <typename T> | ||
| concept VirtualSubPack = requires { | ||
| typename T::pack_type; | ||
| requires std::is_same_v<decltype(T::pack_type::Naxes), const int>; | ||
| }; // NOLINT(readability/braces) | ||
|
|
||
| namespace impl { | ||
|
|
||
| struct AllIndependentVariables { | ||
| template <typename T> | ||
| requires(!DependentVariable<T>) | ||
| static auto get(T) { | ||
| return TypeList<T>(); | ||
| } | ||
|
|
||
| template <template <typename...> typename TL, typename... Ts> | ||
| static auto get(TL<Ts...>) { | ||
| return AllIndependentVariables::get(Ts()...); | ||
| } | ||
|
|
||
| template <typename T> | ||
| requires(DependentVariable<T>) | ||
| static auto get(T) { | ||
| return AllIndependentVariables::get(typename T::independent_vars()); | ||
| } | ||
|
|
||
| template <typename T, typename... Ts> | ||
| static auto get(T, Ts...) { | ||
| return union_type_lists_t<decltype(AllIndependentVariables::get(T())), | ||
| decltype(AllIndependentVariables::get(Ts()...))>(); | ||
| } | ||
| }; | ||
| } // namespace impl | ||
|
|
||
| // Get a TypeList of all the independent variables that make up the requested types. | ||
| template <typename... Ts> | ||
| using all_independent_variables_t = decltype(impl::AllIndependentVariables::get(Ts()...)); | ||
|
|
||
| } // namespace variable_names | ||
|
|
||
| // Namespace in which to put swarm variable name types that are used for indexing into | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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 think a lot of this has overlap with the
pack_views in my loop abstraction PR. We should think about if there is a way to combine things, but maybe after this is merged.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.
Probably it is mostly orthogonal after I have looked some more. I could change
pack_views to support virtual variables, but that would be separate fromSubPacks.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 was thinking of redoing this on top of the
pack_views. My first look at what you added seemed to me like it would be pretty straightforward.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.
pack_viewsare pretty tightly coupled to the loop abstraction stuff, so maybe not a replacement unless everyone switched to the loop abstraction.