// 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 System.Linq; using Deltares.WTIStability.Data.Geo; using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.UpliftVan.Input; using Ringtoets.MacroStabilityInwards.KernelWrapper.Kernels.UpliftVan; namespace Ringtoets.MacroStabilityInwards.KernelWrapper.Creators.Input { /// /// Creates instances which are required by . /// internal static class SoilCreator { /// /// Creates a based on information contained in the profile , /// which can be used by . /// /// The from which to take the information. /// A new with information taken from the . /// Thrown when is null. /// Thrown when /// or is an invalid value. /// Thrown when /// or is a valid value but unsupported. public static Soil[] Create(UpliftVanSoilProfile profile) { if (profile == null) { throw new ArgumentNullException(nameof(profile)); } return profile.Layers.Select(l => new Soil(l.MaterialName) { UsePop = l.UsePop, ShearStrengthModel = ConvertShearStrengthModel(l.ShearStrengthModel), AbovePhreaticLevel = l.AbovePhreaticLevel, BelowPhreaticLevel = l.BelowPhreaticLevel, Cohesion = l.Cohesion, FrictionAngle = l.FrictionAngle, RatioCuPc = l.ShearStrengthRatio, StrengthIncreaseExponent = l.StrengthIncreaseExponent, PoP = l.Pop, DilatancyType = ConvertDilatancyType(l.DilatancyType) }).ToArray(); } /// /// 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 ShearStrengthModel ConvertShearStrengthModel(UpliftVanShearStrengthModel shearStrengthModel) { if (!Enum.IsDefined(typeof(UpliftVanShearStrengthModel), shearStrengthModel)) { throw new InvalidEnumArgumentException(nameof(shearStrengthModel), (int) shearStrengthModel, typeof(UpliftVanShearStrengthModel)); } switch (shearStrengthModel) { case UpliftVanShearStrengthModel.SuCalculated: return ShearStrengthModel.CuCalculated; case UpliftVanShearStrengthModel.CPhi: return ShearStrengthModel.CPhi; case UpliftVanShearStrengthModel.CPhiOrSuCalculated: return ShearStrengthModel.CPhiOrCuCalculated; default: throw new NotSupportedException(); } } /// /// 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 DilatancyType ConvertDilatancyType(UpliftVanDilatancyType dilatancyType) { if (!Enum.IsDefined(typeof(UpliftVanDilatancyType), dilatancyType)) { throw new InvalidEnumArgumentException(nameof(dilatancyType), (int) dilatancyType, typeof(UpliftVanDilatancyType)); } switch (dilatancyType) { case UpliftVanDilatancyType.Phi: return DilatancyType.Phi; case UpliftVanDilatancyType.Zero: return DilatancyType.Zero; case UpliftVanDilatancyType.MinusPhi: return DilatancyType.MinusPhi; default: throw new NotSupportedException(); } } } }