Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/DikesDesign/DesignCalculator.cs =================================================================== diff -u -r1218 -r1329 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/DikesDesign/DesignCalculator.cs (.../DesignCalculator.cs) (revision 1218) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/DikesDesign/DesignCalculator.cs (.../DesignCalculator.cs) (revision 1329) @@ -55,72 +55,84 @@ var soiProfileProbability = location.Segment.SoilProfileProbabilities[subSoilScenarioIndex]; for (int designScenarioIndex = 0; designScenarioIndex < location.Scenarios.Count; designScenarioIndex++) { - // Prepare input DesignScenario designScenario = location.Scenarios[designScenarioIndex]; - var damKernelInput = new DamKernelInput(); - var projectPath = damProjectData.ProjectPath != "" ? damProjectData.ProjectPath : Directory.GetCurrentDirectory(); - damKernelInput.ProjectDir = projectPath; - damKernelInput.CalculationDir = Path.Combine(projectPath, damProjectData.CalculationMap); - damKernelInput.Location = location; - damKernelInput.SubSoilScenario = soiProfileProbability; - damKernelInput.DamFailureMechanismeCalculationSpecification = damProjectData.DamProjectCalculationSpecification.CurrentSpecification; - damKernelInput.RiverLevelHigh = designScenario.RiverLevel; - damKernelInput.RiverLevelLow = designScenario.RiverLevelLow; - damKernelInput.FilenamePrefix = String.Format("Loc({0})_Sce({1})", designScenario.Location.Name, designScenario.LocationScenarioID); - AnalysisType analysisType = DamProjectCalculationSpecification.SelectedAnalysisType; - SynchronizeScenarioDataWithLocationData(designScenario, location); - IKernelDataInput kernelDataInput; - IKernelDataOutput kernelDataOutput; - - // Create kernelwrapper - IKernelWrapper kernelWrapper = KernelWrapperHelper.CreateKernelWrapper(damProjectData.DamProjectCalculationSpecification.CurrentSpecification); - if (kernelWrapper == null) + try { - throw new NotImplementedException(Resources.DesignCalculatorKernelNotImplemented); - } + // Prepare input + var damKernelInput = new DamKernelInput(); + var projectPath = damProjectData.ProjectPath != "" ? damProjectData.ProjectPath : Directory.GetCurrentDirectory(); + damKernelInput.ProjectDir = projectPath; + damKernelInput.CalculationDir = Path.Combine(projectPath, damProjectData.CalculationMap); + damKernelInput.Location = location; + damKernelInput.SubSoilScenario = soiProfileProbability; + damKernelInput.DamFailureMechanismeCalculationSpecification = damProjectData.DamProjectCalculationSpecification.CurrentSpecification; + damKernelInput.RiverLevelHigh = designScenario.RiverLevel; + damKernelInput.RiverLevelLow = designScenario.RiverLevelLow; + damKernelInput.FilenamePrefix = String.Format("Loc({0})_Sce({1})", designScenario.Location.Name, designScenario.LocationScenarioID); + AnalysisType analysisType = DamProjectCalculationSpecification.SelectedAnalysisType; + SynchronizeScenarioDataWithLocationData(designScenario, location); + IKernelDataInput kernelDataInput; + IKernelDataOutput kernelDataOutput; - PrepareResult prepareResult = kernelWrapper.Prepare(damKernelInput, 0, out kernelDataInput, out kernelDataOutput); + // Create kernelwrapper + IKernelWrapper kernelWrapper = KernelWrapperHelper.CreateKernelWrapper(damProjectData.DamProjectCalculationSpecification.CurrentSpecification); + if (kernelWrapper == null) + { + throw new NotImplementedException(Resources.DesignCalculatorKernelNotImplemented); + } - // 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) - { - switch (analysisType) + 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) { - case AnalysisType.AdaptGeometry: - PerformDesignCalculation( - kernelWrapper, kernelDataInput, kernelDataOutput, - damKernelInput, designScenario, calculationMessages, - damProjectData.DesignCalculations); - break; - case AnalysisType.NoAdaption: - DesignCalculatorSingle.PerformSingleCalculation( - kernelWrapper, kernelDataInput, kernelDataOutput, - damKernelInput, designScenario, calculationMessages, - damProjectData.DesignCalculations); - break; + switch (analysisType) + { + case AnalysisType.AdaptGeometry: + PerformDesignCalculation( + kernelWrapper, kernelDataInput, kernelDataOutput, + damKernelInput, designScenario, calculationMessages, + damProjectData.DesignCalculations); + break; + case AnalysisType.NoAdaption: + DesignCalculatorSingle.PerformSingleCalculation( + kernelWrapper, kernelDataInput, kernelDataOutput, + damKernelInput, designScenario, calculationMessages, + damProjectData.DesignCalculations); + break; + } } - } - else - { - if (prepareResult == PrepareResult.NotRelevant) + else { - calculationMessages.Add(new LogMessage(LogMessageType.Info, null, - string.Format(Resources.DesignCalculatorIrrelevant, - location.Name, - soiProfileProbability.ToString(), - designScenario.LocationScenarioID))); + if (prepareResult == PrepareResult.NotRelevant) + { + calculationMessages.Add(new LogMessage(LogMessageType.Info, null, + string.Format(Resources.DesignCalculatorIrrelevant, + location.Name, + soiProfileProbability.ToString(), + designScenario.LocationScenarioID))); + } + if (prepareResult == PrepareResult.Failed) + { + calculationMessages.Add(new LogMessage(LogMessageType.Error, null, + string.Format(Resources.DesignCalculatorPrepareError, + location.Name, + soiProfileProbability.ToString(), + designScenario.LocationScenarioID))); + } } - if (prepareResult == PrepareResult.Failed) - { - calculationMessages.Add(new LogMessage(LogMessageType.Error, null, - string.Format(Resources.DesignCalculatorPrepareError, - location.Name, - soiProfileProbability.ToString(), - designScenario.LocationScenarioID))); - } } + catch (Exception e) + { + calculationMessages.Add(new LogMessage(LogMessageType.Info, null, + string.Format(Resources.DesignCalculatorGeneralException, + location.Name, + soiProfileProbability.ToString(), + designScenario.LocationScenarioID, + e.Message))); + } } }