-
Notifications
You must be signed in to change notification settings - Fork 191
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
Aug 27, 2024
1 parent
11928b9
commit 8e243df
Showing
11 changed files
with
1,290 additions
and
6 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
391 changes: 391 additions & 0 deletions
391
src/Evolution/Particles/MonteCarlo/GhostZoneCommunication.hpp
Large diffs are not rendered by default.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
src/Evolution/Particles/MonteCarlo/GhostZoneCommunicationStep.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,30 @@ | ||
// Distributed under the MIT License. | ||
// See LICENSE.txt for details. | ||
|
||
#pragma once | ||
|
||
/// Items related to the evolution of particles | ||
/// Items related to Monte-Carlo radiation transport | ||
namespace Particles::MonteCarlo { | ||
|
||
/// This class is used to template communication actions | ||
/// in the Monte-Carlo code, to know which of the two | ||
/// communication steps we need to take care of | ||
/// (just before or just after the MC step). | ||
enum class CommunicationStep { | ||
/// PreStep should occur just before the MC step. | ||
/// It should send to the ghost zones of each | ||
/// element the fluid and metric data. | ||
PreStep, | ||
/// PostStep should occur just after a MC step. | ||
/// It sends packets that have left their current | ||
/// element to the element they now belong to. | ||
/// NOT CODE YET: This is also when information | ||
/// about energy/momentum/lepton number exchance | ||
/// in the ghost zones should be communicated back | ||
/// to the corresponding live point for coupling to | ||
/// the fluid evolution. | ||
PostStep | ||
}; | ||
|
||
} // namespace Particles::MonteCarlo |
96 changes: 96 additions & 0 deletions
96
src/Evolution/Particles/MonteCarlo/GhostZoneCommunicationTags.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,96 @@ | ||
// Distributed under the MIT License. | ||
// See LICENSE.txt for details. | ||
|
||
#pragma once | ||
|
||
#include <array> | ||
#include <map> | ||
#include <optional> | ||
#include <utility> | ||
|
||
#include "DataStructures/DataBox/Tag.hpp" | ||
#include "DataStructures/Tensor/TypeAliases.hpp" | ||
#include "Domain/Structure/DirectionalIdMap.hpp" | ||
#include "Evolution/Particles/MonteCarlo/GhostZoneCommunicationStep.hpp" | ||
#include "Evolution/Particles/MonteCarlo/Packet.hpp" | ||
#include "Time/Slab.hpp" | ||
#include "Time/Tags/TimeStepId.hpp" | ||
#include "Time/Time.hpp" | ||
#include "Time/TimeStepId.hpp" | ||
#include "Utilities/Gsl.hpp" | ||
|
||
/// \cond | ||
class DataVector; | ||
/// \endcond | ||
|
||
/// Items related to the evolution of particles | ||
/// Items related to Monte-Carlo radiation transport | ||
namespace Particles::MonteCarlo { | ||
|
||
/*! | ||
* \brief The container for ghost zone data to be communicated | ||
* in the Monte-Carlo algorithm | ||
* | ||
* The stored data consists of | ||
* (1) The fluid variables in those ghost cells, in the form | ||
* of a DataVector. The data should contain the | ||
* scalars (baryon density, temperature, electron fraction, | ||
* and cell light-crossing time) in pre-step communication | ||
* and (coupling_tilde_tau, coupling_tilde_s, coupling_rho_ye) | ||
* in post-step communication | ||
* (2) The packets moved from a neighbor to this element. This | ||
* can be std::null_ptr in pre-step communication | ||
*/ | ||
template <size_t Dim> | ||
struct McGhostZoneData { | ||
void pup(PUP::er& p) { | ||
p | ghost_zone_hydro_variables; | ||
p | packets_entering_this_element; | ||
} | ||
|
||
DataVector ghost_zone_hydro_variables{}; | ||
std::optional<std::vector<Particles::MonteCarlo::Packet>> | ||
packets_entering_this_element{}; | ||
}; | ||
|
||
/// Inbox tag to be used before MC step | ||
template <size_t Dim, CommunicationStep CommStep> | ||
struct McGhostZoneDataInboxTag { | ||
using stored_type = McGhostZoneData<Dim>; | ||
|
||
using temporal_id = TimeStepId; | ||
using type = std::map<TimeStepId, DirectionalIdMap<Dim, stored_type>>; | ||
using value_type = type; | ||
|
||
CommunicationStep comm_step = CommStep; | ||
|
||
template <typename ReceiveDataType> | ||
static size_t insert_into_inbox(const gsl::not_null<type*> inbox, | ||
const temporal_id& time_step_id, | ||
ReceiveDataType&& data) { | ||
auto& current_inbox = (*inbox)[time_step_id]; | ||
if (not current_inbox.insert(std::forward<ReceiveDataType>(data)) | ||
.second) { | ||
ERROR("Failed to insert data to receive at instance '" | ||
<< time_step_id | ||
<< " in McGhostZonePreStepDataInboxTag.\n"); | ||
} | ||
return current_inbox.size(); | ||
} | ||
|
||
void pup(PUP::er& /*p*/) {} | ||
}; | ||
|
||
// Tags to put in DataBox for MC communication. | ||
namespace Tags { | ||
|
||
/// Simple tag for the structure containing ghost zone data | ||
/// for Monte Carlo radiation transport. | ||
template <size_t Dim> | ||
struct McGhostZoneDataTag : db::SimpleTag { | ||
using type = DirectionalIdMap<Dim, McGhostZoneData<Dim>>; | ||
}; | ||
|
||
} // namespace Tags | ||
|
||
} // namespace Particles::MonteCarlo |
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,47 @@ | ||
// Distributed under the MIT License. | ||
// See LICENSE.txt for details. | ||
|
||
#pragma once | ||
|
||
#include <optional> | ||
|
||
#include "DataStructures/DataBox/Tag.hpp" | ||
#include "Domain/Structure/DirectionalIdMap.hpp" | ||
|
||
/// \cond | ||
class DataVector; | ||
/// \endcond | ||
|
||
namespace Particles::MonteCarlo { | ||
|
||
/// Structure used to gather ghost zone data for Monte-Carlo evolution. | ||
/// We need the rest mass density, electron fraction, temperature, and | ||
/// an estimate of the light-crossing time one cell deep within each | ||
/// neighboring element. | ||
template <size_t Dim> | ||
struct MortarData { | ||
DirectionalIdMap<Dim, std::optional<DataVector>> rest_mass_density{}; | ||
DirectionalIdMap<Dim, std::optional<DataVector>> electron_fraction{}; | ||
DirectionalIdMap<Dim, std::optional<DataVector>> temperature{}; | ||
DirectionalIdMap<Dim, std::optional<DataVector>> cell_light_crossing_time{}; | ||
|
||
void pup(PUP::er& p) { | ||
p | rest_mass_density; | ||
p | electron_fraction; | ||
p | temperature; | ||
p | cell_light_crossing_time; | ||
} | ||
}; | ||
|
||
namespace Tags { | ||
|
||
/// Simple tag containing the fluid and metric data in the ghost zones | ||
/// for Monte-Carlo packets evolution. | ||
template <size_t Dim> | ||
struct MortarDataTag : db::SimpleTag { | ||
using type = MortarData<Dim>; | ||
}; | ||
|
||
} // namespace Tags | ||
|
||
} // namespace Particles::MonteCarlo |
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,31 @@ | ||
// Distributed under the MIT License. | ||
// See LICENSE.txt for details. | ||
|
||
#pragma once | ||
|
||
#include <vector> | ||
|
||
#include "DataStructures/DataBox/Tag.hpp" | ||
#include "DataStructures/Tensor/TypeAliases.hpp" | ||
#include "Evolution/Particles/MonteCarlo/Packet.hpp" | ||
|
||
/// Items related to the evolution of particles | ||
/// Items related to Monte-Carlo radiation transport | ||
/// Tags for MC | ||
namespace Particles::MonteCarlo::Tags { | ||
|
||
/// Simple tag containing the vector of Monte-Carlo | ||
/// packets belonging to an element. | ||
struct PacketsOnElement : db::SimpleTag { | ||
using type = std::vector<Particles::MonteCarlo::Packet>; | ||
}; | ||
|
||
/// Simple tag containing an approximation of the light | ||
/// crossing time for each cell (the shortest time among | ||
/// all coordinate axis directions). | ||
template <typename DataType> | ||
struct CellLightCrossingTime : db::SimpleTag { | ||
using type = Scalar<DataType>; | ||
}; | ||
|
||
} // namespace Particles::MonteCarlo::Tags |
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
Oops, something went wrong.