Skip to content

Commit

Permalink
[1D] Include max grid point setting in YAML input/output
Browse files Browse the repository at this point in the history
  • Loading branch information
speth committed Oct 17, 2021
1 parent 07bea35 commit 6bf4523
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions interfaces/cython/cantera/test/test_onedim.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,7 @@ def test_save_restore_add_species_yaml(self):

self.create_sim(p, Tin, reactants, mech="h2o2.yaml")
gas1 = self.gas
self.sim.max_grid_points = 234
self.solve_fixed_T()
self.solve_mix(ratio=5, slope=0.5, curve=0.3)
self.sim.save(filename, "test", loglevel=0)
Expand All @@ -699,6 +700,7 @@ def test_save_restore_add_species_yaml(self):
T2 = self.sim.T
Y2 = self.sim.Y

self.assertEqual(self.sim.max_grid_points, 234)
self.assertArrayNear(T1, T2)
for k1, species in enumerate(gas1.species_names):
k2 = gas2.species_index(species)
Expand Down
5 changes: 5 additions & 0 deletions src/oneD/StFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,8 @@ AnyMap StFlow::serialize(const double* soln) const
state["refine-criteria"]["curve"] = m_refiner->maxSlope();
state["refine-criteria"]["prune"] = m_refiner->prune();
state["refine-criteria"]["grid-min"] = m_refiner->gridMin();
state["refine-criteria"]["max-points"] =
static_cast<long int>(m_refiner->maxPoints());

if (m_zfixed != Undef) {
state["fixed-point"]["location"] = m_zfixed;
Expand Down Expand Up @@ -953,6 +955,9 @@ void StFlow::restore(const AnyMap& state, double* soln, int loglevel)
if (criteria.hasKey("grid-min")) {
m_refiner->setGridMin(criteria["grid-min"].asDouble());
}
if (criteria.hasKey("max-points")) {
m_refiner->setMaxPoints(criteria["max-points"].asInt());
}
}

if (state.hasKey("fixed-point")) {
Expand Down

0 comments on commit 6bf4523

Please sign in to comment.