Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some restarts w/non-CC fields #1144

Merged
merged 2 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
- [[PR 1004]](https://github.com/parthenon-hpc-lab/parthenon/pull/1004) Allow parameter modification from an input file for restarts

### Fixed (not changing behavior/API/variables/...)
- [[PR 1144]](https://github.com/parthenon-hpc-lab/parthenon/pull/1144) Fix some restarts w/non-CC fields
- [[PR 1132]](https://github.com/parthenon-hpc-lab/parthenon/pull/1132) Fix regional dependencies for iterative task lists and make solvers work for arbirtrary MeshData partitioning
- [[PR 1139]](https://github.com/parthenon-hpc-lab/parthenon/pull/1139) only add --expt-relaxed-constexpr for COMPILE_LANGUAGE:CXX
- [[PR 1131]](https://github.com/parthenon-hpc-lab/parthenon/pull/1131) Make deallocation of fine and sparse fields work
Expand Down
22 changes: 7 additions & 15 deletions src/parthenon_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,8 @@ void ParthenonManager::RestartPackages(Mesh &rm, RestartReader &resfile) {
}

// Allocate space based on largest vector
int max_vlen = 1;
int num_sparse = 0;
size_t nCells = 1;
size_t max_fillsize = 1;
for (const auto &v_info : all_vars_info) {
const auto &label = v_info.label;

Expand All @@ -306,27 +305,20 @@ void ParthenonManager::RestartPackages(Mesh &rm, RestartReader &resfile) {
"Dense field " + label +
" is marked as sparse in restart file");
}
max_vlen = std::max(max_vlen, v_info.num_components);
IndexRange out_ib = v_info.cellbounds.GetBoundsI(theDomain);
IndexRange out_jb = v_info.cellbounds.GetBoundsJ(theDomain);
IndexRange out_kb = v_info.cellbounds.GetBoundsK(theDomain);

std::vector<size_t> bsize;
bsize.push_back(out_ib.e - out_ib.s + 1);
bsize.push_back(out_jb.e - out_jb.s + 1);
bsize.push_back(out_kb.e - out_kb.s + 1);

nCells = std::max(nCells, bsize[0] * bsize[1] * bsize[2]);
max_fillsize =
std::max(max_fillsize, static_cast<size_t>(v_info.FillSize(theDomain)));
}

// make sure we have all sparse variables that are in the restart file
PARTHENON_REQUIRE_THROWS(
num_sparse == sparse_info.num_sparse,
"Mismatch between sparse fields in simulation and restart file");

std::vector<Real> tmp(static_cast<size_t>(nb) * nCells * max_vlen);
std::vector<Real> tmp(static_cast<size_t>(nb) * max_fillsize);
for (const auto &v_info : all_vars_info) {
const auto vlen = v_info.num_components;
const auto vlen = v_info.num_components * v_info.ntop_elems;
const auto fill_size = v_info.FillSize(theDomain);
const auto &label = v_info.label;

if (Globals::my_rank == 0) {
Expand Down Expand Up @@ -354,7 +346,7 @@ void ParthenonManager::RestartPackages(Mesh &rm, RestartReader &resfile) {
pmb->meshblock_data.Get()->GetVarPtr(label)->dealloc_count = dealloc_count;
} else {
// nothing to read for this block, advance reading index
index += nCells * vlen;
index += fill_size;
continue;
}
}
Expand Down
Loading