Index: DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/TestFiles/InputForDebuggingBeeSwarm.xml =================================================================== diff -u --- DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/TestFiles/InputForDebuggingBeeSwarm.xml (revision 0) +++ DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/TestFiles/InputForDebuggingBeeSwarm.xml (revision 4182) @@ -0,0 +1,618 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file Index: DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/IntegrationTests/MultiCoreMacroStabilityTests.cs =================================================================== diff -u -r4172 -r4182 --- DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/IntegrationTests/MultiCoreMacroStabilityTests.cs (.../MultiCoreMacroStabilityTests.cs) (revision 4172) +++ DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/IntegrationTests/MultiCoreMacroStabilityTests.cs (.../MultiCoreMacroStabilityTests.cs) (revision 4182) @@ -20,15 +20,20 @@ // All rights reserved. using System; +using System.Collections.Generic; using System.Globalization; using System.IO; using System.Threading; +using System.Linq; using Deltares.DamEngine.Data.General; using Deltares.DamEngine.Interface; using Deltares.DamEngine.Io; using Deltares.DamEngine.Io.XmlOutput; using Deltares.DamEngine.TestHelpers; using NUnit.Framework; +using TimeSerie = Deltares.DamEngine.Io.XmlOutput.TimeSerie; +using Deltares.DamEngine.Calculators.DikesOperational; +using Deltares.DamEngine.Data.General.TimeSeries; namespace Deltares.DamEngine.IntegrationTests.IntegrationTests; @@ -147,7 +152,131 @@ Assert.AreEqual(16, numberOfRealResults); } } + + [Test]//, Ignore("This test is only used for debugging XML files generated by Dam UI")] + [TestCase(10)] + [TestCase(24)] + public void OperationalBeeSwarmMultiCoreWithXmlInputFile(int maxCores) + { + const string inputFilename = "InputForDebuggingBeeSwarm.xml"; // or put your own name here; + string fullInputFilename = Path.Combine(mapTestFiles, inputFilename); + Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; + string inputString = File.ReadAllText(fullInputFilename); + var engineInterface = new EngineInterface(inputString); + Assert.IsNotNull(engineInterface.DamProjectData); + engineInterface.DamProjectData.MaxCalculationCores = maxCores; + string result = engineInterface.Validate(); + Assert.IsTrue(result == null, "Validation must succeed but does not, see output xml in debugger"); + string outputString = engineInterface.Run(); + string outputName = "Output" + maxCores + ".xml"; + File.WriteAllText(outputName, outputString); + //Output output = DamXmlSerialization.LoadOutputFromXmlString(outputString); + //TimeSerieCollection outputTimeSeriesCollection = new TimeSerieCollection(); + //outputTimeSeriesCollection.Series.AddRange(engineInterface.DamProjectData.OutputTimeSerieCollection.Series); + List series = engineInterface.DamProjectData.OutputTimeSerieCollection.Series; + + int errorCount = GeneralHelper.DetermineNumberOfCalculationErrors(engineInterface.DamProjectData.CalculationMessages); + Assert.AreEqual(0, errorCount, "There should be nor errors during the calculation."); + + var seriesCount = 0; + var resultsCount = 0; + const double cTolerance = 0.0005; + + foreach (Deltares.DamEngine.Data.General.TimeSeries.TimeSerie timeSeries in series) + { + //Assert.IsTrue(validParameterIDs.Any(n => n == timeSeries.ParameterId)); + //Assert.IsTrue(locations.Any(l => l.Name == timeSeries.LocationId)); + // StabilityInside check + if (timeSeries.ParameterId == TimeSerieParameters.StabilityInsideFactor.ToString()) + { + if (timeSeries.LocationId == "Purmer_PU0042+00_K") + { + TimeSerieEntry firstEntry = timeSeries.Entries.First(); + Assert.AreEqual(1.442, firstEntry.Value, cTolerance, "The computed safety factory is not correct"); + resultsCount++; + TimeSerieEntry lastEntry = timeSeries.Entries.Last(); + Assert.AreEqual(1.579, lastEntry.Value, cTolerance, "The computed safety factory is not correct"); + resultsCount++; + } + if (timeSeries.LocationId == "Purmer_PU0042+00_K_V") + { + TimeSerieEntry firstEntry = timeSeries.Entries.First(); + Assert.AreEqual(1.365, firstEntry.Value, cTolerance, "The computed safety factory is not correct"); + resultsCount++; + TimeSerieEntry lastEntry = timeSeries.Entries.Last(); + Assert.AreEqual(1.481, lastEntry.Value, cTolerance, "The computed safety factory is not correct"); + resultsCount++; + } + + if (timeSeries.LocationId == "Purmer_PU0042+00_R") + { + TimeSerieEntry firstEntry = timeSeries.Entries.First(); + Assert.AreEqual(1.239, firstEntry.Value, cTolerance, "The computed safety factory is not correct"); + resultsCount++; + TimeSerieEntry lastEntry = timeSeries.Entries.Last(); + Assert.AreEqual(1.355, lastEntry.Value, cTolerance, "The computed safety factory is not correct"); + resultsCount++; + } + if (timeSeries.LocationId == "Purmer_PU0042+00_R_V") + { + TimeSerieEntry firstEntry = timeSeries.Entries.First(); + Assert.AreEqual(1.168, firstEntry.Value, cTolerance, "The computed safety factory is not correct"); + resultsCount++; + TimeSerieEntry lastEntry = timeSeries.Entries.Last(); + Assert.AreEqual(1.272, lastEntry.Value, cTolerance, "The computed safety factory is not correct"); + resultsCount++; + } + + if (timeSeries.LocationId == "Purmer_PU0110+20_K") + { + TimeSerieEntry firstEntry = timeSeries.Entries.First(); + Assert.AreEqual(Double.NaN, firstEntry.Value, cTolerance, "The computed safety factory is not correct"); + resultsCount++; + TimeSerieEntry lastEntry = timeSeries.Entries.Last(); + Assert.AreEqual(Double.NaN, lastEntry.Value, cTolerance, "The computed safety factory is not correct"); + resultsCount++; + } + + if (timeSeries.LocationId == "Purmer_PU0110+20_K_V") + { + TimeSerieEntry firstEntry = timeSeries.Entries.First(); + Assert.AreEqual(Double.NaN, firstEntry.Value, cTolerance, "The computed safety factory is not correct"); + resultsCount++; + TimeSerieEntry lastEntry = timeSeries.Entries.Last(); + Assert.AreEqual(Double.NaN, lastEntry.Value, cTolerance, "The computed safety factory is not correct"); + resultsCount++; + } + + if (timeSeries.LocationId == "Purmer_PU0110+20_R") + { + TimeSerieEntry firstEntry = timeSeries.Entries.First(); + Assert.AreEqual(Double.NaN, firstEntry.Value, cTolerance, "The computed safety factory is not correct"); + resultsCount++; + TimeSerieEntry lastEntry = timeSeries.Entries.Last(); + Assert.AreEqual(Double.NaN, lastEntry.Value, cTolerance, "The computed safety factory is not correct"); + resultsCount++; + } + + if (timeSeries.LocationId == "Purmer_PU0110+20_R_V") + { + TimeSerieEntry firstEntry = timeSeries.Entries.First(); + Assert.AreEqual(Double.NaN, firstEntry.Value, cTolerance, "The computed safety factory is not correct"); + resultsCount++; + TimeSerieEntry lastEntry = timeSeries.Entries.Last(); + Assert.AreEqual(Double.NaN, lastEntry.Value, cTolerance, "The computed safety factory is not correct"); + resultsCount++; + } + } + + seriesCount++; + } + + Assert.IsTrue(seriesCount > 0, "No output time series"); + Assert.AreEqual(16, resultsCount, "Incorrect number of results"); + + } + private static void RemoveTestWorkingDirectory(string testWorkingFolder) { if (Directory.Exists(testWorkingFolder))