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);
        }
Exemplo n.º 2
0
        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 CreateUpliftVan_LayerLookupNull_ThrowsArgumentNullException()
        {
            // Call
            void Call() => MacroStabilityInputCreator.CreateUpliftVan(
                UpliftVanCalculatorInputTestFactory.Create(), new List <Soil>(),
                null, new SurfaceLine(), new SoilProfile(), new Waternet(), new Waternet());

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(Call);

            Assert.AreEqual("layerLookup", exception.ParamName);
        }
        public void CreateUpliftVan_UpliftVanInputNull_ThrowsArgumentNullException()
        {
            // Call
            void Call() => MacroStabilityInputCreator.CreateUpliftVan(
                null, new List <Soil>(), new Dictionary <SoilLayer, LayerWithSoil>(),
                new SurfaceLine(), new SoilProfile(), new Waternet(), new Waternet());

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(Call);

            Assert.AreEqual("upliftVanInput", exception.ParamName);
        }
Exemplo n.º 5
0
        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 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);
        }