Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/Ringtoets.MacroStabilityInwards.IO.csproj
===================================================================
diff -u -rab481580593706295cd3af50672dc394ce5fe3ee -r4e0b333b9e7d89ba6563e1b2f9cb011c92c8015f
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/Ringtoets.MacroStabilityInwards.IO.csproj (.../Ringtoets.MacroStabilityInwards.IO.csproj) (revision ab481580593706295cd3af50672dc394ce5fe3ee)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/Ringtoets.MacroStabilityInwards.IO.csproj (.../Ringtoets.MacroStabilityInwards.IO.csproj) (revision 4e0b333b9e7d89ba6563e1b2f9cb011c92c8015f)
@@ -50,6 +50,7 @@
+
Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsSoilLayerTransformer.cs
===================================================================
diff -u
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsSoilLayerTransformer.cs (revision 0)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsSoilLayerTransformer.cs (revision 4e0b333b9e7d89ba6563e1b2f9cb011c92c8015f)
@@ -0,0 +1,120 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU 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 General Public License for more details.
+//
+// You should have received a copy of the GNU 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 Ringtoets.Common.IO.Exceptions;
+using Ringtoets.Common.IO.SoilProfile;
+using Ringtoets.MacroStabilityInwards.Primitives;
+using CommonShearStrengthModel = Ringtoets.Common.IO.SoilProfile.ShearStrengthModel;
+using ShearStrengthModel = Ringtoets.MacroStabilityInwards.Primitives.ShearStrengthModel;
+
+namespace Ringtoets.MacroStabilityInwards.IO.SoilProfiles
+{
+ ///
+ /// Transforms generic into
+ /// or .
+ ///
+ internal static class MacroStabilityInwardsSoilLayerTransformer
+ {
+ ///
+ /// Transforms the generic into a
+ /// .
+ ///
+ /// The soil layer to use in the transformation.
+ /// A based on the given data.
+ /// Thrown when is
+ /// null.
+ /// Thrown when transformation would not result
+ /// in a valid transformed instance.
+ public static MacroStabilityInwardsSoilLayer1D Transform(SoilLayer1D soilLayer)
+ {
+ if (soilLayer == null)
+ {
+ throw new ArgumentNullException(nameof(soilLayer));
+ }
+
+ var layer = new MacroStabilityInwardsSoilLayer1D(soilLayer.Top)
+ {
+ Properties =
+ {
+ MaterialName = soilLayer.MaterialName,
+ IsAquifer = soilLayer.IsAquifer,
+ Color = soilLayer.Color,
+ UsePop = soilLayer.UsePop,
+ AbovePhreaticLevelMean = soilLayer.AbovePhreaticLevelMean,
+ AbovePhreaticLevelDeviation = soilLayer.AbovePhreaticLevelDeviation,
+ BelowPhreaticLevelMean = soilLayer.BelowPhreaticLevelMean,
+ BelowPhreaticLevelDeviation = soilLayer.BelowPhreaticLevelDeviation,
+ CohesionMean = soilLayer.CohesionMean,
+ CohesionDeviation = soilLayer.CohesionDeviation,
+ CohesionShift = soilLayer.CohesionShift,
+ FrictionAngleMean = soilLayer.FrictionAngleMean,
+ FrictionAngleDeviation = soilLayer.FrictionAngleDeviation,
+ FrictionAngleShift = soilLayer.FrictionAngleShift,
+ ShearStrengthRatioMean = soilLayer.ShearStrengthRatioMean,
+ ShearStrengthRatioDeviation = soilLayer.ShearStrengthRatioDeviation,
+ ShearStrengthRatioShift = soilLayer.ShearStrengthRatioShift,
+ StrengthIncreaseExponentMean = soilLayer.StrengthIncreaseExponentMean,
+ StrengthIncreaseExponentDeviation = soilLayer.StrengthIncreaseExponentDeviation,
+ StrengthIncreaseExponentShift = soilLayer.StrengthIncreaseExponentShift,
+ PopMean = soilLayer.PopMean,
+ PopDeviation = soilLayer.PopDeviation,
+ PopShift = soilLayer.PopShift
+ }
+ };
+
+ try
+ {
+ layer.Properties.ShearStrengthModel = TransformShearStrengthModel(soilLayer.ShearStrengthModel);
+ }
+ catch (NotSupportedException e)
+ {
+ throw new ImportedDataTransformException("Er ging iets mis met transformeren.", e);
+ }
+
+ return layer;
+ }
+
+ ///
+ /// Transforms the to .
+ ///
+ /// The model to transform.
+ /// A based on the given data.
+ /// Thrown when
+ /// has an invalid value.
+ private static ShearStrengthModel TransformShearStrengthModel(CommonShearStrengthModel shearStrengthModel)
+ {
+ switch (shearStrengthModel)
+ {
+ case CommonShearStrengthModel.None:
+ return ShearStrengthModel.None;
+ case CommonShearStrengthModel.SuCalculated:
+ return ShearStrengthModel.SuCalculated;
+ case CommonShearStrengthModel.CPhi:
+ return ShearStrengthModel.CPhi;
+ case CommonShearStrengthModel.CPhiOrSuCalculated:
+ return ShearStrengthModel.CPhiOrSuCalculated;
+ default:
+ throw new NotSupportedException();
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/ShearStrengthModel.cs
===================================================================
diff -u -r9caa7daa14d0070e2a3f68c4b9e66109318bd9ab -r4e0b333b9e7d89ba6563e1b2f9cb011c92c8015f
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/ShearStrengthModel.cs (.../ShearStrengthModel.cs) (revision 9caa7daa14d0070e2a3f68c4b9e66109318bd9ab)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Primitives/ShearStrengthModel.cs (.../ShearStrengthModel.cs) (revision 4e0b333b9e7d89ba6563e1b2f9cb011c92c8015f)
@@ -21,11 +21,14 @@
namespace Ringtoets.MacroStabilityInwards.Primitives
{
+ ///
+ /// All shear strength model types.
+ ///
public enum ShearStrengthModel
{
- None,
- SuCalculated,
- CPhi,
- CPhiOrSuCalculated
+ None = 1,
+ SuCalculated = 2,
+ CPhi = 3,
+ CPhiOrSuCalculated = 4
}
}
\ No newline at end of file
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/Ringtoets.MacroStabilityInwards.IO.Test.csproj
===================================================================
diff -u -rab481580593706295cd3af50672dc394ce5fe3ee -r4e0b333b9e7d89ba6563e1b2f9cb011c92c8015f
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/Ringtoets.MacroStabilityInwards.IO.Test.csproj (.../Ringtoets.MacroStabilityInwards.IO.Test.csproj) (revision ab481580593706295cd3af50672dc394ce5fe3ee)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/Ringtoets.MacroStabilityInwards.IO.Test.csproj (.../Ringtoets.MacroStabilityInwards.IO.Test.csproj) (revision 4e0b333b9e7d89ba6563e1b2f9cb011c92c8015f)
@@ -78,6 +78,7 @@
+
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsSoilLayerTransformerTest.cs
===================================================================
diff -u
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsSoilLayerTransformerTest.cs (revision 0)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsSoilLayerTransformerTest.cs (revision 4e0b333b9e7d89ba6563e1b2f9cb011c92c8015f)
@@ -0,0 +1,178 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU 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 General Public License for more details.
+//
+// You should have received a copy of the GNU 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.Drawing;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Ringtoets.Common.IO.Exceptions;
+using Ringtoets.Common.IO.SoilProfile;
+using Ringtoets.MacroStabilityInwards.IO.SoilProfiles;
+using Ringtoets.MacroStabilityInwards.Primitives;
+using CommonShearStrengthModel = Ringtoets.Common.IO.SoilProfile.ShearStrengthModel;
+using ShearStrengthModel = Ringtoets.MacroStabilityInwards.Primitives.ShearStrengthModel;
+
+namespace Ringtoets.MacroStabilityInwards.IO.Test.SoilProfiles
+{
+ [TestFixture]
+ public class MacroStabilityInwardsSoilLayerTransformerTest
+ {
+ [Test]
+ public void SoilLayer1DTransform_SoilLayer1DNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => MacroStabilityInwardsSoilLayerTransformer.Transform(null);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("soilLayer", exception.ParamName);
+ }
+
+ [Test]
+ public void SoilLayer1DTransform_PropertiesSetAndValid_ReturnMacroStabilityInwardSoilLayer1D()
+ {
+ // Setup
+ var random = new Random(22);
+
+ bool isAquifer = random.NextBoolean();
+ double top = random.NextDouble();
+ const string materialName = "materialX";
+ Color color = Color.AliceBlue;
+ bool usePop = random.NextBoolean();
+ var shearStrengthModel = random.NextEnumValue();
+
+ double abovePhreaticLevelMean = random.NextDouble();
+ double abovePhreaticLevelDeviation = random.NextDouble();
+ double belowPhreaticLevelMean = random.NextDouble();
+ double belowPhreaticLevelDeviation = random.NextDouble();
+ double cohesionMean = random.NextDouble();
+ double cohesionDeviation = random.NextDouble();
+ double cohesionShift = random.NextDouble();
+ double frictionAngleMean = random.NextDouble();
+ double frictionAngleDeviation = random.NextDouble();
+ double frictionAngleShift = random.NextDouble();
+ double shearStrengthRatioMean = random.NextDouble();
+ double shearStrengthRatioDeviation = random.NextDouble();
+ double shearStrengthRatioShift = random.NextDouble();
+ double strengthIncreaseExponentMean = random.NextDouble();
+ double strengthIncreaseExponentDeviation = random.NextDouble();
+ double strengthIncreaseExponentShift = random.NextDouble();
+ double popMean = random.NextDouble();
+ double popDeviation = random.NextDouble();
+ double popShift = random.NextDouble();
+
+ var layer = new SoilLayer1D(top)
+ {
+ IsAquifer = isAquifer,
+ MaterialName = materialName,
+ Color = color,
+ UsePop = usePop,
+ ShearStrengthModel = shearStrengthModel,
+ AbovePhreaticLevelMean = abovePhreaticLevelMean,
+ AbovePhreaticLevelDeviation = abovePhreaticLevelDeviation,
+ BelowPhreaticLevelMean = belowPhreaticLevelMean,
+ BelowPhreaticLevelDeviation = belowPhreaticLevelDeviation,
+ CohesionMean = cohesionMean,
+ CohesionDeviation = cohesionDeviation,
+ CohesionShift = cohesionShift,
+ FrictionAngleMean = frictionAngleMean,
+ FrictionAngleDeviation = frictionAngleDeviation,
+ FrictionAngleShift = frictionAngleShift,
+ ShearStrengthRatioMean = shearStrengthRatioMean,
+ ShearStrengthRatioDeviation = shearStrengthRatioDeviation,
+ ShearStrengthRatioShift = shearStrengthRatioShift,
+ StrengthIncreaseExponentMean = strengthIncreaseExponentMean,
+ StrengthIncreaseExponentDeviation = strengthIncreaseExponentDeviation,
+ StrengthIncreaseExponentShift = strengthIncreaseExponentShift,
+ PopMean = popMean,
+ PopDeviation = popDeviation,
+ PopShift = popShift
+ };
+
+ // Call
+ MacroStabilityInwardsSoilLayer1D soilLayer1D = MacroStabilityInwardsSoilLayerTransformer.Transform(layer);
+
+ // Assert
+ Assert.AreEqual(top, soilLayer1D.Top);
+
+ SoilLayerProperties properties = soilLayer1D.Properties;
+ Assert.AreEqual(isAquifer, properties.IsAquifer);
+ Assert.AreEqual(materialName, properties.MaterialName);
+ Assert.AreEqual(color, properties.Color);
+ Assert.AreEqual(usePop, properties.UsePop);
+ Assert.AreEqual(GetMacroStabilityInwardsShearStrengthModel(shearStrengthModel), properties.ShearStrengthModel);
+ Assert.AreEqual(abovePhreaticLevelMean, properties.AbovePhreaticLevelMean);
+ Assert.AreEqual(abovePhreaticLevelDeviation, properties.AbovePhreaticLevelDeviation);
+ Assert.AreEqual(belowPhreaticLevelMean, properties.BelowPhreaticLevelMean);
+ Assert.AreEqual(belowPhreaticLevelDeviation, properties.BelowPhreaticLevelDeviation);
+ Assert.AreEqual(cohesionMean, properties.CohesionMean);
+ Assert.AreEqual(cohesionDeviation, properties.CohesionDeviation);
+ Assert.AreEqual(cohesionShift, properties.CohesionShift);
+ Assert.AreEqual(frictionAngleMean, properties.FrictionAngleMean);
+ Assert.AreEqual(frictionAngleDeviation, properties.FrictionAngleDeviation);
+ Assert.AreEqual(frictionAngleShift, properties.FrictionAngleShift);
+ Assert.AreEqual(shearStrengthRatioMean, properties.ShearStrengthRatioMean);
+ Assert.AreEqual(shearStrengthRatioDeviation, properties.ShearStrengthRatioDeviation);
+ Assert.AreEqual(shearStrengthRatioShift, properties.ShearStrengthRatioShift);
+ Assert.AreEqual(strengthIncreaseExponentMean, properties.StrengthIncreaseExponentMean);
+ Assert.AreEqual(strengthIncreaseExponentDeviation, properties.StrengthIncreaseExponentDeviation);
+ Assert.AreEqual(strengthIncreaseExponentShift, properties.StrengthIncreaseExponentShift);
+ Assert.AreEqual(popMean, properties.PopMean);
+ Assert.AreEqual(popDeviation, properties.PopDeviation);
+ Assert.AreEqual(popShift, properties.PopShift);
+ }
+
+ [Test]
+ public void SoilLayer1DTransform_InvalidShearStrengthModel_ThrowImportedDataTransformException()
+ {
+ // Setup
+ var layer = new SoilLayer1D(1)
+ {
+ ShearStrengthModel = (CommonShearStrengthModel) 99
+ };
+
+ // Call
+ TestDelegate test = () => MacroStabilityInwardsSoilLayerTransformer.Transform(layer);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("Er ging iets mis met transformeren.", exception.Message);
+ Assert.IsInstanceOf(exception.InnerException);
+ }
+
+ private ShearStrengthModel GetMacroStabilityInwardsShearStrengthModel(CommonShearStrengthModel shearStrengthModel)
+ {
+ switch (shearStrengthModel)
+ {
+ case CommonShearStrengthModel.None:
+ return ShearStrengthModel.None;
+ case CommonShearStrengthModel.SuCalculated:
+ return ShearStrengthModel.SuCalculated;
+ case CommonShearStrengthModel.CPhi:
+ return ShearStrengthModel.CPhi;
+ case CommonShearStrengthModel.CPhiOrSuCalculated:
+ return ShearStrengthModel.CPhiOrSuCalculated;
+ default:
+ throw new ArgumentOutOfRangeException(nameof(shearStrengthModel), shearStrengthModel, null);
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingSoilLayerTransformer.cs
===================================================================
diff -u -r09693d79085118c47709b7059ab7c1ef459ad2aa -r4e0b333b9e7d89ba6563e1b2f9cb011c92c8015f
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingSoilLayerTransformer.cs (.../PipingSoilLayerTransformer.cs) (revision 09693d79085118c47709b7059ab7c1ef459ad2aa)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingSoilLayerTransformer.cs (.../PipingSoilLayerTransformer.cs) (revision 4e0b333b9e7d89ba6563e1b2f9cb011c92c8015f)
@@ -37,8 +37,7 @@
internal static class PipingSoilLayerTransformer
{
///
- /// Transforms the generic into a piping specific
- /// soil profile of type .
+ /// Transforms the generic into a .
///
/// The soil layer to use in the transformation.
/// A new based on the given data.
@@ -61,7 +60,7 @@
Color = soilLayer.Color
};
- SetOptionalStochasticParameters(pipingSoilLayer, soilLayer);
+ SetStochasticParameters(pipingSoilLayer, soilLayer);
return pipingSoilLayer;
}
@@ -108,7 +107,7 @@
Color = soilLayer.Color
};
- SetOptionalStochasticParameters(pipingSoilLayer, soilLayer);
+ SetStochasticParameters(pipingSoilLayer, soilLayer);
soilLayers.Add(pipingSoilLayer);
}
@@ -144,7 +143,7 @@
/// The to get the properties from.
/// This method does not perform validation. Use to
/// verify whether the distributions for the stochastic parameters are correctly defined.
- private static void SetOptionalStochasticParameters(PipingSoilLayer pipingSoilLayer, SoilLayerBase soilLayer1D)
+ private static void SetStochasticParameters(PipingSoilLayer pipingSoilLayer, SoilLayerBase soilLayer1D)
{
pipingSoilLayer.BelowPhreaticLevelMean = soilLayer1D.BelowPhreaticLevelMean;
pipingSoilLayer.BelowPhreaticLevelDeviation = soilLayer1D.BelowPhreaticLevelDeviation;