Index: DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/GeneralHelper.cs =================================================================== diff -u --- DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/GeneralHelper.cs (revision 0) +++ DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/GeneralHelper.cs (revision 4172) @@ -0,0 +1,42 @@ +// Copyright (C) Stichting Deltares 2023. 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 Deltares.DamEngine.Data.Standard.Logging; + +namespace Deltares.DamEngine.TestHelpers; + +public static class GeneralHelper +{ + public static int DetermineNumberOfCalculationErrors(List calculationMessages) + { + int errorCount = 0; + foreach (var logMessage in calculationMessages) + { + if ((logMessage.MessageType == LogMessageType.Error) || (logMessage.MessageType == LogMessageType.FatalError)) + { + errorCount++; + } + } + + return errorCount; + } +} \ No newline at end of file Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityInwards/MacroStabilityInwardsKernelWrapper.cs =================================================================== diff -u -r4150 -r4172 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityInwards/MacroStabilityInwardsKernelWrapper.cs (.../MacroStabilityInwardsKernelWrapper.cs) (revision 4150) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityInwards/MacroStabilityInwardsKernelWrapper.cs (.../MacroStabilityInwardsKernelWrapper.cs) (revision 4172) @@ -175,7 +175,7 @@ macroStabilityOutput.Message = new LogMessage { MessageType = LogMessageType.FatalError, - Message = e.Message + Message = e.Message + " Stack: " + e.StackTrace }; kernelDataOutput = macroStabilityOutput; return PrepareResult.Failed; Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityCommonHelper.cs =================================================================== diff -u -r4150 -r4172 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityCommonHelper.cs (.../MacroStabilityCommonHelper.cs) (revision 4150) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityCommonHelper.cs (.../MacroStabilityCommonHelper.cs) (revision 4172) @@ -329,7 +329,7 @@ var message = new LogMessage { MessageType = LogMessageType.FatalError, - Message = e.Message + Message = e.Message + " stack: " + e.StackTrace }; messages.Add(message); if (kernelDataOutput != null) @@ -382,6 +382,7 @@ { macroStabilityOutput.CalculationResult = CalculationResult.UnexpectedError; messages.Add(new LogMessage(LogMessageType.Error, null, e.Message)); + messages.Add(new LogMessage(LogMessageType.Error, null, e.StackTrace)); } } Index: DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/Routines2D.cs =================================================================== diff -u -r4132 -r4172 --- DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/Routines2D.cs (.../Routines2D.cs) (revision 4132) +++ DamEngine/trunk/src/Deltares.DamEngine.Data/Geometry/Routines2D.cs (.../Routines2D.cs) (revision 4172) @@ -269,37 +269,41 @@ while (index < polygon.CalcPoints.Count) { - deltaX = polygon[index].X - x; - deltaZ = polygon[index].Z - z; - absX = Math.Abs(deltaX); - absZ = Math.Abs(deltaZ); - if ((absX < epsilon) && (absZ < epsilon)) + if (polygon[index] != null) { - UndoAddIfNeeded(polygon, pointAdded); - return PointInPolygon.OnPolygonEdge; - } + deltaX = polygon[index].X - x; + deltaZ = polygon[index].Z - z; + absX = Math.Abs(deltaX); + absZ = Math.Abs(deltaZ); + if ((absX < epsilon) && (absZ < epsilon)) + { + UndoAddIfNeeded(polygon, pointAdded); + return PointInPolygon.OnPolygonEdge; + } - double al2 = Math.Atan2(deltaZ, deltaX); - double al3 = al2 - al1; + double al2 = Math.Atan2(deltaZ, deltaX); + double al3 = al2 - al1; - if (al3 < -Math.PI) - { - al3 = al3 + (2.0 * Math.PI); - } + if (al3 < -Math.PI) + { + al3 = al3 + (2.0 * Math.PI); + } - if (al3 > Math.PI) - { - al3 = al3 - (2.0 * Math.PI); - } + if (al3 > Math.PI) + { + al3 = al3 - (2.0 * Math.PI); + } - if (((Math.PI - al3) < epsilon) || ((Math.PI + al3) < epsilon)) - { - UndoAddIfNeeded(polygon, pointAdded); - return PointInPolygon.OnPolygonEdge; + if (((Math.PI - al3) < epsilon) || ((Math.PI + al3) < epsilon)) + { + UndoAddIfNeeded(polygon, pointAdded); + return PointInPolygon.OnPolygonEdge; + } + + som = som + al3; + al1 = al2; } - som = som + al3; - al1 = al2; index++; } Index: DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/IntegrationTests/MultiCoreMacroStabilityTests.cs =================================================================== diff -u -r4158 -r4172 --- DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/IntegrationTests/MultiCoreMacroStabilityTests.cs (.../MultiCoreMacroStabilityTests.cs) (revision 4158) +++ DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/IntegrationTests/MultiCoreMacroStabilityTests.cs (.../MultiCoreMacroStabilityTests.cs) (revision 4172) @@ -71,6 +71,9 @@ string outputString = engineInterface.Run(); File.WriteAllText("Output.xml", outputString); Output output = DamXmlSerialization.LoadOutputFromXmlString(outputString); + int errorCount = GeneralHelper.DetermineNumberOfCalculationErrors(engineInterface.DamProjectData.CalculationMessages); + Assert.AreEqual(0, errorCount, "There should be nor errors during the calculation."); + Assert.AreEqual(output.Results.CalculationMessages.Length, engineInterface.DamProjectData.CalculationMessages.Count); if (engineInterface.DamProjectData.DamProjectType == DamProjectType.Design) { Assert.AreNotEqual(null, output.Results.CalculationResults); @@ -85,7 +88,8 @@ numberOfResults += resultSerie.Entries.TimeSerieEntry.Length; foreach (TimeSerieEntriesTimeSerieEntry timeSerieEntriesTimeSerieEntry in resultSerie.Entries.TimeSerieEntry) { - if (!Double.IsNaN(timeSerieEntriesTimeSerieEntry.Value)) + if (!Double.IsNaN(timeSerieEntriesTimeSerieEntry.Value) && (timeSerieEntriesTimeSerieEntry.Value > 0) && + (timeSerieEntriesTimeSerieEntry.Value < 100000)) { numberOfRealResults++; } @@ -115,6 +119,9 @@ string outputString = engineInterface.Run(); File.WriteAllText("Output.xml", outputString); Output output = DamXmlSerialization.LoadOutputFromXmlString(outputString); + int errorCount = GeneralHelper.DetermineNumberOfCalculationErrors(engineInterface.DamProjectData.CalculationMessages); + Assert.AreEqual(0, errorCount, "There should be nor errors during the calculation."); + Assert.AreEqual(output.Results.CalculationMessages.Length, engineInterface.DamProjectData.CalculationMessages.Count); if (engineInterface.DamProjectData.DamProjectType == DamProjectType.Design) { Assert.IsNotNull(output.Results.CalculationResults); @@ -129,7 +136,8 @@ numberOfResults += resultSerie.Entries.TimeSerieEntry.Length; foreach (TimeSerieEntriesTimeSerieEntry timeSerieEntriesTimeSerieEntry in resultSerie.Entries.TimeSerieEntry) { - if (!Double.IsNaN(timeSerieEntriesTimeSerieEntry.Value)) + if (!Double.IsNaN(timeSerieEntriesTimeSerieEntry.Value) && (timeSerieEntriesTimeSerieEntry.Value > 0) && + (timeSerieEntriesTimeSerieEntry.Value < 100000)) { numberOfRealResults++; } Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/DikesOperational/OperationalCalculator.cs =================================================================== diff -u -r4132 -r4172 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/DikesOperational/OperationalCalculator.cs (.../OperationalCalculator.cs) (revision 4132) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/DikesOperational/OperationalCalculator.cs (.../OperationalCalculator.cs) (revision 4172) @@ -249,10 +249,16 @@ // stability where Piping calc is wanted). In that case, do nothing but just skip. if (prepareResult == PrepareResult.Successful) { - PerformOperationalCalculation( - kernelWrapper, kernelDataInput, kernelDataOutput, - damKernelInput, timeStepIndex, timeSerieEntry, out calculationResult, - calculationMessages); + lock (kernelWrapper)//"this" makes it single core again ;-). + { + lock (damKernelInput) + { + PerformOperationalCalculation( + kernelWrapper, kernelDataInput, kernelDataOutput, + damKernelInput, timeStepIndex, timeSerieEntry, out calculationResult, + calculationMessages); + } + } } else {