public override IEnumerable <PropertyInfo> GetPropertyInfos() { yield return(new PropertyInfo <HydraulicLoadsStateFailureMechanismContext, HydraulicLoadsStateFailureMechanismProperties> { CreateInstance = context => new HydraulicLoadsStateFailureMechanismProperties(context.WrappedData) }); yield return(new PropertyInfo <RegistrationStateFailureMechanismContext, RegistrationStateFailureMechanismProperties> { CreateInstance = context => new RegistrationStateFailureMechanismProperties(context.WrappedData) }); yield return(new PropertyInfo <StabilityStoneCoverWaveConditionsOutputContext, StabilityStoneCoverWaveConditionsOutputProperties> { CreateInstance = context => new StabilityStoneCoverWaveConditionsOutputProperties(context.WrappedData, context.Input) }); yield return(new PropertyInfo <StabilityStoneCoverWaveConditionsInputContext, StabilityStoneCoverWaveConditionsInputContextProperties> { CreateInstance = context => new StabilityStoneCoverWaveConditionsInputContextProperties( context, () => WaveConditionsInputHelper.GetAssessmentLevel(context.WrappedData, context.AssessmentSection), new ObservablePropertyChangeHandler(context.Calculation, context.WrappedData)) }); }
public void GetAssessmentLevel_ValidInputWithHydraulicBoundaryLocation_ReturnsExpectedValue( WaveConditionsInputWaterLevelType waterLevelType, Func <WaveConditionsInput, IAssessmentSection, double> getExpectedAssessmentLevel) { // Setup var assessmentSection = new AssessmentSectionStub(); var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); assessmentSection.SetHydraulicBoundaryLocationCalculations(new[] { hydraulicBoundaryLocation }, true); var input = new WaveConditionsInput { HydraulicBoundaryLocation = hydraulicBoundaryLocation, WaterLevelType = waterLevelType, CalculationsTargetProbability = assessmentSection.WaterLevelCalculationsForUserDefinedTargetProbabilities.First() }; // Call double assessmentLevel = WaveConditionsInputHelper.GetAssessmentLevel(input, assessmentSection); // Assert Assert.AreEqual(getExpectedAssessmentLevel(input, assessmentSection), assessmentLevel); }
private void SetConfigurationTargetProbabilityProperty(WaveConditionsCalculationConfiguration configuration, WaveConditionsInput input) { if (input.WaterLevelType == WaveConditionsInputWaterLevelType.None) { return; } configuration.TargetProbability = WaveConditionsInputHelper.GetTargetProbability(input, assessmentSection); }
private static void Validate(WaveImpactAsphaltCoverWaveConditionsCalculationContext context) { IAssessmentSection assessmentSection = context.AssessmentSection; WaveImpactAsphaltCoverWaveConditionsCalculation calculation = context.WrappedData; WaveConditionsCalculationServiceBase.Validate(calculation.InputParameters, WaveConditionsInputHelper.GetAssessmentLevel(calculation.InputParameters, context.AssessmentSection), assessmentSection.HydraulicBoundaryDatabase); }
private static void ValidateAllInCalculationGroup(WaveImpactAsphaltCoverCalculationGroupContext context) { foreach (WaveImpactAsphaltCoverWaveConditionsCalculation calculation in context.WrappedData.GetCalculations().OfType <WaveImpactAsphaltCoverWaveConditionsCalculation>()) { WaveConditionsCalculationServiceBase.Validate(calculation.InputParameters, WaveConditionsInputHelper.GetAssessmentLevel(calculation.InputParameters, context.AssessmentSection), context.AssessmentSection.HydraulicBoundaryDatabase); } }
public void GetTargetProbability_InputNull_ThrowsArgumentNullException() { // Call void Call() => WaveConditionsInputHelper.GetTargetProbability(null, new AssessmentSectionStub()); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("input", exception.ParamName); }
public void GetUpperBoundaryAssessmentLevel_DifferentAssessmentLevels_ReturnsExpectedUpperBoundary(double assessmentLevel, double expectedUpperBoundary) { // Call RoundedDouble upperBoundary = WaveConditionsInputHelper.GetUpperBoundaryAssessmentLevel((RoundedDouble)assessmentLevel); // Assert Assert.AreEqual(2, upperBoundary.NumberOfDecimalPlaces); Assert.AreEqual(expectedUpperBoundary, upperBoundary); }
public void GetAssessmentLevel_AssessmentSectionNull_ThrowsArgumentNullException() { // Call void Call() => WaveConditionsInputHelper.GetAssessmentLevel(new WaveConditionsInput(), null); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("assessmentSection", exception.ParamName); }
public void GetHydraulicBoundaryLocationCalculation_AssessmentSectionNull_ThrowsArgumentNullException() { // Call void Call() => WaveConditionsInputHelper.GetHydraulicBoundaryLocationCalculation(new WaveConditionsInput(), null); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("assessmentSection", exception.ParamName); }
private static void ValidateAllInCalculationGroup(GrassCoverErosionOutwardsCalculationGroupContext context) { CalculationGroup calculationGroup = context.WrappedData; foreach (GrassCoverErosionOutwardsWaveConditionsCalculation calculation in calculationGroup.GetCalculations().OfType <GrassCoverErosionOutwardsWaveConditionsCalculation>()) { WaveConditionsCalculationServiceBase.Validate( calculation.InputParameters, WaveConditionsInputHelper.GetAssessmentLevel(calculation.InputParameters, context.AssessmentSection), context.AssessmentSection.HydraulicBoundaryDatabase); } }
public void SetWaterLevelType_WaveConditionsInputNull_ThrowsArgumentNullException() { // Setup var random = new Random(21); // Call void Call() => WaveConditionsInputHelper.SetWaterLevelType(null, random.NextEnumValue <NormativeProbabilityType>()); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("waveConditionsInput", exception.ParamName); }
public void SetWaterLevelType_WithWaveConditionsInputAndVariousNormativeProbabilityTypes_SetsWaterLevelType( NormativeProbabilityType normativeProbabilityType, WaveConditionsInputWaterLevelType expectedWaveConditionsInputWaterLevelType) { // Setup var waveConditionsInput = new WaveConditionsInput(); // Call WaveConditionsInputHelper.SetWaterLevelType(waveConditionsInput, normativeProbabilityType); // Assert Assert.AreEqual(expectedWaveConditionsInputWaterLevelType, waveConditionsInput.WaterLevelType); }
public override IEnumerable <ViewInfo> GetViewInfos() { yield return(new RiskeerViewInfo <HydraulicLoadsStateFailureMechanismContext, HydraulicLoadsStateFailureMechanismView>(() => Gui) { GetViewName = (view, context) => context.WrappedData.Name, CreateInstance = context => new HydraulicLoadsStateFailureMechanismView(context.WrappedData, context.Parent) }); yield return(new RiskeerViewInfo <RegistrationStateFailureMechanismContext, RegistrationStateFailureMechanismView>(() => Gui) { GetViewName = (view, context) => context.WrappedData.Name, AdditionalDataCheck = context => context.WrappedData.InAssembly, CreateInstance = context => new RegistrationStateFailureMechanismView(context.WrappedData, context.Parent), CloseForData = CloseFailureMechanismViewForData }); yield return(new RiskeerViewInfo < WaveImpactAsphaltCoverFailureMechanismSectionResultContext, IObservableEnumerable <NonAdoptableWithProfileProbabilityFailureMechanismSectionResult>, NonAdoptableWithProfileProbabilityFailureMechanismResultView <WaveImpactAsphaltCoverFailureMechanism> >(() => Gui) { GetViewName = (view, context) => RiskeerCommonFormsResources.FailureMechanism_AssessmentResult_DisplayName, CloseForData = CloseFailureMechanismResultViewForData, GetViewData = context => context.WrappedData, CreateInstance = context => { var failureMechanism = (WaveImpactAsphaltCoverFailureMechanism)context.FailureMechanism; IAssessmentSection assessmentSection = context.AssessmentSection; return new NonAdoptableWithProfileProbabilityFailureMechanismResultView <WaveImpactAsphaltCoverFailureMechanism>( context.WrappedData, failureMechanism, assessmentSection, WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism, fm => fm.GeneralWaveImpactAsphaltCoverInput.ApplyLengthEffectInSection, sr => WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleSection(sr, failureMechanism, assessmentSection)); } }); yield return(new RiskeerViewInfo <WaveImpactAsphaltCoverWaveConditionsInputContext, ICalculation <WaveConditionsInput>, WaveConditionsInputView>(() => Gui) { GetViewName = (view, context) => RiskeerCommonFormsResources.Calculation_Input, CloseForData = RiskeerPluginHelper.ShouldCloseViewWithCalculationData, CreateInstance = context => new WaveConditionsInputView( context.Calculation, () => WaveConditionsInputHelper.GetHydraulicBoundaryLocationCalculation(context.WrappedData, context.AssessmentSection), new WaveImpactAsphaltCoverWaveConditionsInputViewStyle()) }); }
public void SetWaterLevelType_InvalidNormativeProbabilityType_ThrowsInvalidEnumArgumentException() { // Setup const NormativeProbabilityType normativeProbabilityType = (NormativeProbabilityType)99; // Call void Call() => WaveConditionsInputHelper.SetWaterLevelType(new WaveConditionsInput(), normativeProbabilityType); // Assert var expectedMessage = $"The value of argument 'normativeProbabilityType' ({normativeProbabilityType}) is invalid for Enum type '{nameof(NormativeProbabilityType)}'."; var exception = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(Call, expectedMessage); Assert.AreEqual("normativeProbabilityType", exception.ParamName); }
private static void AddWaveConditionsCalculation(WaveImpactAsphaltCoverCalculationGroupContext nodeData) { var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation { Name = NamingHelper.GetUniqueName(nodeData.WrappedData.Children, RiskeerCommonDataResources.Calculation_DefaultName, c => c.Name) }; WaveConditionsInputHelper.SetWaterLevelType(calculation.InputParameters, nodeData.AssessmentSection.FailureMechanismContribution.NormativeProbabilityType); nodeData.WrappedData.Children.Add(calculation); nodeData.WrappedData.NotifyObservers(); }
/// <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(); } }
public override IEnumerable <ExportInfo> GetExportInfos() { yield return(new ExportInfo <WaveImpactAsphaltCoverCalculationGroupContext> { Name = context => RiskeerCommonFormsResources.WaveConditionsExporter_DisplayName, Extension = RiskeerCommonFormsResources.DataTypeDisplayName_csv_file_filter_Extension, CreateFileExporter = (context, filePath) => { IEnumerable <WaveImpactAsphaltCoverWaveConditionsCalculation> calculations = context.WrappedData.GetCalculations().Cast <WaveImpactAsphaltCoverWaveConditionsCalculation>(); return new WaveImpactAsphaltCoverWaveConditionsExporter(calculations, filePath, input => WaveConditionsInputHelper.GetTargetProbability(input, context.AssessmentSection) .ToString(CultureInfo.InvariantCulture)); }, IsEnabled = context => context.WrappedData.GetCalculations().Cast <WaveImpactAsphaltCoverWaveConditionsCalculation>().Any(c => c.HasOutput), GetExportPath = () => ExportHelper.GetFilePath(GetInquiryHelper(), GetWaveConditionsFileFilterGenerator()) }); yield return(new ExportInfo <WaveImpactAsphaltCoverWaveConditionsCalculationContext> { Name = context => RiskeerCommonFormsResources.WaveConditionsExporter_DisplayName, Extension = RiskeerCommonFormsResources.DataTypeDisplayName_csv_file_filter_Extension, CreateFileExporter = (context, filePath) => new WaveImpactAsphaltCoverWaveConditionsExporter(new[] { context.WrappedData }, filePath, input => WaveConditionsInputHelper.GetTargetProbability(input, context.AssessmentSection) .ToString(CultureInfo.InvariantCulture)), IsEnabled = context => context.WrappedData.HasOutput, GetExportPath = () => ExportHelper.GetFilePath(GetInquiryHelper(), GetWaveConditionsFileFilterGenerator()) }); yield return(RiskeerExportInfoFactory.CreateCalculationGroupConfigurationExportInfo <WaveImpactAsphaltCoverCalculationGroupContext>( (context, filePath) => new WaveImpactAsphaltCoverWaveConditionsCalculationConfigurationExporter( context.WrappedData.Children, filePath, context.AssessmentSection), context => context.WrappedData.Children.Any(), GetInquiryHelper())); yield return(RiskeerExportInfoFactory.CreateCalculationConfigurationExportInfo <WaveImpactAsphaltCoverWaveConditionsCalculationContext>( (context, filePath) => new WaveImpactAsphaltCoverWaveConditionsCalculationConfigurationExporter( new[] { context.WrappedData }, filePath, context.AssessmentSection), GetInquiryHelper())); }
/// <summary> /// Creates a calculation and sets the <paramref name="hydraulicBoundaryLocation"/> /// and the water level type on its input. /// </summary> /// <param name="hydraulicBoundaryLocation">The <see cref="HydraulicBoundaryLocation"/> to set.</param> /// <param name="calculations">The list of calculations to base the calculation name from.</param> /// <param name="normativeProbabilityType">The <see cref="NormativeProbabilityType"/> to base the water level type input on.</param> /// <returns>An <see cref="ICalculationBase"/> representing a stability stone cover calculation.</returns> /// <exception cref="InvalidEnumArgumentException">Thrown when <paramref name="normativeProbabilityType"/> is an invalid value.</exception> /// <exception cref="NotSupportedException">Thrown when <paramref name="normativeProbabilityType"/> is a valid value, /// but unsupported.</exception> private static ICalculationBase CreateStabilityStoneCoverWaveConditionsCalculation( HydraulicBoundaryLocation hydraulicBoundaryLocation, IEnumerable <ICalculationBase> calculations, NormativeProbabilityType normativeProbabilityType) { string nameBase = hydraulicBoundaryLocation.Name; var calculation = new StabilityStoneCoverWaveConditionsCalculation { Name = NamingHelper.GetUniqueName(calculations, nameBase, c => c.Name), InputParameters = { HydraulicBoundaryLocation = hydraulicBoundaryLocation } }; WaveConditionsInputHelper.SetWaterLevelType(calculation.InputParameters, normativeProbabilityType); return(calculation); }
public void GetAssessmentLevel_InputWithInvalidWaterLevelType_ThrowsInvalidEnumArgumentException() { // Setup const WaveConditionsInputWaterLevelType waterLevelType = (WaveConditionsInputWaterLevelType)99; var waveConditionsInput = new WaveConditionsInput { WaterLevelType = waterLevelType }; // Call void Call() => WaveConditionsInputHelper.GetAssessmentLevel(waveConditionsInput, new AssessmentSectionStub()); // Assert var expectedMessage = $"The value of argument 'WaterLevelType' ({waterLevelType}) is invalid for Enum type '{nameof(WaveConditionsInputWaterLevelType)}'."; var exception = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(Call, expectedMessage); Assert.AreEqual("WaterLevelType", exception.ParamName); }
public void GetTargetProbability_ValidInput_ReturnsExpectedValue( WaveConditionsInputWaterLevelType waterLevelType, Func <WaveConditionsInput, IAssessmentSection, double> getExpectedTargetProbability) { // Setup var assessmentSection = new AssessmentSectionStub(); var input = new WaveConditionsInput { WaterLevelType = waterLevelType, CalculationsTargetProbability = new HydraulicBoundaryLocationCalculationsForTargetProbability(0.01) }; // Call double targetProbability = WaveConditionsInputHelper.GetTargetProbability(input, assessmentSection); // Assert Assert.AreEqual(getExpectedTargetProbability(input, assessmentSection), targetProbability); }
public void GetAssessmentLevel_ValidInputWithoutHydraulicBoundaryLocation_ReturnsNaN(WaveConditionsInputWaterLevelType waterLevelType) { // Setup var assessmentSection = new AssessmentSectionStub(); assessmentSection.SetHydraulicBoundaryLocationCalculations(new[] { new TestHydraulicBoundaryLocation() }, true); var input = new WaveConditionsInput { WaterLevelType = waterLevelType, CalculationsTargetProbability = assessmentSection.WaterLevelCalculationsForUserDefinedTargetProbabilities.First() }; // Call double assessmentLevel = WaveConditionsInputHelper.GetAssessmentLevel(input, assessmentSection); // Assert Assert.IsNaN(assessmentLevel); }
/// <summary> /// Performs a wave conditions calculation for the stability of stone revetment failure mechanism based on the supplied /// <see cref="StabilityStoneCoverWaveConditionsCalculation"/> and sets /// <see cref="StabilityStoneCoverWaveConditionsCalculation.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="StabilityStoneCoverWaveConditionsCalculation"/> 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="StabilityStoneCoverWaveConditionsCalculation"/> 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 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> /// <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(StabilityStoneCoverWaveConditionsCalculation calculation, IAssessmentSection assessmentSection, GeneralStabilityStoneCoverWaveConditionsInput 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)); } StabilityStoneCoverWaveConditionsInput calculationInput = calculation.InputParameters; StabilityStoneCoverWaveConditionsCalculationType calculationType = calculationInput.CalculationType; if (!Enum.IsDefined(typeof(StabilityStoneCoverWaveConditionsCalculationType), calculationType)) { throw new InvalidEnumArgumentException(nameof(calculationType), (int)calculationType, typeof(StabilityStoneCoverWaveConditionsCalculationType)); } CalculationServiceHelper.LogCalculationBegin(); double targetProbability = WaveConditionsInputHelper.GetTargetProbability(calculationInput, assessmentSection); RoundedDouble assessmentLevel = WaveConditionsInputHelper.GetAssessmentLevel(calculationInput, assessmentSection); int waterLevelCount = calculationInput.GetWaterLevels(assessmentLevel).Count(); TotalWaterLevelCalculations = calculationType == StabilityStoneCoverWaveConditionsCalculationType.Both ? waterLevelCount * 2 : waterLevelCount; try { IEnumerable <WaveConditionsOutput> blocksOutputs = null; if (calculationType == StabilityStoneCoverWaveConditionsCalculationType.Both || calculationType == StabilityStoneCoverWaveConditionsCalculationType.Blocks) { CurrentCalculationType = Resources.StabilityStoneCoverWaveConditions_Blocks_DisplayName; blocksOutputs = CalculateBlocks(calculation, assessmentSection, assessmentLevel, generalWaveConditionsInput.GeneralBlocksWaveConditionsInput, targetProbability); } if (Canceled) { return; } IEnumerable <WaveConditionsOutput> columnsOutputs = null; if (calculationType == StabilityStoneCoverWaveConditionsCalculationType.Both || calculationType == StabilityStoneCoverWaveConditionsCalculationType.Columns) { CurrentCalculationType = Resources.StabilityStoneCoverWaveConditions_Columns_DisplayName; columnsOutputs = CalculateColumns(calculation, assessmentSection, assessmentLevel, generalWaveConditionsInput.GeneralColumnsWaveConditionsInput, targetProbability); } if (!Canceled) { calculation.Output = CreateOutput(calculationType, blocksOutputs, columnsOutputs); } } finally { CalculationServiceHelper.LogCalculationEnd(); } }
protected override bool Validate() { return(WaveConditionsCalculationServiceBase.Validate(calculation.InputParameters, WaveConditionsInputHelper.GetAssessmentLevel(calculation.InputParameters, assessmentSection), assessmentSection.HydraulicBoundaryDatabase)); }
/// <summary> /// Performs a wave conditions calculation for the grass cover erosion outwards failure mechanism based on the supplied /// <see cref="GrassCoverErosionOutwardsWaveConditionsCalculation"/> and sets /// <see cref="GrassCoverErosionOutwardsWaveConditionsCalculation.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="GrassCoverErosionOutwardsWaveConditionsCalculation"/> that holds all the information required to perform the calculation.</param> /// <param name="failureMechanism">The grass cover erosion outwards failure mechanism, which contains general parameters that apply to all /// <see cref="GrassCoverErosionOutwardsWaveConditionsCalculation"/> instances.</param> /// <param name="assessmentSection">The <see cref="IAssessmentSection"/> that holds information about the target probability used in the calculation.</param> /// <exception cref="ArgumentNullException">Thrown when <paramref name="calculation"/>, <paramref name="failureMechanism"/> /// or <paramref name="assessmentSection"/> is <c>null</c>.</exception> /// <exception cref="ArgumentException">Thrown when: /// <list type="bullet"> /// <item>the hydraulic boundary database file path contains invalid characters.</item> /// <item><paramref name="failureMechanism"/> has no (0) contribution.</item> /// </list></exception> /// <exception cref="InvalidEnumArgumentException">Thrown when an unexpected /// enum value is encountered.</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> /// <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> /// <exception cref="NotSupportedException">Thrown when <see cref="GrassCoverErosionOutwardsWaveConditionsCalculationType"/> /// is a valid value, but unsupported.</exception> public void Calculate(GrassCoverErosionOutwardsWaveConditionsCalculation calculation, GrassCoverErosionOutwardsFailureMechanism failureMechanism, IAssessmentSection assessmentSection) { if (calculation == null) { throw new ArgumentNullException(nameof(calculation)); } if (failureMechanism == null) { throw new ArgumentNullException(nameof(failureMechanism)); } if (assessmentSection == null) { throw new ArgumentNullException(nameof(assessmentSection)); } GrassCoverErosionOutwardsWaveConditionsInput calculationInput = calculation.InputParameters; GrassCoverErosionOutwardsWaveConditionsCalculationType calculationType = calculationInput.CalculationType; if (!Enum.IsDefined(typeof(GrassCoverErosionOutwardsWaveConditionsCalculationType), calculationType)) { throw new InvalidEnumArgumentException(nameof(calculationType), (int)calculationType, typeof(GrassCoverErosionOutwardsWaveConditionsCalculationType)); } CalculationServiceHelper.LogCalculationBegin(); RoundedDouble assessmentLevel = WaveConditionsInputHelper.GetAssessmentLevel(calculationInput, assessmentSection); double targetProbability = WaveConditionsInputHelper.GetTargetProbability(calculationInput, assessmentSection); HydraulicBoundaryDatabase hydraulicBoundaryDatabase = assessmentSection.HydraulicBoundaryDatabase; DetermineTotalWaterLevelCalculations(calculationInput, assessmentLevel); try { IEnumerable <WaveConditionsOutput> waveRunUpOutput = null; if (ShouldCalculateWaveRunUp(calculationType)) { CurrentCalculationType = Resources.GrassCoverErosionOutwardsWaveConditions_WaveRunUp_DisplayName; waveRunUpOutput = CalculateWaveRunUp(calculation, failureMechanism, hydraulicBoundaryDatabase, assessmentLevel, targetProbability); } if (Canceled) { return; } IEnumerable <WaveConditionsOutput> waveImpactOutput = null; if (ShouldCalculateWaveImpact(calculationType)) { CurrentCalculationType = Resources.GrassCoverErosionOutwardsWaveConditions_WaveImpact_DisplayName; waveImpactOutput = CalculateWaveImpact(calculation, failureMechanism, hydraulicBoundaryDatabase, assessmentLevel, targetProbability); } IEnumerable <WaveConditionsOutput> waveImpactWithWaveDirectionOutput = null; if (ShouldCalculateWaveImpactWithWaveDirection(calculationType)) { CurrentCalculationType = Resources.GrassCoverErosionOutwardsWaveConditions_WaveImpactWithWaveDirection_DisplayName; waveImpactWithWaveDirectionOutput = CalculateWaveImpactWithWaveDirection(calculation, failureMechanism, hydraulicBoundaryDatabase, assessmentLevel, targetProbability); } if (!Canceled) { calculation.Output = CreateOutput(calculationType, waveRunUpOutput, waveImpactOutput, waveImpactWithWaveDirectionOutput); } } finally { CalculationServiceHelper.LogCalculationEnd(); } }
private static IEnumerable <RoundedDouble> GetWaterLevels(StabilityStoneCoverWaveConditionsCalculation calculation, IAssessmentSection assessmentSection) { return(calculation.InputParameters.GetWaterLevels(WaveConditionsInputHelper.GetAssessmentLevel(calculation.InputParameters, assessmentSection))); }
private static IEnumerable <RoundedDouble> GetWaterLevels(GrassCoverErosionOutwardsWaveConditionsCalculation calculation, IAssessmentSection assessmentSection) { return(calculation.InputParameters.GetWaterLevels(WaveConditionsInputHelper.GetAssessmentLevel(calculation.InputParameters, assessmentSection))); }