Index: Riskeer/Piping/src/Riskeer.Piping.Service/Probabilistic/ProbabilisticPipingCalculationService.cs
===================================================================
diff -u -r71c3adcd5c30cb64e6a1b804e6841558e8d2d712 -re2e68bfffc5f32da0f436e4fa9c694d881afc8cd
--- Riskeer/Piping/src/Riskeer.Piping.Service/Probabilistic/ProbabilisticPipingCalculationService.cs (.../ProbabilisticPipingCalculationService.cs) (revision 71c3adcd5c30cb64e6a1b804e6841558e8d2d712)
+++ Riskeer/Piping/src/Riskeer.Piping.Service/Probabilistic/ProbabilisticPipingCalculationService.cs (.../ProbabilisticPipingCalculationService.cs) (revision e2e68bfffc5f32da0f436e4fa9c694d881afc8cd)
@@ -21,14 +21,11 @@
using System;
using System.Collections.Generic;
-using System.ComponentModel;
using System.Linq;
-using Core.Common.Base.Geometry;
using Core.Common.Base.IO;
using log4net;
using Riskeer.Common.Data.AssessmentSection;
using Riskeer.Common.Data.Exceptions;
-using Riskeer.Common.Data.FailureMechanism;
using Riskeer.Common.Data.Hydraulics;
using Riskeer.Common.Data.IllustrationPoints;
using Riskeer.Common.Data.Probabilistics;
@@ -58,7 +55,7 @@
private IPipingCalculator profileSpecificCalculator;
private IPipingCalculator sectionSpecificCalculator;
private bool canceled;
-
+
///
/// Fired when the calculation progress changed.
///
@@ -110,38 +107,49 @@
}
///
+ /// Cancels any currently running grass cover erosion inwards calculation.
+ ///
+ public void Cancel()
+ {
+ profileSpecificCalculator?.Cancel();
+ sectionSpecificCalculator?.Cancel();
+ canceled = true;
+ }
+
+ ///
/// Performs a structures calculation based on the supplied and sets
/// if the calculation was successful. Error and status information is logged during the execution of the operation.
///
/// The that holds all the information required to perform the calculation.
- /// The which the belongs to.
+ /// Calculation input parameters that apply to all instances.
/// The with the
/// hydraulic boundary calculation settings.
+ /// The length of the section the calculation belongs to.
/// Preprocessing is disabled when the preprocessor directory equals .
- /// Thrown when any parameter is null.
+ /// Thrown when ,
+ /// or is null.
/// Thrown when the hydraulic boundary database file path
/// contains invalid characters.
- /// Thrown when an unexpected
- /// enum value is encountered.
/// Thrown when:
///
/// - No settings database file could be found at the location of the hydraulic boundary database file path
/// with the same name.
/// - Unable to open settings database file.
/// - Unable to read required data from database file.
///
- /// Thrown when an error occurs while performing the calculation.
- public void Calculate(ProbabilisticPipingCalculation calculation, PipingFailureMechanism failureMechanism,
- HydraulicBoundaryCalculationSettings calculationSettings)
+ /// Thrown when an error occurs during parsing of the Hydra-Ring output.
+ /// Thrown when an error occurs during the calculation.
+ internal void Calculate(ProbabilisticPipingCalculation calculation, GeneralPipingInput generalInput,
+ HydraulicBoundaryCalculationSettings calculationSettings, double sectionLength)
{
if (calculation == null)
{
throw new ArgumentNullException(nameof(calculation));
}
- if (failureMechanism == null)
+ if (generalInput == null)
{
- throw new ArgumentNullException(nameof(failureMechanism));
+ throw new ArgumentNullException(nameof(generalInput));
}
if (calculationSettings == null)
@@ -163,15 +171,15 @@
try
{
PartialProbabilisticPipingOutput profileSpecificOutput = CalculateProfileSpecific(
- calculation, failureMechanism, hydraulicBoundaryDatabaseFilePath, usePreprocessor);
+ calculation, generalInput, hydraulicBoundaryDatabaseFilePath, usePreprocessor);
if (canceled)
{
return;
}
PartialProbabilisticPipingOutput sectionSpecificOutput = CalculateSectionSpecific(
- calculation, failureMechanism, hydraulicBoundaryDatabaseFilePath, usePreprocessor);
+ calculation, generalInput, sectionLength, hydraulicBoundaryDatabaseFilePath, usePreprocessor);
if (canceled)
{
@@ -189,25 +197,15 @@
}
}
- ///
- /// Cancels any currently running grass cover erosion inwards calculation.
- ///
- public void Cancel()
+ private PartialProbabilisticPipingOutput CalculateProfileSpecific(ProbabilisticPipingCalculation calculation, GeneralPipingInput generalInput,
+ string hydraulicBoundaryDatabaseFilePath, bool usePreprocessor)
{
- profileSpecificCalculator?.Cancel();
- sectionSpecificCalculator?.Cancel();
- canceled = true;
- }
-
- private PartialProbabilisticPipingOutput CalculateProfileSpecific(ProbabilisticPipingCalculation calculation, PipingFailureMechanism failureMechanism, string hydraulicBoundaryDatabaseFilePath, bool usePreprocessor)
- {
NotifyProgress(string.Format(Resources.ProbabilisticPipingCalculationService_Calculate_Executing_calculation_of_type_0,
Resources.ProbabilisticPipingCalculationService_ProfileSpecific),
1, numberOfCalculators);
PipingCalculationInput profileSpecificCalculationInput = CreateInput(
- calculation, failureMechanism.GeneralInput, 0,
- hydraulicBoundaryDatabaseFilePath, usePreprocessor);
+ calculation, generalInput, 0, hydraulicBoundaryDatabaseFilePath, usePreprocessor);
PerformCalculation(() => profileSpecificCalculator.Calculate(profileSpecificCalculationInput),
() => profileSpecificCalculator.LastErrorFileContent,
@@ -233,16 +231,15 @@
generalResult);
}
- private PartialProbabilisticPipingOutput CalculateSectionSpecific(ProbabilisticPipingCalculation calculation, PipingFailureMechanism failureMechanism, string hydraulicBoundaryDatabaseFilePath, bool usePreprocessor)
+ private PartialProbabilisticPipingOutput CalculateSectionSpecific(ProbabilisticPipingCalculation calculation, GeneralPipingInput generalInput,
+ double sectionLength, string hydraulicBoundaryDatabaseFilePath, bool usePreprocessor)
{
NotifyProgress(string.Format(Resources.ProbabilisticPipingCalculationService_Calculate_Executing_calculation_of_type_0,
Resources.ProbabilisticPipingCalculationService_SectionSpecific),
2, numberOfCalculators);
- FailureMechanismSection section = failureMechanism.Sections.First(s => calculation.IsSurfaceLineIntersectionWithReferenceLineInSection(Math2D.ConvertPointsToLineSegments(s.Points)));
-
PipingCalculationInput sectionSpecificCalculationInput = CreateInput(
- calculation, failureMechanism.GeneralInput, section.Length,
+ calculation, generalInput, sectionLength,
hydraulicBoundaryDatabaseFilePath, usePreprocessor);
PerformCalculation(() => sectionSpecificCalculator.Calculate(sectionSpecificCalculationInput),
@@ -429,7 +426,7 @@
return validationResults;
}
-
+
private void NotifyProgress(string stepName, int currentStepNumber, int totalStepNumber)
{
OnProgressChanged?.Invoke(stepName, currentStepNumber, totalStepNumber);