Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/UpliftVanCalculator.cs =================================================================== diff -u -rc07f72d9a77743ab37c2ec417890c003399c6d75 -r5acabb007f107c284b99ef7140fb127da93fb7f7 --- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/UpliftVanCalculator.cs (.../UpliftVanCalculator.cs) (revision c07f72d9a77743ab37c2ec417890c003399c6d75) +++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/UpliftVanCalculator.cs (.../UpliftVanCalculator.cs) (revision 5acabb007f107c284b99ef7140fb127da93fb7f7) @@ -114,20 +114,21 @@ private IUpliftVanKernel CreateUpliftVanKernel() { LayerWithSoil[] layersWithSoil = LayerWithSoilCreator.Create(input.SoilProfile, out IDictionary layerLookup); + List soils = layersWithSoil.Select(lws => lws.Soil).ToList(); SurfaceLine surfaceLine = SurfaceLineCreator.Create(input.SurfaceLine); SoilProfile soilProfile = SoilProfileCreator.Create(layersWithSoil); - MacroStabilityInput waternetDailyKernelInput = MacroStabilityInputCreator.CreateDailyWaternetForUpliftVan(input, layersWithSoil, surfaceLine, soilProfile); - MacroStabilityInput waternetExtremeKernelInput = MacroStabilityInputCreator.CreateExtremeWaternetForUpliftVan(input, layersWithSoil, surfaceLine, soilProfile); + MacroStabilityInput waternetDailyKernelInput = MacroStabilityInputCreator.CreateDailyWaternetForUpliftVan(input, soils, surfaceLine, soilProfile); + MacroStabilityInput waternetExtremeKernelInput = MacroStabilityInputCreator.CreateExtremeWaternetForUpliftVan(input, soils, surfaceLine, soilProfile); IWaternetKernel waternetDailyKernelWrapper = factory.CreateWaternetDailyKernel(waternetDailyKernelInput); waternetDailyKernelWrapper.Calculate(); IWaternetKernel waternetExtremeKernelWrapper = factory.CreateWaternetExtremeKernel(waternetExtremeKernelInput); waternetExtremeKernelWrapper.Calculate(); - MacroStabilityInput kernelInput = MacroStabilityInputCreator.CreateUpliftVan(input, layersWithSoil, layerLookup, + MacroStabilityInput kernelInput = MacroStabilityInputCreator.CreateUpliftVan(input, soils, layerLookup, surfaceLine, soilProfile, waternetDailyKernelWrapper.Waternet, waternetExtremeKernelWrapper.Waternet); Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.KernelWrapper/Creators/Input/MacroStabilityInputCreator.cs =================================================================== diff -u -r08c064ff60c918a0368124ae6a2a75d7a063f805 -r5acabb007f107c284b99ef7140fb127da93fb7f7 --- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.KernelWrapper/Creators/Input/MacroStabilityInputCreator.cs (.../MacroStabilityInputCreator.cs) (revision 08c064ff60c918a0368124ae6a2a75d7a063f805) +++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.KernelWrapper/Creators/Input/MacroStabilityInputCreator.cs (.../MacroStabilityInputCreator.cs) (revision 5acabb007f107c284b99ef7140fb127da93fb7f7) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Collections.Generic; using System.Linq; using Deltares.MacroStability.CSharpWrapper; @@ -27,18 +28,72 @@ using Riskeer.MacroStabilityInwards.KernelWrapper.Calculators.Input; using Riskeer.MacroStabilityInwards.KernelWrapper.Calculators.UpliftVan.Input; using Riskeer.MacroStabilityInwards.KernelWrapper.Calculators.Waternet.Input; +using Riskeer.MacroStabilityInwards.KernelWrapper.Kernels.UpliftVan; +using Riskeer.MacroStabilityInwards.KernelWrapper.Kernels.Waternet; using KernelPreconsolidationStress = Deltares.MacroStability.CSharpWrapper.Input.PreconsolidationStress; using SoilProfile = Deltares.MacroStability.CSharpWrapper.Input.SoilProfile; using WaternetCreationMode = Deltares.MacroStability.CSharpWrapper.Input.WaternetCreationMode; namespace Riskeer.MacroStabilityInwards.KernelWrapper.Creators.Input { + /// + /// Creates instances which are required + /// by and . + /// internal static class MacroStabilityInputCreator { - public static MacroStabilityInput CreateUpliftVan(UpliftVanCalculatorInput upliftVanInput, IEnumerable layersWithSoil, + /// + /// Creates objects based on the given input for the Uplift Van calculation. + /// + /// The containing all the values required + /// for performing the Uplift Van calculation. + /// The collection of . + /// The lookup between for and + /// The . + /// The . + /// The calculated for daily circumstances. + /// The calculated for extreme circumstances. + /// The created . + /// Thrown when any parameter is null. + public static MacroStabilityInput CreateUpliftVan(UpliftVanCalculatorInput upliftVanInput, ICollection soils, IDictionary layerLookup, SurfaceLine surfaceLine, SoilProfile soilProfile, Waternet dailyWaternet, Waternet extremeWaternet) { + if (upliftVanInput == null) + { + throw new ArgumentNullException(nameof(upliftVanInput)); + } + + if (soils == null) + { + throw new ArgumentNullException(nameof(soils)); + } + + if (layerLookup == null) + { + throw new ArgumentNullException(nameof(layerLookup)); + } + + if (surfaceLine == null) + { + throw new ArgumentNullException(nameof(surfaceLine)); + } + + if (soilProfile == null) + { + throw new ArgumentNullException(nameof(soilProfile)); + } + + if (dailyWaternet == null) + { + throw new ArgumentNullException(nameof(dailyWaternet)); + } + + if (extremeWaternet == null) + { + throw new ArgumentNullException(nameof(extremeWaternet)); + } + return new MacroStabilityInput { StabilityModel = @@ -52,7 +107,7 @@ PreconsolidationStressCreator.Create(upliftVanInput.SoilProfile.PreconsolidationStresses).ToList()), AddConstructionStage(soilProfile, extremeWaternet) }, - Soils = layersWithSoil.Select(lws => lws.Soil).ToList(), + Soils = soils, MoveGrid = upliftVanInput.MoveGrid, MaximumSliceWidth = upliftVanInput.MaximumSliceWidth, UpliftVanCalculationGrid = UpliftVanCalculationGridCreator.Create(upliftVanInput.SlipPlane), @@ -80,26 +135,101 @@ }; } - public static MacroStabilityInput CreateDailyWaternetForUpliftVan(UpliftVanCalculatorInput upliftVanInput, IEnumerable layersWithSoil, - SurfaceLine surfaceLine, SoilProfile soilProfile) + /// + /// Creates objects based on the given input for the daily waternet calculation. + /// + /// The containing all the values required + /// for performing the Waternet calculation. + /// The collection of . + /// The . + /// The . + /// The created . + /// Thrown when any parameter is null. + public static MacroStabilityInput CreateDailyWaternetForUpliftVan(UpliftVanCalculatorInput upliftVanInput, ICollection soils, + SurfaceLine surfaceLine, SoilProfile soilProfile) { - return CreateWaternet(layersWithSoil, surfaceLine, soilProfile, UpliftVanWaternetCreatorInputCreator.CreateDaily(upliftVanInput)); + if (upliftVanInput == null) + { + throw new ArgumentNullException(nameof(upliftVanInput)); + } + + if (soils == null) + { + throw new ArgumentNullException(nameof(soils)); + } + + if (surfaceLine == null) + { + throw new ArgumentNullException(nameof(surfaceLine)); + } + + if (soilProfile == null) + { + throw new ArgumentNullException(nameof(soilProfile)); + } + + return CreateWaternet(soils, surfaceLine, soilProfile, UpliftVanWaternetCreatorInputCreator.CreateDaily(upliftVanInput)); } - public static MacroStabilityInput CreateExtremeWaternetForUpliftVan(UpliftVanCalculatorInput upliftVanInput, IEnumerable layersWithSoil, - SurfaceLine surfaceLine, SoilProfile soilProfile) + /// + /// Creates objects based on the given input for the extreme waternet calculation. + /// + /// The containing all the values required + /// for performing the Waternet calculation. + /// The collection of . + /// The . + /// The . + /// The created . + /// Thrown when any parameter is null. + public static MacroStabilityInput CreateExtremeWaternetForUpliftVan(UpliftVanCalculatorInput upliftVanInput, ICollection soils, + SurfaceLine surfaceLine, SoilProfile soilProfile) { - return CreateWaternet(layersWithSoil, surfaceLine, soilProfile, UpliftVanWaternetCreatorInputCreator.CreateExtreme(upliftVanInput)); + if (upliftVanInput == null) + { + throw new ArgumentNullException(nameof(upliftVanInput)); + } + + if (soils == null) + { + throw new ArgumentNullException(nameof(soils)); + } + + if (surfaceLine == null) + { + throw new ArgumentNullException(nameof(surfaceLine)); + } + + if (soilProfile == null) + { + throw new ArgumentNullException(nameof(soilProfile)); + } + + return CreateWaternet(soils, surfaceLine, soilProfile, UpliftVanWaternetCreatorInputCreator.CreateExtreme(upliftVanInput)); } - public static MacroStabilityInput CreateWaternet(WaternetCalculatorInput input) + /// + /// Creates objects based on the given input for the waternet calculation. + /// + /// The containing all the values required + /// for performing the Waternet calculation. + /// The created . + /// Thrown when any parameter is null. + public static MacroStabilityInput CreateWaternet(WaternetCalculatorInput waternetInput) { - LayerWithSoil[] layersWithSoil = LayerWithSoilCreator.Create(input.SoilProfile, out IDictionary _); - return CreateWaternet(layersWithSoil, SurfaceLineCreator.Create(input.SurfaceLine), - SoilProfileCreator.Create(layersWithSoil), WaternetCreatorInputCreator.Create(input)); + if (waternetInput == null) + { + throw new ArgumentNullException(nameof(waternetInput)); + } + + LayerWithSoil[] layersWithSoil = LayerWithSoilCreator.Create(waternetInput.SoilProfile, out IDictionary _); + return CreateWaternet( + layersWithSoil.Select(lws => lws.Soil).ToList(), + SurfaceLineCreator.Create(waternetInput.SurfaceLine), + SoilProfileCreator.Create(layersWithSoil), + WaternetCreatorInputCreator.Create(waternetInput)); } - private static MacroStabilityInput CreateWaternet(IEnumerable layersWithSoil, SurfaceLine surfaceLine, + private static MacroStabilityInput CreateWaternet(ICollection soils, SurfaceLine surfaceLine, SoilProfile soilProfile, WaternetCreatorInput waternetCreatorInput) { return new MacroStabilityInput @@ -113,7 +243,7 @@ SoilProfile = soilProfile } }, - Soils = layersWithSoil.Select(lws => lws.Soil).ToList() + Soils = soils }, PreprocessingInput = { Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanCalculatorTest.cs =================================================================== diff -u -r920ba77e301ed424167f375e29c4505544ab7794 -r5acabb007f107c284b99ef7140fb127da93fb7f7 --- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanCalculatorTest.cs (.../UpliftVanCalculatorTest.cs) (revision 920ba77e301ed424167f375e29c4505544ab7794) +++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanCalculatorTest.cs (.../UpliftVanCalculatorTest.cs) (revision 5acabb007f107c284b99ef7140fb127da93fb7f7) @@ -137,11 +137,12 @@ UpliftVanKernelStub upliftVanKernel = factory.LastCreatedUpliftVanKernel; LayerWithSoil[] layersWithSoil = LayerWithSoilCreator.Create(input.SoilProfile, out IDictionary layerLookup); + List soils = layersWithSoil.Select(lws => lws.Soil).ToList(); SurfaceLine surfaceLine = SurfaceLineCreator.Create(input.SurfaceLine); CSharpWrapperSoilProfile soilProfile = SoilProfileCreator.Create(layersWithSoil); - MacroStabilityInput dailyWaternetInputForUpliftVan = MacroStabilityInputCreator.CreateDailyWaternetForUpliftVan(input, layersWithSoil, surfaceLine, soilProfile); - MacroStabilityInput extremeWaternetInputForUpliftVan = MacroStabilityInputCreator.CreateExtremeWaternetForUpliftVan(input, layersWithSoil, surfaceLine, soilProfile); + MacroStabilityInput dailyWaternetInputForUpliftVan = MacroStabilityInputCreator.CreateDailyWaternetForUpliftVan(input, soils, surfaceLine, soilProfile); + MacroStabilityInput extremeWaternetInputForUpliftVan = MacroStabilityInputCreator.CreateExtremeWaternetForUpliftVan(input, soils, surfaceLine, soilProfile); WaternetKernelStub waternetDailyKernel = (WaternetKernelStub) factory.CreateWaternetDailyKernel(dailyWaternetInputForUpliftVan); WaternetKernelStub waternetExtremeKernel = (WaternetKernelStub) factory.CreateWaternetExtremeKernel(extremeWaternetInputForUpliftVan); @@ -155,7 +156,7 @@ WaternetKernelInputAssert.AssertMacroStabilityInput(extremeWaternetInputForUpliftVan, waternetExtremeKernel.KernelInput); UpliftVanKernelInputAssert.AssertMacroStabilityInput( MacroStabilityInputCreator.CreateUpliftVan( - input, layersWithSoil, layerLookup, surfaceLine, soilProfile, + input, soils, layerLookup, surfaceLine, soilProfile, waternetDailyKernel.Waternet, waternetExtremeKernel.Waternet), upliftVanKernel.KernelInput); }