Пример #1
0
        /// <summary>
        /// Validates the Waternet with daily circumstances based on the values
        /// of the <see cref="IMacroStabilityInwardsWaternetInput"/>.
        /// </summary>
        /// <param name="input">The input to get the values from.</param>
        /// <param name="generalInput">General calculation parameters that are the same across all calculations.</param>
        /// <returns>The validation issues found, if any.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        /// <exception cref="WaternetCalculationException">Thrown when an error occurs
        /// during the validation.</exception>
        public static IEnumerable <MacroStabilityInwardsKernelMessage> ValidateDaily(IMacroStabilityInwardsWaternetInput input, IGeneralMacroStabilityInwardsWaternetInput generalInput)
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

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

            IWaternetCalculator calculator = MacroStabilityInwardsCalculatorFactory.Instance
                                             .CreateWaternetDailyCalculator(
                CreateDailyCalculatorInput(input, generalInput),
                MacroStabilityInwardsKernelWrapperFactory.Instance);

            try
            {
                return(calculator.Validate().ToArray());
            }
            catch (WaternetCalculatorException e)
            {
                throw new WaternetCalculationException(e.Message, e);
            }
        }
Пример #2
0
        /// <summary>
        /// Calculates the Waternet with daily circumstances based on the values
        /// of the <see cref="IMacroStabilityInwardsWaternetInput"/>.
        /// </summary>
        /// <param name="input">The input to get the values from.</param>
        /// <param name="generalInput">General calculation parameters that are the same across all calculations.</param>
        /// <returns>A calculated <see cref="MacroStabilityInwardsWaternet"/>,
        /// or an empty <see cref="MacroStabilityInwardsWaternet"/> when the Waternet
        /// could not be calculated.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        public static MacroStabilityInwardsWaternet CalculateDaily(IMacroStabilityInwardsWaternetInput input, IGeneralMacroStabilityInwardsWaternetInput generalInput)
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

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

            IWaternetCalculator calculator = MacroStabilityInwardsCalculatorFactory.Instance
                                             .CreateWaternetDailyCalculator(
                CreateDailyCalculatorInput(input, generalInput),
                MacroStabilityInwardsKernelWrapperFactory.Instance);

            try
            {
                WaternetCalculatorResult result = calculator.Calculate();
                return(MacroStabilityInwardsWaternetConverter.Convert(result));
            }
            catch (WaternetCalculatorException)
            {
                return(new MacroStabilityInwardsWaternet(new MacroStabilityInwardsPhreaticLine[0],
                                                         new MacroStabilityInwardsWaternetLine[0]));
            }
        }
Пример #3
0
        private static bool ValidateTopOfProfileExceedsSurfaceLineTop(IMacroStabilityInwardsWaternetInput inputParameters,
                                                                      MacroStabilityInwardsSoilProfile1D soilProfile1D)
        {
            double layerTop       = soilProfile1D.Layers.Max(l => l.Top);
            double surfaceLineTop = inputParameters.SurfaceLine.LocalGeometry.Max(p => p.Y);

            return(layerTop + withinSurfaceLineLevelLimit >= surfaceLineTop);
        }
Пример #4
0
        /// <summary>
        /// Asserts whether <paramref name="actual"/> corresponds to <paramref name="original"/>.
        /// </summary>
        /// <param name="original">The original <see cref="IMacroStabilityInwardsWaternetInput"/>.</param>
        /// <param name="actual">The actual <see cref="WaternetCalculatorInput"/>.</param>
        /// <param name="assessmentLevel">The assessment level to assert.</param>
        /// <exception cref="AssertionException">Thrown when <paramref name="actual"/>
        /// does not correspond to <paramref name="original"/> or <paramref name="assessmentLevel"/>.</exception>
        public static void AssertExtremeInput(IMacroStabilityInwardsWaternetInput original, WaternetCalculatorInput actual, double assessmentLevel)
        {
            AssertPhreaticLineOffsets(original.LocationInputExtreme, actual.PhreaticLineOffsets);
            Assert.AreEqual(original.LocationInputExtreme.WaterLevelPolder, actual.WaterLevelPolder);
            Assert.AreEqual(original.LocationInputExtreme.PenetrationLength, actual.PenetrationLength);
            Assert.AreEqual(assessmentLevel, actual.AssessmentLevel);

            AssertGenericInput(original, actual);
        }
Пример #5
0
        /// <summary>
        /// Asserts whether <paramref name="actual"/> corresponds to <paramref name="original"/>.
        /// </summary>
        /// <param name="original">The original <see cref="IMacroStabilityInwardsWaternetInput"/>.</param>
        /// <param name="actual">The actual <see cref="WaternetCalculatorInput"/>.</param>
        /// <exception cref="AssertionException">Thrown when <paramref name="actual"/>
        /// does not correspond to <paramref name="original"/>.</exception>
        public static void AssertDailyInput(IMacroStabilityInwardsWaternetInput original, WaternetCalculatorInput actual)
        {
            AssertPhreaticLineOffsets(original.LocationInputDaily, actual.PhreaticLineOffsets);
            Assert.AreEqual(original.LocationInputDaily.WaterLevelPolder, actual.WaterLevelPolder);
            Assert.AreEqual(original.LocationInputDaily.PenetrationLength, actual.PenetrationLength);
            Assert.AreEqual(original.WaterLevelRiverAverage, actual.AssessmentLevel);

            AssertGenericInput(original, actual);
        }
Пример #6
0
        private static WaternetCalculatorInput CreateExtremeCalculatorInput(IMacroStabilityInwardsWaternetInput input, IGeneralMacroStabilityInwardsWaternetInput generalInput, RoundedDouble assessmentLevel)
        {
            WaternetCalculatorInput.ConstructionProperties properties = CreateCalculatorInputConstructionProperties(input, generalInput);
            properties.PhreaticLineOffsets = PhreaticLineOffsetsConverter.Convert(input.LocationInputExtreme);
            properties.AssessmentLevel     = assessmentLevel;
            properties.WaterLevelPolder    = input.LocationInputExtreme.WaterLevelPolder;
            properties.PenetrationLength   = input.LocationInputExtreme.PenetrationLength;

            return(new WaternetCalculatorInput(properties));
        }
Пример #7
0
        private static WaternetCalculatorInput CreateDailyCalculatorInput(IMacroStabilityInwardsWaternetInput input, IGeneralMacroStabilityInwardsWaternetInput generalInput)
        {
            WaternetCalculatorInput.ConstructionProperties properties = CreateCalculatorInputConstructionProperties(input, generalInput);
            properties.PhreaticLineOffsets = PhreaticLineOffsetsConverter.Convert(input.LocationInputDaily);
            properties.AssessmentLevel     = input.WaterLevelRiverAverage;
            properties.WaterLevelPolder    = input.LocationInputDaily.WaterLevelPolder;
            properties.PenetrationLength   = input.LocationInputDaily.PenetrationLength;

            return(new WaternetCalculatorInput(properties));
        }
Пример #8
0
        /// <summary>
        /// Creates a new <see cref="PersistableWaternetCreatorSettings"/> for daily.
        /// </summary>
        /// <param name="input">The input to use.</param>
        /// <param name="idFactory">The factory for creating IDs.</param>
        /// <param name="registry">The persistence registry.</param>
        /// <returns>The created <see cref="PersistableWaternetCreatorSettings"/>.</returns>
        /// <exception cref="InvalidEnumArgumentException">Thrown when <see cref="IMacroStabilityInwardsWaternetInput.DikeSoilScenario"/>
        /// has an invalid value for <see cref="MacroStabilityInwardsDikeSoilScenario"/>.</exception>
        /// <exception cref="NotSupportedException">Thrown when <see cref="IMacroStabilityInwardsWaternetInput.DikeSoilScenario"/>
        /// is not supported.</exception>
        private static PersistableWaternetCreatorSettings CreateDaily(IMacroStabilityInwardsWaternetInput input, IdFactory idFactory, MacroStabilityInwardsExportRegistry registry)
        {
            PersistableWaternetCreatorSettings waternetCreatorSettings = Create(input, idFactory, registry, MacroStabilityInwardsExportStageType.Daily);

            waternetCreatorSettings.NormativeWaterLevel  = input.WaterLevelRiverAverage;
            waternetCreatorSettings.WaterLevelHinterland = input.LocationInputDaily.WaterLevelPolder;
            SetOffsets(input.LocationInputDaily, waternetCreatorSettings);
            waternetCreatorSettings.IntrusionLength = input.LocationInputDaily.PenetrationLength;

            return(waternetCreatorSettings);
        }
Пример #9
0
        /// <summary>
        /// Creates a new <see cref="PersistableWaternetCreatorSettings"/> for extreme.
        /// </summary>
        /// <param name="input">The input to use.</param>
        /// <param name="normativeAssessmentLevel">The normative assessment level to use.</param>
        /// <param name="idFactory">The factory for creating IDs.</param>
        /// <param name="registry">The persistence registry.</param>
        /// <returns>The created <see cref="PersistableWaternetCreatorSettings"/>.</returns>
        /// <exception cref="InvalidEnumArgumentException">Thrown when <see cref="IMacroStabilityInwardsWaternetInput.DikeSoilScenario"/>
        /// has an invalid value for <see cref="MacroStabilityInwardsDikeSoilScenario"/>.</exception>
        /// <exception cref="NotSupportedException">Thrown when <see cref="IMacroStabilityInwardsWaternetInput.DikeSoilScenario"/>
        /// is not supported.</exception>
        private static PersistableWaternetCreatorSettings CreateExtreme(IMacroStabilityInwardsWaternetInput input, RoundedDouble normativeAssessmentLevel,
                                                                        IdFactory idFactory, MacroStabilityInwardsExportRegistry registry)
        {
            PersistableWaternetCreatorSettings waternetCreatorSettings = Create(input, idFactory, registry, MacroStabilityInwardsExportStageType.Extreme);

            waternetCreatorSettings.NormativeWaterLevel  = normativeAssessmentLevel;
            waternetCreatorSettings.WaterLevelHinterland = input.LocationInputExtreme.WaterLevelPolder;
            SetOffsets(input.LocationInputExtreme, waternetCreatorSettings);
            waternetCreatorSettings.IntrusionLength = input.LocationInputExtreme.PenetrationLength;

            return(waternetCreatorSettings);
        }
Пример #10
0
        /// <summary>
        /// Converts <see cref="IMacroStabilityInwardsWaternetInput"/> drainage properties
        /// into <see cref="DrainageConstruction"/>.
        /// </summary>
        /// <param name="input">The input to get the properties from.</param>
        /// <returns>The converted <see cref="DrainageConstruction"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="input"/>
        /// is <c>null</c>.</exception>
        public static DrainageConstruction Convert(IMacroStabilityInwardsWaternetInput input)
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            bool isClayDike = input.DikeSoilScenario == MacroStabilityInwardsDikeSoilScenario.ClayDikeOnClay ||
                              input.DikeSoilScenario == MacroStabilityInwardsDikeSoilScenario.ClayDikeOnSand;

            return(!isClayDike && input.DrainageConstructionPresent
                       ? new DrainageConstruction(input.XCoordinateDrainageConstruction, input.ZCoordinateDrainageConstruction)
                       : new DrainageConstruction());
        }
Пример #11
0
 /// <summary>
 /// Asserts whether <paramref name="actual"/> corresponds to <paramref name="original"/>.
 /// </summary>
 /// <param name="original">The original <see cref="IMacroStabilityInwardsWaternetInput"/>.</param>
 /// <param name="actual">The actual <see cref="WaternetCalculatorInput"/>.</param>
 /// <exception cref="AssertionException">Thrown when <paramref name="actual"/>
 /// does not correspond to <paramref name="original"/>.</exception>
 private static void AssertGenericInput(IMacroStabilityInwardsWaternetInput original, WaternetCalculatorInput actual)
 {
     AssertSoilProfile(original.SoilProfileUnderSurfaceLine, actual.SoilProfile);
     AssertDrainageConstruction(original, actual.DrainageConstruction);
     Assert.AreSame(original.SurfaceLine, actual.SurfaceLine);
     Assert.AreEqual(original.DikeSoilScenario, actual.DikeSoilScenario);
     Assert.AreEqual(original.WaterLevelRiverAverage, actual.WaterLevelRiverAverage);
     Assert.AreEqual(original.MinimumLevelPhreaticLineAtDikeTopRiver, actual.MinimumLevelPhreaticLineAtDikeTopRiver);
     Assert.AreEqual(original.MinimumLevelPhreaticLineAtDikeTopPolder, actual.MinimumLevelPhreaticLineAtDikeTopPolder);
     Assert.AreEqual(original.LeakageLengthOutwardsPhreaticLine3, actual.LeakageLengthOutwardsPhreaticLine3);
     Assert.AreEqual(original.LeakageLengthInwardsPhreaticLine3, actual.LeakageLengthInwardsPhreaticLine3);
     Assert.AreEqual(original.LeakageLengthOutwardsPhreaticLine4, actual.LeakageLengthOutwardsPhreaticLine4);
     Assert.AreEqual(original.LeakageLengthInwardsPhreaticLine4, actual.LeakageLengthInwardsPhreaticLine4);
     Assert.AreEqual(original.PiezometricHeadPhreaticLine2Outwards, actual.PiezometricHeadPhreaticLine2Outwards);
     Assert.AreEqual(original.PiezometricHeadPhreaticLine2Inwards, actual.PiezometricHeadPhreaticLine2Inwards);
     Assert.AreEqual(original.AdjustPhreaticLine3And4ForUplift, actual.AdjustPhreaticLine3And4ForUplift);
 }
Пример #12
0
        /// <summary>
        /// Creates a new <see cref="PersistableWaternetCreatorSettings"/>.
        /// </summary>
        /// <param name="input">The input to use.</param>
        /// <param name="idFactory">The factory for creating IDs.</param>
        /// <param name="registry">The persistence registry.</param>
        /// <param name="stageType">The stage type.</param>
        /// <returns>The created <see cref="PersistableWaternetCreatorSettings"/>.</returns>
        /// <exception cref="InvalidEnumArgumentException">Thrown when <see cref="IMacroStabilityInwardsWaternetInput.DikeSoilScenario"/>
        /// has an invalid value for <see cref="MacroStabilityInwardsDikeSoilScenario"/>.</exception>
        /// <exception cref="NotSupportedException">Thrown when <see cref="IMacroStabilityInwardsWaternetInput.DikeSoilScenario"/>
        /// is not supported.</exception>
        private static PersistableWaternetCreatorSettings Create(IMacroStabilityInwardsWaternetInput input, IdFactory idFactory, MacroStabilityInwardsExportRegistry registry,
                                                                 MacroStabilityInwardsExportStageType stageType)
        {
            bool isDitchPresent          = IsDitchPresent(input.SurfaceLine);
            var  waternetCreatorSettings = new PersistableWaternetCreatorSettings
            {
                Id = idFactory.Create(),
                InitialLevelEmbankmentTopWaterSide = input.MinimumLevelPhreaticLineAtDikeTopRiver,
                InitialLevelEmbankmentTopLandSide  = input.MinimumLevelPhreaticLineAtDikeTopPolder,
                AdjustForUplift = input.AdjustPhreaticLine3And4ForUplift,
                PleistoceneLeakageLengthOutwards = input.LeakageLengthOutwardsPhreaticLine3,
                PleistoceneLeakageLengthInwards  = input.LeakageLengthInwardsPhreaticLine3,
                AquiferLayerInsideAquitardLeakageLengthOutwards = input.LeakageLengthOutwardsPhreaticLine4,
                AquiferLayerInsideAquitardLeakageLengthInwards  = input.LeakageLengthInwardsPhreaticLine4,
                AquitardHeadWaterSide         = input.PiezometricHeadPhreaticLine2Outwards,
                AquitardHeadLandSide          = input.PiezometricHeadPhreaticLine2Inwards,
                MeanWaterLevel                = input.WaterLevelRiverAverage,
                IsDrainageConstructionPresent = input.DrainageConstructionPresent,
                DrainageConstruction          = new PersistablePoint(input.XCoordinateDrainageConstruction, input.ZCoordinateDrainageConstruction),
                IsDitchPresent                = isDitchPresent,
                DitchCharacteristics          = CreateDitchCharacteristics(input.SurfaceLine, isDitchPresent),
                EmbankmentCharacteristics     = CreateEmbankmentCharacteristics(input.SurfaceLine),
                EmbankmentSoilScenario        = CreateEmbankmentSoilScenario(input.DikeSoilScenario),
                IsAquiferLayerInsideAquitard  = false
            };

            IEnumerable <MacroStabilityInwardsSoilLayer2D> aquiferLayers = MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(input.SoilProfileUnderSurfaceLine.Layers)
                                                                           .Where(l => l.Data.IsAquifer);

            if (aquiferLayers.Count() == 1)
            {
                waternetCreatorSettings.AquiferLayerId = registry.GeometryLayers[stageType][aquiferLayers.Single()];
            }

            registry.AddWaternetCreatorSettings(stageType, waternetCreatorSettings.Id);

            return(waternetCreatorSettings);
        }
Пример #13
0
 /// <summary>
 /// Asserts whether <paramref name="original"/> corresponds to <paramref name="original"/>.
 /// </summary>
 /// <param name="original">The original <see cref="IMacroStabilityInwardsWaternetInput"/>.</param>
 /// <param name="actual">The actual <see cref="DrainageConstruction"/>.</param>
 /// <exception cref="AssertionException">Thrown when <paramref name="original"/>
 /// does not correspond to <paramref name="original"/>.</exception>
 public static void AssertDrainageConstruction(IMacroStabilityInwardsWaternetInput original, DrainageConstruction actual)
 {
     Assert.AreEqual(original.DrainageConstructionPresent, actual.IsPresent);
     Assert.AreEqual(original.XCoordinateDrainageConstruction, actual.XCoordinate);
     Assert.AreEqual(original.ZCoordinateDrainageConstruction, actual.ZCoordinate);
 }
Пример #14
0
 private static WaternetCalculatorInput.ConstructionProperties CreateCalculatorInputConstructionProperties(IMacroStabilityInwardsWaternetInput input, IGeneralMacroStabilityInwardsWaternetInput generalInput)
 {
     return(new WaternetCalculatorInput.ConstructionProperties
     {
         SurfaceLine = input.SurfaceLine,
         SoilProfile = SoilProfileConverter.Convert(input.SoilProfileUnderSurfaceLine),
         DrainageConstruction = DrainageConstructionConverter.Convert(input),
         DikeSoilScenario = input.DikeSoilScenario,
         WaterLevelRiverAverage = input.WaterLevelRiverAverage,
         MinimumLevelPhreaticLineAtDikeTopRiver = input.MinimumLevelPhreaticLineAtDikeTopRiver,
         MinimumLevelPhreaticLineAtDikeTopPolder = input.MinimumLevelPhreaticLineAtDikeTopPolder,
         LeakageLengthOutwardsPhreaticLine3 = input.LeakageLengthOutwardsPhreaticLine3,
         LeakageLengthInwardsPhreaticLine3 = input.LeakageLengthInwardsPhreaticLine3,
         LeakageLengthOutwardsPhreaticLine4 = input.LeakageLengthOutwardsPhreaticLine4,
         LeakageLengthInwardsPhreaticLine4 = input.LeakageLengthInwardsPhreaticLine4,
         PiezometricHeadPhreaticLine2Outwards = input.PiezometricHeadPhreaticLine2Outwards,
         PiezometricHeadPhreaticLine2Inwards = input.PiezometricHeadPhreaticLine2Inwards,
         AdjustPhreaticLine3And4ForUplift = input.AdjustPhreaticLine3And4ForUplift,
         WaterVolumetricWeight = generalInput.WaterVolumetricWeight
     });
 }