// Copyright (C) Stichting Deltares 2021. 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 System.Collections.Generic; using System.Data; using System.Linq; using Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.General.PlLines; using Deltares.DamEngine.Calculators.KernelWrappers.MacroStabilityCommon; using Deltares.DamEngine.Data.Geometry; using Deltares.DamEngine.Data.Geotechnics; using NUnit.Framework; namespace Deltares.DamEngine.Calculators.Tests.KernelWrappers.MacroStabilityCommon { public class PlLinesToWaternetConverterTests { [Test] [TestCase(0)] [TestCase(0.01)] [TestCase(10)] public void ConvertPlLineToWaternet_PlLinesFullyDefinedAtOrBelowSoil1DProfile_ReturnsExpectedWaternet(double offsetFromBottomOfProfile) { // Setup var random = new Random(21); double leftCoordinate = random.NextDouble(); double rightCoordinate = leftCoordinate + 1; var penetrationLength = random.NextDouble(); SoilProfile1D soilProfile = CreateSoilProfile1DForTest(); double bottomLevel = soilProfile.BottomLevel; double plLineZCoordinate = bottomLevel - offsetFromBottomOfProfile; var plLines = new PlLines(); PlLine plLine = plLines.Lines[PlLineType.Pl1]; plLine.Points.Add(new PlLinePoint(leftCoordinate, plLineZCoordinate)); plLine.Points.Add(new PlLinePoint(rightCoordinate, plLineZCoordinate)); plLine = plLines.Lines[PlLineType.Pl2]; plLine.Points.Add(new PlLinePoint(leftCoordinate, plLineZCoordinate)); plLine.Points.Add(new PlLinePoint(rightCoordinate, plLineZCoordinate)); plLine = plLines.Lines[PlLineType.Pl3]; plLine.Points.Add(new PlLinePoint(leftCoordinate, plLineZCoordinate)); plLine.Points.Add(new PlLinePoint(rightCoordinate, plLineZCoordinate)); plLine = plLines.Lines[PlLineType.Pl4]; plLine.Points.Add(new PlLinePoint(leftCoordinate, plLineZCoordinate)); plLine.Points.Add(new PlLinePoint(rightCoordinate, plLineZCoordinate)); // Call var waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile, penetrationLength, leftCoordinate, rightCoordinate); // Assert Assert.IsNull(waternet.PhreaticLine); CollectionAssert.IsEmpty(waternet.HeadLineList); CollectionAssert.IsEmpty(waternet.WaternetLineList); } [Test] public void TestConvertPlLinesToWaternet() { const double cDif = 0.0001; var plLines = CreatePlLinesForTest(); var soilProfile1D = CreateSoilProfile1DForTest(); Assert.AreEqual(-2.111, soilProfile1D.InBetweenAquiferLayer.TopLevel, cDif); Assert.AreEqual(-6.111, soilProfile1D.BottomAquiferLayer.TopLevel, cDif); const double penetrationLength = 2.1; const double left = 0; const double right = 100; var waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile1D, penetrationLength, left, right); // Pl 1 is only the phreatic line, a headline or waternetline does not have to be created // Pl 2 gets waternetline to level of BottomAquiferLayer.TopLevel + penetrationLength // Pl 3 gets waternetline to level of InBetweenAquiferLayer.TopLevel // Pl 4 gets waternetline to level of BottomAquiferLayer.TopLevel // ex[ected phreatic line from pl 1 Assert.AreEqual(3, waternet.PhreaticLine.Points.Count); Assert.AreEqual(0, waternet.PhreaticLine.Points[0].X, cDif); Assert.AreEqual(0, waternet.PhreaticLine.Points[0].Z, cDif); Assert.AreEqual(50, waternet.PhreaticLine.Points[1].X, cDif); Assert.AreEqual(1, waternet.PhreaticLine.Points[1].Z, cDif); Assert.AreEqual(100, waternet.PhreaticLine.Points[2].X, cDif); Assert.AreEqual(1, waternet.PhreaticLine.Points[2].Z, cDif); // expected head lines from pl 2, 3 and 4 Assert.AreEqual(3, waternet.HeadLineList.Count); Assert.AreEqual(2, waternet.HeadLineList[0].Points.Count); Assert.AreEqual(3, waternet.HeadLineList[1].Points.Count); Assert.AreEqual(2, waternet.HeadLineList[2].Points.Count); // check the points of first head line that represents pl 2 Assert.AreEqual(0, waternet.HeadLineList[0].Points[0].X, cDif); Assert.AreEqual(0, waternet.HeadLineList[0].Points[0].Z, cDif); Assert.AreEqual(100, waternet.HeadLineList[0].Points[1].X, cDif); Assert.AreEqual(-1, waternet.HeadLineList[0].Points[1].Z, cDif); // expected waternet lines from pl 2, 3 and 4 Assert.AreEqual(3, waternet.WaternetLineList.Count); // expected waternet line 0 is connected to pl2 with level -6.111 + 2.1 = -4.011 Assert.AreEqual(waternet.HeadLineList[0], waternet.WaternetLineList[0].HeadLine); Assert.AreEqual(0, waternet.WaternetLineList[0].Points[0].X, cDif); Assert.AreEqual(-4.011, waternet.WaternetLineList[0].Points[0].Z, cDif); Assert.AreEqual(100, waternet.WaternetLineList[0].Points[1].X, cDif); Assert.AreEqual(-4.011, waternet.WaternetLineList[0].Points[1].Z, cDif); // expected waternet line 1 is connected to pl3 with level -6.111 Assert.AreEqual(waternet.HeadLineList[1], waternet.WaternetLineList[1].HeadLine); Assert.AreEqual(-6.111, waternet.WaternetLineList[1].Points[0].Z, cDif); // expected waternet line 2 is connected to pl4 with level -2.111 Assert.AreEqual(waternet.HeadLineList[2], waternet.WaternetLineList[2].HeadLine); Assert.AreEqual(-2.111, waternet.WaternetLineList[2].Points[0].Z, cDif); } [Test] public void TestConvertPlLinesToWaternetWhenNoHeadLinesExpected() { var plLines = CreatePlLinesForTest(); var soilProfile1D = CreateSoilProfile1DForTest(); var waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile1D, 0, 0, 0); // head lines Assert.AreEqual(3, waternet.HeadLineList.Count); Assert.AreEqual(2, waternet.HeadLineList[0].Points.Count); Assert.AreEqual(3, waternet.HeadLineList[1].Points.Count); Assert.AreEqual(2, waternet.HeadLineList[2].Points.Count); // phreatic line Assert.AreEqual(3, waternet.PhreaticLine.Points.Count); // 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.ConvertPlLineToWaternet(plLines, soilProfile1D, 0, 0, 0); // head lines Assert.AreEqual(1, waternet.HeadLineList.Count); Assert.AreEqual(2, waternet.HeadLineList[0].Points.Count); // phreatic line Assert.AreEqual(3, waternet.PhreaticLine.Points.Count); } [Test] public void TestConvertPlLinesToWaternetWhenNoWaternetLinesExpected() { const double cDif = 0.0001; var plLines = CreatePlLinesForTest(); var soilProfile1D = CreateSoilProfile1DForTest(); const double penetrationLength = 2.1; var waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile1D, penetrationLength, 0, 0); Assert.AreEqual(3, waternet.HeadLineList.Count); Assert.AreEqual(3, waternet.WaternetLineList.Count); // check that no waternetlines are added for pl3 when InBetweenAquiferLayer is null soilProfile1D = CreateSoilProfile1DWith1AquiferForTest(); waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile1D, penetrationLength, 0, 0); Assert.AreEqual(3, waternet.HeadLineList.Count); Assert.AreEqual(2, waternet.WaternetLineList.Count); // expected waternet line 0 is connected to pl2 with level -6.111 + 2.1 = -4.011 Assert.AreEqual(waternet.HeadLineList[0], waternet.WaternetLineList[0].HeadLine); Assert.AreEqual(-4.011, waternet.WaternetLineList[0].Points[0].Z, cDif); // expected waternet line 1 is connected to pl3 with level -6.111 Assert.AreEqual(waternet.HeadLineList[1], waternet.WaternetLineList[1].HeadLine); Assert.AreEqual(-6.111, waternet.WaternetLineList[1].Points[0].Z, cDif); // check that no waternetlines are added for pl2, pl3 and pl4 when BottomAquiferLayer is null soilProfile1D = CreateSoilProfile1DWithoutAquifersForTest(); waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile1D, penetrationLength, 0, 0); Assert.AreEqual(3, waternet.HeadLineList.Count); Assert.AreEqual(0, waternet.WaternetLineList.Count); } [Test] public void TestConvertLevelToWaternetLine() { const double cDif = 0.0001; const double level = 1.234; const double left = -50.111; const double right = 50.123; var waternetLine = PlLinesToWaternetConverter.CreateWaternetLine(level, left, right); Assert.AreEqual(2, waternetLine.Points.Count); Assert.AreEqual(-50.111, waternetLine.Points[0].X, cDif); Assert.AreEqual(1.234, waternetLine.Points[0].Z, cDif); Assert.AreEqual(50.123, waternetLine.Points[1].X, cDif); Assert.AreEqual(1.234, waternetLine.Points[1].Z, cDif); } [Test] [TestCaseSource(nameof(GetSoilProfilesWithContinuousBottomAquiferLayer))] public void ConvertPlLineToWaternet_ValidPLLinesAndSoilProfile2DWithContinuousAquiferLayers_ReturnsExpectedWaternet( SoilProfile2D soilProfile, IEnumerable expectedBottomAquiferCoordinates) { // Setup var random = new Random(21); double leftCoordinate = soilProfile.Geometry.Left; double rightCoordinate = soilProfile.Geometry.Right; double penetrationLength = random.NextDouble(); var plLines = new PlLines(); PlLine plLine = plLines.Lines[PlLineType.Pl1]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -5)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -5)); plLine = plLines.Lines[PlLineType.Pl2]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -6)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -6)); plLine = plLines.Lines[PlLineType.Pl3]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -7)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -7)); plLine = plLines.Lines[PlLineType.Pl4]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -8)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -8)); // Call Waternet waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile, penetrationLength); // Assert AssertGeometry(plLines.Lines[PlLineType.Pl1].Points, waternet.PhreaticLine.Points); Assert.AreEqual(3, waternet.HeadLineList.Count); 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.AreEqual(2, waternet.WaternetLineList.Count); WaternetLine pl2WaternetLine = waternet.WaternetLineList[0]; Assert.AreSame(waternet.HeadLineList[0], pl2WaternetLine.HeadLine); var offSetAquiferCoordinates = expectedBottomAquiferCoordinates.Select(aquiferCoordinate => new GeometryPoint(aquiferCoordinate.X, aquiferCoordinate.Z + penetrationLength)) .ToArray(); AssertGeometry(offSetAquiferCoordinates, pl2WaternetLine.Points); WaternetLine pl3WaternetLine = waternet.WaternetLineList[1]; Assert.AreSame(waternet.HeadLineList[1], pl3WaternetLine.HeadLine); AssertGeometry(expectedBottomAquiferCoordinates, pl3WaternetLine.Points); } /// /// ------------------------------------------------------------- /// top layer /// ------------------------------------------------------------- /// inbetween aquifer layer left | inbetween aquifer layer right /// ------------------------------------------------------------- /// inbetween layer /// ------------------------------------------------------------- /// bottom aquifer layer /// [Test] public void ConvertPlLineToWaternet_ValidPLLinesAndSoilProfile2DWithContinuousInBetweenAquiferLayerConsistOfTwoParts_ReturnsExpectedWaternet() { // Setup var random = new Random(21); double leftCoordinate = random.NextDouble(); double rightCoordinate = leftCoordinate + 1; double penetrationLength = random.NextDouble(); var topLeftUpperLayer = new Point2D(leftCoordinate, 0); var topRightUpperLayer = new Point2D(rightCoordinate, 0); var bottomRightUpperLayer = new Point2D(rightCoordinate, -10); var bottomLeftUpperLayer = new Point2D(leftCoordinate, -10); SoilLayer2D soilLayer = CreateSoilLayer2D(topLeftUpperLayer, topRightUpperLayer, bottomRightUpperLayer, bottomLeftUpperLayer); var topRightInBetweenAquiferLayerLeft = new Point2D(rightCoordinate / 2, -10); var bottomRightInBetweenAquiferLayerLeft = new Point2D(rightCoordinate / 2, -20); var bottomLeftInBetweenAquiferLayerLeft = new Point2D(leftCoordinate, -20); SoilLayer2D soilLayerAquiferInBetweenLeft = CreateSoilLayer2D(bottomLeftUpperLayer, topRightInBetweenAquiferLayerLeft, bottomRightInBetweenAquiferLayerLeft, bottomLeftInBetweenAquiferLayerLeft); soilLayerAquiferInBetweenLeft.IsAquifer = true; var topRightInBetweenAquiferLayerRight = new Point2D(rightCoordinate, -10); var bottomRightInBetweenAquiferLayerRight = new Point2D(rightCoordinate, -20); SoilLayer2D soilLayerAquiferInBetweenRight = CreateSoilLayer2D(topRightInBetweenAquiferLayerLeft, topRightInBetweenAquiferLayerRight, bottomRightInBetweenAquiferLayerRight, bottomLeftInBetweenAquiferLayerLeft); soilLayerAquiferInBetweenRight.IsAquifer = true; var topRightInBetweenLayer = new Point2D(rightCoordinate, -20); var bottomRightInBetweenLayer = new Point2D(rightCoordinate, -25); var bottomLeftInBetweenLayer = new Point2D(leftCoordinate, -25); SoilLayer2D soilLayerInBetween = CreateSoilLayer2D(bottomLeftInBetweenAquiferLayerLeft, topRightInBetweenLayer, bottomRightInBetweenLayer, bottomLeftInBetweenLayer); var topRightBottomAquiferLayer = new Point2D(rightCoordinate, -25); var bottomRightBottomAquiferLayer = new Point2D(rightCoordinate, -30); var bottomLeftBottomAquiferLayer = new Point2D(leftCoordinate, -30); SoilLayer2D soilLayerAquiferBottom = CreateSoilLayer2D(bottomLeftInBetweenLayer, topRightBottomAquiferLayer, bottomRightBottomAquiferLayer, bottomLeftBottomAquiferLayer); soilLayerAquiferBottom.IsAquifer = true; var soilProfile = new SoilProfile2D { Geometry = new GeometryData { Left = leftCoordinate, Right = rightCoordinate, Bottom = -20 } }; soilProfile.Surfaces.Add(soilLayer); soilProfile.Surfaces.Add(soilLayerAquiferInBetweenLeft); soilProfile.Surfaces.Add(soilLayerAquiferInBetweenRight); soilProfile.Surfaces.Add(soilLayerInBetween); soilProfile.Surfaces.Add(soilLayerAquiferBottom); var plLines = new PlLines(); PlLine plLine = plLines.Lines[PlLineType.Pl1]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -5)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -5)); plLine = plLines.Lines[PlLineType.Pl2]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -6)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -6)); plLine = plLines.Lines[PlLineType.Pl3]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -7)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -7)); plLine = plLines.Lines[PlLineType.Pl4]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -8)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -8)); // Call Waternet waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile, penetrationLength); // Assert AssertGeometry(plLines.Lines[PlLineType.Pl1].Points, waternet.PhreaticLine.Points); Assert.AreEqual(3, waternet.HeadLineList.Count); 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.AreEqual(3, waternet.WaternetLineList.Count); var expectedBottomAquiferCoordinates = new [] { bottomLeftInBetweenLayer, new Point2D(rightCoordinate / 2, -25), topRightBottomAquiferLayer }; WaternetLine pl2WaternetLine = waternet.WaternetLineList[0]; Assert.AreSame(waternet.HeadLineList[0], pl2WaternetLine.HeadLine); var offSetAquiferCoordinates = expectedBottomAquiferCoordinates.Select(aquiferCoordinate => new GeometryPoint(aquiferCoordinate.X, aquiferCoordinate.Z + penetrationLength)) .ToArray(); AssertGeometry(offSetAquiferCoordinates, pl2WaternetLine.Points); WaternetLine pl3WaternetLine = waternet.WaternetLineList[1]; Assert.AreSame(waternet.HeadLineList[1], pl3WaternetLine.HeadLine); AssertGeometry(expectedBottomAquiferCoordinates, pl3WaternetLine.Points); WaternetLine pl4WaternetLine = waternet.WaternetLineList[2]; Assert.AreSame(waternet.HeadLineList[2], pl4WaternetLine.HeadLine); AssertGeometry(new[] { bottomLeftUpperLayer, topRightInBetweenAquiferLayerLeft, topRightInBetweenAquiferLayerRight }, pl4WaternetLine.Points); } /// /// --------------------------------------------------- /// top layer /// --------------------------------------------------- /// inbetween aquifer layer /// --------------------------------------------------- /// inbetween layer /// --------------------------------------------------- /// bottom aquifer layer /// [Test] public void ConvertPlLineToWaternet_ValidPLLinesAndSoilProfile2DWithContinuousInBetweenAquiferLayerConsistOfOnePart_ReturnsExpectedWaternet() { // Setup var random = new Random(21); double leftCoordinate = random.NextDouble(); double rightCoordinate = leftCoordinate + 1; double penetrationLength = random.NextDouble(); var topLeftUpperLayer = new Point2D(leftCoordinate, 0); var topRightUpperLayer = new Point2D(rightCoordinate, 0); var bottomRightUpperLayer = new Point2D(rightCoordinate, -10); var bottomLeftUpperLayer = new Point2D(leftCoordinate, -10); SoilLayer2D soilLayer = CreateSoilLayer2D(topLeftUpperLayer, topRightUpperLayer, bottomRightUpperLayer, bottomLeftUpperLayer); var bottomRightInBetweenAquiferLayer = new Point2D(rightCoordinate, -20); var bottomLeftInBetweenAquiferLayer = new Point2D(leftCoordinate, -20); SoilLayer2D soilLayerAquiferInBetween = CreateSoilLayer2D(bottomLeftUpperLayer, bottomRightUpperLayer, bottomRightInBetweenAquiferLayer, bottomLeftInBetweenAquiferLayer); soilLayerAquiferInBetween.IsAquifer = true; var topRightInBetweenLayer = new Point2D(rightCoordinate, -20); var bottomRightInBetweenLayer = new Point2D(rightCoordinate, -25); var bottomLeftInBetweenLayer = new Point2D(leftCoordinate, -25); SoilLayer2D soilLayerInBetween = CreateSoilLayer2D(bottomLeftInBetweenAquiferLayer, topRightInBetweenLayer, bottomRightInBetweenLayer, bottomLeftInBetweenLayer); var bottomRightBottomAquiferLayer = new Point2D(rightCoordinate, -30); var bottomleftBottomAquiferLayer = new Point2D(leftCoordinate, -30); SoilLayer2D soilLayerAquiferBottom = CreateSoilLayer2D(bottomLeftInBetweenLayer, bottomRightInBetweenLayer, bottomRightBottomAquiferLayer, bottomleftBottomAquiferLayer); soilLayerAquiferBottom.IsAquifer = true; var soilProfile = new SoilProfile2D { Geometry = new GeometryData { Left = leftCoordinate, Right = rightCoordinate, Bottom = -20 } }; soilProfile.Surfaces.Add(soilLayer); soilProfile.Surfaces.Add(soilLayerAquiferInBetween); soilProfile.Surfaces.Add(soilLayerInBetween); soilProfile.Surfaces.Add(soilLayerAquiferBottom); var plLines = new PlLines(); PlLine plLine = plLines.Lines[PlLineType.Pl1]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -5)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -5)); plLine = plLines.Lines[PlLineType.Pl2]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -6)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -6)); plLine = plLines.Lines[PlLineType.Pl3]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -7)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -7)); plLine = plLines.Lines[PlLineType.Pl4]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -8)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -8)); // Call Waternet waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile, penetrationLength); // Assert AssertGeometry(plLines.Lines[PlLineType.Pl1].Points, waternet.PhreaticLine.Points); Assert.AreEqual(3, waternet.HeadLineList.Count); 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.AreEqual(3, waternet.WaternetLineList.Count); var expectedBottomAquiferCoordinates = new[] { bottomLeftInBetweenLayer, bottomRightInBetweenLayer }; WaternetLine pl2WaternetLine = waternet.WaternetLineList[0]; Assert.AreSame(waternet.HeadLineList[0], pl2WaternetLine.HeadLine); var offSetAquiferCoordinates = expectedBottomAquiferCoordinates.Select(aquiferCoordinate => new GeometryPoint(aquiferCoordinate.X, aquiferCoordinate.Z + penetrationLength)) .ToArray(); AssertGeometry(offSetAquiferCoordinates, pl2WaternetLine.Points); WaternetLine pl3WaternetLine = waternet.WaternetLineList[1]; Assert.AreSame(waternet.HeadLineList[1], pl3WaternetLine.HeadLine); AssertGeometry(expectedBottomAquiferCoordinates, pl3WaternetLine.Points); WaternetLine pl4WaternetLine = waternet.WaternetLineList[2]; Assert.AreSame(waternet.HeadLineList[2], pl4WaternetLine.HeadLine); AssertGeometry(new[] { bottomLeftUpperLayer, bottomRightUpperLayer }, pl4WaternetLine.Points); } /// /// ------------------------------------------------------------- /// top layer /// ------------------------------------------------------------- /// inbetween aquifer layer left | Gap layer /// |------------------------------- /// | /// | Inbetween aquifer layer right /// -----------------------------| /// inbetween layer | /// |------------------------------- /// /// ------------------------------------------------------------- /// bottom aquifer layer /// [Test] public void ConvertPlLineToWaternet_ValidPLLinesAndSoilProfile2DWithContinuousInBetweenAquiferLayerRightLayerTopLevelInRangeLeftLayer_ReturnsExpectedWaternet() { // Setup var random = new Random(21); double leftCoordinate = random.NextDouble(); double rightCoordinate = leftCoordinate + 1; double penetrationLength = random.NextDouble(); var topLeftUpperLayer = new Point2D(leftCoordinate, 0); var topRightUpperLayer = new Point2D(rightCoordinate, 0); var bottomRightUpperLayer = new Point2D(rightCoordinate, -10); var bottomLeftUpperLayer = new Point2D(leftCoordinate, -10); SoilLayer2D soilLayer = CreateSoilLayer2D(topLeftUpperLayer, topRightUpperLayer, bottomRightUpperLayer, bottomLeftUpperLayer); var topRightInBetweenAquiferLayerLeft = new Point2D(rightCoordinate / 2, -10); var bottomRightInBetweenAquiferLayerLeft = new Point2D(rightCoordinate / 2, -20); var bottomLeftInBetweenAquiferLayerLeft = new Point2D(leftCoordinate, -20); SoilLayer2D soilLayerAquiferInBetweenLeft = CreateSoilLayer2D(bottomLeftUpperLayer, topRightInBetweenAquiferLayerLeft, bottomRightInBetweenAquiferLayerLeft, bottomLeftInBetweenAquiferLayerLeft); soilLayerAquiferInBetweenLeft.IsAquifer = true; // Add a layer to fill the gap between the right aquiferlayer and the upper layer var bottomRightGapLayer = new Point2D(rightCoordinate, -15); var bottomLeftGapLayer = new Point2D(rightCoordinate / 2, -15); SoilLayer2D soilLayerGap = CreateSoilLayer2D(topRightInBetweenAquiferLayerLeft, bottomRightUpperLayer, bottomRightGapLayer, bottomLeftGapLayer); var bottomRightInBetweenAquiferLayerRight = new Point2D(rightCoordinate, -21); var bottomLeftInBetweenAquiferLayerRight = new Point2D(rightCoordinate / 2, -21); SoilLayer2D soilLayerAquiferInBetweenRight = CreateSoilLayer2D(bottomLeftGapLayer, bottomRightGapLayer, bottomRightInBetweenAquiferLayerRight, bottomLeftInBetweenAquiferLayerRight); soilLayerAquiferInBetweenRight.IsAquifer = true; var bottomRightInBetweenLayer = new Point2D(rightCoordinate, -25); var bottomLeftInBetweenLayer = new Point2D(leftCoordinate, -25); var soilLayerInBetween = new SoilLayer2D { GeometrySurface = new GeometrySurface { OuterLoop = new GeometryLoop { CurveList = { new GeometryCurve(bottomLeftInBetweenAquiferLayerLeft, bottomRightInBetweenAquiferLayerLeft), new GeometryCurve(bottomRightInBetweenAquiferLayerLeft, bottomLeftInBetweenAquiferLayerRight), new GeometryCurve(bottomLeftInBetweenAquiferLayerRight, bottomRightInBetweenAquiferLayerRight), new GeometryCurve(bottomRightInBetweenAquiferLayerRight, bottomRightInBetweenLayer), new GeometryCurve(bottomRightInBetweenLayer, bottomLeftInBetweenLayer) } } } }; var topRightBottomAquiferLayer = new Point2D(rightCoordinate, -25); var bottomRightBottomAquiferLayer = new Point2D(rightCoordinate, -30); var bottomLeftBottomAquiferLayer = new Point2D(leftCoordinate, -30); SoilLayer2D soilLayerAquiferBottom = CreateSoilLayer2D(bottomLeftInBetweenLayer, topRightBottomAquiferLayer, bottomRightBottomAquiferLayer, bottomLeftBottomAquiferLayer); soilLayerAquiferBottom.IsAquifer = true; var soilProfile = new SoilProfile2D { Geometry = new GeometryData { Left = leftCoordinate, Right = rightCoordinate, Bottom = -20 } }; soilProfile.Surfaces.Add(soilLayer); soilProfile.Surfaces.Add(soilLayerAquiferInBetweenLeft); soilProfile.Surfaces.Add(soilLayerGap); soilProfile.Surfaces.Add(soilLayerAquiferInBetweenRight); soilProfile.Surfaces.Add(soilLayerInBetween); soilProfile.Surfaces.Add(soilLayerAquiferBottom); var plLines = new PlLines(); PlLine plLine = plLines.Lines[PlLineType.Pl1]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -5)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -5)); plLine = plLines.Lines[PlLineType.Pl2]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -6)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -6)); plLine = plLines.Lines[PlLineType.Pl3]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -7)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -7)); plLine = plLines.Lines[PlLineType.Pl4]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -8)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -8)); // Call Waternet waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile, penetrationLength); // Assert AssertGeometry(plLines.Lines[PlLineType.Pl1].Points, waternet.PhreaticLine.Points); Assert.AreEqual(3, waternet.HeadLineList.Count); 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.AreEqual(3, waternet.WaternetLineList.Count); var expectedBottomAquiferCoordinates = new[] { bottomLeftInBetweenLayer, new Point2D(rightCoordinate / 2, -25), bottomRightInBetweenLayer }; WaternetLine pl2WaternetLine = waternet.WaternetLineList[0]; Assert.AreSame(waternet.HeadLineList[0], pl2WaternetLine.HeadLine); var offSetAquiferCoordinates = expectedBottomAquiferCoordinates.Select(aquiferCoordinate => new GeometryPoint(aquiferCoordinate.X, aquiferCoordinate.Z + penetrationLength)) .ToArray(); AssertGeometry(offSetAquiferCoordinates, pl2WaternetLine.Points); WaternetLine pl3WaternetLine = waternet.WaternetLineList[1]; Assert.AreSame(waternet.HeadLineList[1], pl3WaternetLine.HeadLine); AssertGeometry(expectedBottomAquiferCoordinates, pl3WaternetLine.Points); WaternetLine pl4WaternetLine = waternet.WaternetLineList[2]; Assert.AreSame(waternet.HeadLineList[2], pl4WaternetLine.HeadLine); AssertGeometry(new[] { new GeometryPoint(leftCoordinate, -10), new GeometryPoint(rightCoordinate / 2, -10), new GeometryPoint(rightCoordinate, -15) }, pl4WaternetLine.Points); } /// /// ------------------------------------------------------------- /// top layer /// |------------------------------- /// | /// | Inbetween aquifer layer right /// -----------------------------| /// inbetween aquifer layer left | /// |------------------------------- /// | /// | /// -----------------------------| /// inbetween layer /// ------------------------------------------------------------- /// bottom aquifer layer /// [Test] public void ConvertPlLineToWaternet_ValidPLLinesAndSoilProfile2DWithContinuousInBetweenAquiferLayerRightLayerBottomLevelInRangeLeftLayer_ReturnsExpectedWaternet() { // Setup var random = new Random(21); double leftCoordinate = random.NextDouble(); double rightCoordinate = leftCoordinate + 1; double penetrationLength = random.NextDouble(); var topLeftUpperLayer = new Point2D(leftCoordinate, 0); var topRightUpperLayer = new Point2D(rightCoordinate, 0); var bottomRightUpperLayer = new Point2D(rightCoordinate, -5); var bottomIntermediateUpperUpperLayer = new Point2D(rightCoordinate / 2, -5); var bottomIntermediateLowerUpperLayer = new Point2D(rightCoordinate / 2, -10); var bottomLeftUpperLayer = new Point2D(leftCoordinate, -10); var soilLayer = new SoilLayer2D { GeometrySurface = new GeometrySurface { OuterLoop = new GeometryLoop { CurveList = { new GeometryCurve(topLeftUpperLayer, topRightUpperLayer), new GeometryCurve(topRightUpperLayer, bottomRightUpperLayer), new GeometryCurve(bottomRightUpperLayer, bottomIntermediateUpperUpperLayer), new GeometryCurve(bottomIntermediateUpperUpperLayer, bottomIntermediateLowerUpperLayer), new GeometryCurve(bottomIntermediateLowerUpperLayer, bottomLeftUpperLayer), new GeometryCurve(bottomLeftUpperLayer, topLeftUpperLayer) } } } }; var bottomRightInBetweenAquiferLayerLeft = new Point2D(rightCoordinate / 2, -20); var bottomLeftInBetweenAquiferLayerLeft = new Point2D(leftCoordinate, -20); SoilLayer2D soilLayerAquiferInBetweenLeft = CreateSoilLayer2D(bottomLeftUpperLayer, bottomIntermediateLowerUpperLayer, bottomRightInBetweenAquiferLayerLeft, bottomLeftInBetweenAquiferLayerLeft); soilLayerAquiferInBetweenLeft.IsAquifer = true; var bottomRightInBetweenAquiferLayerRight = new Point2D(rightCoordinate, -20); var bottomLeftInBetweenAquiferLayerRight = new Point2D(rightCoordinate / 2, -20); SoilLayer2D soilLayerAquiferInBetweenRight = CreateSoilLayer2D(bottomIntermediateUpperUpperLayer, bottomRightUpperLayer, bottomRightInBetweenAquiferLayerRight, bottomLeftInBetweenAquiferLayerRight); soilLayerAquiferInBetweenRight.IsAquifer = true; var bottomRightInBetweenLayer = new Point2D(rightCoordinate, -25); var bottomLeftInBetweenLayer = new Point2D(leftCoordinate, -25); SoilLayer2D soilLayerInBetween = CreateSoilLayer2D(bottomLeftInBetweenAquiferLayerLeft, bottomRightInBetweenAquiferLayerRight, bottomRightInBetweenLayer, bottomLeftInBetweenLayer); var topRightBottomAquiferLayer = new Point2D(rightCoordinate, -25); var bottomRightBottomAquiferLayer = new Point2D(rightCoordinate, -30); var bottomLeftBottomAquiferLayer = new Point2D(leftCoordinate, -30); SoilLayer2D soilLayerAquiferBottom = CreateSoilLayer2D(bottomLeftInBetweenLayer, topRightBottomAquiferLayer, bottomRightBottomAquiferLayer, bottomLeftBottomAquiferLayer); soilLayerAquiferBottom.IsAquifer = true; var soilProfile = new SoilProfile2D { Geometry = new GeometryData { Left = leftCoordinate, Right = rightCoordinate, Bottom = -20 } }; soilProfile.Surfaces.Add(soilLayer); soilProfile.Surfaces.Add(soilLayerAquiferInBetweenLeft); soilProfile.Surfaces.Add(soilLayerAquiferInBetweenRight); soilProfile.Surfaces.Add(soilLayerInBetween); soilProfile.Surfaces.Add(soilLayerAquiferBottom); var plLines = new PlLines(); PlLine plLine = plLines.Lines[PlLineType.Pl1]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -5)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -5)); plLine = plLines.Lines[PlLineType.Pl2]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -6)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -6)); plLine = plLines.Lines[PlLineType.Pl3]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -7)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -7)); plLine = plLines.Lines[PlLineType.Pl4]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -8)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -8)); // Call Waternet waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile, penetrationLength); // Assert AssertGeometry(plLines.Lines[PlLineType.Pl1].Points, waternet.PhreaticLine.Points); Assert.AreEqual(3, waternet.HeadLineList.Count); 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.AreEqual(3, waternet.WaternetLineList.Count); var expectedBottomAquiferCoordinates = new[] { bottomLeftInBetweenLayer, new Point2D(rightCoordinate / 2, -25), bottomRightInBetweenLayer }; WaternetLine pl2WaternetLine = waternet.WaternetLineList[0]; Assert.AreSame(waternet.HeadLineList[0], pl2WaternetLine.HeadLine); var offSetAquiferCoordinates = expectedBottomAquiferCoordinates.Select(aquiferCoordinate => new GeometryPoint(aquiferCoordinate.X, aquiferCoordinate.Z + penetrationLength)) .ToArray(); AssertGeometry(offSetAquiferCoordinates, pl2WaternetLine.Points); WaternetLine pl3WaternetLine = waternet.WaternetLineList[1]; Assert.AreSame(waternet.HeadLineList[1], pl3WaternetLine.HeadLine); AssertGeometry(expectedBottomAquiferCoordinates, pl3WaternetLine.Points); WaternetLine pl4WaternetLine = waternet.WaternetLineList[2]; Assert.AreSame(waternet.HeadLineList[2], pl4WaternetLine.HeadLine); AssertGeometry(new[] { bottomLeftUpperLayer, bottomIntermediateUpperUpperLayer, bottomRightUpperLayer }, pl4WaternetLine.Points); } /// /// ------------------------------------------------------------- /// top layer /// /// -----------------------------| /// inbetween aquifer layer left | /// |------------------------------- /// | Inbetween aquifer layer right /// | ------------------------------ /// | /// | /// -----------------------------| /// inbetween layer /// ------------------------------------------------------------- /// bottom aquifer layer /// [Test] public void ConvertPlLineToWaternet_ValidPLLinesAndSoilProfile2DWithContinuousInBetweenAquiferLayerRightLayerEnvelopedByLeftLayer_ReturnsExpectedWaternet() { // Setup var random = new Random(21); double leftCoordinate = random.NextDouble(); double rightCoordinate = leftCoordinate + 1; double penetrationLength = random.NextDouble(); var topLeftUpperLayer = new Point2D(leftCoordinate, 0); var topRightUpperLayer = new Point2D(rightCoordinate, 0); var bottomRightUpperLayer = new Point2D(rightCoordinate, -15); var bottomIntermediateLowerUpperLayer = new Point2D(rightCoordinate / 2, -15); var bottomIntermediateUpperUpperLayer = new Point2D(rightCoordinate / 2, -10); var bottomLeftUpperLayer = new Point2D(leftCoordinate, -10); var soilLayer = new SoilLayer2D { GeometrySurface = new GeometrySurface { OuterLoop = new GeometryLoop { CurveList = { new GeometryCurve(topLeftUpperLayer, topRightUpperLayer), new GeometryCurve(topRightUpperLayer, bottomRightUpperLayer), new GeometryCurve(bottomRightUpperLayer, bottomIntermediateLowerUpperLayer), new GeometryCurve(bottomIntermediateLowerUpperLayer, bottomIntermediateUpperUpperLayer), new GeometryCurve(bottomIntermediateUpperUpperLayer, bottomLeftUpperLayer), new GeometryCurve(bottomLeftUpperLayer, topLeftUpperLayer) } } } }; var bottomRightInBetweenAquiferLayerLeft = new Point2D(rightCoordinate / 2, -20); var bottomLeftInBetweenAquiferLayerLeft = new Point2D(leftCoordinate, -20); SoilLayer2D soilLayerAquiferInBetweenLeft = CreateSoilLayer2D(bottomLeftUpperLayer, bottomIntermediateUpperUpperLayer, bottomRightInBetweenAquiferLayerLeft, bottomLeftInBetweenAquiferLayerLeft); soilLayerAquiferInBetweenLeft.IsAquifer = true; var bottomRightInBetweenAquiferLayerRight = new Point2D(rightCoordinate, -17); var bottomLeftInBetweenAquiferLayerRight = new Point2D(rightCoordinate / 2, -17); SoilLayer2D soilLayerAquiferInBetweenRight = CreateSoilLayer2D(bottomIntermediateLowerUpperLayer, bottomRightUpperLayer, bottomRightInBetweenAquiferLayerRight, bottomLeftInBetweenAquiferLayerRight); soilLayerAquiferInBetweenRight.IsAquifer = true; var bottomRightInBetweenLayer = new Point2D(rightCoordinate, -25); var bottomLeftInBetweenLayer = new Point2D(leftCoordinate, -25); var soilLayerInBetween = new SoilLayer2D { GeometrySurface = new GeometrySurface { OuterLoop = new GeometryLoop { CurveList = { new GeometryCurve(bottomLeftInBetweenAquiferLayerLeft, bottomRightInBetweenAquiferLayerLeft), new GeometryCurve(bottomRightInBetweenAquiferLayerLeft, bottomLeftInBetweenAquiferLayerRight), new GeometryCurve(bottomLeftInBetweenAquiferLayerRight, bottomRightInBetweenAquiferLayerRight), new GeometryCurve(bottomRightInBetweenAquiferLayerRight, bottomRightInBetweenLayer), new GeometryCurve(bottomRightInBetweenLayer, bottomLeftInBetweenLayer), new GeometryCurve(bottomLeftInBetweenLayer, bottomLeftInBetweenAquiferLayerLeft) } } } }; var topRightBottomAquiferLayer = new Point2D(rightCoordinate, -25); var bottomRightBottomAquiferLayer = new Point2D(rightCoordinate, -30); var bottomLeftBottomAquiferLayer = new Point2D(leftCoordinate, -30); SoilLayer2D soilLayerAquiferBottom = CreateSoilLayer2D(bottomLeftInBetweenLayer, topRightBottomAquiferLayer, bottomRightBottomAquiferLayer, bottomLeftBottomAquiferLayer); soilLayerAquiferBottom.IsAquifer = true; var soilProfile = new SoilProfile2D { Geometry = new GeometryData { Left = leftCoordinate, Right = rightCoordinate, Bottom = -20 } }; soilProfile.Surfaces.Add(soilLayer); soilProfile.Surfaces.Add(soilLayerAquiferInBetweenLeft); soilProfile.Surfaces.Add(soilLayerAquiferInBetweenRight); soilProfile.Surfaces.Add(soilLayerInBetween); soilProfile.Surfaces.Add(soilLayerAquiferBottom); var plLines = new PlLines(); PlLine plLine = plLines.Lines[PlLineType.Pl1]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -5)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -5)); plLine = plLines.Lines[PlLineType.Pl2]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -6)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -6)); plLine = plLines.Lines[PlLineType.Pl3]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -7)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -7)); plLine = plLines.Lines[PlLineType.Pl4]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -8)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -8)); // Call Waternet waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile, penetrationLength); // Assert AssertGeometry(plLines.Lines[PlLineType.Pl1].Points, waternet.PhreaticLine.Points); Assert.AreEqual(3, waternet.HeadLineList.Count); 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.AreEqual(3, waternet.WaternetLineList.Count); var expectedBottomAquiferCoordinates = new[] { bottomLeftInBetweenLayer, new Point2D(rightCoordinate / 2, -25), bottomRightInBetweenLayer }; WaternetLine pl2WaternetLine = waternet.WaternetLineList[0]; Assert.AreSame(waternet.HeadLineList[0], pl2WaternetLine.HeadLine); var offSetAquiferCoordinates = expectedBottomAquiferCoordinates.Select(aquiferCoordinate => new GeometryPoint(aquiferCoordinate.X, aquiferCoordinate.Z + penetrationLength)) .ToArray(); AssertGeometry(offSetAquiferCoordinates, pl2WaternetLine.Points); WaternetLine pl3WaternetLine = waternet.WaternetLineList[1]; Assert.AreSame(waternet.HeadLineList[1], pl3WaternetLine.HeadLine); AssertGeometry(expectedBottomAquiferCoordinates, pl3WaternetLine.Points); WaternetLine pl4WaternetLine = waternet.WaternetLineList[2]; Assert.AreSame(waternet.HeadLineList[2], pl4WaternetLine.HeadLine); AssertGeometry(new[] { bottomLeftUpperLayer, bottomIntermediateUpperUpperLayer, bottomRightUpperLayer }, pl4WaternetLine.Points); } /// /// ------------------------------------------------------------- /// top layer /// |------------------------------- /// | Inbetween aquifer layer right /// | /// -----------------------------| /// inbetween aquifer layer left | /// | /// -----------------------------| /// inbetween layer | /// |------------------------------- /// /// ------------------------------------------------------------- /// bottom aquifer layer /// [Test] public void ConvertPlLineToWaternet_ValidPLLinesAndSoilProfile2DWithContinuousInBetweenAquiferLayerRightLayerEnvelopesLeftLayer_ReturnsExpectedWaternet() { // Setup var random = new Random(21); double leftCoordinate = random.NextDouble(); double rightCoordinate = leftCoordinate + 1; double penetrationLength = random.NextDouble(); var topLeftUpperLayer = new Point2D(leftCoordinate, 0); var topRightUpperLayer = new Point2D(rightCoordinate, 0); var bottomRightUpperLayer = new Point2D(rightCoordinate, -5); var bottomIntermediateLowerUpperLayer = new Point2D(rightCoordinate / 2, -5); var bottomIntermediateUpperUpperLayer = new Point2D(rightCoordinate / 2, -10); var bottomLeftUpperLayer = new Point2D(leftCoordinate, -10); var soilLayer = new SoilLayer2D { GeometrySurface = new GeometrySurface { OuterLoop = new GeometryLoop { CurveList = { new GeometryCurve(topLeftUpperLayer, topRightUpperLayer), new GeometryCurve(topRightUpperLayer, bottomRightUpperLayer), new GeometryCurve(bottomRightUpperLayer, bottomIntermediateLowerUpperLayer), new GeometryCurve(bottomIntermediateLowerUpperLayer, bottomIntermediateUpperUpperLayer), new GeometryCurve(bottomIntermediateUpperUpperLayer, bottomLeftUpperLayer), new GeometryCurve(bottomLeftUpperLayer, topLeftUpperLayer) } } } }; var bottomRightInBetweenAquiferLayerLeft = new Point2D(rightCoordinate / 2, -20); var bottomLeftInBetweenAquiferLayerLeft = new Point2D(leftCoordinate, -20); SoilLayer2D soilLayerAquiferInBetweenLeft = CreateSoilLayer2D(bottomLeftUpperLayer, bottomIntermediateUpperUpperLayer, bottomRightInBetweenAquiferLayerLeft, bottomLeftInBetweenAquiferLayerLeft); soilLayerAquiferInBetweenLeft.IsAquifer = true; var bottomRightInBetweenAquiferLayerRight = new Point2D(rightCoordinate, -21); var bottomLeftInBetweenAquiferLayerRight = new Point2D(rightCoordinate / 2, -21); SoilLayer2D soilLayerAquiferInBetweenRight = CreateSoilLayer2D(bottomIntermediateLowerUpperLayer, bottomRightUpperLayer, bottomRightInBetweenAquiferLayerRight, bottomLeftInBetweenAquiferLayerRight); soilLayerAquiferInBetweenRight.IsAquifer = true; var bottomRightInBetweenLayer = new Point2D(rightCoordinate, -25); var bottomLeftInBetweenLayer = new Point2D(leftCoordinate, -25); var soilLayerInBetween = new SoilLayer2D { GeometrySurface = new GeometrySurface { OuterLoop = new GeometryLoop { CurveList = { new GeometryCurve(bottomLeftInBetweenAquiferLayerLeft, bottomRightInBetweenAquiferLayerLeft), new GeometryCurve(bottomRightInBetweenAquiferLayerLeft, bottomLeftInBetweenAquiferLayerRight), new GeometryCurve(bottomLeftInBetweenAquiferLayerRight, bottomRightInBetweenAquiferLayerRight), new GeometryCurve(bottomRightInBetweenAquiferLayerRight, bottomRightInBetweenLayer), new GeometryCurve(bottomRightInBetweenLayer, bottomLeftInBetweenLayer), new GeometryCurve(bottomLeftInBetweenLayer, bottomLeftInBetweenAquiferLayerLeft) } } } }; var topRightBottomAquiferLayer = new Point2D(rightCoordinate, -25); var bottomRightBottomAquiferLayer = new Point2D(rightCoordinate, -30); var bottomLeftBottomAquiferLayer = new Point2D(leftCoordinate, -30); SoilLayer2D soilLayerAquiferBottom = CreateSoilLayer2D(bottomLeftInBetweenLayer, topRightBottomAquiferLayer, bottomRightBottomAquiferLayer, bottomLeftBottomAquiferLayer); soilLayerAquiferBottom.IsAquifer = true; var soilProfile = new SoilProfile2D { Geometry = new GeometryData { Left = leftCoordinate, Right = rightCoordinate, Bottom = -20 } }; soilProfile.Surfaces.Add(soilLayer); soilProfile.Surfaces.Add(soilLayerAquiferInBetweenLeft); soilProfile.Surfaces.Add(soilLayerAquiferInBetweenRight); soilProfile.Surfaces.Add(soilLayerInBetween); soilProfile.Surfaces.Add(soilLayerAquiferBottom); var plLines = new PlLines(); PlLine plLine = plLines.Lines[PlLineType.Pl1]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -5)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -5)); plLine = plLines.Lines[PlLineType.Pl2]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -6)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -6)); plLine = plLines.Lines[PlLineType.Pl3]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -7)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -7)); plLine = plLines.Lines[PlLineType.Pl4]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -8)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -8)); // Call Waternet waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile, penetrationLength); // Assert AssertGeometry(plLines.Lines[PlLineType.Pl1].Points, waternet.PhreaticLine.Points); Assert.AreEqual(3, waternet.HeadLineList.Count); 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.AreEqual(3, waternet.WaternetLineList.Count); var expectedBottomAquiferCoordinates = new[] { bottomLeftInBetweenLayer, new Point2D(rightCoordinate / 2, -25), bottomRightInBetweenLayer }; WaternetLine pl2WaternetLine = waternet.WaternetLineList[0]; Assert.AreSame(waternet.HeadLineList[0], pl2WaternetLine.HeadLine); var offSetAquiferCoordinates = expectedBottomAquiferCoordinates.Select(aquiferCoordinate => new GeometryPoint(aquiferCoordinate.X, aquiferCoordinate.Z + penetrationLength)) .ToArray(); AssertGeometry(offSetAquiferCoordinates, pl2WaternetLine.Points); WaternetLine pl3WaternetLine = waternet.WaternetLineList[1]; Assert.AreSame(waternet.HeadLineList[1], pl3WaternetLine.HeadLine); AssertGeometry(expectedBottomAquiferCoordinates, pl3WaternetLine.Points); WaternetLine pl4WaternetLine = waternet.WaternetLineList[2]; Assert.AreSame(waternet.HeadLineList[2], pl4WaternetLine.HeadLine); AssertGeometry(new[] { bottomLeftUpperLayer, bottomIntermediateLowerUpperLayer, bottomRightUpperLayer }, pl4WaternetLine.Points); } [Test] [TestCase(true, false)] [TestCase(false, true)] public void ConvertPlLineToWaternet_ValidPLLinesAndSoilProfile2DWithDiscontinuousInBetweenAquiferLayer_ReturnsExpectedWaternet( bool isLeftInBetweenLayerAquifer, bool isRightInBetweenLayerAquifer) { // Setup var random = new Random(21); double leftCoordinate = random.NextDouble(); double rightCoordinate = leftCoordinate + 1; double penetrationLength = random.NextDouble(); var topLeftUpperLayer = new Point2D(leftCoordinate, 0); var topRightUpperLayer = new Point2D(rightCoordinate, 0); var bottomRightUpperLayer = new Point2D(rightCoordinate, -10); var bottomLeftUpperLayer = new Point2D(leftCoordinate, -10); SoilLayer2D soilLayer = CreateSoilLayer2D(topLeftUpperLayer, topRightUpperLayer, bottomRightUpperLayer, bottomLeftUpperLayer); var topRightInBetweenAquiferLayerLeft = new Point2D(rightCoordinate / 2, -10); var bottomRightInBetweenAquiferLayerLeft = new Point2D(rightCoordinate / 2, -20); var bottomLeftInBetweenAquiferLayerLeft = new Point2D(leftCoordinate, -20); SoilLayer2D soilLayerAquiferInBetweenLeft = CreateSoilLayer2D(bottomLeftUpperLayer, topRightInBetweenAquiferLayerLeft, bottomRightInBetweenAquiferLayerLeft, bottomLeftInBetweenAquiferLayerLeft); soilLayerAquiferInBetweenLeft.IsAquifer = isLeftInBetweenLayerAquifer; var topRightInBetweenAquiferLayerRight = new Point2D(rightCoordinate, -10); var bottomRightInBetweenAquiferLayerRight = new Point2D(rightCoordinate, -20); var bottomLeftInBetweenAquiferLayerRight = new Point2D(leftCoordinate, -20); SoilLayer2D soilLayerAquiferInBetweenRight = CreateSoilLayer2D(topRightInBetweenAquiferLayerLeft, topRightInBetweenAquiferLayerRight, bottomRightInBetweenAquiferLayerRight, bottomLeftInBetweenAquiferLayerRight); soilLayerAquiferInBetweenRight.IsAquifer = isRightInBetweenLayerAquifer; var topRightInBetweenLayer = new Point2D(rightCoordinate, -20); var bottomRightInBetweenLayer = new Point2D(rightCoordinate, -25); var bottomLeftInBetweenLayer = new Point2D(leftCoordinate, -25); SoilLayer2D soilLayerInBetween = CreateSoilLayer2D(bottomLeftInBetweenAquiferLayerLeft, topRightInBetweenLayer, bottomRightInBetweenLayer, bottomLeftInBetweenLayer); var topRightBottomAquiferLayer = new Point2D(rightCoordinate, -25); var bottomRightBottomAquiferLayer = new Point2D(rightCoordinate, -30); var bottomLeftBottomAquiferLayer = new Point2D(leftCoordinate, -30); SoilLayer2D soilLayerAquiferBottom = CreateSoilLayer2D(bottomLeftInBetweenLayer, topRightBottomAquiferLayer, bottomRightBottomAquiferLayer, bottomLeftBottomAquiferLayer); soilLayerAquiferBottom.IsAquifer = true; var soilProfile = new SoilProfile2D { Geometry = new GeometryData { Left = leftCoordinate, Right = rightCoordinate, Bottom = -20 } }; soilProfile.Surfaces.Add(soilLayer); soilProfile.Surfaces.Add(soilLayerAquiferInBetweenLeft); soilProfile.Surfaces.Add(soilLayerAquiferInBetweenRight); soilProfile.Surfaces.Add(soilLayerInBetween); soilProfile.Surfaces.Add(soilLayerAquiferBottom); var plLines = new PlLines(); PlLine plLine = plLines.Lines[PlLineType.Pl1]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -5)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -5)); plLine = plLines.Lines[PlLineType.Pl2]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -6)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -6)); plLine = plLines.Lines[PlLineType.Pl3]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -7)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -7)); plLine = plLines.Lines[PlLineType.Pl4]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -8)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -8)); // Call Waternet waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile, penetrationLength); // Assert AssertGeometry(plLines.Lines[PlLineType.Pl1].Points, waternet.PhreaticLine.Points); Assert.AreEqual(3, waternet.HeadLineList.Count); 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.AreEqual(2, waternet.WaternetLineList.Count); var expectedBottomAquiferCoordinates = new[] { bottomLeftInBetweenLayer, new Point2D(rightCoordinate / 2, -25), bottomRightInBetweenLayer }; WaternetLine pl2WaternetLine = waternet.WaternetLineList[0]; Assert.AreSame(waternet.HeadLineList[0], pl2WaternetLine.HeadLine); var offSetAquiferCoordinates = expectedBottomAquiferCoordinates.Select(aquiferCoordinate => new GeometryPoint(aquiferCoordinate.X, aquiferCoordinate.Z + penetrationLength)) .ToArray(); AssertGeometry(offSetAquiferCoordinates, pl2WaternetLine.Points); WaternetLine pl3WaternetLine = waternet.WaternetLineList[1]; Assert.AreSame(waternet.HeadLineList[1], pl3WaternetLine.HeadLine); AssertGeometry(expectedBottomAquiferCoordinates, pl3WaternetLine.Points); } [Test] public void ConvertPlLineToWaternet_ValidPLLinesAndSoilProfile2DWithDiscontinuousBottomAquiferLayer_ReturnsExpectedWaternet() { // Setup var random = new Random(21); double leftCoordinate = random.NextDouble(); double rightCoordinate = leftCoordinate + 1; double penetrationLength = random.NextDouble(); var pointOne = new Point2D(leftCoordinate, 0); var pointTwo = new Point2D(rightCoordinate, 0); var pointThree = new Point2D(leftCoordinate, -10); var pointFour = new Point2D(rightCoordinate, -10); SoilLayer2D soilLayer = CreateSoilLayer2D(pointOne, pointTwo, pointThree, pointFour); var pointFive = new Point2D(rightCoordinate / 2, -10); var pointSix = new Point2D(rightCoordinate / 2, -20); var pointSeven = new Point2D(leftCoordinate, -20); SoilLayer2D soilLayerAquiferPartOne = CreateSoilLayer2D(pointThree, pointFive, pointSix, pointSeven); soilLayerAquiferPartOne.IsAquifer = true; var pointEight = new Point2D(rightCoordinate, -5); var pointNine = new Point2D(rightCoordinate, -9); var pointTen = new Point2D(rightCoordinate / 2, -5); var pointEleven = new Point2D(rightCoordinate / 2, -9); SoilLayer2D soilLayerAquiferPartTwo = CreateSoilLayer2D(pointTen, pointEight, pointNine, pointEleven); soilLayerAquiferPartTwo.IsAquifer = true; var soilProfile = new SoilProfile2D { Geometry = new GeometryData { Left = leftCoordinate, Right = rightCoordinate, Bottom = -20 } }; soilProfile.Surfaces.Add(soilLayer); soilProfile.Surfaces.Add(soilLayerAquiferPartOne); soilProfile.Surfaces.Add(soilLayerAquiferPartTwo); var plLines = new PlLines(); PlLine plLine = plLines.Lines[PlLineType.Pl1]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -5)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -5)); plLine = plLines.Lines[PlLineType.Pl2]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -6)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -6)); plLine = plLines.Lines[PlLineType.Pl3]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -7)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -7)); plLine = plLines.Lines[PlLineType.Pl4]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -8)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -8)); // Call Waternet waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile, penetrationLength); // 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); CollectionAssert.IsEmpty(waternet.WaternetLineList); } [Test] [TestCase(true, false)] [TestCase(false, true)] public void ConvertPlLineToWaternet_ValidPLLinesAndSoilProfile2DWithBottomAquiferLayerNotSpanningWholeInterval_ReturnsExpectedWaternet( bool isLeftBottomLayerAquifer, bool isRightBottomLayerAquifer) { // Setup var random = new Random(21); double leftCoordinate = random.NextDouble(); double rightCoordinate = leftCoordinate + 1; double penetrationLength = random.NextDouble(); var pointOne = new Point2D(leftCoordinate, 0); var pointTwo = new Point2D(rightCoordinate, 0); var pointThree = new Point2D(leftCoordinate, -10); var pointFour = new Point2D(rightCoordinate, -10); SoilLayer2D soilLayer = CreateSoilLayer2D(pointOne, pointTwo, pointThree, pointFour); var pointFive = new Point2D(rightCoordinate / 2, -10); var pointSix = new Point2D(rightCoordinate / 2, -20); var pointSeven = new Point2D(leftCoordinate, -20); SoilLayer2D soilLayerAquiferPartOne = CreateSoilLayer2D(pointThree, pointFive, pointSix, pointSeven); soilLayerAquiferPartOne.IsAquifer = isLeftBottomLayerAquifer; var pointEight = new Point2D(rightCoordinate, -10); var pointNine = new Point2D(rightCoordinate, -20); var pointTen = new Point2D(rightCoordinate / 2, -10); var pointEleven = new Point2D(rightCoordinate / 2, -20); SoilLayer2D soilLayerAquiferPartTwo = CreateSoilLayer2D(pointTen, pointEight, pointNine, pointEleven); soilLayerAquiferPartTwo.IsAquifer = isRightBottomLayerAquifer; var soilProfile = new SoilProfile2D { Geometry = new GeometryData { Left = leftCoordinate, Right = rightCoordinate, Bottom = -20 } }; soilProfile.Surfaces.Add(soilLayer); soilProfile.Surfaces.Add(soilLayerAquiferPartOne); soilProfile.Surfaces.Add(soilLayerAquiferPartTwo); var plLines = new PlLines(); PlLine plLine = plLines.Lines[PlLineType.Pl1]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -5)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -5)); plLine = plLines.Lines[PlLineType.Pl2]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -6)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -6)); plLine = plLines.Lines[PlLineType.Pl3]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -7)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -7)); plLine = plLines.Lines[PlLineType.Pl4]; plLine.Points.Add(new PlLinePoint(leftCoordinate, -8)); plLine.Points.Add(new PlLinePoint(rightCoordinate, -8)); // Call Waternet waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile, penetrationLength); // 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); CollectionAssert.IsEmpty(waternet.WaternetLineList); } [Test] [ExpectedException(typeof(NoNullAllowedException), ExpectedMessage = "Geen ondergrond profiel gedefinieerd")] [SetUICulture("nl-NL")] public void TestLanguageNLThrowsExceptionWhenSoilProfile1DIsNull() { var plLines = new PlLines(); PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines,null, 0, 0, 0); } [Test] [ExpectedException(typeof(NoNullAllowedException), ExpectedMessage = "Geen object voor pn-lijnen gedefinieerd")] [SetUICulture("nl-NL")] public void TestLanguageNLThrowsExceptionWhenPlLinesIsNull() { var soilProfile1D = new SoilProfile1D(); PlLinesToWaternetConverter.ConvertPlLineToWaternet(null, soilProfile1D, 0, 0, 0); } [Test] [ExpectedException(typeof(NoNullAllowedException), ExpectedMessage = "Geen ondergrond profiel gedefinieerd")] [SetUICulture("nl-NL")] public void ConvertPlLineToWaternet_SoilProfileNull_ThrowsException() { var plLines = new PlLines(); PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, null, 0); } [Test] [ExpectedException(typeof(NoNullAllowedException), ExpectedMessage = "Geen object voor pn-lijnen gedefinieerd")] [SetUICulture("nl-NL")] public void ConvertPlLineToWaternet_ProfileLinesNull_ThrowsException() { var soilProfile = new SoilProfile2D(); PlLinesToWaternetConverter.ConvertPlLineToWaternet(null, soilProfile, 0); } private PlLines CreatePlLinesForTest() { var plLines = new PlLines(); // pl 1 is phreatic line var plLine = plLines.Lines[PlLineType.Pl1]; plLine.IsPhreatic = true; plLine.Points.Add(new PlLinePoint(0, 0)); plLine.Points.Add(new PlLinePoint(50, 1)); plLine.Points.Add(new PlLinePoint(100, 1)); // pl 2 first equal to point of pl 1 plLine = plLines.Lines[PlLineType.Pl2]; plLine.Points.Add(new PlLinePoint(0, 0)); plLine.Points.Add(new PlLinePoint(100, -1)); // pl 3 plLine = plLines.Lines[PlLineType.Pl3]; plLine.Points.Add(new PlLinePoint(0, 1)); plLine.Points.Add(new PlLinePoint(50, 0)); plLine.Points.Add(new PlLinePoint(100, -1)); // pl 4 plLine = plLines.Lines[PlLineType.Pl4]; plLine.Points.Add(new PlLinePoint(0, -5)); plLine.Points.Add(new PlLinePoint(100, -5)); return plLines; } private SoilProfile1D CreateSoilProfile1DForTest() { var soilProfile1D = new SoilProfile1D(); soilProfile1D.BottomLevel = -30.0; SoilLayer1D layer = new SoilLayer1D(); layer.Name = "L1a"; layer.TopLevel = 1.212; layer.IsAquifer = true; // aquifer at top soilProfile1D.Layers.Add(layer); layer = new SoilLayer1D(); layer.Name = "L1b"; layer.TopLevel = 1.212; layer.IsAquifer = false; soilProfile1D.Layers.Add(layer); layer = new SoilLayer1D(); layer.Name = "L2a"; layer.TopLevel = -2.111; // top of in-between aquifer layer.IsAquifer = true; soilProfile1D.Layers.Add(layer); layer = new SoilLayer1D(); layer.Name = "L2b"; layer.TopLevel = -2.151; layer.IsAquifer = true; soilProfile1D.Layers.Add(layer); layer = new SoilLayer1D(); layer.Name = "L3"; layer.TopLevel = -3.373; layer.IsAquifer = false; soilProfile1D.Layers.Add(layer); layer = new SoilLayer1D(); layer.Name = "L4"; layer.TopLevel = -4.151; layer.IsAquifer = true; soilProfile1D.Layers.Add(layer); layer = new SoilLayer1D(); layer.Name = "L5"; layer.TopLevel = -5.373; layer.IsAquifer = false; soilProfile1D.Layers.Add(layer); layer = new SoilLayer1D(); layer.Name = "L6a"; layer.TopLevel = -6.111; // top of bottom aquifer layer.IsAquifer = true; soilProfile1D.Layers.Add(layer); layer = new SoilLayer1D(); layer.Name = "L6b"; layer.TopLevel = -6.151; layer.IsAquifer = true; soilProfile1D.Layers.Add(layer); layer = new SoilLayer1D(); layer.Name = "L7"; layer.TopLevel = -7.373; layer.IsAquifer = false; soilProfile1D.Layers.Add(layer); return soilProfile1D; } private SoilProfile1D CreateSoilProfile1DWith1AquiferForTest() { var soilProfile1D = new SoilProfile1D(); soilProfile1D.BottomLevel = -30.0; SoilLayer1D layer = new SoilLayer1D(); layer = new SoilLayer1D(); layer.Name = "L1b"; layer.TopLevel = 1.212; layer.IsAquifer = false; soilProfile1D.Layers.Add(layer); layer = new SoilLayer1D(); layer.Name = "L6a"; layer.TopLevel = -6.111; // top of bottom aquifer layer.IsAquifer = true; soilProfile1D.Layers.Add(layer); return soilProfile1D; } private SoilProfile1D CreateSoilProfile1DWithoutAquifersForTest() { var soilProfile1D = new SoilProfile1D(); soilProfile1D.BottomLevel = -30.0; SoilLayer1D layer = new SoilLayer1D(); layer = new SoilLayer1D(); layer.Name = "L1b"; layer.TopLevel = 1.212; layer.IsAquifer = false; soilProfile1D.Layers.Add(layer); return soilProfile1D; } private static IEnumerable GetSoilProfilesWithContinuousBottomAquiferLayer() { var random = new Random(21); double leftCoordinate = random.NextDouble(); double rightCoordinate = leftCoordinate + 1; var topLeftUpperLayer = new Point2D(leftCoordinate, 0); var topRightUpperLayer = new Point2D(rightCoordinate, 0); var bottomLeftUpperLayer = new Point2D(leftCoordinate, -10); var bottomRightUpperLayer = new Point2D(rightCoordinate, -10); SoilLayer2D soilLayer = CreateSoilLayer2D(topLeftUpperLayer, topRightUpperLayer, bottomRightUpperLayer, bottomLeftUpperLayer); var topRightLeftBottomLayer = new Point2D(rightCoordinate / 2, -10); var bottomRightLeftBottomLayer = new Point2D(rightCoordinate / 2, -20); var bottomLeftLeftBottomLayer = new Point2D(leftCoordinate, -20); SoilLayer2D soilLayerAquiferPartOne = CreateSoilLayer2D(bottomLeftUpperLayer, topRightLeftBottomLayer, bottomRightLeftBottomLayer, bottomLeftLeftBottomLayer); soilLayerAquiferPartOne.IsAquifer = true; var bottomRightRightBottomLayer = new Point2D(rightCoordinate, -20); SoilLayer2D soilLayerAquiferPartTwo = CreateSoilLayer2D(topRightLeftBottomLayer, bottomRightUpperLayer, bottomRightRightBottomLayer, bottomRightLeftBottomLayer); soilLayerAquiferPartTwo.IsAquifer = true; var soilProfileFullAdjoin = new SoilProfile2D { Geometry = new GeometryData { Left = leftCoordinate, Right = rightCoordinate, Bottom = -20 } }; soilProfileFullAdjoin.Surfaces.Add(soilLayer); soilProfileFullAdjoin.Surfaces.Add(soilLayerAquiferPartOne); soilProfileFullAdjoin.Surfaces.Add(soilLayerAquiferPartTwo); yield return new TestCaseData(soilProfileFullAdjoin, new[] { new GeometryPoint(leftCoordinate, -10), new GeometryPoint(rightCoordinate / 2, -10), new GeometryPoint(rightCoordinate, -10) }).SetName("Right aquifer fully adjoins left aquifer"); var topRightBottomLayer = new Point2D(rightCoordinate, -10); var bottomRightBottomLayer = new Point2D(rightCoordinate, -20); var bottomLeftBottomLayer = new Point2D(leftCoordinate, -20); SoilLayer2D soilLayerAquifer = CreateSoilLayer2D(bottomLeftUpperLayer, topRightBottomLayer, bottomRightBottomLayer, bottomLeftBottomLayer); soilLayerAquifer.IsAquifer = true; var soilProfileOneBottomAquiferLayer = new SoilProfile2D { Geometry = new GeometryData { Left = leftCoordinate, Right = rightCoordinate, Bottom = -20 } }; soilProfileOneBottomAquiferLayer.Surfaces.Add(soilLayer); soilProfileOneBottomAquiferLayer.Surfaces.Add(soilLayerAquifer); yield return new TestCaseData(soilProfileOneBottomAquiferLayer, new[] { new GeometryPoint(leftCoordinate, -10), new GeometryPoint(rightCoordinate, -10) }).SetName("One aquifer bottom layer"); var topLeftRightBottomLayer = new Point2D(rightCoordinate / 2, -5); var topRightRightBottomLayer = new Point2D(rightCoordinate, -5); bottomRightRightBottomLayer = new Point2D(rightCoordinate, -15); var bottomLeftRightBottomLayer = new Point2D(rightCoordinate / 2, -15); soilLayerAquiferPartTwo = CreateSoilLayer2D(topLeftRightBottomLayer, topRightRightBottomLayer, bottomRightRightBottomLayer, bottomLeftRightBottomLayer); soilLayerAquiferPartTwo.IsAquifer = true; var soilProfileRightSoilLayerBottomInRange = new SoilProfile2D { Geometry = new GeometryData { Left = leftCoordinate, Right = rightCoordinate, Bottom = -20 } }; soilProfileRightSoilLayerBottomInRange.Surfaces.Add(soilLayer); soilProfileRightSoilLayerBottomInRange.Surfaces.Add(soilLayerAquiferPartOne); soilProfileRightSoilLayerBottomInRange.Surfaces.Add(soilLayerAquiferPartTwo); yield return new TestCaseData(soilProfileRightSoilLayerBottomInRange, new[] { new GeometryPoint(leftCoordinate, -10), new GeometryPoint(rightCoordinate / 2, -5), new GeometryPoint(rightCoordinate, -5) }).SetName("Right aquifer only bottom in range"); topLeftRightBottomLayer = new Point2D(rightCoordinate / 2, -15); topRightRightBottomLayer = new Point2D(rightCoordinate, -15); bottomRightRightBottomLayer = new Point2D(rightCoordinate, -25); bottomLeftRightBottomLayer = new Point2D(rightCoordinate / 2, -25); soilLayerAquiferPartTwo = CreateSoilLayer2D(topLeftRightBottomLayer, topRightRightBottomLayer, bottomRightRightBottomLayer, bottomLeftRightBottomLayer); soilLayerAquiferPartTwo.IsAquifer = true; var soilProfileRightSoilLayerTopInRange = new SoilProfile2D { Geometry = new GeometryData { Left = leftCoordinate, Right = rightCoordinate, Bottom = -20 } }; soilProfileRightSoilLayerTopInRange.Surfaces.Add(soilLayer); soilProfileRightSoilLayerTopInRange.Surfaces.Add(soilLayerAquiferPartOne); soilProfileRightSoilLayerTopInRange.Surfaces.Add(soilLayerAquiferPartTwo); yield return new TestCaseData(soilProfileRightSoilLayerTopInRange, new[] { new GeometryPoint(leftCoordinate, -10), new GeometryPoint(rightCoordinate / 2, -10), new GeometryPoint(rightCoordinate, -15) }).SetName("Right aquifer only top in range"); topLeftRightBottomLayer = new Point2D(rightCoordinate / 2, -5); topRightRightBottomLayer = new Point2D(rightCoordinate, -5); bottomRightRightBottomLayer = new Point2D(rightCoordinate, -25); bottomLeftRightBottomLayer = new Point2D(rightCoordinate / 2, -25); soilLayerAquiferPartTwo = CreateSoilLayer2D(topLeftRightBottomLayer, topRightRightBottomLayer, bottomRightRightBottomLayer, bottomLeftRightBottomLayer); soilLayerAquiferPartTwo.IsAquifer = true; var soilProfileRightAquiferLayerFullyEnvelopsLeft = new SoilProfile2D { Geometry = new GeometryData { Left = leftCoordinate, Right = rightCoordinate, Bottom = -20 } }; soilProfileRightAquiferLayerFullyEnvelopsLeft.Surfaces.Add(soilLayer); soilProfileRightAquiferLayerFullyEnvelopsLeft.Surfaces.Add(soilLayerAquiferPartOne); soilProfileRightAquiferLayerFullyEnvelopsLeft.Surfaces.Add(soilLayerAquiferPartTwo); yield return new TestCaseData(soilProfileRightAquiferLayerFullyEnvelopsLeft, new[] { new GeometryPoint(leftCoordinate, -10), new GeometryPoint(rightCoordinate / 2, -5), new GeometryPoint(rightCoordinate, -5) }).SetName("Right aquifer fully envelopes left aquifer"); topLeftRightBottomLayer = new Point2D(rightCoordinate / 2, -15); topRightRightBottomLayer = new Point2D(rightCoordinate, -15); bottomRightRightBottomLayer = new Point2D(rightCoordinate, -17); bottomLeftRightBottomLayer = new Point2D(rightCoordinate / 2, -17); soilLayerAquiferPartTwo = CreateSoilLayer2D(topLeftRightBottomLayer, topRightRightBottomLayer, bottomRightRightBottomLayer, bottomLeftRightBottomLayer); soilLayerAquiferPartTwo.IsAquifer = true; var soilProfileRightAquiferLayerFullyEnvelopedByLeft = new SoilProfile2D { Geometry = new GeometryData { Left = leftCoordinate, Right = rightCoordinate, Bottom = -20 } }; soilProfileRightAquiferLayerFullyEnvelopedByLeft.Surfaces.Add(soilLayer); soilProfileRightAquiferLayerFullyEnvelopedByLeft.Surfaces.Add(soilLayerAquiferPartOne); soilProfileRightAquiferLayerFullyEnvelopedByLeft.Surfaces.Add(soilLayerAquiferPartTwo); yield return new TestCaseData(soilProfileRightAquiferLayerFullyEnvelopedByLeft, new[] { new GeometryPoint(leftCoordinate, -10), new GeometryPoint(rightCoordinate / 2, -10), new GeometryPoint(rightCoordinate, -15) }).SetName("Right aquifer fully enveloped by left aquifer"); } /// /// Creates a rectangular . /// /// /// /// /// /// A rectangular . private static SoilLayer2D CreateSoilLayer2D(Point2D topLeftCoordinate, Point2D topRightCoordinate, Point2D bottomRightCoordinate, Point2D bottomLeftCoordinate) { return new SoilLayer2D { GeometrySurface = new GeometrySurface { OuterLoop = new GeometryLoop { CurveList = { new GeometryCurve(topLeftCoordinate, topRightCoordinate), new GeometryCurve(topRightCoordinate, bottomRightCoordinate), new GeometryCurve(bottomRightCoordinate, bottomLeftCoordinate), new GeometryCurve(bottomLeftCoordinate, topLeftCoordinate) } } } }; } private static void AssertGeometry(IEnumerable expectedPoints, IEnumerable actualPoints) { var convertedPoints = expectedPoints.Select(p => new GeometryPoint(p.X, p.Z)).ToArray(); AssertGeometry(convertedPoints, actualPoints); } private static void AssertGeometry(IEnumerable expectedPoints, IEnumerable actualPoints) { int expectedNrOfPoints = expectedPoints.Count(); Assert.AreEqual(expectedNrOfPoints, actualPoints.Count()); for (int i = 0; i < expectedNrOfPoints; i++) { GeometryPoint expectedPoint = expectedPoints.ElementAt(i); GeometryPoint actualPoint = actualPoints.ElementAt(i); Assert.AreEqual(expectedPoint.X, actualPoint.X); Assert.AreEqual(expectedPoint.Z, actualPoint.Z); } } } }