Index: DamEngine/trunk/src/Deltares.DamEngine.Interface.Tests/Deltares.DamEngine.Interface.Tests.csproj =================================================================== diff -u -r1471 -r1472 --- DamEngine/trunk/src/Deltares.DamEngine.Interface.Tests/Deltares.DamEngine.Interface.Tests.csproj (.../Deltares.DamEngine.Interface.Tests.csproj) (revision 1471) +++ DamEngine/trunk/src/Deltares.DamEngine.Interface.Tests/Deltares.DamEngine.Interface.Tests.csproj (.../Deltares.DamEngine.Interface.Tests.csproj) (revision 1472) @@ -48,6 +48,7 @@ + @@ -145,6 +146,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/DikesDesign/DesignCalculator.cs =================================================================== diff -u -r1468 -r1472 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/DikesDesign/DesignCalculator.cs (.../DesignCalculator.cs) (revision 1468) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/DikesDesign/DesignCalculator.cs (.../DesignCalculator.cs) (revision 1472) @@ -21,6 +21,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using Deltares.DamEngine.Calculators.General; using Deltares.DamEngine.Calculators.KernelWrappers.Common; @@ -100,8 +101,10 @@ private void RunDesignCalculatorTask(object designCalculatorTask) { DesignCalculatorTask task = (DesignCalculatorTask)designCalculatorTask; + Debug.WriteLine("Start calculation Location '{0}', soilprofile '{1}'", task.Location, task.SoiProfileProbability); CalculateOneScenario(task.Location, task.SoiProfileProbability, task.DesignScenario, task.ProjectPath, task.CalculationMap, task.FailureMechanismeCalculationSpecification, task.DesignResults, task.CalculationMessages); + Debug.WriteLine("End calculation Location '{0}', soilprofile '{1}'", task.Location, task.SoiProfileProbability); } private void CalculateOneScenario(Location location, SoilGeometryProbability soiProfileProbability, DesignScenario designScenario, string projectPath, string calculationMap, DamFailureMechanismeCalculationSpecification damFailureMechanismeCalculationSpecification, Index: DamEngine/trunk/src/Deltares.DamEngine.Interface.Tests/MultiCorePipingCalculationTests.cs =================================================================== diff -u -r1471 -r1472 --- DamEngine/trunk/src/Deltares.DamEngine.Interface.Tests/MultiCorePipingCalculationTests.cs (.../MultiCorePipingCalculationTests.cs) (revision 1471) +++ DamEngine/trunk/src/Deltares.DamEngine.Interface.Tests/MultiCorePipingCalculationTests.cs (.../MultiCorePipingCalculationTests.cs) (revision 1472) @@ -21,6 +21,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Linq; using System.Text; @@ -36,10 +37,6 @@ class MultiCorePipingCalculationTests { private const double tolerance = 0.0005; - private string DetermineOutputFilename(string prefix, string modelType, int coreCount, string extension = ".xml") - { - return String.Format("{0}_{1}_{2}core{3}_OutputFile", prefix, modelType, coreCount, extension); - } [Test] [TestCase(PipingModelType.Bligh)] [TestCase(PipingModelType.Sellmeijer4Forces)] @@ -54,7 +51,9 @@ // Set piping model type inputString = XmlAdapter.ChangeValueInXml(inputString, "PipingModelType", pipingModelType.ToString()); + // Calculate one core + Debug.WriteLine("Perform single core calculation Piping"); EngineInterface engineInterface = new EngineInterface(inputString); Assert.IsNotNull(engineInterface.DamProjectData); string outputString = engineInterface.Run(); @@ -64,6 +63,7 @@ File.WriteAllText(outputFilename, outputString, Encoding.Unicode); // Calculate multicore + Debug.WriteLine("Perform multicore calculation with {0} cores Piping", multiCoreCount); inputString = XmlAdapter.ChangeValueInXml(inputString, "MaxCalculationCores", multiCoreCount.ToString()); engineInterface = new EngineInterface(inputString); Assert.IsNotNull(engineInterface.DamProjectData); @@ -80,15 +80,40 @@ { DesignResult multiCoreResult = outputMultiCore.Results.CalculationResults.DesignResults.Where(x => x.LocationName.Equals(oneCoreResult.LocationName) && x.ProfileName.Equals(oneCoreResult.ProfileName)).FirstOrDefault(); Assert.NotNull(multiCoreResult); - if (Math.Abs(oneCoreResult.PipingDesignResults.BlighFactor - multiCoreResult.PipingDesignResults.BlighFactor) > tolerance) + switch (pipingModelType) { - var diffString = String.Format("Different result in {0}, {1}: 1 core = {2}, multicore = {3}", oneCoreResult.LocationName, oneCoreResult.ProfileName, oneCoreResult.PipingDesignResults.BlighFactor, multiCoreResult.PipingDesignResults.BlighFactor); - differencesStringBuilder.AppendLine(diffString); - differences.Add(diffString); + case PipingModelType.Bligh: + if (Math.Abs(oneCoreResult.PipingDesignResults.BlighFactor - multiCoreResult.PipingDesignResults.BlighFactor) > tolerance) + { + var diffString = String.Format("Different result in {0}, {1}: 1 core = {2}, multicore = {3}", oneCoreResult.LocationName, oneCoreResult.ProfileName, oneCoreResult.PipingDesignResults.BlighFactor, multiCoreResult.PipingDesignResults.BlighFactor); + differencesStringBuilder.AppendLine(diffString); + differences.Add(diffString); + } + break; + case PipingModelType.Sellmeijer4Forces: + if (Math.Abs(oneCoreResult.PipingDesignResults.Sellmeijer4ForcesFactor - multiCoreResult.PipingDesignResults.Sellmeijer4ForcesFactor) > tolerance) + { + var diffString = String.Format("Different result in {0}, {1}: 1 core = {2}, multicore = {3}", oneCoreResult.LocationName, oneCoreResult.ProfileName, oneCoreResult.PipingDesignResults.BlighFactor, multiCoreResult.PipingDesignResults.BlighFactor); + differencesStringBuilder.AppendLine(diffString); + differences.Add(diffString); + } + break; + case PipingModelType.SellmeijerVnk: + if (Math.Abs(oneCoreResult.PipingDesignResults.SellmeijerVnkFactor - multiCoreResult.PipingDesignResults.SellmeijerVnkFactor) > tolerance) + { + var diffString = String.Format("Different result in {0}, {1}: 1 core = {2}, multicore = {3}", oneCoreResult.LocationName, oneCoreResult.ProfileName, oneCoreResult.PipingDesignResults.BlighFactor, multiCoreResult.PipingDesignResults.BlighFactor); + differencesStringBuilder.AppendLine(diffString); + differences.Add(diffString); + } + break; } } Assert.IsTrue(differences.Count == 0, "Differences found" + Environment.NewLine + differencesStringBuilder); } + private string DetermineOutputFilename(string prefix, string modelType, int coreCount, string extension = ".xml") + { + return String.Format("{0}_{1}_{2}core_OutputFile{3}", prefix, modelType, coreCount, extension); + } } } Index: DamEngine/trunk/src/Deltares.DamEngine.Interface.Tests/TestFiles/MacroStabilityTutorialDesignInputFileMultipleLocations.xml =================================================================== diff -u --- DamEngine/trunk/src/Deltares.DamEngine.Interface.Tests/TestFiles/MacroStabilityTutorialDesignInputFileMultipleLocations.xml (revision 0) +++ DamEngine/trunk/src/Deltares.DamEngine.Interface.Tests/TestFiles/MacroStabilityTutorialDesignInputFileMultipleLocations.xml (revision 1472) @@ -0,0 +1,1127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file Index: DamEngine/trunk/src/Deltares.DamEngine.Interface.Tests/MultiCoreMacroStabilityTests.cs =================================================================== diff -u --- DamEngine/trunk/src/Deltares.DamEngine.Interface.Tests/MultiCoreMacroStabilityTests.cs (revision 0) +++ DamEngine/trunk/src/Deltares.DamEngine.Interface.Tests/MultiCoreMacroStabilityTests.cs (revision 1472) @@ -0,0 +1,114 @@ +// Copyright (C) Stichting Deltares 2018. 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.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using Deltares.DamEngine.Data.General; +using Deltares.DamEngine.Io; +using Deltares.DamEngine.Io.XmlOutput; +using Deltares.DamEngine.TestHelpers; +using NUnit.Framework; + +namespace Deltares.DamEngine.Interface.Tests +{ + [TestFixture] + public class MultiCoreMacroStabilityTests + { + private const double tolerance = 0.0005; + + [Test, Category("Slow")] + [TestCase(MStabModelType.Bishop, AnalysisType.NoAdaption)] + [TestCase(MStabModelType.UpliftVan, AnalysisType.NoAdaption)] + [TestCase(MStabModelType.BishopUpliftVan, AnalysisType.NoAdaption)] + [TestCase(MStabModelType.Bishop, AnalysisType.AdaptGeometry)] + [TestCase(MStabModelType.UpliftVan, AnalysisType.AdaptGeometry)] + public void CanPerformRunMacroStabilityTutorialDesignMultiCore(MStabModelType mStabModelType, AnalysisType analysisType) + { + // Based on ".data\DamEngineTestProjects\DAM Tutorial Design\DAM Tutorial Design.damx" + // with Dam Classic rev.1059 + // Select locations DWP_1 to DWP_12 + const int multiCoreCount = 4; + const string fileName = @"TestFiles\MacroStabilityTutorialDesignInputFileMultipleLocations.xml"; + const string fileNameOutputPrefix = @"TestFiles\MacroStabilityTutorialDesignMultipleLocations"; + string inputString = File.ReadAllText(fileName); + inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used + inputString = XmlAdapter.ChangeValueInXml(inputString, "MapForSoilgeometries2D", @"TestFiles\DAM Tutorial Design.geometries2D.0\"); + inputString = XmlAdapter.ChangeValueInXml(inputString, "SoilDatabaseName", @"TestFiles\DAM Tutorial Design0.soilmaterials.mdb"); + inputString = XmlAdapter.ChangeValueInXml(inputString, "StabilityModelType", mStabModelType.ToString()); + inputString = XmlAdapter.ChangeValueInXml(inputString, "AnalysisType", analysisType.ToString()); + + // Calculate one core + string calcDir = String.Format("TestStabInwards{0}_{1}Core", analysisType.ToString(), 1); + inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used + if (Directory.Exists(calcDir)) + { + Directory.Delete(calcDir, true); // delete previous results + } + Directory.CreateDirectory(calcDir); + Debug.WriteLine("Perform single core calculation Macrostability"); + EngineInterface engineInterface = new EngineInterface(inputString); + Assert.IsNotNull(engineInterface.DamProjectData); + string outputString = engineInterface.Run(); + Assert.IsNotNull(outputString); + var outputOneCore = DamXmlSerialization.LoadOutputFromXmlString(outputString); + string outputFilename = DetermineOutputFilename(fileNameOutputPrefix, mStabModelType.ToString(), analysisType.ToString(), 1); + File.WriteAllText(outputFilename, outputString, Encoding.Unicode); + + // Calculate multicore + Debug.WriteLine("Perform multicore calculation with {0} cores Macrostability", multiCoreCount); + calcDir = String.Format("TestStabInwards{0}_{1}Core", analysisType.ToString(), multiCoreCount); + inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used + inputString = XmlAdapter.ChangeValueInXml(inputString, "MaxCalculationCores", multiCoreCount.ToString()); + engineInterface = new EngineInterface(inputString); + Assert.IsNotNull(engineInterface.DamProjectData); + outputString = engineInterface.Run(); + Assert.IsNotNull(outputString); + var outputMultiCore = DamXmlSerialization.LoadOutputFromXmlString(outputString); + outputFilename = DetermineOutputFilename(fileNameOutputPrefix, mStabModelType.ToString(), analysisType.ToString(), multiCoreCount); + File.WriteAllText(outputFilename, outputString, Encoding.Unicode); + + // Compare the results + var differences = new List(); + StringBuilder differencesStringBuilder = new StringBuilder(); + foreach (DesignResult oneCoreResult in outputOneCore.Results.CalculationResults.DesignResults) + { + DesignResult multiCoreResult = outputMultiCore.Results.CalculationResults.DesignResults.Where(x => x.LocationName.Equals(oneCoreResult.LocationName) && x.ProfileName.Equals(oneCoreResult.ProfileName)).FirstOrDefault(); + Assert.NotNull(multiCoreResult); + if (Math.Abs(oneCoreResult.StabilityDesignResults.SafetyFactor - multiCoreResult.StabilityDesignResults.SafetyFactor) > tolerance) + { + var diffString = String.Format("Different result in {0}, {1}: 1 core = {2}, multicore = {3}", oneCoreResult.LocationName, oneCoreResult.ProfileName, oneCoreResult.PipingDesignResults.BlighFactor, multiCoreResult.PipingDesignResults.BlighFactor); + differencesStringBuilder.AppendLine(diffString); + differences.Add(diffString); + } + } + + Assert.IsTrue(differences.Count == 0, "Differences found" + Environment.NewLine + differencesStringBuilder); + } + private string DetermineOutputFilename(string prefix, string modelType, string analysisType, int coreCount, string extension = ".xml") + { + return String.Format("{0}_{1}_{2}_{3}core_OutputFile{4}", prefix, modelType, analysisType, coreCount, extension); + } + } +} \ No newline at end of file