Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/PlLinesToWaternetConverterTests.cs =================================================================== diff -u -r5068 -r5083 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/PlLinesToWaternetConverterTests.cs (.../PlLinesToWaternetConverterTests.cs) (revision 5068) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/PlLinesToWaternetConverterTests.cs (.../PlLinesToWaternetConverterTests.cs) (revision 5083) @@ -22,18 +22,25 @@ using System; using System.Collections.Generic; using System.Data; +using System.Globalization; +using System.IO; using System.Linq; +using System.Threading; using Deltares.DamEngine.Calculators.KernelWrappers.MacroStabilityCommon; using Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.General.PlLines; using Deltares.DamEngine.Data.Geometry; using Deltares.DamEngine.Data.Geotechnics; +using Deltares.DamEngine.Interface; +using Deltares.DamEngine.TestHelpers.Factories; using NUnit.Framework; namespace Deltares.DamEngine.Calculators.Tests.KernelWrappers.MacroStabilityCommon; public class PlLinesToWaternetConverterTests { + private const string mapTestFiles = @"KernelWrappers\MacroStabilityCommon\TestFiles\"; + private const double precision3Decimals = 0.00051; private const double precision6Decimals = 0.00000051; private const double penetrationLength = 0.5; @@ -44,6 +51,43 @@ private static readonly double middleXCoordinate = 0.5 * (leftCoordinate + rightCoordinate); [Test] + public void GivenALine_WhenSplittingAtTwoPoints_ThenReturnsThreeNewLines() + { + // Setup + var line = new Line(new Point2D(0, 0), new Point2D(90, 9)); + var xCoordinatesToBeAdded = new List() + + { + 30, + 60 + }; + List splitLines = []; + + // Call + PlLinesToWaternetConverter.SplitLineAtXCoordinate(xCoordinatesToBeAdded, line, splitLines); + + // Assert + Assert.That(splitLines, Has.Count.EqualTo(3)); + Assert.Multiple(() => + { + Assert.That(splitLines[0].BeginPoint.X, Is.EqualTo(0)); + Assert.That(splitLines[0].BeginPoint.Z, Is.EqualTo(0)); + Assert.That(splitLines[0].EndPoint.X, Is.EqualTo(30)); + Assert.That(splitLines[0].EndPoint.Z, Is.EqualTo(3)); + + Assert.That(splitLines[1].BeginPoint.X, Is.EqualTo(30)); + Assert.That(splitLines[1].BeginPoint.Z, Is.EqualTo(3)); + Assert.That(splitLines[1].EndPoint.X, Is.EqualTo(60)); + Assert.That(splitLines[1].EndPoint.Z, Is.EqualTo(6)); + + Assert.That(splitLines[2].BeginPoint.X, Is.EqualTo(60)); + Assert.That(splitLines[2].BeginPoint.Z, Is.EqualTo(6)); + Assert.That(splitLines[2].EndPoint.X, Is.EqualTo(90)); + Assert.That(splitLines[2].EndPoint.Z, Is.EqualTo(9)); + }); + } + + [Test] [TestCase(0)] [TestCase(0.01)] [TestCase(10)] @@ -1232,6 +1276,145 @@ Assert.That(() => PlLinesToWaternetConverter.CreateWaternetBasedOnPlLines(null, soilProfile, 0, IntrusionVerticalWaterPressureType.Standard), Throws.InstanceOf().With.Message.EqualTo("Geen object voor pn-lijnen gedefinieerd")); } + [Test] + public void Given2DProfileAndPl1FromTutorialDWP1_WhenCreatingTheWaternetLineForPL1ForDAMStandard_ThenExpectedWaternetLineReturned() + { + // Setup + const string inputFilename = "InputTutorialStabilitySoilProfileDWP1.xml"; + string fullInputFilename = Path.Combine(mapTestFiles, inputFilename); + Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; + string inputString = File.ReadAllText(fullInputFilename); + var engineInterface = new EngineInterface(inputString); + SoilProfile2D soilProfile = engineInterface.DamProjectData.Dike.SoilProfiles2D[0]; + + var pL1 = new PlLine(); + pL1.Points.Add(new PlLinePoint(0, 4.4)); + pL1.Points.Add(new PlLinePoint(43.51, 4.4)); + pL1.Points.Add(new PlLinePoint(46.42, 3.9)); + pL1.Points.Add(new PlLinePoint(50.59, 3.9)); + pL1.Points.Add(new PlLinePoint(60.76, 2.69)); + pL1.Points.Add(new PlLinePoint(69.06, 1.6)); + pL1.Points.Add(new PlLinePoint(74.75, 1.6)); + pL1.Points.Add(new PlLinePoint(80.78, 1.6)); + + // Call + WaternetLine waternetLine = PlLinesToWaternetConverter.CreateWaternetLineForPhreaticLineForDamStandard(soilProfile, pL1); + + // Assert + Assert.That(waternetLine, Has.Count.EqualTo(9)); + Assert.Multiple(() => + { + Assert.That(waternetLine.Points[0].X, Is.EqualTo(0).Within(precision3Decimals)); + Assert.That(waternetLine.Points[0].Z, Is.EqualTo(0.92).Within(precision3Decimals)); + Assert.That(waternetLine.Points[1].X, Is.EqualTo(10.14).Within(precision3Decimals)); + Assert.That(waternetLine.Points[1].Z, Is.EqualTo(0.95).Within(precision3Decimals)); + Assert.That(waternetLine.Points[2].X, Is.EqualTo(17.08).Within(precision3Decimals)); + Assert.That(waternetLine.Points[2].Z, Is.EqualTo(0.88).Within(precision3Decimals)); + Assert.That(waternetLine.Points[3].X, Is.EqualTo(19.45).Within(precision3Decimals)); + Assert.That(waternetLine.Points[3].Z, Is.EqualTo(0.81).Within(precision3Decimals)); + Assert.That(waternetLine.Points[4].X, Is.EqualTo(20.62).Within(precision3Decimals)); + Assert.That(waternetLine.Points[4].Z, Is.EqualTo(0.3).Within(precision3Decimals)); + Assert.That(waternetLine.Points[5].X, Is.EqualTo(21.84).Within(precision3Decimals)); + Assert.That(waternetLine.Points[5].Z, Is.EqualTo(-0.61).Within(precision3Decimals)); + Assert.That(waternetLine.Points[6].X, Is.EqualTo(23.08).Within(precision3Decimals)); + Assert.That(waternetLine.Points[6].Z, Is.EqualTo(-0.38).Within(precision3Decimals)); + Assert.That(waternetLine.Points[7].X, Is.EqualTo(24.61).Within(precision3Decimals)); + Assert.That(waternetLine.Points[7].Z, Is.EqualTo(0.63).Within(precision3Decimals)); + Assert.That(waternetLine.Points[8].X, Is.EqualTo(80.78).Within(precision3Decimals)); + Assert.That(waternetLine.Points[8].Z, Is.EqualTo(0.63).Within(precision3Decimals)); + }); + } + + /// + /// E I + /// A |--------------------\------------------\-------------------| M Level 0 m + /// | Aquitard 1 \ F Aquitard 2 \ J Aquitard 3 | + /// B |----------------------\------------------\-----------------| N Level -8 m + /// | Aquitard 4 \ G Aquitard 5 \ K Aquitard 6 | + /// C |------------------------\------------------\---------------| O Level -12 m + /// | Aquitard 7 \ H Aquitard 8 \ L Aquit. 9 | + /// D |--------------------------\------------------\-------------| P Level -15 m + /// | | + /// | bottom aquifer layer | + /// |-----------------------------------------------------------| Level -20 m + /// + [Test] + [TestCase(-5, -8)] + [TestCase(-10, -12)] + [TestCase(-13, -15)] + public void Given2DProfileWithInclinedLayerSeparations_WhenCreatingTheWaternetLineForPL1ForDAMStandardOption_ThenExpectedWaternetLineReturned(double pL1Level, double expectedWaternetLineLevel) + { + // Setup + double xMiddle1 = leftCoordinate + (rightCoordinate - leftCoordinate) / 3; + double xMiddle2 = leftCoordinate + 2 * (rightCoordinate - leftCoordinate) / 3; + var pointA = new Point2D(leftCoordinate, 0); + var pointB = new Point2D(leftCoordinate, -8); + var pointC = new Point2D(leftCoordinate, -12); + var pointD = new Point2D(leftCoordinate, -15); + var pointE = new Point2D(xMiddle1, 0); + var pointF = new Point2D(xMiddle1 + 0.0001, -8); + var pointG = new Point2D(xMiddle1 + 0.0002, -12); + var pointH = new Point2D(xMiddle1 + 0.0003, -15); + var pointI = new Point2D(xMiddle2, 0); + var pointJ = new Point2D(xMiddle2 + 0.0001, -8); + var pointK = new Point2D(xMiddle2 + 0.0002, -12); + var pointL = new Point2D(xMiddle2 + 0.0003, -15); + var pointM = new Point2D(rightCoordinate, 0); + var pointN = new Point2D(rightCoordinate, -8); + var pointO = new Point2D(rightCoordinate, -12); + var pointP = new Point2D(rightCoordinate, -15); + + SoilLayer2D soilLayer1 = FactoryForSoilProfiles.CreateQuadrilateralSoilLayer2D(pointA, pointE, pointF, pointB, "Layer1"); + SoilLayer2D soilLayer2 = FactoryForSoilProfiles.CreateQuadrilateralSoilLayer2D(pointE, pointI, pointJ, pointF, "Layer2"); + SoilLayer2D soilLayer3 = FactoryForSoilProfiles.CreateQuadrilateralSoilLayer2D(pointI, pointM, pointN, pointJ, "Layer3"); + SoilLayer2D soilLayer4 = FactoryForSoilProfiles.CreateQuadrilateralSoilLayer2D(pointB, pointF, pointG, pointC, "Layer4"); + SoilLayer2D soilLayer5 = FactoryForSoilProfiles.CreateQuadrilateralSoilLayer2D(pointF, pointJ, pointK, pointG, "Layer5"); + SoilLayer2D soilLayer6 = FactoryForSoilProfiles.CreateQuadrilateralSoilLayer2D(pointJ, pointN, pointO, pointK, "Layer6"); + SoilLayer2D soilLayer7 = FactoryForSoilProfiles.CreateQuadrilateralSoilLayer2D(pointC, pointG, pointH, pointD, "Layer7"); + SoilLayer2D soilLayer8 = FactoryForSoilProfiles.CreateQuadrilateralSoilLayer2D(pointG, pointK, pointL, pointH, "Layer8"); + SoilLayer2D soilLayer9 = FactoryForSoilProfiles.CreateQuadrilateralSoilLayer2D(pointK, pointO, pointP, pointL, "Layer9"); + SoilLayer2D soilLayerBottom = CreateRectangularSoilLayer2D(-15, -20, leftCoordinate, rightCoordinate, true); + var soilProfile = new SoilProfile2D + { + Geometry = new GeometryData + { + Left = leftCoordinate, + Right = rightCoordinate, + Bottom = -20 + }, + Name = "SoilProfileTest" + }; + soilProfile.Surfaces.Add(soilLayer1); + soilProfile.Surfaces.Add(soilLayer2); + soilProfile.Surfaces.Add(soilLayer3); + soilProfile.Surfaces.Add(soilLayer4); + soilProfile.Surfaces.Add(soilLayer5); + soilProfile.Surfaces.Add(soilLayer6); + soilProfile.Surfaces.Add(soilLayer7); + soilProfile.Surfaces.Add(soilLayer8); + soilProfile.Surfaces.Add(soilLayer9); + soilProfile.Surfaces.Add(soilLayerBottom); + soilProfile.Geometry.Surfaces.Add(new GeometrySurface()); + /*soilProfile.Geometry.SurfaceLine.CalcPoints.Add(new Point2D(leftCoordinate, 20)); + soilProfile.Geometry.SurfaceLine.CalcPoints.Add(new Point2D(rightCoordinate, 20)); + soilProfile.Geometry.SurfaceLine.SyncPoints();*/ + + PlLines plLines = CreateAllPlLines(pL1Level); + + // Call + WaternetLine waternetLine = PlLinesToWaternetConverter.CreateWaternetLineForPhreaticLineForDamStandard(soilProfile, plLines.Lines[PlLineType.Pl1]); + + // Assert + Assert.That(waternetLine, Has.Count.EqualTo(2)); + Assert.Multiple(() => + { + Assert.That(waternetLine.Points[0].X, Is.EqualTo(leftCoordinate).Within(precision3Decimals)); + Assert.That(waternetLine.Points[0].Z, Is.EqualTo(expectedWaternetLineLevel).Within(precision3Decimals)); + Assert.That(waternetLine.Points[1].X, Is.EqualTo(rightCoordinate).Within(precision3Decimals)); + Assert.That(waternetLine.Points[1].Z, Is.EqualTo(expectedWaternetLineLevel).Within(precision3Decimals)); + }); + } + private static SoilProfile1D CreateSoilProfile1DForTest(out GeometryPointString surfaceLine) { const double topLevel = 1.212; Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/Deltares.DamEngine.Calculators.Tests.csproj =================================================================== diff -u -r5067 -r5083 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/Deltares.DamEngine.Calculators.Tests.csproj (.../Deltares.DamEngine.Calculators.Tests.csproj) (revision 5067) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/Deltares.DamEngine.Calculators.Tests.csproj (.../Deltares.DamEngine.Calculators.Tests.csproj) (revision 5083) @@ -19,6 +19,9 @@ + + PreserveNewest + PreserveNewest Index: DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/Factories/FactoryForSoilProfiles.cs =================================================================== diff -u -r5074 -r5083 --- DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/Factories/FactoryForSoilProfiles.cs (.../FactoryForSoilProfiles.cs) (revision 5074) +++ DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/Factories/FactoryForSoilProfiles.cs (.../FactoryForSoilProfiles.cs) (revision 5083) @@ -1073,13 +1073,15 @@ return soilProfile2D; } - // -50 -20 -10 0 35 60 - // |-----------------|--------------|-----------------------------| Level 10 m - // | surface 1 | surface 2 | surface 3 | - // |-----------------|------|-------|--------------|--------------| Level 0 m - // | surface 4 | surface 5 | surface | - // | | | 6 | - // |------------------------|----------------------|--------------| Level -15 m + /// + /// -50 -20 -10 0 35 60 + /// |-----------------|--------------|-----------------------------| Level 10 m + /// | surface 1 | surface 2 | surface 3 | + /// |-----------------|------|-------|--------------|--------------| Level 0 m + /// | surface 4 | surface 5 | surface | + /// | | | 6 | + /// |------------------------|----------------------|--------------| Level -15 m + /// public static SoilProfile2D CreateSoilProfile2DWithSixSurfacesFormingTwoLayers() { SoilLayer2D soilLayer1 = CreateRectangularSoilLayer2D(10, 0, -50, -20, "Surface 1"); @@ -1181,7 +1183,8 @@ } } }, - SoilName = soilName + SoilName = soilName, + IsAquifer = false }; } Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/TestFiles/InputTutorialStabilitySoilProfileDWP1.xml =================================================================== diff -u --- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/TestFiles/InputTutorialStabilitySoilProfileDWP1.xml (revision 0) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/TestFiles/InputTutorialStabilitySoilProfileDWP1.xml (revision 5083) @@ -0,0 +1,511 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file