Index: dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/Deltares.DamEngine.Calculators.Tests.csproj
===================================================================
diff -u -r828 -r829
--- dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/Deltares.DamEngine.Calculators.Tests.csproj (.../Deltares.DamEngine.Calculators.Tests.csproj) (revision 828)
+++ dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/Deltares.DamEngine.Calculators.Tests.csproj (.../Deltares.DamEngine.Calculators.Tests.csproj) (revision 829)
@@ -47,10 +47,10 @@
-
-
-
-
+
+
+
+
@@ -75,23 +75,23 @@
Copying.AGPL.licenseheader
-
+ PreserveNewest
-
+ PreserveNewest
-
+ PreserveNewest
-
+ PreserveNewest
-
+ PreserveNewest
Index: dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStabilityCommon/Geometry2DTo1DConverterTest.cs
===================================================================
diff -u
--- dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStabilityCommon/Geometry2DTo1DConverterTest.cs (revision 0)
+++ dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStabilityCommon/Geometry2DTo1DConverterTest.cs (revision 829)
@@ -0,0 +1,181 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of the Dam Engine.
+//
+// The Dam Engine is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.IO;
+using Deltares.DamEngine.Calculators.General;
+using Deltares.DamEngine.Data.Geotechnics;
+using Deltares.DamEngine.TestHelpers;
+using NUnit.Framework;
+
+namespace Deltares.DamEngine.Calculators.Tests.KernelWrappers.DamMacroStabilityCommon
+{
+ [TestFixture]
+ public class Geometry2DTo1DConverterTest
+ {
+ const double cTolerance = 0.00001;
+ private const string TestFolder = @"..\..\Deltares.DamEngine.Calculators.Tests\KernelWrappers\DamMacroStabilityCommon\TestData";
+ private string geometryFileName1D1 = Path.Combine(TestFolder, "1D1.sti");
+ private string geometryFileName18_4_94 = Path.Combine(TestFolder, "18_4_94.sti");
+ string cDikeMaterial = "OA";
+
+ SurfaceLine2 surfaceLine;
+ Soil dikeEmbankmentMaterial;
+
+ [TestFixtureSetUp]
+ public void FixtureSetup()
+ {
+ surfaceLine = FactoryForSurfaceLines.CreateSurfaceLineTutorial1();
+ dikeEmbankmentMaterial = new Soil();
+ dikeEmbankmentMaterial.Name = cDikeMaterial;
+ }
+
+ [SetUp]
+ public void Setup() {}
+
+ [TestFixtureTearDown]
+ public void FixtureTearDown() {}
+
+ [Test]
+ public void CanCreateSoilProfileIfSurfaceLinePointBelowGeometrySurface()
+ {
+ SoilList soilList = CreateSoilList();
+ var geometry2DTo1DConverter = new Geometry2DTo1DConverter(geometryFileName1D1, surfaceLine, dikeEmbankmentMaterial, soilList);
+ SoilProfile1D soilProfile = geometry2DTo1DConverter.Convert(64.0);
+ Assert.AreEqual(6, soilProfile.Layers.Count);
+ Assert.AreEqual("DKN5", soilProfile.Layers[0].SoilName);
+ Assert.AreEqual("DKN5", soilProfile.Layers[0].Soil.Name);
+ Assert.AreEqual(1.31640522876, soilProfile.Layers[0].TopLevel, cTolerance);
+ Assert.AreEqual(17.50, soilProfile.Layers[0].Soil.AbovePhreaticLevel, cTolerance);
+ Assert.AreEqual(17.50, soilProfile.Layers[0].Soil.BelowPhreaticLevel, cTolerance);
+ }
+
+ [Test]
+ public void CanCreateSoilProfileWithOriginOffsetIfSurfaceLinePointBelowGeometrySurface()
+ {
+ const double offset = 10.0;
+ SoilList soilList = CreateSoilList();
+ var geometry2DTo1DConverter = new Geometry2DTo1DConverter(geometryFileName1D1, surfaceLine, dikeEmbankmentMaterial, soilList, offset);
+ SoilProfile1D soilProfile = geometry2DTo1DConverter.Convert(64.0 - offset);
+ Assert.AreEqual(6, soilProfile.Layers.Count);
+ Assert.AreEqual("DKN5", soilProfile.Layers[0].SoilName);
+ Assert.AreEqual("DKN5", soilProfile.Layers[0].Soil.Name);
+ Assert.AreEqual(1.31640522876, soilProfile.Layers[0].TopLevel, cTolerance);
+ Assert.AreEqual(17.50, soilProfile.Layers[0].Soil.AbovePhreaticLevel, cTolerance);
+ Assert.AreEqual(17.50, soilProfile.Layers[0].Soil.BelowPhreaticLevel, cTolerance);
+ }
+
+ [Test]
+ public void CanCreateSoilProfileIfSurfaceLinePointAboveGeometrySurface()
+ {
+ SoilList soilList = CreateSoilList();
+ var geometry2DTo1DConverter = new Geometry2DTo1DConverter(geometryFileName1D1, surfaceLine, dikeEmbankmentMaterial, soilList);
+ SoilProfile1D soilProfile = geometry2DTo1DConverter.Convert(73.0);
+ Assert.AreEqual(6, soilProfile.Layers.Count);
+ Assert.AreEqual(cDikeMaterial, soilProfile.Layers[0].SoilName);
+ Assert.AreEqual(cDikeMaterial, soilProfile.Layers[0].Soil.Name);
+ Assert.AreEqual(18.00, soilProfile.Layers[0].Soil.AbovePhreaticLevel, cTolerance);
+ Assert.AreEqual(20.00, soilProfile.Layers[0].Soil.BelowPhreaticLevel, cTolerance);
+ Assert.AreEqual("DKN4", soilProfile.Layers[1].SoilName);
+ Assert.AreEqual("DKN4", soilProfile.Layers[1].Soil.Name);
+ Assert.AreEqual(17.16, soilProfile.Layers[1].Soil.AbovePhreaticLevel, cTolerance);
+ Assert.AreEqual(17.16, soilProfile.Layers[1].Soil.BelowPhreaticLevel, cTolerance);
+ }
+
+ ///
+ /// This test fails sometimes and random (see MWDAM-303)
+ /// You may need to run it a couple of times before it fails
+ ///
+ [Test]
+ public void RandomFailingCase()
+ {
+ SoilList soilList = CreateSoilList();
+ var geometry2DTo1DConverter = new Geometry2DTo1DConverter(geometryFileName18_4_94, surfaceLine, dikeEmbankmentMaterial, soilList);
+ for (int i = 0; i < 10; i++)
+ {
+ Console.WriteLine(String.Format("Index = {0}", i));
+ SoilProfile1D soilProfile = geometry2DTo1DConverter.Convert(110.0);
+ Assert.AreEqual(-16.43, soilProfile.BottomLevel, String.Format("Random fail on index = {0}", i));
+ }
+ }
+
+ private SoilList CreateSoilList()
+ {
+ var soilList = new SoilList();
+ var s1 = new Soil("DKN5")
+ {
+ AbovePhreaticLevel = 17.5,
+ BelowPhreaticLevel = 17.50
+ };
+ soilList.Soils.Add(s1);
+ var s2 = new Soil("DKN4")
+ {
+ AbovePhreaticLevel = 17.16,
+ BelowPhreaticLevel = 17.16
+ };
+ soilList.Soils.Add(s2);
+ var s3 = new Soil("OA")
+ {
+ AbovePhreaticLevel = 18.00,
+ BelowPhreaticLevel = 20.00
+ };
+ soilList.Soils.Add(s3);
+ var s4 = new Soil("DKN3");
+ soilList.Soils.Add(s4);
+ var s5 = new Soil("LM");
+ soilList.Soils.Add(s5);
+
+ var s6 = new Soil("Dijks (17,5)");
+ soilList.Soils.Add(s6);
+ var s7 = new Soil("Tiel naast (15,0) (1)");
+ soilList.Soils.Add(s7);
+ var s8 = new Soil("Tiel onder (15,5)");
+ soilList.Soils.Add(s8);
+ var s9 = new Soil("G2 onder (16,0)");
+ soilList.Soils.Add(s9);
+ var s10 = new Soil("G2 naast (14,5)");
+ soilList.Soils.Add(s10);
+ var s11 = new Soil("G1 onder (14,0) (1)");
+ soilList.Soils.Add(s11);
+ var s12 = new Soil("G1 naast (12,6)");
+ soilList.Soils.Add(s12);
+ var s13 = new Soil("HV onder (11,0)");
+ soilList.Soils.Add(s13);
+ var s14 = new Soil("HV naast (10,40)");
+ soilList.Soils.Add(s14);
+ var s15 = new Soil("BV onder (12,0) (4)");
+ soilList.Soils.Add(s15);
+ var s16 = new Soil("BV naast (11,0)");
+ soilList.Soils.Add(s16);
+ var s17 = new Soil("kreft onder (18,5)");
+ soilList.Soils.Add(s17);
+ var s18 = new Soil("kreft naast (18,5)");
+ soilList.Soils.Add(s18);
+ var s19 = new Soil("verkeer (14)");
+ soilList.Soils.Add(s19);
+ var s20 = new Soil("pleistoceen (4)");
+ soilList.Soils.Add(s20);
+ var s21 = new Soil("WL_pleistoceen (4)");
+ soilList.Soils.Add(s21);
+ return soilList;
+ }
+ }
+}
Index: dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStabilityInwards/DamMacroStabilityInwardsKernelWrapperTests.cs
===================================================================
diff -u -r828 -r829
--- dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStabilityInwards/DamMacroStabilityInwardsKernelWrapperTests.cs (.../DamMacroStabilityInwardsKernelWrapperTests.cs) (revision 828)
+++ dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStabilityInwards/DamMacroStabilityInwardsKernelWrapperTests.cs (.../DamMacroStabilityInwardsKernelWrapperTests.cs) (revision 829)
@@ -37,7 +37,7 @@
[TestFixture]
public class DamMacroStabilityTests
{
- private const string TestFolder = @"..\..\Deltares.DamEngine.Calculators.Tests\KernelWrappers\DamMacroStability\TestData";
+ private const string TestFolder = @"..\..\Deltares.DamEngine.Calculators.Tests\KernelWrappers\DamMacroStabilityCommon\TestData";
// [Test]
// public void TestFullCalculation()
Index: dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStabilityCommon/DamMStabGeometry2DDataAssemblerTest.cs
===================================================================
diff -u
--- dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStabilityCommon/DamMStabGeometry2DDataAssemblerTest.cs (revision 0)
+++ dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStabilityCommon/DamMStabGeometry2DDataAssemblerTest.cs (revision 829)
@@ -0,0 +1,72 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of the Dam Engine.
+//
+// The Dam Engine is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.IO;
+using System.Xml.Linq;
+using Deltares.DamEngine.Calculators.General;
+using Deltares.DamEngine.Calculators.KernelWrappers.DamMacroStabilityCommon.Assemblers;
+using NUnit.Framework;
+
+namespace Deltares.DamEngine.Calculators.Tests.KernelWrappers.DamMacroStabilityCommon
+{
+ [TestFixture]
+ public class DamMStabGeometry2DDataAssemblerTest
+ {
+ private DAMMStabGeometry2DDataAssembler assembler;
+ private const double cTolerance = 0.001;
+ private const string TestFolder = @"..\..\Deltares.DamEngine.Calculators.Tests\KernelWrappers\DamMacroStabilityCommon\TestData";
+ private string outputXml = Path.Combine(TestFolder, "Geometry2DDataOutput.xml");
+
+ [SetUp]
+ public void TestSetup()
+ {
+ this.assembler = new DAMMStabGeometry2DDataAssembler();
+ }
+
+ [Test]
+ public void CanReadDAMMStabGeometry2DDataXML()
+ {
+ XDocument doc = XDocument.Load(outputXml);
+ Geometry2DData geometry2DData = assembler.CreateOutputObject(doc);
+ Assert.AreEqual(11, geometry2DData.LayerCount);
+
+ var layer = geometry2DData.GetLayer(1);
+ Assert.AreEqual("Sand", layer.soilName);
+ Assert.IsNotNull(layer.boundaryLine);
+ Assert.AreEqual(3, layer.boundaryLine.Points.Count);
+ Assert.AreEqual(-50.0, layer.boundaryLine.Points[0].X, cTolerance);
+ Assert.AreEqual(-10.2, layer.boundaryLine.Points[0].Z, cTolerance);
+ Assert.AreEqual(13.17, layer.boundaryLine.Points[1].X, cTolerance);
+ Assert.AreEqual(-10.2, layer.boundaryLine.Points[1].Z, cTolerance);
+ Assert.AreEqual(100.0, layer.boundaryLine.Points[2].X, cTolerance);
+ Assert.AreEqual(-10.2, layer.boundaryLine.Points[2].Z, cTolerance);
+
+ layer = geometry2DData.GetLayer(10);
+ Assert.AreEqual("Surchage", layer.soilName);
+ Assert.IsNotNull(layer.boundaryLine);
+ Assert.AreEqual(19, layer.boundaryLine.Points.Count);
+ Assert.AreEqual(-50.0, layer.boundaryLine.Points[0].X, cTolerance);
+ Assert.AreEqual(-5.97, layer.boundaryLine.Points[0].Z, cTolerance);
+ Assert.AreEqual(100.0, layer.boundaryLine.Points[18].X, cTolerance);
+ Assert.AreEqual(-0.86, layer.boundaryLine.Points[18].Z, cTolerance);
+ }
+ }
+}
Index: dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStabilityCommon/DAMMstabGeometry2DSectionAssemblerTest.cs
===================================================================
diff -u
--- dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStabilityCommon/DAMMstabGeometry2DSectionAssemblerTest.cs (revision 0)
+++ dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStabilityCommon/DAMMstabGeometry2DSectionAssemblerTest.cs (revision 829)
@@ -0,0 +1,206 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of the Dam Engine.
+//
+// The Dam Engine is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Xml.Linq;
+using Deltares.DamEngine.Calculators.General;
+using Deltares.DamEngine.Calculators.KernelWrappers.DamMacroStabilityCommon.Assemblers;
+using Deltares.DamEngine.Data.Geotechnics;
+using NUnit.Framework;
+
+namespace Deltares.DamEngine.Calculators.Tests.KernelWrappers.DamMacroStabilityCommon
+{
+ [TestFixture]
+ public class DAMMStabGeometry2DSectionAssemblerTest
+ {
+ private const string TestFolder = @"..\..\Deltares.DamEngine.Calculators.Tests\KernelWrappers\DamMacroStabilityCommon\TestData";
+ private string outputXml = Path.Combine(TestFolder, "ProfileOutput.xml");
+ private const string testDirectory = "TestResults";
+ private const string testFileName = "DAMMStabGeometry2DSectionAssemblerTest.xml";
+ private const double cTolerance = 1e-8;
+ private DAMMStabGeometry2DSectionAssembler assembler;
+ private Geometry2DSectionParameters geometry2DSectionParameters;
+ //private SoilProfile soilProfile1;
+ #region Setup/Teardown
+
+ [SetUp]
+ public void TestSetup()
+ {
+ const string soilGeometry2DName = "SoilGeometry2DName";
+ this.assembler = new DAMMStabGeometry2DSectionAssembler();
+ this.geometry2DSectionParameters = new Geometry2DSectionParameters();
+ this.geometry2DSectionParameters.XCoordinateSection = 65.4;
+ this.geometry2DSectionParameters.SoilGeometry2DName = soilGeometry2DName;
+ // Soil profiles
+ var soilProfile = new SoilProfile1D();
+ soilProfile.Name = "SoilProfile1";
+ soilProfile.BottomLevel = -25.3;
+ Soil soilClay = new Soil("Clay", 20.0, 20.0);
+ Soil soilPeat = new Soil("Peat", 20.0, 20.0);
+ Soil soilSand = new Soil("Sand", 20.0, 20.0);
+ var layer = new SoilLayer1D();
+ layer.Name = "L1";
+ layer.SoilName = "Layer 1";
+ layer.TopLevel = -1.52;
+ layer.Soil = soilClay;
+ layer.IsAquifer = false;
+ soilProfile.Layers.Add(layer);
+ layer = new SoilLayer1D();
+ layer.Name = "L2";
+ layer.SoilName = "Layer 2";
+ layer.TopLevel = -3.18;
+ layer.Soil = soilPeat;
+ layer.IsAquifer = false;
+ soilProfile.Layers.Add(layer);
+ layer = new SoilLayer1D();
+ layer.Name = "L3";
+ layer.SoilName = "Layer 3";
+ layer.TopLevel = -7.37;
+ layer.Soil = soilSand;
+ layer.IsAquifer = true;
+ soilProfile.Layers.Add(layer);
+ layer = new SoilLayer1D();
+ layer.Name = "L4";
+ layer.SoilName = "Layer 4";
+ layer.TopLevel = -12.28;
+ layer.Soil = soilPeat;
+ layer.IsAquifer = false;
+ soilProfile.Layers.Add(layer);
+ layer = new SoilLayer1D();
+ layer.Name = "L5";
+ layer.SoilName = "Layer 5";
+ layer.TopLevel = -15.62;
+ layer.Soil = soilClay;
+ layer.IsAquifer = false;
+ soilProfile.Layers.Add(layer);
+ layer = new SoilLayer1D();
+ layer.Name = "L6";
+ layer.SoilName = "Layer 6";
+ layer.TopLevel = -18.39;
+ layer.Soil = soilSand;
+ layer.IsAquifer = true;
+ soilProfile.Layers.Add(layer);
+ this.geometry2DSectionParameters.SoilProfile = soilProfile;
+ }
+
+ #endregion
+
+
+ [TestFixtureSetUp]
+ public void TestFixtureSetup()
+ {
+ }
+
+ [Test]
+ public void CanCreateAndValidateDAMMStabGeometry2DSectionXML()
+ {
+ // Do the thing: create XML element from SoilProfile
+ XDocument doc = this.assembler.CreateDataTransferObject(this.geometry2DSectionParameters);
+
+ Directory.CreateDirectory(testDirectory);
+ doc.Save(Path.Combine(testDirectory, testFileName));
+
+ //// Validate against schema
+ //string message;
+ //if (!this.assembler.ValidateSchema(doc, out message))
+ //{
+ // Assert.Fail("SCHEMA VALIDATION: " + message);
+ //}
+
+ // Compare resulting XML to original object
+
+ // Input
+ XElement inputElement = (from element in doc.Root.Descendants()
+ where element.Name.LocalName == DAMMStabGeometry2DSectionAssembler.XmlElementGeometry2DSectionInput
+ select element).Single();
+
+ // Database
+ Assert.AreEqual(this.geometry2DSectionParameters.SoilGeometry2DName, inputElement.AttributeAs(DAMMStabGeometry2DSectionAssembler.XmlAttributeSoilGeometry2DFilename), String.Format("{0}", DAMMStabGeometry2DSectionAssembler.XmlAttributeSoilGeometry2DFilename));
+ Assert.AreEqual(this.geometry2DSectionParameters.XCoordinateSection, inputElement.AttributeAs(DAMMStabGeometry2DSectionAssembler.XmlAttributeXCoordinateSection), String.Format("{0}", DAMMStabGeometry2DSectionAssembler.XmlAttributeXCoordinateSection));
+
+
+ // Profile
+ IEnumerable soilProfileCollectionElements = from element in doc.Root.Descendants()
+ where element.Name.LocalName == DamMStabAssembler.XmlElementProfile
+ select element;
+
+ Assert.AreEqual(1, soilProfileCollectionElements.Count(), "Number of profiles");
+
+ XElement soilProfileElement = soilProfileCollectionElements.Single();
+
+ Assert.IsNotNull(soilProfileElement.Attribute(DamMStabAssembler.XmlAttributeName), String.Format("{0}", DamMStabAssembler.XmlAttributeName));
+ Assert.AreEqual(geometry2DSectionParameters.SoilProfile.Name, soilProfileElement.AttributeAs(DamMStabAssembler.XmlAttributeName), String.Format("{0}", DamMStabAssembler.XmlAttributeName));
+ Assert.IsNotNull(soilProfileElement.Attribute(DamMStabAssembler.XmlAttributeXCoordinate), String.Format("{0}", DamMStabAssembler.XmlAttributeXCoordinate));
+ Assert.IsNotNull(soilProfileElement.Attribute(DamMStabAssembler.XmlAttributeYCoordinate), String.Format("{0}", DamMStabAssembler.XmlAttributeYCoordinate));
+ Assert.IsNotNull(soilProfileElement.Attribute(DamMStabAssembler.XmlAttributePhreaticLevel), String.Format("{0}", DamMStabAssembler.XmlAttributePhreaticLevel));
+ Assert.IsNotNull(soilProfileElement.Attribute(DamMStabAssembler.XmlAttributeHasPhreaticLevel), String.Format("{0}", DamMStabAssembler.XmlAttributeHasPhreaticLevel));
+ Assert.IsNotNull(soilProfileElement.Attribute(DamMStabAssembler.XmlAttributeBottomLevel), String.Format("{0}", DamMStabAssembler.XmlAttributeBottomLevel));
+ Assert.AreEqual(geometry2DSectionParameters.SoilProfile.BottomLevel, soilProfileElement.AttributeAs(DamMStabAssembler.XmlAttributeBottomLevel), cTolerance, String.Format("{0}", DamMStabAssembler.XmlAttributeBottomLevel));
+ // Created no PL line so characteristic layers are unassigned
+ Assert.IsNotNull(soilProfileElement.Attribute(DamMStabAssembler.XmlAttributeBottomSandLayerID), DamMStabAssembler.XmlAttributeBottomSandLayerID);
+ Assert.IsNotNull(soilProfileElement.Attribute(DamMStabAssembler.XmlAttributeInBetweenSandLayerID), DamMStabAssembler.XmlAttributeInBetweenSandLayerID);
+ Assert.IsNull(soilProfileElement.Attribute(DamMStabAssembler.XmlAttributeInfiltrationLayerID), DamMStabAssembler.XmlAttributeInfiltrationLayerID);
+
+ // Profile layers
+ IEnumerable layersCollectionElements = from element in soilProfileElement.Descendants()
+ where element.Name.LocalName == DamMStabAssembler.XmlElementLayers
+ select element;
+
+ Assert.AreEqual(1, layersCollectionElements.Count(), "profile layer collection tag");
+
+ IEnumerable layerCollectionElements = from element in layersCollectionElements.Descendants()
+ where element.Name.LocalName == DamMStabAssembler.XmlElementLayer
+ select element;
+
+ Assert.AreEqual(geometry2DSectionParameters.SoilProfile.Layers.Count, layerCollectionElements.Count(), "Number of profile layers");
+
+ IEnumerator layerElementEnumerator = layerCollectionElements.GetEnumerator();
+ foreach (SoilLayer1D layer in geometry2DSectionParameters.SoilProfile.Layers)
+ {
+ layerElementEnumerator.MoveNext();
+ XElement layerElement = layerElementEnumerator.Current;
+ Assert.IsNotNull(layerElement.Attribute(DamMStabAssembler.XmlAttributeID), String.Format("{0}", String.Format("ID of layer #{0}", geometry2DSectionParameters.SoilProfile.Layers.IndexOf(layer))));
+ Assert.AreEqual(layer.Name, layerElement.AttributeAs(DamMStabAssembler.XmlAttributeID), String.Format("ID of layer #{0}", geometry2DSectionParameters.SoilProfile.Layers.IndexOf(layer)));
+ Assert.IsNotNull(layerElement.Attribute(DamMStabAssembler.XmlAttributeSoilID), String.Format("{0}", String.Format("SoilID of layer #{0}", geometry2DSectionParameters.SoilProfile.Layers.IndexOf(layer))));
+ Assert.AreEqual(layer.Soil.Name, layerElement.AttributeAs(DamMStabAssembler.XmlAttributeSoilID), String.Format("SoilID of layer #{0}", geometry2DSectionParameters.SoilProfile.Layers.IndexOf(layer)));
+ Assert.IsNotNull(layerElement.Attribute(DamMStabAssembler.XmlAttributeTopLevel), String.Format("{0}", String.Format("TopLevel of layer #{0}", geometry2DSectionParameters.SoilProfile.Layers.IndexOf(layer))));
+ Assert.AreEqual(layer.TopLevel, layerElement.AttributeAs(DamMStabAssembler.XmlAttributeTopLevel), String.Format("TopLevel of layer #{0}", geometry2DSectionParameters.SoilProfile.Layers.IndexOf(layer)));
+ }
+
+ }
+
+ [Test]
+ public void CanReadDAMMStabGeometry2DSectionXML()
+ {
+ XDocument doc = XDocument.Load(outputXml);
+ Geometry2DSectionParameters geometry2DSectionParameters = assembler.CreateOutputObject(doc);
+ Assert.AreEqual(6, geometry2DSectionParameters.SoilProfile.Layers.Count);
+ Assert.AreEqual(-10, geometry2DSectionParameters.SoilProfile.BottomLevel, cTolerance);
+ Assert.IsTrue(geometry2DSectionParameters.SoilProfile.Layers[3].SoilName.Equals("DKN3"));
+ Assert.AreEqual(-2.8, geometry2DSectionParameters.SoilProfile.Layers[3].TopLevel, cTolerance);
+ Assert.IsTrue(geometry2DSectionParameters.SoilGeometry2DName.Equals("1D1.sti"));
+ Assert.AreEqual(64.0, geometry2DSectionParameters.XCoordinateSection, cTolerance);
+ }
+ }
+}
\ No newline at end of file
Index: dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStabilityCommon/MStabXmlDocTests.cs
===================================================================
diff -u
--- dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStabilityCommon/MStabXmlDocTests.cs (revision 0)
+++ dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStabilityCommon/MStabXmlDocTests.cs (revision 829)
@@ -0,0 +1,205 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of the Dam Engine.
+//
+// The Dam Engine is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Xml.Linq;
+using Deltares.DamEngine.Calculators.KernelWrappers.DamMacroStabilityCommon;
+using Deltares.DamEngine.Calculators.KernelWrappers.DamMacroStabilityCommon.Assemblers;
+using Deltares.DamEngine.Data.Design;
+using Deltares.DamEngine.Data.General;
+using Deltares.DamEngine.Data.Geotechnics;
+using Deltares.DamEngine.Data.Standard.Logging;
+using Deltares.DamEngine.TestHelpers;
+using NUnit.Framework;
+
+namespace Deltares.DamEngine.Calculators.Tests.KernelWrappers.DamMacroStabilityCommon
+{
+ [TestFixture]
+ public class MStabXmlDocTests
+ {
+ private const string TestFolder = @"..\..\Deltares.DamEngine.Calculators.Tests\KernelWrappers\DamMacroStabilityCommon\TestData";
+
+ [Test]
+ public void TestCreateMStabXmlDoc()
+ {
+
+ List errorMessages;
+
+ const string stabilityProjectFilename = "testproject";
+ var xmlFileName = Path.Combine(TestFolder, "testproject.xml");
+ // Expected1D1.xml was generated with Dam Classic revision 745 with test CanCalculateStabilitySafetyFactorGeometry2D
+ // In the file that is generated here sometimes value -0 is written instead of 0.
+ // To compare the two files in an easy way, Expected1D1.xml was manually modified
+ var expectedxmlFileName = Path.Combine(TestFolder, "Expected1D1.xml");
+ var soilGeometry2DName = Path.Combine(TestFolder, "1D1.sti");
+ var soilDbName = Path.Combine(TestFolder, "soilmaterials.mdb");
+ var requiredSafetyFactor = 1.2;
+
+ if (File.Exists(xmlFileName))
+ {
+ File.Delete(xmlFileName);
+ }
+
+ var line = FactoryForSurfaceLines.CreateSurfaceLineTutorial1();
+ var location = new Location();
+ var scenario = CreateScenarioForLocation(location, line);
+ scenario.Location.SoildatabaseName = soilDbName;
+
+ var surfaceLine = scenario.Location.SurfaceLine;
+ var trafficLoad = 10.0;
+ var subSoilScenario = new SoilGeometryProbability();
+ subSoilScenario.StiFileName = soilGeometry2DName;
+ subSoilScenario.SoilProfileType = SoilProfileType.ProfileTypeStiFile;
+ subSoilScenario.SegmentFailureMechanismType = FailureMechanismSystemType.StabilityInside;
+
+ var failureMechanismeParamatersMStab = new FailureMechanismeParamatersMStab();
+ failureMechanismeParamatersMStab.MStabParameters.GridPosition = MStabGridPosition.Right;
+ failureMechanismeParamatersMStab.MStabParameters.SearchMethod = MStabSearchMethod.GeneticAlgorithm;
+ failureMechanismeParamatersMStab.MStabParameters.CalculationOptions.MinimalCircleDepth = 1.0;
+
+ MStabDesignEmbankment mStabDesignEmbankment = null;
+
+ XDocument mstabXml = MStabXmlDoc.CreateMStabXmlDoc(stabilityProjectFilename, scenario, subSoilScenario,
+ scenario.RiverLevel, mStabDesignEmbankment, surfaceLine, trafficLoad, requiredSafetyFactor, failureMechanismeParamatersMStab,
+ out errorMessages);
+
+ mstabXml.Save(xmlFileName);
+ Assert.IsTrue(File.Exists(xmlFileName));
+ CompareByLine(ModifiedXmlDocument(expectedxmlFileName), ModifiedXmlDocument(xmlFileName));
+ }
+
+ private void CompareByLine(XDocument expectedXmlDocument, XDocument xmlDocument)
+ {
+ string expectedText = expectedXmlDocument.ToString();
+ string testedText = xmlDocument.ToString();
+ Assert.AreEqual(expectedText, testedText);
+ }
+
+ public XDocument ModifiedXmlDocument(string xmlFileName)
+ {
+ XDocument xDocument = XDocument.Load(xmlFileName);
+
+ // Modify FileIdentification
+ const string fileIdentificationElementName = "FileIdentification";
+ XElement fileIdentificationElement = (from element in xDocument.Root.Descendants()
+ where element.Name.LocalName == fileIdentificationElementName
+ select element).Single();
+
+ // clear application that created the xml
+ XAttribute application = fileIdentificationElement.Attribute("Application");
+ Debug.Assert(application != null, "application != null");
+ application.Value = "";
+
+ // clear version of application that created the xml
+ XAttribute version = fileIdentificationElement.Attribute("Version");
+ Debug.Assert(version != null, "version != null");
+ version.Value = "";
+
+ // clear creation date and time
+ XAttribute created = fileIdentificationElement.Attribute("Created");
+ Debug.Assert(created != null, "created != null");
+ created.Value = "";
+
+ // Modify DamMStabInput
+ XElement inputElement = (from element in xDocument.Root.Descendants()
+ where element.Name.LocalName == DamMStabAssembler.XmlElementNameInput
+ select element).Single();
+
+ // clear name of output sti file
+ XAttribute mstabFileName = inputElement.Attribute(DamMStabAssembler.XmlAttributeMStabFileName);
+ Debug.Assert(mstabFileName != null, "mstabFileName != null");
+ mstabFileName.Value = "";
+
+ // clear name of soil database
+ XAttribute dbName = inputElement.Attribute(DamMStabAssembler.XmlAttributeSoilDBName);
+ Debug.Assert(dbName != null, "dbName != null");
+ dbName.Value = "";
+
+ // clear name of geometry input file
+ XElement geometryOptionsElement = (from element in inputElement.Descendants()
+ where element.Name.LocalName == DamMStabAssembler.XmlElementGeometryCreationOptions
+ select element).Single();
+ XAttribute geomFileName = geometryOptionsElement.Attribute(DamMStabAssembler.XmlAttributeSoilGeometry2DFilename);
+ Debug.Assert(geomFileName != null, "geomFileName != null");
+ geomFileName.Value = "";
+ return xDocument;
+ }
+
+ public static DesignScenario CreateScenarioForLocation(Location location, SurfaceLine2 surfaceLine)
+ {
+ DesignScenario scenario = new DesignScenario();
+ scenario.Location = location;
+ scenario.Location.DamType = DamType.Regional;
+ scenario.Location.Name = "LocationName";
+ scenario.Location.DikeEmbankmentMaterial = "OB1";
+ scenario.Location.ShoulderEmbankmentMaterial = "OB2";
+ scenario.Location.SoilList = CreateSoilList();
+ scenario.LocationScenarioID = "ScenarioID";
+ scenario.Location.SurfaceLine = surfaceLine;
+ return scenario;
+ }
+ private static SoilList CreateSoilList()
+ {
+ var soilList = new SoilList();
+ var s1 = new Soil("DKN5")
+ {
+ AbovePhreaticLevel = 17.5,
+ BelowPhreaticLevel = 17.50
+ };
+ soilList.Soils.Add(s1);
+ var s2 = new Soil("DKN4")
+ {
+ AbovePhreaticLevel = 17.16,
+ BelowPhreaticLevel = 17.16
+ };
+ soilList.Soils.Add(s2);
+ var s3 = new Soil("OA")
+ {
+ AbovePhreaticLevel = 18.00,
+ BelowPhreaticLevel = 20.00
+ };
+ soilList.Soils.Add(s3);
+ var s4 = new Soil("DKN3");
+ soilList.Soils.Add(s4);
+ var s5 = new Soil("LM");
+ soilList.Soils.Add(s5);
+
+ var s6 = new Soil("OB1");
+ soilList.Soils.Add(s6);
+ var s7 = new Soil("OB2");
+ soilList.Soils.Add(s7);
+
+ soilList.AquiferDictionary = new Dictionary();
+ soilList.AquiferDictionary.Add(s1, false);
+ soilList.AquiferDictionary.Add(s2, false);
+ soilList.AquiferDictionary.Add(s3, true);
+ soilList.AquiferDictionary.Add(s4, false);
+ soilList.AquiferDictionary.Add(s5, true);
+ soilList.AquiferDictionary.Add(s6, false);
+ soilList.AquiferDictionary.Add(s7, false);
+ return soilList;
+ }
+
+ }
+}
Fisheye: Tag 829 refers to a dead (removed) revision in file `dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStability/MStabXmlDocTests.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 829 refers to a dead (removed) revision in file `dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStability/Geometry2DTo1DConverterTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 829 refers to a dead (removed) revision in file `dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStability/TestData/18_4_94.sti'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 829 refers to a dead (removed) revision in file `dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStability/TestData/Geometry2DDataOutput.xml'.
Fisheye: No comparison available. Pass `N' to diff?
Index: dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStability/TestData/soilmaterials.mdb
===================================================================
diff -u -r769 -r829
Binary files differ
Fisheye: Tag 829 refers to a dead (removed) revision in file `dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStability/DAMMstabGeometry2DSectionAssemblerTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 829 refers to a dead (removed) revision in file `dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStability/DamMStabGeometry2DDataAssemblerTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 829 refers to a dead (removed) revision in file `dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStability/TestData/1D1.sti'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 829 refers to a dead (removed) revision in file `dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStability/TestData/ProfileOutput.xml'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 829 refers to a dead (removed) revision in file `dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStability/TestData/expectedTest.sti'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 829 refers to a dead (removed) revision in file `dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStability/TestData/DWP_1.sti'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 829 refers to a dead (removed) revision in file `dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStability/TestData/test.xml'.
Fisheye: No comparison available. Pass `N' to diff?
Index: dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStability/TestData/DAM Tutorial Design0.soilmaterials.mdb
===================================================================
diff -u -r800 -r829
Binary files differ
Fisheye: Tag 829 refers to a dead (removed) revision in file `dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStability/TestData/Expected1D1.xml'.
Fisheye: No comparison available. Pass `N' to diff?