From 7c7b467093fca76e3e543377baccf0b76a214103 Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Wed, 30 Apr 2025 23:53:31 -0300 Subject: [PATCH 1/9] 1st sample --- tests/runff/sample_simulation.ff | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tests/runff/sample_simulation.ff diff --git a/tests/runff/sample_simulation.ff b/tests/runff/sample_simulation.ff new file mode 100644 index 00000000..f9c3c2f3 --- /dev/null +++ b/tests/runff/sample_simulation.ff @@ -0,0 +1,14 @@ +setParameter[fuelsTableFile=fuels.csv] +setParameter[spatialIncrement=3] +setParameter[perimeterResolution=10] +setParameter[propagationSpeedAdjustmentFactor=0.6] +setParameter[windReductionFactor=0.4] +setParameter[propagationModel=Rothermel] +setParameter[dumpMode=ff] +setParameter[ForeFireDataDirectory=.] + +loadData[data.nc;2025-02-10T17:35:54Z] +startFire[loc=(35881.873264425,28699.674854985,0);t=0] +step[dt=3600] +print[to_reload.ff] +save[] From 2a781236604738347f48face6e748b00caa2a32b Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Wed, 30 Apr 2025 23:56:58 -0300 Subject: [PATCH 2/9] working --- tests/runff/run.ff | 28 ++++++++++++++++++++++++++++ tests/runff/sample_simulation.ff | 14 -------------- 2 files changed, 28 insertions(+), 14 deletions(-) create mode 100644 tests/runff/run.ff delete mode 100644 tests/runff/sample_simulation.ff diff --git a/tests/runff/run.ff b/tests/runff/run.ff new file mode 100644 index 00000000..d01e468e --- /dev/null +++ b/tests/runff/run.ff @@ -0,0 +1,28 @@ +# ForeFire Basic Simulation Example +# REQUIRES: data.nc and fuels.csv in the current directory. + +# --- Parameters --- +setParameter[fuelsTableFile=fuels.csv] +setParameter[spatialIncrement=3] +setParameter[perimeterResolution=10] +setParameter[propagationModel=Rothermel] +setParameter[dumpMode=geojson] +setParameter[ForeFireDataDirectory=.] + +# Optional Tuning Params (kept from original for behaviour consistency): +setParameter[propagationSpeedAdjustmentFactor=0.6] +setParameter[windReductionFactor=0.4] + +# --- Load Data & Domain --- +loadData[data.nc;2025-02-10T17:35:54Z] + +# --- Ignition --- +startFire[loc=(35881.873264425,28699.674854985,0);t=0] # Single ignition point + +# --- Run Simulation --- +goTo[t=1800] + +# --- End --- +# GUI uses print[] / plot[] to get data. No explicit save/print needed here. +print[] +# Omit quit[] if using listenHTTP \ No newline at end of file diff --git a/tests/runff/sample_simulation.ff b/tests/runff/sample_simulation.ff deleted file mode 100644 index f9c3c2f3..00000000 --- a/tests/runff/sample_simulation.ff +++ /dev/null @@ -1,14 +0,0 @@ -setParameter[fuelsTableFile=fuels.csv] -setParameter[spatialIncrement=3] -setParameter[perimeterResolution=10] -setParameter[propagationSpeedAdjustmentFactor=0.6] -setParameter[windReductionFactor=0.4] -setParameter[propagationModel=Rothermel] -setParameter[dumpMode=ff] -setParameter[ForeFireDataDirectory=.] - -loadData[data.nc;2025-02-10T17:35:54Z] -startFire[loc=(35881.873264425,28699.674854985,0);t=0] -step[dt=3600] -print[to_reload.ff] -save[] From d596a06ff0487d65321c78878842c1aa61ac3a9b Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Thu, 1 May 2025 00:04:43 -0300 Subject: [PATCH 3/9] good --- tests/runff/run.ff | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/runff/run.ff b/tests/runff/run.ff index d01e468e..615fc1d7 100644 --- a/tests/runff/run.ff +++ b/tests/runff/run.ff @@ -2,14 +2,14 @@ # REQUIRES: data.nc and fuels.csv in the current directory. # --- Parameters --- +setParameter[ForeFireDataDirectory=.] setParameter[fuelsTableFile=fuels.csv] -setParameter[spatialIncrement=3] -setParameter[perimeterResolution=10] setParameter[propagationModel=Rothermel] setParameter[dumpMode=geojson] -setParameter[ForeFireDataDirectory=.] # Optional Tuning Params (kept from original for behaviour consistency): +setParameter[perimeterResolution=10] +setParameter[spatialIncrement=3] setParameter[propagationSpeedAdjustmentFactor=0.6] setParameter[windReductionFactor=0.4] @@ -17,12 +17,11 @@ setParameter[windReductionFactor=0.4] loadData[data.nc;2025-02-10T17:35:54Z] # --- Ignition --- -startFire[loc=(35881.873264425,28699.674854985,0);t=0] # Single ignition point +startFire[loc=(35882.873264425,28698.674854985,0);t=0] # --- Run Simulation --- -goTo[t=1800] +goTo[t=3600] # --- End --- -# GUI uses print[] / plot[] to get data. No explicit save/print needed here. print[] # Omit quit[] if using listenHTTP \ No newline at end of file From d2232dfe28fbaa780e99b452b193e722b132c6ae Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Thu, 1 May 2025 00:23:15 -0300 Subject: [PATCH 4/9] better coords --- tests/runff/run.ff | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/runff/run.ff b/tests/runff/run.ff index 615fc1d7..e724ef4e 100644 --- a/tests/runff/run.ff +++ b/tests/runff/run.ff @@ -15,9 +15,8 @@ setParameter[windReductionFactor=0.4] # --- Load Data & Domain --- loadData[data.nc;2025-02-10T17:35:54Z] - # --- Ignition --- -startFire[loc=(35882.873264425,28698.674854985,0);t=0] +startFire[lonlat=(8.70, 41.952, 0);t=0] # --- Run Simulation --- goTo[t=3600] From ff3193e52eca32fae58e84ab881bcd98c6a3eaad Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Thu, 1 May 2025 00:54:24 -0300 Subject: [PATCH 5/9] color --- src/HttpCommandServer.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/HttpCommandServer.hpp b/src/HttpCommandServer.hpp index 6134a799..8b91f547 100644 --- a/src/HttpCommandServer.hpp +++ b/src/HttpCommandServer.hpp @@ -72,14 +72,14 @@ namespace http_command { running = true; server_thread = std::thread(&HttpCommandServer::acceptLoop, this); std::cout - << "\033[32m" // start green + << "\033[35m" // start color << "HTTP command server listening at http://localhost:" << port << "\033[0m" << std::endl; std::cout << "\033[33m" // start yellow - << "To stop the server, press Ctrl-C or type exit in the ForeFire shell." + << "To stop the server, press Ctrl-C or type quit in the ForeFire shell." << "\033[0m" << std::endl; From 4917a0fc4cbbaec0129ef84bec2b01aee9d66e98 Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Thu, 1 May 2025 01:01:02 -0300 Subject: [PATCH 6/9] flag -f for listen Http Server --- tools/forefire/ForeFire.cpp | 78 ++++++++++++++++++++++++++++--------- 1 file changed, 60 insertions(+), 18 deletions(-) diff --git a/tools/forefire/ForeFire.cpp b/tools/forefire/ForeFire.cpp index 334c79f7..eae7248f 100644 --- a/tools/forefire/ForeFire.cpp +++ b/tools/forefire/ForeFire.cpp @@ -33,33 +33,75 @@ ForeFire::ForeFire() : executor() {} ForeFire::~ForeFire() {} void ForeFire::usage(const char* name) { - cout << "usage: " << name << " [-i file] [-o file]" << endl; - cout << " -i: input command file" << endl; - cout << " -o: output command file" << endl; + cout << "usage: " << name << " [-i file] [-l] [-v] [-w file]" << endl; + cout << " -i file: input command file" << endl; + cout << " -l : Start directly in listenHTTP mode" << endl; + cout << " -v : print version" << endl; + cout << " -w file: web shell mode" << endl; + } int ForeFire::startShell(int argc, char* argv[]) { ifstream* inputStream = nullptr; int fileopt; int EOO = -1; - while ((fileopt = getopt(argc, argv, "w:i:o:v")) != EOO) { - if (fileopt == 'v') { - cout << ff_version << endl; - return 1; + bool startListenHttpMode = false; + while ((fileopt = getopt(argc, argv, "w:i:o:vl")) != EOO) { + switch (fileopt) { + case 'l': + startListenHttpMode = true; + goto end_option_parsing; + + case 'v': + cout << ff_version << endl; + return 1; + case 'w': + FFWebShell(optarg); + return 1; + case 'i': + inputStream = new ifstream(optarg); + if (!inputStream || !inputStream->is_open()) { + cerr << "Error: Could not open input file: " << optarg << endl; + delete inputStream; + return 1; + } + break; + case '?': // Handle unknown options or missing args for options requiring one + default: + usage(argv[0]); + return 1; } - if (fileopt == 'w') { - FFWebShell(optarg); - return 1; - } else if (fileopt == 'i') { - inputStream = new ifstream(optarg); - if (!inputStream) { - cout << "wrong input file, check your settings..." << optarg << endl; - } + } + + end_option_parsing:; // Label for the goto jump + + // --- Execution Logic --- + if (startListenHttpMode) { + // Execute listenHTTP directly with defaults + cout << "Starting ForeFire in listenHTTP mode..." << endl; + + // It's good practice to ensure standalone mode + string standAlone = "setParameter[runmode=standalone]"; + executor.ExecuteCommand(standAlone); + + // Execute the default listenHTTP command + string listenCommand = "listenHTTP[]"; + executor.ExecuteCommand(listenCommand); + + // Keep the main thread alive indefinitely + cout << "HTTP server started. Process waiting... (Press Ctrl+C to exit)" << endl; + while (true) { + sleep(3600); // Wait loop } + // This part is effectively unreachable in normal operation + return 0; + + } else { + + FFShell(inputStream); + delete inputStream; + return 0; // Normal exit for non-server mode } - FFShell(inputStream); - delete inputStream; - return 1; } void ForeFire::FFWebShell(char* path) { From c85b0e9131a4e46b036c797c327767ee68d5b7b1 Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Thu, 1 May 2025 01:05:09 -0300 Subject: [PATCH 7/9] adjust --- tools/forefire/ForeFire.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/forefire/ForeFire.cpp b/tools/forefire/ForeFire.cpp index eae7248f..b9b72bad 100644 --- a/tools/forefire/ForeFire.cpp +++ b/tools/forefire/ForeFire.cpp @@ -89,11 +89,11 @@ int ForeFire::startShell(int argc, char* argv[]) { executor.ExecuteCommand(listenCommand); // Keep the main thread alive indefinitely - cout << "HTTP server started. Process waiting... (Press Ctrl+C to exit)" << endl; + cout << "(Press Ctrl+C to exit)" << endl; while (true) { - sleep(3600); // Wait loop + sleep(3600); } - // This part is effectively unreachable in normal operation + return 0; } else { From 1f7e47d6c44481ac0f2ba068ba76d3035bcc477d Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Thu, 1 May 2025 01:25:22 -0300 Subject: [PATCH 8/9] nice logo printed --- tests/runff/run.ff | 2 +- tools/forefire/ForeFire.cpp | 26 ++++++++++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/tests/runff/run.ff b/tests/runff/run.ff index e724ef4e..5fa7d2d7 100644 --- a/tests/runff/run.ff +++ b/tests/runff/run.ff @@ -7,7 +7,7 @@ setParameter[fuelsTableFile=fuels.csv] setParameter[propagationModel=Rothermel] setParameter[dumpMode=geojson] -# Optional Tuning Params (kept from original for behaviour consistency): +# Optional Tuning Params setParameter[perimeterResolution=10] setParameter[spatialIncrement=3] setParameter[propagationSpeedAdjustmentFactor=0.6] diff --git a/tools/forefire/ForeFire.cpp b/tools/forefire/ForeFire.cpp index b9b72bad..e5299200 100644 --- a/tools/forefire/ForeFire.cpp +++ b/tools/forefire/ForeFire.cpp @@ -131,10 +131,28 @@ void ForeFire::FFShell(ifstream* inputStream) { executor.ExecuteCommand(line); } } else { - cout << "Wildfire solver ForeFire Version :" << ff_version << endl; - cout << "Copyright (C) 2025 CNRS/Univ.Corsica " << endl; - cout << "Comes with ABSOLUTELY NO WARRANTY " << endl; - cout << "Type 'help[]' for commands" << endl; + + const char* logoFF = R"( + ██████╗ ██████╗ + ██╔═══╝ ██╔═══╝ + ██████╗ ██████╗ + ██╔═══╝ ██╔═══╝ + ██║ ██║ + ╚═╝ ╚═╝ + )"; + + cout << logoFF << endl; + cout << " =================================================" << endl; + cout << " ForeFire - Wildfire Propagation Simulator" << endl; + cout << " =================================================" << endl; + cout << " Version: " << ff_version << endl; + cout << " License: See LICENSE file (ABSOLUTELY NO WARRANTY)" << endl; + cout << " Copyright (C) 2025 CNRS/Univ.Corsica" << endl; + cout << endl; + cout << " Type 'help[]' for a list of commands." << endl; + cout << " Use Tab for auto-completion." << endl; // Add hint about completion + cout << endl; + std::string line; while (true) { line = advanced_editor::LineEditor::getLine("forefire> "); From de084a4568ce35bd8d5fbc324aab5d3ffc8b5a6c Mon Sep 17 00:00:00 2001 From: antonio-leblanc Date: Thu, 1 May 2025 01:32:07 -0300 Subject: [PATCH 9/9] less is more --- src/HttpCommandServer.hpp | 2 +- tools/forefire/ForeFire.cpp | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/HttpCommandServer.hpp b/src/HttpCommandServer.hpp index 8b91f547..22ff23c9 100644 --- a/src/HttpCommandServer.hpp +++ b/src/HttpCommandServer.hpp @@ -73,7 +73,7 @@ namespace http_command { server_thread = std::thread(&HttpCommandServer::acceptLoop, this); std::cout << "\033[35m" // start color - << "HTTP command server listening at http://localhost:" << port + << "ForeFire HTTP command server listening at http://localhost:" << port << "\033[0m" << std::endl; diff --git a/tools/forefire/ForeFire.cpp b/tools/forefire/ForeFire.cpp index e5299200..35c39452 100644 --- a/tools/forefire/ForeFire.cpp +++ b/tools/forefire/ForeFire.cpp @@ -73,18 +73,15 @@ int ForeFire::startShell(int argc, char* argv[]) { } } - end_option_parsing:; // Label for the goto jump + end_option_parsing:; - // --- Execution Logic --- if (startListenHttpMode) { - // Execute listenHTTP directly with defaults - cout << "Starting ForeFire in listenHTTP mode..." << endl; - // It's good practice to ensure standalone mode + cout << "" << endl; + string standAlone = "setParameter[runmode=standalone]"; executor.ExecuteCommand(standAlone); - // Execute the default listenHTTP command string listenCommand = "listenHTTP[]"; executor.ExecuteCommand(listenCommand);