Skip to content

Commit

Permalink
Avoid overstepping arrays, copying non-cell vars
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Prather committed Oct 20, 2023
1 parent cc725b0 commit 83494d1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions kharma/b_ct/b_ct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ TaskStatus B_CT::CalculateEMF(MeshData<Real> *md)
auto& emf_pack = md->PackVariables(std::vector<std::string>{"B_CT.emf"});

// Figure out indices
const IndexRange3 b = KDomain::GetRange(md, IndexDomain::entire, 0, 0);
const IndexRange3 b1 = KDomain::GetRange(md, IndexDomain::entire, 1, 1);
const IndexRange3 b = KDomain::GetRange(md, IndexDomain::interior, 0, 0);
const IndexRange3 b1 = KDomain::GetRange(md, IndexDomain::interior, 1, 1);
const IndexRange block = IndexRange{0, emf_pack.GetDim(5)-1};

auto pmb0 = md->GetBlockData(0)->GetBlockPointer().get();
Expand Down Expand Up @@ -339,8 +339,8 @@ TaskStatus B_CT::AddSource(MeshData<Real> *md, MeshData<Real> *mdudt)
auto& emf_pack = md->PackVariables(std::vector<std::string>{"B_CT.emf"});

// Figure out indices
const IndexRange3 b = KDomain::GetRange(md, IndexDomain::entire, 0, 0);
const IndexRange3 b1 = KDomain::GetRange(md, IndexDomain::entire, 0, 1);
const IndexRange3 b = KDomain::GetRange(md, IndexDomain::interior, 0, 0);
const IndexRange3 b1 = KDomain::GetRange(md, IndexDomain::interior, 0, 1);
const IndexRange block = IndexRange{0, emf_pack.GetDim(5)-1};

auto pmb0 = md->GetBlockData(0)->GetBlockPointer().get();
Expand Down
6 changes: 3 additions & 3 deletions kharma/driver/kharma_driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,12 @@ class KHARMADriver : public MultiStageDriver {
static TaskStatus WeightedSumDataFace(const std::vector<MetadataFlag> &flags, MeshData<Real> *in1, MeshData<Real> *in2, const Real w1, const Real w2,
MeshData<Real> *out)
{
Kokkos::Profiling::pushRegion("Task_WeightedSumData");
Kokkos::Profiling::pushRegion("Task_WeightedSumDataFace");
const auto &x = in1->PackVariables(flags);
const auto &y = in2->PackVariables(flags);
const auto &z = out->PackVariables(flags);
parthenon::par_for(
DEFAULT_LOOP_PATTERN, "WeightedSumData", DevExecSpace(), 0, x.GetDim(5) - 1, 0,
DEFAULT_LOOP_PATTERN, "WeightedSumDataFace", DevExecSpace(), 0, x.GetDim(5) - 1, 0,
x.GetDim(4) - 1, 0, x.GetDim(3) - 1, 0, x.GetDim(2) - 1, 0, x.GetDim(1) - 1,
KOKKOS_LAMBDA(const int b, const int l, const int k, const int j, const int i) {
// TOOD(someone) This is potentially dangerous and/or not intended behavior
Expand All @@ -182,7 +182,7 @@ class KHARMADriver : public MultiStageDriver {
z(b, F3, l, k, j, i) = w1 * x(b, F3, l, k, j, i) + w2 * y(b, F3, l, k, j, i);
}
});
Kokkos::Profiling::popRegion(); // Task_WeightedSumData
Kokkos::Profiling::popRegion(); // Task_WeightedSumDataFace
return TaskStatus::complete;
}

Expand Down
2 changes: 1 addition & 1 deletion kharma/driver/kharma_step.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ TaskCollection KHARMADriver::MakeDefaultTaskCollection(BlockList_t &blocks, int
// At the end of the step, updating "mbd_sub_step_final" updates the base
// So we have to keep a copy at the beginning to calculate jcon
// We have to explicitly copy, since after the first step `Add`==`Get`
Copy<MeshBlockData<Real>>({}, base.get(), pmb->meshblock_data.Add("preserve").get());
Copy<MeshBlockData<Real>>({Metadata::Cell}, base.get(), pmb->meshblock_data.Add("preserve").get());
}
}
}
Expand Down

0 comments on commit 83494d1

Please sign in to comment.