Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/ConversionHelperTests.cs =================================================================== diff -u -r1997 -r2002 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/ConversionHelperTests.cs (.../ConversionHelperTests.cs) (revision 1997) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/ConversionHelperTests.cs (.../ConversionHelperTests.cs) (revision 2002) @@ -146,5 +146,24 @@ Assert.AreEqual(0, result.Differences.Count, "Differences found converting/reconverting Soil"); } #endregion + + #region WaterpressureInterpolationModel + [TestCase(Data.Geotechnics.WaterpressureInterpolationModel.Automatic, WaterpressureInterpolationModel.Automatic)] + [TestCase(Data.Geotechnics.WaterpressureInterpolationModel.Hydrostatic, WaterpressureInterpolationModel.Hydrostatic)] + public static void CanConvertToMacroStabilityWaterpressureInterpolationModel( + Data.Geotechnics.WaterpressureInterpolationModel damWaterpressureInterpolationModel, WaterpressureInterpolationModel waterpressureInterpolationModel) + { + Assert.AreEqual(waterpressureInterpolationModel, ConversionHelper.ConvertToMacroStabilityWaterpressureInterpolationModel(damWaterpressureInterpolationModel)); + } + + [TestCase(WaterpressureInterpolationModel.Automatic, Data.Geotechnics.WaterpressureInterpolationModel.Automatic)] + [TestCase(WaterpressureInterpolationModel.Hydrostatic, Data.Geotechnics.WaterpressureInterpolationModel.Hydrostatic)] + public static void CanConvertToDamWaterpressureInterpolationModel( + WaterpressureInterpolationModel waterpressureInterpolationModel, Data.Geotechnics.WaterpressureInterpolationModel damWaterpressureInterpolationModel) + { + Assert.AreEqual(damWaterpressureInterpolationModel, ConversionHelper.ConvertToDamWaterpressureInterpolationModel(waterpressureInterpolationModel)); + } + #endregion + } } Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/ConversionHelper.cs =================================================================== diff -u -r1997 -r2002 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/ConversionHelper.cs (.../ConversionHelper.cs) (revision 1997) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/ConversionHelper.cs (.../ConversionHelper.cs) (revision 2002) @@ -27,6 +27,7 @@ using Deltares.MacroStability.Data; using Deltares.MacroStability.Geometry; using Soil = Deltares.MacroStability.Geometry.Soil; +using WaterpressureInterpolationModel = Deltares.MacroStability.Geometry.WaterpressureInterpolationModel; namespace Deltares.DamEngine.Calculators.KernelWrappers.MacroStabilityCommon.MacroStabilityIo { @@ -171,6 +172,7 @@ } return macroStabilitySoil; } + /// Converts to Dam soil. /// The MacroStability soil. /// The Dam soil. @@ -226,5 +228,30 @@ return damSoil; } #endregion + /// Converts to macro stability waterpressure interpolation model. + /// The waterpressure interpolation model. + /// + public static WaterpressureInterpolationModel ConvertToMacroStabilityWaterpressureInterpolationModel(Data.Geotechnics.WaterpressureInterpolationModel waterpressureInterpolationModel) + { + var translationTable = new Dictionary() + { + {Data.Geotechnics.WaterpressureInterpolationModel.Automatic, WaterpressureInterpolationModel.Automatic}, + {Data.Geotechnics.WaterpressureInterpolationModel.Hydrostatic, WaterpressureInterpolationModel.Hydrostatic} + }; + return translationTable[waterpressureInterpolationModel]; + } + + /// Converts to dam waterpressure interpolation model. + /// The waterpressure interpolation model. + /// + public static Data.Geotechnics.WaterpressureInterpolationModel ConvertToDamWaterpressureInterpolationModel(WaterpressureInterpolationModel waterpressureInterpolationModel) + { + var translationTable = new Dictionary() + { + {WaterpressureInterpolationModel.Automatic, Data.Geotechnics.WaterpressureInterpolationModel.Automatic}, + {WaterpressureInterpolationModel.Hydrostatic, Data.Geotechnics.WaterpressureInterpolationModel.Hydrostatic} + }; + return translationTable[waterpressureInterpolationModel]; + } } } Index: DamEngine/trunk/src/Deltares.DamEngine.Interface.Tests/FillDamFromXmlInputTests.cs =================================================================== diff -u -r1990 -r2002 --- DamEngine/trunk/src/Deltares.DamEngine.Interface.Tests/FillDamFromXmlInputTests.cs (.../FillDamFromXmlInputTests.cs) (revision 1990) +++ DamEngine/trunk/src/Deltares.DamEngine.Interface.Tests/FillDamFromXmlInputTests.cs (.../FillDamFromXmlInputTests.cs) (revision 2002) @@ -57,7 +57,7 @@ DamXmlSerialization.SaveInputAsXmlFile(inputFilename, input); // Init static that is to be loaded with not expected value - DamProjectCalculationSpecification.SelectedAnalysisType = TestDataCreator.notExpectedAnalysisType; + DamProjectCalculationSpecification.SelectedAnalysisType = TestDataCreator.NotExpectedAnalysisType; // Load input file input = DamXmlSerialization.LoadInputFromXmlFile(inputFilename); @@ -76,7 +76,7 @@ xmlString = DamXmlSerialization.SaveInputAsXmlString(input); // Init static that is to be loaded with not expected value - DamProjectCalculationSpecification.SelectedAnalysisType = TestDataCreator.notExpectedAnalysisType; + DamProjectCalculationSpecification.SelectedAnalysisType = TestDataCreator.NotExpectedAnalysisType; // Load input string input = DamXmlSerialization.LoadInputFromXmlString(xmlString); @@ -97,9 +97,22 @@ private void CompareDamProjectData(DamProjectData actual, DamProjectData expected) { - Assert.AreEqual(TestDataCreator.expectedAnalysisType, DamProjectCalculationSpecification.SelectedAnalysisType); + Assert.AreEqual(TestDataCreator.ExpectedAnalysisType, DamProjectCalculationSpecification.SelectedAnalysisType); var compare = new CompareLogic { Config = { MaxDifferences = 100 } }; + compare.Config.MembersToIgnore = new List + { + "Points", + "MinGeometryPointsX", + "MinGeometryPointsZ", + "MaxGeometryPointsX", + "MaxGeometryPointsZ", + "CurveList", + "Curves", + "Surfaces", + "SurfaceLine", + "Loops", + }; // TODO i.m.o the serializing of the geometry should be improved, so these ignores are not needed anymore var result = compare.Compare(expected, actual); Assert.AreEqual(0, result.Differences.Count, "Differences found read/write Input object"); Index: DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/TestDataCreator.cs =================================================================== diff -u -r1990 -r2002 --- DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/TestDataCreator.cs (.../TestDataCreator.cs) (revision 1990) +++ DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/TestDataCreator.cs (.../TestDataCreator.cs) (revision 2002) @@ -22,9 +22,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Deltares.DamEngine.Data.Design; using Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.General.Sensors; @@ -37,8 +34,8 @@ { public class TestDataCreator { - public const AnalysisType expectedAnalysisType = AnalysisType.AdaptGeometry; - public const AnalysisType notExpectedAnalysisType = AnalysisType.NoAdaption; + public const AnalysisType ExpectedAnalysisType = AnalysisType.AdaptGeometry; + public const AnalysisType NotExpectedAnalysisType = AnalysisType.NoAdaption; public static DamProjectData CreateExampleDamProjectData() { @@ -209,7 +206,7 @@ { damProjectData.DamProjectType = DamProjectType.Design; damProjectData.DamProjectCalculationSpecification = new DamProjectCalculationSpecification(); - DamProjectCalculationSpecification.SelectedAnalysisType = expectedAnalysisType; + DamProjectCalculationSpecification.SelectedAnalysisType = ExpectedAnalysisType; var calculationSpecification = new DamFailureMechanismeCalculationSpecification(); calculationSpecification.FailureMechanismSystemType = FailureMechanismSystemType.Piping; calculationSpecification.CalculationModel = PipingModelType.Bligh; @@ -530,6 +527,30 @@ profile.PreconsolidationStresses.Add(preCon); } const int layerCount = 3; + var point1 = new Point2D(0, 0); + var point2 = new Point2D(0, 10); + var point3 = new Point2D(10, 10); + var point4 = new Point2D(1, 1); + var point5 = new Point2D(1, 9); + var point6 = new Point2D(9, 9); + profile.Geometry.Points.Add(point1); + profile.Geometry.Points.Add(point2); + profile.Geometry.Points.Add(point3); + profile.Geometry.Points.Add(point4); + profile.Geometry.Points.Add(point5); + profile.Geometry.Points.Add(point6); + var curve1 = new GeometryCurve() { HeadPoint = point1, EndPoint = point2 }; + var curve2 = new GeometryCurve() { HeadPoint = point2, EndPoint = point3 }; + var curve3 = new GeometryCurve() { HeadPoint = point3, EndPoint = point1 }; + var curve4 = new GeometryCurve() { HeadPoint = point4, EndPoint = point5 }; + var curve5 = new GeometryCurve() { HeadPoint = point5, EndPoint = point6 }; + var curve6 = new GeometryCurve() { HeadPoint = point6, EndPoint = point4 }; + profile.Geometry.Curves.Add(curve1); + profile.Geometry.Curves.Add(curve2); + profile.Geometry.Curves.Add(curve3); + profile.Geometry.Curves.Add(curve4); + profile.Geometry.Curves.Add(curve5); + profile.Geometry.Curves.Add(curve6); for (int j = 0; j < layerCount; j++) { var layer = new SoilLayer2D @@ -550,16 +571,25 @@ } layer.GeometrySurface = new GeometrySurface(); var outerLoop = new GeometryLoop(); - outerLoop.Points.Add((new GeometryPoint(0, 0))); - outerLoop.Points.Add((new GeometryPoint(0, 10))); - outerLoop.Points.Add((new GeometryPoint(10, 10))); + outerLoop.CalcPoints.Add(point1); + outerLoop.CalcPoints.Add(point2); + outerLoop.CalcPoints.Add(point3); + outerLoop.CurveList.Add(curve1); + outerLoop.CurveList.Add(curve2); + outerLoop.CurveList.Add(curve3); layer.GeometrySurface.OuterLoop = outerLoop; + profile.Geometry.Loops.Add(outerLoop); var innerloop = new GeometryLoop(); - innerloop.Points.Add((new GeometryPoint(1, 1))); - innerloop.Points.Add((new GeometryPoint(1, 9))); - innerloop.Points.Add((new GeometryPoint(9, 9))); + innerloop.CalcPoints.Add(point4); + innerloop.CalcPoints.Add(point5); + innerloop.CalcPoints.Add(point6); + innerloop.CurveList.Add(curve4); + innerloop.CurveList.Add(curve5); + innerloop.CurveList.Add(curve6); layer.GeometrySurface.InnerLoops.Add(innerloop); + profile.Geometry.Loops.Add(innerloop); profile.Surfaces.Add(layer); + profile.Geometry.Surfaces.Add(layer.GeometrySurface); } dike.SoilProfiles2D.Add(profile); } Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/Deltares.DamEngine.Calculators.csproj =================================================================== diff -u -r1998 -r2002 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/Deltares.DamEngine.Calculators.csproj (.../Deltares.DamEngine.Calculators.csproj) (revision 1998) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/Deltares.DamEngine.Calculators.csproj (.../Deltares.DamEngine.Calculators.csproj) (revision 2002) @@ -101,7 +101,7 @@ - + Index: DamEngine/trunk/src/Deltares.DamEngine.Interface/FillXmlInputFromDam.cs =================================================================== diff -u -r1974 -r2002 --- DamEngine/trunk/src/Deltares.DamEngine.Interface/FillXmlInputFromDam.cs (.../FillXmlInputFromDam.cs) (revision 1974) +++ DamEngine/trunk/src/Deltares.DamEngine.Interface/FillXmlInputFromDam.cs (.../FillXmlInputFromDam.cs) (revision 2002) @@ -730,26 +730,26 @@ }; var loop = layer.GeometrySurface.OuterLoop; - inputLayer.Surface.OuterLoop = new SoilProfile2DLayer2DSurfaceOuterPoint[loop.Points.Count]; - for (int j = 0; j < loop.Points.Count; j++) + inputLayer.Surface.OuterLoop = new SoilProfile2DLayer2DSurfaceOuterPoint[loop.CalcPoints.Count]; + for (int j = 0; j < loop.CalcPoints.Count; j++) { var point = new SoilProfile2DLayer2DSurfaceOuterPoint { - X = loop.Points[j].X, - Z = loop.Points[j].Z + X = loop.CalcPoints[j].X, + Z = loop.CalcPoints[j].Z }; inputLayer.Surface.OuterLoop[j] = point; } var innerloop = layer.GeometrySurface.InnerLoops.FirstOrDefault(); if (innerloop != null) { - inputLayer.Surface.Innerloop = new SoilProfile2DLayer2DSurfaceInnerPoint[innerloop.Points.Count]; - for (int j = 0; j < innerloop.Points.Count; j++) + inputLayer.Surface.Innerloop = new SoilProfile2DLayer2DSurfaceInnerPoint[innerloop.CalcPoints.Count]; + for (int j = 0; j < innerloop.CalcPoints.Count; j++) { var point = new SoilProfile2DLayer2DSurfaceInnerPoint { - X = innerloop.Points[j].X, - Z = innerloop.Points[j].Z + X = innerloop.CalcPoints[j].X, + Z = innerloop.CalcPoints[j].Z }; inputLayer.Surface.Innerloop[j] = point; } Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/WTISerializer.cs =================================================================== diff -u -r1998 -r2002 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/WTISerializer.cs (.../WTISerializer.cs) (revision 1998) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/WTISerializer.cs (.../WTISerializer.cs) (revision 2002) @@ -42,7 +42,7 @@ public class WtiSerializer { // Fileversion for the WTI file. Only to be increased when content of file changes. - private const int fileVersion = 1; + private const int FileVersion = 1; /// /// Serializes an stability model to an xml string obeying WTIStabilityModel.xsd /// @@ -636,7 +636,7 @@ private static void WriteVersionInfo(XmlDocument doc, XmlElement parent, string name) { XmlElement element = doc.CreateElement(name); - element.SetAttribute("FileVersion", fileVersion.ToString(CultureInfo.InvariantCulture)); + element.SetAttribute("FileVersion", FileVersion.ToString(CultureInfo.InvariantCulture)); element.SetAttribute("ProgramVersion", Assembly.GetAssembly(typeof(WtiSerializer)).ImageRuntimeVersion); parent.AppendChild(element); } @@ -671,15 +671,15 @@ element.SetAttribute("AbovePhreaticLevel", soil.AbovePhreaticLevel.ToString(CultureInfo.InvariantCulture)); element.SetAttribute("BelowPhreaticLevel", soil.BelowPhreaticLevel.ToString(CultureInfo.InvariantCulture)); - if (soil.Dilatancy == soil.FrictionAngle) + if (soil.Dilatancy.AlmostEquals(soil.FrictionAngle)) { element.SetAttribute("DilatancyType", "Phi"); } - else if (soil.Dilatancy == -soil.FrictionAngle) + else if (soil.Dilatancy.AlmostEquals(-soil.FrictionAngle)) { element.SetAttribute("DilatancyType", "MinusPhi"); } - else if (soil.Dilatancy == 0) + else if (soil.Dilatancy.AlmostEquals(0.0)) { element.SetAttribute("DilatancyType", "Zero"); } @@ -797,12 +797,14 @@ element.SetAttribute("OuterLoop", keys[surface.OuterLoop].ToString(CultureInfo.InvariantCulture)); XmlElement innerLoopsElement = doc.CreateElement("InnerLoops"); - foreach (GeometryLoop loop in surface.InnerLoops) - { - XmlElement loopElement = doc.CreateElement("InnerLoop"); - loopElement.SetAttribute("Loop", keys[loop].ToString(CultureInfo.InvariantCulture)); - innerLoopsElement.AppendChild(loopElement); - } + // Ignore innerloops, they are not needed for the calculation and are thrown away in + // MacroStability.GeometryData.SynchronizeLoops() + // foreach (GeometryLoop loop in surface.InnerLoops) + // { + // XmlElement loopElement = doc.CreateElement("InnerLoop"); + // loopElement.SetAttribute("Loop", keys[loop].ToString(CultureInfo.InvariantCulture)); + // innerLoopsElement.AppendChild(loopElement); + // } element.AppendChild(innerLoopsElement); parent.AppendChild(element); Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/MacroStabilityIoTests.cs =================================================================== diff -u -r1999 -r2002 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/MacroStabilityIoTests.cs (.../MacroStabilityIoTests.cs) (revision 1999) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/MacroStabilityIoTests.cs (.../MacroStabilityIoTests.cs) (revision 2002) @@ -25,6 +25,7 @@ using Deltares.DamEngine.Data.General; using Deltares.DamEngine.TestHelpers; using Deltares.DamEngine.Calculators.KernelWrappers.MacroStabilityCommon.MacroStabilityIo; +using Deltares.DamEngine.Data.Geotechnics; using KellermanSoftware.CompareNetObjects; namespace Deltares.DamEngine.Calculators.Tests.KernelWrappers.MacroStabilityCommon @@ -59,18 +60,40 @@ { // Given DamEngine data (DamProjectData) DamProjectData expectedDamProjectData = CreateExampleDamProjectData(); - KernelModel expectedKernelModel = FillWtiFromDamEngine.CreateKernelModelFromDamProjectData(expectedDamProjectData); + Location expectedLocation = expectedDamProjectData.Dike.Locations[0]; + SoilProfile2D expectedSoilProfile2D = expectedLocation.Segment.SoilProfileProbabilities[0].SoilProfile2D; + SurfaceLine2 expectedSurfaceLine2D = expectedLocation.SurfaceLine; + FailureMechanismParametersMStab expectedParametersMStab = expectedDamProjectData.DamProjectCalculationSpecification.CurrentSpecification.FailureMechanismParametersMStab; + FillWtiKernelData fillWtiKernelData = new FillWtiKernelData() + { + FailureMechanismParametersMStab = expectedParametersMStab, + Location = expectedLocation, + SoilProfile2D = expectedSoilProfile2D, + SurfaceLine2 = expectedSurfaceLine2D + }; + KernelModel expectedKernelModel = fillWtiKernelData.CreateKernelModel(); + // When Serializing and Deserializing string xmlWti = WtiSerializer.Serialize(expectedKernelModel); const string fileName = "TestInput.wti"; string fullFileName = Path.Combine(WtiFilesMap, fileName); File.WriteAllText(fullFileName, xmlWti); KernelModel actualKernelModel = WtiDeserializer.Deserialize(xmlWti); - DamProjectData actualDamProjectData = FillDamEngineFromWti.CreateDamProjectDataFromKernelModel(actualKernelModel); + var fillDamEngineFromWti = new FillDamEngineFromWti(); + fillDamEngineFromWti.FillDamProjectDataFromKernelModel(actualKernelModel); // Then the data models are equal - CompareDamProjectData(actualDamProjectData, expectedDamProjectData); + var compare = new CompareLogic { Config = { MaxDifferences = 100 } }; + var result = compare.Compare(expectedLocation, fillDamEngineFromWti.Location); + Assert.AreEqual(0, result.Differences.Count, "Differences found read/write kernel Location"); + result = compare.Compare(expectedSoilProfile2D, fillDamEngineFromWti.SoilProfile2D); + Assert.AreEqual(0, result.Differences.Count, "Differences found read/write kernel SoilProfile2D"); + result = compare.Compare(expectedSurfaceLine2D, fillDamEngineFromWti.SurfaceLine2); + Assert.AreEqual(0, result.Differences.Count, "Differences found read/write kernel SurfaceLine2"); + result = compare.Compare(expectedParametersMStab, fillDamEngineFromWti.FailureMechanismParametersMStab); + Assert.AreEqual(0, result.Differences.Count, "Differences found read/write kernel FailureMechanismParametersMStab"); + } private DamProjectData CreateExampleDamProjectData() @@ -114,14 +137,5 @@ // Then the strings are equal Assert.AreEqual(xmlInput, xmlOutput); } - - private static void CompareDamProjectData(DamProjectData actual, DamProjectData expected) - { - - var compare = new CompareLogic { Config = { MaxDifferences = 100 } }; - var result = compare.Compare(expected, actual); - Assert.AreEqual(0, result.Differences.Count, "Differences found read/write Input object"); - - } } } Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/FillDamEngineFromWti.cs =================================================================== diff -u -r1987 -r2002 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/FillDamEngineFromWti.cs (.../FillDamEngineFromWti.cs) (revision 1987) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/FillDamEngineFromWti.cs (.../FillDamEngineFromWti.cs) (revision 2002) @@ -20,18 +20,65 @@ // All rights reserved. using Deltares.DamEngine.Data.General; +using Deltares.DamEngine.Data.Geotechnics; using Deltares.MacroStability.Kernel; namespace Deltares.DamEngine.Calculators.KernelWrappers.MacroStabilityCommon.MacroStabilityIo { public class FillDamEngineFromWti { + public Location Location { get; set; } + public SoilProfile2D SoilProfile2D { get; set; } + public SurfaceLine2 SurfaceLine2 { get; set; } + public FailureMechanismParametersMStab FailureMechanismParametersMStab { get; set; } /// Creates the dam project data from the kernel model. /// The kernel model. /// The DamProjectData object filled with Wti data - public static DamProjectData CreateDamProjectDataFromKernelModel(KernelModel kernelModel) + public void FillDamProjectDataFromKernelModel(KernelModel kernelModel) { - return new DamProjectData(); + Location = new Location(); + SoilProfile2D = new SoilProfile2D(); + SurfaceLine2 = new SurfaceLine2(); + TransferLocation(kernelModel, Location); + TransferSoilProfile2D(kernelModel, SoilProfile2D); + TransferSurfaceLine2(kernelModel, SurfaceLine2); + TransferParametersMStab(kernelModel, FailureMechanismParametersMStab); } + + /// Transfers the parameters m stab. + /// The kernel model. + /// The MStab parameters. + /// + private void TransferParametersMStab(KernelModel kernelModel, FailureMechanismParametersMStab failureMechanismParametersMStab) + { + throw new System.NotImplementedException(); + } + + /// Transfers the surface line2. + /// The kernel model. + /// The SurfaceLine2. + /// + private void TransferSurfaceLine2(KernelModel kernelModel, SurfaceLine2 surfaceLine2) + { + throw new System.NotImplementedException(); + } + + /// Transfers the soil profile2 d. + /// The kernel model. + /// The SoilProfile2D. + /// + private void TransferSoilProfile2D(KernelModel kernelModel, SoilProfile2D soilProfile2D) + { + throw new System.NotImplementedException(); + } + + /// Transfers the location. + /// The kernel model. + /// The location. + /// + private void TransferLocation(KernelModel kernelModel, Location location) + { + throw new System.NotImplementedException(); + } } } Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/FillWtiFromDamEngine.cs =================================================================== diff -u -r1997 -r2002 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/FillWtiFromDamEngine.cs (.../FillWtiFromDamEngine.cs) (revision 1997) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/FillWtiFromDamEngine.cs (.../FillWtiKernelData.cs) (revision 2002) @@ -19,134 +19,238 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using System; using System.Collections.Generic; using Deltares.DamEngine.Data.General; using Deltares.MacroStability.Data; using Deltares.MacroStability.Geometry; using Deltares.MacroStability.Kernel; using Deltares.MacroStability.Preprocessing; -using Deltares.MacroStability.WaternetCreator; +using GeometryPoint = Deltares.DamEngine.Data.Geometry.GeometryPoint; using Location = Deltares.MacroStability.WaternetCreator.Location; +using SoilLayer2D = Deltares.DamEngine.Data.Geotechnics.SoilLayer2D; namespace Deltares.DamEngine.Calculators.KernelWrappers.MacroStabilityCommon.MacroStabilityIo { - public class FillWtiFromDamEngine + public class FillWtiKernelData { + public Data.General.Location Location { get; set; } + public Data.Geotechnics.SoilProfile2D SoilProfile2D { get; set; } + public Data.Geotechnics.SurfaceLine2 SurfaceLine2 { get; set; } + public FailureMechanismParametersMStab FailureMechanismParametersMStab { get; set; } + private Dictionary dictSoils = new Dictionary(); + private Dictionary dictPoints = new Dictionary(); + private Dictionary dictCurves = new Dictionary(); + private Dictionary dictLoops = new Dictionary(); + private Dictionary dictSurfaces = new Dictionary(); + /// Creates the kernel model from dam project data. /// The DamProjectData object filled with Wti data /// The KernelModel filled with the Dam Project Data - public static KernelModel CreateKernelModelFromDamProjectData(DamProjectData damProjectData) + public KernelModel CreateKernelModel() { KernelModel kernelModel = new KernelModel(); kernelModel.StabilityModel = new StabilityModel(); kernelModel.PreprocessingModel = new PreprocessingModel(); - TransferWtiStabilityModel(damProjectData, kernelModel.StabilityModel); - TransferVersionInfo(); - TransferSoilModel(damProjectData, kernelModel.StabilityModel.SoilModel.Soils); + TransferWtiStabilityModel(FailureMechanismParametersMStab, kernelModel.StabilityModel); + TransferVersionInfo(); // TODO + TransferSoils(SoilProfile2D, kernelModel.StabilityModel.SoilModel.Soils); kernelModel.StabilityModel.SoilProfile = new SoilProfile2D(); - TransferSoilProfile(damProjectData, kernelModel.StabilityModel.SoilProfile); - TransferSurfaceLine(); - TransferLocation(damProjectData, kernelModel.PreprocessingModel.LastStage.Locations); - TransferPreconsolidationStresses(); - TransferUniformLoads(); - TransferConsolidationValues(); - TransferMultiplicationFactorsCPhiForUplift(); - TransferWaternets(); - TransferSpencerSlipPlanes(); - TransferUpliftVanCalculationGrid(); - TransferSlipPlaneConstraints(); - TransferLevenbergMarquardtOptions(); + TransferSoilProfile(SoilProfile2D, kernelModel.StabilityModel.SoilProfile); // TODO + TransferSurfaceLine(); // TODO + TransferLocation(Location, kernelModel.PreprocessingModel.LastStage.Locations); // TODO + TransferPreconsolidationStresses(); // TODO + TransferUniformLoads(); // TODO + TransferConsolidationValues(); // TODO + TransferMultiplicationFactorsCPhiForUplift(); // TODO + TransferWaternets(); // TODO + TransferSpencerSlipPlanes(); // TODO + TransferUpliftVanCalculationGrid(); // TODO + TransferSlipPlaneConstraints(); // TODO + TransferLevenbergMarquardtOptions(); // TODO return kernelModel; } - private static void TransferSoilProfile(DamProjectData damProjectData, SoilProfile2D soilProfile2D) + private void TransferSoilProfile(DamEngine.Data.Geotechnics.SoilProfile2D damSoilProfile2D, SoilProfile2D soilProfile2D) { - soilProfile2D.Geometry = new GeometryData(); - soilProfile2D.Geometry.Points.Add(new Point2D()); - soilProfile2D.Geometry.Curves.Add(new GeometryCurve()); + // 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); + } + soilProfile2D.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); + } + soilProfile2D.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); + } + soilProfile2D.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); + } + soilProfile2D.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); + } } - private static void TransferWtiStabilityModel(DamProjectData damProjectData, StabilityModel stabilityModel) + private void TransferWtiStabilityModel(FailureMechanismParametersMStab failureMechanismParametersMStab, StabilityModel stabilityModel) { stabilityModel.MoveGrid = true; // is not in DamEngine datamodel stabilityModel.MaximumSliceWidth = 1.0; // is not in DamEngine datamodel stabilityModel.SearchAlgorithm = ConversionHelper.ConvertToMacroStabilitySearchMethod( - damProjectData.DamProjectCalculationSpecification.CurrentSpecification.FailureMechanismParametersMStab.MStabParameters.SearchMethod); + failureMechanismParametersMStab.MStabParameters.SearchMethod); stabilityModel.ModelOption = ConversionHelper.ConvertToModelOptions( - damProjectData.DamProjectCalculationSpecification.CurrentSpecification.FailureMechanismParametersMStab.MStabParameters.Model); + failureMechanismParametersMStab.MStabParameters.Model); stabilityModel.GridOrientation = ConversionHelper.ConvertToGridOrientation( - damProjectData.DamProjectCalculationSpecification.CurrentSpecification.FailureMechanismParametersMStab.MStabParameters.GridPosition); + failureMechanismParametersMStab.MStabParameters.GridPosition); } - private static void TransferVersionInfo() + private void TransferVersionInfo() { } - private static void TransferSoilModel(DamProjectData damProjectData, IList soils) + private void TransferSoils(Data.Geotechnics.SoilProfile2D damSoilProfile2D, IList soils) { - foreach (Data.Geotechnics.Soil soil in damProjectData.Dike.SoilList.Soils) + // Harvest all soils from damSoilProfile2D + foreach (SoilLayer2D surface in damSoilProfile2D.Surfaces) { - Soil macroStabilitySoil = ConversionHelper.ConvertToMacroStabilitySoil(soil); - soils.Add(macroStabilitySoil); + var soil = surface.Soil; + if (!dictSoils.ContainsKey(soil)) + { + Soil macroStabilitySoil = ConversionHelper.ConvertToMacroStabilitySoil(soil); + dictSoils.Add(soil, macroStabilitySoil); + } } + + // Add soils to the kernel soillist + foreach (KeyValuePair entry in dictSoils) + { + soils.Add(entry.Value); + } } - - - private static void TransferSurfaceLine() + private void TransferSurfaceLine() { } - private static void TransferLocation(DamProjectData damProjectData, IList locations) + private void TransferLocation(Data.General.Location location, IList locations) { locations.Add(new Location()); } - private static void TransferPreconsolidationStresses() + private void TransferPreconsolidationStresses() { } - private static void TransferUniformLoads() + private void TransferUniformLoads() { } - private static void TransferConsolidationValues() + private void TransferConsolidationValues() { } - private static void TransferMultiplicationFactorsCPhiForUplift() + private void TransferMultiplicationFactorsCPhiForUplift() { } - private static void TransferWaternets() + private void TransferWaternets() { } - private static void TransferSpencerSlipPlanes() + private void TransferSpencerSlipPlanes() { } - private static void TransferUpliftVanCalculationGrid() + private void TransferUpliftVanCalculationGrid() { } - private static void TransferSlipPlaneConstraints() + private void TransferSlipPlaneConstraints() { } - private static void TransferLevenbergMarquardtOptions() + private void TransferLevenbergMarquardtOptions() { } Fisheye: Tag 2002 refers to a dead (removed) revision in file `DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/FillWtiFromDamEngine.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityInwards/MacroStabilityInput.cs =================================================================== diff -u -r1983 -r2002 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityInwards/MacroStabilityInput.cs (.../MacroStabilityInput.cs) (revision 1983) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityInwards/MacroStabilityInput.cs (.../MacroStabilityInput.cs) (revision 2002) @@ -20,12 +20,20 @@ // All rights reserved. using Deltares.DamEngine.Calculators.KernelWrappers.Interfaces; +using Deltares.DamEngine.Data.General; namespace Deltares.DamEngine.Calculators.KernelWrappers.MacroStabilityInwards { public class MacroStabilityInput : IKernelDataInput { //ToDo MWDAM-1356: Not clear yet what input must be provided //probably something like FailureMechanismParametersMStab + /// + /// Gets or sets the failure mechanisme paramaters m stab. + /// + /// + /// The failure mechanisme paramaters m stab. + /// + public FailureMechanismParametersMStab FailureMechanismParametersMStab { get; set; } } } Index: DamEngine/trunk/src/Deltares.DamEngine.Interface/FillDamFromXmlInput.cs =================================================================== diff -u -r1974 -r2002 --- DamEngine/trunk/src/Deltares.DamEngine.Interface/FillDamFromXmlInput.cs (.../FillDamFromXmlInput.cs) (revision 1974) +++ DamEngine/trunk/src/Deltares.DamEngine.Interface/FillDamFromXmlInput.cs (.../FillDamFromXmlInput.cs) (revision 2002) @@ -746,17 +746,17 @@ var loop = inputLayer.Surface.OuterLoop; for (int j = 0; j < loop.Length; j++) { - var point = new GeometryPoint(loop[j].X, loop[j].Z); - layer.GeometrySurface.OuterLoop.Points.Add(point); + var point = new Point2D(loop[j].X, loop[j].Z); + layer.GeometrySurface.OuterLoop.CalcPoints.Add(point); } var innerloop = inputLayer.Surface.Innerloop; if (innerloop != null) { var newloop = new GeometryLoop(); for (int j = 0; j < innerloop.Length; j++) { - var point = new GeometryPoint(innerloop[j].X, innerloop[j].Z); - newloop.Points.Add(point); + var point = new Point2D(innerloop[j].X, innerloop[j].Z); + newloop.CalcPoints.Add(point); } layer.GeometrySurface.InnerLoops.Add(newloop); }