Skip to content

Commit

Permalink
Temporary fix for edges/corners in MC and TimeStepObserver
Browse files Browse the repository at this point in the history
  • Loading branch information
Francois Foucart committed Dec 6, 2024
1 parent f533cb9 commit 45d1b93
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
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
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
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 @@ -197,8 +197,8 @@ void test_advance_packets(const bool skip) {
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 @@ -317,7 +317,7 @@ void test_advance_packets(const bool skip) {
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 45d1b93

Please sign in to comment.