public void GetSubMechanismModelId_Always_ReturnsExpectedValues(int subMechanismModelId, int?expectedSubMechanismModelId)
        {
            // Call
            var overtoppingCalculationInput = new OvertoppingCalculationInput(
                1, double.NaN,
                new List <HydraRingRoughnessProfilePoint>(),
                new List <HydraRingForelandPoint>(),
                new HydraRingBreakWater(0, 1.1),
                2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
                15, 16, 17, 18, 19, 20, 21, 22);

            // Assert
            Assert.AreEqual(expectedSubMechanismModelId, overtoppingCalculationInput.GetSubMechanismModelId(subMechanismModelId));
        }
        /// <summary>
        /// Performs an overtopping calculation.
        /// </summary>
        /// <param name="calculation">The calculation containing the input for the overtopping calculation.</param>
        /// <param name="generalInput">The general grass cover erosion inwards calculation input parameters.</param>
        /// <param name="hydraulicBoundaryDatabaseFilePath">The path which points to the hydraulic boundary database file.</param>
        /// <param name="usePreprocessor">Indicator whether to use the preprocessor in the calculation.</param>
        /// <param name="numberOfCalculators">The total number of calculations to perform.</param>
        /// <returns>A <see cref="OvertoppingOutput"/>.</returns>
        /// <exception cref="HydraRingCalculationException">Thrown when an error occurs while performing the calculation.</exception>
        private OvertoppingOutput CalculateOvertopping(GrassCoverErosionInwardsCalculation calculation,
                                                       GeneralGrassCoverErosionInwardsInput generalInput,
                                                       string hydraulicBoundaryDatabaseFilePath,
                                                       bool usePreprocessor,
                                                       int numberOfCalculators)
        {
            NotifyProgress(string.Format(Resources.GrassCoverErosionInwardsCalculationService_Calculate_Executing_calculation_of_type_0,
                                         Resources.GrassCoverErosionInwardsCalculationService_Overtopping),
                           1, numberOfCalculators);

            OvertoppingCalculationInput overtoppingCalculationInput = CreateOvertoppingInput(calculation,
                                                                                             generalInput,
                                                                                             hydraulicBoundaryDatabaseFilePath,
                                                                                             usePreprocessor);

            PerformCalculation(() => overtoppingCalculator.Calculate(overtoppingCalculationInput),
                               () => overtoppingCalculator.LastErrorFileContent,
                               () => overtoppingCalculator.OutputDirectory,
                               calculation.Name,
                               Resources.GrassCoverErosionInwardsCalculationService_Overtopping);

            GeneralResult <TopLevelFaultTreeIllustrationPoint> generalResult = null;

            try
            {
                generalResult = calculation.InputParameters.ShouldOvertoppingOutputIllustrationPointsBeCalculated
                                    ? ConvertIllustrationPointsResult(overtoppingCalculator.IllustrationPointsResult,
                                                                      overtoppingCalculator.IllustrationPointsParserErrorMessage)
                                    : null;
            }
            catch (ArgumentException e)
            {
                log.Warn(string.Format(Resources.GrassCoverErosionInwardsCalculationService_CalculateOvertopping_Error_in_reading_illustrationPoints_for_CalculationName_0_overtopping_with_ErrorMessage_1,
                                       calculation.Name,
                                       e.Message));
            }

            var overtoppingOutput = new OvertoppingOutput(overtoppingCalculator.WaveHeight,
                                                          overtoppingCalculator.IsOvertoppingDominant,
                                                          overtoppingCalculator.ExceedanceProbabilityBeta,
                                                          generalResult);

            return(overtoppingOutput);
        }
        /// <summary>
        /// Creates an instance of <see cref="OvertoppingCalculationInput"/> for calculation purposes.
        /// </summary>
        /// <param name="calculation">The calculation containing the input for the overtopping calculation.</param>
        /// <param name="generalInput">The general grass cover erosion inwards calculation input parameters.</param>
        /// <param name="hydraulicBoundaryDatabaseFilePath">The path which points to the hydraulic boundary database file.</param>
        /// <param name="usePreprocessor">Indicator whether to use the preprocessor in the calculation.</param>
        /// <returns>A new <see cref="OvertoppingCalculationInput"/> instance.</returns>
        /// <exception cref="ArgumentException">Thrown when the <paramref name="hydraulicBoundaryDatabaseFilePath"/>
        /// contains invalid characters.</exception>
        /// <exception cref="CriticalFileReadException">Thrown when:
        /// <list type="bullet">
        /// <item>No settings database file could be found at the location of <paramref name="hydraulicBoundaryDatabaseFilePath"/>
        /// with the same name.</item>
        /// <item>Unable to open settings database file.</item>
        /// <item>Unable to read required data from database file.</item>
        /// </list>
        /// </exception>
        private static OvertoppingCalculationInput CreateOvertoppingInput(GrassCoverErosionInwardsCalculation calculation,
                                                                          GeneralGrassCoverErosionInwardsInput generalInput,
                                                                          string hydraulicBoundaryDatabaseFilePath,
                                                                          bool usePreprocessor)
        {
            var overtoppingCalculationInput = new OvertoppingCalculationInput(calculation.InputParameters.HydraulicBoundaryLocation.Id,
                                                                              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,
                                                                              calculation.InputParameters.CriticalFlowRate.Mean,
                                                                              calculation.InputParameters.CriticalFlowRate.StandardDeviation,
                                                                              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(overtoppingCalculationInput, hydraulicBoundaryDatabaseFilePath, usePreprocessor);

            return(overtoppingCalculationInput);
        }
        public void Constructor_Always_ExpectedValues()
        {
            // Setup
            const int hydraulicBoundaryLocationId = 1000;

            const double sectionNormal = 22.2;
            const double dikeHeight    = 1.1;
            const double modelFactorCriticalOvertopping = 2.2;
            const double factorFbMean = 3.3;
            const double factorFbStandardDeviation = 4.4;
            const double factorFbLowerBoundary     = 14.4;
            const double factorFbUpperBoundary     = 15.5;
            const double factorFnMean = 5.5;
            const double factorFnStandardDeviation                   = 6.6;
            const double factorFnLowerBoundary                       = 16.6;
            const double factorFnUpperBoundary                       = 17.7;
            const double modelFactorOvertopping                      = 7.7;
            const double criticalOvertoppingMean                     = 8.8;
            const double criticalOvertoppingStandardDeviation        = 9.9;
            const double modelFactorFrunupMean                       = 10.0;
            const double modelFactorFrunupStandardDeviation          = 11.1;
            const double modelFactorFrunupLowerBoundary              = 18.8;
            const double modelFactorFrunupUpperBoundary              = 19.9;
            const double exponentModelFactorShallowMean              = 12.2;
            const double exponentModelFactorShallowStandardDeviation = 13.3;
            const double exponentModelFactorShallowLowerBoundary     = 20.0;
            const double exponentModelFactorShallowUpperBoundary     = 21.1;

            var expectedRingProfilePoints = new List <HydraRingRoughnessProfilePoint>
            {
                new HydraRingRoughnessProfilePoint(1.1, 2.2, 3.3)
            };
            var expectedRingForelandPoints = new List <HydraRingForelandPoint>
            {
                new HydraRingForelandPoint(2.2, 3.3)
            };
            var expectedRingBreakWater = new HydraRingBreakWater(2, 3.3);

            // Call
            var overtoppingCalculationInput = new OvertoppingCalculationInput(
                hydraulicBoundaryLocationId, sectionNormal,
                expectedRingProfilePoints, expectedRingForelandPoints, expectedRingBreakWater,
                dikeHeight,
                modelFactorCriticalOvertopping,
                factorFbMean, factorFbStandardDeviation,
                factorFbLowerBoundary, factorFbUpperBoundary,
                factorFnMean, factorFnStandardDeviation,
                factorFnLowerBoundary, factorFnUpperBoundary,
                modelFactorOvertopping,
                criticalOvertoppingMean, criticalOvertoppingStandardDeviation,
                modelFactorFrunupMean, modelFactorFrunupStandardDeviation,
                modelFactorFrunupLowerBoundary, modelFactorFrunupUpperBoundary,
                exponentModelFactorShallowMean, exponentModelFactorShallowStandardDeviation,
                exponentModelFactorShallowLowerBoundary, exponentModelFactorShallowUpperBoundary);

            // Assert
            Assert.IsInstanceOf <ExceedanceProbabilityCalculationInput>(overtoppingCalculationInput);
            Assert.AreEqual(1, overtoppingCalculationInput.CalculationTypeId);
            Assert.AreEqual(HydraRingFailureMechanismType.DikesOvertopping, overtoppingCalculationInput.FailureMechanismType);
            Assert.AreEqual(1, overtoppingCalculationInput.VariableId);
            Assert.AreEqual(1017, overtoppingCalculationInput.FaultTreeModelId);
            Assert.AreEqual(hydraulicBoundaryLocationId, overtoppingCalculationInput.HydraulicBoundaryLocationId);
            HydraRingDataEqualityHelper.AreEqual(GetDefaultOvertoppingVariables().ToArray(), overtoppingCalculationInput.Variables.ToArray());
            CollectionAssert.AreEqual(expectedRingProfilePoints, overtoppingCalculationInput.ProfilePoints);
            CollectionAssert.AreEqual(expectedRingForelandPoints, overtoppingCalculationInput.ForelandPoints);
            Assert.AreEqual(expectedRingBreakWater, overtoppingCalculationInput.BreakWater);
            Assert.IsNaN(overtoppingCalculationInput.Beta);

            HydraRingSection hydraRingSection = overtoppingCalculationInput.Section;

            Assert.AreEqual(1, hydraRingSection.SectionId);
            Assert.IsNaN(hydraRingSection.SectionLength);
            Assert.AreEqual(sectionNormal, hydraRingSection.CrossSectionNormal);
        }
Ejemplo n.º 5
0
 public void Calculate(OvertoppingCalculationInput input)
 {
     Calculate(HydraRingUncertaintiesType.All, input);
 }