Skip to content

Fix ideal moist and flaky restart#111

Merged
chengcli merged 3 commits intomainfrom
cli/fix_ideal_moist
Feb 11, 2026
Merged

Fix ideal moist and flaky restart#111
chengcli merged 3 commits intomainfrom
cli/fix_ideal_moist

Conversation

@chengcli
Copy link
Owner

No description provided.

Copilot AI review requested due to automatic review settings February 11, 2026 18:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug in the equation of state conserved limiter for moist physics and refactors the Python binding API for mesh block initialization. The changes address an uninitialized variable issue that could affect restart functionality in ideal moist simulations.

Changes:

  • Fixed uninitialized variable bug in apply_conserved_limiter_ by computing vapor/cloud counts at the beginning of the function
  • Reordered energy limiter to run before vapor/cloud processing to ensure proper energy bounds on restart
  • Split Python binding initialize method into two separate methods: initialize (for normal initialization) and initialize_from_restart (for restart initialization)

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/eos/equation_of_state.cpp Fixes undefined behavior by initializing ny, nvapor, and ncloud before use; reorders energy limiter to run before vapor processing
python/csrc/pymesh.cpp Splits initialization method into two separate methods for clarity, but introduces a breaking API change

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 138 to +151
"initialize",
[](snap::MeshBlockImpl &self, snap::Variables &vars) {
self.initialize(vars);
return std::make_pair(vars, 0.);
},
py::arg("vars"))
.def(
"initialize_from_restart",
[](snap::MeshBlockImpl &self, snap::Variables &vars,
std::string restart_file) {
double time;
if (restart_file.empty()) {
time = self.initialize(vars);
} else {
time = self.initialize(vars, restart_file.c_str());
}
double time = self.initialize(vars, restart_file.c_str());
return std::make_pair(vars, time);
},
py::arg("vars"), py::arg("restart_file") = "")
py::arg("vars"), py::arg("restart_file"))
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking API change: Splitting the initialize method into two separate methods breaks backward compatibility. The original API supported initialize(vars, restart_file="") where an empty string would perform normal initialization and a non-empty string would initialize from a restart file.

The new API requires callers to choose between initialize(vars) or initialize_from_restart(vars, restart_file). While this is clearer and more explicit, any existing code that passes a restart file to initialize will break.

Consider one of the following approaches:

  1. Deprecate the old API first before removing it, providing a migration path
  2. Keep backward compatibility by supporting both the old combined method and the new separate methods
  3. Document this breaking change clearly in release notes and provide migration guidance

Note: While no Python examples in this repository currently use restart files with the initialize method, external code may rely on this API.

Copilot uses AI. Check for mistakes.
@chengcli chengcli merged commit f252dcc into main Feb 11, 2026
9 checks passed
@chengcli chengcli deleted the cli/fix_ideal_moist branch February 11, 2026 21:00
@github-actions
Copy link
Contributor

🎉 Released v1.2.9!

What's Changed

Full Changelog: v1.2.8...v1.2.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant