Index: DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/GeneralHelper.cs =================================================================== diff -u -r5823 -r6139 --- DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/GeneralHelper.cs (.../GeneralHelper.cs) (revision 5823) +++ DamEngine/trunk/src/Deltares.DamEngine.TestHelpers/GeneralHelper.cs (.../GeneralHelper.cs) (revision 6139) @@ -26,13 +26,15 @@ using System.Text; using Deltares.DamEngine.Data.Design; using Deltares.DamEngine.Data.General; +using Deltares.DamEngine.Data.Standard.Calculation; using Deltares.DamEngine.Data.Standard.Logging; using Deltares.DamEngine.Interface; using Deltares.DamEngine.Io; using Deltares.DamEngine.Io.XmlOutput; using DGeoSuite.Common; using KellermanSoftware.CompareNetObjects; using NUnit.Framework; +using ConversionHelper = Deltares.DamEngine.Interface.ConversionHelper; namespace Deltares.DamEngine.TestHelpers; @@ -123,13 +125,15 @@ foreach (DesignResult calculationResult in outputResults.CalculationResults) { - bool isDesignSuccessful = IsAdaptGeometrySuccessful(outputResults.CalculationMessages, calculationResult); + bool isDesignSuccessful = calculationResult.CalculationResult == ConversionHelper.ConvertToOutputCalculationResult(CalculationResult.Succeeded) && + IsAdaptGeometrySuccessful(outputResults.CalculationMessages, calculationResult); double fosRequired = FetchRequiredFactor(engineInterface, calculationResult.ScenarioName, calculationResult.LocationName); double fosCalculated = FetchCalculatedFactor(engineInterface, calculationResult); if (isDesignSuccessful) { - const string message = "After adapting the geometry, the calculated safety factor is less than the" + - " required safety factor; this is unexpected."; + string message = "After adapting the geometry, the calculated safety factor is less than the required safety factor " + + $"for location '{calculationResult.LocationName}' and scenario '{calculationResult.ScenarioName}'. " + + "This is unexpected."; Assert.That(fosCalculated, Is.GreaterThanOrEqualTo(fosRequired), message); } else Index: DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/IntegrationTests/MultiCoreMacroStabilityInwardsTests.cs =================================================================== diff -u --- DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/IntegrationTests/MultiCoreMacroStabilityInwardsTests.cs (revision 0) +++ DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/IntegrationTests/MultiCoreMacroStabilityInwardsTests.cs (revision 6139) @@ -0,0 +1,93 @@ +// Copyright (C) Stichting Deltares 2024. 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 System.Linq; +using Deltares.DamEngine.Data.General; +using Deltares.DamEngine.Data.Standard.Calculation; +using Deltares.DamEngine.Io; +using Deltares.DamEngine.Io.XmlInput; +using Deltares.DamEngine.Io.XmlOutput; +using Deltares.DamEngine.TestHelpers; +using NUnit.Framework; +using ConversionHelper = Deltares.DamEngine.Interface.ConversionHelper; + +namespace Deltares.DamEngine.IntegrationTests.IntegrationTests; + +[TestFixture] +public class MultiCoreMacroStabilityInwardsTests +{ + private const string tutorialStability2D = @"TestFiles\InputTutorialStability2D.xml"; + + [Test, Category(Categories.Slow)] + [TestCase(4, InputStabilityModelType.Bishop, "SlopeAdaptionBeforeShoulderAdaption", 21, 6)] + [TestCase(8, InputStabilityModelType.Bishop, "SlopeAdaptionBeforeShoulderAdaption", 21, 6)] + [TestCase(12, InputStabilityModelType.Bishop, "SlopeAdaptionBeforeShoulderAdaption", 21, 6)] + [TestCase(4, InputStabilityModelType.UpliftVan, "SlopeAdaptionBeforeShoulderAdaption", 9, 17)] + [TestCase(8, InputStabilityModelType.UpliftVan, "SlopeAdaptionBeforeShoulderAdaption", 9, 17)] + [TestCase(12, InputStabilityModelType.UpliftVan, "SlopeAdaptionBeforeShoulderAdaption", 9, 17)] + [TestCase(4, InputStabilityModelType.Bishop, "OptimizedSlopeAndShoulderAdaption", 10, 17)] + [TestCase(8, InputStabilityModelType.Bishop, "OptimizedSlopeAndShoulderAdaption", 10, 17)] + [TestCase(12, InputStabilityModelType.Bishop, "OptimizedSlopeAndShoulderAdaption", 10, 17)] + [TestCase(4, InputStabilityModelType.UpliftVan, "OptimizedSlopeAndShoulderAdaption", 9, 17)] + [TestCase(8, InputStabilityModelType.UpliftVan, "OptimizedSlopeAndShoulderAdaption", 9, 17)] + [TestCase(12, InputStabilityModelType.UpliftVan, "OptimizedSlopeAndShoulderAdaption", 9, 17)] + public void GivenTutorialDesign_WhenCalculateAllWithGeometryAdaption_ThenGivesExpectedResults(int maxCores, InputStabilityModelType stabilityModelType, string designMethod, + int expectedSucceeded = 21, int expectedFailed = 6) + { + int processorCount = Environment.ProcessorCount; + if (maxCores > processorCount) + { + Assert.Ignore($"The number of cores requested ({maxCores}) is higher than the number of available cores ({processorCount})."); + } + + // Use XML of general Tutorial Design project + var calcDir = $"TestMultiCoreStabInwards{stabilityModelType.ToString()}_AdaptGeometry_{designMethod}_{maxCores.ToString()}-core"; + if (Directory.Exists(calcDir)) + { + Directory.Delete(calcDir, true); // delete previous results + } + + string inputString = File.ReadAllText(tutorialStability2D); + inputString = XmlAdapter.ChangeStabilityInputModel(inputString, stabilityModelType); + inputString = XmlAdapter.ChangeValueInXml(inputString, "FailureMechanismSystemType", ConversionHelper.ConvertToInputFailureMechanismSystemType( + FailureMechanismSystemType.StabilityInside).ToString()); + inputString = XmlAdapter.ChangeValueInXml(inputString, "ProjectPath", ""); // Current directory will be used + inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used + inputString = XmlAdapter.ChangeValueInXml(inputString, "SegmentFailureMechanismType", + ConversionHelper.InputSegmentFailureMechanismStability.ToString()); + inputString = XmlAdapter.ChangeValueInXml(inputString, "AnalysisType", "AdaptGeometry"); + inputString = XmlAdapter.ChangeValueInXml(inputString, "StabilityDesignMethod", designMethod); + inputString = XmlAdapter.ChangeValueInXml(inputString, "MaxCalculationCores", maxCores.ToString()); + File.WriteAllText(calcDir + "_InputFile.xml", inputString); + Output output = GeneralHelper.RunAfterInputValidation(inputString); + DamXmlSerialization.SaveOutputAsXmlFile(calcDir + "_OutputFile.xml", output); + Assert.Multiple(() => + { + Assert.That(output.Results.CalculationResults.Length, Is.EqualTo(expectedSucceeded + expectedFailed)); + int actualSucceeded = output.Results.CalculationResults.Count(result => ConversionHelper.ConvertToCalculationResult(result.CalculationResult) == CalculationResult.Succeeded); + Assert.That(actualSucceeded, Is.EqualTo(expectedSucceeded)); + int actualFailed = output.Results.CalculationResults.Count(result => ConversionHelper.ConvertToCalculationResult(result.CalculationResult) == CalculationResult.RunFailed); + Assert.That(actualFailed, Is.EqualTo(expectedFailed)); + }); + } +} \ No newline at end of file