// Copyright (C) Stichting Deltares 2018. All rights reserved. // // This file is part of the Dam Engine. // // The Dam Engine is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . // // All names, logos, and references to "Deltares" are registered trademarks of // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. using System; using System.Linq; using Deltares.DamEngine.Calculators.PlLinesCreator; using Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.General.PlLines; using Deltares.DamEngine.Data.General.Sensors; using Deltares.DamEngine.Data.Geotechnics; namespace Deltares.DamEngine.Calculators.KernelWrappers.Common { /// /// Helper for Pl Lines /// public class PlLinesHelper { /// /// Creates the pl lines. /// /// The location. /// The sub soil scenario. /// The water level. /// Name of the soil geometry2 d. /// The water level river low. /// The regional assessment scenario job settings. /// The sensor pl line creator settings. /// The uplift situation. /// The created Pl-lines public static PlLines CreatePlLinesForStability(Location location, SoilGeometryProbability subSoilScenario, double waterLevel, string soilGeometry2DName, double? waterLevelRiverLow, RegionalAssessmentScenarioJobSettings regionalAssessmentScenarioJobSettings, SensorPlLineCreatorSettings sensorPlLineCreatorSettings, out UpliftSituation upliftSituation) { PlLines plLines = null; upliftSituation = new UpliftSituation(); switch (location.ModelParametersForPlLines.PlLineCreationMethod) { case PlLineCreationMethod.ExpertKnowledgeLinearInDike: case PlLineCreationMethod.ExpertKnowledgeRRD: plLines = CreatePlLinesForStabilityExpertKnowledge(location, subSoilScenario, waterLevel, soilGeometry2DName, waterLevelRiverLow, regionalAssessmentScenarioJobSettings, out upliftSituation); break; case PlLineCreationMethod.Sensors: plLines = CreatePlLinesForStabilitySensors(location, subSoilScenario, sensorPlLineCreatorSettings); break; default: throw new NotImplementedException(string.Format(@"Pl-line creation method '{0}' is not implemented", location.ModelParametersForPlLines.PlLineCreationMethod)); } return plLines; } /// /// Creates the pl lines for stability sensors. /// /// The location. /// The sub soil scenario. /// The sensor pl-line creator settings. /// public static PlLines CreatePlLinesForStabilitySensors(Location location, SoilGeometryProbability subSoilScenario, SensorPlLineCreatorSettings sensorPlLineCreatorSettings) { PlLines plLines = null; var actualSensorValues = location.SensorLocation.SensorValues[sensorPlLineCreatorSettings.DateTime][location]; var lineTypes = sensorPlLineCreatorSettings.SensorLocation.Sensors.SelectMany(s => s.PlLineMappings).Distinct().ToList(); var creator = SensorPlLineCreator.CreateInstance(sensorPlLineCreatorSettings.SensorLocation, actualSensorValues, lineTypes); try { plLines = creator.CreateAllPlLines(); } catch (InvalidOperationException e) { throw new SensorPlLineCreatorException(e.Message, e); } return plLines; } /// /// Creates the pl lines. /// /// The location. /// The sub soil scenario. /// The water level. /// Name of the soil geometry2 d. /// The water level river low. /// The regional assessment scenario job settings. /// The uplift situation. /// The created Pl-lines public static PlLines CreatePlLinesForStabilityExpertKnowledge(Location location, SoilGeometryProbability subSoilScenario, double waterLevel, string soilGeometry2DName, double? waterLevelRiverLow, RegionalAssessmentScenarioJobSettings regionalAssessmentScenarioJobSettings, out UpliftSituation upliftSituation) { var plLinesCreator = new PlLinesCreator.PlLinesCreator { WaterLevelRiverLow = waterLevelRiverLow, IsUseLowWaterLevel = (waterLevelRiverLow != null), WaterLevelRiverHigh = waterLevel, SurfaceLine = location.SurfaceLine, WaterLevelPolder = location.PolderLevel, HeadInPlLine2 = location.HeadPl2, HeadInPlLine3 = location.HeadPl3, HeadInPlLine4 = location.HeadPl4, ModelParametersForPlLines = location.ModelParametersForPlLines, SoilProfile = subSoilScenario.SoilProfile1D, SoilProfileType = subSoilScenario.SoilProfileType, SoilGeometry2DName = soilGeometry2DName, GaugePlLines = null, // TODO: Operational Gauges = null, // TODO: Operational IsAdjustPL3AndPL4SoNoUpliftWillOccurEnabled = true, // for stability this must be set to true PlLineOffsetBelowDikeTopAtRiver = location.PlLineOffsetBelowDikeTopAtRiver, PlLineOffsetBelowDikeTopAtPolder = location.PlLineOffsetBelowDikeTopAtPolder, PlLineOffsetBelowShoulderBaseInside = location.PlLineOffsetBelowShoulderBaseInside, PlLineOffsetBelowDikeToeAtPolder = location.PlLineOffsetBelowDikeToeAtPolder, PlLineOffsetBelowDikeCrestMiddle = location.PlLineOffsetBelowDikeCrestMiddle, UsePlLineOffsetFactorBelowShoulderCrest = location.UsePlLineOffsetFactorBelowShoulderCrest, DikeEmbankmentMaterial = location.GetDikeEmbankmentSoil(), IsHydraulicShortcut = (regionalAssessmentScenarioJobSettings.HydraulicShortcutType == HydraulicShortcutType.HydraulicShortcut), XSoilGeometry2DOrigin = location.XSoilGeometry2DOrigin, IsUseOvenDryUnitWeight = (regionalAssessmentScenarioJobSettings.DikeDrySensitivity == DikeDrySensitivity.Dry), SoilList = location.SoilList, NWOPhreaticAdaption = PhreaticAdaptionType.MakeEmpty }; if ((regionalAssessmentScenarioJobSettings.DikeDrySensitivity == DikeDrySensitivity.Dry) && (regionalAssessmentScenarioJobSettings.LoadSituation == LoadSituation.Dry)) { // For dry situation other offsets have to be used as in normal situation plLinesCreator.PlLineOffsetBelowDikeTopAtRiver = location.PlLineOffsetDryBelowDikeTopAtRiver; plLinesCreator.PlLineOffsetBelowDikeTopAtPolder = location.PlLineOffsetDryBelowDikeTopAtPolder; plLinesCreator.PlLineOffsetBelowShoulderBaseInside = location.PlLineOffsetDryBelowShoulderBaseInside; plLinesCreator.PlLineOffsetBelowDikeToeAtPolder = location.PlLineOffsetDryBelowDikeToeAtPolder; plLinesCreator.PlLineOffsetBelowDikeCrestMiddle = location.PlLineOffsetDryBelowDikeCrestMiddle; plLinesCreator.PlLineOffsetFactorBelowShoulderCrest = location.PlLineOffsetDryFactorBelowShoulderCrest; plLinesCreator.UsePlLineOffsetBelowDikeCrestMiddle = location.UsePlLineOffsetDryBelowDikeCrestMiddle; plLinesCreator.UsePlLineOffsetFactorBelowShoulderCrest = location.UsePlLineOffsetDryFactorBelowShoulderCrest; plLinesCreator.WaterLevelPolder = location.PolderLevelLow; } var plLines = plLinesCreator.CreateAllPlLines(location); upliftSituation.Pl3HeadAdjusted = plLinesCreator.Pl3HeadAdjusted; upliftSituation.Pl3LocationXMinUplift = plLinesCreator.Pl3LocationXMinUplift; upliftSituation.Pl3MinUplift = plLinesCreator.Pl3MinUplift; upliftSituation.Pl4HeadAdjusted = plLinesCreator.Pl4HeadAdjusted; upliftSituation.Pl4LocationXMinUplift = plLinesCreator.Pl4LocationXMinUplift; upliftSituation.Pl4MinUplift = plLinesCreator.Pl4MinUplift; upliftSituation.IsUplift = false; // must be determined later on; just to avoid compiler error return plLines; } /// /// Creates the pl lines. /// /// The location. /// The soil profile. /// The water level. /// /// The uplift situation. /// public static PlLines CreatePlLinesForPiping(Location location, SoilProfile1D soilProfile, double waterLevel, HydraulicShortcutType hydraulicShortcut, out UpliftSituation upliftSituation) { var plLinesCreator = new PlLinesCreator.PlLinesCreator { WaterLevelRiverHigh = waterLevel, SurfaceLine = location.SurfaceLine, WaterLevelPolder = location.PolderLevel, HeadInPlLine2 = location.HeadPl2, HeadInPlLine3 = location.HeadPl3, HeadInPlLine4 = location.HeadPl4, ModelParametersForPlLines = location.ModelParametersForPlLines, SoilProfile = soilProfile, GaugePlLines = null, // TODO: Operational Gauges = null, // TODO: Operational IsAdjustPL3AndPL4SoNoUpliftWillOccurEnabled = false, // for piping this must be set to false PlLineOffsetBelowDikeTopAtRiver = location.PlLineOffsetBelowDikeTopAtRiver, PlLineOffsetBelowDikeTopAtPolder = location.PlLineOffsetBelowDikeTopAtPolder, DikeEmbankmentMaterial = location.GetDikeEmbankmentSoil(), IsHydraulicShortcut = hydraulicShortcut == HydraulicShortcutType.HydraulicShortcut, XSoilGeometry2DOrigin = location.XSoilGeometry2DOrigin }; var plLines = plLinesCreator.CreateAllPlLines(location); upliftSituation.Pl3HeadAdjusted = plLinesCreator.Pl3HeadAdjusted; upliftSituation.Pl3LocationXMinUplift = plLinesCreator.Pl3LocationXMinUplift; upliftSituation.Pl3MinUplift = plLinesCreator.Pl3MinUplift; upliftSituation.Pl4HeadAdjusted = plLinesCreator.Pl4HeadAdjusted; upliftSituation.Pl4LocationXMinUplift = plLinesCreator.Pl4LocationXMinUplift; upliftSituation.Pl4MinUplift = plLinesCreator.Pl4MinUplift; upliftSituation.IsUplift = false; // must be determined later on; just to avoid compiler error return plLines; } } }