Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/DikesDesign/DesignCalculatorCombinedSlopeAndShoulderAdaption.cs =================================================================== diff -u -r3893 -r4000 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/DikesDesign/DesignCalculatorCombinedSlopeAndShoulderAdaption.cs (.../DesignCalculatorCombinedSlopeAndShoulderAdaption.cs) (revision 3893) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/DikesDesign/DesignCalculatorCombinedSlopeAndShoulderAdaption.cs (.../DesignCalculatorCombinedSlopeAndShoulderAdaption.cs) (revision 4000) @@ -42,6 +42,7 @@ public class DesignCalculatorCombinedSlopeAndShoulderAdaption { private const double defaultMaxFractionOfDikeHeightForShoulderHeight = 0.67; + /// /// Performs the design calculation combined slope adaption and shoulder adaption. /// @@ -64,7 +65,7 @@ Location location = damKernelInput.Location; SoilGeometryProbability subSoilScenario = damKernelInput.SubSoilScenario; const int maxRedesignIterations = 200; - string resultMessage = ""; + var resultMessage = ""; int iterationIndex = -1; designScenario.CalculationResult = CalculationResult.NoRun; @@ -93,8 +94,7 @@ } else { - double maxFractionOfDikeHeightForShoulderHeight = location.UseNewMaxHeightShoulderAsFraction ? - location.NewMaxHeightShoulderAsFraction : defaultMaxFractionOfDikeHeightForShoulderHeight; + double maxFractionOfDikeHeightForShoulderHeight = location.UseNewMaxHeightShoulderAsFraction ? location.NewMaxHeightShoulderAsFraction : defaultMaxFractionOfDikeHeightForShoulderHeight; double maxShoulderLevel = DesignCalculatorUtils.CalculateMaximumShoulderLevel(surfaceLine, maxFractionOfDikeHeightForShoulderHeight); while (isRedesignRequired && surfaceLine != null) @@ -110,14 +110,14 @@ double shoulderHeight; double shoulderLength; DesignCalculatorUtils.DetermineNewShoulderLengthAndHeight(location.StabilityShoulderGrowDeltaX, - location.StabilityShoulderGrowSlope, surfaceLine, limitPointForShoulderDesign, out shoulderHeight, out shoulderLength); + location.StabilityShoulderGrowSlope, surfaceLine, limitPointForShoulderDesign, out shoulderHeight, out shoulderLength); // Create new shoulder var surfaceLineShoulderAdapter = new SurfaceLineShoulderAdapter(surfaceLine, location, designScenario.PolderLevel); surfaceLineShoulderAdapter.MaxShoulderLevel = maxShoulderLevel; surfaceLine = surfaceLineShoulderAdapter.ConstructNewSurfaceLine(shoulderLength, shoulderHeight, false); - var validationError = surfaceLine.Validate().FirstOrDefault(vr => vr.MessageType == ValidationResultType.Error); + ValidationResult validationError = surfaceLine.Validate().FirstOrDefault(vr => vr.MessageType == ValidationResultType.Error); if (validationError != null) { throw new SurfaceLineException(validationError.Text); @@ -131,11 +131,12 @@ var surfaceLineSlopeAdapter = new SurfaceLineSlopeAdapter(surfaceLine, location, designScenario.PolderLevel); surfaceLine = surfaceLineSlopeAdapter.ConstructNewSurfaceLine(location.StabilitySlopeAdaptionDeltaX); - var validationError = surfaceLine.Validate().FirstOrDefault(vr => vr.MessageType == ValidationResultType.Error); + ValidationResult validationError = surfaceLine.Validate().FirstOrDefault(vr => vr.MessageType == ValidationResultType.Error); if (validationError != null) { throw new SurfaceLineException(validationError.Text); } + designScenario.SetRedesignedSurfaceLine(subSoilScenario.SoilProfile1D, subSoilScenario.SoilProfile2D, surfaceLine); } else @@ -149,19 +150,21 @@ kernelWrapper.PrepareDesign(kernelDataInput, kernelDataOutput, damKernelInput, iterationIndex, out embankmentDesignParameters); if (damKernelInput.SubSoilScenario.SoilProfileType == SoilProfileType.ProfileType2D) { - var embankmentSoil = + Soil embankmentSoil = damKernelInput.Location.SoilList.GetSoilByName(embankmentDesignParameters - .EmbankmentMaterialname); - damKernelInput.SubSoilScenario.SoilProfile2D = + .EmbankmentMaterialname); + damKernelInput.SubSoilScenario.SoilProfile2D = AdaptProfile2DToNewSurfaceLine(damKernelInput.SubSoilScenario.SoilProfile2D, surfaceLine, embankmentSoil); } - DesignCalculatorUtils.KernelCalculate(out kernelDataInput, kernelWrapper, out kernelDataOutput, damKernelInput, - iterationIndex, out locationCalculationMessages); + + DesignCalculatorUtils.KernelCalculate(out kernelDataInput, kernelWrapper, out kernelDataOutput, damKernelInput, + iterationIndex, out locationCalculationMessages); calculationMessages.AddRange(locationCalculationMessages); - isRedesignRequired = !kernelWrapper.EvaluateDesign(damKernelInput, kernelDataInput, kernelDataOutput, out designAdvise, - out evaluationMessage); + isRedesignRequired = !kernelWrapper.EvaluateDesign(damKernelInput, kernelDataInput, kernelDataOutput, out designAdvise, + out evaluationMessage); } } + calculationMessages.AddRange(locationCalculationMessages); designScenario.CalculationResult = CalculationResult.Succeeded; designScenario.SetResultMessage(subSoilScenario.SoilProfile1D, subSoilScenario.SoilProfile2D, "Succes"); @@ -177,6 +180,7 @@ errorMessage = errorMessage + ";" + innerException.Message; innerException = innerException.InnerException; } + designScenario.SetResultMessage(subSoilScenario.SoilProfile1D, subSoilScenario.SoilProfile2D, errorMessage); designScenario.CalculationResult = CalculationResult.RunFailed; // Redesign not succesful, so no redesigned surfaceline will be returned @@ -189,8 +193,8 @@ private static SoilProfile2D AdaptProfile2DToNewSurfaceLine(SoilProfile2D soilProfile2D, SurfaceLine2 surfaceLine, Soil dikeEmbankmentSoil) { - var topX = surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeTopAtPolder).X; - var soilProfile1D = soilProfile2D.GetSoilProfile1D(topX); + double topX = surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeTopAtPolder).X; + SoilProfile1D soilProfile1D = soilProfile2D.GetSoilProfile1D(topX); var soilSurfaceProfile = new SoilSurfaceProfile { SoilProfile = soilProfile1D, @@ -199,18 +203,20 @@ DikeEmbankmentMaterial = dikeEmbankmentSoil }; // Convert the soilSurfaceProfile to a SoilProfile2D to be able to edit it properly. - var soilProfile2DNew = soilSurfaceProfile.ConvertToSoilProfile2D(); - var numberOfCommonSurface = Math.Min(soilProfile2DNew.Surfaces.Count, soilProfile2D.Surfaces.Count); - for (int i = 0; i < numberOfCommonSurface; i++) + SoilProfile2D soilProfile2DNew = soilSurfaceProfile.ConvertToSoilProfile2D(); + int numberOfCommonSurface = Math.Min(soilProfile2DNew.Surfaces.Count, soilProfile2D.Surfaces.Count); + for (var i = 0; i < numberOfCommonSurface; i++) { soilProfile2DNew.Surfaces[i].WaterpressureInterpolationModel = soilProfile2D.Surfaces[i].WaterpressureInterpolationModel; } + for (int i = numberOfCommonSurface; i < soilProfile2DNew.Surfaces.Count; i++) { soilProfile2DNew.Surfaces[i].WaterpressureInterpolationModel = WaterpressureInterpolationModel.Automatic; } + return soilProfile2DNew; } } -} +} \ No newline at end of file