public void CreateExtremeWaternetForUpliftVan_ValidData_ReturnMacroStabilityInput() { // Setup UpliftVanCalculatorInput input = UpliftVanCalculatorInputTestFactory.Create(); LayerWithSoil[] layersWithSoil = LayerWithSoilCreator.Create(input.SoilProfile, out IDictionary <SoilLayer, LayerWithSoil> _); List <Soil> soils = layersWithSoil.Select(lws => lws.Soil).ToList(); SurfaceLine surfaceLine = SurfaceLineCreator.Create(input.SurfaceLine); SoilProfile soilProfile = SoilProfileCreator.Create(layersWithSoil); // Call MacroStabilityInput macroStabilityInput = MacroStabilityInputCreator.CreateExtremeWaternetForUpliftVan( input, soils, surfaceLine, soilProfile); // Assert CollectionAssert.AreEqual(soils, macroStabilityInput.StabilityModel.Soils, new SoilComparer()); Assert.AreSame(soilProfile, macroStabilityInput.StabilityModel.ConstructionStages.Single().SoilProfile); PreConstructionStage preConstructionStage = macroStabilityInput.PreprocessingInput.PreConstructionStages.Single(); Assert.AreSame(surfaceLine, preConstructionStage.SurfaceLine); Assert.IsTrue(preConstructionStage.CreateWaternet); KernelInputAssert.AssertWaternetCreatorInput(UpliftVanWaternetCreatorInputCreator.CreateExtreme(input), preConstructionStage.WaternetCreatorInput); }
public void Create_GlobalSurfaceLine_ProjectSurfaceLineIntoLZPlaneSpannedByFirstAndLastPoint() { // Setup const string name = "Global coordinate surface line"; var surfaceLine = new MacroStabilityInwardsSurfaceLine(name); surfaceLine.SetGeometry(new[] { new Point3D(1.0, 1.0, 2.2), new Point3D(2.0, 3.0, 4.4), // Outlier from line specified by extrema new Point3D(3.0, 4.0, 7.7) }); // Call SurfaceLine actual = SurfaceLineCreator.Create(surfaceLine); // Assert double length = Math.Sqrt(2 * 2 + 3 * 3); const double secondCoordinateFactor = (2.0 * 1.0 + 3.0 * 2.0) / (2.0 * 2.0 + 3.0 * 3.0); double[] expectedCoordinatesX = { 0.0, secondCoordinateFactor *length, length }; CollectionAssert.AreEqual(expectedCoordinatesX, actual.CharacteristicPoints.Select(p => p.GeometryPoint.X), new DoubleWithToleranceComparer(1e-2)); CollectionAssert.AreEqual(surfaceLine.Points.Select(p => p.Z), actual.CharacteristicPoints.Select(p => p.GeometryPoint.Z)); Assert.IsTrue(actual.CharacteristicPoints.All(cp => cp.CharacteristicPointType == CharacteristicPointType.None)); }
public void CreateUpliftVan_ValidDataWithManualTangentLines_ReturnMacroStabilityInput() { // Setup var random = new Random(21); double tangentZTop = random.NextDouble(); double tangentZBottom = random.NextDouble(); int tangentLineNumber = random.Next(); UpliftVanCalculatorInput input = UpliftVanCalculatorInputTestFactory.Create(tangentZTop, tangentZBottom, tangentLineNumber); LayerWithSoil[] layersWithSoil = LayerWithSoilCreator.Create(input.SoilProfile, out IDictionary <SoilLayer, LayerWithSoil> layerLookup); List <Soil> soils = layersWithSoil.Select(lws => lws.Soil).ToList(); SurfaceLine surfaceLine = SurfaceLineCreator.Create(input.SurfaceLine); SoilProfile soilProfile = SoilProfileCreator.Create(layersWithSoil); var dailyWaternet = new Waternet(); var extremeWaternet = new Waternet(); // Call MacroStabilityInput macroStabilityInput = MacroStabilityInputCreator.CreateUpliftVan( input, soils, layerLookup, surfaceLine, soilProfile, dailyWaternet, extremeWaternet); // Assert SearchAreaConditions searchAreaConditions = macroStabilityInput.PreprocessingInput.SearchAreaConditions; Assert.AreEqual(input.SlipPlane.TangentLinesAutomaticAtBoundaries, searchAreaConditions.AutoTangentLines); Assert.AreEqual(input.SlipPlane.TangentLineNumber, searchAreaConditions.TangentLineNumber); Assert.AreEqual(input.SlipPlane.TangentZTop, searchAreaConditions.TangentLineZTop); Assert.AreEqual(input.SlipPlane.TangentZBottom, searchAreaConditions.TangentLineZBottom); }
private IUpliftVanKernel CreateUpliftVanKernel() { LayerWithSoil[] layersWithSoil = LayerWithSoilCreator.Create(input.SoilProfile, out IDictionary <SoilLayer, LayerWithSoil> layerLookup); List <Soil> soils = layersWithSoil.Select(lws => lws.Soil).ToList(); SurfaceLine surfaceLine = SurfaceLineCreator.Create(input.SurfaceLine); SoilProfile soilProfile = SoilProfileCreator.Create(layersWithSoil); MacroStabilityInput waternetDailyKernelInput = MacroStabilityInputCreator.CreateDailyWaternetForUpliftVan(input, soils, surfaceLine, soilProfile); MacroStabilityInput waternetExtremeKernelInput = MacroStabilityInputCreator.CreateExtremeWaternetForUpliftVan(input, soils, surfaceLine, soilProfile); IWaternetKernel waternetDailyKernel = factory.CreateWaternetDailyKernel(waternetDailyKernelInput); waternetDailyKernel.Calculate(); IWaternetKernel waternetExtremeKernel = factory.CreateWaternetExtremeKernel(waternetExtremeKernelInput); waternetExtremeKernel.Calculate(); MacroStabilityInput kernelInput = MacroStabilityInputCreator.CreateUpliftVan(input, soils, layerLookup, surfaceLine, soilProfile, waternetDailyKernel.Waternet, waternetExtremeKernel.Waternet); return(factory.CreateUpliftVanKernel(kernelInput)); }
public void Create_SurfaceLineWithAllCharacteristicPoints_CreateSurfaceLineWithGeometryAndCharacteristicPoints() { // Setup const string name = "Surface line with characteristic points"; var geometry = new[] { new Point3D(0, 0, 0), new Point3D(1, 0, 2), new Point3D(2, 0, 3), new Point3D(3, 0, 0), new Point3D(4, 0, 2), new Point3D(5, 0, 3), new Point3D(6, 0, 0), new Point3D(7, 0, 2), new Point3D(8, 0, 3), new Point3D(9, 0, 0), new Point3D(10, 0, 2), new Point3D(11, 0, 3) }; var surfaceLine = new MacroStabilityInwardsSurfaceLine(name); surfaceLine.SetGeometry(geometry); surfaceLine.SetBottomDitchDikeSideAt(geometry[0]); surfaceLine.SetBottomDitchPolderSideAt(geometry[1]); surfaceLine.SetDikeToeAtPolderAt(geometry[2]); surfaceLine.SetDikeToeAtRiverAt(geometry[3]); surfaceLine.SetDikeTopAtPolderAt(geometry[4]); surfaceLine.SetDitchDikeSideAt(geometry[5]); surfaceLine.SetDitchPolderSideAt(geometry[6]); surfaceLine.SetSurfaceLevelInsideAt(geometry[7]); surfaceLine.SetSurfaceLevelOutsideAt(geometry[8]); surfaceLine.SetShoulderBaseInsideAt(geometry[9]); surfaceLine.SetShoulderTopInsideAt(geometry[10]); surfaceLine.SetDikeTopAtRiverAt(geometry[11]); // Call SurfaceLine actual = SurfaceLineCreator.Create(surfaceLine); // Assert IEnumerable <double> expectedCoordinatesX = surfaceLine.Points.Select(p => p.X); IEnumerable <double> expectedCoordinatesZ = surfaceLine.Points.Select(p => p.Z); CollectionAssert.AreEqual(expectedCoordinatesX, actual.CharacteristicPoints.Select(p => p.GeometryPoint.X)); CollectionAssert.AreEqual(expectedCoordinatesZ, actual.CharacteristicPoints.Select(p => p.GeometryPoint.Z)); Assert.AreEqual(CharacteristicPointType.BottomDitchDikeSide, actual.CharacteristicPoints.ElementAt(0).CharacteristicPointType); Assert.AreEqual(CharacteristicPointType.BottomDitchPolderSide, actual.CharacteristicPoints.ElementAt(1).CharacteristicPointType); Assert.AreEqual(CharacteristicPointType.DikeToeAtPolder, actual.CharacteristicPoints.ElementAt(2).CharacteristicPointType); Assert.AreEqual(CharacteristicPointType.DikeToeAtRiver, actual.CharacteristicPoints.ElementAt(3).CharacteristicPointType); Assert.AreEqual(CharacteristicPointType.DikeTopAtPolder, actual.CharacteristicPoints.ElementAt(4).CharacteristicPointType); Assert.AreEqual(CharacteristicPointType.DitchDikeSide, actual.CharacteristicPoints.ElementAt(5).CharacteristicPointType); Assert.AreEqual(CharacteristicPointType.DitchPolderSide, actual.CharacteristicPoints.ElementAt(6).CharacteristicPointType); Assert.AreEqual(CharacteristicPointType.SurfaceLevelInside, actual.CharacteristicPoints.ElementAt(7).CharacteristicPointType); Assert.AreEqual(CharacteristicPointType.SurfaceLevelOutside, actual.CharacteristicPoints.ElementAt(8).CharacteristicPointType); Assert.AreEqual(CharacteristicPointType.ShoulderBaseInside, actual.CharacteristicPoints.ElementAt(9).CharacteristicPointType); Assert.AreEqual(CharacteristicPointType.ShoulderTopInside, actual.CharacteristicPoints.ElementAt(10).CharacteristicPointType); Assert.AreEqual(CharacteristicPointType.DikeTopAtRiver, actual.CharacteristicPoints.ElementAt(11).CharacteristicPointType); }
public void Create_SurfaceLineNull_ThrowsArgumentNullException() { // Call void Call() => SurfaceLineCreator.Create(null); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("surfaceLine", exception.ParamName); }
public void Create_SurfaceLineWithoutPoints_CreateSurfaceLineWithoutPoints() { // Setup const string name = "Surface line without points"; var surfaceLine = new MacroStabilityInwardsSurfaceLine(name); // Call SurfaceLine actual = SurfaceLineCreator.Create(surfaceLine); // Assert CollectionAssert.IsEmpty(actual.CharacteristicPoints); }
public void CreateWaternet_ValidData_ReturnMacroStabilityInput() { // Setup WaternetCalculatorInput input = WaternetCalculatorInputTestFactory.CreateValidCalculatorInput(); // Call MacroStabilityInput macroStabilityInput = MacroStabilityInputCreator.CreateWaternet(input); // Assert LayerWithSoil[] layersWithSoil = LayerWithSoilCreator.Create(input.SoilProfile, out IDictionary <SoilLayer, LayerWithSoil> _); CollectionAssert.AreEqual(layersWithSoil.Select(lws => lws.Soil).ToList(), macroStabilityInput.StabilityModel.Soils, new SoilComparer()); KernelInputAssert.AssertSoilProfile(SoilProfileCreator.Create(layersWithSoil), macroStabilityInput.StabilityModel.ConstructionStages.Single().SoilProfile); PreConstructionStage preConstructionStage = macroStabilityInput.PreprocessingInput.PreConstructionStages.Single(); KernelInputAssert.AssertSurfaceLine(SurfaceLineCreator.Create(input.SurfaceLine), preConstructionStage.SurfaceLine); Assert.IsTrue(preConstructionStage.CreateWaternet); KernelInputAssert.AssertWaternetCreatorInput(WaternetCreatorInputCreator.Create(input), preConstructionStage.WaternetCreatorInput); }
public void Create_NormalizedLocalSurfaceLine_ReturnsSurfaceLineWithIdenticalPoints() { // Setup const string name = "Local coordinate surface line"; var surfaceLine = new MacroStabilityInwardsSurfaceLine(name); surfaceLine.SetGeometry(new[] { new Point3D(0.0, 0.0, 1.1), new Point3D(2.2, 0.0, 3.3), new Point3D(4.4, 0.0, 5.5) }); // Call SurfaceLine actual = SurfaceLineCreator.Create(surfaceLine); // Assert CollectionAssert.AreEqual(surfaceLine.Points.Select(p => p.X), actual.CharacteristicPoints.Select(p => p.GeometryPoint.X)); CollectionAssert.AreEqual(surfaceLine.Points.Select(p => p.Z), actual.CharacteristicPoints.Select(p => p.GeometryPoint.Z)); Assert.IsTrue(actual.CharacteristicPoints.All(cp => cp.CharacteristicPointType == CharacteristicPointType.None)); }
public void Calculate_CalculatorWithCompleteInput_InputCorrectlySetToKernel() { // Setup UpliftVanCalculatorInput input = UpliftVanCalculatorInputTestFactory.Create(); using (new MacroStabilityInwardsKernelFactoryConfig()) { var factory = (TestMacroStabilityInwardsKernelFactory)MacroStabilityInwardsKernelWrapperFactory.Instance; UpliftVanKernelStub upliftVanKernel = factory.LastCreatedUpliftVanKernel; WaternetKernelStub waternetDailyKernel = factory.LastCreatedWaternetDailyKernel; WaternetKernelStub waternetExtremeKernel = factory.LastCreatedWaternetExtremeKernel; SetValidKernelOutput(waternetDailyKernel); SetValidKernelOutput(waternetExtremeKernel); SetValidKernelOutput(upliftVanKernel); LayerWithSoil[] layersWithSoil = LayerWithSoilCreator.Create(input.SoilProfile, out IDictionary <SoilLayer, LayerWithSoil> layerLookup); List <Soil> soils = layersWithSoil.Select(lws => lws.Soil).ToList(); SurfaceLine surfaceLine = SurfaceLineCreator.Create(input.SurfaceLine); CSharpWrapperSoilProfile soilProfile = SoilProfileCreator.Create(layersWithSoil); // Call new UpliftVanCalculator(input, factory).Calculate(); // Assert WaternetKernelInputAssert.AssertMacroStabilityInput( MacroStabilityInputCreator.CreateDailyWaternetForUpliftVan(input, soils, surfaceLine, soilProfile), waternetDailyKernel.KernelInput); WaternetKernelInputAssert.AssertMacroStabilityInput( MacroStabilityInputCreator.CreateExtremeWaternetForUpliftVan(input, soils, surfaceLine, soilProfile), waternetExtremeKernel.KernelInput); UpliftVanKernelInputAssert.AssertMacroStabilityInput( MacroStabilityInputCreator.CreateUpliftVan( input, soils, layerLookup, surfaceLine, soilProfile, waternetDailyKernel.Waternet, waternetExtremeKernel.Waternet), upliftVanKernel.KernelInput); } }
public void Create_LocalSurfaceLineNotNormalized_TranslateAllPointsToMakeFirstCoordinateZeroX() { // Setup const string name = "Local coordinate surface line"; const double firstX = 4.6; var surfaceLine = new MacroStabilityInwardsSurfaceLine(name); surfaceLine.SetGeometry(new[] { new Point3D(firstX, 0.0, 1.1), new Point3D(7.8, 0.0, 3.3), new Point3D(9.9, 0.0, 5.5) }); // Call SurfaceLine actual = SurfaceLineCreator.Create(surfaceLine); // Assert double[] expectedCoordinatesX = surfaceLine.Points.Select(p => p.X - firstX).ToArray(); CollectionAssert.AreEqual(expectedCoordinatesX, actual.CharacteristicPoints.Select(p => p.GeometryPoint.X), new DoubleWithToleranceComparer(1e-2)); CollectionAssert.AreEqual(surfaceLine.Points.Select(p => p.Z), actual.CharacteristicPoints.Select(p => p.GeometryPoint.Z)); Assert.IsTrue(actual.CharacteristicPoints.All(cp => cp.CharacteristicPointType == CharacteristicPointType.None)); }
public void Create_SurfaceLineWithOnlyOnePoint_CreateSurfaceLineWithOnePoint() { // Setup const string name = "Global coordinate surface line"; var surfaceLine = new MacroStabilityInwardsSurfaceLine(name); surfaceLine.SetGeometry(new[] { new Point3D(1.0, 1.0, 2.2) }); // Call SurfaceLine actual = SurfaceLineCreator.Create(surfaceLine); // Assert double[] expectedCoordinatesX = { 0.0 }; CollectionAssert.AreEqual(expectedCoordinatesX, actual.CharacteristicPoints.Select(p => p.GeometryPoint.X)); CollectionAssert.AreEqual(surfaceLine.Points.Select(p => p.Z), actual.CharacteristicPoints.Select(p => p.GeometryPoint.Z)); Assert.IsTrue(actual.CharacteristicPoints.All(cp => cp.CharacteristicPointType == CharacteristicPointType.None)); }
public void CreateUpliftVan_ValidData_ReturnMacroStabilityInput() { // Setup UpliftVanCalculatorInput input = UpliftVanCalculatorInputTestFactory.Create(); LayerWithSoil[] layersWithSoil = LayerWithSoilCreator.Create(input.SoilProfile, out IDictionary <SoilLayer, LayerWithSoil> layerLookup); List <Soil> soils = layersWithSoil.Select(lws => lws.Soil).ToList(); SurfaceLine surfaceLine = SurfaceLineCreator.Create(input.SurfaceLine); SoilProfile soilProfile = SoilProfileCreator.Create(layersWithSoil); var dailyWaternet = new Waternet(); var extremeWaternet = new Waternet(); // Call MacroStabilityInput macroStabilityInput = MacroStabilityInputCreator.CreateUpliftVan( input, soils, layerLookup, surfaceLine, soilProfile, dailyWaternet, extremeWaternet); // Assert StabilityInput stabilityModel = macroStabilityInput.StabilityModel; Assert.AreEqual(Orientation.Inwards, stabilityModel.Orientation); Assert.AreEqual(SearchAlgorithm.Grid, stabilityModel.SearchAlgorithm); Assert.AreEqual(StabilityModelOptionType.UpliftVan, stabilityModel.ModelOption); CollectionAssert.AreEqual(soils, stabilityModel.Soils, new SoilComparer()); Assert.AreEqual(input.MoveGrid, stabilityModel.MoveGrid); Assert.AreEqual(input.MaximumSliceWidth, stabilityModel.MaximumSliceWidth); UpliftVanKernelInputAssert.AssertUpliftVanCalculationGrid( UpliftVanCalculationGridCreator.Create(input.SlipPlane), stabilityModel.UpliftVanCalculationGrid); UpliftVanKernelInputAssert.AssertSlipPlaneConstraints( SlipPlaneConstraintsCreator.Create(input.SlipPlaneConstraints), stabilityModel.SlipPlaneConstraints); AssertConstructionStages(input, stabilityModel, soilProfile, dailyWaternet, extremeWaternet, layerLookup); Assert.AreEqual(input.SlipPlane.GridNumberOfRefinements, stabilityModel.NumberOfRefinementsGrid); Assert.AreEqual(input.SlipPlane.TangentLineNumberOfRefinements, stabilityModel.NumberOfRefinementsTangentLines); SearchAreaConditions searchAreaConditions = macroStabilityInput.PreprocessingInput.SearchAreaConditions; Assert.AreEqual(0.8, searchAreaConditions.MaxSpacingBetweenBoundaries); Assert.IsTrue(searchAreaConditions.OnlyAbovePleistoceen); Assert.AreEqual(input.SlipPlane.GridAutomaticDetermined, searchAreaConditions.AutoSearchArea); Assert.AreEqual(input.SlipPlane.TangentLinesAutomaticAtBoundaries, searchAreaConditions.AutoTangentLines); Assert.AreEqual(1, searchAreaConditions.TangentLineNumber); Assert.AreEqual(0, searchAreaConditions.TangentLineZTop); Assert.AreEqual(0, searchAreaConditions.TangentLineZBottom); Assert.AreEqual(input.SlipPlaneConstraints.AutomaticForbiddenZones, searchAreaConditions.AutomaticForbiddenZones); Assert.AreEqual(2, macroStabilityInput.PreprocessingInput.PreConstructionStages.Count); foreach (PreConstructionStage preConstructionStage in macroStabilityInput.PreprocessingInput.PreConstructionStages) { Assert.IsFalse(preConstructionStage.CreateWaternet); Assert.AreSame(surfaceLine, preConstructionStage.SurfaceLine); Assert.IsNull(preConstructionStage.WaternetCreatorInput); // Not needed as Waternet is already calculated } AssertIrrelevantValues(stabilityModel, searchAreaConditions); }