Skip to content

Commit

Permalink
Additional corrections for communications and clang-tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
Francois Foucart committed Dec 6, 2024
1 parent 3641eb7 commit 84ed5be
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,11 @@ struct EvolutionMetavars {
Parallel::Phase::Evolve,
tmpl::list<
Actions::AdvanceTime,
evolution::Actions::RunEventsAndTriggers,
evolution::Actions::RunEventsAndTriggers<false>,
Actions::AdvanceTime,
evolution::Actions::RunEventsAndTriggers,
evolution::Actions::RunEventsAndTriggers<false>,
Actions::AdvanceTime,
evolution::Actions::RunEventsAndTriggers,
evolution::Actions::RunEventsAndTriggers<false>,
Particles::MonteCarlo::Actions::SendDataForMcCommunication<
volume_dim,
// No local time stepping
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ namespace Initialization::Actions {
/// - Adds:
/// * Particles::MonteCarlo::Tags::PacketsOnElement
/// * Particles::MonteCarlo::Tags::RandomNumberGenerator
/// * Particles::MonteCarlo::Tags::DesiredPacketEnergyAtEmission
/// <NeutrinoSpecies>
/// * Particles::MonteCarlo::Tags::DesiredPacketEnergyAtEmission<
/// NeutrinoSpecies>
/// * Particles::MonteCarlo::Tags::CellLightCrossingTime<DataVector>
/// * Background hydro variables
/// * Particles::MonteCarlo::Tags::MortarDataTag<dim>
Expand Down Expand Up @@ -117,7 +117,7 @@ struct InitializeMCTags {
tmpl::list<Particles::MonteCarlo::Tags::PacketsOnElement>>(
make_not_null(&box), std::move(all_packets));

unsigned long seed =
const unsigned long seed =
std::random_device{}(); // static_cast<unsigned long>(time(NULL));
typename Particles::MonteCarlo::Tags::RandomNumberGenerator::type rng(seed);

Expand Down
10 changes: 10 additions & 0 deletions src/Evolution/Particles/MonteCarlo/GhostZoneCommunication.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,16 @@ struct GhostDataMcPackets {
const size_t d = max_distance_direction.value().dimension();
const Side side = max_distance_direction.value().side();
packet.coordinates.get(d) += (side == Side::Lower) ? (2.0) : (-2.0);
// Corner/edge treatment; move packet in a live point for now
// Definitely needs improvement...
for (size_t dd = 0; dd < Dim; dd++) {
if (dd != d && packet.coordinates.get(dd) < -1.0) {
packet.coordinates.get(dd) = -2.0 - packet.coordinates.get(dd);
}
if (dd != d && packet.coordinates.get(dd) > 1.0) {
packet.coordinates.get(dd) = 2.0 - packet.coordinates.get(dd);
}
}
if (output.contains(max_distance_direction.value())) {
output[max_distance_direction.value()].push_back(packet);
}
Expand Down
11 changes: 7 additions & 4 deletions src/ParallelAlgorithms/Events/ObserveTimeStep.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,21 @@ class ObserveTimeStep : public Event {
// We obtain the grid size from the variables, rather than the mesh,
// so that this observer is not DG-specific.
using argument_tags =
tmpl::list<::Tags::TimeStep>; //, typename System::variables_tag>;
tmpl::list<::Tags::TimeStep, typename System::variables_tag>;

template <typename ArrayIndex, typename ParallelComponent,
typename Metavariables>
void operator()(const TimeDelta& time_step,
// const typename System::variables_tag::type& variables,
const typename System::variables_tag::type& variables,
Parallel::GlobalCache<Metavariables>& cache,
const ArrayIndex& array_index,
const ParallelComponent* const /*meta*/,
const ObservationValue& observation_value) const {
const size_t number_of_grid_points =
1; // variables.number_of_grid_points();
size_t number_of_grid_points = 1;
if constexpr (not std::is_same_v<typename System::variables_tag::tags_list,
tmpl::list<>>) {
number_of_grid_points = variables.number_of_grid_points();
}
const double slab_size = time_step.slab().duration().value();
const double step_size = abs(time_step.value());
const double wall_time = sys::wall_time();
Expand Down
10 changes: 6 additions & 4 deletions tests/Unit/Evolution/Particles/MonteCarlo/Test_CellVolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ SPECTRE_TEST_CASE("Unit.Evolution.Particles.MonteCarloCellVolume",
Spectral::Quadrature::CellCentered);

const size_t dv_size = 27;
DataVector zero_dv(dv_size, 0.0);
Scalar<DataVector> lapse{DataVector(dv_size, 1.2)};
Scalar<DataVector> sqrt_determinant_spatial_metric{DataVector(dv_size, 0.9)};
Scalar<DataVector> det_jacobian_logical_to_inertial{DataVector(dv_size, 1.1)};
const DataVector zero_dv(dv_size, 0.0);
const Scalar<DataVector> lapse{DataVector(dv_size, 1.2)};
const Scalar<DataVector> sqrt_determinant_spatial_metric
{DataVector(dv_size, 0.9)};
const Scalar<DataVector> det_jacobian_logical_to_inertial
{DataVector(dv_size, 1.1)};
const double time_step = 0.6;

Scalar<DataVector> cell_proper_four_volume{DataVector(dv_size, 0.0)};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,10 @@ void test_send_receive_actions() {
// topological coordinate of their new element.
packet_east.coordinates[0] -= 2.0;
packet_south.coordinates[1] += 2.0;
// Current hack for edges/corners
if constexpr (Dim > 2){
packet_south.coordinates[2] = -2.0 - packet_south.coordinates[2];
}
{
const auto& east_data = ActionTesting::get_inbox_tag<
comp, Particles::MonteCarlo::McGhostZoneDataInboxTag<
Expand Down
22 changes: 11 additions & 11 deletions tests/Unit/Evolution/Particles/MonteCarlo/Test_TakeTimeStep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ void test_flat_space_time_step() {
const size_t num_ghost_zones = 1;

const size_t dv_size = cube(size_1d);
DataVector zero_dv(dv_size, 0.0);
const DataVector zero_dv(dv_size, 0.0);
const size_t dv_size_with_ghost = cube(size_1d + 2 * num_ghost_zones);
DataVector zero_dv_with_ghost(dv_size_with_ghost, 0.0);
const DataVector zero_dv_with_ghost(dv_size_with_ghost, 0.0);
const size_t dv_size_in_ghost = square(size_1d) * num_ghost_zones;
DataVector zero_dv_in_ghost(dv_size_in_ghost, 0.0);
DataVector one_dv_in_ghost(dv_size_in_ghost, 1.0);
const DataVector zero_dv_in_ghost(dv_size_in_ghost, 0.0);
const DataVector one_dv_in_ghost(dv_size_in_ghost, 1.0);

// Minkowski metric
Scalar<DataVector> lapse{DataVector(dv_size, 1.0)};
const Scalar<DataVector> lapse{DataVector(dv_size, 1.0)};
tnsr::II<DataVector, 3, Frame::Inertial> inv_spatial_metric =
make_with_value<tnsr::II<DataVector, 3, Frame::Inertial>>(lapse, 0.0);
inv_spatial_metric.get(0, 0) = 1.0;
Expand All @@ -52,14 +52,14 @@ void test_flat_space_time_step() {
spatial_metric.get(0, 0) = 1.0;
spatial_metric.get(1, 1) = 1.0;
spatial_metric.get(2, 2) = 1.0;
Scalar<DataVector> sqrt_determinant_spatial_metric(dv_size, 1.0);
tnsr::I<DataVector, 3, Frame::Inertial> shift =
const Scalar<DataVector> sqrt_determinant_spatial_metric(dv_size, 1.0);
const tnsr::I<DataVector, 3, Frame::Inertial> shift =
make_with_value<tnsr::I<DataVector, 3, Frame::Inertial>>(lapse, 0.0);
tnsr::i<DataVector, 3, Frame::Inertial> d_lapse =
const tnsr::i<DataVector, 3, Frame::Inertial> d_lapse =
make_with_value<tnsr::i<DataVector, 3, Frame::Inertial>>(lapse, 0.0);
tnsr::iJ<DataVector, 3, Frame::Inertial> d_shift =
const tnsr::iJ<DataVector, 3, Frame::Inertial> d_shift =
make_with_value<tnsr::iJ<DataVector, 3, Frame::Inertial>>(lapse, 0.0);
tnsr::iJJ<DataVector, 3, Frame::Inertial> d_inv_spatial_metric =
const tnsr::iJJ<DataVector, 3, Frame::Inertial> d_inv_spatial_metric =
make_with_value<tnsr::iJJ<DataVector, 3, Frame::Inertial>>(lapse, 0.0);

// Mesh velocity set to std::null for now
Expand Down Expand Up @@ -90,7 +90,7 @@ void test_flat_space_time_step() {
inverse_jacobian_logical_to_inertial.get(0, 0) = 1.0;
inverse_jacobian_logical_to_inertial.get(1, 1) = 1.0;
inverse_jacobian_logical_to_inertial.get(2, 2) = 1.0;
Scalar<DataVector> det_jacobian_logical_to_inertial(dv_size, 1.0);
const Scalar<DataVector> det_jacobian_logical_to_inertial(dv_size, 1.0);

// Coordinates
tnsr::I<DataVector, 3, Frame::ElementLogical> mesh_coordinates =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ struct component {
Frame::Inertial>,
Tags::deriv<gr::Tags::Shift<DataVector, Dim>, tmpl::size_t<Dim>,
Frame::Inertial>,
Tags::deriv<gr::Tags::InverseSpatialMetric<DataVector, Dim>,
Tags::deriv<gr::Tags::SpatialMetric<DataVector, Dim>,
tmpl::size_t<Dim>, Frame::Inertial>,
gr::Tags::SpatialMetric<DataVector, Dim, Frame::Inertial>,
gr::Tags::InverseSpatialMetric<DataVector, Dim, Frame::Inertial>,
gr::Tags::DetSpatialMetric<DataVector>,
gr::Tags::SqrtDetSpatialMetric<DataVector>,
evolution::dg::subcell::Tags::Coordinates<Dim, Frame::ElementLogical>,
domain::Tags::MeshVelocity<Dim>,
evolution::dg::subcell::fd::Tags::InverseJacobianLogicalToInertial<Dim>,
Expand Down Expand Up @@ -192,8 +192,8 @@ void test_advance_packets() {
make_with_value<tnsr::i<DataVector, 3, Frame::Inertial>>(lapse, 0.0);
tnsr::iJ<DataVector, 3, Frame::Inertial> d_shift =
make_with_value<tnsr::iJ<DataVector, 3, Frame::Inertial>>(lapse, 0.0);
tnsr::iJJ<DataVector, 3, Frame::Inertial> d_inv_spatial_metric =
make_with_value<tnsr::iJJ<DataVector, 3, Frame::Inertial>>(lapse, 0.0);
tnsr::ijj<DataVector, 3, Frame::Inertial> d_spatial_metric =
make_with_value<tnsr::ijj<DataVector, 3, Frame::Inertial>>(lapse, 0.0);

// Fluid variables
Scalar<DataVector> rest_mass_density(zero_dv);
Expand Down Expand Up @@ -313,7 +313,7 @@ void test_advance_packets() {
shift,
d_lapse,
d_shift,
d_inv_spatial_metric,
d_spatial_metric,
spatial_metric,
inv_spatial_metric,
sqrt_determinant_spatial_metric,
Expand Down

0 comments on commit 84ed5be

Please sign in to comment.