Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/Uplift/UpliftLocationDeterminatorTest.cs =================================================================== diff -u --- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/Uplift/UpliftLocationDeterminatorTest.cs (revision 0) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/Uplift/UpliftLocationDeterminatorTest.cs (revision 1011) @@ -0,0 +1,166 @@ +using Deltares.DamEngine.Calculators.PlLinesCreator; +using Deltares.DamEngine.Calculators.Uplift; +using Deltares.DamEngine.Data.General; +using Deltares.DamEngine.Data.General.PlLines; +using Deltares.DamEngine.Data.Geotechnics; +using Deltares.DamEngine.TestHelpers.Factories; +using NUnit.Framework; + +namespace Deltares.DamEngine.Calculators.Tests.Uplift +{ + + [TestFixture] + public class UpliftLocationDeterminatorTest + { + private static PLLines CreatePLLines(SurfaceLine2 surfaceLine, SoilProfile1D soilProfile, double riverLevel, bool isUseOvenDryUnitWeight) + { + PLLinesCreator plLineCreator = new PLLinesCreator(); + plLineCreator.IsUseOvenDryUnitWeight = isUseOvenDryUnitWeight; + plLineCreator.SoilProfile = soilProfile; + plLineCreator.SurfaceLine = surfaceLine; + plLineCreator.WaterLevelRiverHigh = riverLevel; + plLineCreator.WaterLevelPolder = -0.5; + plLineCreator.ModelParametersForPLLines.DampingFactorPL3 = 0.3; + plLineCreator.ModelParametersForPLLines.DampingFactorPL4 = 0.4; + plLineCreator.ModelParametersForPLLines.PenetrationLength = 1.5; + plLineCreator.IsAdjustPL3AndPL4SoNoUpliftWillOccurEnabled = false; // for piping this must be set to false + var location = new Location { DamType = DamType.Regional }; + return plLineCreator.CreateAllPLLines(location); + } + + [TestFixtureSetUp] + public void FixtureSetup() + { + } + + [TestFixtureTearDown] + public void FixtureTearDown() + { + } + [Test] + [ExpectedException(typeof(UpliftLocationDeterminatorException))] + public void ThrowsExceptionIfSoilProfileNotAssignedInUpliftLocationDeterminator() + { + var surfaceLineTutorial1 = FactoryForSurfaceLines.CreateSurfaceLineTutorial1(); + var upliftLocationDeterminator = new UpliftLocationDeterminator(); + upliftLocationDeterminator.SurfaceLine = surfaceLineTutorial1; + upliftLocationDeterminator.PLLines = FactoryForPLLines.CreatePLLinesForUpliftLocationDeterminatorTests(); + UpliftLocationAndResult upliftLocationAndResult = upliftLocationDeterminator.GetLocationAndResult(1.0); + } + + [Test] + [ExpectedException(typeof(UpliftLocationDeterminatorException))] + public void ThrowsExceptionIfPLLinesNotAssignedInUpliftLocationDeterminator() + { + var surfaceLineTutorial1 = FactoryForSurfaceLines.CreateSurfaceLineTutorial1(); + var upliftLocationDeterminator = new UpliftLocationDeterminator(); + upliftLocationDeterminator.SurfaceLine = surfaceLineTutorial1; + upliftLocationDeterminator.SoilProfile = FactoryForSoilProfiles.CreateClaySandClaySandProfile(); + UpliftLocationAndResult upliftLocationAndResult = upliftLocationDeterminator.GetLocationAndResult(1.0); + } + + [Test] + [ExpectedException(typeof(UpliftLocationDeterminatorException))] + public void ThrowsExceptionIfSurfaceLineNotAssignedInUpliftLocationDeterminator() + { + var upliftLocationDeterminator = new UpliftLocationDeterminator(); + upliftLocationDeterminator.SoilProfile = FactoryForSoilProfiles.CreateClaySandClaySandProfile(); + upliftLocationDeterminator.PLLines = FactoryForPLLines.CreatePLLinesForUpliftLocationDeterminatorTests(); + UpliftLocationAndResult upliftLocationAndResult = upliftLocationDeterminator.GetLocationAndResult(1.0); + } + + [Test] + public void CheckIfUpliftIsDetectedForBothSandlayers() + { + var surfaceLineForPipingBligh = FactoryForSurfaceLines.CreateSurfaceLineForPipingBligh(); + var upliftLocationDeterminator = new UpliftLocationDeterminator(); + upliftLocationDeterminator.SoilProfile = FactoryForSoilProfiles.CreateClaySandClaySandProfileForPipingBligh(); + upliftLocationDeterminator.PLLines = FactoryForPLLines.CreatePLLinesForUpliftLocationDeterminatorTests(); + upliftLocationDeterminator.SurfaceLine = surfaceLineForPipingBligh; + UpliftLocationAndResult upliftLocationAndResult = upliftLocationDeterminator.GetLocationAndResult(1.0); + Assert.IsTrue(upliftLocationAndResult.LocationEquals(upliftLocationDeterminator.SurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtPolder))); + } + + [Test] + public void GetLowestUpliftFactorCoordinateFromSimpleSurfaceLineAndOneSandLayerProfile() + { + const double cTolerance = 0.000001; + const double cExpectedXCoordinate = 59.5; + const double cExpectedZCoordinate = -2.0; + const double cExpectedUpliftFactor = 0.675781015; // Value taken from calculation itself + + // Set required upliftcalculator variables + const double cRiverlevel = 4; + SurfaceLine2 surfaceLine = FactoryForSurfaceLines.CreateSurfaceLineTutorial1(); + SoilProfile1D soilProfile = FactoryForSoilProfiles.CreateClaySandProfile(); + PLLines plLines = CreatePLLines(surfaceLine, soilProfile, cRiverlevel, false); + + UpliftLocationDeterminator upliftLocationDeterminator = new UpliftLocationDeterminator() + { + SurfaceLine = surfaceLine, + SoilProfile = soilProfile, + PLLines = plLines + }; + UpliftLocationAndResult upliftLocationAndResult = upliftLocationDeterminator.GetLocationAtWithLowestUpliftFactor(); + + Assert.AreEqual(cExpectedXCoordinate, upliftLocationAndResult.X, cTolerance); + Assert.AreEqual(cExpectedZCoordinate, upliftLocationAndResult.Z, cTolerance); + Assert.AreEqual(cExpectedUpliftFactor, upliftLocationAndResult.UpliftFactor.Value, cTolerance); + } + + [Test] + public void GetLocationInPolderNearestDikeWithUpliftFactorLowerThanOneFromSimpleSurfaceLineAndOneSandLayerProfile() + { + const double cTolerance = 0.000001; + const double cExpectedUpliftFactor = 0.0666253589441213; // this value is copied from the debugger + // Set required upliftcalculator variables + const double cRiverlevel = 4; + SurfaceLine2 surfaceLine = FactoryForSurfaceLines.CreateSurfaceLineTutorial1(); + SoilProfile1D soilProfile = FactoryForSoilProfiles.CreateClaySandProfileForPipingBligh(); + PLLines plLines = CreatePLLines(surfaceLine, soilProfile, cRiverlevel, false); + + UpliftLocationDeterminator upliftLocationDeterminator = new UpliftLocationDeterminator() + { + SurfaceLine = surfaceLine, + SoilProfile = soilProfile, + PLLines = plLines + }; + UpliftLocationAndResult upliftLocationAndResult = upliftLocationDeterminator.GetLocationInPolderNearestDikeWithUpliftFactorLowerThanRequired(1.0); + + Assert.IsTrue(upliftLocationAndResult.LocationEquals(upliftLocationDeterminator.SurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtPolder))); + Assert.AreEqual(cExpectedUpliftFactor, upliftLocationAndResult.UpliftFactor.Value, cTolerance); + } + + /// + /// Same as above test, but now the oven dry unit weight has to be used + /// + [Test] + public void GetLocationInPolderNearestDikeWithUpliftFactorLowerThanOneFromSimpleSurfaceLineAndOneSandLayerProfileAndDryOption() + { + const double cTolerance = 0.000001; + const double cExpectedUpliftFactor = 0.0666253589441213; // this value is copied from the debugger + // Set required upliftcalculator variables + const double cRiverlevel = 4; + SurfaceLine2 surfaceLine = FactoryForSurfaceLines.CreateSurfaceLineTutorial1(); + SoilProfile1D soilProfile = FactoryForSoilProfiles.CreateClaySandProfileForPipingBligh(); + foreach (SoilLayer1D layer in soilProfile.Layers) + { + layer.Soil.DryUnitWeight = layer.Soil.AbovePhreaticLevel; + layer.Soil.AbovePhreaticLevel = layer.Soil.AbovePhreaticLevel + 1.0; + } + PLLines plLines = CreatePLLines(surfaceLine, soilProfile, cRiverlevel, false); + + UpliftLocationDeterminator upliftLocationDeterminator = new UpliftLocationDeterminator() + { + SurfaceLine = surfaceLine, + SoilProfile = soilProfile, + PLLines = plLines, + IsUseOvenDryUnitWeight = true + }; + UpliftLocationAndResult upliftLocationAndResult = upliftLocationDeterminator.GetLocationInPolderNearestDikeWithUpliftFactorLowerThanRequired(1.0); + + Assert.IsTrue(upliftLocationAndResult.LocationEquals(upliftLocationDeterminator.SurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtPolder))); + Assert.AreEqual(cExpectedUpliftFactor, upliftLocationAndResult.UpliftFactor.Value, cTolerance); + } + } +} \ No newline at end of file Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/PlLinesCreator/PLLinesCreatorTest.cs =================================================================== diff -u -r926 -r1011 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/PlLinesCreator/PLLinesCreatorTest.cs (.../PLLinesCreatorTest.cs) (revision 926) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/PlLinesCreator/PLLinesCreatorTest.cs (.../PLLinesCreatorTest.cs) (revision 1011) @@ -26,14 +26,13 @@ using Deltares.DamEngine.Data.General.PlLines; using Deltares.DamEngine.Data.Geometry; using Deltares.DamEngine.Data.Geotechnics; -using Deltares.DamEngine.TestHelpers; using Deltares.DamEngine.TestHelpers.Factories; using NUnit.Framework; namespace Deltares.DamEngine.Calculators.Tests { [TestFixture] - public class PlLinesCreatorTest + public class PLLinesCreatorTest { private double Tolerance = 0.001; Index: DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/Factories/FactoryForPLLines.cs =================================================================== diff -u --- DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/Factories/FactoryForPLLines.cs (revision 0) +++ DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/Factories/FactoryForPLLines.cs (revision 1011) @@ -0,0 +1,31 @@ +using Deltares.DamEngine.Data.General; +using Deltares.DamEngine.Data.General.PlLines; + +namespace Deltares.DamEngine.TestHelpers.Factories +{ + public class FactoryForPLLines + { + /// + /// Create simple PLline + /// + /// PLLines + public static PLLines CreatePLLinesForUpliftLocationDeterminatorTests() + { + var plLines = new PLLines(); + + plLines.Lines[PLLineType.PL1] = new PLLine(); + plLines.Lines[PLLineType.PL1].Points.Add(new PLLinePoint(0, 1.5)); + plLines.Lines[PLLineType.PL1].Points.Add(new PLLinePoint(13, 1.5)); + plLines.Lines[PLLineType.PL2] = new PLLine(); + plLines.Lines[PLLineType.PL2].Points.Add(new PLLinePoint(0, 4)); + plLines.Lines[PLLineType.PL2].Points.Add(new PLLinePoint(13, 4)); + plLines.Lines[PLLineType.PL3] = new PLLine(); + plLines.Lines[PLLineType.PL3].Points.Add(new PLLinePoint(0, 2)); + plLines.Lines[PLLineType.PL3].Points.Add(new PLLinePoint(13, 2)); + plLines.Lines[PLLineType.PL4] = new PLLine(); + plLines.Lines[PLLineType.PL4].Points.Add(new PLLinePoint(0, 3)); + plLines.Lines[PLLineType.PL4].Points.Add(new PLLinePoint(13, 3)); + return plLines; + } + } +} Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/Common/PlLinesHelperTests.cs =================================================================== diff -u -r926 -r1011 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/Common/PlLinesHelperTests.cs (.../PlLinesHelperTests.cs) (revision 926) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/Common/PlLinesHelperTests.cs (.../PlLinesHelperTests.cs) (revision 1011) @@ -19,17 +19,9 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Deltares.DamEngine.Calculators.KernelWrappers.Common; using Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.General.PlLines; -using Deltares.DamEngine.Data.Geometry; -using Deltares.DamEngine.Data.Geotechnics; -using Deltares.DamEngine.TestHelpers; using Deltares.DamEngine.TestHelpers.Factories; using NUnit.Framework; Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/Deltares.DamEngine.Calculators.Tests.csproj =================================================================== diff -u -r971 -r1011 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/Deltares.DamEngine.Calculators.Tests.csproj (.../Deltares.DamEngine.Calculators.Tests.csproj) (revision 971) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/Deltares.DamEngine.Calculators.Tests.csproj (.../Deltares.DamEngine.Calculators.Tests.csproj) (revision 1011) @@ -63,6 +63,7 @@ + Index: DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/Deltares.DamEngine.TestHelpers.csproj =================================================================== diff -u -r877 -r1011 --- DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/Deltares.DamEngine.TestHelpers.csproj (.../Deltares.DamEngine.TestHelpers.csproj) (revision 877) +++ DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/Deltares.DamEngine.TestHelpers.csproj (.../Deltares.DamEngine.TestHelpers.csproj) (revision 1011) @@ -39,6 +39,7 @@ +