Exemple #1
0
 private IEnumerable <WaveConditionsOutput> CalculateBlocks(StabilityStoneCoverWaveConditionsCalculation calculation,
                                                            IAssessmentSection assessmentSection, RoundedDouble assessmentLevel,
                                                            GeneralWaveConditionsInput generalInput, double targetProbability)
 {
     return(Calculate(calculation, assessmentSection, assessmentLevel, generalInput, targetProbability,
                      Resources.StabilityStoneCoverWaveConditions_Blocks_DisplayName));
 }
        public void Constructor_ExpectedValues()
        {
            // Call
            var inputParameters = new GeneralGrassCoverErosionOutwardsInput();

            // Assert
            Assert.AreEqual(2, inputParameters.N.NumberOfDecimalPlaces);
            Assert.AreEqual(2.0, inputParameters.N, inputParameters.N.GetAccuracy());

            GeneralWaveConditionsInput generalWaveImpactWaveConditionsInput = inputParameters.GeneralWaveImpactWaveConditionsInput;

            Assert.AreEqual(1.0, generalWaveImpactWaveConditionsInput.A, generalWaveImpactWaveConditionsInput.A.GetAccuracy());
            Assert.AreEqual(0.67, generalWaveImpactWaveConditionsInput.B, generalWaveImpactWaveConditionsInput.B.GetAccuracy());
            Assert.AreEqual(0.0, generalWaveImpactWaveConditionsInput.C, generalWaveImpactWaveConditionsInput.C.GetAccuracy());

            GeneralWaveConditionsInput generalWaveRunUpWaveConditionsInput = inputParameters.GeneralWaveRunUpWaveConditionsInput;

            Assert.AreEqual(1.0, generalWaveRunUpWaveConditionsInput.A, generalWaveRunUpWaveConditionsInput.A.GetAccuracy());
            Assert.AreEqual(1.7, generalWaveRunUpWaveConditionsInput.B, generalWaveRunUpWaveConditionsInput.B.GetAccuracy());
            Assert.AreEqual(0.3, generalWaveRunUpWaveConditionsInput.C, generalWaveRunUpWaveConditionsInput.C.GetAccuracy());

            GeneralWaveConditionsInput generalWaveImpactWithWaveDirectionWaveConditionsInput = inputParameters.GeneralWaveImpactWithWaveDirectionWaveConditionsInput;

            Assert.AreEqual(1.0, generalWaveImpactWithWaveDirectionWaveConditionsInput.A, generalWaveImpactWithWaveDirectionWaveConditionsInput.A.GetAccuracy());
            Assert.AreEqual(0.67, generalWaveImpactWithWaveDirectionWaveConditionsInput.B, generalWaveImpactWithWaveDirectionWaveConditionsInput.B.GetAccuracy());
            Assert.AreEqual(0.67, generalWaveImpactWithWaveDirectionWaveConditionsInput.C, generalWaveImpactWithWaveDirectionWaveConditionsInput.C.GetAccuracy());

            Assert.IsFalse(inputParameters.ApplyLengthEffectInSection);
        }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GeneralGrassCoverErosionOutwardsInput"/> class.
 /// </summary>
 public GeneralGrassCoverErosionOutwardsInput()
 {
     n = new RoundedDouble(numberOfDecimalPlacesN, 2.0);
     GeneralWaveImpactWaveConditionsInput = new GeneralWaveConditionsInput(1.0, 0.67, 0.0);
     GeneralWaveRunUpWaveConditionsInput  = new GeneralWaveConditionsInput(1.0, 1.7, 0.3);
     GeneralWaveImpactWithWaveDirectionWaveConditionsInput = new GeneralWaveConditionsInput(1.0, 0.67, 0.67);
 }
Exemple #4
0
        public void Calculate_Always_InputPropertiesCorrectlySentToCalculator(BreakWaterType breakWaterType)
        {
            // Setup
            IAssessmentSection assessmentSection = CreateAssessmentSectionWithHydraulicBoundaryOutput();
            WaveImpactAsphaltCoverWaveConditionsCalculation calculation = GetValidCalculation(assessmentSection.HydraulicBoundaryDatabase.Locations.First());

            calculation.InputParameters.BreakWater.Type = breakWaterType;

            var waveImpactAsphaltCoverFailureMechanism = new WaveImpactAsphaltCoverFailureMechanism();

            var calculator = new TestWaveConditionsCosineCalculator();

            var mockRepository    = new MockRepository();
            var calculatorFactory = mockRepository.StrictMock <IHydraRingCalculatorFactory>();

            calculatorFactory.Expect(cf => cf.CreateWaveConditionsCosineCalculator(null))
            .IgnoreArguments()
            .Return(calculator)
            .Repeat
            .Times(3);
            mockRepository.ReplayAll();

            using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
            {
                // Call
                new WaveImpactAsphaltCoverWaveConditionsCalculationService().Calculate(
                    calculation,
                    assessmentSection,
                    waveImpactAsphaltCoverFailureMechanism.GeneralInput);

                // Assert
                WaveConditionsCosineCalculationInput[] waveConditionsInputs = calculator.ReceivedInputs.ToArray();
                Assert.AreEqual(3, waveConditionsInputs.Length);

                var waterLevelIndex = 0;
                foreach (WaveConditionsCosineCalculationInput actualInput in waveConditionsInputs)
                {
                    GeneralWaveConditionsInput generalInput = waveImpactAsphaltCoverFailureMechanism.GeneralInput;

                    WaveConditionsInput input = calculation.InputParameters;
                    var expectedInput         = new WaveConditionsCosineCalculationInput(1,
                                                                                         input.Orientation,
                                                                                         input.HydraulicBoundaryLocation.Id,
                                                                                         assessmentSection.FailureMechanismContribution.MaximumAllowableFloodingProbability,
                                                                                         input.ForeshoreProfile.Geometry.Select(c => new HydraRingForelandPoint(c.X, c.Y)),
                                                                                         new HydraRingBreakWater(BreakWaterTypeHelper.GetHydraRingBreakWaterType(breakWaterType), input.BreakWater.Height),
                                                                                         GetWaterLevels(calculation, assessmentSection).ElementAt(waterLevelIndex++),
                                                                                         generalInput.A,
                                                                                         generalInput.B,
                                                                                         generalInput.C);

                    HydraRingDataEqualityHelper.AreEqual(expectedInput, actualInput);
                }
            }

            mockRepository.VerifyAll();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="WaveImpactAsphaltCoverFailureMechanism"/> class.
 /// </summary>
 public WaveImpactAsphaltCoverFailureMechanism()
     : base(Resources.WaveImpactAsphaltCoverFailureMechanism_DisplayName, Resources.WaveImpactAsphaltCoverFailureMechanism_Code)
 {
     CalculationsGroup = new CalculationGroup
     {
         Name = RiskeerCommonDataResources.HydraulicBoundaryConditions_DisplayName
     };
     ForeshoreProfiles = new ForeshoreProfileCollection();
     GeneralInput      = new GeneralWaveConditionsInput(1.0, 0.0, 0.0);
     GeneralWaveImpactAsphaltCoverInput = new GeneralWaveImpactAsphaltCoverInput();
     CalculationsInputComments          = new Comment();
 }
Exemple #6
0
        private IEnumerable <WaveConditionsOutput> Calculate(StabilityStoneCoverWaveConditionsCalculation calculation,
                                                             IAssessmentSection assessmentSection, RoundedDouble assessmentLevel,
                                                             GeneralWaveConditionsInput generalInput, double targetProbability,
                                                             string calculationType)
        {
            log.InfoFormat(RevetmentServiceResources.WaveConditionsCalculationService_Calculate_calculationType_0_started, calculationType);
            IEnumerable <WaveConditionsOutput> outputs = CalculateWaveConditions(calculation.InputParameters,
                                                                                 assessmentLevel, generalInput.A,
                                                                                 generalInput.B, generalInput.C, targetProbability,
                                                                                 assessmentSection.HydraulicBoundaryDatabase);

            log.InfoFormat(RevetmentServiceResources.WaveConditionsCalculationService_Calculate_calculationType_0_ended, calculationType);
            return(outputs);
        }
        /// <summary>
        /// Performs a wave conditions calculation for the wave impact on asphalt failure mechanism based on the supplied
        /// <see cref="WaveImpactAsphaltCoverWaveConditionsCalculation"/>  and sets
        /// <see cref="WaveImpactAsphaltCoverWaveConditionsCalculation.Output"/> if the calculation was successful.
        /// Error and status information is logged during the execution of the operation.
        /// </summary>
        /// <param name="calculation">The <see cref="WaveImpactAsphaltCoverWaveConditionsCalculation"/> that holds all the information required to perform the calculation.</param>
        /// <param name="assessmentSection">The <see cref="IAssessmentSection"/> that holds information about the target probability used in the calculation.</param>
        /// <param name="generalWaveConditionsInput">Calculation input parameters that apply to all <see cref="WaveImpactAsphaltCoverWaveConditionsCalculation"/> instances.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="calculation"/>, <paramref name="assessmentSection"/>
        /// or <paramref name="generalWaveConditionsInput"/> is <c>null</c>.</exception>
        /// <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 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>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when the target probability or
        /// calculated probability falls outside the [0.0, 1.0] range and is not <see cref="double.NaN"/>.</exception>
        /// <exception cref="HydraRingFileParserException">Thrown when an error occurs during parsing of the Hydra-Ring output.</exception>
        /// <exception cref="HydraRingCalculationException">Thrown when an error occurs during the calculation.</exception>
        public void Calculate(WaveImpactAsphaltCoverWaveConditionsCalculation calculation,
                              IAssessmentSection assessmentSection,
                              GeneralWaveConditionsInput generalWaveConditionsInput)
        {
            if (calculation == null)
            {
                throw new ArgumentNullException(nameof(calculation));
            }

            if (assessmentSection == null)
            {
                throw new ArgumentNullException(nameof(assessmentSection));
            }

            if (generalWaveConditionsInput == null)
            {
                throw new ArgumentNullException(nameof(generalWaveConditionsInput));
            }

            CalculationServiceHelper.LogCalculationBegin();

            RoundedDouble a = generalWaveConditionsInput.A;
            RoundedDouble b = generalWaveConditionsInput.B;
            RoundedDouble c = generalWaveConditionsInput.C;

            double targetProbability = WaveConditionsInputHelper.GetTargetProbability(calculation.InputParameters, assessmentSection);

            RoundedDouble assessmentLevel = WaveConditionsInputHelper.GetAssessmentLevel(calculation.InputParameters, assessmentSection);

            CurrentCalculationType      = Resources.WaveImpactAsphaltCover_DisplayName;
            TotalWaterLevelCalculations = calculation.InputParameters.GetWaterLevels(assessmentLevel).Count();

            try
            {
                IEnumerable <WaveConditionsOutput> outputs = CalculateWaveConditions(calculation.InputParameters,
                                                                                     assessmentLevel,
                                                                                     a, b, c, targetProbability,
                                                                                     assessmentSection.HydraulicBoundaryDatabase);

                if (!Canceled)
                {
                    calculation.Output = new WaveImpactAsphaltCoverWaveConditionsOutput(outputs);
                }
            }
            finally
            {
                CalculationServiceHelper.LogCalculationEnd();
            }
        }
Exemple #8
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            var    random = new Random(21);
            double a      = random.NextDouble();
            double b      = random.NextDouble();
            double c      = random.NextDouble();

            // Call
            var generalInput = new GeneralWaveConditionsInput(a, b, c);

            // Assert
            Assert.AreEqual(a, generalInput.A, generalInput.A.GetAccuracy());
            Assert.AreEqual(2, generalInput.A.NumberOfDecimalPlaces);
            Assert.AreEqual(b, generalInput.B, generalInput.B.GetAccuracy());
            Assert.AreEqual(2, generalInput.B.NumberOfDecimalPlaces);
            Assert.AreEqual(c, generalInput.C, generalInput.C.GetAccuracy());
            Assert.AreEqual(2, generalInput.C.NumberOfDecimalPlaces);
        }
        public void Constructor_ExpectedValues()
        {
            // Setup
            var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism();

            // Call
            var properties = new WaveImpactAsphaltCoverFailureMechanismProperties(failureMechanism);

            // Assert
            Assert.IsInstanceOf <WaveImpactAsphaltCoverFailureMechanismPropertiesBase>(properties);
            Assert.AreSame(failureMechanism, properties.Data);
            Assert.AreEqual(failureMechanism.Name, properties.Name);
            Assert.AreEqual(failureMechanism.Code, properties.Code);

            GeneralWaveConditionsInput generalWaveConditionsInput = failureMechanism.GeneralInput;

            Assert.AreEqual(generalWaveConditionsInput.A, properties.A);
            Assert.AreEqual(generalWaveConditionsInput.B, properties.B);
            Assert.AreEqual(generalWaveConditionsInput.C, properties.C);
        }
Exemple #10
0
 /// <summary>
 /// Creates a new instance of <see cref="GeneralStabilityStoneCoverWaveConditionsInput"/>.
 /// </summary>
 public GeneralStabilityStoneCoverWaveConditionsInput()
 {
     GeneralBlocksWaveConditionsInput  = new GeneralWaveConditionsInput(1.0, 1.0, 1.0);
     GeneralColumnsWaveConditionsInput = new GeneralWaveConditionsInput(1.0, 0.4, 0.8);
     n = new RoundedDouble(numberOfDecimalPlacesN, 4.0);
 }