Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/PlLinesToWaternetConverter.cs =================================================================== diff -u -r5015 -r5020 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/PlLinesToWaternetConverter.cs (.../PlLinesToWaternetConverter.cs) (revision 5015) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/PlLinesToWaternetConverter.cs (.../PlLinesToWaternetConverter.cs) (revision 5020) @@ -47,7 +47,8 @@ private const string waternetLine1Name = "Waternet line phreatic line"; private const string waternetLine2Name = "Penetration zone lower aquifer"; private const string waternetLine3Name = "Waternet line lower aquifer"; - private const string waternetLine4Name = "Waternet area in-between aquifer"; + private const string waternetLine4TopName = "Waternet line in-between aquifer top"; + private const string waternetLine4BottomName = "Waternet line in-between aquifer bottom"; private const string headLine1Name = "Phreatic line (PL 1)"; private const string headLine2Name = "Head line 2 (PL 2)"; private const string headLine3Name = "Head line 3 (PL 3)"; @@ -228,11 +229,16 @@ { number++; double levelTop = inBetweenAquiferCluster.Item1.TopLevel; + WaternetLine waternetLineTop = CreateWaternetLine(levelTop, xLeft, xRight); + waternetLineTop.Name = waternetLine4TopName + " (" + number + ")"; + waternetLineTop.HeadLine = headLine; + waternet.WaternetLineList.Add(waternetLineTop); + double levelBottom = inBetweenAquiferCluster.Item2.BottomLevel; - WaternetLine waternetLine = CreateWaternetLine(levelTop, levelBottom, xLeft, xRight); - waternetLine.Name = waternetLine4Name + " (" + number + ")"; - waternetLine.HeadLine = headLine; - waternet.WaternetLineList.Add(waternetLine); + WaternetLine waternetLineBottom = CreateWaternetLine(levelBottom, xLeft, xRight); + waternetLineBottom.Name = waternetLine4BottomName + " (" + number + ")"; + waternetLineBottom.HeadLine = headLine; + waternet.WaternetLineList.Add(waternetLineBottom); } } @@ -263,10 +269,15 @@ if (inBetweenAquiferUpperCoordinates.Any() && inBetweenAquiferLowerCoordinates.Any()) { - WaternetLine waternetLine = CreateWaternetLine(inBetweenAquiferUpperCoordinates, inBetweenAquiferLowerCoordinates); - waternetLine.HeadLine = headLine; - waternetLine.Name = waternetLine4Name + " (" + (i + 1) + ")"; - waternet.WaternetLineList.Add(waternetLine); + WaternetLine waternetLineTop = CreateWaternetLine(inBetweenAquiferUpperCoordinates); + waternetLineTop.HeadLine = headLine; + waternetLineTop.Name = waternetLine4TopName + " (" + (i + 1) + ")"; + waternet.WaternetLineList.Add(waternetLineTop); + + WaternetLine waternetLineBottom = CreateWaternetLine(inBetweenAquiferLowerCoordinates); + waternetLineBottom.HeadLine = headLine; + waternetLineBottom.Name = waternetLine4BottomName + " (" + (i + 1) + ")"; + waternet.WaternetLineList.Add(waternetLineBottom); } } } @@ -714,13 +725,17 @@ { const double minimumDistance = 0.001; WaternetLine waternetLine1 = waternet.WaternetLineList.Find(w => w.Name == waternetLine1Name); - foreach (GeometryPoint waternetLine1Point - in from waternetLineOther in waternet.WaternetLineList.FindAll(w => w.Name != waternetLine1Name) - from waternetLine1Point in waternetLine1.Points - where waternetLineOther.Points.Any(point => Math.Abs(point.Z - waternetLine1Point.Z) < epsilon) - select waternetLine1Point) + if (waternetLine1 != null) { - waternetLine1Point.Z += minimumDistance; + foreach (GeometryPoint waternetLine1Point + in from waternetLineOther in waternet.WaternetLineList.FindAll(w => w.Name != waternetLine1Name) + from waternetLine1Point in waternetLine1.Points + where waternetLineOther.Points.Any(point => Math.Abs(point.Z - waternetLine1Point.Z) < epsilon) + select waternetLine1Point) + { + waternetLine1Point.Z += minimumDistance; + } + waternetLine1.SyncCalcPoints(); } } Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/PlLinesToWaternetConverterTests.cs =================================================================== diff -u -r5015 -r5020 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/PlLinesToWaternetConverterTests.cs (.../PlLinesToWaternetConverterTests.cs) (revision 5015) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/PlLinesToWaternetConverterTests.cs (.../PlLinesToWaternetConverterTests.cs) (revision 5020) @@ -80,11 +80,12 @@ Assert.That(waternet.WaternetLineList, Is.Empty); } - [TestCase(IntrusionVerticalWaterPressureType.Standard, -2.110, 4)] - [TestCase(IntrusionVerticalWaterPressureType.Linear, 1.212, 4)] - [TestCase(IntrusionVerticalWaterPressureType.HydroStatic, -2.110, 4)] + [TestCase(IntrusionVerticalWaterPressureType.Standard, -2.110, 6)] + [TestCase(IntrusionVerticalWaterPressureType.Linear, 1.212, 6)] + [TestCase(IntrusionVerticalWaterPressureType.HydroStatic, -2.110, 6)] [TestCase(IntrusionVerticalWaterPressureType.FullHydroStatic, -30.000, 1)] - [TestCase(IntrusionVerticalWaterPressureType.SemiTimeDependent, -2.110, 5)] + [TestCase(IntrusionVerticalWaterPressureType.SemiTimeDependent, -2.110, 7)] + [TestCase(IntrusionVerticalWaterPressureType.SemiTimeDependent, -2.110, 7)] public void Given1DSoilProfileWithTwoInBetweenAquifers_WhenCreatingWaternetBasedOnPlLinesAnd1DSoilProfile_ThenReturnsValidWaternet(IntrusionVerticalWaterPressureType? pressureType, double levelWaternetPl1, int waternetLineCount) { PlLines plLines = CreatePlLinesForTest(); @@ -107,8 +108,8 @@ // Pl 1 is the phreatic line and gets waternet line to bottom level of the deepest layer where PL 1 lies // Pl 2 gets waternet line to level of BottomAquiferLayer.TopLevel + penetrationLength - // Pl 3 gets waternet line to level of InBetweenAquiferLayer.TopLevel - // Pl 4 gets waternet line around the BottomAquiferLayer + // Pl 3 gets waternet line to level of BottomAquiferLayer + // Pl 4 gets 4 waternet lines to level of InBetweenAquiferLayer.TopLevel and InBetweenAquiferLayer.BottomLevel for both in-between aquifers Assert.That(waternet.WaternetLineList, Has.Count.EqualTo(waternetLineCount)); Assert.Multiple(() => @@ -167,8 +168,10 @@ // PL 3 and PL 4 WaternetLine waternetLinePl3 = waternet.WaternetLineList.Find(waternetLine => waternetLine.Name == "Waternet line lower aquifer"); - WaternetLine waternetLinePl4Top = waternet.WaternetLineList.Find(waternetLine => waternetLine.Name == "Waternet area in-between aquifer (1)"); - WaternetLine waternetLinePl4Bottom = waternet.WaternetLineList.Find(waternetLine => waternetLine.Name == "Waternet area in-between aquifer (2)"); + WaternetLine waternetLinePl4TopInBetweenAquiferTop = waternet.WaternetLineList.Find(waternetLine => waternetLine.Name == "Waternet line in-between aquifer top (1)"); + WaternetLine waternetLinePl4TopInBetweenAquiferBottom = waternet.WaternetLineList.Find(waternetLine => waternetLine.Name == "Waternet line in-between aquifer bottom (1)"); + WaternetLine waternetLinePl4BottomInBetweenAquiferTop = waternet.WaternetLineList.Find(waternetLine => waternetLine.Name == "Waternet line in-between aquifer top (2)"); + WaternetLine waternetLinePl4BottomInBetweenAquiferBottom = waternet.WaternetLineList.Find(waternetLine => waternetLine.Name == "Waternet line in-between aquifer bottom (2)"); if (pressureType != IntrusionVerticalWaterPressureType.FullHydroStatic) { @@ -182,48 +185,50 @@ { Assert.That(waternetLinePl3.Points[0].Z, Is.EqualTo(-6.111).Within(precision3Decimals)); - // expected: highest waternet line connected to pl4 has level between -2.111 and -3.373 - Assert.That(waternetLinePl4Top.HeadLine.Name, Is.EqualTo("Head line 4 (PL 4)")); - Assert.That(waternetLinePl4Top.Points, Has.Count.EqualTo(5)); + // expected: highest waternet lines connected to pl4 have levels -2.111 and -3.373 + Assert.That(waternetLinePl4TopInBetweenAquiferTop.HeadLine.Name, Is.EqualTo("Head line 4 (PL 4)")); + Assert.That(waternetLinePl4TopInBetweenAquiferTop.Points, Has.Count.EqualTo(2)); + Assert.That(waternetLinePl4TopInBetweenAquiferBottom.HeadLine.Name, Is.EqualTo("Head line 4 (PL 4)")); + Assert.That(waternetLinePl4TopInBetweenAquiferBottom.Points, Has.Count.EqualTo(2)); }); Assert.Multiple(() => { - Assert.That(waternetLinePl4Top.Points[0].X, Is.EqualTo(0).Within(precision3Decimals)); - Assert.That(waternetLinePl4Top.Points[0].Z, Is.EqualTo(-2.111).Within(precision3Decimals)); - Assert.That(waternetLinePl4Top.Points[1].X, Is.EqualTo(100).Within(precision3Decimals)); - Assert.That(waternetLinePl4Top.Points[1].Z, Is.EqualTo(-2.111).Within(precision3Decimals)); - Assert.That(waternetLinePl4Top.Points[2].X, Is.EqualTo(100).Within(precision3Decimals)); - Assert.That(waternetLinePl4Top.Points[2].Z, Is.EqualTo(-3.373).Within(precision3Decimals)); - Assert.That(waternetLinePl4Top.Points[3].X, Is.EqualTo(0).Within(precision3Decimals)); - Assert.That(waternetLinePl4Top.Points[3].Z, Is.EqualTo(-3.373).Within(precision3Decimals)); - Assert.That(waternetLinePl4Top.Points[4].X, Is.EqualTo(0).Within(precision3Decimals)); - Assert.That(waternetLinePl4Top.Points[4].Z, Is.EqualTo(-2.111).Within(precision3Decimals)); + Assert.That(waternetLinePl4TopInBetweenAquiferTop.Points[0].X, Is.EqualTo(0).Within(precision3Decimals)); + Assert.That(waternetLinePl4TopInBetweenAquiferTop.Points[0].Z, Is.EqualTo(-2.111).Within(precision3Decimals)); + Assert.That(waternetLinePl4TopInBetweenAquiferTop.Points[1].X, Is.EqualTo(100).Within(precision3Decimals)); + Assert.That(waternetLinePl4TopInBetweenAquiferTop.Points[1].Z, Is.EqualTo(-2.111).Within(precision3Decimals)); + Assert.That(waternetLinePl4TopInBetweenAquiferBottom.Points[0].X, Is.EqualTo(0).Within(precision3Decimals)); + Assert.That(waternetLinePl4TopInBetweenAquiferBottom.Points[0].Z, Is.EqualTo(-3.373).Within(precision3Decimals)); + Assert.That(waternetLinePl4TopInBetweenAquiferBottom.Points[1].X, Is.EqualTo(100).Within(precision3Decimals)); + Assert.That(waternetLinePl4TopInBetweenAquiferBottom.Points[1].Z, Is.EqualTo(-3.373).Within(precision3Decimals)); - // expected: lowest waternet line 4 connected to pl4 has level between -4.151 and -5.373 - Assert.That(waternetLinePl4Bottom.HeadLine.Name, Is.EqualTo("Head line 4 (PL 4)")); - Assert.That(waternetLinePl4Bottom.Points, Has.Count.EqualTo(5)); + // expected: lowest waternet lines 4 connected to pl4 have levels -4.151 and -5.373 + Assert.That(waternetLinePl4BottomInBetweenAquiferTop.HeadLine.Name, Is.EqualTo("Head line 4 (PL 4)")); + Assert.That(waternetLinePl4BottomInBetweenAquiferTop.Points, Has.Count.EqualTo(2)); + Assert.That(waternetLinePl4BottomInBetweenAquiferBottom.HeadLine.Name, Is.EqualTo("Head line 4 (PL 4)")); + Assert.That(waternetLinePl4BottomInBetweenAquiferBottom.Points, Has.Count.EqualTo(2)); }); Assert.Multiple(() => { - Assert.That(waternetLinePl4Bottom.Points[0].X, Is.EqualTo(0).Within(precision3Decimals)); - Assert.That(waternetLinePl4Bottom.Points[0].Z, Is.EqualTo(-4.151).Within(precision3Decimals)); - Assert.That(waternetLinePl4Bottom.Points[1].X, Is.EqualTo(100).Within(precision3Decimals)); - Assert.That(waternetLinePl4Bottom.Points[1].Z, Is.EqualTo(-4.151).Within(precision3Decimals)); - Assert.That(waternetLinePl4Bottom.Points[2].X, Is.EqualTo(100).Within(precision3Decimals)); - Assert.That(waternetLinePl4Bottom.Points[2].Z, Is.EqualTo(-5.373).Within(precision3Decimals)); - Assert.That(waternetLinePl4Bottom.Points[3].X, Is.EqualTo(0).Within(precision3Decimals)); - Assert.That(waternetLinePl4Bottom.Points[3].Z, Is.EqualTo(-5.373).Within(precision3Decimals)); - Assert.That(waternetLinePl4Bottom.Points[4].X, Is.EqualTo(0).Within(precision3Decimals)); - Assert.That(waternetLinePl4Bottom.Points[4].Z, Is.EqualTo(-4.151).Within(precision3Decimals)); + Assert.That(waternetLinePl4BottomInBetweenAquiferTop.Points[0].X, Is.EqualTo(0).Within(precision3Decimals)); + Assert.That(waternetLinePl4BottomInBetweenAquiferTop.Points[0].Z, Is.EqualTo(-4.151).Within(precision3Decimals)); + Assert.That(waternetLinePl4BottomInBetweenAquiferTop.Points[1].X, Is.EqualTo(100).Within(precision3Decimals)); + Assert.That(waternetLinePl4BottomInBetweenAquiferTop.Points[1].Z, Is.EqualTo(-4.151).Within(precision3Decimals)); + Assert.That(waternetLinePl4BottomInBetweenAquiferBottom.Points[0].X, Is.EqualTo(0).Within(precision3Decimals)); + Assert.That(waternetLinePl4BottomInBetweenAquiferBottom.Points[0].Z, Is.EqualTo(-5.373).Within(precision3Decimals)); + Assert.That(waternetLinePl4BottomInBetweenAquiferBottom.Points[1].X, Is.EqualTo(100).Within(precision3Decimals)); + Assert.That(waternetLinePl4BottomInBetweenAquiferBottom.Points[1].Z, Is.EqualTo(-5.373).Within(precision3Decimals)); }); } else { Assert.Multiple(() => { Assert.That(waternetLinePl3, Is.Null); - Assert.That(waternetLinePl4Top, Is.Null); - Assert.That(waternetLinePl4Bottom, Is.Null); + Assert.That(waternetLinePl4TopInBetweenAquiferTop, Is.Null); + Assert.That(waternetLinePl4TopInBetweenAquiferBottom, Is.Null); + Assert.That(waternetLinePl4BottomInBetweenAquiferTop, Is.Null); + Assert.That(waternetLinePl4BottomInBetweenAquiferBottom, Is.Null); }); } } @@ -270,7 +275,7 @@ Assert.Multiple(() => { Assert.That(waternet.HeadLineList, Has.Count.EqualTo(3)); - Assert.That(waternet.WaternetLineList, Has.Count.EqualTo(5)); + Assert.That(waternet.WaternetLineList, Has.Count.EqualTo(7)); }); // check that no waternet lines are added for pl4 when InBetweenAquiferLayer is null @@ -315,12 +320,12 @@ /// Aquifer 7a | Aquifer 7b | Aquifer 7c /// --------------------------------------------------- Level -35 m /// - [TestCase(IntrusionVerticalWaterPressureType.Standard, -9.999, 4, 2)] - [TestCase(IntrusionVerticalWaterPressureType.Linear, 20.000, 4, 2)] - [TestCase(IntrusionVerticalWaterPressureType.HydroStatic, 10.001, 4, 2)] + [TestCase(IntrusionVerticalWaterPressureType.Standard, -9.999, 6, 2)] + [TestCase(IntrusionVerticalWaterPressureType.Linear, 20.000, 6, 2)] + [TestCase(IntrusionVerticalWaterPressureType.HydroStatic, 10.001, 6, 2)] [TestCase(IntrusionVerticalWaterPressureType.FullHydroStatic, -35.000, 1, 0)] - [TestCase(IntrusionVerticalWaterPressureType.SemiTimeDependent, -9.999, 5, 3, penetrationLength)] - [TestCase(IntrusionVerticalWaterPressureType.SemiTimeDependent, -9.999, 4, 2, 0)] + [TestCase(IntrusionVerticalWaterPressureType.SemiTimeDependent, -9.999, 7, 3, penetrationLength)] + [TestCase(IntrusionVerticalWaterPressureType.SemiTimeDependent, -9.999, 6, 2, 0)] public void Given2DSoilProfileWithTwoInBetweenAquifers_WhenCreatingWaternetBasedOnPlLinesAnd2DSoilProfile_ThenReturnsValidWaternet(IntrusionVerticalWaterPressureType? pressureType, double levelWaternetPl1, int waternetLineCount, int headlineCount, double penetrationZone = double.NaN) { double xA = leftCoordinate + (rightCoordinate - leftCoordinate) / 3; @@ -431,25 +436,33 @@ Assert.That(pl3WaternetLine.HeadLine, Is.SameAs(waternet.HeadLineList[indexHeadlinePl3])); AssertGeometry(expectedBottomAquiferCoordinates, pl3WaternetLine.Points); - WaternetLine pl4WaternetLine1 = waternet.WaternetLineList.Find(w => w.Name == "Waternet area in-between aquifer (1)"); - Assert.That(pl4WaternetLine1.HeadLine, Is.SameAs(waternet.HeadLineList[indexHeadlinePl4])); + WaternetLine pl4WaternetLine1Top = waternet.WaternetLineList.Find(w => w.Name == "Waternet line in-between aquifer top (1)"); + Assert.That(pl4WaternetLine1Top.HeadLine, Is.SameAs(waternet.HeadLineList[indexHeadlinePl4])); AssertGeometry([ new Point2D(leftCoordinate, 10), - new Point2D(rightCoordinate, 10), - new Point2D(rightCoordinate, 0), + new Point2D(rightCoordinate, 10) + ], pl4WaternetLine1Top.Points); + + WaternetLine pl4WaternetLineBottom = waternet.WaternetLineList.Find(w => w.Name == "Waternet line in-between aquifer bottom (1)"); + Assert.That(pl4WaternetLineBottom.HeadLine, Is.SameAs(waternet.HeadLineList[indexHeadlinePl4])); + AssertGeometry([ new Point2D(leftCoordinate, 0), - new Point2D(leftCoordinate, 10) - ], pl4WaternetLine1.Points); + new Point2D(rightCoordinate, 0) + ], pl4WaternetLineBottom.Points); - WaternetLine pl4WaternetLine2 = waternet.WaternetLineList.Find(w => w.Name == "Waternet area in-between aquifer (2)"); - Assert.That(pl4WaternetLine2.HeadLine, Is.SameAs(waternet.HeadLineList[indexHeadlinePl4])); + WaternetLine pl4WaternetLine2Top = waternet.WaternetLineList.Find(w => w.Name == "Waternet line in-between aquifer top (2)"); + Assert.That(pl4WaternetLine2Top.HeadLine, Is.SameAs(waternet.HeadLineList[indexHeadlinePl4])); AssertGeometry([ new Point2D(leftCoordinate, -10), - new Point2D(rightCoordinate, -10), - new Point2D(rightCoordinate, -20), + new Point2D(rightCoordinate, -10) + ], pl4WaternetLine2Top.Points); + + WaternetLine pl4WaternetLine2Bottom = waternet.WaternetLineList.Find(w => w.Name == "Waternet line in-between aquifer bottom (2)"); + Assert.That(pl4WaternetLine2Bottom.HeadLine, Is.SameAs(waternet.HeadLineList[indexHeadlinePl4])); + AssertGeometry([ new Point2D(leftCoordinate, -20), - new Point2D(leftCoordinate, -10) - ], pl4WaternetLine2.Points); + new Point2D(rightCoordinate, -20) + ], pl4WaternetLine2Bottom.Points); } }