Beispiel #1
0
        public void ParseForeshore_Use_ReturnCollection()
        {
            // Setup
            var mockRepository = new MockRepository();
            var foreshore      = mockRepository.Stub <IUseForeshore>();

            foreshore.UseForeshore = true;

            var pointOne = new Point2D(1, 1);
            var pointTwo = new Point2D(2, 2);

            foreshore.Stub(call => call.ForeshoreGeometry).Return(new RoundedPoint2DCollection(2, new[]
            {
                pointOne,
                pointTwo
            }));
            mockRepository.ReplayAll();

            // Call
            IEnumerable <HydraRingForelandPoint> parsedForeshore = HydraRingInputParser.ParseForeshore(foreshore);

            // Assert
            HydraRingForelandPoint[] actualForelandPoints = parsedForeshore.ToArray();
            Assert.AreEqual(pointOne.X, actualForelandPoints[0].X);
            Assert.AreEqual(pointOne.Y, actualForelandPoints[0].Z);
            Assert.AreEqual(pointTwo.X, actualForelandPoints[1].X);
            Assert.AreEqual(pointTwo.Y, actualForelandPoints[1].Z);

            mockRepository.VerifyAll();
        }
 private static StructuresClosureVerticalWallCalculationInput CreateClosureVerticalWallCalculationInput(
     ClosingStructuresInput structureInput,
     GeneralClosingStructuresInput generalInput)
 {
     return(new StructuresClosureVerticalWallCalculationInput(
                structureInput.HydraulicBoundaryLocation.Id,
                structureInput.StructureNormalOrientation,
                HydraRingInputParser.ParseForeshore(structureInput),
                HydraRingInputParser.ParseBreakWater(structureInput),
                generalInput.GravitationalAcceleration,
                structureInput.FactorStormDurationOpenStructure,
                structureInput.FailureProbabilityOpenStructure,
                structureInput.FailureProbabilityReparation,
                structureInput.IdenticalApertures,
                structureInput.AllowedLevelIncreaseStorage.Mean, structureInput.AllowedLevelIncreaseStorage.StandardDeviation,
                generalInput.ModelFactorStorageVolume.Mean, generalInput.ModelFactorStorageVolume.StandardDeviation,
                structureInput.StorageStructureArea.Mean, structureInput.StorageStructureArea.CoefficientOfVariation,
                generalInput.ModelFactorInflowVolume,
                structureInput.FlowWidthAtBottomProtection.Mean, structureInput.FlowWidthAtBottomProtection.StandardDeviation,
                structureInput.CriticalOvertoppingDischarge.Mean, structureInput.CriticalOvertoppingDischarge.CoefficientOfVariation,
                structureInput.FailureProbabilityStructureWithErosion,
                structureInput.StormDuration.Mean, structureInput.StormDuration.CoefficientOfVariation,
                structureInput.ProbabilityOpenStructureBeforeFlooding,
                generalInput.ModelFactorOvertoppingFlow.Mean, generalInput.ModelFactorOvertoppingFlow.StandardDeviation,
                structureInput.StructureNormalOrientation,
                structureInput.ModelFactorSuperCriticalFlow.Mean, structureInput.ModelFactorSuperCriticalFlow.StandardDeviation,
                structureInput.LevelCrestStructureNotClosing.Mean, structureInput.LevelCrestStructureNotClosing.StandardDeviation,
                structureInput.WidthFlowApertures.Mean, structureInput.WidthFlowApertures.StandardDeviation,
                structureInput.DeviationWaveDirection));
 }
        /// <summary>
        /// Creates the input for a calculation for the given <paramref name="waterLevel"/>.
        /// </summary>
        /// <param name="waterLevel">The level of the water.</param>
        /// <param name="a">The 'a' factor decided on failure mechanism level.</param>
        /// <param name="b">The 'b' factor decided on failure mechanism level.</param>
        /// <param name="c">The 'c' factor decided on failure mechanism level.</param>
        /// <param name="targetProbability">The target probability to use.</param>
        /// <param name="input">The input that is different per calculation.</param>
        /// <param name="calculationSettings">The <see cref="HydraulicBoundaryCalculationSettings"/> containing all data
        /// to perform a hydraulic boundary calculation.</param>
        /// <returns>A <see cref="WaveConditionsCalculationInput"/>.</returns>
        /// <exception cref="ArgumentException">Thrown when the hydraulic boundary database file path.
        /// contains invalid characters.</exception>
        /// <exception cref="CriticalFileReadException">Thrown when:
        /// <list type="bullet">
        /// <item>No settings database file could be found at the location of the hydraulic boundary database file path
        /// 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 WaveConditionsCosineCalculationInput CreateInput(RoundedDouble waterLevel,
                                                                        RoundedDouble a,
                                                                        RoundedDouble b,
                                                                        RoundedDouble c,
                                                                        double targetProbability,
                                                                        WaveConditionsInput input,
                                                                        HydraulicBoundaryCalculationSettings calculationSettings)
        {
            var waveConditionsCosineCalculationInput = new WaveConditionsCosineCalculationInput(
                1,
                input.Orientation,
                input.HydraulicBoundaryLocation.Id,
                targetProbability,
                HydraRingInputParser.ParseForeshore(input),
                HydraRingInputParser.ParseBreakWater(input),
                waterLevel,
                a,
                b,
                c);

            HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(waveConditionsCosineCalculationInput,
                                                                       calculationSettings.HydraulicBoundaryDatabaseFilePath,
                                                                       !string.IsNullOrEmpty(calculationSettings.PreprocessorDirectory));

            return(waveConditionsCosineCalculationInput);
        }
Beispiel #4
0
        protected override StructuresOvertoppingCalculationInput CreateInput(HeightStructuresInput structureInput,
                                                                             GeneralHeightStructuresInput generalInput,
                                                                             string hydraulicBoundaryDatabaseFilePath,
                                                                             bool usePreprocessor)
        {
            var structuresOvertoppingCalculationInput = new StructuresOvertoppingCalculationInput(
                structureInput.HydraulicBoundaryLocation.Id,
                structureInput.StructureNormalOrientation,
                HydraRingInputParser.ParseForeshore(structureInput),
                HydraRingInputParser.ParseBreakWater(structureInput),
                generalInput.GravitationalAcceleration,
                generalInput.ModelFactorOvertoppingFlow.Mean, generalInput.ModelFactorOvertoppingFlow.StandardDeviation,
                structureInput.LevelCrestStructure.Mean, structureInput.LevelCrestStructure.StandardDeviation,
                structureInput.StructureNormalOrientation,
                structureInput.ModelFactorSuperCriticalFlow.Mean, structureInput.ModelFactorSuperCriticalFlow.StandardDeviation,
                structureInput.AllowedLevelIncreaseStorage.Mean, structureInput.AllowedLevelIncreaseStorage.StandardDeviation,
                generalInput.ModelFactorStorageVolume.Mean, generalInput.ModelFactorStorageVolume.StandardDeviation,
                structureInput.StorageStructureArea.Mean, structureInput.StorageStructureArea.CoefficientOfVariation,
                generalInput.ModelFactorInflowVolume,
                structureInput.FlowWidthAtBottomProtection.Mean, structureInput.FlowWidthAtBottomProtection.StandardDeviation,
                structureInput.CriticalOvertoppingDischarge.Mean, structureInput.CriticalOvertoppingDischarge.CoefficientOfVariation,
                structureInput.FailureProbabilityStructureWithErosion,
                structureInput.WidthFlowApertures.Mean, structureInput.WidthFlowApertures.StandardDeviation,
                structureInput.DeviationWaveDirection,
                structureInput.StormDuration.Mean, structureInput.StormDuration.CoefficientOfVariation);

            HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(structuresOvertoppingCalculationInput, hydraulicBoundaryDatabaseFilePath, usePreprocessor);

            return(structuresOvertoppingCalculationInput);
        }
Beispiel #5
0
        public void ParseForeshore_DoesNotUse_ReturnEmptyCollection()
        {
            // Setup
            var mockRepository = new MockRepository();
            var foreshore      = mockRepository.Stub <IUseForeshore>();

            foreshore.UseForeshore = false;
            mockRepository.ReplayAll();

            // Call
            IEnumerable <HydraRingForelandPoint> parsedForeshore = HydraRingInputParser.ParseForeshore(foreshore);

            // Assert
            CollectionAssert.IsEmpty(parsedForeshore);
            mockRepository.VerifyAll();
        }
Beispiel #6
0
        public void ParseBreakWater_DoesNotUse_ReturnNull(BreakWaterType breakWaterType)
        {
            // Setup
            var mockRepository = new MockRepository();
            var breakWater     = mockRepository.Stub <IUseBreakWater>();

            breakWater.UseBreakWater = false;
            mockRepository.ReplayAll();

            // Call
            HydraRingBreakWater parsedBreakWater = HydraRingInputParser.ParseBreakWater(breakWater);

            // Assert
            Assert.IsNull(parsedBreakWater);
            mockRepository.VerifyAll();
        }
Beispiel #7
0
        public void ParseBreakWater_Use_ReturnHydraRingBreakWater(BreakWaterType breakWaterType)
        {
            // Setup
            var    random           = new Random(22);
            double breakWaterHeight = random.NextDouble();

            var mockRepository = new MockRepository();
            var breakWater     = mockRepository.Stub <IUseBreakWater>();

            breakWater.UseBreakWater = true;
            var expectedBreakWater = new BreakWater(breakWaterType, breakWaterHeight);

            breakWater.Stub(call => call.BreakWater).Return(expectedBreakWater);
            mockRepository.ReplayAll();

            // Call
            HydraRingBreakWater parsedBreakWater = HydraRingInputParser.ParseBreakWater(breakWater);

            // Assert
            Assert.AreEqual(BreakWaterTypeHelper.GetHydraRingBreakWaterType(breakWaterType), parsedBreakWater.Type);
            Assert.AreEqual(expectedBreakWater.Height, parsedBreakWater.Height, expectedBreakWater.Height.GetAccuracy());
            mockRepository.VerifyAll();
        }
Beispiel #8
0
        public void ParseBreakWater_InvalidBreakWaterType_ThrowInvalidEnumArgumentException()
        {
            // Setup
            var random         = new Random(22);
            var mockRepository = new MockRepository();
            var breakWater     = mockRepository.Stub <IUseBreakWater>();

            breakWater.UseBreakWater = true;
            var expectedBreakWater = new BreakWater((BreakWaterType)99, random.NextDouble());

            breakWater.Stub(call => call.BreakWater).Return(expectedBreakWater);
            mockRepository.ReplayAll();

            // Call
            TestDelegate test = () => HydraRingInputParser.ParseBreakWater(breakWater);

            // Assert
            string message = $"The value of argument 'type' ({99}) is invalid for Enum type '{typeof(BreakWaterType).Name}'.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(test, message);

            mockRepository.VerifyAll();
        }
        /// <summary>
        /// Creates an instance of <see cref="DikeHeightCalculationInput"/> for calculation purposes.
        /// </summary>
        /// <param name="calculation">The calculation containing the input for the dike height 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="DikeHeightCalculationInput"/> 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 DikeHeightCalculationInput CreateDikeHeightInput(GrassCoverErosionInwardsCalculation calculation,
                                                                        GeneralGrassCoverErosionInwardsInput generalInput,
                                                                        string hydraulicBoundaryDatabaseFilePath,
                                                                        bool usePreprocessor)
        {
            var dikeHeightCalculationInput = new DikeHeightCalculationInput(calculation.InputParameters.HydraulicBoundaryLocation.Id,
                                                                            calculation.InputParameters.DikeHeightTargetProbability,
                                                                            calculation.InputParameters.Orientation,
                                                                            ParseProfilePoints(calculation.InputParameters.DikeGeometry),
                                                                            HydraRingInputParser.ParseForeshore(calculation.InputParameters),
                                                                            HydraRingInputParser.ParseBreakWater(calculation.InputParameters),
                                                                            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(dikeHeightCalculationInput, hydraulicBoundaryDatabaseFilePath, usePreprocessor);

            return(dikeHeightCalculationInput);
        }
Beispiel #10
0
 private static StructuresStabilityPointFloodedCulvertQuadraticCalculationInput CreateFloodedCulvertQuadraticCalculationInput(
     StabilityPointStructuresInput structureInput,
     GeneralStabilityPointStructuresInput generalInput)
 {
     return(new StructuresStabilityPointFloodedCulvertQuadraticCalculationInput(
                structureInput.HydraulicBoundaryLocation.Id,
                structureInput.StructureNormalOrientation,
                HydraRingInputParser.ParseForeshore(structureInput),
                HydraRingInputParser.ParseBreakWater(structureInput),
                structureInput.VolumicWeightWater,
                generalInput.GravitationalAcceleration,
                structureInput.LevelCrestStructure.Mean,
                structureInput.LevelCrestStructure.StandardDeviation,
                structureInput.StructureNormalOrientation,
                structureInput.FactorStormDurationOpenStructure,
                structureInput.ThresholdHeightOpenWeir.Mean,
                structureInput.ThresholdHeightOpenWeir.StandardDeviation,
                structureInput.InsideWaterLevelFailureConstruction.Mean,
                structureInput.InsideWaterLevelFailureConstruction.StandardDeviation,
                structureInput.FailureProbabilityRepairClosure,
                structureInput.FailureCollisionEnergy.Mean,
                structureInput.FailureCollisionEnergy.CoefficientOfVariation,
                generalInput.ModelFactorCollisionLoad.Mean,
                generalInput.ModelFactorCollisionLoad.CoefficientOfVariation,
                structureInput.ShipMass.Mean,
                structureInput.ShipMass.CoefficientOfVariation,
                structureInput.ShipVelocity.Mean,
                structureInput.ShipVelocity.CoefficientOfVariation,
                structureInput.LevellingCount,
                structureInput.ProbabilityCollisionSecondaryStructure,
                structureInput.FlowVelocityStructureClosable.Mean,
                structureInput.FlowVelocityStructureClosable.CoefficientOfVariation,
                structureInput.InsideWaterLevel.Mean,
                structureInput.InsideWaterLevel.StandardDeviation,
                structureInput.AllowedLevelIncreaseStorage.Mean,
                structureInput.AllowedLevelIncreaseStorage.StandardDeviation,
                generalInput.ModelFactorStorageVolume.Mean,
                generalInput.ModelFactorStorageVolume.StandardDeviation,
                structureInput.StorageStructureArea.Mean,
                structureInput.StorageStructureArea.CoefficientOfVariation,
                generalInput.ModelFactorInflowVolume,
                structureInput.FlowWidthAtBottomProtection.Mean,
                structureInput.FlowWidthAtBottomProtection.StandardDeviation,
                structureInput.CriticalOvertoppingDischarge.Mean,
                structureInput.CriticalOvertoppingDischarge.CoefficientOfVariation,
                structureInput.FailureProbabilityStructureWithErosion,
                structureInput.StormDuration.Mean,
                structureInput.StormDuration.CoefficientOfVariation,
                generalInput.ModelFactorLongThreshold.Mean,
                generalInput.ModelFactorLongThreshold.StandardDeviation,
                structureInput.BankWidth.Mean,
                structureInput.BankWidth.StandardDeviation,
                structureInput.EvaluationLevel,
                generalInput.ModelFactorLoadEffect.Mean,
                generalInput.ModelFactorLoadEffect.StandardDeviation,
                generalInput.WaveRatioMaxHN,
                generalInput.WaveRatioMaxHStandardDeviation,
                structureInput.VerticalDistance,
                generalInput.ModificationFactorWavesSlowlyVaryingPressureComponent,
                generalInput.ModificationFactorDynamicOrImpulsivePressureComponent,
                structureInput.DrainCoefficient.Mean,
                structureInput.DrainCoefficient.StandardDeviation,
                structureInput.AreaFlowApertures.Mean,
                structureInput.AreaFlowApertures.StandardDeviation,
                structureInput.ConstructiveStrengthQuadraticLoadModel.Mean,
                structureInput.ConstructiveStrengthQuadraticLoadModel.CoefficientOfVariation,
                structureInput.StabilityQuadraticLoadModel.Mean,
                structureInput.StabilityQuadraticLoadModel.CoefficientOfVariation));
 }