Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/PlLinesToWaternetConverterTests.cs =================================================================== diff -u -r4986 -r4988 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/PlLinesToWaternetConverterTests.cs (.../PlLinesToWaternetConverterTests.cs) (revision 4986) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/PlLinesToWaternetConverterTests.cs (.../PlLinesToWaternetConverterTests.cs) (revision 4988) @@ -79,7 +79,7 @@ Assert.That(waternet.HeadLineList, Is.Empty); Assert.That(waternet.WaternetLineList, Is.Empty); } - + [TestCase(IntrusionVerticalWaterPressureType.Standard, -2.110, 4)] [TestCase(IntrusionVerticalWaterPressureType.Linear, 1.212, 4)] [TestCase(IntrusionVerticalWaterPressureType.HydroStatic, -2.110, 4)] @@ -109,36 +109,19 @@ // 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 + Assert.That(waternet.WaternetLineList, Has.Count.EqualTo(waternetLineCount)); - // expected phreatic line from pl 1 - Assert.That(waternet.PhreaticLine.Points, Has.Count.EqualTo(3)); Assert.Multiple(() => { + // phreatic line (PL 1) + Assert.That(waternet.PhreaticLine.Points, Has.Count.EqualTo(3)); Assert.That(waternet.PhreaticLine.Points[0].X, Is.EqualTo(0).Within(precision3Decimals)); Assert.That(waternet.PhreaticLine.Points[0].Z, Is.EqualTo(0).Within(precision3Decimals)); Assert.That(waternet.PhreaticLine.Points[1].X, Is.EqualTo(50).Within(precision3Decimals)); Assert.That(waternet.PhreaticLine.Points[1].Z, Is.EqualTo(1).Within(precision3Decimals)); Assert.That(waternet.PhreaticLine.Points[2].X, Is.EqualTo(100).Within(precision3Decimals)); Assert.That(waternet.PhreaticLine.Points[2].Z, Is.EqualTo(1).Within(precision3Decimals)); - }); - // expected headlines from pl 2, 3 and 4 - Assert.That(waternet.HeadLineList, Has.Count.EqualTo(3)); - Assert.Multiple(() => - { - Assert.That(waternet.HeadLineList[0].Points, Has.Count.EqualTo(2)); - Assert.That(waternet.HeadLineList[0].Name, Is.EqualTo("Head line 2 (PL 2)")); - Assert.That(waternet.HeadLineList[1].Points, Has.Count.EqualTo(3)); - Assert.That(waternet.HeadLineList[1].Name, Is.EqualTo("Head line 3 (PL 3)")); - Assert.That(waternet.HeadLineList[2].Points, Has.Count.EqualTo(2)); - Assert.That(waternet.HeadLineList[2].Name, Is.EqualTo("Head line 4 (PL 4)")); - // check the points of first headline that represents pl 2 - Assert.That(waternet.HeadLineList[0].Points[0].X, Is.EqualTo(0).Within(precision3Decimals)); - Assert.That(waternet.HeadLineList[0].Points[0].Z, Is.EqualTo(0).Within(precision3Decimals)); - Assert.That(waternet.HeadLineList[0].Points[1].X, Is.EqualTo(100).Within(precision3Decimals)); - Assert.That(waternet.HeadLineList[0].Points[1].Z, Is.EqualTo(-1).Within(precision3Decimals)); - Assert.That(waternet.WaternetLineList, Has.Count.EqualTo(waternetLineCount)); - WaternetLine waternetLinePl1 = waternet.WaternetLineList.Find(waternetLine => waternetLine.Name == "Waternet line phreatic line"); // expected: waternet line connected to pl1 has level: // - for DAM Standard and Semi time dependent types, -2.111 m + 1 mm (Pl1 is in layer 2 from 0 m to -2.111 m) @@ -153,77 +136,89 @@ Assert.That(waternetLinePl1.Points[0].Z, Is.EqualTo(levelWaternetPl1).Within(precision3Decimals)); Assert.That(waternetLinePl1.Points[1].X, Is.EqualTo(100).Within(precision3Decimals)); Assert.That(waternetLinePl1.Points[1].Z, Is.EqualTo(levelWaternetPl1).Within(precision3Decimals)); + }); - WaternetLine waternetLinePl2 = waternet.WaternetLineList.Find(waternetLine => waternetLine.Name == "Penetration zone lower aquifer"); - if (pressureType == IntrusionVerticalWaterPressureType.SemiTimeDependent) + // PL 2 + WaternetLine waternetLinePl2 = waternet.WaternetLineList.Find(waternetLine => waternetLine.Name == "Penetration zone lower aquifer"); + if (pressureType == IntrusionVerticalWaterPressureType.SemiTimeDependent) + { + Assert.Multiple(() => { + Assert.That(waternet.HeadLineList[0].Points, Has.Count.EqualTo(2)); + Assert.That(waternet.HeadLineList[0].Name, Is.EqualTo("Head line 2 (PL 2)")); + // check the points of first headline that represents pl 2 + Assert.That(waternet.HeadLineList[0].Points[0].X, Is.EqualTo(0).Within(precision3Decimals)); + Assert.That(waternet.HeadLineList[0].Points[0].Z, Is.EqualTo(0).Within(precision3Decimals)); + Assert.That(waternet.HeadLineList[0].Points[1].X, Is.EqualTo(100).Within(precision3Decimals)); + Assert.That(waternet.HeadLineList[0].Points[1].Z, Is.EqualTo(-1).Within(precision3Decimals)); // expected: waternet line connected to pl2 has level -6.111 + 2.1 = -4.011 Assert.That(waternetLinePl2.HeadLine, Is.EqualTo(waternet.HeadLineList[0])); Assert.That(waternetLinePl2.Points, Has.Count.EqualTo(2)); Assert.That(waternetLinePl2.Points[0].X, Is.EqualTo(0).Within(precision3Decimals)); Assert.That(waternetLinePl2.Points[0].Z, Is.EqualTo(-4.011).Within(precision3Decimals)); Assert.That(waternetLinePl2.Points[1].X, Is.EqualTo(100).Within(precision3Decimals)); Assert.That(waternetLinePl2.Points[1].Z, Is.EqualTo(-4.011).Within(precision3Decimals)); - } - else - { - Assert.That(waternetLinePl2, Is.Null); - } + }); + } + else + { + Assert.That(waternetLinePl2, Is.Null); + } - 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)"); - - if (pressureType != IntrusionVerticalWaterPressureType.FullHydroStatic) - { - // expected: waternet line connected to pl3 has level -6.111 - Assert.That(waternetLinePl3.HeadLine, Is.EqualTo(waternet.HeadLineList[1])); - Assert.That(waternetLinePl3.Points, Has.Count.EqualTo(2)); - Assert.That(waternetLinePl3.Points[0].Z, Is.EqualTo(-6.111).Within(precision3Decimals)); + // 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)"); - // expected: highest waternet line connected to pl4 has level between -2.111 and -3.373 - Assert.That(waternetLinePl4Top.HeadLine, Is.EqualTo(waternet.HeadLineList[2])); - Assert.That(waternetLinePl4Top.Points, Has.Count.EqualTo(5)); - 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)); + if (pressureType != IntrusionVerticalWaterPressureType.FullHydroStatic) + { + // expected: waternet line connected to pl3 has level -6.111 + Assert.That(waternetLinePl3.HeadLine.Name, Is.EqualTo("Head line 3 (PL 3)")); + Assert.That(waternetLinePl3.Points, Has.Count.EqualTo(2)); + Assert.That(waternetLinePl3.Points[0].Z, Is.EqualTo(-6.111).Within(precision3Decimals)); - // expected: lowest waternet line 4 connected to pl4 has level between -4.151 and -5.373 - Assert.That(waternetLinePl4Bottom.HeadLine, Is.EqualTo(waternet.HeadLineList[2])); - Assert.That(waternetLinePl4Bottom.Points, Has.Count.EqualTo(5)); - 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)); - } - else - { - Assert.That(waternetLinePl3, Is.Null); - Assert.That(waternetLinePl4Top, Is.Null); - Assert.That(waternetLinePl4Bottom, Is.Null); - } - }); + // 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)); + 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)); + + // 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)); + 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)); + } + else + { + Assert.That(waternetLinePl3, Is.Null); + Assert.That(waternetLinePl4Top, Is.Null); + Assert.That(waternetLinePl4Bottom, Is.Null); + } } [Test] public void GivenNullPlLines_WhenCreatingWaternetBasedOnPlLinesAnd1DSoilProfile_ThenReturnsNoHeadLines() { PlLines plLines = CreatePlLinesForTest(); SoilProfile1D soilProfile1D = CreateSoilProfile1DForTest(out GeometryPointString surfaceLine); - Waternet waternet = PlLinesToWaternetConverter.CreateWaternetBasedOnPlLines(plLines, soilProfile1D, surfaceLine, 0, 0, 0, IntrusionVerticalWaterPressureType.Standard); + Waternet waternet = PlLinesToWaternetConverter.CreateWaternetBasedOnPlLines(plLines, soilProfile1D, surfaceLine, 0.5, 0, 0, IntrusionVerticalWaterPressureType.SemiTimeDependent); // head lines Assert.That(waternet.HeadLineList, Has.Count.EqualTo(3)); Assert.Multiple(() => @@ -238,7 +233,7 @@ // check that no headline are added when Pl2, Pl3 or Pl4 does not exist or has no points plLines.Lines[PlLineType.Pl3] = null; plLines.Lines[PlLineType.Pl4].Points.Clear(); - waternet = PlLinesToWaternetConverter.CreateWaternetBasedOnPlLines(plLines, soilProfile1D, surfaceLine, 0, 0, 0, IntrusionVerticalWaterPressureType.Standard); + waternet = PlLinesToWaternetConverter.CreateWaternetBasedOnPlLines(plLines, soilProfile1D, surfaceLine, 0.5, 0, 0, IntrusionVerticalWaterPressureType.SemiTimeDependent); // head lines Assert.That(waternet.HeadLineList, Has.Count.EqualTo(1)); Assert.Multiple(() => @@ -280,18 +275,17 @@ Assert.That(waternet.WaternetLineList[2].Points[0].Z, Is.EqualTo(-6.111).Within(precision3Decimals)); }); - // check that no waternet lines are added for pl2, pl3 and pl4 when BottomAquiferLayer is null + // check that no waternet lines are added for pl2, pl3 and pl4 when no aquifer present soilProfile1D = CreateSoilProfile1DWithoutAquifersForTest(); - waternet = PlLinesToWaternetConverter.CreateWaternetBasedOnPlLines(plLines, soilProfile1D, surfaceLine, penetrateLength, 0, 0, IntrusionVerticalWaterPressureType.Standard); + waternet = PlLinesToWaternetConverter.CreateWaternetBasedOnPlLines(plLines, soilProfile1D, surfaceLine, penetrateLength, 0, 0, IntrusionVerticalWaterPressureType.SemiTimeDependent); Assert.Multiple(() => { - Assert.That(waternet.HeadLineList, Has.Count.EqualTo(3)); + Assert.That(waternet.HeadLineList, Has.Count.EqualTo(1)); Assert.That(waternet.WaternetLineList, Has.Count.EqualTo(1)); Assert.That(waternet.WaternetLineList[0].HeadLine.Name, Is.SameAs(waternet.PhreaticLine.Name)); }); } - /// X_a X_b /// --------------------------------------------------- Level 20 m /// Aquitard 1 @@ -309,13 +303,13 @@ /// Aquifer 7a | Aquifer 7b | Aquifer 7c /// --------------------------------------------------- Level -35 m /// - [TestCase(IntrusionVerticalWaterPressureType.Standard, -9.999, 4)] - [TestCase(IntrusionVerticalWaterPressureType.Linear, 20.000, 4)] - [TestCase(IntrusionVerticalWaterPressureType.HydroStatic, 10.001, 4)] - [TestCase(IntrusionVerticalWaterPressureType.FullHydroStatic, -35.000, 1)] - [TestCase(IntrusionVerticalWaterPressureType.SemiTimeDependent, -9.999, 5, penetrationLength)] - [TestCase(IntrusionVerticalWaterPressureType.SemiTimeDependent, -9.999, 4, 0)] - public void Given2DSoilProfileWithTwoInBetweenAquifers_WhenCreatingWaternetBasedOnPlLinesAnd2DSoilProfile_ThenReturnsValidWaternet(IntrusionVerticalWaterPressureType? pressureType, double levelWaternetPl1, int waternetLineCount, double penetrationZone = double.NaN) + [TestCase(IntrusionVerticalWaterPressureType.Standard, -9.999, 4, 2)] + [TestCase(IntrusionVerticalWaterPressureType.Linear, 20.000, 4, 2)] + [TestCase(IntrusionVerticalWaterPressureType.HydroStatic, 10.001, 4, 2)] + [TestCase(IntrusionVerticalWaterPressureType.FullHydroStatic, -35.000, 1, 0)] + [TestCase(IntrusionVerticalWaterPressureType.SemiTimeDependent, -9.999, 5, 3, penetrationLength)] + [TestCase(IntrusionVerticalWaterPressureType.SemiTimeDependent, -9.999, 4, 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; double xB = rightCoordinate - (rightCoordinate - leftCoordinate) / 3; @@ -369,26 +363,37 @@ // Assert AssertGeometry(plLines.Lines[PlLineType.Pl1].Points, waternet.PhreaticLine.Points); - Assert.That(waternet.HeadLineList, Has.Count.EqualTo(3)); - AssertGeometry(plLines.Lines[PlLineType.Pl2].Points, waternet.HeadLineList[0].Points); - AssertGeometry(plLines.Lines[PlLineType.Pl3].Points, waternet.HeadLineList[1].Points); - AssertGeometry(plLines.Lines[PlLineType.Pl4].Points, waternet.HeadLineList[2].Points); + Assert.That(waternet.HeadLineList, Has.Count.EqualTo(headlineCount)); + var indexHeadlinePl3 = 0; + var indexHeadlinePl4 = 1; + if (pressureType == IntrusionVerticalWaterPressureType.SemiTimeDependent && penetrationZone > 0) + { + AssertGeometry(plLines.Lines[PlLineType.Pl2].Points, waternet.HeadLineList[0].Points); + indexHeadlinePl3 += 1; + indexHeadlinePl4 += 1; + } + if (pressureType != IntrusionVerticalWaterPressureType.FullHydroStatic) + { + AssertGeometry(plLines.Lines[PlLineType.Pl3].Points, waternet.HeadLineList[indexHeadlinePl3].Points); + AssertGeometry(plLines.Lines[PlLineType.Pl4].Points, waternet.HeadLineList[indexHeadlinePl4].Points); + } + Assert.That(waternet.WaternetLineList, Has.Count.EqualTo(waternetLineCount)); WaternetLine pl1WaternetLine = waternet.WaternetLineList.Find(w => w.HeadLine.Name == waternet.PhreaticLine.Name); Assert.That(pl1WaternetLine.HeadLine.Name, Is.SameAs(waternet.PhreaticLine.Name)); Point2D[] expectedWaternetLine1 = [ - new Point2D(leftCoordinate, levelWaternetPl1), - new Point2D(rightCoordinate, levelWaternetPl1) + new(leftCoordinate, levelWaternetPl1), + new(rightCoordinate, levelWaternetPl1) ]; AssertGeometry(expectedWaternetLine1, pl1WaternetLine.Points); Point2D[] expectedBottomAquiferCoordinates = [ - new Point2D(leftCoordinate, -25), - new Point2D(rightCoordinate, -25) + new(leftCoordinate, -25), + new(rightCoordinate, -25) ]; WaternetLine pl2WaternetLine = waternet.WaternetLineList.Find(w => w.HeadLine.Name == "Head line 2 (PL 2)"); @@ -407,11 +412,11 @@ if (waternetLineCount > 1) { WaternetLine pl3WaternetLine = waternet.WaternetLineList.Find(w => w.HeadLine.Name == "Head line 3 (PL 3)"); - Assert.That(pl3WaternetLine.HeadLine, Is.SameAs(waternet.HeadLineList[1])); + 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[2])); + Assert.That(pl4WaternetLine1.HeadLine, Is.SameAs(waternet.HeadLineList[indexHeadlinePl4])); AssertGeometry([ new Point2D(leftCoordinate, 10), new Point2D(rightCoordinate, 10), @@ -421,7 +426,7 @@ ], pl4WaternetLine1.Points); WaternetLine pl4WaternetLine2 = waternet.WaternetLineList.Find(w => w.Name == "Waternet area in-between aquifer (2)"); - Assert.That(pl4WaternetLine2.HeadLine, Is.SameAs(waternet.HeadLineList[2])); + Assert.That(pl4WaternetLine2.HeadLine, Is.SameAs(waternet.HeadLineList[indexHeadlinePl4])); AssertGeometry([ new Point2D(leftCoordinate, -10), new Point2D(rightCoordinate, -10), @@ -431,7 +436,7 @@ ], pl4WaternetLine2.Points); } } - + [Test] public void TestConvertLevelToWaternetLine() { @@ -511,7 +516,7 @@ bool isInBetweenLayerPresent = PlLinesToWaternetConverter.AreInBetweenAquiferClustersPresent(soilProfile, out int count); IEnumerable topLevelInBetweenAquifer = PlLinesToWaternetConverter.DetermineLayerBoundaryPoints(PlLinesToWaternetConverter.LayerType.TopLayerInBetweenAquiferCluster, soilProfile, 0); IEnumerable bottomLevelInBetweenAquifer = PlLinesToWaternetConverter.DetermineLayerBoundaryPoints(PlLinesToWaternetConverter.LayerType.BottomLayerInBetweenAquiferCluster, soilProfile, 0); - + // Assert Assert.Multiple(() => { @@ -572,7 +577,7 @@ bool isInBetweenLayerPresent = PlLinesToWaternetConverter.AreInBetweenAquiferClustersPresent(soilProfile, out int count); IEnumerable topLevelInBetweenAquifer = PlLinesToWaternetConverter.DetermineLayerBoundaryPoints(PlLinesToWaternetConverter.LayerType.TopLayerInBetweenAquiferCluster, soilProfile, 0); IEnumerable bottomLevelInBetweenAquifer = PlLinesToWaternetConverter.DetermineLayerBoundaryPoints(PlLinesToWaternetConverter.LayerType.BottomLayerInBetweenAquiferCluster, soilProfile, 0); - + // Assert Assert.Multiple(() => { @@ -664,7 +669,7 @@ bool isInBetweenLayerPresent = PlLinesToWaternetConverter.AreInBetweenAquiferClustersPresent(soilProfile, out int count); IEnumerable topLevelInBetweenAquifer = PlLinesToWaternetConverter.DetermineLayerBoundaryPoints(PlLinesToWaternetConverter.LayerType.TopLayerInBetweenAquiferCluster, soilProfile, 0); IEnumerable bottomLevelInBetweenAquifer = PlLinesToWaternetConverter.DetermineLayerBoundaryPoints(PlLinesToWaternetConverter.LayerType.BottomLayerInBetweenAquiferCluster, soilProfile, 0); - + // Assert Assert.Multiple(() => { @@ -756,7 +761,7 @@ bool isInBetweenLayerPresent = PlLinesToWaternetConverter.AreInBetweenAquiferClustersPresent(soilProfile, out int count); IEnumerable topLevelInBetweenAquifer = PlLinesToWaternetConverter.DetermineLayerBoundaryPoints(PlLinesToWaternetConverter.LayerType.TopLayerInBetweenAquiferCluster, soilProfile, 0); IEnumerable bottomLevelInBetweenAquifer = PlLinesToWaternetConverter.DetermineLayerBoundaryPoints(PlLinesToWaternetConverter.LayerType.BottomLayerInBetweenAquiferCluster, soilProfile, 0); - + // Assert Assert.Multiple(() => { @@ -873,7 +878,7 @@ bool isInBetweenLayerPresent = PlLinesToWaternetConverter.AreInBetweenAquiferClustersPresent(soilProfile, out int count); IEnumerable topLevelInBetweenAquifer = PlLinesToWaternetConverter.DetermineLayerBoundaryPoints(PlLinesToWaternetConverter.LayerType.TopLayerInBetweenAquiferCluster, soilProfile, 0); IEnumerable bottomLevelInBetweenAquifer = PlLinesToWaternetConverter.DetermineLayerBoundaryPoints(PlLinesToWaternetConverter.LayerType.BottomLayerInBetweenAquiferCluster, soilProfile, 0); - + // Assert Assert.Multiple(() => { @@ -991,7 +996,7 @@ bool isInBetweenLayerPresent = PlLinesToWaternetConverter.AreInBetweenAquiferClustersPresent(soilProfile, out int count); IEnumerable topLevelInBetweenAquifer = PlLinesToWaternetConverter.DetermineLayerBoundaryPoints(PlLinesToWaternetConverter.LayerType.TopLayerInBetweenAquiferCluster, soilProfile, 0); IEnumerable bottomLevelInBetweenAquifer = PlLinesToWaternetConverter.DetermineLayerBoundaryPoints(PlLinesToWaternetConverter.LayerType.BottomLayerInBetweenAquiferCluster, soilProfile, 0); - + // Assert Assert.Multiple(() => { @@ -1055,9 +1060,9 @@ soilProfile.Surfaces.Add(soilLayerInBetween); soilProfile.Surfaces.Add(soilLayerAquiferBottom); - // Call + // Call bool isInBetweenLayerPresent = PlLinesToWaternetConverter.AreInBetweenAquiferClustersPresent(soilProfile, out int count); - + // Assert Assert.Multiple(() => { @@ -1103,11 +1108,8 @@ Waternet waternet = PlLinesToWaternetConverter.CreateWaternetBasedOnPlLines(plLines, soilProfile, penetrationLength, IntrusionVerticalWaterPressureType.Standard); // Assert + Assert.That(waternet.HeadLineList, Has.Count.EqualTo(0)); AssertGeometry(plLines.Lines[PlLineType.Pl1].Points, waternet.PhreaticLine.Points); - AssertGeometry(plLines.Lines[PlLineType.Pl2].Points, waternet.HeadLineList[0].Points); - AssertGeometry(plLines.Lines[PlLineType.Pl3].Points, waternet.HeadLineList[1].Points); - AssertGeometry(plLines.Lines[PlLineType.Pl4].Points, waternet.HeadLineList[2].Points); - Assert.That(waternet.WaternetLineList, Has.Count.EqualTo(1)); Assert.That(waternet.WaternetLineList[0].HeadLine.Name, Is.SameAs(waternet.PhreaticLine.Name)); } @@ -1150,10 +1152,7 @@ // Assert AssertGeometry(plLines.Lines[PlLineType.Pl1].Points, waternet.PhreaticLine.Points); - AssertGeometry(plLines.Lines[PlLineType.Pl2].Points, waternet.HeadLineList[0].Points); - AssertGeometry(plLines.Lines[PlLineType.Pl3].Points, waternet.HeadLineList[1].Points); - AssertGeometry(plLines.Lines[PlLineType.Pl4].Points, waternet.HeadLineList[2].Points); - + Assert.That(waternet.HeadLineList, Has.Count.EqualTo(0)); Assert.That(waternet.WaternetLineList, Has.Count.EqualTo(1)); Assert.That(waternet.WaternetLineList[0].HeadLine.Name, Is.SameAs(waternet.PhreaticLine.Name)); } @@ -1173,7 +1172,7 @@ var soilProfile1D = new SoilProfile1D(); Assert.That(() => PlLinesToWaternetConverter.CreateWaternetBasedOnPlLines(null, soilProfile1D, null, 0, 0, 0, IntrusionVerticalWaterPressureType.Standard), Throws.InstanceOf().With.Message.EqualTo("Geen object voor pn-lijnen gedefinieerd")); } - + [Test] [SetUICulture("nl-NL")] public void GivenSurfaceLineIsNull_WhenCreatingWaternetBasedOnPlLinesAndOn1DProfile_ThenLanguageNLThrowsException() Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/PlLinesToWaternetConverter.cs =================================================================== diff -u -r4986 -r4988 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/PlLinesToWaternetConverter.cs (.../PlLinesToWaternetConverter.cs) (revision 4986) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/PlLinesToWaternetConverter.cs (.../PlLinesToWaternetConverter.cs) (revision 4988) @@ -86,32 +86,28 @@ plLine = plLines.Lines[PlLineType.Pl2]; headLine = CreateLine(plLine, headLine2Name); - if (headLine != null && !IsBelowSoilProfile(soilProfile1D, plLine)) + if (headLine != null && !IsBelowSoilProfile(soilProfile1D, plLine) && soilProfile1D.BottomAquiferLayer != null && + pressureType == IntrusionVerticalWaterPressureType.SemiTimeDependent && penetrationLength > 0) { waternet.HeadLineList.Add(headLine); - if (soilProfile1D.BottomAquiferLayer != null && pressureType == IntrusionVerticalWaterPressureType.SemiTimeDependent && penetrationLength > 0) - { - double level = soilProfile1D.BottomAquiferLayer.TopLevel + penetrationLength; - WaternetLine waternetLine = CreateWaternetLine(level, xLeft, xRight); - waternetLine.Name = waternetLine2Name; - waternetLine.HeadLine = headLine; - waternet.WaternetLineList.Add(waternetLine); - } + double level = soilProfile1D.BottomAquiferLayer.TopLevel + penetrationLength; + WaternetLine waternetLine = CreateWaternetLine(level, xLeft, xRight); + waternetLine.Name = waternetLine2Name; + waternetLine.HeadLine = headLine; + waternet.WaternetLineList.Add(waternetLine); } plLine = plLines.Lines[PlLineType.Pl3]; headLine = CreateLine(plLine, headLine3Name); - if (headLine != null && !IsBelowSoilProfile(soilProfile1D, plLine)) + if (headLine != null && !IsBelowSoilProfile(soilProfile1D, plLine) && soilProfile1D.BottomAquiferLayer != null && + pressureType != IntrusionVerticalWaterPressureType.FullHydroStatic) { waternet.HeadLineList.Add(headLine); - if (soilProfile1D.BottomAquiferLayer != null && pressureType != IntrusionVerticalWaterPressureType.FullHydroStatic) - { - double level = soilProfile1D.BottomAquiferLayer.TopLevel; - WaternetLine waternetLine = CreateWaternetLine(level, xLeft, xRight); - waternetLine.Name = waternetLine3Name; - waternetLine.HeadLine = headLine; - waternet.WaternetLineList.Add(waternetLine); - } + double level = soilProfile1D.BottomAquiferLayer.TopLevel; + WaternetLine waternetLine = CreateWaternetLine(level, xLeft, xRight); + waternetLine.Name = waternetLine3Name; + waternetLine.HeadLine = headLine; + waternet.WaternetLineList.Add(waternetLine); } CreateWaternetLinesForInBetweenAquifers(waternet, soilProfile1D, xLeft, xRight, plLines.Lines[PlLineType.Pl4], pressureType); @@ -151,33 +147,26 @@ } plLine = plLines.Lines[PlLineType.Pl2]; - if (plLine != null) - { - var headLine = CreateLine(plLine, headLine2Name); - waternet.HeadLineList.Add(headLine); - - if (bottomAquiferCoordinates.Any() && pressureType == IntrusionVerticalWaterPressureType.SemiTimeDependent && penetrationLength > 0) + if (plLine != null && bottomAquiferCoordinates.Any() && pressureType == IntrusionVerticalWaterPressureType.SemiTimeDependent && penetrationLength > 0) { + var headLine = CreateLine(plLine, headLine2Name); + waternet.HeadLineList.Add(headLine); WaternetLine waternetLine = CreateWaternetLine(bottomAquiferCoordinates, penetrationLength); waternetLine.Name = waternetLine2Name; waternetLine.HeadLine = headLine; waternet.WaternetLineList.Add(waternetLine); - } } plLine = plLines.Lines[PlLineType.Pl3]; - if (plLine != null) - { - var headLine = CreateLine(plLine, headLine3Name); - waternet.HeadLineList.Add(headLine); - - if (bottomAquiferCoordinates.Any() && pressureType != IntrusionVerticalWaterPressureType.FullHydroStatic) + if (plLine != null && bottomAquiferCoordinates.Any() && pressureType != IntrusionVerticalWaterPressureType.FullHydroStatic) { + var headLine = CreateLine(plLine, headLine3Name); + waternet.HeadLineList.Add(headLine); + WaternetLine waternetLine = CreateWaternetLine(bottomAquiferCoordinates); waternetLine.HeadLine = headLine; waternetLine.Name = waternetLine3Name; waternet.WaternetLineList.Add(waternetLine); - } } CreateWaternetLinesForInBetweenAquifers(waternet, soilProfile, plLines.Lines[PlLineType.Pl4], pressureType); @@ -215,13 +204,13 @@ { return; } - - waternet.HeadLineList.Add(headLine); + if (soilProfile1D.GetInBetweenAquiferClusters == null || pressureType == IntrusionVerticalWaterPressureType.FullHydroStatic) { return; } + waternet.HeadLineList.Add(headLine); var number = 0; foreach ((SoilLayer1D, SoilLayer1D) inBetweenAquiferCluster in soilProfile1D.GetInBetweenAquiferClusters.Where(layer => layer is { Item1: not null, Item2: not null })) { @@ -243,9 +232,6 @@ return; } - var headLine = CreateLine(plLine4, headLine4Name); - waternet.HeadLineList.Add(headLine); - if (pressureType == IntrusionVerticalWaterPressureType.FullHydroStatic) { return; @@ -256,6 +242,8 @@ return; } + var headLine = CreateLine(plLine4, headLine4Name); + waternet.HeadLineList.Add(headLine); for (var i = 0; i < inBetweenAquiferCount; i++) { Point2D[] inBetweenAquiferUpperCoordinates = DetermineLayerBoundaryPoints(LayerType.TopLayerInBetweenAquiferCluster, soilProfile, i).ToArray();