Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/Properties/Resources.resx
===================================================================
diff -u -r1001 -r1036
--- DamEngine/trunk/src/Deltares.DamEngine.Calculators/Properties/Resources.resx (.../Resources.resx) (revision 1001)
+++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/Properties/Resources.resx (.../Resources.resx) (revision 1036)
@@ -165,4 +165,7 @@
The use of Zone Areas is not allowed for stability outside.
+
+ Model horizontal balance does not support 2d-geometries.
+
\ No newline at end of file
Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/Deltares.DamEngine.Calculators.Tests.csproj
===================================================================
diff -u -r1032 -r1036
--- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/Deltares.DamEngine.Calculators.Tests.csproj (.../Deltares.DamEngine.Calculators.Tests.csproj) (revision 1032)
+++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/Deltares.DamEngine.Calculators.Tests.csproj (.../Deltares.DamEngine.Calculators.Tests.csproj) (revision 1036)
@@ -53,6 +53,7 @@
+
Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/Properties/Resources.nl-NL.resx
===================================================================
diff -u -r1001 -r1036
--- DamEngine/trunk/src/Deltares.DamEngine.Calculators/Properties/Resources.nl-NL.resx (.../Resources.nl-NL.resx) (revision 1001)
+++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/Properties/Resources.nl-NL.resx (.../Resources.nl-NL.resx) (revision 1036)
@@ -117,6 +117,9 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ Model Horizontaal Evenwicht ondersteunt geen 2D profielen.
+
Het gebruik van zones is niet toegestaan voor buitenwaardse stabiliteit.
Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/DamMacroStabilityHorizontalBalance/DamMacroStabilityHorizontalBalanceKernelWrapper.cs
===================================================================
diff -u
--- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/DamMacroStabilityHorizontalBalance/DamMacroStabilityHorizontalBalanceKernelWrapper.cs (revision 0)
+++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/DamMacroStabilityHorizontalBalance/DamMacroStabilityHorizontalBalanceKernelWrapper.cs (revision 1036)
@@ -0,0 +1,264 @@
+// Copyright (C) Stichting Deltares 2018. 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.Data;
+using System.IO;
+using System.Xml.Linq;
+using Deltares.DamEngine.Calculators.KernelWrappers.Common;
+using Deltares.DamEngine.Calculators.KernelWrappers.DamMacroStabilityCommon;
+using Deltares.DamEngine.Calculators.KernelWrappers.Interfaces;
+using Deltares.DamEngine.Calculators.Properties;
+using Deltares.DamEngine.Data.General;
+using Deltares.DamEngine.Data.General.Results;
+using Deltares.DamEngine.Data.Standard.Calculation;
+using Deltares.DamEngine.Data.Standard.Logging;
+using Deltares.DamMacroStability.Calculator;
+
+namespace Deltares.DamEngine.Calculators.KernelWrappers.DamMacroStabilityHorizontalBalance
+{
+ ///
+ /// Class for the wrapper around the Stability Horizontal Balance calculator
+ ///
+ ///
+ public class DamMacroStabilityHorizontalBalanceKernelWrapper: IKernelWrapper
+ {
+
+ ///
+ /// Gets or sets the failure mechanisme paramaters for mstab.
+ ///
+ ///
+ /// The failure mechanisme paramaters mstab.
+ ///
+ public FailureMechanismParametersMStab FailureMechanismParametersMStab { get; set; }
+
+ ///
+ /// Prepares the failure mechanism input based on general dam kernel input.
+ ///
+ /// The dam kernel input.
+ /// The number of the current iteration
+ /// The kernel data input.
+ /// The kernel data output.
+ ///
+ /// Result of the prepare
+ ///
+ public PrepareResult Prepare(DamKernelInput damKernelInput, int iterationIndex, out IKernelDataInput kernelDataInput, out IKernelDataOutput kernelDataOutput)
+ {
+ var damMacroStabilityOutput = new DamMacroStabilityOutput()
+ {
+ StabilityOutputItems = new List(),
+ CalculationResult = CalculationResult.NoRun
+ };
+ kernelDataOutput = damMacroStabilityOutput;
+ if (damKernelInput.SubSoilScenario.SegmentFailureMechanismType == FailureMechanismSystemType.HorizontalBalance)
+ {
+ FailureMechanismParametersMStab.MStabParameters.Model = MStabModelType.HorizontalBalance;
+ FailureMechanismParametersMStab.ProjectWorkingPath = damKernelInput.CalculationDir;
+
+ kernelDataOutput = damMacroStabilityOutput;
+
+ var damMacroStabilityInput = new DamMacroStabilityInput()
+ {
+ DGeoStabilityExePath = FailureMechanismParametersMStab.DGeoStabilityExePath,
+ DGeoStabilityInputFileName = DamMacroStabilityUtils.GetStabilityInputFileName(damKernelInput, iterationIndex,
+ FailureMechanismParametersMStab.MStabParameters.Model, FailureMechanismParametersMStab.ProjectWorkingPath),
+ FailureMechanismParametersMStab = FailureMechanismParametersMStab
+ };
+ kernelDataInput = damMacroStabilityInput;
+
+ // Write xml file
+ XDocument xmlDocument = CreateMstabDamXmlDocument(damKernelInput, damMacroStabilityInput);
+
+ // Use xml file to create sti file
+ CreateStiFile(xmlDocument);
+
+ return PrepareResult.Successful;
+ }
+ kernelDataInput = null;
+ return PrepareResult.NotRelevant;
+ }
+
+ ///
+ /// Validates the kernel data input.
+ ///
+ /// The kernel data input.
+ /// The kernel data output.
+ /// The messages.
+ ///
+ /// Number of errors that prevent a calculation
+ ///
+ public int Validate(IKernelDataInput kernelDataInput, IKernelDataOutput kernelDataOutput, out List messages)
+ {
+ var input = (DamMacroStabilityInput)kernelDataInput;
+ messages = new List();
+ return messages.Count;
+ }
+
+ ///
+ /// Performs a failure mechanism calculation based on the input.
+ ///
+ /// The kernel data input.
+ /// The kernel data output.
+ /// The messages.
+ public void Execute(IKernelDataInput kernelDataInput, IKernelDataOutput kernelDataOutput, out List messages)
+ {
+ DamMacroStabilityOutput damMacroStabilityOutput = (DamMacroStabilityOutput)kernelDataOutput;
+ messages = new List();
+
+ // start calculation
+ var calculator = StabilityCalculator(kernelDataInput);
+ calculator.Calculate();
+
+ // get results
+ var results = calculator.GetResults();
+ if (results.Count > 0)
+ {
+ var damMacroStabilityOutputItem = new DamMacroStabilityOutputItem();
+ // For Horizontal balance only zone 1 is used to give back the results.
+ var zone1 = new DamMacroStabilityOutputItem.ResultsSingleZone
+ {
+ SafetyFactor = results[0].Zone1.SafetyFactor,
+ //#Bka: I think only safetyfactor is relevant.
+ CircleSurfacePointLeftXCoordinate = results[0].Zone1.CircleSurfacePointLeftXCoordinate,
+ CircleSurfacePointRightXCoordinate = results[0].Zone1.CircleSurfacePointRightXCoordinate,
+ };
+ damMacroStabilityOutputItem.Zone1Results = zone1;
+ damMacroStabilityOutput.StabilityOutputItems.Add(damMacroStabilityOutputItem);
+ }
+ }
+
+ ///
+ /// Fills the dam result based on the kernel output.
+ ///
+ /// The dam kernel input.
+ /// The kernel data output.
+ /// The result message.
+ /// The design results
+ ///
+ ///
+ public void PostProcess(DamKernelInput damKernelInput, IKernelDataOutput kernelDataOutput, string resultMessage, out List designResults)
+ {
+ DamMacroStabilityOutput damMacroStabilityOutput = kernelDataOutput as DamMacroStabilityOutput;
+ if (damKernelInput == null)
+ {
+ throw new NoNullAllowedException(Resources.DamMacroStabilityKernelWrapper_StabilityCalculator_NoInputObjectDefinedForMacroStability);
+ }
+ if (damMacroStabilityOutput == null)
+ {
+ throw new NoNullAllowedException(Resources.DamMacroStabilityKernelWrapper_PostProcess_NoOutputObjectDefinedForMacroStability);
+ }
+
+ string soilProfile2DName = damKernelInput.SubSoilScenario.ToString();
+
+ designResults = new List();
+ var designResult = new DesignResult(damKernelInput.DamFailureMechanismeCalculationSpecification,
+ damKernelInput.DesignScenario, damKernelInput.SubSoilScenario.SoilProfile1D, soilProfile2DName,
+ DamProjectCalculationSpecification.SelectedAnalysisType)
+ {
+ // initialize as failed
+ CalculationResult = CalculationResult.RunFailed
+ };
+ // Outwards can have only one result as BishopUpliftVan as model is not allowed
+ if (damMacroStabilityOutput.StabilityOutputItems.Count == 1)
+ {
+ var damMacroStabilityOutputItem = damMacroStabilityOutput.StabilityOutputItems[0];
+ var stabilityDesignResults = new StabilityDesignResults
+ {
+ Zone1SafetyFactor = damMacroStabilityOutputItem.Zone1Results.SafetyFactor,
+ //#Bka: zonepoints are probably irrelevant.
+ LocalZone1EntryPointX = damMacroStabilityOutputItem.Zone1Results.CircleSurfacePointRightXCoordinate,
+ LocalZone1ExitPointX = damMacroStabilityOutputItem.Zone1Results.CircleSurfacePointLeftXCoordinate,
+ ResultMessage = resultMessage,
+ UpliftSituation = null
+ };
+ stabilityDesignResults.SafetyFactor = stabilityDesignResults.Zone1SafetyFactor;
+ stabilityDesignResults.RedesignedSurfaceLine = damKernelInput.Location.SurfaceLine;
+ designResult.StabilityDesignResults = stabilityDesignResults;
+ designResult.CalculationResult = damMacroStabilityOutputItem.CalculationResult;
+ designResult.CalculationSubDir = DamMacroStabilityUtils.GetCalculationSubDir(damKernelInput.DamFailureMechanismeCalculationSpecification.StabilityModelType);
+ }
+ designResults.Add(designResult);
+ }
+
+
+ ///
+ /// Creates the mstab dam XML document.
+ ///
+ /// The dam kernel input.
+ /// The kernel data input.
+ ///
+ ///
+ internal XDocument CreateMstabDamXmlDocument(DamKernelInput damKernelInput, DamMacroStabilityInput kernelDataInput)
+ {
+ var stabilityProjectFilename = kernelDataInput.DGeoStabilityInputFileName;
+ var scenario = damKernelInput.DesignScenario;
+ var subSoilScenario = damKernelInput.SubSoilScenario;
+ // There is no required safety for Horizontal Balannce (not used in design as of yet) so just use 1.0 instead.
+ var requiredSafetyFactor = 1.0;
+ List errorMessages;
+
+ XDocument mstabXml = MStabXmlDoc.CreateMStabXmlDoc(stabilityProjectFilename, scenario, subSoilScenario,
+ null, requiredSafetyFactor,
+ kernelDataInput.FailureMechanismParametersMStab, out errorMessages);
+ mstabXml.Save(stabilityProjectFilename + ".xml");
+
+ return mstabXml;
+ }
+
+ ///
+ /// Creates the sti file.
+ ///
+ /// The XML document.
+ ///
+ internal void CreateStiFile(XDocument xmlDocument)
+ {
+ DGSMStabDAMInterface mstabDamDll = new DGSMStabDAMInterface();
+ var result = mstabDamDll.CreateProjectFile(xmlDocument.ToString());
+ if (result > 0)
+ {
+ string errorMessage = mstabDamDll.ErrorMessage();
+ throw new MacroStabilityException(errorMessage);
+ }
+ }
+
+ ///
+ /// Creates the Stability calculator.
+ ///
+ /// The kernel data input.
+ ///
+ ///
+ internal static StabilityCalculator StabilityCalculator(IKernelDataInput kernelDataInput)
+ {
+ DamMacroStabilityInput damMacroStabilityInput = kernelDataInput as DamMacroStabilityInput;
+ if (damMacroStabilityInput == null)
+ {
+ throw new NoNullAllowedException(Resources.DamMacroStabilityKernelWrapper_StabilityCalculator_NoInputObjectDefinedForMacroStability);
+ }
+ var calculator = new StabilityCalculator
+ {
+ ProjectName = damMacroStabilityInput.DGeoStabilityInputFileName,
+ DGeoStabilityExePath = damMacroStabilityInput.DGeoStabilityExePath
+ };
+ return calculator;
+ }
+ }
+}
Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/DamMacroStabilityCommon/MStabXmlDoc.cs
===================================================================
diff -u -r1026 -r1036
--- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/DamMacroStabilityCommon/MStabXmlDoc.cs (.../MStabXmlDoc.cs) (revision 1026)
+++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/DamMacroStabilityCommon/MStabXmlDoc.cs (.../MStabXmlDoc.cs) (revision 1036)
@@ -131,7 +131,7 @@
if (profile1D == null)
{
throw new MStabXmlDocException(
- "Model horizontal balance does not support 2d-geometries");
+ Resources.DamMacroStabilityKernelWrapper_HorBal2DProfNotAllowed);
}
failureMechanismParametersMStab.MStabParameters.HorizontalBalanceArea = new HorizontalBalanceArea
{
Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStabilityHorizontalBalance/DamMacroStabilityHorizontalBalanceKernelWrapperTests.cs
===================================================================
diff -u
--- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStabilityHorizontalBalance/DamMacroStabilityHorizontalBalanceKernelWrapperTests.cs (revision 0)
+++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStabilityHorizontalBalance/DamMacroStabilityHorizontalBalanceKernelWrapperTests.cs (revision 1036)
@@ -0,0 +1,426 @@
+// Copyright (C) Stichting Deltares 2018. 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.Collections.Generic;
+using System.Data;
+using System.IO;
+using Deltares.DamEngine.Calculators.KernelWrappers.Common;
+using Deltares.DamEngine.Calculators.KernelWrappers.DamMacroStabilityCommon;
+using Deltares.DamEngine.Calculators.KernelWrappers.DamMacroStabilityHorizontalBalance;
+using Deltares.DamEngine.Calculators.KernelWrappers.Interfaces;
+using Deltares.DamEngine.Calculators.Tests.KernelWrappers.DamMacroStabilityCommon;
+using Deltares.DamEngine.Data.General;
+using Deltares.DamEngine.Data.General.Results;
+using Deltares.DamEngine.Data.Geotechnics;
+using Deltares.DamEngine.Data.Standard.Calculation;
+using Deltares.DamEngine.Data.Standard.Logging;
+using Deltares.DamEngine.TestHelpers.Factories;
+using NUnit.Framework;
+
+namespace Deltares.DamEngine.Calculators.Tests.KernelWrappers.DamMacroStabilityHorizontalBalance
+{
+ [TestFixture]
+ public class DamMacroStabilityHorizontalBalanceKernelWrapperTests
+ {
+ private const string testFolder = @"..\..\Deltares.DamEngine.Calculators.Tests\KernelWrappers\DamMacroStabilityCommon\TestData";
+
+
+ [Test]
+ public void TestObsoleteCalculationForProcess()
+ {
+ // expected is that preparation of this calculation is not done.
+ var absoluteFolder = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), testFolder));
+ var workingDir = Path.Combine(absoluteFolder, "FullOut");
+ // Relative paths in ini file do not work yet in DGeoStability 16.2. This is fixed in 18.1.
+ if (Directory.Exists(workingDir))
+ {
+ Directory.Delete(workingDir, true);
+ }
+
+ var damKernelInput = CreateDamKernelInput();
+ damKernelInput.CalculationDir = workingDir;
+ var failureMechanismParametersMStab = new FailureMechanismParametersMStab
+ {
+ ProjectWorkingPath = workingDir
+ };
+
+ var kernelWrapper = new DamMacroStabilityHorizontalBalanceKernelWrapper
+ {
+ FailureMechanismParametersMStab = failureMechanismParametersMStab
+ };
+ // Set the requested mechanism for this subsoil to StabilityInside to make it irrelevant
+ damKernelInput.SubSoilScenario.SegmentFailureMechanismType = FailureMechanismSystemType.StabilityInside;
+ // Prepare the wrapper. This should fail as the given mechanism is not relevant for this kernel
+ IKernelDataInput damStabilityInput;
+ IKernelDataOutput kernelOutput;
+ var result = kernelWrapper.Prepare(damKernelInput, 0, out damStabilityInput, out kernelOutput);
+ Assert.AreEqual(result, PrepareResult.NotRelevant);
+ }
+
+ [Test]
+ public void TestFullCalculationForProcess() // gebaseerd op CanCalculateStabilitySafetyFactorGeometry1DUsingSlopeW DamClassic
+ {
+ const double cToleranceSafetyFactor = 0.001;
+ const double cTrafficLoad = 10.0;
+ const double cMinimalCircleDepth = 1.0;
+
+ var absoluteFolder = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), testFolder));
+ var workingDir = Path.Combine(absoluteFolder, "FullOut");
+ // Relative paths in ini file do not work yet in DGeoStability 16.2. This is fixed in 18.1.
+ if (Directory.Exists(workingDir))
+ {
+ Directory.Delete(workingDir, true);
+ }
+
+ var line = FactoryForSurfaceLines.CreateSurfaceLineTutorial1();
+ var location = new Location();
+ var scenario = DamMacroStabilityTestHelper.CreateScenarioForLocation(location, line);
+ scenario.RiverLevel = 4.0;
+ scenario.Location.PolderLevel = -1.0;
+ scenario.Location.StabilityOptions = new StabilityOptions
+ {
+ TrafficLoad = cTrafficLoad
+ };
+ var soilDbName = Path.Combine(testFolder, "soilmaterials.mdb");
+ scenario.Location.StabilityOptions.SoilDatabaseName = soilDbName;
+ var soilProfile = CreateSoilProfile();
+ //var modelParametersForPLLines = new ModelParametersForPLLines();
+ MStabParameters mstabParameters = new MStabParameters
+ {
+ ShearStrength = MStabShearStrength.CPhi,
+ IsProbabilistic = false,
+ Model = MStabModelType.HorizontalBalance,
+ SearchMethod = MStabSearchMethod.Grid,
+ GridPosition = MStabGridPosition.Right,
+ ZonesType = MStabZonesType.NoZones,
+ CalculationOptions =
+ {
+ MinimalCircleDepth = cMinimalCircleDepth
+ }
+ };
+ var subSoilScenario = new SoilGeometryProbability
+ {
+ SoilProfile1D = soilProfile,
+ SoilProfileType = SoilProfileType.ProfileType1D,
+ SegmentFailureMechanismType = FailureMechanismSystemType.HorizontalBalance
+ };
+ var damFailureMechanismeCalculationSpecification = new DamFailureMechanismeCalculationSpecification
+ {
+ FailureMechanismSystemType = FailureMechanismSystemType.HorizontalBalance,
+ FailureMechanismParametersMStab = new FailureMechanismParametersMStab()
+ {
+ MStabParameters = mstabParameters
+ }
+ };
+ var damKernelInput = new DamKernelInput
+ {
+ DamFailureMechanismeCalculationSpecification = damFailureMechanismeCalculationSpecification,
+ Location = location,
+ DesignScenario = scenario,
+ SubSoilScenario = subSoilScenario,
+ CalculationDir = workingDir
+ };
+ var kernelWrapper = new DamMacroStabilityHorizontalBalanceKernelWrapper()
+ {
+ FailureMechanismParametersMStab = damFailureMechanismeCalculationSpecification.FailureMechanismParametersMStab
+ };
+
+ // Prepare the wrapper. Result is input for the calculation dll
+ IKernelDataInput damStabilityInput;
+ IKernelDataOutput kernelOutput;
+ var result = kernelWrapper.Prepare(damKernelInput, 0, out damStabilityInput, out kernelOutput);
+ Assert.AreEqual(result, PrepareResult.Successful);
+ // Validate the input
+ List messages;
+ kernelWrapper.Validate(damStabilityInput, kernelOutput, out messages);
+ Assert.AreEqual(0, messages.Count);
+
+ // Run the dll
+ kernelWrapper.Execute(damStabilityInput, kernelOutput, out messages);
+ DamMacroStabilityOutput damMacroStabilityOutput = (DamMacroStabilityOutput)kernelOutput;
+ Assert.AreEqual(0, messages.Count);
+ Assert.AreEqual(10.169, damMacroStabilityOutput.StabilityOutputItems[0].Zone1Results.SafetyFactor, cToleranceSafetyFactor);
+ Assert.IsNull(damMacroStabilityOutput.StabilityOutputItems[0].Zone2Results);
+
+ // Fill the design results
+ List results;
+ kernelWrapper.PostProcess(damKernelInput, damMacroStabilityOutput, "", out results);
+ Assert.AreEqual(10.169, results[0].StabilityDesignResults.SafetyFactor, cToleranceSafetyFactor);
+ Assert.AreEqual("", results[0].StabilityDesignResults.ResultMessage);
+ Assert.AreEqual(CalculationResult.Succeeded, results[0].CalculationResult);
+ }
+
+ [Test]
+ [ExpectedException(typeof(MStabXmlDocException), ExpectedMessage = "Model Horizontaal Evenwicht ondersteunt geen 2D profielen.")]
+ [SetUICulture("nl-NL")]
+ public void TestLanguageNLThrowsExceptionWhenInputUses2DProfile()
+ {
+ CreateKerneWrapperInputWith2DProfile();
+ }
+
+ [Test]
+ [ExpectedException(typeof(MStabXmlDocException), ExpectedMessage = "Model horizontal balance does not support 2d-geometries.")]
+ [SetUICulture("en-US")]
+ public void TestLanguageENThrowsExceptionWhenInputUses2DProfile()
+ {
+ CreateKerneWrapperInputWith2DProfile();
+ }
+
+ [Test]
+ [ExpectedException(typeof(NoNullAllowedException), ExpectedMessage = "Geen invoer object gedefinieerd voor Macrostabiliteit")]
+ [SetUICulture("nl-NL")]
+ public void TestLanguageNLThrowsExceptionWhenInputIsNull()
+ {
+ DamMacroStabilityHorizontalBalanceKernelWrapper.StabilityCalculator(null);
+ }
+
+ [Test]
+ [ExpectedException(typeof(NoNullAllowedException), ExpectedMessage = "No input object defined for Macro Stability")]
+ [SetUICulture("en-US")]
+ public void TestLanguageENThrowsExceptionWhenInputIsNull()
+ {
+ DamMacroStabilityHorizontalBalanceKernelWrapper.StabilityCalculator(null);
+ }
+
+ [Test]
+ [ExpectedException(typeof(NoNullAllowedException), ExpectedMessage = "No input object defined for Macro Stability")]
+ [SetUICulture("en-US")]
+ public void PostProcessTestLanguageENThrowsExceptionWhenInputIsNull()
+ {
+ var kernelWrapper = new DamMacroStabilityHorizontalBalanceKernelWrapper();
+ List results;
+ kernelWrapper.PostProcess(null, null, "", out results);
+ }
+
+ [Test]
+ [ExpectedException(typeof(NoNullAllowedException), ExpectedMessage = "Geen uitvoer object gedefinieerd voor Macrostabiliteit")]
+ [SetUICulture("nl-NL")]
+ public void PostProcessTestThrowsExceptionWhenOutputIsNull()
+ {
+ var kernelWrapper = new DamMacroStabilityHorizontalBalanceKernelWrapper();
+ List results;
+ var damKernelInput = CreateDamKernelInput();
+ kernelWrapper.PostProcess(damKernelInput, null, "", out results);
+ }
+
+ [Test]
+ public void TestPostProcess()
+ {
+ var kernelWrapper = new DamMacroStabilityHorizontalBalanceKernelWrapper();
+ var damKernelInput = CreateDamKernelInput();
+ DamMacroStabilityOutputItem outputItem = new DamMacroStabilityOutputItem();
+
+ var zone1 = new DamMacroStabilityOutputItem.ResultsSingleZone
+ {
+ SafetyFactor = 1.1,
+ CircleSurfacePointLeftXCoordinate = 1.2,
+ CircleSurfacePointRightXCoordinate = 1.3
+ };
+ outputItem.Zone1Results = zone1;
+ DamMacroStabilityOutput output = new DamMacroStabilityOutput
+ {
+ StabilityOutputItems = new List
+ {
+ outputItem
+ }
+ };
+ List results;
+ kernelWrapper.PostProcess(damKernelInput, output, "", out results);
+ Assert.AreEqual(1.1, results[0].StabilityDesignResults.SafetyFactor);
+ Assert.AreEqual(1.1, results[0].StabilityDesignResults.Zone1SafetyFactor);
+ Assert.AreEqual(1.3, results[0].StabilityDesignResults.LocalZone1EntryPointX);
+ Assert.AreEqual(1.2, results[0].StabilityDesignResults.LocalZone1ExitPointX);
+ // Horizontal Balance does not have results for zone 2
+ Assert.AreEqual(null, results[0].StabilityDesignResults.Zone2SafetyFactor);
+ Assert.AreEqual(null, results[0].StabilityDesignResults.LocalZone2EntryPointX);
+ Assert.AreEqual(null, results[0].StabilityDesignResults.LocalZone2ExitPointX);
+ }
+ private void PrepareWithInvalidFile()
+ {
+ // expected results are based on test CanCalculateStabilitySafetyFactorGeometry2D
+ // in 'https://repos.deltares.nl/repos/dam/dam classic' revision 190
+ var soilDbName = Path.Combine(testFolder, "soilmaterials.mdb");
+ var soilGeometry2DName = "1D1.sti";
+
+ var absoluteFolder = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), testFolder));
+ var workingDir = Path.Combine(absoluteFolder, "FullOut");
+ // Relative paths in ini file do not work yet in DGeoStability 16.2. This is fixed in 18.1.
+
+ if (Directory.Exists(workingDir))
+ {
+ Directory.Delete(workingDir, true);
+ }
+
+ var line = FactoryForSurfaceLines.CreateSurfaceLineTutorial1();
+ var location = new Location();
+ var scenario = DamMacroStabilityTestHelper.CreateScenarioForLocation(location, line);
+ scenario.Location.StabilityOptions = new StabilityOptions
+ {
+ TrafficLoad = 10.0,
+ SoilGeometries2DPath = testFolder
+ };
+ scenario.Location.StabilityOptions.SoilDatabaseName = soilDbName;
+ scenario.ModelFactors.RequiredSafetyFactorStabilityInnerSlope = 1.1;
+
+ var subSoilScenario = new SoilGeometryProbability
+ {
+ StiFileName = soilGeometry2DName,
+ SoilProfileType = SoilProfileType.ProfileTypeStiFile,
+ SegmentFailureMechanismType = FailureMechanismSystemType.HorizontalBalance
+ };
+
+ var FailureMechanismParametersMStab = new FailureMechanismParametersMStab
+ {
+ MStabParameters =
+ {
+ GridPosition = MStabGridPosition.Left,
+ SearchMethod = MStabSearchMethod.GeneticAlgorithm,
+ CalculationOptions =
+ {
+ MinimalCircleDepth = 1.0
+ }
+ },
+ ProjectWorkingPath = workingDir
+ };
+
+ var damKernelInput = new DamKernelInput
+ {
+ Location = location,
+ DesignScenario = scenario,
+ SubSoilScenario = subSoilScenario,
+ ProjectDir = absoluteFolder,
+ CalculationDir = workingDir
+ };
+
+ var kernelWrapper = new DamMacroStabilityHorizontalBalanceKernelWrapper
+ {
+ FailureMechanismParametersMStab = FailureMechanismParametersMStab
+ };
+
+ // Prepare the wrapper. Result is input for the calculation dll
+ IKernelDataInput damStabilityInput;
+ IKernelDataOutput kernelOutput;
+ kernelWrapper.Prepare(damKernelInput, 0, out damStabilityInput, out kernelOutput);
+ }
+
+ private static DamKernelInput CreateDamKernelInput(bool realOut = false)
+ {
+ var absoluteFolder = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), testFolder));
+ var soilDbName = Path.Combine(testFolder, "soilmaterials.mdb");
+ var soilGeometry2DName = "1D1.sti";
+ var line = FactoryForSurfaceLines.CreateSurfaceLineTutorial1();
+ var location = new Location();
+ if (realOut)
+ {
+ soilDbName = Path.Combine(absoluteFolder, "soilmaterialsOutwards.mdb");
+ soilGeometry2DName = "OutwardsZones.sti";
+ foreach (var characteristicPoint in line.CharacteristicPoints)
+ {
+ characteristicPoint.Z = characteristicPoint.Z - 3;
+ }
+ location.PolderLevel = -11;
+ }
+
+ var scenario = DamMacroStabilityTestHelper.CreateScenarioForLocation(location, line);
+ scenario.Location.StabilityOptions = new StabilityOptions
+ {
+ TrafficLoad = 10.0,
+ SoilGeometries2DPath = absoluteFolder
+ };
+ scenario.Location.StabilityOptions.SoilDatabaseName = soilDbName;
+ scenario.ModelFactors.RequiredSafetyFactorStabilityOuterSlope = 1.1;
+
+ var subSoilScenario = new SoilGeometryProbability
+ {
+ StiFileName = soilGeometry2DName,
+ SoilProfileType = SoilProfileType.ProfileTypeStiFile,
+ SegmentFailureMechanismType = FailureMechanismSystemType.HorizontalBalance
+ };
+ var damFailureMechanismeCalculationSpecification = new DamFailureMechanismeCalculationSpecification()
+ {
+ FailureMechanismSystemType = FailureMechanismSystemType.HorizontalBalance,
+ StabilityModelType = MStabModelType.Bishop
+ };
+ var damKernelInput = new DamKernelInput
+ {
+ DamFailureMechanismeCalculationSpecification = damFailureMechanismeCalculationSpecification,
+ Location = location,
+ DesignScenario = scenario,
+ SubSoilScenario = subSoilScenario
+ };
+ return damKernelInput;
+ }
+
+ private static void CreateKerneWrapperInputWith2DProfile()
+ {
+ var absoluteFolder = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), testFolder));
+ var workingDir = Path.Combine(absoluteFolder, "FullOut");
+ // Relative paths in ini file do not work yet in DGeoStability 16.2. This is fixed in 18.1.
+ if (Directory.Exists(workingDir))
+ {
+ Directory.Delete(workingDir, true);
+ }
+
+ var damKernelInput = CreateDamKernelInput();
+ damKernelInput.ProjectDir = absoluteFolder;
+ damKernelInput.CalculationDir = workingDir;
+ var failureMechanismParametersMStab = new FailureMechanismParametersMStab
+ {
+ MStabParameters =
+ {
+ GridPosition = MStabGridPosition.Left,
+ SearchMethod = MStabSearchMethod.Grid,
+ CalculationOptions =
+ {
+ MinimalCircleDepth = 1.0
+ }
+ },
+ ProjectWorkingPath = workingDir
+ };
+
+ var kernelWrapper = new DamMacroStabilityHorizontalBalanceKernelWrapper()
+ {
+ FailureMechanismParametersMStab = failureMechanismParametersMStab
+ };
+
+ // Prepare the wrapper. Result is input for the calculation dll
+ IKernelDataInput damStabilityInput;
+ IKernelDataOutput kernelOutput;
+ kernelWrapper.Prepare(damKernelInput, 0, out damStabilityInput, out kernelOutput);
+ }
+
+ ///
+ /// Create standard 4 layer soilprofile for tests
+ ///
+ ///
+ public static SoilProfile1D CreateSoilProfile()
+ {
+
+ SoilProfile1D soilProfile = FactoryForSoilProfiles.CreateClaySandClaySandProfile();
+ soilProfile.Name = "SoilProfileName";
+ soilProfile.Layers[0].Soil.Name = "DKN3";
+ soilProfile.Layers[1].Soil.Name = "zand";
+ soilProfile.Layers[2].Soil.Name = "DKN3";
+ soilProfile.Layers[3].Soil.Name = "zand";
+ return soilProfile;
+ }
+ }
+}
Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/Properties/Resources.Designer.cs
===================================================================
diff -u -r1001 -r1036
--- DamEngine/trunk/src/Deltares.DamEngine.Calculators/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 1001)
+++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 1036)
@@ -61,6 +61,15 @@
}
///
+ /// Looks up a localized string similar to Model horizontal balance does not support 2d-geometries..
+ ///
+ internal static string DamMacroStabilityKernelWrapper_HorBal2DProfNotAllowed {
+ get {
+ return ResourceManager.GetString("DamMacroStabilityKernelWrapper_HorBal2DProfNotAllowed", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to The use of Zone Areas is not allowed for stability outside..
///
internal static string DamMacroStabilityKernelWrapper_OutsideWithZoneAreasNotAllowed {
Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/Deltares.DamEngine.Calculators.csproj
===================================================================
diff -u -r1028 -r1036
--- DamEngine/trunk/src/Deltares.DamEngine.Calculators/Deltares.DamEngine.Calculators.csproj (.../Deltares.DamEngine.Calculators.csproj) (revision 1028)
+++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/Deltares.DamEngine.Calculators.csproj (.../Deltares.DamEngine.Calculators.csproj) (revision 1036)
@@ -80,6 +80,7 @@
+