Index: dam engine/trunk/src/Deltares.DamEngine.Interface.Tests/FillDamFromXmlInputTests.cs =================================================================== diff -u -r545 -r555 --- dam engine/trunk/src/Deltares.DamEngine.Interface.Tests/FillDamFromXmlInputTests.cs (.../FillDamFromXmlInputTests.cs) (revision 545) +++ dam engine/trunk/src/Deltares.DamEngine.Interface.Tests/FillDamFromXmlInputTests.cs (.../FillDamFromXmlInputTests.cs) (revision 555) @@ -31,6 +31,7 @@ using NUnit.Framework; using Soil = Deltares.DamEngine.Data.Geotechnics.Soil; using SoilProfile1D = Deltares.DamEngine.Data.Geotechnics.SoilProfile1D; +using SoilProfile2D = Deltares.DamEngine.Data.Geotechnics.SoilProfile2D; namespace Deltares.DamEngine.Interface.Tests { @@ -81,6 +82,7 @@ FillSoils(dike); FillLocations(dike); FillSoilProfiles1D(dike); + FillSoilProfiles2D(dike); return damProjectData; } @@ -189,20 +191,7 @@ { var profile = new SoilProfile1D(); profile.Name = "Profile1D " + (i + 1).ToString(); - profile.BottomLevel = -21.12 * i; - //profile.PreconsolidationStresses = new List(); -// const int preConCount = 2; -// for (int j = 0; j < preConCount; j++) -// { -// var preCon = new PreConsolidationStress -// { -// Name = "Precon " + (j + 1).ToString(), -// StressValue = 3.33 * i * j, -// X = 12.3 * i * j, -// Z = 0.3 * -i * j -// }; -// profile. -// } + profile.BottomLevel = -21.12 * (i + 1); const int layerCount = 3; for (int j = 0; j < layerCount; j++) { @@ -224,6 +213,7 @@ } profile.Layers.Add(layer); } + dike.SoilProfiles.Add(profile); } } private static DesignScenario FillDesignScenario(int factor) @@ -250,6 +240,65 @@ return designScenario; } + private static void FillSoilProfiles2D(Dike dike) + { + dike.SoilProfiles2D = new List(); + const int profilesCount = 2; + for (int i = 0; i < profilesCount; i++) + { + var profile = new SoilProfile2D + { + Name = "Profile2D " + (i + 1).ToString() + }; + + const int preConCount = 2; + for (int j = 0; j < preConCount; j++) + { + var preCon = new PreConsolidationStress + { + Name = "Precon " + (j + 1).ToString(), + StressValue = 3.33 * (i + 1) * (j + 1), + X = 12.3 * (i + 1) * (j + 1), + Z = 0.3 * (-i - 1) * (j + 1) + }; + profile.PreconsolidationStresses.Add(preCon); + } + const int layerCount = 3; + for (int j = 0; j < layerCount; j++) + { + var layer = new SoilLayer2D + { + Name = "Layer" + (j + 1).ToString(), + Soil = dike.SoilList.Soils[j] + + }; + if (j < 2) + { + layer.WaterpressureInterpolationModel = WaterpressureInterpolationModel.Automatic; + layer.IsAquifer = false; + } + else + { + layer.WaterpressureInterpolationModel = WaterpressureInterpolationModel.Hydrostatic; + layer.IsAquifer = true; + } + 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))); + layer.GeometrySurface.OuterLoop = 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))); + layer.GeometrySurface.InnerLoops.Add(innerloop); + profile.Surfaces.Add(layer); + } + dike.SoilProfiles2D.Add(profile); + } + } + private void CompareDamProjectData(DamProjectData actual, DamProjectData expected) { var compare = new CompareLogic { Config = { MaxDifferences = 100 } }; Index: dam engine/trunk/src/Deltares.DamEngine.Interface/FillXmlInputFromDam.cs =================================================================== diff -u -r551 -r555 --- dam engine/trunk/src/Deltares.DamEngine.Interface/FillXmlInputFromDam.cs (.../FillXmlInputFromDam.cs) (revision 551) +++ dam engine/trunk/src/Deltares.DamEngine.Interface/FillXmlInputFromDam.cs (.../FillXmlInputFromDam.cs) (revision 555) @@ -21,13 +21,15 @@ using System; using System.Collections.Generic; +using System.Linq; using Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.Geotechnics; using Deltares.DamEngine.Io.XmlInput; using Input = Deltares.DamEngine.Io.XmlInput.Input; using Location = Deltares.DamEngine.Data.General.Location; using Soil = Deltares.DamEngine.Io.XmlInput.Soil; using SoilProfile1D = Deltares.DamEngine.Data.Geotechnics.SoilProfile1D; +using SoilProfile2D = Deltares.DamEngine.Data.Geotechnics.SoilProfile2D; namespace Deltares.DamEngine.Interface { @@ -50,8 +52,18 @@ TransferSurfaceLines(dike.SurfaceLines2, input.SurfaceLines); input.Soils = new Soil[dike.SoilList.Soils.Count]; TransferSoils(dike.SoilList.Soils, input.Soils); - input.SoilProfiles1D = new Io.XmlInput.SoilProfile1D[dike.SoilProfiles.Count]; - TransferSoilProfiles1D(dike.SoilProfiles, input.SoilProfiles1D); + if (dike.SoilProfiles != null) + { + var profilesCount = dike.SoilProfiles.Count; + input.SoilProfiles1D = new Io.XmlInput.SoilProfile1D[profilesCount]; + TransferSoilProfiles1D(dike.SoilProfiles, input.SoilProfiles1D); + } + if (dike.SoilProfiles2D != null) + { + var profilesCount = dike.SoilProfiles2D.Count; + input.SoilProfiles2D = new Io.XmlInput.SoilProfile2D[profilesCount]; + TransferSoilProfiles2D(dike.SoilProfiles2D, input.SoilProfiles2D); + } return input; } @@ -229,7 +241,8 @@ Layers = new SoilProfile1DLayer[soilProfile1D.LayerCount] }; AddLayers(soilProfile1D, inputSoilProfile1D); - } + inputSoilProfiles1D[i] = inputSoilProfile1D; + } } private static void AddLayers(SoilProfile1D soilProfile1D, Io.XmlInput.SoilProfile1D inputSoilProfile1D) @@ -246,7 +259,93 @@ WaterpressureInterpolationModel = ConversionHelper.ConvertToInputWaterpressureInterpolationModel( layer.WaterpressureInterpolationModel) }; + inputSoilProfile1D.Layers[i] = inputLayer; } } + + private static void TransferSoilProfiles2D(IList dikeSoilProfiles2D, + Io.XmlInput.SoilProfile2D[] inputSoilProfiles2D) + { + var profilesCount = dikeSoilProfiles2D.Count; + for (int i = 0; i < profilesCount; i++) + { + var soilProfile2D = dikeSoilProfiles2D[i]; + var inputSoilProfile2D = new Io.XmlInput.SoilProfile2D + { + Name = soilProfile2D.Name, + Layers = new SoilProfile2DLayer[soilProfile2D.Surfaces.Count] + }; + AddPreconsolidationStresses(soilProfile2D, inputSoilProfile2D); + AddLayers2D(soilProfile2D, inputSoilProfile2D); + inputSoilProfiles2D[i] = inputSoilProfile2D; + } + } + + private static void AddPreconsolidationStresses(SoilProfile2D soilProfile2D, Io.XmlInput.SoilProfile2D inputSoilProfile2D ) + { + if (soilProfile2D.PreconsolidationStresses != null) + { + var preconCount = soilProfile2D.PreconsolidationStresses.Count; + inputSoilProfile2D.PreconsolidationStresses = new SoilProfile2DPreconsolidationStress[preconCount]; + for (int i = 0; i < preconCount; i++) + { + var precon = soilProfile2D.PreconsolidationStresses[i]; + var inputPrecon = new SoilProfile2DPreconsolidationStress + { + Name = precon.Name, + StressValue = precon.StressValue, + X = precon.X, + Z = precon.Z + }; + inputSoilProfile2D.PreconsolidationStresses[i] = inputPrecon; + } + } + } + + private static void AddLayers2D(SoilProfile2D soilProfile2D, Io.XmlInput.SoilProfile2D inputSoilProfile2D) + { + if (soilProfile2D != null) + { + for (int i = 0; i < soilProfile2D.Surfaces.Count; i++) + { + var layer = soilProfile2D.Surfaces[i]; + var inputLayer = new SoilProfile2DLayer + { + SoilName = layer.Soil.Name, + IsAquifer = layer.IsAquifer, + WaterpressureInterpolationModel = ConversionHelper.ConvertToInputWaterpressureInterpolationModel( + layer.WaterpressureInterpolationModel), + Surface = new SoilProfile2DLayerSurface() + }; + + var loop = layer.GeometrySurface.OuterLoop; + inputLayer.Surface.OuterLoop = new SoilProfile2DLayerSurfaceOuterPoint[loop.Points.Count]; + for (int j = 0; j < loop.Points.Count; j++) + { + var point = new SoilProfile2DLayerSurfaceOuterPoint + { + X = loop.Points[j].X, + Z = loop.Points[j].Z + }; + inputLayer.Surface.OuterLoop[j] = point; + } + var innerloop = layer.GeometrySurface.InnerLoops.FirstOrDefault(); + if (innerloop != null) + { + inputLayer.Surface.Innerloop = new SoilProfile2DLayerSurfaceInnerPoint[innerloop.Points.Count]; + for (int j = 0; j < innerloop.Points.Count; j++) + { + var point = new SoilProfile2DLayerSurfaceInnerPoint + { + X = innerloop.Points[j].X, + Z = innerloop.Points[j].Z + }; + inputLayer.Surface.Innerloop[j] = point; + } + } + inputSoilProfile2D.Layers[i] = inputLayer; + } + } + } } } Index: dam engine/trunk/src/Deltares.DamEngine.Interface/FillDamFromXmlInput.cs =================================================================== diff -u -r551 -r555 --- dam engine/trunk/src/Deltares.DamEngine.Interface/FillDamFromXmlInput.cs (.../FillDamFromXmlInput.cs) (revision 551) +++ dam engine/trunk/src/Deltares.DamEngine.Interface/FillDamFromXmlInput.cs (.../FillDamFromXmlInput.cs) (revision 555) @@ -60,6 +60,7 @@ TransferSoils(input.Soils, dike.SoilList.Soils); TransferLocations(input.Locations, dike.Locations, dike.SurfaceLines2); TransferSoilProfiles1D(input.SoilProfiles1D, dike.SoilProfiles, dike.SoilList); + TransferSoilProfiles2D(input.SoilProfiles2D, dike.SoilProfiles2D, dike.SoilList); //TransferSegments(input.Segments, damProjectData.Segments); To be implemented at other side. PostProcess(input, damProjectData); @@ -107,11 +108,13 @@ { if (segmentSoilProfileProbability.SoilGeometryType == SoilGeometryType.SoilGeometry1D) { - segmentSoilProfileProbability.SoilProfile = FindSoilProfile1DByName(project.Dike.SoilProfiles, segmentSoilProfileProbability.SoilGeometry1DName); + segmentSoilProfileProbability.SoilProfile = FindSoilProfile1DByName(project.Dike.SoilProfiles, + segmentSoilProfileProbability.SoilGeometry1DName); } else { - segmentSoilProfileProbability.SoilProfile2D = FindSoilProfile2DByName(segmentSoilProfileProbability.SoilGeometry2DName); + segmentSoilProfileProbability.SoilProfile2D = FindSoilProfile2DByName(project.Dike.SoilProfiles2D, + segmentSoilProfileProbability.SoilGeometry2DName); } } } @@ -237,40 +240,103 @@ var inputSoilProfile1D = inputSoilProfiles1D[i]; soilProfile1D.Name = inputSoilProfile1D.Name; soilProfile1D.BottomLevel = inputSoilProfile1D.BottomLevel; - // AddPreconsolidationStresses(inputSoilProfile1D, soilProfile1D); for 2D only AddLayers(inputSoilProfile1D, soilProfile1D, soils); + dikeSoilProfiles.Add(soilProfile1D); + } + } + } + + private static void AddLayers(Io.XmlInput.SoilProfile1D inputSoilProfile1D, SoilProfile1D soilProfile1D, SoilList soils) + { + if (inputSoilProfile1D != null) + { + for (int i = 0; i < inputSoilProfile1D.Layers.Length; i++) + { + var layer = new SoilLayer1D(); + var inputLayer = inputSoilProfile1D.Layers[i]; + layer.Name = inputLayer.Name; + layer.Soil = soils.GetSoilByName(inputLayer.SoilName); + layer.TopLevel = inputLayer.TopLevel; + layer.IsAquifer = inputLayer.IsAquifer; + layer.WaterpressureInterpolationModel = ConversionHelper.ConvertToWaterpressureInterpolationModel( + inputLayer.WaterpressureInterpolationModel); + soilProfile1D.Layers.Add(layer); } } } -// private static void AddPreconsolidationStresses(Io.XmlInput.SoilProfile1D inputSoilProfile1D , SoilProfile1D soilProfile1D) -// { -// for (int i = 0; i < inputSoilProfile1D.PreconsolidationStresses.Length; i++) -// { -// var precon = new PreConsolidationStress(); -// var inputPrecon = inputSoilProfile1D.PreconsolidationStresses[i]; -// precon.Name = inputPrecon.Name; -// precon.StressValue = inputPrecon.StressValue; -// precon.X = inputPrecon.X; -// precon.Z = inputPrecon.Z; -// } -// } To be used for 2D + private static void TransferSoilProfiles2D(Io.XmlInput.SoilProfile2D[] inputSoilProfiles2D, + IList dikeSoilProfiles, SoilList soils) + { + if (inputSoilProfiles2D != null) + { + for (int i = 0; i < inputSoilProfiles2D.Length; i++) + { + var soilProfile2D = new SoilProfile2D(); + var inputSoilProfile2D = inputSoilProfiles2D[i]; + soilProfile2D.Name = inputSoilProfile2D.Name; + AddPreconsolidationStresses(inputSoilProfile2D, soilProfile2D); + AddLayers2D(inputSoilProfile2D, soilProfile2D, soils); + dikeSoilProfiles.Add(soilProfile2D); + } + } + } - private static void AddLayers(Io.XmlInput.SoilProfile1D inputSoilProfile1D, SoilProfile1D soilProfile1D, SoilList soils) + private static void AddPreconsolidationStresses(Io.XmlInput.SoilProfile2D inputSoilProfile2D, SoilProfile2D soilProfile2D) { - for (int i = 0; i < inputSoilProfile1D.Layers.Length; i++) + if (inputSoilProfile2D.PreconsolidationStresses != null) { - var layer = new SoilLayer1D(); - var inputLayer = inputSoilProfile1D.Layers[i]; - layer.Name = inputLayer.Name; - layer.Soil = soils.GetSoilByName(inputLayer.SoilName); - layer.TopLevel = inputLayer.TopLevel; - layer.IsAquifer = inputLayer.IsAquifer; - layer.WaterpressureInterpolationModel = ConversionHelper.ConvertToWaterpressureInterpolationModel( - inputLayer.WaterpressureInterpolationModel); + for (int i = 0; i < inputSoilProfile2D.PreconsolidationStresses.Length; i++) + { + var precon = new PreConsolidationStress(); + var inputPrecon = inputSoilProfile2D.PreconsolidationStresses[i]; + precon.Name = inputPrecon.Name; + precon.StressValue = inputPrecon.StressValue; + precon.X = inputPrecon.X; + precon.Z = inputPrecon.Z; + soilProfile2D.PreconsolidationStresses.Add(precon); + } } } + private static void AddLayers2D(Io.XmlInput.SoilProfile2D inputSoilProfile2D, SoilProfile2D soilProfile2D, SoilList soils) + { + if (inputSoilProfile2D != null) + { + for (int i = 0; i < inputSoilProfile2D.Layers.Length; i++) + { + var layer = new SoilLayer2D + { + GeometrySurface = new GeometrySurface() + }; + var inputLayer = inputSoilProfile2D.Layers[i]; + layer.Name = inputLayer.SoilName; + layer.Soil = soils.GetSoilByName(inputLayer.SoilName); + layer.IsAquifer = inputLayer.IsAquifer; + layer.WaterpressureInterpolationModel = ConversionHelper.ConvertToWaterpressureInterpolationModel( + inputLayer.WaterpressureInterpolationModel); + 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 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); + } + layer.GeometrySurface.InnerLoops.Add(newloop); + } + soilProfile2D.Surfaces.Add(layer); + } + } + } + private static void TransferSegments(Io.XmlInput.Segment[] inputSegments, IList segments ) { for (int i = 0; i < inputSegments.Length; i++) @@ -315,10 +381,14 @@ return null; } - private static SoilProfile2D FindSoilProfile2DByName(string name) + private static SoilProfile2D FindSoilProfile2DByName(IList soilProfiles, string name) { - // Todo Implement - return new SoilProfile2D(); + foreach (var soilProfile2D in soilProfiles) + { + if (soilProfile2D.Name == name) + return soilProfile2D; + } + return null; } }