Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityInwards/MacroStabilityInwardsKernelWrapper.cs =================================================================== diff -u -r2970 -r3004 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityInwards/MacroStabilityInwardsKernelWrapper.cs (.../MacroStabilityInwardsKernelWrapper.cs) (revision 2970) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityInwards/MacroStabilityInwardsKernelWrapper.cs (.../MacroStabilityInwardsKernelWrapper.cs) (revision 3004) @@ -36,8 +36,7 @@ using Deltares.DamEngine.Data.Standard; using Deltares.DamEngine.Data.Standard.Calculation; using Deltares.MacroStability.CSharpWrapper; -using Deltares.MacroStability.CSharpWrapper.Output; -using ConversionHelper = Deltares.DamEngine.Calculators.KernelWrappers.MacroStabilityCommon.MacroStabilityIo.ConversionHelper; +using Deltares.MacroStability.Standard; using GeometryPoint = Deltares.DamEngine.Data.Geometry.GeometryPoint; using LogMessage = Deltares.DamEngine.Data.Standard.Logging.LogMessage; using LogMessageType = Deltares.DamEngine.Data.Standard.Logging.LogMessageType; @@ -48,7 +47,7 @@ { private Calculator stabilityCalculator; - private int lastIterationIndex = 0; + private int lastIterationIndex; /// /// Gets or sets the failure mechanisme paramaters for mstab. @@ -58,10 +57,6 @@ /// public FailureMechanismParametersMStab FailureMechanismParametersMStab { get; set; } //ToDo MWDAM-? Use same as for DGeoStability or create new one? - public bool tmpPresumePrepareSucceeds; //ToDo MWDAM-1356 - public bool tmpPresumeInputValid; //ToDo MWDAM-1356 - public bool tmpPresumeRunSucceeds; //ToDo MWDAM-1356 - /// /// Prepares the specified dam kernel input. /// @@ -93,14 +88,13 @@ macroStabilityOutput.UpliftSituation = upliftSituation; if (upliftSituation.IsUplift) { - // ToDo MWDAM-1356: Not clear yet what parts are required for input. - var left = 0.0;// ToDo MWDAM-1356: first point of surfaceline - var right = 100.0;// ToDo MWDAM-1356: last point of surfaceline + var left = damKernelInput.Location.SurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.SurfaceLevelOutside).X; + var right = damKernelInput.Location.SurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.SurfaceLevelInside).X; var penetrationLength = damKernelInput.Location.ModelParametersForPlLines.PenetrationLength; - var waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, damKernelInput.SubSoilScenario.SoilProfile1D, + var waterNet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, damKernelInput.SubSoilScenario.SoilProfile1D, penetrationLength, left, right); TrafficLoad trafficLoad = null; - if (damKernelInput.Location.StabilityOptions.TrafficLoad.HasValue) + if (damKernelInput.Location.StabilityOptions.TrafficLoad.HasValue && !damKernelInput.Location.StabilityOptions.TrafficLoad.Value.AlmostZero()) { trafficLoad = new TrafficLoad(); trafficLoad.Pressure = damKernelInput.Location.StabilityOptions.TrafficLoad.Value; @@ -112,16 +106,13 @@ FillMacroStabilityWrapperInputFromEngine fillMacroStabilityWrapperFromEngine = new FillMacroStabilityWrapperInputFromEngine() { - TrafficLoad = trafficLoad - // ToDo MWDAM-1373/1374: fill SoilProfile2D - // ToDo MWDAM-1399: add data for calculation grid Uplift Van, connect it to actual engine input + TrafficLoad = trafficLoad, + UpliftVanCalculationGrid = null, }; - - macroStabilityInput.Input = fillMacroStabilityWrapperFromEngine.CreateMacroStabilityInput(damKernelInput, FailureMechanismParametersMStab, waternet); - // KernelModel expectedKernelModel = fillMacroStabilityWrapperFromEngine.CreateKernelModel(); - // expectedKernelModel. - // var xmlInput = CreateXmlInput(macroStabilityInput, FailureMechanismParametersMStab.EmbankmentDesignParameters); + // ToDo MWDAM-1373/1374: fill SoilProfile2D + EnsureSoilProfile2DIsFilled(damKernelInput.SubSoilScenario, damKernelInput.Location.SurfaceLine, damKernelInput.Location.GetDikeEmbankmentSoil()); + macroStabilityInput.Input = fillMacroStabilityWrapperFromEngine.CreateMacroStabilityInput(damKernelInput, FailureMechanismParametersMStab, waterNet); return PrepareKernel(macroStabilityInput.Input); } return PrepareResult.NotRelevant; @@ -136,6 +127,30 @@ return PrepareResult.NotRelevant; } + private void EnsureSoilProfile2DIsFilled(SoilGeometryProbability subSoilScenario, SurfaceLine2 surfaceLine2, Soil dikeEmbankmentSoil) + { + // var soilProfile2D = subSoilScenario.SoilProfile2D; + // if (soilProfile2D == null) + // { + // var soilSurfaceProfile = new SoilSurfaceProfile + // { + // SoilProfile = subSoilScenario.SoilProfile1D, + // SurfaceLine2 = surfaceLine2, + // Name = surfaceLine2.Name + "_" + subSoilScenario.SoilProfile1D.Name, + // DikeEmbankmentMaterial = dikeEmbankmentSoil + // }; + // // Convert the soilsurfacesoilprofile to a SoilProfile2D to be able to edit it properly. + // var soilProfile2DNew = soilSurfaceProfile.ConvertToSoilProfile2D(); + // //soilSurfaceProfile.Dispose(); + // // For some obscure reason, the created soilProfile2D is handled wrong in the UI (see DSB=786). + // // Its curves do not seem to match the surfaces in the events send on selecting and dragging a curve. + // // This causes the strange behaviour. To solve this, a Clone is made of the soilProfile2D and that clone is added instead. + // //soilProfile2D = (SoilProfile2D)soilProfile2D.Clone(); + // //soilProfile2DNew.Dispose(); + // soilProfile2D = soilProfile2DNew; + // } + } + private PrepareResult PrepareKernel(MacroStability.CSharpWrapper.Input.MacroStabilityInput input) { try @@ -201,9 +216,10 @@ try { var macroStabilityOutputKernel = stabilityCalculator.Calculate(); - ParseRunResult(macroStabilityOutputKernel, out var macroStabilityOutputItem, out messages); - macroStabilityOutput.StabilityOutputItems.Add(macroStabilityOutputItem); - macroStabilityOutput.CalculationResult = CalculationResult.Succeeded; + //ParseRunResult(macroStabilityOutputKernel, out var macroStabilityOutputItem, out messages); + macroStabilityOutput = + FillEngineFromMacroStabilityWrapperOutput.FillEngineDataWithResults(macroStabilityOutputKernel, + out messages); } catch (Exception e) { @@ -212,48 +228,7 @@ } } - internal void ParseRunResult(MacroStability.CSharpWrapper.Output.MacroStabilityOutput runResult, out MacroStabilityOutputItem macroStabilityOutputItem, out List messages) - { - messages = new List(); - macroStabilityOutputItem = new MacroStabilityOutputItem(); - macroStabilityOutputItem.SafetyFactor = runResult.StabilityOutput.SafetyFactor; - if (runResult.ResultType == CalculationResultType.Succeeded) - { - macroStabilityOutputItem.CalculationResult = CalculationResult.Succeeded; - macroStabilityOutputItem.StabilityModelType = - ConversionHelper.ConvertToMStabModelTypeFromOutput(runResult.StabilityOutput.ModelOptionType); - // macroStabilityOutputItem.CircleSurfacePointLeftXCoordinate = - // runResult.StabilityOutput.MinimumSafetyCurve.Slices.First().TopLeftPoint.X; - // macroStabilityOutputItem.CircleSurfacePointRightXCoordinate = - // runResult.StabilityOutput.MinimumSafetyCurve.Slices.Last().TopRightPoint.X; - } - else - { - macroStabilityOutputItem.CalculationResult = ConversionHelper.ConvertToDamResultType(runResult.ResultType); - } - - if (runResult.StabilityOutput.Messages != null) - { - foreach (var message in runResult.StabilityOutput.Messages) - { - messages.Add(new LogMessage - { - Message = message.Content, - MessageType = ConversionHelper.ConvertKernelLogMessageTypeToLogMessageType(message.MessageType) - }); - } - } - } - /// - /// Creates the calculator for stability based on kernel input. - /// - public void CreateStabilityCalculator() - { - //Calculator.Calculate(); - } - - /// /// Fills the design results with the kernel output. /// /// The dam kernel input.