Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/GrassCoverErosionInwardsCalculationService.cs =================================================================== diff -u -r63ef22d4a71266b90b211becbc34cb45a93f8f14 -r799979c3ff8428d06aa94c2dff7aab779cbba55b --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/GrassCoverErosionInwardsCalculationService.cs (.../GrassCoverErosionInwardsCalculationService.cs) (revision 63ef22d4a71266b90b211becbc34cb45a93f8f14) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/GrassCoverErosionInwardsCalculationService.cs (.../GrassCoverErosionInwardsCalculationService.cs) (revision 799979c3ff8428d06aa94c2dff7aab779cbba55b) @@ -152,12 +152,8 @@ throw new ArgumentNullException(nameof(generalInput)); } - string hlcdDirectory = Path.GetDirectoryName(hydraulicBoundaryDatabaseFilePath); - SubCalculationAssessmentOutput dikeHeightOutput = null; - SubCalculationAssessmentOutput overtoppingRateOutput = null; + int numberOfCalculators = CreateCalculators(calculation, Path.GetDirectoryName(hydraulicBoundaryDatabaseFilePath)); - int numberOfCalculators = CreateCalculators(calculation, hlcdDirectory); - NotifyProgress(Resources.GrassCoverErosionInwardsCalculationService_Calculate_Executing_overtopping_calculation, 1, numberOfCalculators); CalculationServiceHelper.LogCalculationBeginTime(calculation.Name); @@ -170,18 +166,30 @@ return; } - dikeHeightOutput = CalculateDikeHeight(calculation, - assessmentSection, - generalInput, - failureMechanismContribution, - hydraulicBoundaryDatabaseFilePath, - numberOfCalculators); + SubCalculationAssessmentOutput dikeHeightOutput = CalculateDikeHeight(calculation, + assessmentSection, + generalInput, + failureMechanismContribution, + hydraulicBoundaryDatabaseFilePath, + numberOfCalculators); if (canceled) { return; } + SubCalculationAssessmentOutput overtoppingRateOutput = CalculateOvertoppingRate(calculation, + assessmentSection, + generalInput, + failureMechanismContribution, + hydraulicBoundaryDatabaseFilePath, + numberOfCalculators); + + if (canceled) + { + return; + } + calculation.Output = new GrassCoverErosionInwardsOutput( overtoppingCalculator.WaveHeight, overtoppingCalculator.IsOvertoppingDominant, @@ -191,7 +199,7 @@ generalInput.N, overtoppingCalculator.ExceedanceProbabilityBeta), dikeHeightOutput, - null); + overtoppingRateOutput); } finally { @@ -217,9 +225,13 @@ NotifyProgress(Resources.GrassCoverErosionInwardsCalculationService_Calculate_Executing_dikeheight_calculation, 2, numberOfCalculators); - double norm = GetProbabilityToUse(assessmentSection.FailureMechanismContribution.Norm, - generalInput, failureMechanismContribution, - calculation.InputParameters.DikeHeightCalculationType); + double norm = calculation.InputParameters.DikeHeightCalculationType == DikeHeightCalculationType.CalculateByAssessmentSectionNorm + ? assessmentSection.FailureMechanismContribution.Norm + : RingtoetsCommonDataCalculationService.ProfileSpecificRequiredProbability( + assessmentSection.FailureMechanismContribution.Norm, + failureMechanismContribution, + generalInput.N); + DikeHeightCalculationInput dikeHeightCalculationInput = CreateDikeHeightInput(calculation, norm, generalInput, hydraulicBoundaryDatabaseFilePath); @@ -239,6 +251,46 @@ return null; } + private SubCalculationAssessmentOutput CalculateOvertoppingRate(GrassCoverErosionInwardsCalculation calculation, + IAssessmentSection assessmentSection, + GeneralGrassCoverErosionInwardsInput generalInput, + double failureMechanismContribution, + string hydraulicBoundaryDatabaseFilePath, + int numberOfCalculators) + { + if (overtoppingRateCalculator == null) + { + return null; + } + + NotifyProgress(Resources.GrassCoverErosionInwardsCalculationService_Calculate_Executing_overtopping_rate_calculation, numberOfCalculators, numberOfCalculators); + + double norm = calculation.InputParameters.OvertoppingRateCalculationType == OvertoppingRateCalculationType.CalculateByAssessmentSectionNorm + ? assessmentSection.FailureMechanismContribution.Norm + : RingtoetsCommonDataCalculationService.ProfileSpecificRequiredProbability( + assessmentSection.FailureMechanismContribution.Norm, + failureMechanismContribution, + generalInput.N); + + OvertoppingRateCalculationInput overtoppingRateCalculationInput = CreateOvertoppingRateInput(calculation, norm, + generalInput, + hydraulicBoundaryDatabaseFilePath); + + bool overtoppingRateCalculated = CalculateOvertoppingRate(overtoppingRateCalculationInput, calculation.Name); + + if (canceled) + { + return null; + } + + if (overtoppingRateCalculated) + { + return CreateOvertoppingRateAssessmentOutput(calculation.Name, overtoppingRateCalculationInput.Beta, norm); + } + + return null; + } + private int CreateCalculators(GrassCoverErosionInwardsCalculation calculation, string hlcdDirectory) { var numberOfCalculators = 1; @@ -314,7 +366,7 @@ } /// - /// Create the output of a dike height calculation. + /// Creates the output of a dike height calculation. /// /// The name of the calculation. /// The target reliability for the calculation. @@ -342,15 +394,33 @@ converged); } - private static double GetProbabilityToUse(double assessmentSectionNorm, GeneralGrassCoverErosionInwardsInput generalInput, - double failureMechanismContribution, DikeHeightCalculationType calculateDikeHeight) + /// + /// Creates the output of an overtopping rate calculation. + /// + /// The name of the calculation. + /// The target reliability for the calculation. + /// The target probability for the calculation. + /// A . + /// Thrown when + /// or the calculated probability falls outside the [0.0, 1.0] range and is not . + private SubCalculationAssessmentOutput CreateOvertoppingRateAssessmentOutput(string calculationName, + double targetReliability, + double targetProbability) { - return calculateDikeHeight == DikeHeightCalculationType.CalculateByAssessmentSectionNorm - ? assessmentSectionNorm - : RingtoetsCommonDataCalculationService.ProfileSpecificRequiredProbability( - assessmentSectionNorm, - failureMechanismContribution, - generalInput.N); + double overtoppingRate = overtoppingRateCalculator.OvertoppingRate; + double reliability = overtoppingRateCalculator.ReliabilityIndex; + double probability = StatisticsConverter.ReliabilityToProbability(reliability); + + CalculationConvergence converged = RingtoetsCommonDataCalculationService.GetCalculationConvergence(overtoppingRateCalculator.Converged); + + if (converged != CalculationConvergence.CalculatedConverged) + { + log.Warn(string.Format(Resources.GrassCoverErosionInwardsCalculationService_OvertoppingRate_calculation_for_calculation_0_not_converged, calculationName)); + } + + return new SubCalculationAssessmentOutput(overtoppingRate, targetProbability, + targetReliability, probability, reliability, + converged); } private void NotifyProgress(string stepName, int currentStepNumber, int totalStepNumber) @@ -410,6 +480,57 @@ } /// + /// Performs the overtopping rate calculation. + /// + /// The input of the overtopping rate calculation. + /// The name of the calculation. + /// True when the calculation was successful. False otherwise. + private bool CalculateOvertoppingRate(OvertoppingRateCalculationInput overtoppingRateCalculationInput, string calculationName) + { + var exceptionThrown = false; + var overtoppingRateCalculated = false; + if (!canceled) + { + try + { + overtoppingRateCalculator.Calculate(overtoppingRateCalculationInput); + } + catch (HydraRingCalculationException) + { + if (!canceled) + { + string lastErrorContent = overtoppingRateCalculator.LastErrorFileContent; + if (string.IsNullOrEmpty(lastErrorContent)) + { + log.ErrorFormat(Resources.GrassCoverErosionInwardsCalculationService_Calculate_Error_in_overtopping_rate_grass_cover_erosion_inwards_0_calculation_no_error_report, calculationName); + } + else + { + log.ErrorFormat(Resources.GrassCoverErosionInwardsCalculationService_Calculate_Error_in_overtopping_rate_grass_cover_erosion_inwards_0_calculation_click_details_for_last_error_report_1, calculationName, lastErrorContent); + } + + exceptionThrown = true; + } + } + finally + { + string lastErrorFileContent = overtoppingRateCalculator.LastErrorFileContent; + if (CalculationServiceHelper.HasErrorOccurred(canceled, exceptionThrown, lastErrorFileContent)) + { + log.ErrorFormat(Resources.GrassCoverErosionInwardsCalculationService_Calculate_Error_in_overtopping_rate_grass_cover_erosion_inwards_0_calculation_click_details_for_last_error_report_1, calculationName, lastErrorFileContent); + } + if (!exceptionThrown && string.IsNullOrEmpty(lastErrorFileContent)) + { + overtoppingRateCalculated = true; + } + + log.InfoFormat(Resources.GrassCoverErosionInwardsCalculationService_CalculateOvertoppingRate_calculation_temporary_directory_can_be_found_on_location_0, dikeHeightCalculator.OutputDirectory); + } + } + return overtoppingRateCalculated; + } + + /// /// Creates the input for an overtopping calculation. /// /// The that holds all the information required to perform the calculation. @@ -517,6 +638,60 @@ return dikeHeightCalculationInput; } + /// + /// Creates the input for a overtopping rate calculation. + /// + /// The that holds all the information required to perform the calculation. + /// The norm to use in the calculation. + /// Calculation input parameters that apply to all instances. + /// The path to the hydraulic boundary database file. + /// A . + /// Thrown when the + /// contains invalid characters. + /// Thrown when: + /// + /// No settings database file could be found at the location of + /// with the same name. + /// Unable to open settings database file. + /// Unable to read required data from database file. + /// + /// + private static OvertoppingRateCalculationInput CreateOvertoppingRateInput(GrassCoverErosionInwardsCalculation calculation, + double norm, + GeneralGrassCoverErosionInwardsInput generalInput, + string hydraulicBoundaryDatabaseFilePath) + { + var overtoppingRateCalculationInput = new OvertoppingRateCalculationInput(calculation.InputParameters.HydraulicBoundaryLocation.Id, + norm, + calculation.InputParameters.Orientation, + ParseProfilePoints(calculation.InputParameters.DikeGeometry), + HydraRingInputParser.ParseForeshore(calculation.InputParameters), + HydraRingInputParser.ParseBreakWater(calculation.InputParameters), + calculation.InputParameters.DikeHeight, + generalInput.CriticalOvertoppingModelFactor, + generalInput.FbFactor.Mean, + generalInput.FbFactor.StandardDeviation, + generalInput.FbFactor.LowerBoundary, + generalInput.FbFactor.UpperBoundary, + generalInput.FnFactor.Mean, + generalInput.FnFactor.StandardDeviation, + generalInput.FnFactor.LowerBoundary, + generalInput.FnFactor.UpperBoundary, + generalInput.OvertoppingModelFactor, + generalInput.FrunupModelFactor.Mean, + generalInput.FrunupModelFactor.StandardDeviation, + generalInput.FrunupModelFactor.LowerBoundary, + generalInput.FrunupModelFactor.UpperBoundary, + generalInput.FshallowModelFactor.Mean, + generalInput.FshallowModelFactor.StandardDeviation, + generalInput.FshallowModelFactor.LowerBoundary, + generalInput.FshallowModelFactor.UpperBoundary); + + HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(overtoppingRateCalculationInput, hydraulicBoundaryDatabaseFilePath); + + return overtoppingRateCalculationInput; + } + private static IEnumerable ParseProfilePoints(RoughnessPoint[] roughnessProfilePoints) { return roughnessProfilePoints.Select(roughnessPoint => new HydraRingRoughnessProfilePoint(roughnessPoint.Point.X, roughnessPoint.Point.Y, roughnessPoint.Roughness)); Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/Properties/Resources.Designer.cs =================================================================== diff -u -rd56bec747401ad6676fac64af5eef6d5fd89c47c -r799979c3ff8428d06aa94c2dff7aab779cbba55b --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision d56bec747401ad6676fac64af5eef6d5fd89c47c) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 799979c3ff8428d06aa94c2dff7aab779cbba55b) @@ -124,6 +124,27 @@ } /// + /// Looks up a localized string similar to De overslagdebiet berekening voor grasbekleding erosie kruin en binnentalud '{0}' is niet gelukt. Bekijk het foutrapport door op details te klikken. + ///{1}. + /// + internal static string GrassCoverErosionInwardsCalculationService_Calculate_Error_in_overtopping_rate_grass_cover_erosion_inwards_0_calculation_click_details_for_last_error_report_1 { + get { + return ResourceManager.GetString("GrassCoverErosionInwardsCalculationService_Calculate_Error_in_overtopping_rate_gr" + + "ass_cover_erosion_inwards_0_calculation_click_details_for_last_error_report_1", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to De overslagdebiet berekening voor grasbekleding erosie kruin en binnentalud '{0}' is niet gelukt. Er is geen foutrapport beschikbaar.. + /// + internal static string GrassCoverErosionInwardsCalculationService_Calculate_Error_in_overtopping_rate_grass_cover_erosion_inwards_0_calculation_no_error_report { + get { + return ResourceManager.GetString("GrassCoverErosionInwardsCalculationService_Calculate_Error_in_overtopping_rate_gr" + + "ass_cover_erosion_inwards_0_calculation_no_error_report", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Uitvoeren dijkhoogte berekening. /// internal static string GrassCoverErosionInwardsCalculationService_Calculate_Executing_dikeheight_calculation { @@ -144,6 +165,16 @@ } /// + /// Looks up a localized string similar to Uitvoeren overslagdebiet berekening. + /// + internal static string GrassCoverErosionInwardsCalculationService_Calculate_Executing_overtopping_rate_calculation { + get { + return ResourceManager.GetString("GrassCoverErosionInwardsCalculationService_Calculate_Executing_overtopping_rate_c" + + "alculation", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Dijkhoogte berekening is uitgevoerd op de tijdelijke locatie '{0}'. Gedetailleerde invoer en uitvoer kan in de bestanden op deze locatie worden gevonden.. /// internal static string GrassCoverErosionInwardsCalculationService_CalculateDikeHeight_calculation_temporary_directory_can_be_found_on_location_0 { @@ -164,6 +195,16 @@ } /// + /// Looks up a localized string similar to Overslagdebiet berekening is uitgevoerd op de tijdelijke locatie '{0}'. Gedetailleerde invoer en uitvoer kan in de bestanden op deze locatie worden gevonden.. + /// + internal static string GrassCoverErosionInwardsCalculationService_CalculateOvertoppingRate_calculation_temporary_directory_can_be_found_on_location_0 { + get { + return ResourceManager.GetString("GrassCoverErosionInwardsCalculationService_CalculateOvertoppingRate_calculation_t" + + "emporary_directory_can_be_found_on_location_0", resourceCulture); + } + } + + /// /// Looks up a localized string similar to De HBN berekening voor grasbekleding erosie kruin en binnentalud '{0}' is niet geconvergeerd.. /// internal static string GrassCoverErosionInwardsCalculationService_DikeHeight_calculation_for_calculation_0_not_converged { @@ -172,5 +213,15 @@ "_0_not_converged", resourceCulture); } } + + /// + /// Looks up a localized string similar to De overslagdebiet berekening voor grasbekleding erosie kruin en binnentalud '{0}' is niet geconvergeerd.. + /// + internal static string GrassCoverErosionInwardsCalculationService_OvertoppingRate_calculation_for_calculation_0_not_converged { + get { + return ResourceManager.GetString("GrassCoverErosionInwardsCalculationService_OvertoppingRate_calculation_for_calcul" + + "ation_0_not_converged", resourceCulture); + } + } } } Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/Properties/Resources.resx =================================================================== diff -u -rd56bec747401ad6676fac64af5eef6d5fd89c47c -r799979c3ff8428d06aa94c2dff7aab779cbba55b --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/Properties/Resources.resx (.../Resources.resx) (revision d56bec747401ad6676fac64af5eef6d5fd89c47c) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/Properties/Resources.resx (.../Resources.resx) (revision 799979c3ff8428d06aa94c2dff7aab779cbba55b) @@ -123,18 +123,27 @@ De HBN berekening voor grasbekleding erosie kruin en binnentalud '{0}' is niet gelukt. Er is geen foutrapport beschikbaar. + + De overslagdebiet berekening voor grasbekleding erosie kruin en binnentalud '{0}' is niet gelukt. Er is geen foutrapport beschikbaar. + Overloop berekening is uitgevoerd op de tijdelijke locatie '{0}'. Gedetailleerde invoer en uitvoer kan in de bestanden op deze locatie worden gevonden. Dijkhoogte berekening is uitgevoerd op de tijdelijke locatie '{0}'. Gedetailleerde invoer en uitvoer kan in de bestanden op deze locatie worden gevonden. + + Overslagdebiet berekening is uitgevoerd op de tijdelijke locatie '{0}'. Gedetailleerde invoer en uitvoer kan in de bestanden op deze locatie worden gevonden. + Uitvoeren overloop en overslag berekening Uitvoeren dijkhoogte berekening + + Uitvoeren overslagdebiet berekening + De berekening voor grasbekleding erosie kruin en binnentalud '{0}' is niet gelukt. Bekijk het foutrapport door op details te klikken. {1} @@ -143,7 +152,14 @@ De HBN berekening voor grasbekleding erosie kruin en binnentalud '{0}' is niet gelukt. Bekijk het foutrapport door op details te klikken. {1} + + De overslagdebiet berekening voor grasbekleding erosie kruin en binnentalud '{0}' is niet gelukt. Bekijk het foutrapport door op details te klikken. +{1} + De HBN berekening voor grasbekleding erosie kruin en binnentalud '{0}' is niet geconvergeerd. + + De overslagdebiet berekening voor grasbekleding erosie kruin en binnentalud '{0}' is niet geconvergeerd. + \ No newline at end of file