Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SoilProfile2DSurfaceLineHelper.cs
===================================================================
diff -u -r4993 -r5010
--- DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SoilProfile2DSurfaceLineHelper.cs (.../SoilProfile2DSurfaceLineHelper.cs) (revision 4993)
+++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geotechnics/SoilProfile2DSurfaceLineHelper.cs (.../SoilProfile2DSurfaceLineHelper.cs) (revision 5010)
@@ -20,6 +20,7 @@
// All rights reserved.
using System;
+using Deltares.DamEngine.Data.Geometry;
namespace Deltares.DamEngine.Data.Geotechnics;
@@ -66,9 +67,28 @@
/// The required shift of the geometry so it will fit the surface line
///
public static SoilProfile2D CombineSurfaceLineWithSoilProfile2D(SurfaceLine2 surfaceLine, SoilProfile2D soilProfile2D,
- Soil defaultSoil, double shift)
+ Soil defaultSoil, double shift)
{
return null;
}
-
+
+ ///
+ /// Check if all the points of the surface line are above the bottom of the soil profile.
+ ///
+ ///
+ ///
+ ///
+ public static bool IsSurfaceLineAboveBottomSoilProfile2D(SurfaceLine2 surfaceLine, SoilProfile2D soilProfile2D)
+ {
+ double bottom = soilProfile2D.Geometry.Bottom;
+ foreach (GeometryPoint point in surfaceLine.Geometry.Points)
+ {
+ if (point.Z < bottom)
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
}
\ No newline at end of file
Index: DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/Factories/FactoryForSurfaceLines.cs
===================================================================
diff -u -r5007 -r5010
--- DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/Factories/FactoryForSurfaceLines.cs (.../FactoryForSurfaceLines.cs) (revision 5007)
+++ DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/Factories/FactoryForSurfaceLines.cs (.../FactoryForSurfaceLines.cs) (revision 5010)
@@ -787,58 +787,45 @@
return surfaceLine;
}
- ///
- /// Creates a surface line, that contains a dike and is fully above SurfaceLineWithDikeAndDitch.
- ///
- /// surface line
- public static SurfaceLine2 CreateSurfaceLineAboveSurfaceLineDikeAndDitch()
+ public static SurfaceLine2 CreateSurfaceLineDike(double offset = 0.0, string name = "SurfaceLineWithDikeAndDitch")
{
var surfaceLine = new SurfaceLine2
{
- Name = "AboveSurfaceLineWithDikeAndDitch",
+ Name = name,
Geometry = new GeometryPointString(),
CharacteristicPoints =
{
GeometryMustContainPoint = true
}
};
- surfaceLine.EnsurePointOfType(0.0, 5.0, CharacteristicPointType.SurfaceLevelOutside);
- surfaceLine.EnsurePointOfType(10.0, 5.0, CharacteristicPointType.DikeToeAtRiver);
- surfaceLine.EnsurePointOfType(34.5, 10.0, CharacteristicPointType.DikeTopAtRiver);
- surfaceLine.EnsurePointOfType(40.5, 10.0, CharacteristicPointType.DikeTopAtPolder);
- surfaceLine.EnsurePointOfType(50.5, 5.0, CharacteristicPointType.DikeToeAtPolder);
- surfaceLine.EnsurePointOfType(75.0, 5.0, CharacteristicPointType.SurfaceLevelInside);
+ surfaceLine.EnsurePointOfType(0.0, offset + 0.0, CharacteristicPointType.SurfaceLevelOutside);
+ surfaceLine.EnsurePointOfType(10.0, offset + 0.0, CharacteristicPointType.DikeToeAtRiver);
+ surfaceLine.EnsurePointOfType(34.5, offset + 5.0, CharacteristicPointType.DikeTopAtRiver);
+ surfaceLine.EnsurePointOfType(40.5, offset + 5.0, CharacteristicPointType.DikeTopAtPolder);
+ surfaceLine.EnsurePointOfType(50.5, offset + 0.0, CharacteristicPointType.DikeToeAtPolder);
+ surfaceLine.EnsurePointOfType(75.0, offset + 0.0, CharacteristicPointType.SurfaceLevelInside);
surfaceLine.Geometry.SyncCalcPoints();
return surfaceLine;
}
///
+ /// Creates a surface line, that contains a dike and is fully above SurfaceLineWithDikeAndDitch.
+ ///
+ /// surface line
+ public static SurfaceLine2 CreateSurfaceLineAboveSurfaceLineDikeAndDitch()
+ {
+ return CreateSurfaceLineDike(5.0, "AboveSurfaceLineWithDikeAndDitch");
+ }
+
+ ///
/// Creates a surface line, that contains a dike and is fully below SurfaceLineWithDikeAndDitch.
///
/// surface line
public static SurfaceLine2 CreateSurfaceLineBelowSurfaceLineDikeAndDitch()
{
- var surfaceLine = new SurfaceLine2
- {
- Name = "BelowSurfaceLineWithDikeAndDitch",
- Geometry = new GeometryPointString(),
- CharacteristicPoints =
- {
- GeometryMustContainPoint = true
- }
- };
-
- surfaceLine.EnsurePointOfType(0.0, -10.0, CharacteristicPointType.SurfaceLevelOutside);
- surfaceLine.EnsurePointOfType(10.0, -10.0, CharacteristicPointType.DikeToeAtRiver);
- surfaceLine.EnsurePointOfType(34.5, -5.0, CharacteristicPointType.DikeTopAtRiver);
- surfaceLine.EnsurePointOfType(40.5, -5.0, CharacteristicPointType.DikeTopAtPolder);
- surfaceLine.EnsurePointOfType(50.5, -10.0, CharacteristicPointType.DikeToeAtPolder);
- surfaceLine.EnsurePointOfType(75.0, -10.0, CharacteristicPointType.SurfaceLevelInside);
-
- surfaceLine.Geometry.SyncCalcPoints();
- return surfaceLine;
+ return CreateSurfaceLineDike(-10.0, "AboveSurfaceLineWithDikeAndDitch");
}
///
@@ -847,24 +834,6 @@
/// surface line
public static SurfaceLine2 CreateSurfaceLineCuttingSurfaceLineDikeAndDitch()
{
- var surfaceLine = new SurfaceLine2
- {
- Name = "BelowSurfaceLineWithDikeAndDitch",
- Geometry = new GeometryPointString(),
- CharacteristicPoints =
- {
- GeometryMustContainPoint = true
- }
- };
-
- surfaceLine.EnsurePointOfType(0.0, -2.0, CharacteristicPointType.SurfaceLevelOutside);
- surfaceLine.EnsurePointOfType(10.0, -2.0, CharacteristicPointType.DikeToeAtRiver);
- surfaceLine.EnsurePointOfType(34.5, 7.0, CharacteristicPointType.DikeTopAtRiver);
- surfaceLine.EnsurePointOfType(40.5, 7.0, CharacteristicPointType.DikeTopAtPolder);
- surfaceLine.EnsurePointOfType(50.5, -2.0, CharacteristicPointType.DikeToeAtPolder);
- surfaceLine.EnsurePointOfType(75.0, -2.0, CharacteristicPointType.SurfaceLevelInside);
-
- surfaceLine.Geometry.SyncCalcPoints();
- return surfaceLine;
+ return CreateSurfaceLineDike(-2.0, "AboveSurfaceLineWithDikeAndDitch");
}
}
\ No newline at end of file
Index: DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/SoilProfile2DSurfaceLineHelperTests.cs
===================================================================
diff -u -r4903 -r5010
--- DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/SoilProfile2DSurfaceLineHelperTests.cs (.../SoilProfile2DSurfaceLineHelperTests.cs) (revision 4903)
+++ DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/SoilProfile2DSurfaceLineHelperTests.cs (.../SoilProfile2DSurfaceLineHelperTests.cs) (revision 5010)
@@ -120,6 +120,18 @@
Assert.That(newSoilProfile2D.Surfaces, Has.Count.EqualTo(testCaseSurfaceLine.SurfaceCount));
}
+ [Test]
+ [TestCase(0, true)] // Surface line is above the bottom of the soil profile
+ [TestCase(-10, true)] // Surface line is on and above the bottom of the soil profile
+ [TestCase(-12, false)] // Surface line is partly below the bottom of the soil profile
+ [TestCase(-20, false)] // Surface line is below the bottom of the soil profile
+ public void GivenSoilProfile2DWhenCallingIsSurfaceLineAboveBottomSoilProfile2DThenCorrectResponseIsReturned(double offset, bool response)
+ {
+ SurfaceLine2 surfaceLine = FactoryForSurfaceLines.CreateSurfaceLineDike(offset);
+ SoilProfile2D soilProfile2D = FactoryForSoilProfiles.CreateSoilProfile2DWithThreeLayers();
+ Assert.That(SoilProfile2DSurfaceLineHelper.IsSurfaceLineAboveBottomSoilProfile2D(surfaceLine, soilProfile2D), Is.EqualTo(response));
+ }
+
///
/// Test case class for GivenSoilProfile2DWhenCombiningWithSurfaceLineThenCorrectNewSoilProfile2DIsCreated()
///
Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/MacroStabilityCommonHelperTests.cs
===================================================================
diff -u -r5004 -r5010
--- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/MacroStabilityCommonHelperTests.cs (.../MacroStabilityCommonHelperTests.cs) (revision 5004)
+++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/MacroStabilityCommonHelperTests.cs (.../MacroStabilityCommonHelperTests.cs) (revision 5010)
@@ -19,6 +19,7 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using System.Linq;
using Deltares.DamEngine.Calculators.KernelWrappers.MacroStabilityCommon;
using Deltares.DamEngine.Data.General;
@@ -269,6 +270,16 @@
});
}
+ [Test]
+ public void GivenSoilGeometryProbabilityWithSoilProfile2DAndSurfaceLinePartlyBelowSoilProfile2DBottomWhenCombiningThenExceptionIsRaised()
+ {
+ SoilGeometryProbability soilGeometryProbability = CreateSoilGeometryProbabilityWithSoilProfile2DWithSurfaceLineDitchDike();
+ SurfaceLine2 surfaceLine = FactoryForSurfaceLines.CreateSurfaceLineDike(-22.0, "PartlyBelowBottom");
+ // Now combine the soilGeometryProbability with the surfaceLine which should in an exception, because the surfaceLine
+ // is partly below the bottom of the SoilProfile2D
+ Assert.Throws(() => { MacroStabilityCommonHelper.CombineSoilProfileWithSurfaceLine(soilGeometryProbability, surfaceLine, new Soil()); });
+ }
+
private static SoilGeometryProbability CreateSoilGeometryProbabilityWithSoilProfile2DWithSurfaceLineDitchDike()
{
SoilGeometryProbability soilGeometryProbability = FactoryForSoilGeometryProbabilities.CreateSoilGeometryProbabilityWithSoilProfile1D();
Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityCommonHelper.cs
===================================================================
diff -u -r5008 -r5010
--- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityCommonHelper.cs (.../MacroStabilityCommonHelper.cs) (revision 5008)
+++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityCommonHelper.cs (.../MacroStabilityCommonHelper.cs) (revision 5010)
@@ -428,7 +428,11 @@
{
throw new ArgumentNullException(nameof(dikeEmbankmentSoil), @"DikeEmbankmentSoil cannot be null.");
}
-
+ if (!SoilProfile2DSurfaceLineHelper.IsSurfaceLineAboveBottomSoilProfile2D(surfaceLine2, subSoilScenario.SoilProfile2D))
+ {
+ throw new InvalidOperationException(@"SurfaceLine is (partly) below the bottom of the SoilProfile2D.");
+ }
+
FitSoilProfile2DToSurfaceLine(subSoilScenario, surfaceLine2);
}