private static PersistableCalculationSettings Create(IdFactory idFactory, MacroStabilityInwardsExportRegistry registry, MacroStabilityInwardsExportStageType stageType) { var settings = new PersistableCalculationSettings { Id = idFactory.Create() }; registry.AddSettings(stageType, settings.Id); return(settings); }
private static PersistableHeadLine Create(MacroStabilityInwardsPhreaticLine phreaticLine, IdFactory idFactory) { var headLine = new PersistableHeadLine { Id = idFactory.Create(), Label = phreaticLine.Name, Points = phreaticLine.Geometry.Select(point => new PersistablePoint(point.X, point.Y)).ToArray() }; createdHeadLines.Add(phreaticLine, headLine); return(headLine); }
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); }
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) }); }
private static PersistableReferenceLine Create(MacroStabilityInwardsWaternetLine waternetLine, IdFactory idFactory) { string headLineId = createdHeadLines[waternetLine.PhreaticLine].Id; var referenceLine = new PersistableReferenceLine { Id = idFactory.Create(), Label = waternetLine.Name, Points = waternetLine.Geometry.Select(point => new PersistablePoint(point.X, point.Y)).ToArray(), TopHeadLineId = headLineId, BottomHeadLineId = headLineId }; return(referenceLine); }
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); }
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) }); }
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); }
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 }); }
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); }
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); }
/// <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); }
/// <summary> /// Creates a new instance of <see cref="PersistableSoil"/>. /// </summary> /// <param name="layer">The layer to use.</param> /// <param name="idFactory">The factory for creating IDs.</param> /// <param name="registry">The persistence registry.</param> /// <returns>The created <see cref="PersistableSoil"/>.</returns> /// <exception cref="InvalidEnumArgumentException">Thrown when /// <see cref="MacroStabilityInwardsShearStrengthModel"/> has an invalid value.</exception> /// <exception cref="NotSupportedException">Thrown when <see cref="MacroStabilityInwardsShearStrengthModel"/> /// has a valid value but is not supported.</exception> private static PersistableSoil Create(MacroStabilityInwardsSoilLayer2D layer, IdFactory idFactory, MacroStabilityInwardsExportRegistry registry) { MacroStabilityInwardsSoilLayerData layerData = layer.Data; var soil = new PersistableSoil { Id = idFactory.Create(), Name = layerData.MaterialName, IsProbabilistic = true, Cohesion = MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetCohesion(layerData).GetDesignValue(), CohesionStochasticParameter = PersistableStochasticParameterFactory.Create(layerData.Cohesion), FrictionAngle = MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetFrictionAngle(layerData).GetDesignValue(), FrictionAngleStochasticParameter = PersistableStochasticParameterFactory.Create(layerData.FrictionAngle), ShearStrengthRatio = MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetShearStrengthRatio(layerData).GetDesignValue(), ShearStrengthRatioStochasticParameter = PersistableStochasticParameterFactory.Create(layerData.ShearStrengthRatio), StrengthIncreaseExponent = MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetStrengthIncreaseExponent(layerData).GetDesignValue(), StrengthIncreaseExponentStochasticParameter = PersistableStochasticParameterFactory.Create(layerData.StrengthIncreaseExponent), CohesionAndFrictionAngleCorrelated = false, ShearStrengthRatioAndShearStrengthExponentCorrelated = false, ShearStrengthModelTypeAbovePhreaticLevel = GetShearStrengthModelTypeForAbovePhreaticLevel(layerData.ShearStrengthModel), ShearStrengthModelTypeBelowPhreaticLevel = GetShearStrengthModelTypeForBelowPhreaticLevel(layerData.ShearStrengthModel), VolumetricWeightAbovePhreaticLevel = MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetAbovePhreaticLevel(layerData).GetDesignValue(), VolumetricWeightBelowPhreaticLevel = MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetBelowPhreaticLevel(layerData).GetDesignValue(), Dilatancy = 0, DilatancyStochasticParameter = PersistableStochasticParameterFactory.Create(new VariationCoefficientNormalDistribution(2) { Mean = (RoundedDouble)1, CoefficientOfVariation = (RoundedDouble)0 }, false) }; soil.Code = $"{soil.Name}-{soil.Id}"; registry.AddSoil(layer, soil.Id); return(soil); }