Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/FillEngineFromMacroStabilityWrapperInput.cs =================================================================== diff -u -r2926 -r2936 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/FillEngineFromMacroStabilityWrapperInput.cs (.../FillEngineFromMacroStabilityWrapperInput.cs) (revision 2926) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/FillEngineFromMacroStabilityWrapperInput.cs (.../FillEngineFromMacroStabilityWrapperInput.cs) (revision 2936) @@ -25,7 +25,9 @@ using Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.Geometry; using Deltares.DamEngine.Data.Geotechnics; +using Deltares.MacroStability.CSharpWrapper.Input; using CharacteristicPoint = Deltares.DamEngine.Data.Geotechnics.CharacteristicPoint; +using Soil = Deltares.DamEngine.Data.Geotechnics.Soil; using SurfaceLine2 = Deltares.DamEngine.Data.Geotechnics.SurfaceLine2; @@ -70,7 +72,8 @@ Location = null; TransferStabilityModel(macroStabilityInput.StabilityModel); TransferSoils(macroStabilityInput.StabilityModel.Soils); - TransferSoilProfile2D(macroStabilityInput.StabilityModel.ConstructionStages.Last().SoilProfile); + var lastStage = macroStabilityInput.StabilityModel.ConstructionStages.Last(); + TransferSoilProfile2D(lastStage.SoilProfile, lastStage.PreconsolidationStresses); TransferSurfaceLine(macroStabilityInput.PreprocessingInput.PreConstructionStages.Last().Surfaceline); TransferWaternet(macroStabilityInput.StabilityModel.ConstructionStages.Last().Waternet); TransferUpliftVanCalculationGrid(macroStabilityInput.StabilityModel.UpliftVanCalculationGrid, macroStabilityInput.PreprocessingInput.SearchAreaConditions); @@ -216,100 +219,79 @@ ConversionHelper.ConvertToMStabGridPosition(kernelModelStabilityModel.Orientation); } - private void TransferSoilProfile2D(MacroStability.CSharpWrapper.Input.SoilProfile kernelSoilProfile2D) + private void TransferSoilProfile2D(MacroStability.CSharpWrapper.Input.SoilProfile kernelSoilProfile2D, IList preconsolidationStresses) { - // SoilProfile2D = new SoilProfile2D(); - // - // // Add points - // foreach (var kernelPoint in kernelSoilProfile2D.Geometry.Points) - // { - // Data.Geometry.Point2D damPoint; - // if (dictPoints.ContainsKey(kernelPoint)) - // { - // damPoint = dictPoints[kernelPoint]; - // } - // else - // { - // damPoint = new Data.Geometry.Point2D() { X = kernelPoint.X, Z = kernelPoint.Z }; - // dictPoints.Add(kernelPoint, damPoint); - // } - // SoilProfile2D.Geometry.Points.Add(damPoint); - // } - // - // // Add curves - // foreach (var kernelCurve in kernelsoilProfile2D.Geometry.Curves) - // { - // Data.Geometry.GeometryCurve damCurve; - // if (dictCurves.ContainsKey(kernelCurve)) - // { - // damCurve = dictCurves[kernelCurve]; - // } - // else - // { - // var kernelHeadPoint = kernelCurve.HeadPoint; - // var kernelEndPoint = kernelCurve.EndPoint; - // var damHeadPoint = dictPoints[kernelHeadPoint]; - // var damEndPoint = dictPoints[kernelEndPoint]; - // damCurve = new Data.Geometry.GeometryCurve() { HeadPoint = damHeadPoint, EndPoint = damEndPoint }; - // dictCurves.Add(kernelCurve, damCurve); - // } - // SoilProfile2D.Geometry.Curves.Add(damCurve); - // } - // - // // Add loops - // foreach (var kernelLoop in kernelsoilProfile2D.Geometry.Loops) - // { - // Data.Geometry.GeometryLoop damLoop; - // if (dictLoops.ContainsKey(kernelLoop)) - // { - // damLoop = dictLoops[kernelLoop]; - // } - // else - // { - // damLoop = new Data.Geometry.GeometryLoop() { Name = kernelLoop.Name }; - // foreach (var damCurve in kernelLoop.CurveList) - // { - // damLoop.CurveList.Add(dictCurves[damCurve]); - // } - // - // dictLoops.Add(kernelLoop, damLoop); - // } - // SoilProfile2D.Geometry.Loops.Add(damLoop); - // } - // - // // Add surfaces - // foreach (var kernelSurface in kernelsoilProfile2D.Geometry.Surfaces) - // { - // Data.Geometry.GeometrySurface damSurface; - // if (dictSurfaces.ContainsKey(kernelSurface)) - // { - // damSurface = dictSurfaces[kernelSurface]; - // } - // else - // { - // damSurface = new Data.Geometry.GeometrySurface() { Name = kernelSurface.Name }; - // damSurface.OuterLoop = dictLoops[kernelSurface.OuterLoop]; - // foreach (var damInnerLoop in kernelSurface.InnerLoops) - // { - // damSurface.InnerLoops.Add(dictLoops[damInnerLoop]); - // } - // - // dictSurfaces.Add(kernelSurface, damSurface); - // } - // - // SoilProfile2D.Geometry.Surfaces.Add(damSurface); - // } - // - // // Add soil surfaces - // foreach (var kernelSoilLayer2D in kernelsoilProfile2D.Surfaces) - // { - // SoilLayer2D damSoilLayer2D = new SoilLayer2D(); - // damSoilLayer2D.GeometrySurface = dictSurfaces[kernelSoilLayer2D.GeometrySurface]; - // damSoilLayer2D.Soil = dictSoils[kernelSoilLayer2D.Soil.Name]; - // damSoilLayer2D.IsAquifer = kernelSoilLayer2D.IsAquifer; - // damSoilLayer2D.WaterpressureInterpolationModel = ConversionHelper.ConvertToDamWaterpressureInterpolationModel(kernelSoilLayer2D.WaterpressureInterpolationModel); - // SoilProfile2D.Surfaces.Add(damSoilLayer2D); - // } + SoilProfile2D = new SoilProfile2D(); + + // Add points + var pointsDictionary = new Dictionary(); + foreach (var kernelPoint in kernelSoilProfile2D.Geometry.Points) + { + var damPoint = new Data.Geometry.Point2D() { X = kernelPoint.X, Z = kernelPoint.Z }; + pointsDictionary.Add(kernelPoint, damPoint); + SoilProfile2D.Geometry.Points.Add(damPoint); + } + + // Add curves + var curvesDictionary = new Dictionary(); + foreach (var kernelCurve in kernelSoilProfile2D.Geometry.Curves) + { + var damHeadPoint = pointsDictionary[kernelCurve.HeadPoint]; + var damEndPoint = pointsDictionary[kernelCurve.EndPoint]; + var damCurve = new GeometryCurve() { HeadPoint = damHeadPoint, EndPoint = damEndPoint }; + curvesDictionary.Add(kernelCurve, damCurve); + SoilProfile2D.Geometry.Curves.Add(damCurve); + } + + // Add loops + var loopsDictionary = new Dictionary(); + foreach (var kernelLoop in kernelSoilProfile2D.Geometry.Loops) + { + var damLoop = new Data.Geometry.GeometryLoop(); + foreach (var damCurve in kernelLoop.Curves) + { + damLoop.CurveList.Add(curvesDictionary[damCurve]); + } + loopsDictionary.Add(kernelLoop, damLoop); + SoilProfile2D.Geometry.Loops.Add(damLoop); + } + + // Add surfaces + var geometrySurfacesDictionary = new Dictionary(); + foreach (var kernelSurface in kernelSoilProfile2D.Geometry.GeometrySurfaces) + { + var damSurface = new Data.Geometry.GeometrySurface(); + damSurface.OuterLoop = loopsDictionary[kernelSurface.OuterLoop]; + foreach (var damInnerLoop in kernelSurface.InnerLoops) + { + damSurface.InnerLoops.Add(loopsDictionary[damInnerLoop]); + } + geometrySurfacesDictionary.Add(kernelSurface, damSurface); + SoilProfile2D.Geometry.Surfaces.Add(damSurface); + } + + // Add soil surfaces + foreach (var kernelSoilLayer2D in kernelSoilProfile2D.SoilSurfaces) + { + SoilLayer2D damSoilLayer2D = new SoilLayer2D(); + damSoilLayer2D.GeometrySurface = geometrySurfacesDictionary[kernelSoilLayer2D.GeometrySurface]; + damSoilLayer2D.Soil = soilDictionary[kernelSoilLayer2D.Soil.Name]; + damSoilLayer2D.IsAquifer = kernelSoilLayer2D.IsAquifer; + damSoilLayer2D.WaterpressureInterpolationModel = ConversionHelper.ConvertToDamWaterpressureInterpolationModel(kernelSoilLayer2D.WaterPressureInterpolationModel); + SoilProfile2D.Surfaces.Add(damSoilLayer2D); + } + + // Add the preconsolidation stresses + foreach (var preconsolidationStress in preconsolidationStresses) + { + var damPreConsolidationStress = new PreConsolidationStress + { + X = preconsolidationStress.Point.X, + Z = preconsolidationStress.Point.Z, + StressValue = preconsolidationStress.StressValue + }; + SoilProfile2D.PreconsolidationStresses.Add(damPreConsolidationStress); + } } } Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/FillMacroStabilityWrapperInputFromEngine.cs =================================================================== diff -u -r2926 -r2936 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/FillMacroStabilityWrapperInputFromEngine.cs (.../FillMacroStabilityWrapperInputFromEngine.cs) (revision 2926) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/FillMacroStabilityWrapperInputFromEngine.cs (.../FillMacroStabilityWrapperInputFromEngine.cs) (revision 2936) @@ -24,6 +24,7 @@ using Deltares.DamEngine.Calculators.KernelWrappers.Common; using Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.Geotechnics; +using Deltares.MacroStability.CSharpWrapper; using WaterNet = Deltares.DamEngine.Data.Geometry.Waternet; using Deltares.MacroStability.CSharpWrapper.Input; @@ -35,6 +36,9 @@ /// public class FillMacroStabilityWrapperInputFromEngine { + + private Dictionary soilsDictionary = + new Dictionary(); /// Gets or sets the UpliftVan calculation grid. /// The uplift van calculation grid. public UpliftVanCalculationGrid UpliftVanCalculationGrid { get; set; } @@ -45,6 +49,7 @@ public MacroStabilityInput CreateMacroStabilityInput(DamKernelInput damKernelInput, FailureMechanismParametersMStab failureMechanismParametersMStab, Data.Geometry.Waternet waternet) { + soilsDictionary.Clear(); var macroStabilityInput = new Deltares.MacroStability.CSharpWrapper.Input.MacroStabilityInput(); macroStabilityInput.StabilityModel = new StabilityInput(); // ToDo check whether this is needed. macroStabilityInput.PreprocessingInput = new PreprocessingInput(); // ToDo check whether this is needed. @@ -55,7 +60,8 @@ macroStabilityInput.StabilityModel.ConstructionStages.Add(new ConstructionStage()); // ToDo check whether this is needed. var lastStage = macroStabilityInput.StabilityModel.ConstructionStages.Last(); lastStage.SoilProfile = new MacroStability.CSharpWrapper.Input.SoilProfile(); // ToDo check whether this is needed. - TransferSoilProfile(damKernelInput.SubSoilScenario.SoilProfile2D, lastStage.SoilProfile); + lastStage.PreconsolidationStresses = new List(); // ToDo check whether this is needed. + TransferSoilProfile(damKernelInput.SubSoilScenario.SoilProfile2D, lastStage.SoilProfile, lastStage.PreconsolidationStresses); macroStabilityInput.PreprocessingInput.PreConstructionStages.Add(new PreConstructionStage()); // ToDo check whether this is needed. var preConstructionLastStage = macroStabilityInput.PreprocessingInput.PreConstructionStages.Last(); @@ -87,101 +93,92 @@ { var kernelSoil = ConversionHelper.ConvertToMacroStabilitySoil(damSoil); kernelSoils.Add(kernelSoil); + soilsDictionary.Add(damSoil, kernelSoil); } } } - private void TransferSoilProfile(DamEngine.Data.Geotechnics.SoilProfile2D damSoilProfile2D, MacroStability.CSharpWrapper.Input.SoilProfile kernelSoilProfile) + private void TransferSoilProfile(SoilProfile2D damSoilProfile2D, MacroStability.CSharpWrapper.Input.SoilProfile kernelSoilProfile, IList preconsolidationStresses) { - // // Add points - // foreach (var damPoint in damSoilProfile2D.Geometry.Points) - // { - // Point2D kernelPoint2D; - // if (dictPoints.ContainsKey(damPoint)) - // { - // kernelPoint2D = dictPoints[damPoint]; - // } - // else - // { - // kernelPoint2D = new Point2D() { X = damPoint.X, Z = damPoint.Z }; - // dictPoints.Add(damPoint, kernelPoint2D); - // } - // kernelSoilProfile.Geometry.Points.Add(kernelPoint2D); - // } - // - // // Add curves - // foreach (var damCurve in damSoilProfile2D.Geometry.Curves) - // { - // GeometryCurve kernelCurve; - // if (dictCurves.ContainsKey(damCurve)) - // { - // kernelCurve = dictCurves[damCurve]; - // } - // else - // { - // var damHeadPoint = damCurve.HeadPoint; - // var damEndPoint = damCurve.EndPoint; - // var kernelHeadPoint = dictPoints[damHeadPoint]; - // var kernelEndPoint = dictPoints[damEndPoint]; - // kernelCurve = new GeometryCurve() {HeadPoint = kernelHeadPoint, EndPoint = kernelEndPoint}; - // dictCurves.Add(damCurve, kernelCurve); - // } - // kernelSoilProfile.Geometry.Curves.Add(kernelCurve); - // } - // - // // Add loops - // foreach (var damLoop in damSoilProfile2D.Geometry.Loops) - // { - // GeometryLoop kernelLoop; - // if (dictLoops.ContainsKey(damLoop)) - // { - // kernelLoop = dictLoops[damLoop]; - // } - // else - // { - // kernelLoop = new GeometryLoop(){Name = damLoop.Name}; - // foreach (var damCurve in damLoop.CurveList) - // { - // kernelLoop.CurveList.Add(dictCurves[damCurve]); - // } - // - // dictLoops.Add(damLoop, kernelLoop); - // } - // kernelSoilProfile.Geometry.Loops.Add(kernelLoop); - // } - // - // // Add surfaces - // foreach (var damSurface in damSoilProfile2D.Geometry.Surfaces) - // { - // GeometrySurface kernelSurface; - // if (dictSurfaces.ContainsKey(damSurface)) - // { - // kernelSurface = dictSurfaces[damSurface]; - // } - // else - // { - // kernelSurface = new GeometrySurface() { Name = damSurface.Name }; - // kernelSurface.OuterLoop = dictLoops[damSurface.OuterLoop]; - // foreach (var damInnerLoop in damSurface.InnerLoops) - // { - // kernelSurface.InnerLoops.Add(dictLoops[damInnerLoop]); - // } - // dictSurfaces.Add(damSurface, kernelSurface); - // } - // kernelSoilProfile.Geometry.Surfaces.Add(kernelSurface); - // } - // - // // Add soil surfaces - // foreach (var damSoilLayer2D in damSoilProfile2D.Surfaces) - // { - // MacroStability.Geometry.SoilLayer2D kernelSoilLayer2D = new MacroStability.Geometry.SoilLayer2D(); - // kernelSoilLayer2D.GeometrySurface = dictSurfaces[damSoilLayer2D.GeometrySurface]; - // kernelSoilLayer2D.Soil = dictSoils[damSoilLayer2D.Soil]; - // kernelSoilLayer2D.IsAquifer = damSoilLayer2D.IsAquifer; - // kernelSoilLayer2D.WaterpressureInterpolationModel = ConversionHelper.ConvertToMacroStabilityWaterpressureInterpolationModel(damSoilLayer2D.WaterpressureInterpolationModel); - // soilProfile2D.Surfaces.Add(kernelSoilLayer2D); - // } - // kernelSoilProfile.Geometry.Rebox(); // The boundaries should be set correctly + // Add points + var pointsDictionary = new Dictionary(); + kernelSoilProfile.Geometry = new Geometry(); + kernelSoilProfile.Geometry.Points = new List(); + foreach (var damPoint in damSoilProfile2D.Geometry.Points) + { + var kernelPoint = new Point2D(damPoint.X, damPoint.Z); + kernelSoilProfile.Geometry.Points.Add(kernelPoint); + pointsDictionary.Add(damPoint, kernelPoint); + } + + // Add curves + var curvesDictionary = new Dictionary(); + kernelSoilProfile.Geometry.Curves = new List(); + foreach (var damCurve in damSoilProfile2D.Geometry.Curves) + { + var kernelCurve = new Curve + { + HeadPoint = pointsDictionary[damCurve.HeadPoint], EndPoint = pointsDictionary[damCurve.EndPoint] + }; + kernelSoilProfile.Geometry.Curves.Add(kernelCurve); + curvesDictionary.Add(damCurve, kernelCurve); + } + + // Add loops + var loopsDictionary = new Dictionary(); + kernelSoilProfile.Geometry.Loops = new List(); + foreach (var damLoop in damSoilProfile2D.Geometry.Loops) + { + var kernelLoop = new Loop(); + kernelLoop.Curves = new List(); + foreach (var geometryCurve in damLoop.CurveList) + { + kernelLoop.Curves.Add(curvesDictionary[geometryCurve]); + } + kernelSoilProfile.Geometry.Loops.Add(kernelLoop); + loopsDictionary.Add(damLoop, kernelLoop); + } + + // Add geometry surfaces + var geometrySurfacesDictionary = new Dictionary(); + kernelSoilProfile.Geometry.GeometrySurfaces = new List(); + foreach (var damSurface in damSoilProfile2D.Geometry.Surfaces) + { + var kernelGeometrySurface = new Surface(); + kernelGeometrySurface.OuterLoop = loopsDictionary[damSurface.OuterLoop]; + geometrySurfacesDictionary.Add(damSurface, kernelGeometrySurface); + kernelGeometrySurface.InnerLoops = new List(damSurface.InnerLoops.Count); + foreach (var damSurfaceInnerLoop in damSurface.InnerLoops) + { + kernelGeometrySurface.InnerLoops.Add(loopsDictionary[damSurfaceInnerLoop]); + } + kernelSoilProfile.Geometry.GeometrySurfaces.Add(kernelGeometrySurface); + } + + // Add soil surfaces + kernelSoilProfile.SoilSurfaces = new List(); + foreach (var damSoilLayer2D in damSoilProfile2D.Surfaces) + { + var kernelSoilLayer2D = new SoilProfileSurface + { + GeometrySurface = geometrySurfacesDictionary[damSoilLayer2D.GeometrySurface], + Soil = soilsDictionary[damSoilLayer2D.Soil], + IsAquifer = damSoilLayer2D.IsAquifer, + WaterPressureInterpolationModel = + ConversionHelper.ConvertToMacroStabilityWaterpressureInterpolationModel(damSoilLayer2D + .WaterpressureInterpolationModel) + }; + kernelSoilProfile.SoilSurfaces.Add(kernelSoilLayer2D); + } + + // Add the preconsolidation stresses + foreach (var preconsolidationStress in damSoilProfile2D.PreconsolidationStresses) + { + var kernelPrecon = new PreconsolidationStress(); + kernelPrecon.Point = new Point2D(preconsolidationStress.X, preconsolidationStress.Z); + kernelPrecon.StressValue = preconsolidationStress.StressValue; + preconsolidationStresses.Add(kernelPrecon); + } } private void TransferSurfaceLine(Data.Geotechnics.SurfaceLine2 damSurfaceLine, SurfaceLine kernelSurfaceLine) Index: DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/Factories/FactoryForDamProjectData.cs =================================================================== diff -u -r2922 -r2936 --- DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/Factories/FactoryForDamProjectData.cs (.../FactoryForDamProjectData.cs) (revision 2922) +++ DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/Factories/FactoryForDamProjectData.cs (.../FactoryForDamProjectData.cs) (revision 2936) @@ -546,6 +546,7 @@ outerLoop.CurveList.Add(curve1); outerLoop.CurveList.Add(curve2); outerLoop.CurveList.Add(curve3); + outerLoop.SyncPoints(); layer.GeometrySurface.OuterLoop = outerLoop; profile.Geometry.Loops.Add(outerLoop); var innerloop = new GeometryLoop(); @@ -555,6 +556,7 @@ innerloop.CurveList.Add(curve4); innerloop.CurveList.Add(curve5); innerloop.CurveList.Add(curve6); + innerloop.SyncPoints(); layer.GeometrySurface.InnerLoops.Add(innerloop); profile.Geometry.Loops.Add(innerloop); profile.Surfaces.Add(layer); Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/MacroStabilityIoTests.cs =================================================================== diff -u -r2922 -r2936 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/MacroStabilityIoTests.cs (.../MacroStabilityIoTests.cs) (revision 2922) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/MacroStabilityIoTests.cs (.../MacroStabilityIoTests.cs) (revision 2936) @@ -101,7 +101,7 @@ // Then the data models are equal CompareStabilityModel(expectedParametersMStab, fillEngineFromMacroStabilityWrapperInput.FailureMechanismParametersMStab); CompareSoilModel(expectedSoilList, fillEngineFromMacroStabilityWrapperInput.SoilList); - + CompareSoilProfile2D(expectedSoilProfile2D, fillEngineFromMacroStabilityWrapperInput.SoilProfile2D); //Todo : add and or implement comparer per item as these are added to the code } @@ -219,10 +219,11 @@ Assert.AreEqual(0, result.Differences.Count, "Differences found read/write kernel SurfaceLine"); } - private void CompareSoilProfile2D(MacroStability.Geometry.SoilProfile2D expectedSoilProfile, MacroStability.Geometry.SoilProfile2D actualSoilProfile) + private void CompareSoilProfile2D(SoilProfile2D expectedSoilProfile, SoilProfile2D actualSoilProfile) { var compare = new CompareLogic { Config = { MaxDifferences = 100 } }; compare.Config.MembersToIgnore = SoilParametersToIgnore; + compare.Config.MembersToIgnore.Add("Name"); var result = compare.Compare(expectedSoilProfile, actualSoilProfile); Assert.AreEqual(0, result.Differences.Count, "Differences found read/write kernel SoilProfile2D"); } @@ -247,8 +248,6 @@ Assert.AreEqual(expectedStabilityModel.MStabParameters.SearchMethod, actualStabilityModel.MStabParameters.SearchMethod); Assert.AreEqual(expectedStabilityModel.MStabParameters.Model, actualStabilityModel.MStabParameters.Model); Assert.AreEqual(expectedStabilityModel.MStabParameters.GridPosition, actualStabilityModel.MStabParameters.GridPosition); - Assert.AreEqual(expectedStabilityModel.MStabParameters.SlipCircleDefinition.GridSizeDetermination, actualStabilityModel.MStabParameters.SlipCircleDefinition.GridSizeDetermination); - } private DamProjectData CreateExampleDamProjectData()