// Copyright (C) Stichting Deltares 2017. All rights reserved. // // This file is part of Ringtoets. // // Ringtoets is free software: you can redistribute it and/or modify // it under the terms of the GNU 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 General Public License for more details. // // You should have received a copy of the GNU 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.ComponentModel; using Deltares.WaternetCreator; using Deltares.WTIStability; using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.UpliftVan.Input; using Ringtoets.MacroStabilityInwards.KernelWrapper.Kernels.UpliftVan; using Ringtoets.MacroStabilityInwards.Primitives; namespace Ringtoets.MacroStabilityInwards.KernelWrapper.Creators.Input { /// /// Creates instances which are required by . /// internal static class StabilityLocationCreator { /// /// Creates a based on the given , /// which can be used by . /// /// The to get the information from. /// A new with the given information from . /// Thrown when is null. /// Thrown when /// is an invalid value. /// Thrown when /// is a valid value but unsupported. public static StabilityLocation Create(UpliftVanCalculatorInput input) { if (input == null) { throw new ArgumentNullException(nameof(input)); } return new StabilityLocation { DikeSoilScenario = ConvertDikeSoilScenario(input.DikeSoilScenario), WaternetCreationMode = WaternetCreationMode.CreateWaternet, PlLineCreationMethod = PlLineCreationMethod.RingtoetsWti2017, WaterLevelRiver = input.AssessmentLevel, WaterLevelRiverAverage = input.WaterLevelRiverAverage, WaterLevelPolder = input.WaterLevelPolder, DrainageConstructionPresent = input.DrainageConstruction.IsPresent, XCoordMiddleDrainageConstruction = input.DrainageConstruction.XCoordinate, ZCoordMiddleDrainageConstruction = input.DrainageConstruction.ZCoordinate, MinimumLevelPhreaticLineAtDikeTopRiver = input.MinimumLevelPhreaticLineAtDikeTopRiver, MinimumLevelPhreaticLineAtDikeTopPolder = input.MinimumLevelPhreaticLineAtDikeTopPolder, UseDefaultOffsets = input.UseDefaultOffsets, PlLineOffsetBelowPointBRingtoetsWti2017 = input.PhreaticLineOffsetBelowDikeTopAtRiver, PlLineOffsetBelowDikeTopAtPolder = input.PhreaticLineOffsetBelowDikeTopAtPolder, PlLineOffsetBelowShoulderBaseInside = input.PhreaticLineOffsetBelowShoulderBaseInside, PlLineOffsetBelowDikeToeAtPolder = input.PhreaticLineOffsetBelowDikeToeAtPolder, AdjustPl3And4ForUplift = input.AdjustPhreaticLine3And4ForUplift, LeakageLengthOutwardsPl3 = input.LeakageLengthOutwardsPhreaticLine3, LeakageLengthInwardsPl3 = input.LeakageLengthInwardsPhreaticLine3, LeakageLengthOutwardsPl4 = input.LeakageLengthOutwardsPhreaticLine4, LeakageLengthInwardsPl4 = input.LeakageLengthInwardsPhreaticLine4, HeadInPlLine2Outwards = input.PiezometricHeadPhreaticLine2Outwards, HeadInPlLine2Inwards = input.PiezometricHeadPhreaticLine2Inwards, PenetrationLength = input.PenetrationLength }; } /// /// Converts a into a . /// /// The to convert. /// A based on . /// Thrown when /// is an invalid value. /// Thrown when /// is a valid value but unsupported. private static DikeSoilScenario ConvertDikeSoilScenario(MacroStabilityInwardsDikeSoilScenario dikeSoilScenario) { if (!Enum.IsDefined(typeof(MacroStabilityInwardsDikeSoilScenario), dikeSoilScenario)) { throw new InvalidEnumArgumentException(nameof(dikeSoilScenario), (int) dikeSoilScenario, typeof(MacroStabilityInwardsDikeSoilScenario)); } switch (dikeSoilScenario) { case MacroStabilityInwardsDikeSoilScenario.ClayDikeOnClay: return DikeSoilScenario.ClayDikeOnClay; case MacroStabilityInwardsDikeSoilScenario.SandDikeOnClay: return DikeSoilScenario.SandDikeOnClay; case MacroStabilityInwardsDikeSoilScenario.ClayDikeOnSand: return DikeSoilScenario.ClayDikeOnSand; case MacroStabilityInwardsDikeSoilScenario.SandDikeOnSand: return DikeSoilScenario.SandDikeOnSand; default: throw new NotSupportedException(); } } } }