// Copyright (C) Stichting Deltares 2019. 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 Deltares.DamEngine.Calculators.KernelWrappers.Common; using Deltares.DamEngine.Data.Design; using Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.General.PlLines; using Deltares.DamEngine.Data.Geotechnics; using Deltares.DamEngine.TestHelpers.Factories; using NUnit.Framework; namespace Deltares.DamEngine.Calculators.Tests.KernelWrappers.Common { [TestFixture] public class PlLinesHelperTests { [Test] public void TestCreatePlLinesNoHydraulicShortcut() { // expected values retrieved from debugging Dam Classic (rev.663) // test CanCalculateThePipingFactorUsingSellmeijer4Forces var location = new Location(); location.Scenarios.Add(new DesignScenario()); location.SurfaceLine = FactoryForSurfaceLines.CreateSurfaceLineTutorial1(); var soilProfile1D = FactoryForSoilProfiles.CreatePipingSellmeijerProfileWithOneSandlayer(); var riverLevel = 1.0; UpliftSituation upliftSituation; var timeStepDateTime = new DateTime(); var plLines = PlLinesHelper.CreatePlLinesForPiping(timeStepDateTime, location, soilProfile1D, riverLevel, out upliftSituation); Assert.AreEqual(4, plLines.PlLineCount); Assert.AreEqual(8, plLines.Lines[PlLineType.Pl1].Points.Count); Assert.IsTrue(new PlLinePoint(0.000, 1.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[0])); Assert.IsTrue(new PlLinePoint(14.900, 1.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[1])); Assert.IsTrue(new PlLinePoint(34.500, 0.500).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[2])); Assert.IsTrue(new PlLinePoint(40.500, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[3])); Assert.IsTrue(new PlLinePoint(50.500, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[4])); Assert.IsTrue(new PlLinePoint(58.500, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[5])); Assert.IsTrue(new PlLinePoint(61.500, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[6])); Assert.IsTrue(new PlLinePoint(75.000, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[7])); Assert.AreEqual(0, plLines.Lines[PlLineType.Pl2].Points.Count); Assert.AreEqual(2, plLines.Lines[PlLineType.Pl3].Points.Count); Assert.IsTrue(new PlLinePoint(0.000, 1.000).LocationEquals(plLines.Lines[PlLineType.Pl3].Points[0])); Assert.IsTrue(new PlLinePoint(75.000, 1.000).LocationEquals(plLines.Lines[PlLineType.Pl3].Points[1])); Assert.AreEqual(0, plLines.Lines[PlLineType.Pl4].Points.Count); } [Test] public void TestCreatePlLinesHydraulicShortcut() { // expected values retrieved from debugging Dam Classic (rev.663) // test CanCalculateThePipingFactorUsingSellmeijer4Forces // Same as TestCreatePlLinesNoHydraulicShortcut because HeadInPlLine3 is not given. var location = new Location(); location.Scenarios.Add(new DesignScenario()); location.SurfaceLine = FactoryForSurfaceLines.CreateSurfaceLineTutorial1(); var soilProfile1D = FactoryForSoilProfiles.CreatePipingSellmeijerProfileWithOneSandlayer(); var riverLevel = 1.0; UpliftSituation upliftSituation; var timeStepDateTime = new DateTime(); var plLines = PlLinesHelper.CreatePlLinesForPiping(timeStepDateTime, location, soilProfile1D, riverLevel, out upliftSituation); Assert.AreEqual(4, plLines.PlLineCount); Assert.AreEqual(8, plLines.Lines[PlLineType.Pl1].Points.Count); Assert.IsTrue(new PlLinePoint(0.000, 1.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[0])); Assert.IsTrue(new PlLinePoint(14.900, 1.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[1])); Assert.IsTrue(new PlLinePoint(34.500, 0.500).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[2])); Assert.IsTrue(new PlLinePoint(40.500, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[3])); Assert.IsTrue(new PlLinePoint(50.500, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[4])); Assert.IsTrue(new PlLinePoint(58.500, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[5])); Assert.IsTrue(new PlLinePoint(61.500, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[6])); Assert.IsTrue(new PlLinePoint(75.000, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[7])); Assert.AreEqual(0, plLines.Lines[PlLineType.Pl2].Points.Count); Assert.AreEqual(2, plLines.Lines[PlLineType.Pl3].Points.Count); Assert.IsTrue(new PlLinePoint(0.000, 1.000).LocationEquals(plLines.Lines[PlLineType.Pl3].Points[0])); Assert.IsTrue(new PlLinePoint(75.000, 1.000).LocationEquals(plLines.Lines[PlLineType.Pl3].Points[1])); Assert.AreEqual(0, plLines.Lines[PlLineType.Pl4].Points.Count); } [Test] public void TestCreatePlLinesHydraulicShortcutWithHeadPl3AndInBetweenAquifer() { // expected values retrieved from debugging Dam Classic (rev.663) // test CanCalculateThePipingFactorUsingSellmeijer4Forces // PL1 is same as TestCreatePlLinesHydraulicShortcutWithHeadPl3 (same riverlevel = 0.5) // PL3 is same as TestCreatePlLinesNoHydraulicShortcut because HeadInPlLine3 is given with value 1 and there is a // in between aquifer so Head (1.0) is used instead of riverlevel. // PL2 and PL4 now generated at riverlevel. var location = new Location(); var scenario = new DesignScenario {HeadPl3 = 1.0}; location.Scenarios.Add(scenario); location.SurfaceLine = FactoryForSurfaceLines.CreateSurfaceLineTutorial1(); var soilProfile1D = FactoryForSoilProfiles.CreatePipingSellmeijerProfileWithOneSandlayer(); AddLayerToSoilProfile(soilProfile1D, -4, false); AddLayerToSoilProfile(soilProfile1D, -5, true); var riverLevel = 0.5; UpliftSituation upliftSituation; var timeStepDateTime = new DateTime(); var plLines = PlLinesHelper.CreatePlLinesForPiping(timeStepDateTime, location, soilProfile1D, riverLevel, out upliftSituation); Assert.AreEqual(4, plLines.PlLineCount); Assert.AreEqual(8, plLines.Lines[PlLineType.Pl1].Points.Count); Assert.IsTrue(new PlLinePoint(0.000, 0.500).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[0])); Assert.IsTrue(new PlLinePoint(12.450, 0.500).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[1])); Assert.IsTrue(new PlLinePoint(34.500, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[2])); Assert.IsTrue(new PlLinePoint(40.500, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[3])); Assert.IsTrue(new PlLinePoint(50.500, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[4])); Assert.IsTrue(new PlLinePoint(58.500, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[5])); Assert.IsTrue(new PlLinePoint(61.500, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[6])); Assert.IsTrue(new PlLinePoint(75.000, 0.000).LocationEquals(plLines.Lines[PlLineType.Pl1].Points[7])); Assert.AreEqual(2, plLines.Lines[PlLineType.Pl2].Points.Count); Assert.IsTrue(new PlLinePoint(0.000, 0.500).LocationEquals(plLines.Lines[PlLineType.Pl2].Points[0])); Assert.IsTrue(new PlLinePoint(75.000, 0.500).LocationEquals(plLines.Lines[PlLineType.Pl2].Points[1])); Assert.AreEqual(2, plLines.Lines[PlLineType.Pl3].Points.Count); Assert.IsTrue(new PlLinePoint(0.000, 1.000).LocationEquals(plLines.Lines[PlLineType.Pl3].Points[0])); Assert.IsTrue(new PlLinePoint(75.000, 1.000).LocationEquals(plLines.Lines[PlLineType.Pl3].Points[1])); Assert.AreEqual(2, plLines.Lines[PlLineType.Pl4].Points.Count); Assert.IsTrue(new PlLinePoint(0.000, 0.500).LocationEquals(plLines.Lines[PlLineType.Pl4].Points[0])); Assert.IsTrue(new PlLinePoint(75.000, 0.500).LocationEquals(plLines.Lines[PlLineType.Pl4].Points[1])); } private void AddLayerToSoilProfile(SoilProfile1D soilProfile, double topLevel, bool isAquifer) { var layer = new SoilLayer1D() { Name = GetNewUniqueLayerId(soilProfile) }; layer.TopLevel = topLevel; layer.Soil = new Soil("Sand", 22.0, 20.0) { PermeabKx = 0.0001, DiameterD70 = Physics.FactorMicroMeterToMeter * 200.0, WhitesConstant = 0.25, BeddingAngle = 37.0 }; layer.IsAquifer = isAquifer; soilProfile.Layers.Add(layer); } private static string GetNewUniqueLayerId(SoilProfile1D soilProfile1D) { int num = 0; string id; do { id = "L" + (object)num++; } while (soilProfile1D.GetLayerWithName(id) != null); return id; } } }