Index: DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/TestFiles/DesignInputFileWithRiverLevelAboveDikeTopButBelowDTHWithNoAdaption.xml
===================================================================
diff -u
--- DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/TestFiles/DesignInputFileWithRiverLevelAboveDikeTopButBelowDTHWithNoAdaption.xml (revision 0)
+++ DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/TestFiles/DesignInputFileWithRiverLevelAboveDikeTopButBelowDTHWithNoAdaption.xml (revision 2633)
@@ -0,0 +1,331 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/DikesDesign/DesignCalculator.cs
===================================================================
diff -u -r2575 -r2633
--- DamEngine/trunk/src/Deltares.DamEngine.Calculators/DikesDesign/DesignCalculator.cs (.../DesignCalculator.cs) (revision 2575)
+++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/DikesDesign/DesignCalculator.cs (.../DesignCalculator.cs) (revision 2633)
@@ -170,43 +170,81 @@
throw new NotImplementedException(Resources.DesignCalculatorKernelNotImplemented);
}
- PrepareResult prepareResult = kernelWrapper.Prepare(damKernelInput, 0, out kernelDataInput, out kernelDataOutput);
-
- // Sometimes the kernelDataInput is not created (p.e when soilprofileprobablility is meant for
- // stability where Piping calc is wanted). In that case, do nothing but just skip.
- if (prepareResult == PrepareResult.Successful)
+ // During the design calculation the location.SurfaceLine is adapted; so store a copy to restore it after the calculation
+ SurfaceLine2 orgLocationSurfaceLine = null;
+ try
{
- switch (analysisType)
+ // Make sure that in case of AdaptGeometry (and RedesignDikeHeight), the surface line is adpted for the given DTH BEFORE the call to Prepare as
+ // otherwise the Prepare will be done on the original surface line which is wrong.
+ if (analysisType == AnalysisType.AdaptGeometry && damKernelInput.Location.RedesignDikeHeight)
{
- case AnalysisType.AdaptGeometry:
- PerformDesignCalculation(
- kernelWrapper, kernelDataInput, kernelDataOutput,
- damKernelInput, designScenario, calculationMessages,
- designResults);
- break;
- case AnalysisType.NoAdaption:
- DesignCalculatorSingle.PerformSingleCalculation(
- kernelWrapper, kernelDataInput, kernelDataOutput,
- damKernelInput, designScenario, calculationMessages,
- designResults);
- break;
+ double? dikeHeight = location.SurfaceLine.GetDikeHeight();
+ if (dikeHeight.HasValue)
+ {
+ if (designScenario.DikeTableHeight > dikeHeight.Value)
+ {
+ orgLocationSurfaceLine = location.SurfaceLine.FullDeepClone();
+ // Redesign the surfaceline to the desired Dike Tabel Height
+ var surfaceLineHeightAdapter =
+ new SurfaceLineHeightAdapter(location.SurfaceLine, location);
+ SurfaceLine2 adaptedSurfaceLine =
+ surfaceLineHeightAdapter.ConstructNewSurfaceLine(
+ designScenario.DikeTableHeight ??
+ location.SurfaceLine.GetDefaultDikeTableHeight() ?? 0);
+ designScenario.SetRedesignedSurfaceLine(damKernelInput.SubSoilScenario.SoilProfile1D,
+ damKernelInput.SubSoilScenario.StiFileName, adaptedSurfaceLine);
+ damKernelInput.Location.SurfaceLine = adaptedSurfaceLine;
+ }
+ }
}
- }
- else
- {
- if (prepareResult == PrepareResult.NotRelevant)
+
+ PrepareResult prepareResult =
+ kernelWrapper.Prepare(damKernelInput, 0, out kernelDataInput, out kernelDataOutput);
+
+ // Sometimes the kernelDataInput is not created (p.e when soilprofileprobablility is meant for
+ // stability where Piping calc is wanted). In that case, do nothing but just skip.
+ if (prepareResult == PrepareResult.Successful)
{
- // Do nothing. Calculation will be skipped.
+ switch (analysisType)
+ {
+ case AnalysisType.AdaptGeometry:
+ PerformDesignCalculation(
+ kernelWrapper, kernelDataInput, kernelDataOutput,
+ damKernelInput, designScenario, calculationMessages,
+ designResults);
+ break;
+ case AnalysisType.NoAdaption:
+ DesignCalculatorSingle.PerformSingleCalculation(
+ kernelWrapper, kernelDataInput, kernelDataOutput,
+ damKernelInput, designScenario, calculationMessages,
+ designResults);
+ break;
+ }
}
- if (prepareResult == PrepareResult.Failed)
+ else
{
- calculationMessages.Add(new LogMessage(LogMessageType.Error, null,
- string.Format(Resources.DesignCalculatorPrepareError,
- location.Name,
- soiProfileProbability,
- designScenario.LocationScenarioID)));
+ if (prepareResult == PrepareResult.NotRelevant)
+ {
+ // Do nothing. Calculation will be skipped.
+ }
+
+ if (prepareResult == PrepareResult.Failed)
+ {
+ calculationMessages.Add(new LogMessage(LogMessageType.Error, null,
+ string.Format(Resources.DesignCalculatorPrepareError,
+ location.Name,
+ soiProfileProbability,
+ designScenario.LocationScenarioID)));
+ }
}
}
+ finally
+ {
+ if (orgLocationSurfaceLine != null)
+ {
+ location.SurfaceLine = orgLocationSurfaceLine;
+ }
+ }
}
catch (Exception e)
{
@@ -235,59 +273,31 @@
DesignScenario designScenario,
List calculationMessages, List designCalculations)
{
- // During the design calculation the location.SurfaceLine is adapted; so store a copy to restore it after the calculation
- Location location = damKernelInput.Location;
- SoilGeometryProbability subSoilScenario = damKernelInput.SubSoilScenario;
- SurfaceLine2 orgLocationSurfaceLine = location.SurfaceLine.FullDeepClone();
- try
+ if (damKernelInput.Location.RedesignDikeShoulder)
{
- if (damKernelInput.Location.RedesignDikeHeight)
+ // Redesign the surfaceline with shoulder and or slope adaption
+ switch (kernelWrapper.GetDesignStrategy(damKernelInput))
{
- double? dikeHeight = location.SurfaceLine.GetDikeHeight();
- if (dikeHeight.HasValue)
- {
- if (designScenario.DikeTableHeight > dikeHeight.Value)
- {
- // Redesign the surfaceline to the desired Dike Tabel Height
- var surfaceLineHeightAdapter = new SurfaceLineHeightAdapter(location.SurfaceLine, location);
- SurfaceLine2 adaptedSurfaceLine = surfaceLineHeightAdapter.ConstructNewSurfaceLine(designScenario.DikeTableHeight ?? location.SurfaceLine.GetDefaultDikeTableHeight() ?? 0);
- designScenario.SetRedesignedSurfaceLine(subSoilScenario.SoilProfile1D, subSoilScenario.StiFileName, adaptedSurfaceLine);
- }
- }
+ case DesignStrategy.ShoulderPerPoint:
+ DesignCalculatorShoulderPerPoint.PerformDesignCalculationShoulderPerPoint(
+ kernelWrapper, kernelDataInput, kernelDataOutput,
+ damKernelInput, designScenario, calculationMessages,
+ designCalculations);
+ break;
+ case DesignStrategy.NoDesignPossible:
+ throw new NotImplementedException("No design is possible for this failure mechanism");
+ case DesignStrategy.SlopeAdaptionBeforeShoulderAdaption:
+ DesignCalculatorFirstSlopeAdaptionThenShoulderAdaption.PerformDesignCalculationFirstSlopeAdaptionThenShoulderAdaption(
+ kernelWrapper, kernelDataInput, kernelDataOutput, damKernelInput, designScenario,
+ calculationMessages, designCalculations);
+ break;
+ case DesignStrategy.OptimizedSlopeAndShoulderAdaption:
+ DesignCalculatorCombinedSlopeAndShoulderAdaption.PerformDesignCalculationCombinedSlopeAdaptionAndShoulderAdaption(
+ kernelWrapper, kernelDataInput, kernelDataOutput, damKernelInput, designScenario,
+ calculationMessages, designCalculations);
+ break;
}
- if (damKernelInput.Location.RedesignDikeShoulder)
- {
- // Redesign the surfaceline with shoulder and or slope adaption
- switch (kernelWrapper.GetDesignStrategy(damKernelInput))
- {
- case DesignStrategy.ShoulderPerPoint:
- DesignCalculatorShoulderPerPoint.PerformDesignCalculationShoulderPerPoint(
- kernelWrapper, kernelDataInput, kernelDataOutput,
- damKernelInput, designScenario, calculationMessages,
- designCalculations);
- break;
- case DesignStrategy.NoDesignPossible:
- throw new NotImplementedException("No design is possible for this failure mechanism");
- case DesignStrategy.SlopeAdaptionBeforeShoulderAdaption:
- DesignCalculatorFirstSlopeAdaptionThenShoulderAdaption.PerformDesignCalculationFirstSlopeAdaptionThenShoulderAdaption(
- kernelWrapper, kernelDataInput, kernelDataOutput, damKernelInput, designScenario,
- calculationMessages, designCalculations);
- break;
- case DesignStrategy.OptimizedSlopeAndShoulderAdaption:
- DesignCalculatorCombinedSlopeAndShoulderAdaption.PerformDesignCalculationCombinedSlopeAdaptionAndShoulderAdaption(
- kernelWrapper, kernelDataInput, kernelDataOutput, damKernelInput, designScenario,
- calculationMessages, designCalculations);
- break;
- }
- }
}
- finally
- {
- // Restore the original surfaceline
- location.SurfaceLine = orgLocationSurfaceLine;
-
- }
-
}
///
Index: DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/IntegrationTests/MacroStabilityInwardsTests.cs
===================================================================
diff -u -r2404 -r2633
--- DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/IntegrationTests/MacroStabilityInwardsTests.cs (.../MacroStabilityInwardsTests.cs) (revision 2404)
+++ DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/IntegrationTests/MacroStabilityInwardsTests.cs (.../MacroStabilityInwardsTests.cs) (revision 2633)
@@ -900,6 +900,76 @@
Assert.AreEqual("Geen ondergrond profielen beschikbaar voor locatie '12-2_027'", output.Results.CalculationMessages[0].Message1);
}
+ [Test]
+ public void TestDesignWithRiverLevelAboveDikeTopButBelowDthCanCalculate()
+ {
+ // Test just to see if calculation works in this case as it should do, result itself is irrelevant so just taken as is.
+ const string calcDir = "TestStabInwardsBishop";
+ if (Directory.Exists(calcDir))
+ {
+ Directory.Delete(calcDir, true); // delete previous results
+ }
+
+ Directory.CreateDirectory(calcDir);
+
+
+ const string fileName = @"TestFiles\DesignInputFileWithRiverLevelAboveDikeTopButBelowDTHWithAdaption.xml";
+ string inputString = File.ReadAllText(fileName);
+ inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used
+ inputString =
+ XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used
+ inputString = XmlAdapter.ChangeValueInXml(inputString, "MapForSoilgeometries2D",
+ @"TestFiles\DAM Tutorial Design.geometries2D.0\");
+ inputString = XmlAdapter.ChangeValueInXml(inputString, "SoilDatabaseName",
+ @"TestFiles\DAM Tutorial Design0.soilmaterials.mdb");
+ inputString = XmlAdapter.ChangeValueInXml(inputString, "SegmentFailureMechanismType",
+ ConversionHelper.InputSegmentFailureMechanismStability.ToString());
+ EngineInterface engineInterface = new EngineInterface(inputString);
+ Assert.IsNotNull(engineInterface.DamProjectData);
+
+ string outputString = engineInterface.Run();
+
+ Assert.IsNotNull(outputString);
+ var output = DamXmlSerialization.LoadOutputFromXmlString(outputString);
+ Assert.IsNotNull(output.Results.CalculationResults, "No results available");
+ Assert.AreEqual(1.255, output.Results.CalculationResults[0].StabilityDesignResults.SafetyFactor, tolerance);
+ }
+
+ [Test]
+ public void TestNoDesignWithRiverLevelAboveDikeTopButBelowDthCanNOTCalculate()
+ {
+ // Test to see if calculation does NOT work in this case as it must fail with water level above dike top.
+ const string calcDir = "TestStabInwardsBishop";
+ if (Directory.Exists(calcDir))
+ {
+ Directory.Delete(calcDir, true); // delete previous results
+ }
+
+ Directory.CreateDirectory(calcDir);
+
+
+ const string fileName = @"TestFiles\DesignInputFileWithRiverLevelAboveDikeTopButBelowDTHWithNoAdaption.xml";
+ string inputString = File.ReadAllText(fileName);
+ inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used
+ inputString =
+ XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used
+ inputString = XmlAdapter.ChangeValueInXml(inputString, "MapForSoilgeometries2D",
+ @"TestFiles\DAM Tutorial Design.geometries2D.0\");
+ inputString = XmlAdapter.ChangeValueInXml(inputString, "SoilDatabaseName",
+ @"TestFiles\DAM Tutorial Design0.soilmaterials.mdb");
+ inputString = XmlAdapter.ChangeValueInXml(inputString, "SegmentFailureMechanismType",
+ ConversionHelper.InputSegmentFailureMechanismStability.ToString());
+ EngineInterface engineInterface = new EngineInterface(inputString);
+ Assert.IsNotNull(engineInterface.DamProjectData);
+
+ string outputString = engineInterface.Run();
+
+ Assert.IsNotNull(outputString);
+ var output = DamXmlSerialization.LoadOutputFromXmlString(outputString);
+ Assert.IsNull(output.Results.CalculationResults, "Should have results available");
+ Assert.AreEqual(1, output.Results.CalculationMessages.Length, tolerance);
+ }
+
private string ChangeInputModel(string input, InputStabilityModelType modelType)
{
string pattern = "StabilityModelType=\"Bishop\"";
Index: DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/TestFiles/DesignInputFileWithRiverLevelAboveDikeTopButBelowDTHWithAdaption.xml
===================================================================
diff -u
--- DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/TestFiles/DesignInputFileWithRiverLevelAboveDikeTopButBelowDTHWithAdaption.xml (revision 0)
+++ DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/TestFiles/DesignInputFileWithRiverLevelAboveDikeTopButBelowDTHWithAdaption.xml (revision 2633)
@@ -0,0 +1,331 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/Deltares.DamEngine.IntegrationTests.csproj
===================================================================
diff -u -r2158 -r2633
--- DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/Deltares.DamEngine.IntegrationTests.csproj (.../Deltares.DamEngine.IntegrationTests.csproj) (revision 2158)
+++ DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/Deltares.DamEngine.IntegrationTests.csproj (.../Deltares.DamEngine.IntegrationTests.csproj) (revision 2633)
@@ -77,6 +77,12 @@
PreserveNewest
+
+ PreserveNewest
+
+
+ PreserveNewest
+
PreserveNewest