// Copyright (C) Stichting Deltares 2018. All rights reserved. // // This file is part of Ringtoets. // // Ringtoets is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // All names, logos, and references to "Deltares" are registered trademarks of // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. using System; using System.Collections.Generic; using System.ComponentModel; using Ringtoets.Common.Service; using Ringtoets.Common.Service.ValidationRules; using Ringtoets.StabilityPointStructures.Data; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; using RingtoetsStabilityPointStructuresFormsResources = Ringtoets.StabilityPointStructures.Forms.Properties.Resources; namespace Ringtoets.StabilityPointStructures.Service { /// /// The stability point structures validation rules registry. /// public class StabilityPointStructuresValidationRulesRegistry : IStructuresValidationRulesRegistry { public IEnumerable GetValidationRules(StabilityPointStructuresInput input) { if (input == null) { throw new ArgumentNullException(nameof(input)); } StabilityPointStructureInflowModelType inflowModelType = input.InflowModelType; if (!Enum.IsDefined(typeof(StabilityPointStructureInflowModelType), inflowModelType)) { throw new InvalidEnumArgumentException(nameof(input), (int) inflowModelType, typeof(StabilityPointStructureInflowModelType)); } IEnumerable validationRules; switch (inflowModelType) { case StabilityPointStructureInflowModelType.LowSill: validationRules = GetLowSillValidationRules(input); break; case StabilityPointStructureInflowModelType.FloodedCulvert: validationRules = GetFloodedCulvertValidationRules(input); break; default: throw new NotSupportedException(); } return validationRules; } /// /// Gets the validation rules applicable for flooded culvert calculations. /// /// The to base the validation rules on. /// An of validation rules to validate a flooded culvert input. /// Thrown when contains /// an invalid value of . /// Thrown when contains /// an unsupported value of . private static IEnumerable GetFloodedCulvertValidationRules(StabilityPointStructuresInput input) { LoadSchematizationType loadSchematizationType = input.LoadSchematizationType; if (!Enum.IsDefined(typeof(LoadSchematizationType), loadSchematizationType)) { throw new InvalidEnumArgumentException(nameof(input), (int) loadSchematizationType, typeof(LoadSchematizationType)); } switch (loadSchematizationType) { case LoadSchematizationType.Linear: return GetFloodedCulvertLinearValidationRules(input); case LoadSchematizationType.Quadratic: return GetFloodedCulvertQuadraticValidationRules(input); default: throw new NotSupportedException(); } } /// /// Gets the validation rules applicable for low sill calculations. /// /// The to base the validation rules on. /// An of validation rules to validate a flooded culvert input. /// Thrown when contains /// an invalid value of . /// Thrown when contains /// an unsupported value of . private static IEnumerable GetLowSillValidationRules(StabilityPointStructuresInput input) { LoadSchematizationType loadSchematizationType = input.LoadSchematizationType; if (!Enum.IsDefined(typeof(LoadSchematizationType), loadSchematizationType)) { throw new InvalidEnumArgumentException(nameof(input), (int) loadSchematizationType, typeof(LoadSchematizationType)); } switch (loadSchematizationType) { case LoadSchematizationType.Linear: return GetLowSillLinearValidationRules(input); case LoadSchematizationType.Quadratic: return GetLowSillQuadraticValidationRules(input); default: throw new NotSupportedException(); } } private static IEnumerable GetLowSillLinearValidationRules(StabilityPointStructuresInput input) { return new ValidationRule[] { new UseBreakWaterRule(input), new NumericInputRule( input.VolumicWeightWater, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_VolumicWeightWater_DisplayName)), new VariationCoefficientLogNormalDistributionRule( input.StormDuration, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_StormDuration_DisplayName)), new NormalDistributionRule( input.InsideWaterLevel, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_InsideWaterLevel_DisplayName)), new NormalDistributionRule( input.InsideWaterLevelFailureConstruction, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_InsideWaterLevelFailureConstruction_DisplayName)), new VariationCoefficientNormalDistributionRule( input.FlowVelocityStructureClosable, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_FlowVelocityStructureClosable_DisplayName)), new NumericInputRule( input.FactorStormDurationOpenStructure, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_FactorStormDurationOpenStructure_DisplayName)), new NumericInputRule( input.StructureNormalOrientation, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_StructureNormalOrientation_DisplayName)), new NormalDistributionRule( input.WidthFlowApertures, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_WidthFlowApertures_DisplayName)), new LogNormalDistributionRule( input.FlowWidthAtBottomProtection, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_FlowWidthAtBottomProtection_DisplayName)), new VariationCoefficientLogNormalDistributionRule( input.StorageStructureArea, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_StorageStructureArea_DisplayName)), new LogNormalDistributionRule( input.AllowedLevelIncreaseStorage, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_AllowedLevelIncreaseStorage_DisplayName)), new NormalDistributionRule( input.LevelCrestStructure, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_LevelCrestStructure_DisplayName)), new NormalDistributionRule( input.ThresholdHeightOpenWeir, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_ThresholdHeightOpenWeir_DisplayName)), new VariationCoefficientLogNormalDistributionRule( input.CriticalOvertoppingDischarge, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_CriticalOvertoppingDischarge_DisplayName)), new VariationCoefficientLogNormalDistributionRule( input.ConstructiveStrengthLinearLoadModel, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_ConstructiveStrengthLinearLoadModel_DisplayName)), new NormalDistributionRule( input.BankWidth, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_BankWidth_DisplayName)), new NumericInputRule( input.EvaluationLevel, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_EvaluationLevel_DisplayName)), new NumericInputRule( input.VerticalDistance, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_VerticalDistance_DisplayName)), new VariationCoefficientLogNormalDistributionRule( input.FailureCollisionEnergy, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_FailureCollisionEnergy_DisplayName)), new VariationCoefficientNormalDistributionRule( input.ShipMass, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_ShipMass_DisplayName)), new VariationCoefficientNormalDistributionRule( input.ShipVelocity, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_ShipVelocity_DisplayName)), new VariationCoefficientLogNormalDistributionRule( input.StabilityLinearLoadModel, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_StabilityLinearLoadModel_DisplayName)) }; } private static IEnumerable GetLowSillQuadraticValidationRules(StabilityPointStructuresInput input) { return new ValidationRule[] { new UseBreakWaterRule(input), new NumericInputRule( input.VolumicWeightWater, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_VolumicWeightWater_DisplayName)), new VariationCoefficientLogNormalDistributionRule( input.StormDuration, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_StormDuration_DisplayName)), new NormalDistributionRule( input.InsideWaterLevel, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_InsideWaterLevel_DisplayName)), new NormalDistributionRule( input.InsideWaterLevelFailureConstruction, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_InsideWaterLevelFailureConstruction_DisplayName)), new VariationCoefficientNormalDistributionRule( input.FlowVelocityStructureClosable, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_FlowVelocityStructureClosable_DisplayName)), new NumericInputRule( input.FactorStormDurationOpenStructure, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_FactorStormDurationOpenStructure_DisplayName)), new NumericInputRule( input.StructureNormalOrientation, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_StructureNormalOrientation_DisplayName)), new NormalDistributionRule( input.WidthFlowApertures, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_WidthFlowApertures_DisplayName)), new LogNormalDistributionRule( input.FlowWidthAtBottomProtection, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_FlowWidthAtBottomProtection_DisplayName)), new VariationCoefficientLogNormalDistributionRule( input.StorageStructureArea, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_StorageStructureArea_DisplayName)), new LogNormalDistributionRule( input.AllowedLevelIncreaseStorage, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_AllowedLevelIncreaseStorage_DisplayName)), new NormalDistributionRule( input.LevelCrestStructure, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_LevelCrestStructure_DisplayName)), new NormalDistributionRule( input.ThresholdHeightOpenWeir, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_ThresholdHeightOpenWeir_DisplayName)), new VariationCoefficientLogNormalDistributionRule( input.CriticalOvertoppingDischarge, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_CriticalOvertoppingDischarge_DisplayName)), new VariationCoefficientLogNormalDistributionRule( input.ConstructiveStrengthQuadraticLoadModel, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_ConstructiveStrengthQuadraticLoadModel_DisplayName)), new NormalDistributionRule( input.BankWidth, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_BankWidth_DisplayName)), new NumericInputRule( input.EvaluationLevel, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_EvaluationLevel_DisplayName)), new NumericInputRule( input.VerticalDistance, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_VerticalDistance_DisplayName)), new VariationCoefficientLogNormalDistributionRule( input.FailureCollisionEnergy, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_FailureCollisionEnergy_DisplayName)), new VariationCoefficientNormalDistributionRule( input.ShipMass, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_ShipMass_DisplayName)), new VariationCoefficientNormalDistributionRule( input.ShipVelocity, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_ShipVelocity_DisplayName)), new VariationCoefficientLogNormalDistributionRule( input.StabilityQuadraticLoadModel, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_StabilityQuadraticLoadModel_DisplayName)) }; } private static IEnumerable GetFloodedCulvertLinearValidationRules(StabilityPointStructuresInput input) { return new ValidationRule[] { new UseBreakWaterRule(input), new NumericInputRule( input.VolumicWeightWater, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_VolumicWeightWater_DisplayName)), new VariationCoefficientLogNormalDistributionRule( input.StormDuration, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_StormDuration_DisplayName)), new NormalDistributionRule( input.InsideWaterLevel, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_InsideWaterLevel_DisplayName)), new NormalDistributionRule( input.InsideWaterLevelFailureConstruction, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_InsideWaterLevelFailureConstruction_DisplayName)), new VariationCoefficientNormalDistributionRule( input.FlowVelocityStructureClosable, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_FlowVelocityStructureClosable_DisplayName)), new NormalDistributionRule( input.DrainCoefficient, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_DrainCoefficient_DisplayName)), new NumericInputRule( input.FactorStormDurationOpenStructure, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_FactorStormDurationOpenStructure_DisplayName)), new NumericInputRule( input.StructureNormalOrientation, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_StructureNormalOrientation_DisplayName)), new LogNormalDistributionRule( input.AreaFlowApertures, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_AreaFlowApertures_DisplayName)), new LogNormalDistributionRule( input.FlowWidthAtBottomProtection, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_FlowWidthAtBottomProtection_DisplayName)), new VariationCoefficientLogNormalDistributionRule( input.StorageStructureArea, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_StorageStructureArea_DisplayName)), new LogNormalDistributionRule( input.AllowedLevelIncreaseStorage, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_AllowedLevelIncreaseStorage_DisplayName)), new NormalDistributionRule( input.LevelCrestStructure, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_LevelCrestStructure_DisplayName)), new NormalDistributionRule( input.ThresholdHeightOpenWeir, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_ThresholdHeightOpenWeir_DisplayName)), new VariationCoefficientLogNormalDistributionRule( input.CriticalOvertoppingDischarge, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_CriticalOvertoppingDischarge_DisplayName)), new VariationCoefficientLogNormalDistributionRule( input.ConstructiveStrengthLinearLoadModel, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_ConstructiveStrengthLinearLoadModel_DisplayName)), new NormalDistributionRule( input.BankWidth, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_BankWidth_DisplayName)), new NumericInputRule( input.EvaluationLevel, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_EvaluationLevel_DisplayName)), new NumericInputRule( input.VerticalDistance, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_VerticalDistance_DisplayName)), new VariationCoefficientLogNormalDistributionRule( input.FailureCollisionEnergy, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_FailureCollisionEnergy_DisplayName)), new VariationCoefficientNormalDistributionRule( input.ShipMass, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_ShipMass_DisplayName)), new VariationCoefficientNormalDistributionRule( input.ShipVelocity, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_ShipVelocity_DisplayName)), new VariationCoefficientLogNormalDistributionRule( input.StabilityLinearLoadModel, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_StabilityLinearLoadModel_DisplayName)) }; } private static IEnumerable GetFloodedCulvertQuadraticValidationRules(StabilityPointStructuresInput input) { return new ValidationRule[] { new UseBreakWaterRule(input), new NumericInputRule( input.VolumicWeightWater, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_VolumicWeightWater_DisplayName)), new VariationCoefficientLogNormalDistributionRule( input.StormDuration, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_StormDuration_DisplayName)), new NormalDistributionRule( input.InsideWaterLevel, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_InsideWaterLevel_DisplayName)), new NormalDistributionRule( input.InsideWaterLevelFailureConstruction, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_InsideWaterLevelFailureConstruction_DisplayName)), new VariationCoefficientNormalDistributionRule( input.FlowVelocityStructureClosable, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_FlowVelocityStructureClosable_DisplayName)), new NormalDistributionRule( input.DrainCoefficient, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_DrainCoefficient_DisplayName)), new NumericInputRule( input.FactorStormDurationOpenStructure, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_FactorStormDurationOpenStructure_DisplayName)), new NumericInputRule( input.StructureNormalOrientation, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_StructureNormalOrientation_DisplayName)), new LogNormalDistributionRule( input.AreaFlowApertures, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_AreaFlowApertures_DisplayName)), new LogNormalDistributionRule( input.FlowWidthAtBottomProtection, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_FlowWidthAtBottomProtection_DisplayName)), new VariationCoefficientLogNormalDistributionRule( input.StorageStructureArea, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_StorageStructureArea_DisplayName)), new LogNormalDistributionRule( input.AllowedLevelIncreaseStorage, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_AllowedLevelIncreaseStorage_DisplayName)), new NormalDistributionRule( input.LevelCrestStructure, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_LevelCrestStructure_DisplayName)), new NormalDistributionRule( input.ThresholdHeightOpenWeir, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_ThresholdHeightOpenWeir_DisplayName)), new VariationCoefficientLogNormalDistributionRule( input.CriticalOvertoppingDischarge, ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonFormsResources.Structure_CriticalOvertoppingDischarge_DisplayName)), new VariationCoefficientLogNormalDistributionRule( input.ConstructiveStrengthQuadraticLoadModel, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_ConstructiveStrengthQuadraticLoadModel_DisplayName)), new NormalDistributionRule( input.BankWidth, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_BankWidth_DisplayName)), new NumericInputRule( input.EvaluationLevel, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_EvaluationLevel_DisplayName)), new NumericInputRule( input.VerticalDistance, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_VerticalDistance_DisplayName)), new VariationCoefficientLogNormalDistributionRule( input.FailureCollisionEnergy, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_FailureCollisionEnergy_DisplayName)), new VariationCoefficientNormalDistributionRule( input.ShipMass, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_ShipMass_DisplayName)), new VariationCoefficientNormalDistributionRule( input.ShipVelocity, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_ShipVelocity_DisplayName)), new VariationCoefficientLogNormalDistributionRule( input.StabilityQuadraticLoadModel, ParameterNameExtractor.GetFromDisplayName(RingtoetsStabilityPointStructuresFormsResources.Structure_StabilityQuadraticLoadModel_DisplayName)) }; } } }