Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/FillMacroStabilityInterfaceInputFromEngine.cs =================================================================== diff -u -r6329 -r6346 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/FillMacroStabilityInterfaceInputFromEngine.cs (.../FillMacroStabilityInterfaceInputFromEngine.cs) (revision 6329) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/FillMacroStabilityInterfaceInputFromEngine.cs (.../FillMacroStabilityInterfaceInputFromEngine.cs) (revision 6346) @@ -30,7 +30,18 @@ using Deltares.Geo.Common.Geometry; using Deltares.DamEngine.Calculators.KernelWrappers.Common; using Deltares.MacroStability.Io.XmlInput; +using CharacteristicPointSet = Deltares.DamEngine.Data.Geotechnics.CharacteristicPointSet; +using CharacteristicPointType = Deltares.DamEngine.Data.Geotechnics.CharacteristicPointType; +using GeometryCurve = Deltares.DamEngine.Data.Geometry.GeometryCurve; +using GeometryLoop = Deltares.DamEngine.Data.Geometry.GeometryLoop; +using GeometrySurface = Deltares.DamEngine.Data.Geometry.GeometrySurface; +using Point2D = Deltares.DamEngine.Data.Geometry.Point2D; +using PreConsolidationStress = Deltares.DamEngine.Data.Geotechnics.PreConsolidationStress; using Soil = Deltares.Geo.Common.Geometry.Soil; +using SoilLayer2D = Deltares.DamEngine.Data.Geotechnics.SoilLayer2D; +using SoilProfile2D = Deltares.DamEngine.Data.Geotechnics.SoilProfile2D; +using SoilProfileType = Deltares.MacroStability.Io.XmlInput.SoilProfileType; +using SoilType = Deltares.MacroStability.Io.XmlInput.SoilType; using SurfaceLine2 = Deltares.DamEngine.Data.Geotechnics.SurfaceLine2; using Waternet = Deltares.DamEngine.Data.Geometry.Waternet; @@ -156,7 +167,7 @@ preprocessingInputType.PreConstructionStages[0] = new PreConstructionStageType(); PreConstructionStageType preConstructionLastStage = preprocessingInputType.PreConstructionStages.Last(); preConstructionLastStage.Surfaceline = new SurfaceLineType(); - preConstructionLastStage.CreateWaternet = false; // #Bka: I can NOT find any use of this at the engine side so this must be false!? + preConstructionLastStage.CreateWaternet = false; // #Bka: I can NOT find any use of this at the engine side so this must be false! TransferSurfaceLine(damKernelInput.Location.SurfaceLine, preConstructionLastStage.Surfaceline); preprocessingInputType.SearchAreaConditions = TransferSearchAreaCondition(damKernelInput, mStabParameters); @@ -288,8 +299,16 @@ ConstructionStageInputType lastStage = stabilityInputType.ConstructionStages.Last(); TransferStabilityModelProperties(mStabParameters, stabilityInputType); + TransferSlipPlaneConstraints(damKernelInput.Location, stabilityInputType.SlipPlaneConstraints); + stabilityInputType.Soils = new SoilType[damKernelInput.Location.SoilList.Soils.Count]; + lastStage.FixedSoilStresses = new FixedSoilStressType[damKernelInput.Location.SoilList.Soils.Count]; + TransferSoils(damKernelInput.Location.SoilList, stabilityInputType.Soils, lastStage.FixedSoilStresses, objectRegistry); - //stabilityInputType.StabilityModel = damKernelInput.StabilityModel; + lastStage.SoilProfile = new SoilProfileType(); + lastStage.PreconsolidationStresses = new PreconsolidationStressType[damKernelInput.SubSoilScenario.SoilProfile2D.PreconsolidationStresses.Count]; + lastStage.WaterDefinition = WaterDefinitionType.WaterNet; + TransferSoilProfile(damKernelInput.SubSoilScenario.SoilProfile2D, lastStage.SoilProfile, lastStage.PreconsolidationStresses, objectRegistry); + return stabilityInputType; } @@ -323,6 +342,25 @@ kernelStabilityInput.NumberOfRefinementsTangentLines = 2; } + private static void TransferSlipPlaneConstraints(Location location, SlipPlaneConstraintsType slipPlaneConstraints) + { + if (location.StabilityOptions == null) + { + return; + } + slipPlaneConstraints.SlipPlaneMinDepth = location.StabilityOptions.MinimalCircleDepth ?? 0.0; + if ((location.StabilityOptions.StabilityZoneType == StabilityZoneType.ForbiddenZone) && + location.StabilityOptions.ForbiddenZoneFactor.HasValue) + { + CharacteristicPointSet characteristicPoints = location.SurfaceLine.CharacteristicPoints; + slipPlaneConstraints.XEntryMin = characteristicPoints.GetPoint2D(CharacteristicPointType.DikeTopAtRiver).X; + double xDikeTopAtPolder = characteristicPoints.GetPoint2D(CharacteristicPointType.DikeTopAtPolder).X; + double xDikeToeAtPolder = characteristicPoints.GetPoint2D(CharacteristicPointType.DikeToeAtPolder).X; + double factor = location.StabilityOptions.ForbiddenZoneFactor.Value; + slipPlaneConstraints.XEntryMax = (xDikeToeAtPolder * factor) + ((1 - factor) * xDikeTopAtPolder); + } + } + private void CreateDefaultBeeSwarmOptions(StabilityInputType kernelStabilityInput) { kernelStabilityInput.BeeswarmAlgorithmOptions = new BeeSwarmAlgorithmOptionsType() @@ -338,4 +376,174 @@ GenerationCount = 40 }; } + + private void TransferSoils(SoilList damSoilList, SoilType[] kernelSoils, FixedSoilStressType[] kernelFixedSoilStresses, ObjectRegistry registry) + { + if (damSoilList != null) + { + int i = 0; + foreach (Data.Geotechnics.Soil damSoil in damSoilList.Soils) + { + SoilType kernelSoil = CreateSoil(damSoil, registry); + kernelSoils[i] = kernelSoil; + FixedSoilStressType kernelFixedSoilStressType = new FixedSoilStressType(); + kernelFixedSoilStressType.POP = damSoil.PoP; + kernelFixedSoilStressType.Soil = kernelSoil.Key; + kernelFixedSoilStresses[i] = kernelFixedSoilStressType; + i++; + } + } + } + + private static SoilType CreateSoil(Deltares.DamEngine.Data.Geotechnics.Soil soil, ObjectRegistry registry) + { + SoilType soilType = InterfaceConversionHelper.ConvertToMacroStabilitySoil(soil); + soilType.Key = registry.GetId(soil); + return soilType; + } + + private void TransferSoilProfile(SoilProfile2D damSoilProfile2D, SoilProfileType kernelSoilProfile, + ICollection preConsolidationStresses, ObjectRegistry registry) + { + // Add points + kernelSoilProfile.Geometry = new GeometryType + { + Bottom = damSoilProfile2D.Geometry.Bottom, + Left = damSoilProfile2D.Geometry.Left, + Right = damSoilProfile2D.Geometry.Right, + Points = new PointType[damSoilProfile2D.Geometry.Points.Count], + Curves = new CurveType[damSoilProfile2D.Geometry.Curves.Count], + Loops = new LoopType[damSoilProfile2D.Geometry.Loops.Count], + GeometrySurfaces = new GeometrySurfaceType[damSoilProfile2D.Geometry.Surfaces.Count] + }; + kernelSoilProfile.SoilSurfaces = new SoilSurfaceType[damSoilProfile2D.Surfaces.Count]; + + TransferSoilProfileGeometryPoints(damSoilProfile2D, kernelSoilProfile, registry); + TransferSoilProfileGeometryCurves(damSoilProfile2D, kernelSoilProfile, registry); + TransferSoilProfileGeometryLoops(damSoilProfile2D, kernelSoilProfile, registry); + TransferSoilProfileGeometrySurfaces(damSoilProfile2D, kernelSoilProfile, registry); + + TransferSoilProfileSoilLayers2D(damSoilProfile2D, kernelSoilProfile, registry); + + TransferSoilProfilePreConsolidationStresses(damSoilProfile2D, preConsolidationStresses); + } + + private static void TransferSoilProfilePreConsolidationStresses(SoilProfile2D damSoilProfile2D, ICollection preConsolidationStresses) + { + foreach (PreConsolidationStress preConsolidationStress in damSoilProfile2D.PreconsolidationStresses) + { + var kernelPreConsolidationStressType = new PreconsolidationStressType + { + Point = new Point2DType + { + X = preConsolidationStress.X, + Z = preConsolidationStress.Z + }, + StressValue = preConsolidationStress.StressValue + }; + preConsolidationStresses.Add(kernelPreConsolidationStressType); + } + } + + private static void TransferSoilProfileSoilLayers2D(SoilProfile2D damSoilProfile2D, SoilProfileType kernelSoilProfile, ObjectRegistry registry) + { + int i = 0; + foreach (SoilLayer2D damSoilLayer2D in damSoilProfile2D.Surfaces) + { + var kernelSoilLayer2D = new SoilSurfaceType + { + Key = registry.GetId(damSoilLayer2D), + Name = damSoilLayer2D.Name, + IsAquifer = damSoilLayer2D.IsAquifer, + GeometrySurface = registry.GetId(damSoilLayer2D.GeometrySurface), + Soil = registry.GetId(damSoilLayer2D.Soil), + WaterPressureInterpolationModelSpecified = true, + WaterPressureInterpolationModel = InterfaceConversionHelper.ConvertToMacroStabilityWaterpressureInterpolationModel(damSoilLayer2D + .WaterpressureInterpolationModel) + }; + kernelSoilProfile.SoilSurfaces[i] = kernelSoilLayer2D; + i++; + } + } + + private static void TransferSoilProfileGeometrySurfaces(SoilProfile2D damSoilProfile2D, SoilProfileType kernelSoilProfile, ObjectRegistry registry) + { + int i; + i = 0; + foreach (SoilLayer2D damSurface in damSoilProfile2D.Surfaces) + { + var kernelGeometrySurface = new GeometrySurfaceType + { + Key = registry.GetId(damSurface) + }; + GeometrySurface damGeometrySurface = damSurface.GeometrySurface; + kernelGeometrySurface.OuterLoop = registry.GetId(damGeometrySurface.OuterLoop); + kernelGeometrySurface.InnerLoops = new GeometrySurfaceTypeInnerLoop[damGeometrySurface.InnerLoops.Count]; + int j = 0; + foreach (GeometryLoop damSurfaceInnerLoop in damGeometrySurface.InnerLoops) + { + kernelGeometrySurface.InnerLoops[j].Loop = registry.GetId(damSurfaceInnerLoop); + } + + kernelSoilProfile.Geometry.GeometrySurfaces [i] = kernelGeometrySurface; + } + } + + private static void TransferSoilProfileGeometryLoops(SoilProfile2D damSoilProfile2D, SoilProfileType kernelSoilProfile, ObjectRegistry registry) + { + int i = 0; + foreach (GeometryLoop damLoop in damSoilProfile2D.Geometry.Loops) + { + var kernelLoop = new LoopType + { + Key = registry.GetId(damLoop), + Curves = new LoopTypeCurve[damLoop.CurveList.Count] + }; + int j = 0; + foreach (GeometryCurve geometryCurve in damLoop.CurveList) + { + var kernelCurve = new LoopTypeCurve + { + Curve = registry.GetId(geometryCurve) + }; + kernelLoop.Curves[j] = kernelCurve; + j++; + } + + kernelSoilProfile.Geometry.Loops[i] = kernelLoop; + i++; + } + } + + private static void TransferSoilProfileGeometryCurves(SoilProfile2D damSoilProfile2D, SoilProfileType kernelSoilProfile, ObjectRegistry registry) + { + int i = 0; + foreach (GeometryCurve damCurve in damSoilProfile2D.Geometry.Curves) + { + var kernelCurve = new CurveType + { + HeadPoint = registry.GetId(damCurve.HeadPoint), + EndPoint = registry.GetId(damCurve.EndPoint), + Key = registry.GetId(damCurve) + }; + kernelSoilProfile.Geometry.Curves[i] = kernelCurve; + i++; + } + } + + private static void TransferSoilProfileGeometryPoints(SoilProfile2D damSoilProfile2D, SoilProfileType kernelSoilProfile, ObjectRegistry registry) + { + int i = 0; + foreach (Point2D damPoint in damSoilProfile2D.Geometry.Points) + { + var kernelPoint = new PointType + { + X = damPoint.X, + Z = damPoint.Z, + Key = registry.GetId(damPoint) + }; + kernelSoilProfile.Geometry.Points[i] = kernelPoint; + i++; + } + } } \ No newline at end of file Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/InterfaceConversionHelper.cs =================================================================== diff -u -r6322 -r6346 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/InterfaceConversionHelper.cs (.../InterfaceConversionHelper.cs) (revision 6322) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/InterfaceConversionHelper.cs (.../InterfaceConversionHelper.cs) (revision 6346) @@ -173,4 +173,102 @@ }; return translationTable[damCharacteristicPointType]; } + + public static SoilType ConvertToMacroStabilitySoil(Data.Geotechnics.Soil soil) + { + var macroStabilitySoil = new SoilType + { + Name = soil.Name, + AbovePhreaticLevel = soil.AbovePhreaticLevel, + BelowPhreaticLevel = soil.BelowPhreaticLevel, + Cohesion = soil.Cohesion, + FrictionAngle = soil.FrictionAngle, + Dilatancy = soil.FrictionAngle, + RatioCuPc = soil.RatioCuPc, + StrengthIncreaseExponent = soil.ShearStrengthModel == ShearStrengthModel.SuTable && double.IsNaN(soil.StrengthIncreaseExponent) ? 1.0 : soil.StrengthIncreaseExponent, // can't be NaN in MAC kernel because used for multi-stages + UseSoilClassification = false, // Soil type is not given so make sure it is not used. + BondStressCurve = null, // these are not supported in DAM so set to null. + SigmaTauTable = new SoilTypeSigmaTauTablePoint[soil.SigmaTauCurve.Points.Count], + SuTable = new SoilTypeSuTablePoint[soil.SuTableCurve.Points.Count] + }; + + if (soil.ShearStrengthModel != null) + { + macroStabilitySoil.ShearStrengthAbovePhreaticLevelModel = ConvertToMacroStabilityShearStrengthModel(soil.ShearStrengthModel.Value); + macroStabilitySoil.ShearStrengthBelowPhreaticLevelModel = ConvertToMacroStabilityShearStrengthModel(soil.ShearStrengthModel.Value); + } + + if (soil.SigmaTauCurve != null) + { + int i = 0; + foreach (SigmaTauPoint point in soil.SigmaTauCurve.Points) + { + SoilTypeSigmaTauTablePoint tablePoint = new SoilTypeSigmaTauTablePoint + { + Sigma = point.Sigma, + Tau = point.Tau + }; + macroStabilitySoil.SigmaTauTable[i] = tablePoint; + i++; + } + } + + if (soil.SuTableCurve != null) + { + int i = 0; + foreach (SigmaSuPoint point in soil.SuTableCurve.Points) + { + SoilTypeSuTablePoint tablePoint = new SoilTypeSuTablePoint + { + Su = point.Su, + EffectiveStress = point.Sigma + }; + macroStabilitySoil.SuTable[i] = tablePoint; + i++; + } + } + + return macroStabilitySoil; + } + + /// Converts to macro stability ShearStrengthModel. + /// The dam ShearStrengthModel. + /// + /// + public static ShearStrengthModelType ConvertToMacroStabilityShearStrengthModel(ShearStrengthModel damShearStrengthModel) + { + var translationTable = new Dictionary + { + { + ShearStrengthModel.CPhi, ShearStrengthModelType.MohrCoulomb + }, + { + ShearStrengthModel.SuCalculated, ShearStrengthModelType.Shansep + }, + { + ShearStrengthModel.SigmaTauCurve, ShearStrengthModelType.SigmaTauTable + }, + { + ShearStrengthModel.SuTable, ShearStrengthModelType.SuTable + } + }; + return translationTable[damShearStrengthModel]; + } + + /// Converts to macro stability waterpressure interpolation model. + /// The waterpressure interpolation model. + /// + public static WaterPressureInterpolationModelType ConvertToMacroStabilityWaterpressureInterpolationModel(WaterpressureInterpolationModel waterpressureInterpolationModel) + { + var translationTable = new Dictionary + { + { + WaterpressureInterpolationModel.Automatic, WaterPressureInterpolationModelType.Automatic + }, + { + WaterpressureInterpolationModel.Hydrostatic, WaterPressureInterpolationModelType.Hydrostatic + } + }; + return translationTable[waterpressureInterpolationModel]; + } } \ No newline at end of file