-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Francois Foucart
committed
Jan 27, 2025
1 parent
1c22afe
commit 715ddc1
Showing
8 changed files
with
111 additions
and
31 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
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,12 @@ | ||
// Distributed under the MIT License. | ||
// See LICENSE.txt for details. | ||
|
||
#pragma once | ||
|
||
/// Labels used to navigate the action list when using MC | ||
namespace Particles::MonteCarlo::Actions::Labels { | ||
/// Beginning of the MC algorithm | ||
struct BeginMonteCarlo {}; | ||
/// End of the MC algorithm | ||
struct EndMonteCarlo {}; | ||
} // namespace Particles::MonteCarlo::Actions::Labels |
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
73 changes: 73 additions & 0 deletions
73
src/Evolution/Particles/MonteCarlo/Actions/TriggerMonteCarloEvolution.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,73 @@ | ||
// Distributed under the MIT License. | ||
// See LICENSE.txt for details. | ||
|
||
#pragma once | ||
|
||
#include <cstddef> | ||
#include <optional> | ||
#include <tuple> | ||
#include <utility> | ||
|
||
#include "DataStructures/DataBox/DataBox.hpp" | ||
#include "Evolution/Particles/MonteCarlo/Actions/Labels.hpp" | ||
#include "Parallel/AlgorithmExecution.hpp" | ||
#include "ParallelAlgorithms/Actions/Goto.hpp" | ||
#include "Time/Tags/TimeStepId.hpp" | ||
#include "Time/Time.hpp" | ||
#include "Time/TimeStepId.hpp" | ||
#include "Utilities/TMPL.hpp" | ||
|
||
/// \cond | ||
namespace Parallel { | ||
template <typename Metavariables> | ||
class GlobalCache; | ||
} // namespace Parallel | ||
namespace tuples { | ||
template <typename...> | ||
class TaggedTuple; | ||
} // namespace tuples | ||
/// \endcond | ||
|
||
namespace Particles::MonteCarlo::Actions { | ||
/*! | ||
* \brief Goes to `Labels::BeginMonteCarlo` or `Labels::EndMonteCarlo` depending | ||
* on whether we are at the end of a full time step or at an intermediate step | ||
* of the timestepping algorithm. | ||
* | ||
* GlobalCache: nothing | ||
* | ||
* DataBox: | ||
* - Uses: | ||
* - | ||
*/ | ||
struct TriggerMonteCarloEvolution { | ||
template <typename DbTagsList, typename... InboxTags, typename Metavariables, | ||
typename ArrayIndex, typename ActionList, | ||
typename ParallelComponent> | ||
static Parallel::iterable_action_return_t apply( | ||
db::DataBox<DbTagsList>& box, | ||
const tuples::TaggedTuple<InboxTags...>& /*inboxes*/, | ||
const Parallel::GlobalCache<Metavariables>& /*cache*/, | ||
const ArrayIndex& /*array_index*/, ActionList /*meta*/, | ||
const ParallelComponent* const /*meta*/) { | ||
const auto& next_time_id = db::get<::Tags::Next<::Tags::TimeStepId>>(box); | ||
// We only run MC if we are at the beginning of a full time step | ||
const bool trigger_mc = (next_time_id.substep() == 0); | ||
// Note: we jump to the `Label+1` because the label actions don't do | ||
// anything anyway | ||
if (trigger_mc) { | ||
const size_t mc_index = | ||
tmpl::index_of<ActionList, | ||
::Actions::Label<Labels::BeginMonteCarlo>>::value + | ||
1; | ||
return {Parallel::AlgorithmExecution::Continue, mc_index}; | ||
} else { | ||
const size_t post_mc_index = | ||
tmpl::index_of<ActionList, | ||
::Actions::Label<Labels::EndMonteCarlo>>::value + | ||
1; | ||
return {Parallel::AlgorithmExecution::Continue, post_mc_index}; | ||
} | ||
} | ||
}; | ||
} // namespace Particles::MonteCarlo::Actions |
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