Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.KernelWrapper/Kernels/UpliftVan/UpliftVanKernelWrapper.cs =================================================================== diff -u -r64553ee5bb2b3c27b0bcfa5eb79aec9e75b9942b -r44f821c9dc2c2355637eaa3175832f8c3c85ed32 --- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.KernelWrapper/Kernels/UpliftVan/UpliftVanKernelWrapper.cs (.../UpliftVanKernelWrapper.cs) (revision 64553ee5bb2b3c27b0bcfa5eb79aec9e75b9942b) +++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.KernelWrapper/Kernels/UpliftVan/UpliftVanKernelWrapper.cs (.../UpliftVanKernelWrapper.cs) (revision 44f821c9dc2c2355637eaa3175832f8c3c85ed32) @@ -129,7 +129,7 @@ public void SetSurfaceLine(SurfaceLine2 surfaceLine) { kernelModel.PreprocessingModel.LastStage.SurfaceLine = surfaceLine; - foreach (var preProcessingConstructionStage in kernelModel.PreprocessingModel.PreProcessingConstructionStages) + foreach (PreprocessingConstructionStage preProcessingConstructionStage in kernelModel.PreprocessingModel.PreProcessingConstructionStages) { preProcessingConstructionStage.SurfaceLine = surfaceLine; } @@ -152,18 +152,12 @@ public void SetFixedSoilStresses(IEnumerable soilStresses) { - kernelModel.StabilityModel.ConstructionStages.ForEachElementDo(cs => - { - cs.SoilStresses.AddRange(soilStresses); - }); + kernelModel.StabilityModel.ConstructionStages.ForEachElementDo(cs => { cs.SoilStresses.AddRange(soilStresses); }); } public void SetPreConsolidationStresses(IEnumerable preConsolidationStresses) { - kernelModel.StabilityModel.ConstructionStages.ForEachElementDo(cs => - { - cs.PreconsolidationStresses.AddRange(preConsolidationStresses); - }); + kernelModel.StabilityModel.ConstructionStages.ForEachElementDo(cs => { cs.PreconsolidationStresses.AddRange(preConsolidationStresses); }); } public void SetAutomaticForbiddenZones(bool automaticForbiddenZones) @@ -193,11 +187,7 @@ { try { - // The following lines are necessary as a workaround for the kernel. - // The kernel validates before generating the grid, with calling Update, this is prevented. - PreprocessingModel preprocessingModel = kernelModel.PreprocessingModel; - var preprocessor = new StabilityPreprocessor(); - preprocessor.Update(kernelModel.StabilityModel, preprocessingModel); + PreprocessModel(); IValidationResult[] validationResults = Validator.Validate(kernelModel); return validationResults; @@ -208,6 +198,21 @@ } } + /// + /// Pre processes the . + /// + /// + /// Workaround for the kernel: The kernel validates before generating the grid. + /// This is prevented by calling update on the . + /// Should be fixed in a new kernel version. + /// + private void PreprocessModel() + { + PreprocessingModel preprocessingModel = kernelModel.PreprocessingModel; + var preprocessor = new StabilityPreprocessor(); + preprocessor.Update(kernelModel.StabilityModel, preprocessingModel); + } + private void WriteXmlFile() { FullInputModelType fullInputModel = FillXmlInputFromDomain.CreateStabilityInput(kernelModel); @@ -234,18 +239,28 @@ private void AddPreProcessingConstructionStages() { - kernelModel.PreprocessingModel.PreProcessingConstructionStages.Add(new PreprocessingConstructionStage + var preprocessingConstructionStage = new PreprocessingConstructionStage { - StabilityModel = kernelModel.StabilityModel, - Locations = - { - // This location is necessary to prevent a location missing warning from the kernel. - // In new kernel versions the kernel itself does this action so later this can be removed. - new Location - { - WaternetCreationMode = WaternetCreationMode.FillInWaternetValues - } - } + StabilityModel = kernelModel.StabilityModel + }; + AddPreprocessingConstructionStageLocation(preprocessingConstructionStage); + kernelModel.PreprocessingModel.PreProcessingConstructionStages.Add(preprocessingConstructionStage); + } + + /// + /// Add a default location to the . + /// + /// The + /// to add the to. + /// + /// This is a workaround to prevent a location missing warning from the kernel. + /// Should be fixed in a new kernel version. + /// + private static void AddPreprocessingConstructionStageLocation(PreprocessingConstructionStage preprocessingConstructionStage) + { + preprocessingConstructionStage.Locations.Add(new Location + { + WaternetCreationMode = WaternetCreationMode.FillInWaternetValues }); }