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..3d0583154 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")) { @@ -4262,22 +4268,43 @@ bool CSimulation::bConfigureFromYamlFile(CConfiguration &config) config.SetFinalWaterLevel( 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()); + // 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(); + 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")) config.SetTideDataFile(processFilePath(hydro.GetChild("tide_data_file").GetValue())); @@ -5278,7 +5305,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 @@ -5351,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)