Index: dam engine/trunk/src/Deltares.DamEngine.Interface/FillDamFromXmlInput.cs
===================================================================
diff -u -r507 -r540
--- dam engine/trunk/src/Deltares.DamEngine.Interface/FillDamFromXmlInput.cs (.../FillDamFromXmlInput.cs) (revision 507)
+++ dam engine/trunk/src/Deltares.DamEngine.Interface/FillDamFromXmlInput.cs (.../FillDamFromXmlInput.cs) (revision 540)
@@ -27,7 +27,10 @@
using Deltares.DamEngine.Data.Geotechnics;
using Deltares.DamEngine.Io.XmlInput;
using Location = Deltares.DamEngine.Data.General.Location;
+using Segment = Deltares.DamEngine.Data.General.Segment;
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
{
@@ -54,7 +57,9 @@
dike.SoilList = new SoilList();
TransferSoils(input.Soils, dike.SoilList.Soils);
TransferLocations(input.Locations, dike.Locations, dike.SurfaceLines2);
- PostProcess(input, dike);
+ TransferSoilProfiles1D(input.SoilProfiles1D, dike.SoilProfiles, dike.SoilList);
+ //TransferSegments(input.Segments, damProjectData.Segments);
+ PostProcess(input, damProjectData);
return damProjectData;
}
@@ -63,10 +68,24 @@
/// Postprocess: connect all objects
///
/// The input.
- /// The dike.
- private static void PostProcess(Input input, Dike dike)
+ /// The project.
+ private static void PostProcess(Input input, DamProjectData project)
{
- // No code needed yet
+ // find proper profiles for segments
+ foreach (var segment in project.Segments)
+ {
+ foreach (var segmentSoilProfileProbability in segment.SoilProfileProbabilities)
+ {
+ if (segmentSoilProfileProbability.SoilGeometryType == SoilGeometryType.SoilGeometry1D)
+ {
+ segmentSoilProfileProbability.SoilProfile = FindSoilProfile1DByName(project.Dike.SoilProfiles, segmentSoilProfileProbability.SoilGeometry1DName);
+ }
+ else
+ {
+ segmentSoilProfileProbability.SoilProfile2D = FindSoilProfile2DByName(segmentSoilProfileProbability.SoilGeometry2DName);
+ }
+ }
+ }
}
private static void TransferSoils(Soil[] inputSoils, List soils)
@@ -146,5 +165,98 @@
dikeLocations.Add(location);
}
}
+
+ private static void TransferSoilProfiles1D(Io.XmlInput.SoilProfile1D[] inputSoilProfiles1D,
+ IList dikeSoilProfiles, SoilList soils)
+ {
+ for (int i = 0; i < inputSoilProfiles1D.Length; i++)
+ {
+ var soilProfile1D = new SoilProfile1D();
+ var inputSoilProfile1D = inputSoilProfiles1D[i];
+ soilProfile1D.Name = inputSoilProfile1D.Name;
+ soilProfile1D.BottomLevel = inputSoilProfile1D.BottomLevel;
+ // AddPreconsolidationStresses(inputSoilProfile1D, soilProfile1D); for 2D only
+ AddLayers(inputSoilProfile1D, soilProfile1D, soils);
+ }
+ }
+
+// 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 AddLayers(Io.XmlInput.SoilProfile1D inputSoilProfile1D, SoilProfile1D soilProfile1D, SoilList soils)
+ {
+ 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);
+ }
+ }
+
+ private static void TransferSegments(Io.XmlInput.Segment[] inputSegments, IList segments )
+ {
+ for (int i = 0; i < inputSegments.Length; i++)
+ {
+ var segment = new Segment();
+ var inputSegment = inputSegments[i];
+ segment.Name = inputSegment.Name;
+ AddSoilProfileProbabilities(inputSegment, segment);
+ segments.Add(segment);
+ }
+ }
+
+ private static void AddSoilProfileProbabilities(Io.XmlInput.Segment inputSegment, Segment segment)
+ {
+ for (int i = 0; i < inputSegment.SoilGeometryProbability.Length; i++)
+ {
+ var soilGeometryProbability = new SoilGeometryProbability();
+ var inputSoilGeometryProbability = inputSegment.SoilGeometryProbability[i];
+ soilGeometryProbability.Probability = inputSoilGeometryProbability.Probability;
+ if (inputSoilGeometryProbability.FailureMechanismSystemTypeSpecified)
+ {
+ //soilGeometryProbability.SegmentFailureMechanismType = inputSoilGeometryProbability.FailureMechanismSystemType;
+ }
+ if (inputSoilGeometryProbability.SoilGeometryType == SegmentSoilGeometryProbabilitySoilGeometryType.SoilGeometry1D)
+ {
+ soilGeometryProbability.SoilGeometry1DName = inputSoilGeometryProbability.SoilGeometryName;
+ }
+ else
+ {
+ soilGeometryProbability.SoilGeometry2DName = inputSoilGeometryProbability.SoilGeometryName;
+ }
+ }
+ }
+
+ private static SoilProfile1D FindSoilProfile1DByName(IList soilProfiles, string name)
+ {
+ foreach (var soilProfile1D in soilProfiles)
+ {
+ if (soilProfile1D.Name == name)
+ return soilProfile1D;
+ }
+ return null;
+ }
+
+ private static SoilProfile2D FindSoilProfile2DByName(string name)
+ {
+ // Todo Implement
+ return new SoilProfile2D();
+ }
+
}
}
Index: dam engine/trunk/src/Deltares.DamEngine.Interface/FillXmlInputFromDam.cs
===================================================================
diff -u -r508 -r540
--- dam engine/trunk/src/Deltares.DamEngine.Interface/FillXmlInputFromDam.cs (.../FillXmlInputFromDam.cs) (revision 508)
+++ dam engine/trunk/src/Deltares.DamEngine.Interface/FillXmlInputFromDam.cs (.../FillXmlInputFromDam.cs) (revision 540)
@@ -27,6 +27,7 @@
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;
namespace Deltares.DamEngine.Interface
{
@@ -48,6 +49,8 @@
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);
return input;
}
@@ -133,5 +136,39 @@
inputLocations[i] = inputLocation;
}
}
+
+ private static void TransferSoilProfiles1D(IList dikeSoilProfiles,
+ Io.XmlInput.SoilProfile1D[] inputSoilProfiles1D)
+ {
+ var profilesCount = dikeSoilProfiles.Count;
+ for (int i = 0; i < profilesCount; i++)
+ {
+ var soilProfile1D = dikeSoilProfiles[i];
+ var inputSoilProfile1D = new Io.XmlInput.SoilProfile1D
+ {
+ Name = soilProfile1D.Name,
+ BottomLevel = soilProfile1D.BottomLevel,
+ Layers = new SoilProfile1DLayer[soilProfile1D.LayerCount]
+ };
+ AddLayers(soilProfile1D, inputSoilProfile1D);
+ }
+ }
+
+ private static void AddLayers(SoilProfile1D soilProfile1D, Io.XmlInput.SoilProfile1D inputSoilProfile1D)
+ {
+ for (int i = 0; i < soilProfile1D.LayerCount; i++)
+ {
+ var layer = soilProfile1D.Layers[i];
+ var inputLayer = new SoilProfile1DLayer
+ {
+ Name = layer.Name,
+ SoilName = layer.Soil.Name,
+ TopLevel = layer.TopLevel,
+ IsAquifer = layer.IsAquifer,
+ WaterpressureInterpolationModel = ConversionHelper.ConvertToInputWaterpressureInterpolationModel(
+ layer.WaterpressureInterpolationModel)
+ };
+ }
+ }
}
}
Index: dam engine/trunk/src/Deltares.DamEngine.Interface.Tests/FillDamFromXmlInputTests.cs
===================================================================
diff -u -r496 -r540
--- dam engine/trunk/src/Deltares.DamEngine.Interface.Tests/FillDamFromXmlInputTests.cs (.../FillDamFromXmlInputTests.cs) (revision 496)
+++ dam engine/trunk/src/Deltares.DamEngine.Interface.Tests/FillDamFromXmlInputTests.cs (.../FillDamFromXmlInputTests.cs) (revision 540)
@@ -20,6 +20,7 @@
// All rights reserved.
using System;
+using System.Collections.Generic;
using Deltares.DamEngine.Data.General;
using Deltares.DamEngine.Data.Geometry;
using Deltares.DamEngine.Data.Geotechnics;
@@ -28,6 +29,7 @@
using KellermanSoftware.CompareNetObjects;
using NUnit.Framework;
using Soil = Deltares.DamEngine.Data.Geotechnics.Soil;
+using SoilProfile1D = Deltares.DamEngine.Data.Geotechnics.SoilProfile1D;
namespace Deltares.DamEngine.Interface.Tests
{
@@ -77,6 +79,7 @@
FillSurfaceLines(dike);
FillSoils(dike);
FillLocations(dike);
+ FillSoilProfiles1D(dike);
return damProjectData;
}
@@ -172,6 +175,52 @@
}
}
+ private static void FillSoilProfiles1D(Dike dike)
+ {
+ dike.SoilProfiles = new List();
+ const int profilesCount = 2;
+ for (int i = 0; i < profilesCount; i++)
+ {
+ 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.
+// }
+ const int layerCount = 3;
+ for (int j = 0; j < layerCount; j++)
+ {
+ var layer = new SoilLayer1D
+ {
+ Name = "Layer" + (j + 1).ToString(),
+ Soil = dike.SoilList.Soils[j],
+ TopLevel = 1 * -j
+ };
+ if (j < 2)
+ {
+ layer.WaterpressureInterpolationModel = WaterpressureInterpolationModel.Automatic;
+ layer.IsAquifer = false;
+ }
+ else
+ {
+ layer.WaterpressureInterpolationModel = WaterpressureInterpolationModel.Hydrostatic;
+ layer.IsAquifer = true;
+ }
+ profile.Layers.Add(layer);
+ }
+ }
+ }
+
private void CompareDamProjectData(DamProjectData actual, DamProjectData expected)
{
var compare = new CompareLogic { Config = { MaxDifferences = 100 } };
Index: dam engine/trunk/src/Deltares.DamEngine.Io/DamInput.cs
===================================================================
diff -u -r535 -r540
--- dam engine/trunk/src/Deltares.DamEngine.Io/DamInput.cs (.../DamInput.cs) (revision 535)
+++ dam engine/trunk/src/Deltares.DamEngine.Io/DamInput.cs (.../DamInput.cs) (revision 540)
@@ -643,8 +643,6 @@
private SoilProfile1DLayer[] layersField;
- private SoilProfile1DPreconsolidationStress[] preconsolidationStressesField;
-
private string nameField;
private double bottomLevelField;
@@ -661,17 +659,6 @@
}
///
- [System.Xml.Serialization.XmlArrayItemAttribute("PreconsolidationStress", IsNullable=false)]
- public SoilProfile1DPreconsolidationStress[] PreconsolidationStresses {
- get {
- return this.preconsolidationStressesField;
- }
- set {
- this.preconsolidationStressesField = value;
- }
- }
-
- ///
[System.Xml.Serialization.XmlAttributeAttribute()]
public string Name {
get {
@@ -773,67 +760,6 @@
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
- [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
- public partial class SoilProfile1DPreconsolidationStress {
-
- private double stressValueField;
-
- private string nameField;
-
- private double xField;
-
- private double zField;
-
- ///
- [System.Xml.Serialization.XmlAttributeAttribute()]
- public double StressValue {
- get {
- return this.stressValueField;
- }
- set {
- this.stressValueField = value;
- }
- }
-
- ///
- [System.Xml.Serialization.XmlAttributeAttribute()]
- public string Name {
- get {
- return this.nameField;
- }
- set {
- this.nameField = value;
- }
- }
-
- ///
- [System.Xml.Serialization.XmlAttributeAttribute()]
- public double X {
- get {
- return this.xField;
- }
- set {
- this.xField = value;
- }
- }
-
- ///
- [System.Xml.Serialization.XmlAttributeAttribute()]
- public double Z {
- get {
- return this.zField;
- }
- set {
- this.zField = value;
- }
- }
- }
-
- ///
- [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
- [System.SerializableAttribute()]
- [System.Diagnostics.DebuggerStepThroughAttribute()]
- [System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class Segment {
private SegmentSoilGeometryProbability[] soilGeometryProbabilityField;