Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityInwards/MacroStabilityInwardsKernelWrapperTests.cs =================================================================== diff -u -r5598 -r5627 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityInwards/MacroStabilityInwardsKernelWrapperTests.cs (.../MacroStabilityInwardsKernelWrapperTests.cs) (revision 5598) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityInwards/MacroStabilityInwardsKernelWrapperTests.cs (.../MacroStabilityInwardsKernelWrapperTests.cs) (revision 5627) @@ -46,50 +46,46 @@ [TestFixture] public class MacroStabilityInwardsKernelWrapperTests { - private const string TestFolder = @"..\..\..\Deltares.DamEngine.IntegrationTests\TestFiles"; - private readonly string inputXmlForDamEngine = Path.Combine(TestFolder, "StabilityDesign1Dbased.xml"); + private const string testFolder = @"..\..\..\Deltares.DamEngine.IntegrationTests\TestFiles"; + private readonly string inputXmlForDamEngine = Path.Combine(testFolder, "StabilityDesign1Dbased.xml"); private const double tolerance4Decimals = 0.000051; [Test] - public void TestPrepare() + [TestCase(0.8, true, false, PrepareResult.NotRelevant)] + [TestCase(1.4, true, true, PrepareResult.Successful)] + [TestCase(1.2, false, false, PrepareResult.Failed)] + public void TestPrepare(double upliftCriterionStability, bool isInputValid, bool expectedIsUplift, PrepareResult expectedPrepareResult) { + // Setup + DamKernelInput kernelInput = CreateDamKernelInputForTest(MStabModelType.UpliftVan, MStabSearchMethod.Grid, GridSizeDetermination.Specified); + kernelInput.Location.ModelFactors.UpliftCriterionStability = upliftCriterionStability; var kernelWrapper = new MacroStabilityInwardsKernelWrapper { FailureMechanismParametersMStab = new FailureMechanismParametersMStab { MStabParameters = { - Model = MStabModelType.UpliftVan + Model = kernelInput.DamFailureMechanismeCalculationSpecification.FailureMechanismParametersMStab.MStabParameters.Model, + SearchMethod = kernelInput.DamFailureMechanismeCalculationSpecification.FailureMechanismParametersMStab.MStabParameters.SearchMethod } } }; - - DamKernelInput kernelInput = CreateDamKernelInputForTest(); - - // Situation 1: no uplift. Expected PrepareResult.NotRelevant - kernelInput.Location.ModelFactors.UpliftCriterionStability = 0.8; - kernelInput.CurrentEmbankmentSoil = kernelInput.Location.GetDikeEmbankmentSoil(); + if (!isInputValid) + { + kernelInput.Location.SurfaceLine.CharacteristicPoints.Clear(); + } + + // Call PrepareResult prepareResult = kernelWrapper.Prepare(kernelInput, 0, out _, out IKernelDataOutput kernelDataOutput); - Assert.That(prepareResult, Is.EqualTo(PrepareResult.NotRelevant)); + + // Assert var damMacroStabilityOutput = (MacroStabilityOutput) kernelDataOutput; - Assert.That(damMacroStabilityOutput.CalculationResult, Is.EqualTo(CalculationResult.NoRun)); - Assert.That(damMacroStabilityOutput.UpliftSituation.IsUplift, Is.False); - - // Situation 2: there is uplift and prepare succeeds. Expected PrepareResult.Successful - kernelInput.Location.ModelFactors.UpliftCriterionStability = 1.4; - prepareResult = kernelWrapper.Prepare(kernelInput, 0, out _, out kernelDataOutput); - Assert.That(prepareResult, Is.EqualTo(PrepareResult.Successful)); - damMacroStabilityOutput = (MacroStabilityOutput) kernelDataOutput; - Assert.That(damMacroStabilityOutput.CalculationResult, Is.EqualTo(CalculationResult.NoRun)); - Assert.That(damMacroStabilityOutput.UpliftSituation.IsUplift, Is.True); - - // Situation 3: prepare fails. Expected PrepareResult.Failed - kernelInput.Location.ModelFactors.UpliftCriterionStability = 1.2; - kernelInput.Location.SurfaceLine.CharacteristicPoints.Clear(); - prepareResult = kernelWrapper.Prepare(kernelInput, 0, out _, out kernelDataOutput); - Assert.That(prepareResult, Is.EqualTo(PrepareResult.Failed)); - damMacroStabilityOutput = (MacroStabilityOutput) kernelDataOutput; - Assert.That(damMacroStabilityOutput.CalculationResult, Is.EqualTo(CalculationResult.NoRun)); + Assert.Multiple(() => + { + Assert.That(prepareResult, Is.EqualTo(expectedPrepareResult)); + Assert.That(damMacroStabilityOutput.CalculationResult, Is.EqualTo(CalculationResult.NoRun)); + Assert.That(damMacroStabilityOutput.UpliftSituation.IsUplift, Is.EqualTo(expectedIsUplift)); + }); } [Test] @@ -113,19 +109,24 @@ CalculationResult = CalculationResult.NoRun }; int errorCount = kernelWrapper.Validate(macroStabilityInput, macroStabilityOutput, out List messages); - Assert.That(errorCount, Is.GreaterThan(0)); - Assert.That(macroStabilityOutput.CalculationResult, Is.EqualTo(CalculationResult.InvalidInputData)); + Assert.Multiple(() => + { + Assert.That(errorCount, Is.GreaterThan(0)); + Assert.That(macroStabilityOutput.CalculationResult, Is.EqualTo(CalculationResult.InvalidInputData)); + }); // Validate the input when valid input is provided. Expected no messages. - DamKernelInput kernelInput = CreateDamKernelInputForTest(); - kernelInput.Location.ModelFactors.UpliftCriterionStability = 1.4; - kernelInput.CurrentEmbankmentSoil = kernelInput.Location.GetDikeEmbankmentSoil(); + DamKernelInput kernelInput = CreateDamKernelInputForTest(MStabModelType.UpliftVan, MStabSearchMethod.Grid, GridSizeDetermination.Specified); PrepareResult prepareResult = kernelWrapper.Prepare(kernelInput, 0, out IKernelDataInput kernelDataInput, out IKernelDataOutput kernelDataOutput); Assert.That(prepareResult, Is.EqualTo(PrepareResult.Successful)); messages.Clear(); + errorCount = kernelWrapper.Validate(kernelDataInput, kernelDataOutput, out messages); - Assert.That(errorCount, Is.EqualTo(0)); - Assert.That(((MacroStabilityOutput) kernelDataOutput).CalculationResult, Is.EqualTo(CalculationResult.NoRun)); + Assert.Multiple(() => + { + Assert.That(errorCount, Is.EqualTo(0)); + Assert.That(((MacroStabilityOutput)kernelDataOutput).CalculationResult, Is.EqualTo(CalculationResult.NoRun)); + }); } [Test] @@ -134,17 +135,19 @@ [TestCase(MStabModelType.BishopUpliftVan)] public void TestPostProcess(MStabModelType modelType) { + DamKernelInput kernelInput = CreateDamKernelInputForTest(modelType, MStabSearchMethod.Grid, GridSizeDetermination.Specified); var kernelWrapper = new MacroStabilityInwardsKernelWrapper { FailureMechanismParametersMStab = new FailureMechanismParametersMStab { MStabParameters = { - Model = modelType + Model = kernelInput.DamFailureMechanismeCalculationSpecification.FailureMechanismParametersMStab.MStabParameters.Model, + SearchMethod = kernelInput.DamFailureMechanismeCalculationSpecification.FailureMechanismParametersMStab.MStabParameters.SearchMethod } } }; - DamKernelInput kernelInput = CreateDamKernelInputForTest(); + var macroStabilityOutput = new MacroStabilityOutput { CalculationResult = CalculationResult.Succeeded, @@ -159,7 +162,7 @@ StabilityModelType = modelType != MStabModelType.BishopUpliftVan ? modelType : MStabModelType.Bishop, CalculationResult = CalculationResult.Succeeded, SafetyFactor = 2.34, - CalculationPath = TestFolder + "@\testpath", + CalculationPath = testFolder + "@\testpath", ProjectName = Path.GetFileNameWithoutExtension(inputXmlForDamEngine), ActiveCenterPoint = new Point2D(10, 10), ActiveCenterPointRadius = 8, @@ -339,7 +342,7 @@ Assert.Multiple(() => { Assert.That(result.BaseFileName, Is.EqualTo(Path.GetFileNameWithoutExtension(inputXmlForDamEngine))); - Assert.That(result.CalculationSubDir, Is.EqualTo(TestFolder + "@\testpath")); + Assert.That(result.CalculationSubDir, Is.EqualTo(testFolder + "@\testpath")); }); } @@ -461,20 +464,19 @@ [Test] public void TestFullCalculationSucceedsWithWarningsWithBadTangentLines() { + // Prepare the wrapper. Result is input for the calculation dll + DamKernelInput kernelInput = CreateDamKernelInputForTest(MStabModelType.UpliftVan, MStabSearchMethod.Grid, GridSizeDetermination.Specified); var kernelWrapper = new MacroStabilityInwardsKernelWrapper { FailureMechanismParametersMStab = new FailureMechanismParametersMStab { MStabParameters = { - Model = MStabModelType.UpliftVan + Model = kernelInput.DamFailureMechanismeCalculationSpecification.FailureMechanismParametersMStab.MStabParameters.Model, + SearchMethod = kernelInput.DamFailureMechanismeCalculationSpecification.FailureMechanismParametersMStab.MStabParameters.SearchMethod } } }; - - // Prepare the wrapper. Result is input for the calculation dll - DamKernelInput kernelInput = CreateDamKernelInputForTest(); - kernelInput.Location.ModelFactors.UpliftCriterionStability = 1.4; SlipCircleDefinition sd = kernelInput.DamFailureMechanismeCalculationSpecification.FailureMechanismParametersMStab .MStabParameters.SlipCircleDefinition; @@ -493,31 +495,33 @@ var macroStabilityOutput = (MacroStabilityOutput) kernelDataOutput; Assert.Multiple(() => { - Assert.That(messages, Has.Count.EqualTo(26)); + Assert.That(messages, Has.Count.EqualTo(24)); Assert.That(macroStabilityOutput.CalculationResult, Is.EqualTo(CalculationResult.Succeeded)); Assert.That(messages[0].Message, Does.Contain("A slice is beyond the geometry at x")); }); } [Test] - public void TestFullCalculationSucceeds() + [TestCase(MStabSearchMethod.Grid, GridSizeDetermination.Specified, 1.2812, 4)] + [TestCase(MStabSearchMethod.Grid, GridSizeDetermination.Automatic, 1.4752, 3)] + [TestCase(MStabSearchMethod.BeeSwarm, GridSizeDetermination.Specified, 2.2597, 3)] + [TestCase(MStabSearchMethod.BeeSwarm, GridSizeDetermination.Automatic, 1.1284, 894)] + public void TestFullCalculationSucceedsWithUpliftVan(MStabSearchMethod searchMethod, GridSizeDetermination gridSizeDetermination, double expectedSafetyFactor, int expectedLogMessageCount) { + // Prepare the wrapper. Result is input for the calculation dll + DamKernelInput kernelInput = CreateDamKernelInputForTest(MStabModelType.UpliftVan, searchMethod, gridSizeDetermination); var kernelWrapper = new MacroStabilityInwardsKernelWrapper { FailureMechanismParametersMStab = new FailureMechanismParametersMStab { MStabParameters = { - Model = MStabModelType.UpliftVan + Model = kernelInput.DamFailureMechanismeCalculationSpecification.FailureMechanismParametersMStab.MStabParameters.Model, + SearchMethod = kernelInput.DamFailureMechanismeCalculationSpecification.FailureMechanismParametersMStab.MStabParameters.SearchMethod } } }; - - // Prepare the wrapper. Result is input for the calculation dll - DamKernelInput kernelInput = CreateDamKernelInputForTest(); - // To ensure uplift occurs, set criterion to 1.4 - kernelInput.Location.ModelFactors.UpliftCriterionStability = 1.4; - kernelInput.CurrentEmbankmentSoil = kernelInput.Location.GetDikeEmbankmentSoil(); + PrepareResult prepareResult = kernelWrapper.Prepare(kernelInput, 0, out IKernelDataInput kernelDataInput, out IKernelDataOutput kernelDataOutput); Assert.That(prepareResult, Is.EqualTo(PrepareResult.Successful)); @@ -530,12 +534,20 @@ var macroStabilityOutput = (MacroStabilityOutput) kernelDataOutput; Assert.Multiple(() => { - Assert.That(messages, Has.Count.EqualTo(2)); + Assert.That(messages, Has.Count.EqualTo(expectedLogMessageCount)); Assert.That(macroStabilityOutput.CalculationResult, Is.EqualTo(CalculationResult.Succeeded)); Assert.That(macroStabilityOutput.StabilityOutputItems, Has.Count.EqualTo(1)); }); - Assert.That(macroStabilityOutput.StabilityOutputItems[0].SafetyFactor, Is.EqualTo(1.5076).Within(tolerance4Decimals)); // ToDo replace by actual value when calculation is done and output is parsed + Assert.That(macroStabilityOutput.StabilityOutputItems[0].SafetyFactor, Is.EqualTo(expectedSafetyFactor).Within(tolerance4Decimals)); + if (searchMethod == MStabSearchMethod.Grid && gridSizeDetermination == GridSizeDetermination.Specified) + { + CheckDesignResultsForUpliftVanSpecifiedGrid(kernelInput, kernelWrapper, macroStabilityOutput); + } + } + + private static void CheckDesignResultsForUpliftVanSpecifiedGrid(DamKernelInput kernelInput, MacroStabilityInwardsKernelWrapper kernelWrapper, MacroStabilityOutput macroStabilityOutput) + { // Fill the design results var designScenario = new DesignScenario { @@ -551,109 +563,58 @@ Assert.That(result.BaseFileName, Is.EqualTo("Loc(TestLocation)_Sce(1)_Pro(DefaultNameSoilProfile1D)")); Assert.That(result.CalculationSubDir, Is.EqualTo("..\\Test\\Stability\\UpliftVan")); Assert.That(result.CalculationResult, Is.EqualTo(CalculationResult.Succeeded)); - Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(1.5076).Within(tolerance4Decimals)); - Assert.That(result.StabilityDesignResults.ActiveCenterPoint.X, Is.EqualTo(50.75).Within(tolerance4Decimals)); - Assert.That(result.StabilityDesignResults.ActiveCenterPoint.Z, Is.EqualTo(12.25).Within(tolerance4Decimals)); - Assert.That(result.StabilityDesignResults.ActiveCenterPointRadius, Is.EqualTo(21).Within(tolerance4Decimals)); - Assert.That(result.StabilityDesignResults.PassiveCenterPoint.X, Is.EqualTo(50.75)); + Assert.That(result.StabilityDesignResults.SafetyFactor, Is.EqualTo(1.2812).Within(tolerance4Decimals)); + Assert.That(result.StabilityDesignResults.ActiveCenterPoint.X, Is.EqualTo(52.75).Within(tolerance4Decimals)); + Assert.That(result.StabilityDesignResults.ActiveCenterPoint.Z, Is.EqualTo(16.75).Within(tolerance4Decimals)); + Assert.That(result.StabilityDesignResults.ActiveCenterPointRadius, Is.EqualTo(17).Within(tolerance4Decimals)); + Assert.That(result.StabilityDesignResults.PassiveCenterPoint.X, Is.EqualTo(58.5)); Assert.That(result.StabilityDesignResults.PassiveCenterPoint.Z, Is.EqualTo(1.95)); - Assert.That(result.StabilityDesignResults.PassiveCenterPointRadius, Is.EqualTo(10.7)); - Assert.That(result.StabilityDesignResults.ResultSlices, Has.Count.EqualTo(36)); + Assert.That(result.StabilityDesignResults.PassiveCenterPointRadius, Is.EqualTo(2.2)); + Assert.That(result.StabilityDesignResults.ResultSlices, Has.Count.EqualTo(22)); }); Assert.Multiple(() => { Assert.That(result.StabilityDesignResults.ResultSlices[0].ShearStrengthModel, Is.EqualTo(ShearStrengthModel.CPhi)); - Assert.That(result.StabilityDesignResults.ResultSlices[0].EffectiveStress, Is.EqualTo(17.1930).Within(tolerance4Decimals)); + Assert.That(result.StabilityDesignResults.ResultSlices[0].EffectiveStress, Is.EqualTo(0.3364).Within(tolerance4Decimals)); Assert.That(result.StabilityDesignResults.ResultSlices[0].FrictionAngleInput, Is.EqualTo(31).Within(tolerance4Decimals)); Assert.That(result.StabilityDesignResults.ResultSlices[0].OCR, Is.EqualTo(double.NaN).Within(tolerance4Decimals)); - Assert.That(result.StabilityDesignResults.ResultSlices[0].NormalStress, Is.EqualTo(9.8692).Within(tolerance4Decimals)); - Assert.That(result.StabilityDesignResults.ResultSlices[0].TopLeftPoint.X, Is.EqualTo(31.2948).Within(tolerance4Decimals)); - Assert.That(result.StabilityDesignResults.ResultSlices[0].TopLeftPoint.Z, Is.EqualTo(4.3446).Within(tolerance4Decimals)); - Assert.That(result.StabilityDesignResults.ResultSlices[0].Width, Is.EqualTo(0.7994).Within(tolerance4Decimals)); - Assert.That(result.StabilityDesignResults.ResultSlices[0].Weight, Is.EqualTo(13.7446).Within(tolerance4Decimals)); + Assert.That(result.StabilityDesignResults.ResultSlices[0].NormalStress, Is.EqualTo(0.2370).Within(tolerance4Decimals)); + Assert.That(result.StabilityDesignResults.ResultSlices[0].TopLeftPoint.X, Is.EqualTo(40.4643).Within(tolerance4Decimals)); + Assert.That(result.StabilityDesignResults.ResultSlices[0].TopLeftPoint.Z, Is.EqualTo(5.000).Within(tolerance4Decimals)); + Assert.That(result.StabilityDesignResults.ResultSlices[0].Width, Is.EqualTo(0.0357).Within(tolerance4Decimals)); + Assert.That(result.StabilityDesignResults.ResultSlices[0].Weight, Is.EqualTo(0.0120).Within(tolerance4Decimals)); }); - var index = 21; + var index = 11; Assert.Multiple(() => { Assert.That(result.StabilityDesignResults.ResultSlices[index].ShearStrengthModel, Is.EqualTo(ShearStrengthModel.CPhi)); - Assert.That(result.StabilityDesignResults.ResultSlices[index].EffectiveStress, Is.EqualTo(91.9128).Within(tolerance4Decimals)); - Assert.That(result.StabilityDesignResults.ResultSlices[index].FrictionAngleInput, Is.EqualTo(10).Within(tolerance4Decimals)); + Assert.That(result.StabilityDesignResults.ResultSlices[index].EffectiveStress, Is.EqualTo(3.4795).Within(tolerance4Decimals)); + Assert.That(result.StabilityDesignResults.ResultSlices[index].FrictionAngleInput, Is.EqualTo(31).Within(tolerance4Decimals)); Assert.That(result.StabilityDesignResults.ResultSlices[index].OCR, Is.EqualTo(double.NaN).Within(tolerance4Decimals)); - Assert.That(result.StabilityDesignResults.ResultSlices[index].NormalStress, Is.EqualTo(90.8542).Within(tolerance4Decimals)); - Assert.That(result.StabilityDesignResults.ResultSlices[index].TopLeftPoint.X, Is.EqualTo(48.6818).Within(tolerance4Decimals)); - Assert.That(result.StabilityDesignResults.ResultSlices[index].TopLeftPoint.Z, Is.EqualTo(0.9091).Within(tolerance4Decimals)); - Assert.That(result.StabilityDesignResults.ResultSlices[index].Width, Is.EqualTo(0.9091).Within(tolerance4Decimals)); - Assert.That(result.StabilityDesignResults.ResultSlices[index].Weight, Is.EqualTo(160.9932).Within(tolerance4Decimals)); + Assert.That(result.StabilityDesignResults.ResultSlices[index].NormalStress, Is.EqualTo(3.2772).Within(tolerance4Decimals)); + Assert.That(result.StabilityDesignResults.ResultSlices[index].TopLeftPoint.X, Is.EqualTo(49.8453).Within(tolerance4Decimals)); + Assert.That(result.StabilityDesignResults.ResultSlices[index].TopLeftPoint.Z, Is.EqualTo(0.3274).Within(tolerance4Decimals)); + Assert.That(result.StabilityDesignResults.ResultSlices[index].Width, Is.EqualTo(0.6547).Within(tolerance4Decimals)); + Assert.That(result.StabilityDesignResults.ResultSlices[index].Weight, Is.EqualTo(2.6007).Within(tolerance4Decimals)); }); index = result.StabilityDesignResults.ResultSlices.Count - 1; Assert.Multiple(() => { Assert.That(result.StabilityDesignResults.ResultSlices[index].ShearStrengthModel, Is.EqualTo(ShearStrengthModel.CPhi)); - Assert.That(result.StabilityDesignResults.ResultSlices[index].EffectiveStress, Is.EqualTo(5.1450).Within(tolerance4Decimals)); + Assert.That(result.StabilityDesignResults.ResultSlices[index].EffectiveStress, Is.EqualTo(1.2862).Within(tolerance4Decimals)); Assert.That(result.StabilityDesignResults.ResultSlices[index].FrictionAngleInput, Is.EqualTo(31).Within(tolerance4Decimals)); Assert.That(result.StabilityDesignResults.ResultSlices[index].OCR, Is.EqualTo(double.NaN).Within(tolerance4Decimals)); - Assert.That(result.StabilityDesignResults.ResultSlices[index].NormalStress, Is.EqualTo(6.8085).Within(tolerance4Decimals)); - Assert.That(result.StabilityDesignResults.ResultSlices[index].TopLeftPoint.X, Is.EqualTo(60.2362).Within(tolerance4Decimals)); - Assert.That(result.StabilityDesignResults.ResultSlices[index].TopLeftPoint.Z, Is.EqualTo(-2.0000).Within(tolerance4Decimals)); - Assert.That(result.StabilityDesignResults.ResultSlices[index].Width, Is.EqualTo(0.4580).Within(tolerance4Decimals)); - Assert.That(result.StabilityDesignResults.ResultSlices[index].Weight, Is.EqualTo(4.6034).Within(tolerance4Decimals)); + Assert.That(result.StabilityDesignResults.ResultSlices[index].NormalStress, Is.EqualTo(1.3009).Within(tolerance4Decimals)); + Assert.That(result.StabilityDesignResults.ResultSlices[index].TopLeftPoint.X, Is.EqualTo(58.5000).Within(tolerance4Decimals)); + Assert.That(result.StabilityDesignResults.ResultSlices[index].TopLeftPoint.Z, Is.EqualTo(0.0000).Within(tolerance4Decimals)); + Assert.That(result.StabilityDesignResults.ResultSlices[index].Width, Is.EqualTo(0.1233).Within(tolerance4Decimals)); + Assert.That(result.StabilityDesignResults.ResultSlices[index].Weight, Is.EqualTo(0.3097).Within(tolerance4Decimals)); }); } } - + [Test] - public void TestFullCalculationSucceedsWithBeeSwarmAsSearchMethod() - { - var kernelWrapper = new MacroStabilityInwardsKernelWrapper - { - FailureMechanismParametersMStab = new FailureMechanismParametersMStab - { - MStabParameters = - { - Model = MStabModelType.UpliftVan, - SearchMethod = MStabSearchMethod.BeeSwarm - } - } - }; - - // Prepare the wrapper. Result is input for the calculation dll - DamKernelInput kernelInput = CreateDamKernelInputForTest(); - kernelInput.DamFailureMechanismeCalculationSpecification.FailureMechanismParametersMStab.MStabParameters - .SearchMethod = MStabSearchMethod.BeeSwarm; - // To ensure uplift occurs, set criterion to 1.4 - kernelInput.Location.ModelFactors.UpliftCriterionStability = 1.4; - kernelInput.CurrentEmbankmentSoil = kernelInput.Location.GetDikeEmbankmentSoil(); - PrepareResult prepareResult = - kernelWrapper.Prepare(kernelInput, 0, out IKernelDataInput kernelDataInput, out IKernelDataOutput kernelDataOutput); - Assert.That(prepareResult, Is.EqualTo(PrepareResult.Successful)); - - // Validate the input - int errorCount = kernelWrapper.Validate(kernelDataInput, kernelDataOutput, out List messages); - Assert.That(errorCount, Is.EqualTo(0)); - - // Run the dll - kernelWrapper.Execute(kernelDataInput, kernelDataOutput, out messages); - var macroStabilityOutput = (MacroStabilityOutput) kernelDataOutput; - Assert.Multiple(() => - { - Assert.That(messages, Has.Count.EqualTo(3)); - Assert.That(macroStabilityOutput.CalculationResult, Is.EqualTo(CalculationResult.Succeeded)); - Assert.That(macroStabilityOutput.StabilityOutputItems, Has.Count.EqualTo(1)); - }); - // SafetyFactor as obtained when running the skx file with this input in the stability kernel directly = 1.9882432331086863 - Assert.That(macroStabilityOutput.StabilityOutputItems[0].SafetyFactor, Is.EqualTo(1.4798).Within(tolerance4Decimals)); - - // Fill the design results - var designScenario = new DesignScenario - { - LocationName = kernelInput.Location.Name - }; - kernelWrapper.PostProcess(kernelInput, macroStabilityOutput, designScenario, "", out List results); - Assert.That(results.Count, Is.GreaterThan(0)); - } - - [Test] public void CalculationUpliftBasedOnDamEngineXmlWorks() { const string calcDir = "TestStabInwardsBishop"; @@ -708,7 +669,7 @@ Assert.That(() => kernelWrapper.PostProcess(null, null, null, "", out _), Throws.InstanceOf().With.Message.EqualTo("Geen Dam invoer object gedefinieerd voor Macrostabiliteit")); } - private static DamKernelInput CreateDamKernelInputForTest() + private static DamKernelInput CreateDamKernelInputForTest(MStabModelType modelType, MStabSearchMethod searchMethod, GridSizeDetermination gridSizeDetermination) { Location location = DamEngineDataTestFactory.CreateLocation(FactoryForSurfaceLines.CreateSurfaceLineTutorial1()); // Correction needed in order to make surface line as lengthy as needed to perform a proper calculation. @@ -717,6 +678,8 @@ // now this not allowed by the kernel validator!) So that needs to be fixed in the kernel). location.SurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DitchPolderSide).X = 62.5; location.SurfaceLine.Geometry.SyncCalcPoints(); + // To ensure uplift occurs, set criterion to 1.4 + location.ModelFactors.UpliftCriterionStability = 1.4; SoilProfile1D soilProfile = DamEngineDataTestFactory.CreateSoilProfile1D(location.SoilList); SetWaterPressureInterpolationModel(soilProfile.Layers); @@ -753,9 +716,13 @@ sd.UpliftVanRightGridVerticalPointDistance = 1; sd.UpliftVanTangentLinesDefinition = TangentLinesDefinition.OnBoundaryLines; sd.UpliftVanTangentLinesDistance = 1; - sd.GridSizeDetermination = GridSizeDetermination.Specified; - damKernelInput.DamFailureMechanismeCalculationSpecification.FailureMechanismParametersMStab.MStabParameters.Model = - MStabModelType.UpliftVan; + sd.GridSizeDetermination = gridSizeDetermination; + + damKernelInput.DamFailureMechanismeCalculationSpecification.FailureMechanismParametersMStab.MStabParameters.Model = modelType; + damKernelInput.DamFailureMechanismeCalculationSpecification.FailureMechanismParametersMStab.MStabParameters.SearchMethod = searchMethod; + + damKernelInput.CurrentEmbankmentSoil = damKernelInput.Location.GetDikeEmbankmentSoil(); + return damKernelInput; }