From cc01f96b94ef1a35deb0429b8e3be6fab47bb8cb Mon Sep 17 00:00:00 2001
From: RJ Sheperd <rjsheperd@gmail.com>
Date: Wed, 18 Dec 2024 17:42:52 -0800
Subject: [PATCH 1/2] [BHP1-1049] Respect User-Provided WAF when running
 Surface & Crown

---
 src/behave/crown.cpp | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/behave/crown.cpp b/src/behave/crown.cpp
index ecfd470..54f9ba0 100644
--- a/src/behave/crown.cpp
+++ b/src/behave/crown.cpp
@@ -112,15 +112,14 @@ void Crown::doCrownRunRothermel()
     double canopyHeight = surfaceFuel_.getCanopyHeight(LengthUnits::Feet);
     double canopyBaseHeight = crownInputs_.getCanopyBaseHeight(LengthUnits::Feet);
     double crownRatio = 0;
-    if(canopyHeight > 0)
-    {
+    if (canopyHeight > 0) {
         crownRatio = (canopyHeight - canopyBaseHeight) / canopyHeight;
     }
 
-    surfaceFuel_.setCrownRatio(crownRatio, FractionUnits::Fraction);
-
     // Step 1: Do surface run and store values needed for further calculations 
-    surfaceFuel_.setWindAdjustmentFactorCalculationMethod(WindAdjustmentFactorCalculationMethod::UseCrownRatio);
+    if (surfaceFuel_.getWindAdjustmentFactorCalculationMethod() == WindAdjustmentFactorCalculationMethod::UseCrownRatio) {
+      surfaceFuel_.setCrownRatio(crownRatio, FractionUnits::Fraction);
+    }
     surfaceFuel_.doSurfaceRunInDirectionOfMaxSpread(); // Crown ROS output given in direction of max spread 
     surfaceFireHeatPerUnitArea_ = surfaceFuel_.getHeatPerUnitArea(HeatPerUnitAreaUnits::BtusPerSquareFoot);
     surfaceFirelineIntensity_ = surfaceFuel_.getFirelineIntensity(FirelineIntensityUnits::BtusPerFootPerSecond);
@@ -172,11 +171,15 @@ void Crown::doCrownRunScottAndReinhardt()
     // Scott and Reinhardt (2001) linked models method for crown fire
     double canopyHeight = surfaceFuel_.getCanopyHeight(LengthUnits::Feet);
     double canopyBaseHeight = crownInputs_.getCanopyBaseHeight(LengthUnits::Feet);
-    double crownRatio = (canopyHeight - canopyBaseHeight) / canopyHeight;
-
-    surfaceFuel_.setCrownRatio(crownRatio, FractionUnits::Fraction);
+    double crownRatio = 0;
+    if (canopyHeight > 0) {
+        crownRatio = (canopyHeight - canopyBaseHeight) / canopyHeight;
+    }
 
     // Step 1: Do surface run and store values needed for further calculations
+    if (surfaceFuel_.getWindAdjustmentFactorCalculationMethod() == WindAdjustmentFactorCalculationMethod::UseCrownRatio) {
+      surfaceFuel_.setCrownRatio(crownRatio, FractionUnits::Fraction);
+    }
     const double windSpeed = surfaceFuel_.getWindSpeed(SpeedUnits::FeetPerMinute, WindHeightInputMode::TwentyFoot);
     surfaceFuel_.setWindSpeed(windSpeed, SpeedUnits::FeetPerMinute, WindHeightInputMode::TwentyFoot);
     surfaceFuel_.doSurfaceRunInDirectionOfMaxSpread();

From 931a022430e66c5cf1805a2d23538b61f8d7dfcb Mon Sep 17 00:00:00 2001
From: Kenneth Cheung <kcheung331@gmail.com>
Date: Wed, 8 Jan 2025 15:53:53 -0500
Subject: [PATCH 2/2] remove setWindAdjustmentFactorCalculationMethod in
 Crown::doCrownRunRothermel()

---
 src/behave/crown.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/behave/crown.cpp b/src/behave/crown.cpp
index ecfd470..7a102e3 100644
--- a/src/behave/crown.cpp
+++ b/src/behave/crown.cpp
@@ -120,7 +120,6 @@ void Crown::doCrownRunRothermel()
     surfaceFuel_.setCrownRatio(crownRatio, FractionUnits::Fraction);
 
     // Step 1: Do surface run and store values needed for further calculations 
-    surfaceFuel_.setWindAdjustmentFactorCalculationMethod(WindAdjustmentFactorCalculationMethod::UseCrownRatio);
     surfaceFuel_.doSurfaceRunInDirectionOfMaxSpread(); // Crown ROS output given in direction of max spread 
     surfaceFireHeatPerUnitArea_ = surfaceFuel_.getHeatPerUnitArea(HeatPerUnitAreaUnits::BtusPerSquareFoot);
     surfaceFirelineIntensity_ = surfaceFuel_.getFirelineIntensity(FirelineIntensityUnits::BtusPerFootPerSecond);