Пример #1
0
 /// <summary>
 /// Validates the <see cref="MacroStabilityInwardsExportStageType"/>.
 /// </summary>
 /// <param name="stageType">The stage type to validate.</param>
 /// <exception cref="InvalidEnumArgumentException">Thrown when <paramref name="stageType"/>
 /// has an invalid value.</exception>
 private static void ValidateStageType(MacroStabilityInwardsExportStageType stageType)
 {
     if (!Enum.IsDefined(typeof(MacroStabilityInwardsExportStageType), stageType))
     {
         throw new InvalidEnumArgumentException(nameof(stageType),
                                                (int)stageType,
                                                typeof(MacroStabilityInwardsExportStageType));
     }
 }
        private static PersistableCalculationSettings Create(IdFactory idFactory, MacroStabilityInwardsExportRegistry registry,
                                                             MacroStabilityInwardsExportStageType stageType)
        {
            var settings = new PersistableCalculationSettings
            {
                Id = idFactory.Create()
            };

            registry.AddSettings(stageType, settings.Id);
            return(settings);
        }
Пример #3
0
 private static PersistableStatePoint CreateYieldStressStatePoint(MacroStabilityInwardsSoilLayer2D layer, IMacroStabilityInwardsPreconsolidationStress preconsolidationStress,
                                                                  MacroStabilityInwardsExportStageType stageType, IdFactory idFactory, MacroStabilityInwardsExportRegistry registry)
 {
     return(new PersistableStatePoint
     {
         Id = idFactory.Create(),
         LayerId = registry.GeometryLayers[stageType][layer],
         IsProbabilistic = false,
         Point = new PersistablePoint(preconsolidationStress.Location.X, preconsolidationStress.Location.Y),
         Stress = CreateYieldStress(preconsolidationStress),
         Label = string.Format(Resources.PersistableStateFactory_CreateStatePoint_PreconsolidationStress_LayerName_0, layer.Data.MaterialName)
     });
 }
        public void AddSettings_InvalidStageType_ThrowsInvalidEnumArgumentException()
        {
            // Setup
            var registry = new MacroStabilityInwardsExportRegistry();
            const MacroStabilityInwardsExportStageType stageType = (MacroStabilityInwardsExportStageType)99;

            // Call
            void Call() => registry.AddSettings(stageType, "1");

            // Assert
            string expectedMessage = $"The value of argument '{nameof(stageType)}' ({stageType}) is invalid for Enum type '{nameof(MacroStabilityInwardsExportStageType)}'.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(Call, expectedMessage);
        }
Пример #5
0
        /// <summary>
        /// Adds a geometry layer to the registry.
        /// </summary>
        /// <param name="stageType">The <see cref="MacroStabilityInwardsExportStageType"/>
        /// to register the geometry layer for.</param>
        /// <param name="geometryLayer">The geometry layer to register.</param>
        /// <param name="id">The id of the geometry layer.</param>
        /// <exception cref="InvalidEnumArgumentException">Thrown when <paramref name="stageType"/>
        /// has an invalid value.</exception>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="geometryLayer"/>
        /// is <c>null</c>.</exception>
        public void AddGeometryLayer(MacroStabilityInwardsExportStageType stageType, MacroStabilityInwardsSoilLayer2D geometryLayer, string id)
        {
            ValidateStageType(stageType);

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

            if (!geometryLayers.ContainsKey(stageType))
            {
                geometryLayers.Add(stageType, new Dictionary <MacroStabilityInwardsSoilLayer2D, string>());
            }

            geometryLayers[stageType].Add(geometryLayer, id);
        }
        public void AddGeometryLayer_InvalidStageType_ThrowsInvalidEnumArgumentException()
        {
            // Setup
            MacroStabilityInwardsSoilLayer2D geometryLayer = MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D();

            var registry = new MacroStabilityInwardsExportRegistry();
            const MacroStabilityInwardsExportStageType stageType = (MacroStabilityInwardsExportStageType)99;

            // Call
            void Call() => registry.AddGeometryLayer(stageType, geometryLayer, "1");

            // Assert
            string expectedMessage = $"The value of argument '{nameof(stageType)}' ({stageType}) is invalid for Enum type '{nameof(MacroStabilityInwardsExportStageType)}'.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(Call, expectedMessage);
        }
Пример #7
0
        private static PersistableSoilLayerCollection CreateSoilLayerCollection(IMacroStabilityInwardsSoilProfileUnderSurfaceLine soilProfile,
                                                                                MacroStabilityInwardsExportStageType stageType, IdFactory idFactory,
                                                                                MacroStabilityInwardsExportRegistry registry)
        {
            var soilLayerCollection = new PersistableSoilLayerCollection
            {
                Id         = idFactory.Create(),
                SoilLayers = MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(soilProfile.Layers)
                             .Select(l => Create(l, stageType, registry))
                             .ToArray()
            };

            registry.AddSoilLayer(stageType, soilLayerCollection.Id);

            return(soilLayerCollection);
        }
Пример #8
0
 private static PersistableStage Create(MacroStabilityInwardsExportStageType stageType, string label,
                                        IdFactory idFactory, MacroStabilityInwardsExportRegistry registry)
 {
     return(new PersistableStage
     {
         Id = idFactory.Create(),
         Label = label,
         CalculationSettingsId = registry.Settings[stageType],
         GeometryId = registry.Geometries[stageType],
         SoilLayersId = registry.SoilLayers[stageType],
         WaternetId = registry.Waternets[stageType],
         WaternetCreatorSettingsId = registry.WaternetCreatorSettings[stageType],
         StateId = stageType == MacroStabilityInwardsExportStageType.Daily
                       ? registry.States[stageType]
                       : null
     });
 }
Пример #9
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);
        }
Пример #10
0
        private static PersistableWaternet Create(MacroStabilityInwardsWaternet waternet, GeneralMacroStabilityInwardsInput generalInput, MacroStabilityInwardsExportStageType stageType,
                                                  IdFactory idFactory, MacroStabilityInwardsExportRegistry registry)
        {
            var persistableWaternet = new PersistableWaternet
            {
                Id = idFactory.Create(),
                UnitWeightWater = generalInput.WaterVolumetricWeight,
                HeadLines       = waternet.PhreaticLines.Select(pl => Create(pl, idFactory)).ToArray(),
                ReferenceLines  = waternet.WaternetLines.Select(wl => Create(wl, idFactory)).ToArray(),
                PhreaticLineId  = waternet.PhreaticLines.Any()
                                     ? createdHeadLines[waternet.PhreaticLines.First()].Id
                                     : null
            };

            registry.AddWaternet(stageType, persistableWaternet.Id);

            return(persistableWaternet);
        }
Пример #11
0
        /// <summary>
        /// Adds a state to the registry.
        /// </summary>
        /// <param name="stageType">The <see cref="MacroStabilityInwardsExportStageType"/>
        /// to register the state for.</param>
        /// <param name="id">The id of the state.</param>
        /// <exception cref="InvalidEnumArgumentException">Thrown when <paramref name="stageType"/>
        /// has an invalid value.</exception>
        public void AddState(MacroStabilityInwardsExportStageType stageType, string id)
        {
            ValidateStageType(stageType);

            states.Add(stageType, id);
        }
Пример #12
0
        /// <summary>
        /// Adds Waternet creator settings to the registry.
        /// </summary>
        /// <param name="stageType">The <see cref="MacroStabilityInwardsExportStageType"/>
        /// to register the Waternet creator settings for.</param>
        /// <param name="id">The id of the Waternet creator settings.</param>
        /// <exception cref="InvalidEnumArgumentException">Thrown when <paramref name="stageType"/>
        /// has an invalid value.</exception>
        public void AddWaternetCreatorSettings(MacroStabilityInwardsExportStageType stageType, string id)
        {
            ValidateStageType(stageType);

            waternetCreatorSettings.Add(stageType, id);
        }
Пример #13
0
        /// <summary>
        /// Adds a geometry to the registry.
        /// </summary>
        /// <param name="stageType">The <see cref="MacroStabilityInwardsExportStageType"/>
        /// to register the geometry for.</param>
        /// <param name="id">The id of the geometry.</param>
        /// <exception cref="InvalidEnumArgumentException">Thrown when <paramref name="stageType"/>
        /// has an invalid value.</exception>
        public void AddGeometry(MacroStabilityInwardsExportStageType stageType, string id)
        {
            ValidateStageType(stageType);

            geometries.Add(stageType, id);
        }
Пример #14
0
        private static PersistableGeometry CreateGeometry(IMacroStabilityInwardsSoilProfileUnderSurfaceLine soilProfile, MacroStabilityInwardsExportStageType stageType,
                                                          IdFactory idFactory, MacroStabilityInwardsExportRegistry registry)
        {
            var geometry = new PersistableGeometry
            {
                Id     = idFactory.Create(),
                Layers = MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(soilProfile.Layers)
                         .Select(l => CreateLayer(l, stageType, idFactory, registry))
                         .ToArray()
            };

            registry.AddGeometry(stageType, geometry.Id);

            return(geometry);
        }
Пример #15
0
        private static PersistableState Create(IMacroStabilityInwardsSoilProfileUnderSurfaceLine soilProfile, MacroStabilityInwardsExportStageType stageType,
                                               IdFactory idFactory, MacroStabilityInwardsExportRegistry registry)
        {
            MacroStabilityInwardsSoilLayer2D[] layers = MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(soilProfile.Layers).ToArray();

            var statePoints = new List <PersistableStatePoint>();

            if (PersistableStateHelper.HasValidStatePoints(soilProfile))
            {
                statePoints.AddRange(layers.Where(l => l.Data.UsePop && PersistableStateHelper.HasValidPop(l.Data.Pop))
                                     .Select(l => CreatePOPStatePoint(l, stageType, idFactory, registry))
                                     .ToArray());

                var preconsolidationStressPoints = new List <PersistableStatePoint>();

                foreach (IMacroStabilityInwardsPreconsolidationStress preconsolidationStress in soilProfile.PreconsolidationStresses)
                {
                    MacroStabilityInwardsSoilLayer2D layer = PersistableStateHelper.GetLayerForPreconsolidationStress(layers, preconsolidationStress);
                    if (layer != null)
                    {
                        preconsolidationStressPoints.Add(
                            CreateYieldStressStatePoint(layer, preconsolidationStress, stageType, idFactory, registry));
                    }
                }

                statePoints.AddRange(preconsolidationStressPoints);
            }

            var state = new PersistableState
            {
                Id          = idFactory.Create(),
                StateLines  = Enumerable.Empty <PersistableStateLine>(),
                StatePoints = statePoints
            };

            registry.AddState(stageType, state.Id);

            return(state);
        }
Пример #16
0
        private static PersistableStatePoint CreatePOPStatePoint(MacroStabilityInwardsSoilLayer2D layer, MacroStabilityInwardsExportStageType stageType,
                                                                 IdFactory idFactory, MacroStabilityInwardsExportRegistry registry)
        {
            Point2D interiorPoint = AdvancedMath2D.GetPolygonInteriorPoint(layer.OuterRing.Points, layer.NestedLayers.Select(layers => layers.OuterRing.Points));

            return(new PersistableStatePoint
            {
                Id = idFactory.Create(),
                LayerId = registry.GeometryLayers[stageType][layer],
                IsProbabilistic = true,
                Point = new PersistablePoint(interiorPoint.X, interiorPoint.Y),
                Stress = CreatePOPStress(layer.Data),
                Label = string.Format(Resources.PersistableStateFactory_CreateStatePoint_POP_LayerName_0, layer.Data.MaterialName)
            });
        }
Пример #17
0
 private static PersistableSoilLayer Create(MacroStabilityInwardsSoilLayer2D layer, MacroStabilityInwardsExportStageType stageType,
                                            MacroStabilityInwardsExportRegistry registry)
 {
     return(new PersistableSoilLayer
     {
         LayerId = registry.GeometryLayers[stageType][layer],
         SoilId = registry.Soils[layer]
     });
 }
Пример #18
0
        private static PersistableLayer CreateLayer(MacroStabilityInwardsSoilLayer2D layer, MacroStabilityInwardsExportStageType stageType,
                                                    IdFactory idFactory, MacroStabilityInwardsExportRegistry registry)
        {
            var persistableLayer = new PersistableLayer
            {
                Id     = idFactory.Create(),
                Label  = layer.Data.MaterialName,
                Points = layer.OuterRing.Points.Select(p => new PersistablePoint(p.X, p.Y)).ToArray()
            };

            registry.AddGeometryLayer(stageType, layer, persistableLayer.Id);
            return(persistableLayer);
        }