diff --git a/src/Evolution/Executables/RadiationTransport/MonteCarlo/EvolveMonteCarlo.hpp b/src/Evolution/Executables/RadiationTransport/MonteCarlo/EvolveMonteCarlo.hpp index 8f90a3c796749..e1bdde9784fd1 100644 --- a/src/Evolution/Executables/RadiationTransport/MonteCarlo/EvolveMonteCarlo.hpp +++ b/src/Evolution/Executables/RadiationTransport/MonteCarlo/EvolveMonteCarlo.hpp @@ -201,11 +201,11 @@ struct EvolutionMetavars { Parallel::Phase::Evolve, tmpl::list< Actions::AdvanceTime, - evolution::Actions::RunEventsAndTriggers, + evolution::Actions::RunEventsAndTriggers, Actions::AdvanceTime, - evolution::Actions::RunEventsAndTriggers, + evolution::Actions::RunEventsAndTriggers, Actions::AdvanceTime, - evolution::Actions::RunEventsAndTriggers, + evolution::Actions::RunEventsAndTriggers, Particles::MonteCarlo::Actions::SendDataForMcCommunication< volume_dim, // No local time stepping diff --git a/src/Evolution/Particles/MonteCarlo/Actions/InitializeMonteCarlo.hpp b/src/Evolution/Particles/MonteCarlo/Actions/InitializeMonteCarlo.hpp index f5ecaf298f3be..8838277839dc5 100644 --- a/src/Evolution/Particles/MonteCarlo/Actions/InitializeMonteCarlo.hpp +++ b/src/Evolution/Particles/MonteCarlo/Actions/InitializeMonteCarlo.hpp @@ -49,8 +49,8 @@ namespace Initialization::Actions { /// - Adds: /// * Particles::MonteCarlo::Tags::PacketsOnElement /// * Particles::MonteCarlo::Tags::RandomNumberGenerator -/// * Particles::MonteCarlo::Tags::DesiredPacketEnergyAtEmission -/// +/// * Particles::MonteCarlo::Tags::DesiredPacketEnergyAtEmission< +/// NeutrinoSpecies> /// * Particles::MonteCarlo::Tags::CellLightCrossingTime /// * Background hydro variables /// * Particles::MonteCarlo::Tags::MortarDataTag @@ -117,7 +117,7 @@ struct InitializeMCTags { tmpl::list>( make_not_null(&box), std::move(all_packets)); - unsigned long seed = + const unsigned long seed = std::random_device{}(); // static_cast(time(NULL)); typename Particles::MonteCarlo::Tags::RandomNumberGenerator::type rng(seed); diff --git a/src/Evolution/Particles/MonteCarlo/GhostZoneCommunication.hpp b/src/Evolution/Particles/MonteCarlo/GhostZoneCommunication.hpp index d11ba5cedcc30..0ced96571ea55 100644 --- a/src/Evolution/Particles/MonteCarlo/GhostZoneCommunication.hpp +++ b/src/Evolution/Particles/MonteCarlo/GhostZoneCommunication.hpp @@ -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); } diff --git a/src/ParallelAlgorithms/Events/ObserveTimeStep.hpp b/src/ParallelAlgorithms/Events/ObserveTimeStep.hpp index 63751cb189d01..b736c560ceb41 100644 --- a/src/ParallelAlgorithms/Events/ObserveTimeStep.hpp +++ b/src/ParallelAlgorithms/Events/ObserveTimeStep.hpp @@ -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 void operator()(const TimeDelta& time_step, - // const typename System::variables_tag::type& variables, + const typename System::variables_tag::type& variables, Parallel::GlobalCache& 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>) { + 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(); diff --git a/tests/Unit/Evolution/Particles/MonteCarlo/Test_CellVolume.cpp b/tests/Unit/Evolution/Particles/MonteCarlo/Test_CellVolume.cpp index 4c8cc0adfb8bb..61ac032d2d0be 100644 --- a/tests/Unit/Evolution/Particles/MonteCarlo/Test_CellVolume.cpp +++ b/tests/Unit/Evolution/Particles/MonteCarlo/Test_CellVolume.cpp @@ -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 lapse{DataVector(dv_size, 1.2)}; - Scalar sqrt_determinant_spatial_metric{DataVector(dv_size, 0.9)}; - Scalar det_jacobian_logical_to_inertial{DataVector(dv_size, 1.1)}; + const DataVector zero_dv(dv_size, 0.0); + const Scalar lapse{DataVector(dv_size, 1.2)}; + const Scalar sqrt_determinant_spatial_metric + {DataVector(dv_size, 0.9)}; + const Scalar det_jacobian_logical_to_inertial + {DataVector(dv_size, 1.1)}; const double time_step = 0.6; Scalar cell_proper_four_volume{DataVector(dv_size, 0.0)}; diff --git a/tests/Unit/Evolution/Particles/MonteCarlo/Test_CommunicationTags.cpp b/tests/Unit/Evolution/Particles/MonteCarlo/Test_CommunicationTags.cpp index a91b6f4c8f5e4..46aaa87fdf8a3 100644 --- a/tests/Unit/Evolution/Particles/MonteCarlo/Test_CommunicationTags.cpp +++ b/tests/Unit/Evolution/Particles/MonteCarlo/Test_CommunicationTags.cpp @@ -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< diff --git a/tests/Unit/Evolution/Particles/MonteCarlo/Test_TakeTimeStep.cpp b/tests/Unit/Evolution/Particles/MonteCarlo/Test_TakeTimeStep.cpp index 1314fb15ccdfd..15ebadbc052fe 100644 --- a/tests/Unit/Evolution/Particles/MonteCarlo/Test_TakeTimeStep.cpp +++ b/tests/Unit/Evolution/Particles/MonteCarlo/Test_TakeTimeStep.cpp @@ -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 lapse{DataVector(dv_size, 1.0)}; + const Scalar lapse{DataVector(dv_size, 1.0)}; tnsr::II inv_spatial_metric = make_with_value>(lapse, 0.0); inv_spatial_metric.get(0, 0) = 1.0; @@ -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 sqrt_determinant_spatial_metric(dv_size, 1.0); - tnsr::I shift = + const Scalar sqrt_determinant_spatial_metric(dv_size, 1.0); + const tnsr::I shift = make_with_value>(lapse, 0.0); - tnsr::i d_lapse = + const tnsr::i d_lapse = make_with_value>(lapse, 0.0); - tnsr::iJ d_shift = + const tnsr::iJ d_shift = make_with_value>(lapse, 0.0); - tnsr::iJJ d_inv_spatial_metric = + const tnsr::iJJ d_inv_spatial_metric = make_with_value>(lapse, 0.0); // Mesh velocity set to std::null for now @@ -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 det_jacobian_logical_to_inertial(dv_size, 1.0); + const Scalar det_jacobian_logical_to_inertial(dv_size, 1.0); // Coordinates tnsr::I mesh_coordinates = diff --git a/tests/Unit/Evolution/Particles/MonteCarlo/Test_TimeStepAction.cpp b/tests/Unit/Evolution/Particles/MonteCarlo/Test_TimeStepAction.cpp index f3352014704d2..d7dca4d480ee8 100644 --- a/tests/Unit/Evolution/Particles/MonteCarlo/Test_TimeStepAction.cpp +++ b/tests/Unit/Evolution/Particles/MonteCarlo/Test_TimeStepAction.cpp @@ -88,11 +88,11 @@ struct component { Frame::Inertial>, Tags::deriv, tmpl::size_t, Frame::Inertial>, - Tags::deriv, + Tags::deriv, tmpl::size_t, Frame::Inertial>, gr::Tags::SpatialMetric, gr::Tags::InverseSpatialMetric, - gr::Tags::DetSpatialMetric, + gr::Tags::SqrtDetSpatialMetric, evolution::dg::subcell::Tags::Coordinates, domain::Tags::MeshVelocity, evolution::dg::subcell::fd::Tags::InverseJacobianLogicalToInertial, @@ -192,8 +192,8 @@ void test_advance_packets() { make_with_value>(lapse, 0.0); tnsr::iJ d_shift = make_with_value>(lapse, 0.0); - tnsr::iJJ d_inv_spatial_metric = - make_with_value>(lapse, 0.0); + tnsr::ijj d_spatial_metric = + make_with_value>(lapse, 0.0); // Fluid variables Scalar rest_mass_density(zero_dv); @@ -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,