-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6040 from nilsdeppe/add_threading_15
Add ElementLocationsReference tag, and TransformPdalForNodegroup metafunction
- Loading branch information
Showing
6 changed files
with
93 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/Parallel/ArrayCollection/Tags/ElementLocationsReference.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Distributed under the MIT License. | ||
// See LICENSE.txt for details. | ||
|
||
#pragma once | ||
|
||
#include <cstddef> | ||
#include <unordered_map> | ||
|
||
#include "DataStructures/DataBox/Tag.hpp" | ||
#include "Parallel/ArrayCollection/Tags/ElementLocations.hpp" | ||
#include "Parallel/GlobalCache.hpp" | ||
#include "Parallel/Invoke.hpp" | ||
#include "Utilities/Gsl.hpp" | ||
|
||
/// \cond | ||
template <size_t Dim> | ||
class ElementId; | ||
namespace Parallel { | ||
class NodeLock; | ||
} // namespace Parallel | ||
/// \endcond | ||
|
||
namespace Parallel::Tags { | ||
/// \brief The node (location) where different elements are. | ||
/// | ||
/// This should be in the DgElementArrayMember's DataBox. | ||
/// | ||
/// Implementation note: This should point to the ElementLocations located in | ||
/// the nodegroup's DataBox. | ||
template <size_t Dim, typename Metavariables, | ||
typename DgElementCollectionComponent> | ||
struct ElementLocationsReference : ElementLocations<Dim>, db::ReferenceTag { | ||
private: | ||
struct GetReference { | ||
using return_type = const typename ElementLocations<Dim>::type&; | ||
|
||
template <typename ParallelComponent, typename DbTagList> | ||
static return_type apply( | ||
db::DataBox<DbTagList>& box, | ||
const gsl::not_null<Parallel::NodeLock*> /*node_lock*/) { | ||
return db::get_mutable_reference<ElementLocations<Dim>>( | ||
make_not_null(&box)); | ||
} | ||
}; | ||
|
||
public: | ||
using base = ElementLocations<Dim>; | ||
using type = typename base::type; | ||
using argument_tags = | ||
tmpl::list<Parallel::Tags::GlobalCacheImpl<Metavariables>>; | ||
|
||
static const type& get( | ||
const Parallel::GlobalCache<Metavariables>* const& cache) { | ||
auto& parallel_comp = | ||
Parallel::get_parallel_component<DgElementCollectionComponent>(*cache); | ||
return Parallel::local_synchronous_action<GetReference>(parallel_comp); | ||
} | ||
}; | ||
} // namespace Parallel::Tags |
29 changes: 29 additions & 0 deletions
29
src/Parallel/ArrayCollection/TransformPdalForNodegroup.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Distributed under the MIT License. | ||
// See LICENSE.txt for details. | ||
|
||
#pragma once | ||
|
||
#include "Parallel/ArrayCollection/StartPhaseOnNodegroup.hpp" | ||
#include "Parallel/Phase.hpp" | ||
#include "Parallel/PhaseDependentActionList.hpp" | ||
#include "Utilities/TMPL.hpp" | ||
|
||
namespace Parallel { | ||
namespace detail { | ||
template <typename OnePhaseActions> | ||
struct TransformPdalForNodegroup { | ||
using type = tmpl::conditional_t< | ||
OnePhaseActions::phase == Parallel::Phase::Initialization, tmpl::list<>, | ||
Parallel::PhaseActions<OnePhaseActions::phase, | ||
tmpl::list<Actions::StartPhaseOnNodegroup>>>; | ||
}; | ||
} // namespace detail | ||
|
||
/// \brief Transforms the `PhaseDepActionList` (phase dependent action | ||
/// list/PDAL) from one used for a `evolution::DgElementArray` to that for | ||
/// `Parallel::DgElementCollection` | ||
template <typename PhaseDepActionList> | ||
using TransformPhaseDependentActionListForNodegroup = | ||
tmpl::flatten<tmpl::transform<PhaseDepActionList, | ||
detail::TransformPdalForNodegroup<tmpl::_1>>>; | ||
} // namespace Parallel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters