Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
jyoo1042 committed Aug 12, 2024
1 parent d3d3c5e commit 4c4c42f
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 66 deletions.
40 changes: 28 additions & 12 deletions src/Evolution/DgSubcell/Actions/ReconstructionCommunication.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,18 +251,21 @@ struct SendDataForReconstruction {
//
// Copy over data since it's already oriented from interpolation
//
// hacky solution to remove the negative rho interpolation problem
size_t N = sliced_data_in_direction.size();
DataVector temp{N};
for (size_t i = 0; i < N; i++) {
temp[i] = sliced_data_in_direction[i];
}
for (size_t i = 0; i < 363; i++) {
if (temp[i] < 1e-12) {
temp[i] = 1e-12;
}
}
std::copy(temp.begin(), temp.end(), subcell_data_to_send.begin());
// hacky solution to remove the negative rho interpolation problem :
// Removed while trying to work on a new solution
// size_t N = sliced_data_in_direction.size();
// DataVector temp{N};
// for (size_t i = 0; i < N; i++) {
// temp[i] = sliced_data_in_direction[i];
// }
// for (size_t i = 0; i < 363; i++) {
// if (temp[i] < 1e-12) {
// temp[i] = 1e-12;
// }
// }
// std::copy(temp.begin(), temp.end(), subcell_data_to_send.begin());
std::copy(sliced_data_in_direction.begin(),
sliced_data_in_direction.end(), subcell_data_to_send.begin());

// Copy rdmp data to end of subcell_data_to_send
std::copy(
Expand Down Expand Up @@ -309,6 +312,19 @@ template <size_t Dim, typename GhostDataMutator, bool LocalTimeStepping>
struct ReceivedAndSendDataForReconstruction {
using inbox_tags = tmpl::list<
evolution::dg::Tags::BoundaryCorrectionAndGhostCellsInbox<Dim>>;
template <typename DbTags, typename... InboxTags, typename ArrayIndex,
typename ActionList, typename ParallelComponent,
typename Metavariables>
static Parallel::iterable_action_return_t apply(
db::DataBox<DbTags>& box, tuples::TaggedTuple<InboxTags...>& /*inboxes*/,

Check failure on line 319 in src/Evolution/DgSubcell/Actions/ReconstructionCommunication.hpp

View workflow job for this annotation

GitHub Actions / Clang-tidy (Debug)

unused parameter 'box'

Check failure on line 319 in src/Evolution/DgSubcell/Actions/ReconstructionCommunication.hpp

View workflow job for this annotation

GitHub Actions / Clang-tidy (Debug)

parameter 'box' is unused

Check failure on line 319 in src/Evolution/DgSubcell/Actions/ReconstructionCommunication.hpp

View workflow job for this annotation

GitHub Actions / Clang-tidy (Release)

unused parameter 'box'

Check failure on line 319 in src/Evolution/DgSubcell/Actions/ReconstructionCommunication.hpp

View workflow job for this annotation

GitHub Actions / Clang-tidy (Release)

parameter 'box' is unused
Parallel::GlobalCache<Metavariables>& cache,

Check failure on line 320 in src/Evolution/DgSubcell/Actions/ReconstructionCommunication.hpp

View workflow job for this annotation

GitHub Actions / Clang-tidy (Debug)

unused parameter 'cache'

Check failure on line 320 in src/Evolution/DgSubcell/Actions/ReconstructionCommunication.hpp

View workflow job for this annotation

GitHub Actions / Clang-tidy (Debug)

parameter 'cache' is unused

Check failure on line 320 in src/Evolution/DgSubcell/Actions/ReconstructionCommunication.hpp

View workflow job for this annotation

GitHub Actions / Clang-tidy (Release)

unused parameter 'cache'

Check failure on line 320 in src/Evolution/DgSubcell/Actions/ReconstructionCommunication.hpp

View workflow job for this annotation

GitHub Actions / Clang-tidy (Release)

parameter 'cache' is unused
const ArrayIndex& /*array_index*/, const ActionList /*meta*/,
const ParallelComponent* const /*meta*/) {
using flux_variables = typename Metavariables::system::flux_variables;

Check failure on line 323 in src/Evolution/DgSubcell/Actions/ReconstructionCommunication.hpp

View workflow job for this annotation

GitHub Actions / Clang-tidy (Debug)

unused type alias 'flux_variables'

Check failure on line 323 in src/Evolution/DgSubcell/Actions/ReconstructionCommunication.hpp

View workflow job for this annotation

GitHub Actions / Clang-tidy (Release)

unused type alias 'flux_variables'

// need a conditional to make sure I have received all the data that was
// needed at this stage for interpolation.
}
};
/*!
* \brief Receive the subcell data from our neighbor, and accumulate the data
Expand Down
111 changes: 57 additions & 54 deletions src/Evolution/DgSubcell/SliceData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,61 +138,64 @@ DirectionMap<Dim, DataVector> slice_data_impl(
subcell_extents);
}
}
} else {
// We add directions to `interpolated` to mark that we are interpolating
// in this particular direction. The value of the bool is `true` _if_ we
// did FD interpolation and `false` if DG interpolation should be
// done. This allows passing in a DirectionalIdMap of just the neighbors
// that need interpolation but with `std::nullopt` in order to not spend
// resources slicing when the data would be overwritten by DG
// interpolation (cheaper and more accurate).
DirectionMap<Dim, bool> interpolated{};
for (const auto& [directional_element_id, interpolant] :
fd_to_neighbor_fd_interpolants) {
if (LIKELY(not interpolant.has_value())) {
// Just to keep track.
interpolated[directional_element_id.direction()] = false;
continue;
}
interpolated[directional_element_id.direction()] = true;
auto result_span =
gsl::make_span(result.at(directional_element_id.direction()).data(),
result.at(directional_element_id.direction()).size() -
additional_buffer);
interpolant.value().interpolate(make_not_null(&result_span),
volume_subcell_vars);
}
// Now copy data for neighbors that are in the same block.
for (size_t component_index = 0; component_index < number_of_components;
++component_index) {
const size_t component_offset_volume = component_index * num_pts;
for (auto& [direction, sliced_data] : result) {
if (UNLIKELY(interpolated.contains(direction))) {
continue;
}
const size_t component_offset_result =
gsl::at(result_grid_points, direction.dimension()) *
component_index;
std::array<size_t, Dim> lower_bounds =
make_array<Dim>(static_cast<size_t>(0));
std::array<size_t, Dim> upper_bounds = subcell_extents.indices();
if (direction.side() == Side::Lower) {
gsl::at(upper_bounds, direction.dimension()) = number_of_ghost_points;
} else {
gsl::at(lower_bounds, direction.dimension()) =
gsl::at(upper_bounds, direction.dimension()) -
number_of_ghost_points;
}
// No need to worry about sliced_data including the additional buffer
// because the instantiations of copy_data above never use the
// sliced_data.size(). All indexing is done by the lower/upper bounds
// arguments
copy_data(&sliced_data, volume_subcell_vars, component_offset_result,
component_offset_volume, lower_bounds, upper_bounds,
subcell_extents);
}
}
}
// else {
// // We add directions to `interpolated` to mark that we are interpolating
// // in this particular direction. The value of the bool is `true` _if_ we
// // did FD interpolation and `false` if DG interpolation should be
// // done. This allows passing in a DirectionalIdMap of just the neighbors
// // that need interpolation but with `std::nullopt` in order to not spend
// // resources slicing when the data would be overwritten by DG
// // interpolation (cheaper and more accurate).
// DirectionMap<Dim, bool> interpolated{};
// for (const auto& [directional_element_id, interpolant] :
// fd_to_neighbor_fd_interpolants) {
// if (LIKELY(not interpolant.has_value())) {
// // Just to keep track.
// interpolated[directional_element_id.direction()] = false;
// continue;
// }
// interpolated[directional_element_id.direction()] = true;
// auto result_span =
// gsl::make_span(result.at(directional_element_id.direction()).data(),
// result.at(directional_element_id.direction()).size()
// -
// additional_buffer);
// interpolant.value().interpolate(make_not_null(&result_span),
// volume_subcell_vars);
// }
// // Now copy data for neighbors that are in the same block.
// for (size_t component_index = 0; component_index < number_of_components;
// ++component_index) {
// const size_t component_offset_volume = component_index * num_pts;
// for (auto& [direction, sliced_data] : result) {
// if (UNLIKELY(interpolated.contains(direction))) {
// continue;
// }
// const size_t component_offset_result =
// gsl::at(result_grid_points, direction.dimension()) *
// component_index;
// std::array<size_t, Dim> lower_bounds =
// make_array<Dim>(static_cast<size_t>(0));
// std::array<size_t, Dim> upper_bounds = subcell_extents.indices();
// if (direction.side() == Side::Lower) {
// gsl::at(upper_bounds, direction.dimension()) =
// number_of_ghost_points;
// } else {
// gsl::at(lower_bounds, direction.dimension()) =
// gsl::at(upper_bounds, direction.dimension()) -
// number_of_ghost_points;
// }
// // No need to worry about sliced_data including the additional buffer
// // because the instantiations of copy_data above never use the
// // sliced_data.size(). All indexing is done by the lower/upper bounds
// // arguments
// copy_data(&sliced_data, volume_subcell_vars, component_offset_result,
// component_offset_volume, lower_bounds, upper_bounds,
// subcell_extents);
// }
// }
// }
return result;
}

Expand Down

0 comments on commit 4c4c42f

Please sign in to comment.