Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/FillMacroStabilityInterfaceInputFromEngine.cs =================================================================== diff -u -r6322 -r6329 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/FillMacroStabilityInterfaceInputFromEngine.cs (.../FillMacroStabilityInterfaceInputFromEngine.cs) (revision 6322) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/FillMacroStabilityInterfaceInputFromEngine.cs (.../FillMacroStabilityInterfaceInputFromEngine.cs) (revision 6329) @@ -139,14 +139,14 @@ var objectRegistry = new ObjectRegistry(); var fullInputModelType = new FullInputModelType { - PreprocessingInput = TransferPreprocessingInput(damKernelInput), + PreprocessingInput = TransferPreprocessingInput(damKernelInput, mStabParameters), StabilityModel = TransferStabilityModel(damKernelInput, mStabParameters, objectRegistry), VersionInfo = TransferVersionInfo() }; return fullInputModelType; } - private PreprocessingInputType TransferPreprocessingInput(DamKernelInput damKernelInput) + private PreprocessingInputType TransferPreprocessingInput(DamKernelInput damKernelInput, MStabParameters mStabParameters) { if (damKernelInput == null) return null; @@ -158,10 +158,103 @@ preConstructionLastStage.Surfaceline = new SurfaceLineType(); preConstructionLastStage.CreateWaternet = false; // #Bka: I can NOT find any use of this at the engine side so this must be false!? TransferSurfaceLine(damKernelInput.Location.SurfaceLine, preConstructionLastStage.Surfaceline); - //preprocessingInputType.SearchAreaConditions = + + preprocessingInputType.SearchAreaConditions = TransferSearchAreaCondition(damKernelInput, mStabParameters); + return preprocessingInputType; } + private SearchAreaConditionsType TransferSearchAreaCondition(DamKernelInput damKernelInput, MStabParameters mStabParameters) + { + SearchAreaConditionsType preprocessingSearchAreaConditions = new SearchAreaConditionsType + { + AutoGeneticAlgorithmOptions = false, //#Bka or true? is not to be found at engine side + AutoGeneticAlgorithmOptionsSpecified = true, + AutoLevenbergMarquardtOptions = false, //#Bka or true? is not to be found at engine side + AutoLevenbergMarquardtOptionsSpecified = true, + AutoSearchAreaSpecified = true, + AutoTangentLinesSpecified = true, + AutomaticForbiddenZones = false, //#Bka or true? is not to be found at engine side + AutomaticForbiddenZonesSpecified = true, + MaxSpacingBetweenBoundaries = 0.8, + MaxSpacingBetweenBoundariesSpecified = true, + OnlyAbovePleistoceenSpecified = true, + SlipPlanePosition = SearchAreaConditionsTypeSlipPlanePosition.High, //#Bka = default in C#wrapper, is not to be found at engine side + SlipPlanePositionSpecified = true, + TangentLineNumberSpecified = true, + TangentLineZBottomSpecified = true, + TangentLineZTopSpecified = true + }; + + switch (mStabParameters.Model) + { + case StabilityModelType.Bishop: + TransferBishopSearchAreaSettings(preprocessingSearchAreaConditions); + //BishopCalculationCircle = TransferBishopCalculationGrid(); #Bka, moet naar TransferStabilityModel want geen deel van TransferPreprocessingInput + break; + case StabilityModelType.UpliftVan: + TransferUpliftVanSearchAreaSettings(preprocessingSearchAreaConditions); + //UpliftVanCalculationGrid = TransferUpliftVanCalculationGrid(); #Bka, toevoegen en moet naar TransferStabilityModel want geen deel van TransferPreprocessingInput + break; + default: + throw new NotImplementedException(nameof(mStabParameters.Model)); + } + + return preprocessingSearchAreaConditions; + } + + private void TransferBishopSearchAreaSettings(SearchAreaConditionsType searchAreaConditions) + { + // In the Macrostability kernel, for Bishop, the automatic tangent lines are set by AutoSearchArea = True. + // Setting AutoTangentLines to true will create the automatic tangent lines of Uplift-Van which is not desired. + searchAreaConditions.AutoTangentLines = false; + searchAreaConditions.AutoSearchArea = BishopCalculationGrid.IsSearchAreaAutomatic; + searchAreaConditions.TangentLineNumber = BishopCalculationGrid.TangentLineCount; + searchAreaConditions.TangentLineZTop = BishopCalculationGrid.TangentLineZTop; + searchAreaConditions.TangentLineZBottom = BishopCalculationGrid.TangentLineZBottom; + } + + private void TransferUpliftVanSearchAreaSettings(SearchAreaConditionsType kernelSearchAreaConditions) + { + kernelSearchAreaConditions.AutoTangentLines = UpliftVanCalculationGrid.TangentLinesCreationMethod is TangentLinesDefinition.Automatic or TangentLinesDefinition.OnBoundaryLines; + kernelSearchAreaConditions.AutoSearchArea = UpliftVanCalculationGrid.IsGridsAutomatic; + kernelSearchAreaConditions.OnlyAbovePleistoceen = UpliftVanCalculationGrid.TangentLinesCreationMethod == TangentLinesDefinition.Automatic; + kernelSearchAreaConditions.MaxSpacingBetweenBoundaries = 0.8; + kernelSearchAreaConditions.TangentLineNumber = UpliftVanCalculationGrid.TangentLineCount; + kernelSearchAreaConditions.TangentLineZTop = UpliftVanCalculationGrid.TangentLineZTop; + kernelSearchAreaConditions.TangentLineZBottom = UpliftVanCalculationGrid.TangentLineZBottom; + } + + private BishopCalculationCircle TransferBishopCalculationGrid() + { + if (BishopCalculationGrid == null) + { + throw new ArgumentNullException(nameof(BishopCalculationGrid)); + } + + var kernelBishopCalculationCircle = new BishopCalculationCircle + { + Grid = new CalculationGridType() + { + + GridXNumber = BishopCalculationGrid.GridXCount, + GridXLeft = BishopCalculationGrid.GridXLeft, + GridXRight = BishopCalculationGrid.GridXRight, + GridZNumber = BishopCalculationGrid.GridZCount, + GridZTop = BishopCalculationGrid.GridZTop, + GridZBottom = BishopCalculationGrid.GridZBottom + } + }; + + if (!BishopCalculationGrid.IsSearchAreaAutomatic) + { + kernelBishopCalculationCircle.TangentLines = new double[BishopCalculationGrid.TangentLineLevels.Count]; + kernelBishopCalculationCircle.TangentLines = BishopCalculationGrid.TangentLineLevels.ToArray(); + } + + return kernelBishopCalculationCircle; + } + private void TransferSurfaceLine(SurfaceLine2 surfaceLineInput, SurfaceLineType surfaceLine) { surfaceLine.CharacteristicPoints = new SurfaceLineTypeCharacteristicPoint[surfaceLine.CharacteristicPoints.Length];