From 7296cfecee76f7143b34215ad227f810b5fef627 Mon Sep 17 00:00:00 2001 From: wilfchun Date: Fri, 14 Nov 2025 11:57:42 +0000 Subject: [PATCH 1/4] Fixed reading of time variable wave data in yaml input --- src/configuration.cpp | 1 + src/configuration.h | 11 +++++++++ src/read_input.cpp | 52 ++++++++++++++++++++++++++++++------------- 3 files changed, 49 insertions(+), 15 deletions(-) diff --git a/src/configuration.cpp b/src/configuration.cpp index 01b60b775..f3995aa59 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -106,6 +106,7 @@ void CConfiguration::InitializeDefaults() // m_dFinalWaterLevel = 0.0; m_bHasFinalWaterLevel = false; + m_strWaveInputMode = "fixed"; m_strWaveHeightTimeSeries = ""; m_strWaveStationDataFile = ""; m_dDeepWaterWaveHeight = 1.0; diff --git a/src/configuration.h b/src/configuration.h index 30469722b..3dd831adf 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -100,6 +100,7 @@ class CConfiguration bool m_bHasFinalWaterLevel; // Waves + string m_strWaveInputMode; string m_strWaveHeightTimeSeries; string m_strWaveStationDataFile; double m_dDeepWaterWaveHeight; @@ -354,6 +355,12 @@ class CConfiguration } // Wave height Data + // Wave height Data + void SetWaveInputMode(string const &str) + { + m_strWaveInputMode = str; + } + void SetWaveHeightTimeSeries(string const &str) { m_strWaveHeightTimeSeries = str; @@ -764,6 +771,10 @@ class CConfiguration { return m_bHasFinalWaterLevel; } + string GetWaveInputMode() const + { + return m_strWaveInputMode; + } // Wave data configuration getters (Cases 37-40) string GetWaveHeightTimeSeries() const diff --git a/src/read_input.cpp b/src/read_input.cpp index c35b53b76..bf974fab2 100644 --- a/src/read_input.cpp +++ b/src/read_input.cpp @@ -4263,20 +4263,42 @@ bool CSimulation::bConfigureFromYamlFile(CConfiguration &config) hydro.GetChild("final_water_level").GetDoubleValue()); // Wave data configuration - if (hydro.HasChild("wave_height_time_series")) - config.SetWaveHeightTimeSeries( - hydro.GetChild("wave_height_time_series").GetValue()); - if (hydro.HasChild("wave_height_shape_file")) - config.SetWaveStationDataFile( - hydro.GetChild("wave_height_shape_file").GetValue()); - if (hydro.HasChild("wave_height")) - config.SetDeepWaterWaveHeight( - hydro.GetChild("wave_height").GetDoubleValue()); - if (hydro.HasChild("wave_orientation")) - config.SetDeepWaterWaveOrientation( - hydro.GetChild("wave_orientation").GetDoubleValue()); - if (hydro.HasChild("wave_period")) - config.SetWavePeriod(hydro.GetChild("wave_period").GetDoubleValue()); + string strWaveInputMode = "fixed"; // default + if (hydro.HasChild("wave_input_mode")) + { + strWaveInputMode = hydro.GetChild("wave_input_mode").GetValue(); + config.SetWaveInputMode(strWaveInputMode); + } + + // Conditionally read wave parameters based on input mode + if (strWaveInputMode == "time_series") + { + // Read time series wave inputs + if (hydro.HasChild("wave_height_time_series")) + config.SetWaveHeightTimeSeries( + processFilePath(hydro.GetChild("wave_height_time_series").GetValue())); + if (hydro.HasChild("wave_height_shape_file")) + config.SetWaveStationDataFile( + processFilePath(hydro.GetChild("wave_height_shape_file").GetValue())); + } + else if (strWaveInputMode == "fixed") + { + // Read fixed wave condition inputs + if (hydro.HasChild("wave_height")) + config.SetDeepWaterWaveHeight( + hydro.GetChild("wave_height").GetDoubleValue()); + if (hydro.HasChild("wave_orientation")) + config.SetDeepWaterWaveOrientation( + hydro.GetChild("wave_orientation").GetDoubleValue()); + if (hydro.HasChild("wave_period")) + config.SetWavePeriod(hydro.GetChild("wave_period").GetDoubleValue()); + } + else + { + cerr << ERR << "Unknown wave_input_mode '" << strWaveInputMode + << "'. Must be 'fixed' or 'time_series'" << endl; + return false; + } // Tide data configuration if (hydro.HasChild("tide_data_file")) @@ -5264,7 +5286,7 @@ bool CSimulation::bApplyConfiguration(CConfiguration const &config) m_bHaveWaveStationData = false; // Case 37: Deep water wave height (m) or a file of point vectors giving deep // water wave height (m) and orientation (for units, see below) - m_dAllCellsDeepWaterWaveHeight = config.GetDeepWaterWaveHeight(); + m_dAllCellsDeepWaterWaveHeight = config.GetWaveHeightTimeSeries(); // Case 39: Deep water wave orientation in input CRS: this is the // oceanographic convention i.e. direction TOWARDS which the waves move (in From 37dcfd577cb05276643df0a17a04d66cd074cea4 Mon Sep 17 00:00:00 2001 From: wilfchun Date: Fri, 14 Nov 2025 12:17:32 +0000 Subject: [PATCH 2/4] Got time varying wave data working from yaml --- src/read_input.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/read_input.cpp b/src/read_input.cpp index bf974fab2..1cd1a43c6 100644 --- a/src/read_input.cpp +++ b/src/read_input.cpp @@ -4262,8 +4262,8 @@ bool CSimulation::bConfigureFromYamlFile(CConfiguration &config) config.SetFinalWaterLevel( hydro.GetChild("final_water_level").GetDoubleValue()); - // Wave data configuration - string strWaveInputMode = "fixed"; // default + // Wave data configuration - read wave_input_mode first + string strWaveInputMode = "fixed"; // default if (hydro.HasChild("wave_input_mode")) { strWaveInputMode = hydro.GetChild("wave_input_mode").GetValue(); @@ -4294,12 +4294,11 @@ bool CSimulation::bConfigureFromYamlFile(CConfiguration &config) config.SetWavePeriod(hydro.GetChild("wave_period").GetDoubleValue()); } else - { + { cerr << ERR << "Unknown wave_input_mode '" << strWaveInputMode - << "'. Must be 'fixed' or 'time_series'" << endl; + << "'. Must be 'fixed' or 'time_series'" << endl; return false; } - // Tide data configuration if (hydro.HasChild("tide_data_file")) config.SetTideDataFile(processFilePath(hydro.GetChild("tide_data_file").GetValue())); @@ -5286,7 +5285,7 @@ bool CSimulation::bApplyConfiguration(CConfiguration const &config) m_bHaveWaveStationData = false; // Case 37: Deep water wave height (m) or a file of point vectors giving deep // water wave height (m) and orientation (for units, see below) - m_dAllCellsDeepWaterWaveHeight = config.GetWaveHeightTimeSeries(); + m_dAllCellsDeepWaterWaveHeight = config.GetDeepWaterWaveHeight(); // Case 39: Deep water wave orientation in input CRS: this is the // oceanographic convention i.e. direction TOWARDS which the waves move (in @@ -5300,7 +5299,8 @@ bool CSimulation::bApplyConfiguration(CConfiguration const &config) { m_bHaveWaveStationData = true; m_strDeepWaterWaveStationsShapefile = config.GetWaveStationDataFile(); - m_dAllCellsDeepWaterWaveHeight = config.GetDeepWaterWaveHeight(); + // m_dAllCellsDeepWaterWaveHeight = config.GetDeepWaterWaveHeight(); + m_strDeepWaterWavesInputFile = config.GetWaveHeightTimeSeries(); } // Case 41: Tide data file (can be blank). This is the change (m) from still From 77686d6a5d0ca4a5ac167fa3b01de99b7dc3574b Mon Sep 17 00:00:00 2001 From: wilfchun Date: Fri, 14 Nov 2025 12:27:19 +0000 Subject: [PATCH 3/4] Fixed raster outpud definition --- src/read_input.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/read_input.cpp b/src/read_input.cpp index 1cd1a43c6..896adef3e 100644 --- a/src/read_input.cpp +++ b/src/read_input.cpp @@ -4223,8 +4223,14 @@ bool CSimulation::bConfigureFromYamlFile(CConfiguration &config) if (gis.HasChild("raster_files")) { CYamlNode rasterFiles = gis.GetChild("raster_files"); - if (rasterFiles.IsSequence()) + if (rasterFiles.IsSequence()){ config.SetRasterFiles(rasterFiles.GetStringSequence()); + } + else { + //Allow the user to supply single entries not in list form + std::vector tempVec{rasterFiles.GetValue()}; + config.SetRasterFiles(tempVec); + } } if (gis.HasChild("vector_files")) { From b2e125363ea4621be9cf6e2dba036ce51287103d Mon Sep 17 00:00:00 2001 From: wilfchun Date: Fri, 14 Nov 2025 12:28:00 +0000 Subject: [PATCH 4/4] Fixed yaml cliff collapse flag --- src/read_input.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/read_input.cpp b/src/read_input.cpp index 896adef3e..3d0583154 100644 --- a/src/read_input.cpp +++ b/src/read_input.cpp @@ -5379,7 +5379,7 @@ bool CSimulation::bApplyConfiguration(CConfiguration const &config) m_dDeanProfileStartAboveSWL = config.GetBermHeight(); // Case 59: Simulate cliff collapse? - m_dDeanProfileStartAboveSWL = config.GetCliffCollapse(); + m_bDoCliffCollapse = config.GetCliffCollapse(); // Case 60: Cliff resistance to erosion if (m_bHaveConsolidatedSediment && m_bDoCliffCollapse)