Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.KernelWrapper/Creators/Input/LayerWithSoilCreator.cs
===================================================================
diff -u -raf2df89e0e5626a73bbf8d964291ce23085f61e2 -r6706d60d5fc1100ffdfaac1cec64e6f61ea9be74
--- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.KernelWrapper/Creators/Input/LayerWithSoilCreator.cs (.../LayerWithSoilCreator.cs) (revision af2df89e0e5626a73bbf8d964291ce23085f61e2)
+++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.KernelWrapper/Creators/Input/LayerWithSoilCreator.cs (.../LayerWithSoilCreator.cs) (revision 6706d60d5fc1100ffdfaac1cec64e6f61ea9be74)
@@ -23,14 +23,14 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
-using Deltares.MacroStability.Geometry;
-using Riskeer.MacroStabilityInwards.KernelWrapper.Calculators.Input;
+using Deltares.MacroStability.CSharpWrapper;
+using Deltares.MacroStability.CSharpWrapper.Input;
using Point2D = Core.Common.Base.Geometry.Point2D;
using ShearStrengthModel = Riskeer.MacroStabilityInwards.KernelWrapper.Calculators.Input.ShearStrengthModel;
using SoilLayer = Riskeer.MacroStabilityInwards.KernelWrapper.Calculators.Input.SoilLayer;
using SoilProfile = Riskeer.MacroStabilityInwards.KernelWrapper.Calculators.Input.SoilProfile;
-using WtiStabilitySoil = Deltares.MacroStability.Geometry.Soil;
-using WtiStabilityShearStrengthModel = Deltares.MacroStability.Geometry.ShearStrengthModel;
+using WaterPressureInterpolationModel = Riskeer.MacroStabilityInwards.KernelWrapper.Calculators.Input.WaterPressureInterpolationModel;
+using CSharpWrapperWaterPressureInterpolationModel = Deltares.MacroStability.CSharpWrapper.Input.WaterPressureInterpolationModel;
namespace Riskeer.MacroStabilityInwards.KernelWrapper.Creators.Input
{
@@ -80,9 +80,11 @@
var layerWithSoil = new LayerWithSoil(
layer.OuterRing,
GetInnerLoopsRecursively(layer),
- new WtiStabilitySoil(layer.MaterialName)
+ new Soil
{
- ShearStrengthModel = ConvertShearStrengthModel(layer.ShearStrengthModel),
+ Name = layer.MaterialName,
+ ShearStrengthAbovePhreaticLevelModel = ConvertShearStrengthAbovePhreaticLevelModel(layer.ShearStrengthModel),
+ ShearStrengthBelowPhreaticLevelModel = ConvertShearStrengthBelowPhreaticLevelModel(layer.ShearStrengthModel),
AbovePhreaticLevel = layer.AbovePhreaticLevel,
BelowPhreaticLevel = layer.BelowPhreaticLevel,
Cohesion = layer.Cohesion,
@@ -118,15 +120,15 @@
}
///
- /// Converts a into a .
+ /// Converts a into a .
///
/// The to convert.
- /// A based on .
+ /// A based on .
/// Thrown when
/// is an invalid value.
/// Thrown when
/// is a valid value, but unsupported.
- private static WtiStabilityShearStrengthModel ConvertShearStrengthModel(ShearStrengthModel shearStrengthModel)
+ private static ShearStrengthModelType ConvertShearStrengthAbovePhreaticLevelModel(ShearStrengthModel shearStrengthModel)
{
if (!Enum.IsDefined(typeof(ShearStrengthModel), shearStrengthModel))
{
@@ -138,26 +140,55 @@
switch (shearStrengthModel)
{
case ShearStrengthModel.SuCalculated:
- return WtiStabilityShearStrengthModel.CuCalculated;
+ return ShearStrengthModelType.Shansep;
case ShearStrengthModel.CPhi:
- return WtiStabilityShearStrengthModel.CPhi;
case ShearStrengthModel.CPhiOrSuCalculated:
- return WtiStabilityShearStrengthModel.CPhiOrCuCalculated;
+ return ShearStrengthModelType.MohrCoulomb;
default:
throw new NotSupportedException();
}
}
///
- /// Converts a into a .
+ /// Converts a into a .
///
+ /// The to convert.
+ /// A based on .
+ /// Thrown when
+ /// is an invalid value.
+ /// Thrown when
+ /// is a valid value, but unsupported.
+ private static ShearStrengthModelType ConvertShearStrengthBelowPhreaticLevelModel(ShearStrengthModel shearStrengthModel)
+ {
+ if (!Enum.IsDefined(typeof(ShearStrengthModel), shearStrengthModel))
+ {
+ throw new InvalidEnumArgumentException(nameof(shearStrengthModel),
+ (int) shearStrengthModel,
+ typeof(ShearStrengthModel));
+ }
+
+ switch (shearStrengthModel)
+ {
+ case ShearStrengthModel.SuCalculated:
+ case ShearStrengthModel.CPhiOrSuCalculated:
+ return ShearStrengthModelType.Shansep;
+ case ShearStrengthModel.CPhi:
+ return ShearStrengthModelType.MohrCoulomb;
+ default:
+ throw new NotSupportedException();
+ }
+ }
+
+ ///
+ /// Converts a into a .
+ ///
/// The to convert.
- /// A based on .
+ /// A based on .
/// Thrown when
/// is an invalid value.
/// Thrown when
/// is a valid value, but unsupported.
- private static WaterpressureInterpolationModel ConvertWaterPressureInterpolationModel(WaterPressureInterpolationModel waterPressureInterpolationModel)
+ private static CSharpWrapperWaterPressureInterpolationModel ConvertWaterPressureInterpolationModel(WaterPressureInterpolationModel waterPressureInterpolationModel)
{
if (!Enum.IsDefined(typeof(WaterPressureInterpolationModel), waterPressureInterpolationModel))
{
@@ -169,9 +200,9 @@
switch (waterPressureInterpolationModel)
{
case WaterPressureInterpolationModel.Automatic:
- return WaterpressureInterpolationModel.Automatic;
+ return CSharpWrapperWaterPressureInterpolationModel.Automatic;
case WaterPressureInterpolationModel.Hydrostatic:
- return WaterpressureInterpolationModel.Hydrostatic;
+ return CSharpWrapperWaterPressureInterpolationModel.Hydrostatic;
default:
throw new NotSupportedException();
}
Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.Test/Creators/Input/LayerWithSoilCreatorTest.cs
===================================================================
diff -u -r7c9cb4119e99bc0eee2bac686e8ca363ec048bb6 -r6706d60d5fc1100ffdfaac1cec64e6f61ea9be74
--- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.Test/Creators/Input/LayerWithSoilCreatorTest.cs (.../LayerWithSoilCreatorTest.cs) (revision 7c9cb4119e99bc0eee2bac686e8ca363ec048bb6)
+++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.Test/Creators/Input/LayerWithSoilCreatorTest.cs (.../LayerWithSoilCreatorTest.cs) (revision 6706d60d5fc1100ffdfaac1cec64e6f61ea9be74)
@@ -24,15 +24,15 @@
using System.ComponentModel;
using System.Linq;
using Core.Common.TestUtil;
-using Deltares.MacroStability.Geometry;
+using Deltares.MacroStability.CSharpWrapper;
using NUnit.Framework;
using Riskeer.MacroStabilityInwards.KernelWrapper.Calculators.Input;
using Riskeer.MacroStabilityInwards.KernelWrapper.Creators.Input;
using Point2D = Core.Common.Base.Geometry.Point2D;
-using ShearStrengthModel = Riskeer.MacroStabilityInwards.KernelWrapper.Calculators.Input.ShearStrengthModel;
using SoilLayer = Riskeer.MacroStabilityInwards.KernelWrapper.Calculators.Input.SoilLayer;
using SoilProfile = Riskeer.MacroStabilityInwards.KernelWrapper.Calculators.Input.SoilProfile;
-using WtiStabilityShearStrengthModel = Deltares.MacroStability.Geometry.ShearStrengthModel;
+using WaterPressureInterpolationModel = Riskeer.MacroStabilityInwards.KernelWrapper.Calculators.Input.WaterPressureInterpolationModel;
+using CSharpWrapperWaterPressureInterpolationModel = Deltares.MacroStability.CSharpWrapper.Input.WaterPressureInterpolationModel;
namespace Riskeer.MacroStabilityInwards.KernelWrapper.Test.Creators.Input
{
@@ -43,7 +43,7 @@
public void Create_SoilProfileNull_ThrowsArgumentNullException()
{
// Call
- void Call() => LayerWithSoilCreator.Create(null, out IDictionary layerLookup);
+ void Call() => LayerWithSoilCreator.Create(null, out IDictionary _);
// Assert
var exception = Assert.Throws(Call);
@@ -159,7 +159,7 @@
}, Enumerable.Empty());
// Call
- void Call() => LayerWithSoilCreator.Create(profile, out IDictionary layerLookup);
+ void Call() => LayerWithSoilCreator.Create(profile, out IDictionary _);
// Assert
string message = $"The value of argument 'shearStrengthModel' ({99}) is invalid for Enum type '{nameof(ShearStrengthModel)}'.";
@@ -181,17 +181,19 @@
}, Enumerable.Empty());
// Call
- void Call() => LayerWithSoilCreator.Create(profile, out IDictionary layerLookup);
+ void Call() => LayerWithSoilCreator.Create(profile, out IDictionary _);
// Assert
string message = $"The value of argument 'waterPressureInterpolationModel' ({99}) is invalid for Enum type '{nameof(WaterPressureInterpolationModel)}'.";
TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, message);
}
- [TestCase(ShearStrengthModel.CPhi, WtiStabilityShearStrengthModel.CPhi)]
- [TestCase(ShearStrengthModel.CPhiOrSuCalculated, WtiStabilityShearStrengthModel.CPhiOrCuCalculated)]
- [TestCase(ShearStrengthModel.SuCalculated, WtiStabilityShearStrengthModel.CuCalculated)]
- public void Create_ValidShearStrengthModel_ExpectedShearStrengthModel(ShearStrengthModel shearStrengthModel, WtiStabilityShearStrengthModel expectedShearStrengthModel)
+ [TestCase(ShearStrengthModel.CPhi, ShearStrengthModelType.MohrCoulomb, ShearStrengthModelType.MohrCoulomb)]
+ [TestCase(ShearStrengthModel.SuCalculated, ShearStrengthModelType.Shansep, ShearStrengthModelType.Shansep)]
+ [TestCase(ShearStrengthModel.CPhiOrSuCalculated, ShearStrengthModelType.MohrCoulomb, ShearStrengthModelType.Shansep)]
+ public void Create_ValidShearStrengthModel_ExpectedShearStrengthModel(
+ ShearStrengthModel shearStrengthModel, ShearStrengthModelType expectedShearStrengthAbovePhreaticLevelModel,
+ ShearStrengthModelType expectedShearStrengthBelowPhreaticLevelModel)
{
// Setup
var profile = new SoilProfile(new[]
@@ -205,16 +207,17 @@
}, Enumerable.Empty());
// Call
- LayerWithSoil[] layersWithSoil = LayerWithSoilCreator.Create(profile, out IDictionary layerLookup);
+ LayerWithSoil[] layersWithSoil = LayerWithSoilCreator.Create(profile, out IDictionary _);
// Assert
- Assert.AreEqual(expectedShearStrengthModel, layersWithSoil[0].Soil.ShearStrengthModel);
+ Assert.AreEqual(expectedShearStrengthAbovePhreaticLevelModel, layersWithSoil[0].Soil.ShearStrengthAbovePhreaticLevelModel);
+ Assert.AreEqual(expectedShearStrengthBelowPhreaticLevelModel, layersWithSoil[0].Soil.ShearStrengthBelowPhreaticLevelModel);
}
- [TestCase(WaterPressureInterpolationModel.Automatic, WaterpressureInterpolationModel.Automatic)]
- [TestCase(WaterPressureInterpolationModel.Hydrostatic, WaterpressureInterpolationModel.Hydrostatic)]
+ [TestCase(WaterPressureInterpolationModel.Automatic, CSharpWrapperWaterPressureInterpolationModel.Automatic)]
+ [TestCase(WaterPressureInterpolationModel.Hydrostatic, CSharpWrapperWaterPressureInterpolationModel.Hydrostatic)]
public void Create_ValidWaterPressureInterpolationModel_ExpectedWaterPressureInterpolationModel(
- WaterPressureInterpolationModel waterPressureInterpolationModel, WaterpressureInterpolationModel expectedWaterPressureInterpolationModel)
+ WaterPressureInterpolationModel waterPressureInterpolationModel, CSharpWrapperWaterPressureInterpolationModel expectedWaterPressureInterpolationModel)
{
// Setup
var profile = new SoilProfile(new[]
@@ -237,10 +240,11 @@
private static void AssertSoilLayerProperties(SoilLayer soilLayer, LayerWithSoil layerWithSoil)
{
Assert.AreEqual(soilLayer.IsAquifer, layerWithSoil.IsAquifer);
- Assert.AreEqual(WaterpressureInterpolationModel.Hydrostatic, layerWithSoil.WaterPressureInterpolationModel);
+ Assert.AreEqual(WaterPressureInterpolationModel.Hydrostatic, layerWithSoil.WaterPressureInterpolationModel);
Assert.IsNotNull(layerWithSoil.Soil);
- Assert.AreEqual(WtiStabilityShearStrengthModel.CuCalculated, layerWithSoil.Soil.ShearStrengthModel);
+ Assert.AreEqual(ShearStrengthModelType.Shansep, layerWithSoil.Soil.ShearStrengthAbovePhreaticLevelModel);
+ Assert.AreEqual(ShearStrengthModelType.Shansep, layerWithSoil.Soil.ShearStrengthBelowPhreaticLevelModel);
Assert.AreEqual(soilLayer.MaterialName, layerWithSoil.Soil.Name);
Assert.AreEqual(soilLayer.AbovePhreaticLevel, layerWithSoil.Soil.AbovePhreaticLevel);
Assert.AreEqual(soilLayer.BelowPhreaticLevel, layerWithSoil.Soil.BelowPhreaticLevel);
@@ -249,11 +253,6 @@
Assert.AreEqual(soilLayer.ShearStrengthRatio, layerWithSoil.Soil.RatioCuPc);
Assert.AreEqual(soilLayer.StrengthIncreaseExponent, layerWithSoil.Soil.StrengthIncreaseExponent);
Assert.AreEqual(soilLayer.Dilatancy, layerWithSoil.Soil.Dilatancy);
- Assert.IsNaN(layerWithSoil.Soil.RRatio); //Irrelevant
- Assert.IsNaN(layerWithSoil.Soil.RheologicalCoefficient); //Irrelevant
- Assert.IsNotNull(layerWithSoil.Soil.BondStressCurve); //Irrelevant
- Assert.AreEqual(SoilType.Sand, layerWithSoil.Soil.SoilType); //Irrelevant
- Assert.IsFalse(layerWithSoil.Soil.UseSoilType); //Irrelevant
}
private static SoilLayer.ConstructionProperties CreateRandomConstructionProperties(int seed, string materialName)