Skip to content
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ Merged since v2.5.0, not yet released.
dividing by it in eq. C7, which drove the radiant fraction to zero. It now
matches `Balbi2020.py` in `wildfire_ROS_models`, and its rate of spread is
floored at zero on a downslope with no wind. ([#196])
- A fuel map loaded with `loadData` that does not overlap the domain is now
stretched over it, as the warning says and as the other layers already were.
It was left at its own extent, so the whole domain read the fuel of its first
cell. ([#220])
- `Rothermel` wrote the wind exponent coefficient as `3.59*10E-4`, which is
3.59e-3 in C++, ten times the 3.59e-4 of Rothermel (1972), so wind raised
the rate of spread too little. Results with wind
Expand Down Expand Up @@ -267,6 +271,7 @@ repository stays easy to return to.
[#197]: https://github.com/forefireAPI/forefire/pull/197
[#194]: https://github.com/forefireAPI/forefire/pull/194
[#196]: https://github.com/forefireAPI/forefire/issues/196
[#220]: https://github.com/forefireAPI/forefire/pull/220
[#195]: https://github.com/forefireAPI/forefire/pull/195
[#202]: https://github.com/forefireAPI/forefire/pull/202
[#199]: https://github.com/forefireAPI/forefire/pull/199
Expand Down
2 changes: 1 addition & 1 deletion src/DataBroker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1506,7 +1506,7 @@ namespace libforefire
domain->NECornerY() - domain->SWCornerY(), 10000.);
double t0 = 0;
double Dt = 10000000.;
FuelDataLayer<double> *newlayer = new FuelDataLayer<double>(property, SWCorner, timeOrigin, spatialExtent, Lt, nx, ny, nz, nt, fuelMap);
FuelDataLayer<double> *newlayer = new FuelDataLayer<double>(property, SWC, t0, ext, Dt, nx, ny, nz, nt, fuelMap);
delete[] fuelMap;
return newlayer;
}
Expand Down
5 changes: 3 additions & 2 deletions tests/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ add_executable(forefire_unit_tests
test_propagation_models.cpp
test_topology.cpp
test_timetable.cpp
test_quit_command.cpp)
test_quit_command.cpp
test_data_broker.cpp)

target_link_libraries(forefire_unit_tests PRIVATE forefireL)
target_include_directories(forefire_unit_tests PRIVATE
Expand All @@ -32,7 +33,7 @@ endif()

# doctest groups its cases into suites; registering one CTest entry per suite
# keeps `ctest` output useful without needing doctest's CMake integration.
foreach(_suite "model registry" "propagation models" "flux models" "http server" "topology" "fire front" "timetable" "quit command")
foreach(_suite "model registry" "propagation models" "flux models" "http server" "topology" "fire front" "timetable" "quit command" "data broker")
string(REPLACE " " "_" _suite_id "${_suite}")
add_test(NAME "unit.${_suite_id}"
COMMAND forefire_unit_tests --test-suite=${_suite} --no-skipped-summary)
Expand Down
63 changes: 63 additions & 0 deletions tests/unit/test_data_broker.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* @file test_data_broker.cpp
* @brief DataBroker::loadFromNCFile on layers that miss the domain.
* @copyright Copyright (C) 2025 ForeFire, Fire Team, SPE, CNRS/Universita di Corsica.
* @license This program is free software; See LICENSE file for details. (See LICENSE file).
*/

#include "doctest/doctest.h"

#include "model_sandbox.h"

#include "DataBroker.h"
#include "FFPoint.h"
#include "FireDomain.h"
#include "FuelDataLayer.h"

#include <cstdio>
#include <string>

using libforefire::FFPoint;
using libforefire::FireDomain;
using libforefire::FuelDataLayer;
using ff_test::ModelSandbox;

TEST_SUITE("data broker") {

#ifndef FF_NO_NETCDF
TEST_CASE("a fuel map that misses the domain is stretched over it like the other layers") {
ModelSandbox sandbox;
sandbox.propagation("Rothermel");
FireDomain* domain = sandbox.fireDomain();

// 2x2 fuel map 100 km away from the 1 km domain: no overlap, so the
// failsafe reprojection applies. Its first cell is fuel 0, the others 1.
const std::string path = "test_data_broker_fuel.nc";
{
NcFile file(path, NcFile::replace);
NcVar dom = file.addVar("domain", ncInt);
dom.putAtt("type", "domain");
dom.putAtt("SWx", ncDouble, 100000.);
dom.putAtt("SWy", ncDouble, 100000.);
dom.putAtt("Lx", ncDouble, 1000.);
dom.putAtt("Ly", ncDouble, 1000.);
std::vector<NcDim> dims = {file.addDim("ft", 1), file.addDim("fz", 1),
file.addDim("fy", 2), file.addDim("fx", 2)};
NcVar fuel = file.addVar("fuel", ncShort, dims);
fuel.putAtt("type", "fuel");
const short cells[4] = {0, 1, 1, 1};
fuel.putVar(cells);
}
domain->getDataBroker()->loadFromNCFile(path);
std::remove(path.c_str());

FuelDataLayer<double>* layer =
dynamic_cast<FuelDataLayer<double>*>(domain->getDataBroker()->getLayer("fuel"));
REQUIRE(layer != nullptr);
// Stretched over the domain, (750, 750) falls in the last cell. Left at
// its own extent the map is outside the domain and every point reads cell 0.
CHECK(layer->getValueAt(FFPoint(750., 750., 0.), 0.) == 1.);
}
#endif

}
Loading