private static void SetGridParametersToEntity(MacroStabilityInwardsCalculationEntity entity,
                                                      MacroStabilityInwardsGrid leftGrid,
                                                      MacroStabilityInwardsGrid rightGrid)
        {
            entity.LeftGridXLeft  = leftGrid.XLeft.ToNaNAsNull();
            entity.LeftGridXRight = leftGrid.XRight.ToNaNAsNull();
            entity.LeftGridNrOfHorizontalPoints = leftGrid.NumberOfHorizontalPoints;
            entity.LeftGridZTop               = leftGrid.ZTop.ToNaNAsNull();
            entity.LeftGridZBottom            = leftGrid.ZBottom.ToNaNAsNull();
            entity.LeftGridNrOfVerticalPoints = leftGrid.NumberOfVerticalPoints;

            entity.RightGridXLeft  = rightGrid.XLeft.ToNaNAsNull();
            entity.RightGridXRight = rightGrid.XRight.ToNaNAsNull();
            entity.RightGridNrOfHorizontalPoints = rightGrid.NumberOfHorizontalPoints;
            entity.RightGridZTop               = rightGrid.ZTop.ToNaNAsNull();
            entity.RightGridZBottom            = rightGrid.ZBottom.ToNaNAsNull();
            entity.RightGridNrOfVerticalPoints = rightGrid.NumberOfVerticalPoints;
        }
        public void Clone_Always_ReturnNewInstanceWithCopiedValues()
        {
            // Setup
            var random   = new Random(21);
            var original = new MacroStabilityInwardsGrid(random.NextDouble(0.0, 1.0),
                                                         random.NextDouble(1.0, 2.0),
                                                         random.NextDouble(1.0, 2.0),
                                                         random.NextDouble(0.0, 1.0))
            {
                NumberOfHorizontalPoints = random.Next(1, 100),
                NumberOfVerticalPoints   = random.Next(1, 100)
            };

            // Call
            object clone = original.Clone();

            // Assert
            CoreCloneAssert.AreObjectClones(original, clone, MacroStabilityInwardsCloneAssert.AreClones);
        }
Ejemplo n.º 3
0
        private void SetChartData()
        {
            MacroStabilityInwardsInput       macroStabilityInwardsInput = data.InputParameters;
            MacroStabilityInwardsSurfaceLine surfaceLine = macroStabilityInwardsInput.SurfaceLine;
            IMacroStabilityInwardsSoilProfile <IMacroStabilityInwardsSoilLayer> soilProfile = macroStabilityInwardsInput.StochasticSoilProfile?.SoilProfile;

            hydraulicLocationCalculationObserver.Observable = getHydraulicBoundaryLocationCalculationFunc();

            SetSurfaceLineChartData(surfaceLine);
            SetSoilProfileChartData(surfaceLine, soilProfile);

            SetWaternetExtremeChartData(DerivedMacroStabilityInwardsInput.GetWaternetExtreme(macroStabilityInwardsInput, generalInput, GetEffectiveAssessmentLevel()), surfaceLine);
            SetWaternetDailyChartData(DerivedMacroStabilityInwardsInput.GetWaternetDaily(macroStabilityInwardsInput, generalInput), surfaceLine);

            MacroStabilityInwardsGridDeterminationType gridDeterminationType = macroStabilityInwardsInput.GridDeterminationType;
            MacroStabilityInwardsGrid leftGrid  = macroStabilityInwardsInput.LeftGrid;
            MacroStabilityInwardsGrid rightGrid = macroStabilityInwardsInput.RightGrid;

            leftGridChartData.Points  = MacroStabilityInwardsChartDataPointsFactory.CreateGridPoints(leftGrid, gridDeterminationType);
            rightGridChartData.Points = MacroStabilityInwardsChartDataPointsFactory.CreateGridPoints(rightGrid, gridDeterminationType);

            tangentLinesData.Lines = MacroStabilityInwardsChartDataPointsFactory.CreateTangentLines(macroStabilityInwardsInput.GridDeterminationType,
                                                                                                    macroStabilityInwardsInput.TangentLineDeterminationType,
                                                                                                    macroStabilityInwardsInput.TangentLineZBottom,
                                                                                                    macroStabilityInwardsInput.TangentLineZTop,
                                                                                                    macroStabilityInwardsInput.TangentLineNumber,
                                                                                                    macroStabilityInwardsInput.SurfaceLine);

            currentSoilProfile = soilProfile;
            if (surfaceLine != null)
            {
                if (currentSurfaceLine == null)
                {
                    currentSurfaceLine = new MacroStabilityInwardsSurfaceLine(surfaceLine.Name);
                }

                currentSurfaceLine.CopyProperties(surfaceLine);
            }
            else
            {
                currentSurfaceLine = null;
            }
        }
        public void Create_WithValidValues_ReturnsEntityWithExpectedPropertiesSet()
        {
            // Setup
            var random = new Random(21);

            MacroStabilityInwardsSlidingCircle leftCircle = CreateSlidingCircle(13);
            MacroStabilityInwardsSlidingCircle rightCircle = CreateSlidingCircle(34);
            IEnumerable<MacroStabilityInwardsSlice> slices = new[]
            {
                MacroStabilityInwardsSliceTestFactory.CreateSlice()
            };
            var slidingCurve = new MacroStabilityInwardsSlidingCurve(leftCircle,
                                                                     rightCircle,
                                                                     slices,
                                                                     random.NextDouble(),
                                                                     random.NextDouble());

            MacroStabilityInwardsGrid leftGrid = MacroStabilityInwardsGridTestFactory.Create();
            MacroStabilityInwardsGrid rightGrid = MacroStabilityInwardsGridTestFactory.Create();
            RoundedDouble[] tangentLines =
            {
                random.NextRoundedDouble()
            };
            var slipPlane = new MacroStabilityInwardsSlipPlaneUpliftVan(leftGrid, rightGrid, tangentLines);

            var output = new MacroStabilityInwardsOutput(slidingCurve, slipPlane, new MacroStabilityInwardsOutput.ConstructionProperties
            {
                FactorOfStability = random.NextDouble(),
                ForbiddenZonesXEntryMax = random.NextDouble(),
                ForbiddenZonesXEntryMin = random.NextDouble()
            });

            // Call
            MacroStabilityInwardsCalculationOutputEntity entity = output.Create();

            // Assert
            Assert.IsNotNull(entity);
            MacroStabilityInwardsCalculationOutputEntityTestHelper.AssertOutputPropertyValues(output, entity);
        }
        public void GetProperties_WithData_ReturnExpectedValues()
        {
            // Setup
            var mocks         = new MockRepository();
            var changeHandler = mocks.Stub <IObservablePropertyChangeHandler>();

            mocks.ReplayAll();

            MacroStabilityInwardsGrid grid = MacroStabilityInwardsGridTestFactory.Create();

            // Call
            var properties = new MacroStabilityInwardsGridProperties(grid, changeHandler, false);

            // Assert
            Assert.AreEqual(grid.XLeft, properties.XLeft);
            Assert.AreEqual(grid.XRight, properties.XRight);
            Assert.AreEqual(grid.ZTop, properties.ZTop);
            Assert.AreEqual(grid.ZBottom, properties.ZBottom);
            Assert.AreEqual(grid.NumberOfHorizontalPoints, properties.NumberOfHorizontalPoints);
            Assert.AreEqual(grid.NumberOfVerticalPoints, properties.NumberOfVerticalPoints);
            mocks.VerifyAll();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates grid points in 2D space based on the provided <paramref name="grid"/>.
        /// </summary>
        /// <param name="grid">The grid to create the grid points for.</param>
        /// <returns>A collection of interpolated points in 2D space based on the provided
        /// <paramref name="grid"/> or an empty collection when:
        /// <list type="bullet">
        /// <item><paramref name="grid"/> is <c>null</c>;</item>
        /// <item>The grid boundaries are <see cref="double.NaN"/>.</item>
        /// </list>
        /// </returns>
        public static IEnumerable <Point2D> CreateGridPoints(MacroStabilityInwardsGrid grid)
        {
            if (grid == null || !AreGridSettingsValid(grid))
            {
                return(new Point2D[0]);
            }

            var points = new List <Point2D>();
            IEnumerable <RoundedDouble> interPolatedVerticalPositions = GetInterPolatedVerticalPositions(grid.ZBottom,
                                                                                                         grid.ZTop,
                                                                                                         grid.NumberOfVerticalPoints);

            foreach (RoundedDouble interPolatedVerticalPosition in interPolatedVerticalPositions)
            {
                points.AddRange(GetInterPolatedHorizontalPoints(grid.XLeft,
                                                                grid.XRight,
                                                                interPolatedVerticalPosition,
                                                                grid.NumberOfHorizontalPoints));
            }

            return(points);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Tries to assign the grid x left and x right parameters to the <paramref name="grid"/>.
        /// </summary>
        /// <param name="gridConfiguration">The grid configuration read from the imported file.</param>
        /// <param name="grid">The calculation grid to configure.</param>
        /// <param name="calculationName">The name of the read calculation.</param>
        /// <returns><c>true</c> if no x left and x right was given, or when x left and x right
        /// are set to the <paramref name="grid"/>, <c>false</c> otherwise.</returns>
        private bool TrySetGridXLeftXRight(MacroStabilityInwardsGridConfiguration gridConfiguration,
                                           MacroStabilityInwardsGrid grid,
                                           string calculationName)
        {
            bool hasXLeftValue  = gridConfiguration.XLeft.HasValue;
            bool hasXRightValue = gridConfiguration.XRight.HasValue;

            if (!hasXLeftValue && !hasXRightValue)
            {
                return(true);
            }

            RoundedDouble xLeft = hasXLeftValue
                                      ? (RoundedDouble)gridConfiguration.XLeft.Value
                                      : RoundedDouble.NaN;

            RoundedDouble xRight = hasXRightValue
                                       ? (RoundedDouble)gridConfiguration.XRight.Value
                                       : RoundedDouble.NaN;

            try
            {
                grid.XLeft  = xLeft;
                grid.XRight = xRight;
            }
            catch (ArgumentException e)
            {
                Log.LogCalculationConversionError(string.Format(Resources.MacroStabilityInwardsCalculationConfigurationImporter_TrySetGridXLeftXRight_Combination_of_XLeft_0_and_XRight_1_invalid_Reason_2,
                                                                xLeft.ToPrecision(grid.XLeft.NumberOfDecimalPlaces),
                                                                xRight.ToPrecision(grid.XRight.NumberOfDecimalPlaces),
                                                                e.Message),
                                                  calculationName);

                return(false);
            }

            return(true);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Tries to assign the grid Z top and Z bottom parameters to the <paramref name="grid"/>.
        /// </summary>
        /// <param name="gridConfiguration">The grid configuration read from the imported file.</param>
        /// <param name="grid">The calculation grid to configure.</param>
        /// <param name="calculationName">The name of the read calculation.</param>
        /// <returns><c>true</c> if no z top and z bottom was given, or when z top and z bottom
        /// are set to the <paramref name="grid"/>, <c>false</c> otherwise.</returns>
        private bool TrySetGridZTopZBottom(MacroStabilityInwardsGridConfiguration gridConfiguration,
                                           MacroStabilityInwardsGrid grid,
                                           string calculationName)
        {
            bool hasZTopValue    = gridConfiguration.ZTop.HasValue;
            bool hasZBottomValue = gridConfiguration.ZBottom.HasValue;

            if (!hasZTopValue && !hasZBottomValue)
            {
                return(true);
            }

            RoundedDouble zTop = hasZTopValue
                                     ? (RoundedDouble)gridConfiguration.ZTop.Value
                                     : RoundedDouble.NaN;

            RoundedDouble zBottom = hasZBottomValue
                                        ? (RoundedDouble)gridConfiguration.ZBottom.Value
                                        : RoundedDouble.NaN;

            try
            {
                grid.ZTop    = zTop;
                grid.ZBottom = zBottom;
            }
            catch (ArgumentException e)
            {
                Log.LogCalculationConversionError(string.Format(Resources.MacroStabilityInwardsCalculationConfigurationImporter_TrySetGridZTopZBottom_Combination_of_ZTop_0_and_ZBottom_1_invalid_Reason_2,
                                                                zTop.ToPrecision(grid.ZTop.NumberOfDecimalPlaces),
                                                                zBottom.ToPrecision(grid.ZBottom.NumberOfDecimalPlaces),
                                                                e.Message),
                                                  calculationName);

                return(false);
            }

            return(true);
        }
        private static void SetSlipPlaneParametersToEntity(MacroStabilityInwardsCalculationOutputEntity entity,
                                                           MacroStabilityInwardsSlipPlaneUpliftVan slipPlane)
        {
            entity.SlipPlaneTangentLinesXml = new TangentLineCollectionXmlSerializer().ToXml(slipPlane.TangentLines);

            MacroStabilityInwardsGrid leftGrid = slipPlane.LeftGrid;

            entity.SlipPlaneLeftGridXLeft  = leftGrid.XLeft.ToNaNAsNull();
            entity.SlipPlaneLeftGridXRight = leftGrid.XRight.ToNaNAsNull();
            entity.SlipPlaneLeftGridNrOfHorizontalPoints = leftGrid.NumberOfHorizontalPoints;
            entity.SlipPlaneLeftGridZTop               = leftGrid.ZTop.ToNaNAsNull();
            entity.SlipPlaneLeftGridZBottom            = leftGrid.ZBottom.ToNaNAsNull();
            entity.SlipPlaneLeftGridNrOfVerticalPoints = leftGrid.NumberOfVerticalPoints;

            MacroStabilityInwardsGrid rightGrid = slipPlane.RightGrid;

            entity.SlipPlaneRightGridXLeft  = rightGrid.XLeft.ToNaNAsNull();
            entity.SlipPlaneRightGridXRight = rightGrid.XRight.ToNaNAsNull();
            entity.SlipPlaneRightGridNrOfHorizontalPoints = rightGrid.NumberOfHorizontalPoints;
            entity.SlipPlaneRightGridZTop               = rightGrid.ZTop.ToNaNAsNull();
            entity.SlipPlaneRightGridZBottom            = rightGrid.ZBottom.ToNaNAsNull();
            entity.SlipPlaneRightGridNrOfVerticalPoints = rightGrid.NumberOfVerticalPoints;
        }
        public void Constructor_ExpectedValues()
        {
            // Call
            var grid = new MacroStabilityInwardsGrid(double.NaN, double.NaN, double.NaN, double.NaN);

            // Assert
            Assert.IsInstanceOf <ICloneable>(grid);

            Assert.IsNaN(grid.XLeft);
            Assert.AreEqual(2, grid.XLeft.NumberOfDecimalPlaces);

            Assert.IsNaN(grid.XRight);
            Assert.AreEqual(2, grid.XRight.NumberOfDecimalPlaces);

            Assert.IsNaN(grid.ZTop);
            Assert.AreEqual(2, grid.ZTop.NumberOfDecimalPlaces);

            Assert.IsNaN(grid.ZBottom);
            Assert.AreEqual(2, grid.ZBottom.NumberOfDecimalPlaces);

            Assert.AreEqual(5, grid.NumberOfHorizontalPoints);
            Assert.AreEqual(5, grid.NumberOfVerticalPoints);
        }
Ejemplo n.º 11
0
        private static MacroStabilityInwardsSlipPlaneUpliftVan ReadSlipPlane(MacroStabilityInwardsCalculationOutputEntity entity)
        {
            var leftGrid = new MacroStabilityInwardsGrid(entity.SlipPlaneLeftGridXLeft.ToNullAsNaN(),
                                                         entity.SlipPlaneLeftGridXRight.ToNullAsNaN(),
                                                         entity.SlipPlaneLeftGridZTop.ToNullAsNaN(),
                                                         entity.SlipPlaneLeftGridZBottom.ToNullAsNaN())
            {
                NumberOfHorizontalPoints = entity.SlipPlaneLeftGridNrOfHorizontalPoints,
                NumberOfVerticalPoints   = entity.SlipPlaneLeftGridNrOfVerticalPoints
            };
            var rightGrid = new MacroStabilityInwardsGrid(entity.SlipPlaneRightGridXLeft.ToNullAsNaN(),
                                                          entity.SlipPlaneRightGridXRight.ToNullAsNaN(),
                                                          entity.SlipPlaneRightGridZTop.ToNullAsNaN(),
                                                          entity.SlipPlaneRightGridZBottom.ToNullAsNaN()
                                                          )
            {
                NumberOfHorizontalPoints = entity.SlipPlaneRightGridNrOfHorizontalPoints,
                NumberOfVerticalPoints   = entity.SlipPlaneRightGridNrOfVerticalPoints
            };

            RoundedDouble[] tangentLines = new TangentLineCollectionXmlSerializer().FromXml(entity.SlipPlaneTangentLinesXml);
            return(new MacroStabilityInwardsSlipPlaneUpliftVan(leftGrid, rightGrid, tangentLines));
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Configure a new <see cref="MacroStabilityInwardsGridConfiguration"/> with
        /// values taken from <paramref name="macroStabilityInwardsGrid"/>.
        /// </summary>
        /// <param name="macroStabilityInwardsGrid">The grid to take the values from.</param>
        /// <returns>A new <see cref="MacroStabilityInwardsGridConfiguration"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="macroStabilityInwardsGrid"/> is <c>null</c>.</exception>
        public static MacroStabilityInwardsGridConfiguration ToMacroStabilityInwardsGridConfiguration(this MacroStabilityInwardsGrid macroStabilityInwardsGrid)
        {
            if (macroStabilityInwardsGrid == null)
            {
                throw new ArgumentNullException(nameof(macroStabilityInwardsGrid));
            }

            return(new MacroStabilityInwardsGridConfiguration
            {
                XLeft = macroStabilityInwardsGrid.XLeft,
                XRight = macroStabilityInwardsGrid.XRight,
                ZTop = macroStabilityInwardsGrid.ZTop,
                ZBottom = macroStabilityInwardsGrid.ZBottom,
                NumberOfHorizontalPoints = macroStabilityInwardsGrid.NumberOfHorizontalPoints,
                NumberOfVerticalPoints = macroStabilityInwardsGrid.NumberOfVerticalPoints
            });
        }
Ejemplo n.º 13
0
 private static UpliftVanGrid ConvertGrid(MacroStabilityInwardsGrid grid)
 {
     return(new UpliftVanGrid(grid.XLeft, grid.XRight, grid.ZTop, grid.ZBottom, grid.NumberOfHorizontalPoints, grid.NumberOfVerticalPoints));
 }
        public void Constructor_ValidData_PropertiesHaveExpectedAttributesValues(bool isReadOnly)
        {
            // Setup
            var mocks         = new MockRepository();
            var changeHandler = mocks.Stub <IObservablePropertyChangeHandler>();

            mocks.ReplayAll();

            MacroStabilityInwardsGrid grid = MacroStabilityInwardsGridTestFactory.Create();

            // Call
            var properties = new MacroStabilityInwardsGridProperties(grid, changeHandler, isReadOnly);

            // Assert
            PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);

            Assert.AreEqual(6, dynamicProperties.Count);

            const string gridCategory = "Grid";

            PropertyDescriptor xLeftProperty = dynamicProperties[expectedXLeftPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(
                xLeftProperty,
                gridCategory,
                "X links [m]",
                "Horizontale coördinaat van de linker kant van het rekengrid.",
                isReadOnly);

            PropertyDescriptor xRightProperty = dynamicProperties[expectedXRightPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(
                xRightProperty,
                gridCategory,
                "X rechts [m]",
                "Horizontale coördinaat van de rechter kant van het rekengrid.",
                isReadOnly);

            PropertyDescriptor zTopProperty = dynamicProperties[expectedZTopPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(
                zTopProperty,
                gridCategory,
                "Z boven [m+NAP]",
                "Verticale coördinaat van de bovenkant van het rekengrid.",
                isReadOnly);

            PropertyDescriptor zBottomProperty = dynamicProperties[expectedZBottomPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(
                zBottomProperty,
                gridCategory,
                "Z onder [m+NAP]",
                "Verticale coördinaat van de onderkant van het rekengrid.",
                isReadOnly);

            PropertyDescriptor numberOfHorizontalPointsProperty = dynamicProperties[expectedNumberOfHorizontalPointsPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(
                numberOfHorizontalPointsProperty,
                gridCategory,
                "Aantal horizontale punten",
                "Aantal punten waarmee het grid wordt samengesteld in horizontale richting.",
                isReadOnly);

            PropertyDescriptor numberOfVerticalPointsProperty = dynamicProperties[expectedNumberOfVerticalPointsPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(
                numberOfVerticalPointsProperty,
                gridCategory,
                "Aantal verticale punten",
                "Aantal punten waarmee het grid wordt samengesteld in verticale richting.",
                isReadOnly);

            mocks.VerifyAll();
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Creates grid points in 2D space based on the provided <paramref name="grid"/>.
 /// </summary>
 /// <param name="grid">The grid to create the grid points for.</param>
 /// <param name="gridDeterminationType">The grid determination type.</param>
 /// <returns>A collection of interpolated points in 2D space based on the provided
 /// <paramref name="grid"/> or an empty collection when:
 /// <list type="bullet">
 /// <item><paramref name="grid"/> is <c>null</c>;</item>
 /// <item><paramref name="gridDeterminationType"/> is <see cref="MacroStabilityInwardsGridDeterminationType.Automatic"/>;</item>
 /// <item>The grid boundaries are <see cref="double.NaN"/>.</item>
 /// </list>
 /// </returns>
 public static IEnumerable <Point2D> CreateGridPoints(MacroStabilityInwardsGrid grid, MacroStabilityInwardsGridDeterminationType gridDeterminationType)
 {
     return(gridDeterminationType == MacroStabilityInwardsGridDeterminationType.Automatic
                ? new Point2D[0]
                : CreateGridPoints(grid));
 }