Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/ConversionHelperTests.cs
===================================================================
diff -u
--- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/ConversionHelperTests.cs (revision 0)
+++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/ConversionHelperTests.cs (revision 1993)
@@ -0,0 +1,119 @@
+// Copyright (C) Stichting Deltares 2019. 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.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Deltares.DamEngine.Calculators.KernelWrappers.MacroStabilityCommon.MacroStabilityIo;
+using Deltares.DamEngine.Data.General;
+using Deltares.DamEngine.Io.XmlInput;
+using Deltares.MacroStability.Data;
+using Deltares.MacroStability.Geometry;
+using NUnit.Framework;
+
+namespace Deltares.DamEngine.Calculators.Tests.KernelWrappers.MacroStabilityCommon
+{
+ [TestFixture]
+ public class ConversionHelperTests
+ {
+ #region SearchMethod
+ [Test]
+ [TestCase(SearchAlgorithm.Grid, MStabSearchMethod.Grid)]
+ [TestCase(SearchAlgorithm.Genetic, MStabSearchMethod.GeneticAlgorithm)]
+ public void CanConvertToDamSearchMethod(SearchAlgorithm searchAlgorithm, MStabSearchMethod mStabSearchMethod)
+ {
+ Assert.AreEqual(mStabSearchMethod, ConversionHelper.ConvertToDamSearchMethod(searchAlgorithm));
+ }
+
+ [ExpectedException(typeof(ArgumentException))]
+ [TestCase(SearchAlgorithm.Beeswarm)]
+ [TestCase(SearchAlgorithm.LevenbergMarquardt)]
+ [TestCase(SearchAlgorithm.Single)]
+ public void CanConvertToDamSearchMethodHandleException(SearchAlgorithm searchAlgorithm)
+ {
+ ConversionHelper.ConvertToDamSearchMethod(searchAlgorithm);
+ }
+
+ [Test]
+ [TestCase(MStabSearchMethod.Grid, SearchAlgorithm.Grid)]
+ [TestCase(MStabSearchMethod.GeneticAlgorithm, SearchAlgorithm.Genetic)]
+ public void ConvertToMacroStabilitySearchMethod(MStabSearchMethod mStabSearchMethod, SearchAlgorithm searchAlgorithm)
+ {
+ Assert.AreEqual(searchAlgorithm, ConversionHelper.ConvertToMacroStabilitySearchMethod(mStabSearchMethod));
+ }
+
+ #endregion
+
+ #region ModelType
+ [Test]
+ [TestCase(ModelOptions.Bishop, MStabModelType.Bishop)]
+ [TestCase(ModelOptions.BishopProbabilityRandomField, MStabModelType.BishopRandomField)]
+ [TestCase(ModelOptions.Fellenius, MStabModelType.Fellenius)]
+ [TestCase(ModelOptions.HorizontalBalance, MStabModelType.HorizontalBalance)]
+ [TestCase(ModelOptions.Spencer, MStabModelType.Spencer)]
+ [TestCase(ModelOptions.UpliftSpencer, MStabModelType.UpliftSpencer)]
+ [TestCase(ModelOptions.UpliftVan, MStabModelType.UpliftVan)]
+ public void CanConvertToMStabModelType(ModelOptions modelOption, MStabModelType mStabModelType)
+ {
+ Assert.AreEqual(mStabModelType, ConversionHelper.ConvertToMStabModelType(modelOption));
+ }
+
+ [Test]
+ [TestCase(MStabModelType.Bishop, ModelOptions.Bishop)]
+ [TestCase(MStabModelType.BishopRandomField, ModelOptions.BishopProbabilityRandomField)]
+ [TestCase(MStabModelType.Fellenius, ModelOptions.Fellenius)]
+ [TestCase(MStabModelType.HorizontalBalance, ModelOptions.HorizontalBalance)]
+ [TestCase(MStabModelType.Spencer, ModelOptions.Spencer)]
+ [TestCase(MStabModelType.UpliftSpencer, ModelOptions.UpliftSpencer)]
+ [TestCase(MStabModelType.UpliftVan, ModelOptions.UpliftVan)]
+ public void CanConvertToModelOptions(MStabModelType mStabModelType, ModelOptions modelOption)
+ {
+ Assert.AreEqual(modelOption, ConversionHelper.ConvertToModelOptions(mStabModelType));
+ }
+
+ [ExpectedException(typeof(ArgumentException))]
+ [TestCase(MStabModelType.SpencerLow)]
+ [TestCase(MStabModelType.SpencerHigh)]
+ public void CanConvertToModelOptionsHandleException(MStabModelType mStabModelType)
+ {
+ ConversionHelper.ConvertToModelOptions(mStabModelType);
+ }
+
+ #endregion
+
+ #region GridOrientation
+ [TestCase(GridOrientation.Outwards, MStabGridPosition.Left)]
+ [TestCase(GridOrientation.Inwards, MStabGridPosition.Right)]
+ public static void CanConvertToMStabGridPosition(GridOrientation gridOrientation, MStabGridPosition mStabGridPosition)
+ {
+ Assert.AreEqual(mStabGridPosition, ConversionHelper.ConvertToMStabGridPosition(gridOrientation));
+ }
+ [TestCase(MStabGridPosition.Left, GridOrientation.Outwards)]
+ [TestCase(MStabGridPosition.Right, GridOrientation.Inwards)]
+ public static void CanConvertToGridOrientation(MStabGridPosition mStabGridPosition, GridOrientation gridOrientation)
+ {
+ Assert.AreEqual(gridOrientation, ConversionHelper.ConvertToGridOrientation(mStabGridPosition));
+ }
+ #endregion
+ }
+}
Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/Deltares.DamEngine.Calculators.Tests.csproj
===================================================================
diff -u -r1988 -r1993
--- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/Deltares.DamEngine.Calculators.Tests.csproj (.../Deltares.DamEngine.Calculators.Tests.csproj) (revision 1988)
+++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/Deltares.DamEngine.Calculators.Tests.csproj (.../Deltares.DamEngine.Calculators.Tests.csproj) (revision 1993)
@@ -36,6 +36,14 @@
False
..\..\lib\FailureMechanisms\DamMacroStability\Deltares.DamMacroStability.Calculator.dll
+
+ False
+ ..\..\lib\FailureMechanisms\Macrostability\Deltares.MacroStability.Data.dll
+
+
+ False
+ ..\..\lib\FailureMechanisms\Macrostability\Deltares.MacroStability.Geometry.dll
+
False
..\..\lib\FailureMechanisms\Macrostability\Deltares.MacroStability.Kernel.dll
@@ -63,6 +71,7 @@
+
Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/ConversionHelper.cs
===================================================================
diff -u
--- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/ConversionHelper.cs (revision 0)
+++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/ConversionHelper.cs (revision 1993)
@@ -0,0 +1,137 @@
+// Copyright (C) Stichting Deltares 2019. 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 Deltares.DamEngine.Data.General;
+using Deltares.MacroStability.Data;
+using Deltares.MacroStability.Geometry;
+
+namespace Deltares.DamEngine.Calculators.KernelWrappers.MacroStabilityCommon.MacroStabilityIo
+{
+ public static class ConversionHelper
+ {
+ #region SearchMethod
+ /// Converts SearchAlgorithm to MStabSearchMethod.
+ /// The MacroStability search algorithm.
+ ///
+ ///
+ public static MStabSearchMethod ConvertToDamSearchMethod(SearchAlgorithm searchAlgorithm)
+ {
+ if (searchAlgorithm != SearchAlgorithm.Grid && searchAlgorithm != SearchAlgorithm.Genetic)
+ {
+ throw new ArgumentException(String.Format("Unsupported search algorithm: {0}", searchAlgorithm));
+ }
+ var translationTable = new Dictionary()
+ {
+ {SearchAlgorithm.Genetic, MStabSearchMethod.GeneticAlgorithm},
+ {SearchAlgorithm.Grid, MStabSearchMethod.Grid}
+ };
+ return translationTable[searchAlgorithm];
+ }
+
+ /// Converts MStabSearchMethod to SearchAlgorithm.
+ /// The Dam search algorithm.
+ ///
+ ///
+ public static SearchAlgorithm ConvertToMacroStabilitySearchMethod(MStabSearchMethod mStabSearchMethod)
+ {
+ var translationTable = new Dictionary()
+ {
+ {MStabSearchMethod.GeneticAlgorithm, SearchAlgorithm.Genetic},
+ {MStabSearchMethod.Grid, SearchAlgorithm.Grid}
+ };
+ return translationTable[mStabSearchMethod];
+ }
+
+ #endregion
+ #region ModelType
+ /// Converts ModelOption to the MStabModelType.
+ /// The model option.
+ /// the Dam MStabModelType
+ public static MStabModelType ConvertToMStabModelType(ModelOptions modelOption)
+ {
+ var translationTable = new Dictionary()
+ {
+ {ModelOptions.Bishop, MStabModelType.Bishop},
+ {ModelOptions.BishopProbabilityRandomField, MStabModelType.BishopRandomField},
+ {ModelOptions.Fellenius, MStabModelType.Fellenius},
+ {ModelOptions.HorizontalBalance, MStabModelType.HorizontalBalance},
+ {ModelOptions.Spencer, MStabModelType.Spencer},
+ {ModelOptions.UpliftSpencer, MStabModelType.UpliftSpencer},
+ {ModelOptions.UpliftVan, MStabModelType.UpliftVan}
+ };
+ return translationTable[modelOption];
+ }
+
+ /// Converts to ModelOptions type.
+ /// the MStabModelType.
+ /// the MacroStability ModelOption
+ ///
+ public static ModelOptions ConvertToModelOptions(MStabModelType mStabModelType)
+ {
+ if (mStabModelType == MStabModelType.SpencerHigh || mStabModelType == MStabModelType.SpencerLow)
+ {
+ throw new ArgumentException(String.Format("Unsupported MStabModelType: {0}", mStabModelType));
+ }
+ var translationTable = new Dictionary()
+ {
+ {MStabModelType.Bishop, ModelOptions.Bishop},
+ {MStabModelType.BishopRandomField, ModelOptions.BishopProbabilityRandomField},
+ {MStabModelType.Fellenius, ModelOptions.Fellenius},
+ {MStabModelType.HorizontalBalance, ModelOptions.HorizontalBalance},
+ {MStabModelType.Spencer, ModelOptions.Spencer},
+ {MStabModelType.UpliftSpencer, ModelOptions.UpliftSpencer},
+ {MStabModelType.UpliftVan, ModelOptions.UpliftVan}
+ };
+ return translationTable[mStabModelType];
+ }
+ #endregion
+
+ #region GridOrientation
+ /// Converts to MStabGridPosition.
+ /// The grid orientation.
+ ///
+ public static MStabGridPosition ConvertToMStabGridPosition(GridOrientation gridOrientation)
+ {
+ var translationTable = new Dictionary()
+ {
+ {GridOrientation.Inwards, MStabGridPosition.Right},
+ {GridOrientation.Outwards, MStabGridPosition.Left}
+ };
+ return translationTable[gridOrientation];
+ }
+
+ /// Converts to GridOrientation.
+ /// The MStabGridPosition.
+ ///
+ public static GridOrientation ConvertToGridOrientation(MStabGridPosition mStabGridPosition)
+ {
+ var translationTable = new Dictionary()
+ {
+ {MStabGridPosition.Right, GridOrientation.Inwards},
+ {MStabGridPosition.Left, GridOrientation.Outwards}
+ };
+ return translationTable[mStabGridPosition];
+ }
+ #endregion
+ }
+}
Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/Deltares.DamEngine.Calculators.csproj
===================================================================
diff -u -r1987 -r1993
--- DamEngine/trunk/src/Deltares.DamEngine.Calculators/Deltares.DamEngine.Calculators.csproj (.../Deltares.DamEngine.Calculators.csproj) (revision 1987)
+++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/Deltares.DamEngine.Calculators.csproj (.../Deltares.DamEngine.Calculators.csproj) (revision 1993)
@@ -105,6 +105,7 @@
+
Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/FillWtiFromDamEngine.cs
===================================================================
diff -u -r1989 -r1993
--- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/FillWtiFromDamEngine.cs (.../FillWtiFromDamEngine.cs) (revision 1989)
+++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/FillWtiFromDamEngine.cs (.../FillWtiFromDamEngine.cs) (revision 1993)
@@ -70,7 +70,14 @@
private static void TransferWtiStabilityModel(DamProjectData damProjectData, StabilityModel stabilityModel)
{
-
+ stabilityModel.MoveGrid = true; // is not in DamEngine datamodel
+ stabilityModel.MaximumSliceWidth = 1.0; // is not in DamEngine datamodel
+ stabilityModel.SearchAlgorithm = ConversionHelper.ConvertToMacroStabilitySearchMethod(
+ damProjectData.DamProjectCalculationSpecification.CurrentSpecification.FailureMechanismParametersMStab.MStabParameters.SearchMethod);
+ stabilityModel.ModelOption = ConversionHelper.ConvertToModelOptions(
+ damProjectData.DamProjectCalculationSpecification.CurrentSpecification.FailureMechanismParametersMStab.MStabParameters.Model);
+ stabilityModel.GridOrientation = ConversionHelper.ConvertToGridOrientation(
+ damProjectData.DamProjectCalculationSpecification.CurrentSpecification.FailureMechanismParametersMStab.MStabParameters.GridPosition);
}
private static void TransferVersionInfo()
Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/MacroStabilityIoTests.cs
===================================================================
diff -u -r1987 -r1993
--- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/MacroStabilityIoTests.cs (.../MacroStabilityIoTests.cs) (revision 1987)
+++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/MacroStabilityIoTests.cs (.../MacroStabilityIoTests.cs) (revision 1993)
@@ -74,7 +74,7 @@
private DamProjectData CreateExampleDamProjectData()
{
- return new DamProjectData();
+ return TestDataCreator.CreateExampleDamProjectData();
}
[TestCase("ValidateOk.xml")]