From 111861a3125ccb7f7aea8f018cb2e1a74c9d6bf3 Mon Sep 17 00:00:00 2001 From: HugoFara Date: Fri, 30 Oct 2026 12:17:03 +0100 Subject: [PATCH] fix(core): a domain built without loadData takes its propagation model from the parameters FireDomain[...] alone left no propagation layer, so the first goTo dereferenced a null one. The layer is now created on first use from the propagationModel parameter, as loadData does. --- src/FireDomain.cpp | 8 ++++++++ tests/unit/test_commands.cpp | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/FireDomain.cpp b/src/FireDomain.cpp index 1f068e6c..76c00380 100644 --- a/src/FireDomain.cpp +++ b/src/FireDomain.cpp @@ -1364,6 +1364,14 @@ // Computing the propagation speed of a given firenode double FireDomain::getPropagationSpeed(FireNode* fn) { + if ( propagativeLayer == nullptr ){ + // A domain built without loadData: pick the model as loadData does + string propagationModel = params->getParameter("propagationModel"); + if ( !addPropagativeLayer(propagationModel) ){ + cout<<"PROBLEM: Unable to retrieve propagation model "<getModelIndexAt(fn); return propModelsTable[modelIndex]->getSpeedForNode(fn) * propagationSpeedAdjustmentFactor; diff --git a/tests/unit/test_commands.cpp b/tests/unit/test_commands.cpp index f31ffc35..71355100 100644 --- a/tests/unit/test_commands.cpp +++ b/tests/unit/test_commands.cpp @@ -175,4 +175,22 @@ TEST_CASE("plot writes arrival times as an ASCII grid, north row first") { CHECK(inexact == 0); } +TEST_CASE("a domain built without a propagation layer spreads with the propagationModel parameter") { + // loadData picks the model from the propagationModel parameter, but a + // bare FireDomain[...] had no propagation layer and goTo segfaulted. + Command executor; + run(executor, "clear[]"); + run(executor, "setParameter[propagationModel=Iso]"); + run(executor, "FireDomain[sw=(0,0,0);ne=(1000,1000,0);t=0]"); + REQUIRE(Command::getDomain() != nullptr); + run(executor, "startFire[loc=(500,500,0)]"); + run(executor, "goTo[t=100]"); + + size_t burnt = 0; + for (const auto& column : Command::getDomain()->getDataMatrix("arrival_time")) + for (double t : column) + if (std::isfinite(t)) burnt++; + CHECK(burnt > 0); +} + } /* TEST_SUITE */