// Copyright (C) Stichting Deltares 2023. 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.IO; using Deltares.DamEngine.Calculators.KernelWrappers.Common; using Deltares.DamEngine.Calculators.Tests.KernelWrappers.TestHelpers; using Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.Geotechnics; using Deltares.DamEngine.TestHelpers.Factories; using NUnit.Framework; namespace Deltares.DamEngine.Calculators.Tests.KernelWrappers.Common { [TestFixture] public class UpliftHelperTests { [Test, Ignore("To be replaced by stix file when stix files are supported")] public void TestDetermineStabilityUpliftWithStiFile() { DamKernelInput damKernelInput = CreateDamKernelInput(); var soilGeometry2DName = "SimpleGeometry.sti"; damKernelInput.SubSoilScenario.SoilProfileType = SoilProfileType.ProfileTypeStiFile; damKernelInput.SubSoilScenario.StiFileName = soilGeometry2DName; damKernelInput.SubSoilScenario.FullStiFileName = Path.Combine(damKernelInput.ProjectDir, Path.Combine(damKernelInput.Location.StabilityOptions.SoilGeometries2DPath, soilGeometry2DName)); damKernelInput.Location.ModelFactors.UpliftCriterionStability = 1.2; var upliftHelper = new UpliftHelper(); UpliftSituation upliftSituation = upliftHelper.DetermineStabilityUplift(damKernelInput, false); Assert.IsTrue(upliftSituation.IsUplift); damKernelInput.Location.ModelFactors.UpliftCriterionStability = 0.8; upliftSituation = upliftHelper.DetermineStabilityUplift(damKernelInput, false); Assert.IsFalse(upliftSituation.IsUplift); } [Test] public void TestDetermineStabilityUpliftWithSoilProfile2D() { SoilProfile2D soilProfile2D = DamEngineDataTestFactory.CreateSoilProfile2D(null); DamKernelInput damKernelInput = CreateDamKernelInput(); damKernelInput.SubSoilScenario.SoilProfileType = SoilProfileType.ProfileType2D; damKernelInput.SubSoilScenario.StiFileName = ""; damKernelInput.SubSoilScenario.FullStiFileName = ""; damKernelInput.SubSoilScenario.SoilProfile2D = soilProfile2D; damKernelInput.Location.ModelFactors.UpliftCriterionStability = 1.2; var upliftHelper = new UpliftHelper(); UpliftSituation upliftSituation = upliftHelper.DetermineStabilityUplift(damKernelInput, false); Assert.IsTrue(upliftSituation.IsUplift); damKernelInput.Location.ModelFactors.UpliftCriterionStability = 0.8; upliftSituation = upliftHelper.DetermineStabilityUplift(damKernelInput, false); Assert.IsFalse(upliftSituation.IsUplift); } private static DamKernelInput CreateDamKernelInput() { const string testFolder = @"KernelWrappers\Common\TestFiles"; string projectPath = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), testFolder)); string soilDbName = Path.Combine(projectPath, "soilMaterials.mdb"); Location location = DamEngineDataTestFactory.CreateLocation(FactoryForSurfaceLines.CreateSurfaceLineTutorial1()); location.StabilityOptions = new StabilityOptions(); location.StabilityOptions.TrafficLoad = 10.0; location.StabilityOptions.SoilGeometries2DPath = projectPath; location.StabilityOptions.SoilDatabaseName = soilDbName; location.ModelFactors.RequiredSafetyFactorStabilityInnerSlope = 1.1; var subSoilScenario = new SoilGeometryProbability(); subSoilScenario.SegmentFailureMechanismType = SegmentFailureMechanismType.Stability; var damKernelInput = new DamKernelInput(); damKernelInput.Location = location; damKernelInput.SubSoilScenario = subSoilScenario; damKernelInput.ProjectDir = projectPath; damKernelInput.RiverLevelLow = null; damKernelInput.DamFailureMechanismeCalculationSpecification = new DamFailureMechanismeCalculationSpecification(); return damKernelInput; } } }