コード例 #1
0
        public void CreateSoilLayerAreas_SurfaceLineOnTopOrAboveSoilLayer_ReturnsSoilLayerPointsAsRectangle()
        {
            // Setup
            var surfaceLine = new PipingSurfaceLine(string.Empty);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0, 0, 4),
                new Point3D(0, 0, 3.2),
                new Point3D(2, 0, 4)
            });
            var soilLayer   = new PipingSoilLayer(3.2);
            var soilProfile = new PipingSoilProfile("name", 2.0, new[]
            {
                soilLayer
            }, SoilProfileType.SoilProfile1D);

            // Call
            IEnumerable <Point2D[]> areas = PipingChartDataPointsFactory.CreateSoilLayerAreas(soilLayer, soilProfile, surfaceLine).ToList();

            // Assert
            Assert.AreEqual(1, areas.Count());
            CollectionAssert.AreEqual(new[]
            {
                new Point2D(0, 3.2),
                new Point2D(2, 3.2),
                new Point2D(2, 2),
                new Point2D(0, 2)
            }, areas.ElementAt(0));
        }
コード例 #2
0
        public void SetCharacteristicPoints_DikeToesReversed_ThrowsImportedDataTransformException()
        {
            // Setup
            const string name   = "Reversed dike toes";
            var          points = new CharacteristicPoints(name)
            {
                DikeToeAtPolder       = new Point3D(3, 2, 5),
                DikeToeAtRiver        = new Point3D(3.4, 3, 8),
                DitchDikeSide         = new Point3D(4.4, 6, 8),
                BottomDitchDikeSide   = new Point3D(5.1, 6, 6.5),
                BottomDitchPolderSide = new Point3D(8.5, 7.2, 4.2),
                DitchPolderSide       = new Point3D(9.6, 7.5, 3.9)
            };
            var surfaceLine = new PipingSurfaceLine(string.Empty);

            surfaceLine.SetGeometry(CharacteristicPointsToGeometry(points));

            // Call
            TestDelegate test = () => surfaceLine.SetCharacteristicPoints(points);

            // Assert
            var exception = Assert.Throws <ImportedDataTransformException>(test);

            Assert.AreEqual($"Het uittredepunt moet landwaarts van het intredepunt liggen voor locatie '{name}'.", exception.Message);
        }
コード例 #3
0
        private PipingSurfaceLine CreateSurfaceLine(Random random)
        {
            var surfaceLine = new PipingSurfaceLine(nameof(PipingSurfaceLine))
            {
                ReferenceLineIntersectionWorldPoint = new Point2D(random.NextDouble(), random.NextDouble())
            };

            var geometryPoints = new Point3D[10];

            for (var i = 0; i < 10; i++)
            {
                geometryPoints[i] = new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble());
            }

            surfaceLine.SetGeometry(geometryPoints);

            surfaceLine.SetBottomDitchDikeSideAt(geometryPoints[1]);
            surfaceLine.SetBottomDitchPolderSideAt(geometryPoints[2]);
            surfaceLine.SetDikeToeAtPolderAt(geometryPoints[3]);
            surfaceLine.SetDikeToeAtRiverAt(geometryPoints[4]);
            surfaceLine.SetDitchDikeSideAt(geometryPoints[5]);
            surfaceLine.SetDitchPolderSideAt(geometryPoints[7]);

            return(surfaceLine);
        }
コード例 #4
0
        /// <summary>
        /// Creates piping input with multiple aquifer layers under the surface line.
        /// </summary>
        /// <param name="expectedThickness">The expected thickness of the aquifer.</param>
        /// <returns>A new <see cref="PipingInput"/>.</returns>
        public static PipingInput CreateInputWithMultipleAquiferLayersUnderSurfaceLine(out double expectedThickness)
        {
            var surfaceLine = new PipingSurfaceLine(string.Empty);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0, 0, 3.3),
                new Point3D(1.0, 0, 3.3)
            });
            var stochasticSoilProfile = new PipingStochasticSoilProfile(
                0.0, new PipingSoilProfile(string.Empty, 0, new[]
            {
                new PipingSoilLayer(4.3)
                {
                    IsAquifer = false
                },
                new PipingSoilLayer(3.3)
                {
                    IsAquifer = true
                },
                new PipingSoilLayer(1.1)
                {
                    IsAquifer = true
                }
            }, SoilProfileType.SoilProfile1D));
            var input = new TestPipingInput
            {
                SurfaceLine           = surfaceLine,
                StochasticSoilProfile = stochasticSoilProfile,
                ExitPointL            = (RoundedDouble)0.5
            };

            expectedThickness = 3.3;
            return(input);
        }
コード例 #5
0
        /// <summary>
        /// Creates piping input with an aquifer layer.
        /// </summary>
        /// <param name="thicknessAquiferLayer">The thickness of the aquifer layer.</param>
        /// <returns>A new <see cref="PipingInput"/>.</returns>
        public static PipingInput CreateInputWithAquifer(double thicknessAquiferLayer = 1.0)
        {
            var surfaceLine = new PipingSurfaceLine(string.Empty);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0, 0, 0.0),
                new Point3D(1.0, 0, 0.0)
            });
            var stochasticSoilProfile = new PipingStochasticSoilProfile(
                0.0, new PipingSoilProfile(string.Empty, -thicknessAquiferLayer, new[]
            {
                new PipingSoilLayer(0.0)
                {
                    IsAquifer = true
                }
            }, SoilProfileType.SoilProfile1D));

            return(new TestPipingInput
            {
                SurfaceLine = surfaceLine,
                StochasticSoilProfile = stochasticSoilProfile,
                ExitPointL = (RoundedDouble)0.5
            });
        }
コード例 #6
0
        public void ChildNodeObjects_Always_ReturnsChildrenOfData()
        {
            // Setup
            var assessmentSection  = mocks.Stub <IAssessmentSection>();
            var pipingSurfaceLine1 = new PipingSurfaceLine("Line A");
            var pipingSurfaceLine2 = new PipingSurfaceLine("Line B");

            var surfaceLines = new PipingSurfaceLineCollection();

            surfaceLines.AddRange(new[]
            {
                pipingSurfaceLine1,
                pipingSurfaceLine2
            }, "path");

            var failureMechanism = new PipingFailureMechanism();

            var pipingSurfaceLineContext = new PipingSurfaceLinesContext(surfaceLines, failureMechanism, assessmentSection);

            mocks.ReplayAll();

            // Call
            object[] objects = info.ChildNodeObjects(pipingSurfaceLineContext);

            // Assert
            CollectionAssert.AreEqual(new[]
            {
                pipingSurfaceLine1,
                pipingSurfaceLine2
            }, objects);
        }
コード例 #7
0
        private static CalculationGroup CreateCalculationGroup(PipingSurfaceLine surfaceLine,
                                                               bool generateSemiProbabilistic,
                                                               bool generateProbabilistic,
                                                               IEnumerable <PipingStochasticSoilModel> soilModels)
        {
            var calculationGroup = new CalculationGroup
            {
                Name = surfaceLine.Name
            };
            IEnumerable <PipingStochasticSoilModel> stochasticSoilModels = GetStochasticSoilModelsForSurfaceLine(surfaceLine, soilModels);

            foreach (PipingStochasticSoilModel stochasticSoilModel in stochasticSoilModels)
            {
                foreach (PipingStochasticSoilProfile soilProfile in stochasticSoilModel.StochasticSoilProfiles)
                {
                    if (generateSemiProbabilistic)
                    {
                        calculationGroup.Children.Add(
                            CreateCalculationScenario <SemiProbabilisticPipingCalculationScenario>(
                                surfaceLine, stochasticSoilModel, soilProfile,
                                calculationGroup.Children));
                    }

                    if (generateProbabilistic)
                    {
                        calculationGroup.Children.Add(
                            CreateCalculationScenario <ProbabilisticPipingCalculationScenario>(
                                surfaceLine, stochasticSoilModel, soilProfile,
                                calculationGroup.Children));
                    }
                }
            }

            return(calculationGroup);
        }
コード例 #8
0
        public void GivenPipingInputViewWithSoilProfileSeries_WhenSurfaceLineSetToNull_ThenCollectionOfEmptyChartDataSetForSoilProfiles()
        {
            // Given
            using (var view = new PipingInputView())
            {
                PipingSurfaceLine           surfaceLine           = GetSurfaceLineWithGeometry();
                PipingStochasticSoilProfile stochasticSoilProfile = GetStochasticSoilProfile();
                var calculation = new TestPipingCalculationScenario(new TestPipingInput())
                {
                    InputParameters =
                    {
                        SurfaceLine           = surfaceLine,
                        StochasticSoilProfile = stochasticSoilProfile
                    }
                };

                view.Data = calculation;

                ChartDataCollection chartData = view.Chart.Data;

                // Precondition
                Assert.IsNotNull(chartData);
                Assert.AreEqual(10, chartData.Collection.Count());
                AssertSoilProfileChartData(stochasticSoilProfile, chartData.Collection.ElementAt(soilProfileIndex), true);

                // When
                calculation.InputParameters.SurfaceLine = null;
                calculation.InputParameters.NotifyObservers();

                // Then
                AssertSoilProfileChartData(stochasticSoilProfile, chartData.Collection.ElementAt(soilProfileIndex), false);
            }
        }
コード例 #9
0
        private static PipingSurfaceLine GetSurfaceLine(Point3D[] points)
        {
            var surfaceLine = new PipingSurfaceLine("Surface line name");

            surfaceLine.SetGeometry(points);
            return(surfaceLine);
        }
コード例 #10
0
        internal static PipingSurfaceLine GetSurfaceLine()
        {
            var surfaceLine = new PipingSurfaceLine(string.Empty);
            var firstCharacteristicPointLocation  = new Point3D(0.2, 0.0, bottom + 3 * top / 4);
            var secondCharacteristicPointLocation = new Point3D(0.3, 0.0, bottom + 2 * top / 4);
            var thirdCharacteristicPointLocation  = new Point3D(0.4, 0.0, bottom + top / 4);
            var fourthCharacteristicPointLocation = new Point3D(0.5, 0.0, bottom + 2 * top / 4);
            var fifthCharacteristicPointLocation  = new Point3D(0.6, 0.0, bottom + 3 * top / 4);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0.0, 0.0, 0.0),
                firstCharacteristicPointLocation,
                secondCharacteristicPointLocation,
                thirdCharacteristicPointLocation,
                fourthCharacteristicPointLocation,
                fifthCharacteristicPointLocation,
                new Point3D(1.0, 0.0, top)
            });
            surfaceLine.SetDikeToeAtPolderAt(firstCharacteristicPointLocation);
            surfaceLine.SetDitchDikeSideAt(secondCharacteristicPointLocation);
            surfaceLine.SetBottomDitchDikeSideAt(thirdCharacteristicPointLocation);
            surfaceLine.SetBottomDitchPolderSideAt(fourthCharacteristicPointLocation);
            surfaceLine.SetDitchPolderSideAt(fifthCharacteristicPointLocation);
            surfaceLine.ReferenceLineIntersectionWorldPoint = new Point2D(0.0, 0.0);

            return(surfaceLine);
        }
コード例 #11
0
        public void Data_WithSurfaceLineWithoutStochasticSoilProfile_CollectionOfEmptyChartDataSetForSoilProfile()
        {
            // Setup
            using (var view = new PipingInputView())
            {
                PipingSurfaceLine surfaceLine = GetSurfaceLineWithGeometry();
                var calculation = new TestPipingCalculationScenario(new TestPipingInput())
                {
                    InputParameters =
                    {
                        SurfaceLine = surfaceLine
                    }
                };

                // Call
                view.Data = calculation;

                // Assert
                Assert.AreSame(calculation, view.Data);
                ChartDataCollection chartData = view.Chart.Data;
                Assert.IsInstanceOf <ChartDataCollection>(chartData);
                Assert.AreEqual(10, chartData.Collection.Count());
                var soilProfileData = (ChartDataCollection)chartData.Collection.ElementAt(soilProfileIndex);
                CollectionAssert.IsEmpty(soilProfileData.Collection);
                Assert.AreEqual("Ondergrondschematisatie", soilProfileData.Name);
            }
        }
コード例 #12
0
        private static PipingSurfaceLine CreateSurfaceLineWithCharacteristicPoints(string name = "Name A")
        {
            var surfaceLine = new PipingSurfaceLine(name)
            {
                ReferenceLineIntersectionWorldPoint = new Point2D(0, 0)
            };
            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)
            };

            surfaceLine.SetGeometry(geometry);
            surfaceLine.SetBottomDitchDikeSideAt(geometry[0]);
            surfaceLine.SetBottomDitchPolderSideAt(geometry[1]);
            surfaceLine.SetDikeToeAtPolderAt(geometry[2]);
            surfaceLine.SetDikeToeAtRiverAt(geometry[3]);
            surfaceLine.SetDitchDikeSideAt(geometry[4]);
            surfaceLine.SetDitchPolderSideAt(geometry[5]);

            return(surfaceLine);
        }
コード例 #13
0
        /// <summary>
        /// This method sets random data values to all properties of <paramref name="input"/>.
        /// </summary>
        /// <param name="input">The input to set the random data values to.</param>
        public static void SetRandomDataToPipingInput(PipingInput input)
        {
            var random = new Random(21);

            var surfaceLine = new PipingSurfaceLine(string.Empty);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(random.Next(0, 5), random.Next(0, 5), random.Next(0, 5)),
                new Point3D(random.Next(5, 10), random.Next(5, 10), random.Next(5, 10))
            });

            input.EntryPointL           = random.NextRoundedDouble();
            input.ExitPointL            = random.NextRoundedDouble();
            input.SurfaceLine           = surfaceLine;
            input.StochasticSoilModel   = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("model");
            input.StochasticSoilProfile = new PipingStochasticSoilProfile(random.NextDouble(),
                                                                          PipingSoilProfileTestFactory.CreatePipingSoilProfile());
            input.HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation();
            input.PhreaticLevelExit         = new NormalDistribution
            {
                Mean = random.NextRoundedDouble(),
                StandardDeviation = random.NextRoundedDouble()
            };
            input.DampingFactorExit = new LogNormalDistribution
            {
                Mean = random.NextRoundedDouble(),
                StandardDeviation = random.NextRoundedDouble()
            };
        }
コード例 #14
0
        public void CreateSoilLayerAreas_SurfaceLineEndsBelowLayerTopButAboveBottom_ReturnsSoilLayerPointsAsRectangleFollowingSurfaceLine()
        {
            // Setup
            var surfaceLine = new PipingSurfaceLine(string.Empty);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0, 0, 3.0),
                new Point3D(1, 0, 2.0),
                new Point3D(2, 0, 2.0)
            });
            const double bottom      = 1.5;
            const double top         = 2.5;
            var          soilLayer   = new PipingSoilLayer(top);
            var          soilProfile = new PipingSoilProfile("name", bottom, new[]
            {
                soilLayer
            }, SoilProfileType.SoilProfile1D);

            // Call
            IEnumerable <Point2D[]> areas = PipingChartDataPointsFactory.CreateSoilLayerAreas(soilLayer, soilProfile, surfaceLine).ToList();

            // Assert
            Assert.AreEqual(1, areas.Count());
            CollectionAssert.AreEqual(new[]
            {
                new Point2D(0.5, top),
                new Point2D(1, 2.0),
                new Point2D(2, 2.0),
                new Point2D(2, bottom),
                new Point2D(0, bottom),
                new Point2D(0, top)
            }, areas.ElementAt(0));
        }
コード例 #15
0
        public void Transform_WithoutCharacteristicPoints_ReturnsSurfaceLineWithoutCharacteristicPointsSet()
        {
            // Setup
            var referenceLine = new ReferenceLine();
            var transformer   = new PipingSurfaceLineTransformer(referenceLine);

            const string surfaceLineName = "somewhere";
            var          surfaceLine     = new SurfaceLine
            {
                Name = surfaceLineName
            };

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(1.0, 5.0, 2.1),
                new Point3D(1.0, 3.0, 2.1)
            });
            referenceLine.SetGeometry(new[]
            {
                new Point2D(0.0, 4.0),
                new Point2D(2.0, 4.0)
            });

            // Call
            PipingSurfaceLine result = transformer.Transform(surfaceLine, null);

            // Assert
            Assert.IsNull(result.DitchDikeSide);
            Assert.IsNull(result.BottomDitchDikeSide);
            Assert.IsNull(result.BottomDitchPolderSide);
            Assert.IsNull(result.DitchPolderSide);
            Assert.IsNull(result.DikeToeAtPolder);
            Assert.IsNull(result.DikeToeAtRiver);
        }
コード例 #16
0
        public void GivenViewWithSurfaceLineData_WhenSurfaceLineUpdatedAndNotified_ThenMapDataUpdated()
        {
            // Given
            var surfaceLine      = new PipingSurfaceLine(string.Empty);
            var failureMechanism = new PipingFailureMechanism();

            failureMechanism.SurfaceLines.AddRange(new[]
            {
                surfaceLine
            }, "path");

            PipingFailureMechanismView view = CreateView(failureMechanism, new AssessmentSectionStub());

            IMapControl map = ((RiskeerMapControl)view.Controls[0]).MapControl;

            var mocks = new MockRepository();

            IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection);
            observers[surfaceLinesIndex].Expect(obs => obs.UpdateObserver());
            mocks.ReplayAll();

            // When
            surfaceLine.SetGeometry(new[]
            {
                new Point3D(7, 8, 9),
                new Point3D(10, 11, 12)
            });
            surfaceLine.NotifyObservers();

            // Then
            var surfaceLineMapData = (MapLineData)map.Data.Collection.ElementAt(surfaceLinesIndex);

            AssertSurfaceLinesMapData(failureMechanism.SurfaceLines, surfaceLineMapData);
            mocks.VerifyAll();
        }
コード例 #17
0
        public void ForeColor_CollectionWithSurfaceLines_ReturnsControlText()
        {
            // Setup
            var assessmentSection  = mocks.Stub <IAssessmentSection>();
            var pipingSurfaceLine1 = new PipingSurfaceLine("Line A");
            var pipingSurfaceLine2 = new PipingSurfaceLine("Line B");

            var surfaceLines = new PipingSurfaceLineCollection();

            surfaceLines.AddRange(new[]
            {
                pipingSurfaceLine1,
                pipingSurfaceLine2
            }, "path");

            var failureMechanism = new PipingFailureMechanism();

            var pipingSurfaceLineContext = new PipingSurfaceLinesContext(surfaceLines, failureMechanism, assessmentSection);

            mocks.ReplayAll();

            // Call
            Color foreColor = info.ForeColor(pipingSurfaceLineContext);

            // Assert
            Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), foreColor);
        }
コード例 #18
0
        public void GivenDialogWithSelectedItems_WhenDoForSelectedButtonClicked_ThenReturnsSelectedCollection()
        {
            // Given
            var selectedSurfaceLine = new PipingSurfaceLine("surface line 1");

            PipingSurfaceLine[] surfaceLines =
            {
                selectedSurfaceLine,
                new PipingSurfaceLine("surface line 2")
            };

            using (var dialog = new PipingSurfaceLineSelectionDialog(testForm, surfaceLines))
            {
                dialog.Show();

                var selectionView = (DataGridViewControl) new ControlTester("DataGridViewControl", dialog).TheObject;
                selectionView.Rows[0].Cells[0].Value = true;

                // When
                var generateButton = new ButtonTester("DoForSelectedButton", dialog);
                generateButton.Click();

                // Then
                CollectionAssert.AreEqual(new[]
                {
                    selectedSurfaceLine
                }, dialog.SelectedItems);
            }
        }
コード例 #19
0
        /// <summary>
        /// Creates a semi-probabilistic calculation for which the surface line on the input intersects with <paramref name="section"/>
        /// and the calculation has not been performed.
        /// </summary>
        /// <typeparam name="T">The type of semi-probabilistic calculation to create.</typeparam>
        /// <param name="section">The section for which an intersection will be created.</param>
        /// <returns>A new instance of type <typeparamref name="T"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="section"/> is <c>null</c>.</exception>
        public static T CreateNotCalculatedCalculation <T>(FailureMechanismSection section)
            where T : SemiProbabilisticPipingCalculation, new()
        {
            if (section == null)
            {
                throw new ArgumentNullException(nameof(section));
            }

            var     pipingSurfaceLine = new PipingSurfaceLine(string.Empty);
            Point2D p = section.Points.First();

            pipingSurfaceLine.SetGeometry(new[]
            {
                new Point3D(p.X, p.Y, 0),
                new Point3D(p.X + 2, p.Y + 2, 0)
            });
            pipingSurfaceLine.ReferenceLineIntersectionWorldPoint = section.Points.First();

            return(new T
            {
                InputParameters =
                {
                    SurfaceLine = pipingSurfaceLine
                }
            });
        }
コード例 #20
0
        /// <summary>
        /// Creates a <see cref="SurfaceLineEntity"/> based on the information of the <see cref="PipingSurfaceLine"/>.
        /// </summary>
        /// <param name="surfaceLine">The surface line to create a database entity for.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <param name="order">Index at which this instance resides inside its parent container.</param>
        /// <returns>A new <see cref="SurfaceLineEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception>
        internal static SurfaceLineEntity Create(this PipingSurfaceLine surfaceLine, PersistenceRegistry registry, int order)
        {
            if (surfaceLine == null)
            {
                throw new ArgumentNullException(nameof(surfaceLine));
            }

            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            if (registry.Contains(surfaceLine))
            {
                return(registry.Get(surfaceLine));
            }

            var entity = new SurfaceLineEntity
            {
                Name = surfaceLine.Name.DeepClone(),
                ReferenceLineIntersectionX = surfaceLine.ReferenceLineIntersectionWorldPoint?.X.ToNaNAsNull(),
                ReferenceLineIntersectionY = surfaceLine.ReferenceLineIntersectionWorldPoint?.Y.ToNaNAsNull(),
                PointsXml = new Point3DCollectionXmlSerializer().ToXml(surfaceLine.Points),
                Order     = order
            };

            CreateCharacteristicPointEntities(surfaceLine, entity);

            registry.Register(entity, surfaceLine);

            return(entity);
        }
コード例 #21
0
        /// <summary>
        /// Creates piping input with a single aquifer layer above the surface line.
        /// </summary>
        /// <param name="deltaAboveSurfaceLine">The distance between the aquifer layer and the surface line.</param>
        /// <returns>A new <see cref="PipingInput"/>.</returns>
        public static PipingInput CreateInputWithSingleAquiferLayerAboveSurfaceLine(double deltaAboveSurfaceLine)
        {
            var          surfaceLine         = new PipingSurfaceLine(string.Empty);
            const double surfaceLineTopLevel = 2.0;

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0, 0, surfaceLineTopLevel),
                new Point3D(1.0, 0, surfaceLineTopLevel)
            });
            var stochasticSoilProfile = new PipingStochasticSoilProfile(
                0.0, new PipingSoilProfile(string.Empty, 0, new[]
            {
                new PipingSoilLayer(surfaceLineTopLevel + deltaAboveSurfaceLine + 2)
                {
                    IsAquifer = false
                },
                new PipingSoilLayer(surfaceLineTopLevel + deltaAboveSurfaceLine + 1)
                {
                    IsAquifer = true
                },
                new PipingSoilLayer(surfaceLineTopLevel + deltaAboveSurfaceLine)
                {
                    IsAquifer = false
                }
            }, SoilProfileType.SoilProfile1D));
            var input = new TestPipingInput
            {
                SurfaceLine           = surfaceLine,
                StochasticSoilProfile = stochasticSoilProfile,
                ExitPointL            = (RoundedDouble)0.5
            };

            return(input);
        }
        public void Read_EntityWithSurfaceLineInCollector_CalculationHasAlreadyReadSurfaceLine()
        {
            // Setup
            var surfaceLine = new PipingSurfaceLine(string.Empty);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(1, 2, 3),
                new Point3D(4, 5, 6)
            });
            var surfaceLineEntity = new SurfaceLineEntity();
            var entity            = new SemiProbabilisticPipingCalculationEntity
            {
                SurfaceLineEntity     = surfaceLineEntity,
                EntryPointL           = 1,
                ExitPointL            = 2,
                DampingFactorExitMean = 1,
                ScenarioContribution  = 0
            };

            var collector = new ReadConversionCollector();

            collector.Read(surfaceLineEntity, surfaceLine);

            // Call
            SemiProbabilisticPipingCalculationScenario calculation = entity.Read(collector);

            // Assert
            Assert.AreSame(surfaceLine, calculation.InputParameters.SurfaceLine);
            Assert.AreEqual(1, calculation.InputParameters.EntryPointL, 1e-6);
            Assert.AreEqual(2, calculation.InputParameters.ExitPointL, 1e-6);
        }
コード例 #23
0
        /// <summary>
        /// Creates piping input with an aquifer layer and coverage layer.
        /// </summary>
        /// <param name="thicknessAquiferLayer">The thickness of the aquifer layer.</param>
        /// <param name="thicknessCoverageLayer">The thickness of the coverage layer.</param>
        /// <typeparam name="T">The type of piping input to create.</typeparam>
        /// <returns>A new <see cref="T"/>.</returns>
        public static T CreateInputWithAquiferAndCoverageLayer <T>(double thicknessAquiferLayer  = 1.0,
                                                                   double thicknessCoverageLayer = 2.0)
            where T : PipingInput, new()
        {
            var surfaceLine = new PipingSurfaceLine(string.Empty);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0, 0, thicknessCoverageLayer),
                new Point3D(1.0, 0, thicknessCoverageLayer)
            });
            var stochasticSoilProfile = new PipingStochasticSoilProfile(
                0.0, new PipingSoilProfile(string.Empty, -thicknessAquiferLayer, new[]
            {
                new PipingSoilLayer(thicknessCoverageLayer)
                {
                    IsAquifer = false
                },
                new PipingSoilLayer(0.0)
                {
                    IsAquifer = true
                }
            }, SoilProfileType.SoilProfile1D));

            return(new T
            {
                SurfaceLine = surfaceLine,
                StochasticSoilProfile = stochasticSoilProfile,
                ExitPointL = (RoundedDouble)0.5
            });
        }
コード例 #24
0
ファイル: PipingInputTest.cs プロジェクト: Deltares/Riskeer
        public void SynchronizeEntryAndExitPointInput_DikeToesBeforeSetEntryPointL_ExitPointLAndEntryPointLUpdated()
        {
            // Setup
            var input = new TestPipingInput();

            var surfaceLine = new PipingSurfaceLine(string.Empty);

            surfaceLine.SetGeometry(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)
            });
            surfaceLine.SetDikeToeAtRiverAt(new Point3D(2, 0, 3));
            surfaceLine.SetDikeToeAtPolderAt(new Point3D(3, 0, 0));

            input.SurfaceLine = surfaceLine;
            input.ExitPointL  = (RoundedDouble)5;
            input.EntryPointL = (RoundedDouble)4;

            // Call
            input.SynchronizeEntryAndExitPointInput();

            // Assert
            Assert.AreEqual(2, input.EntryPointL, input.EntryPointL.GetAccuracy());
            Assert.AreEqual(3, input.ExitPointL, input.ExitPointL.GetAccuracy());
        }
コード例 #25
0
        public void SetCharacteristicPoints_CharacteristicPointsNull_NoCharacteristicPointsSet()
        {
            // Setup
            var surfaceLine = new PipingSurfaceLine(string.Empty);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(3, 2, 5),
                new Point3D(3.4, 3, 8),
                new Point3D(4.4, 6, 8),
                new Point3D(5.1, 6, 6.5),
                new Point3D(8.5, 7.2, 4.2),
                new Point3D(9.6, 7.5, 3.9)
            });

            // Call
            surfaceLine.SetCharacteristicPoints(null);

            // Assert
            Assert.IsNull(surfaceLine.DikeToeAtRiver);
            Assert.IsNull(surfaceLine.DikeToeAtPolder);
            Assert.IsNull(surfaceLine.DitchDikeSide);
            Assert.IsNull(surfaceLine.BottomDitchDikeSide);
            Assert.IsNull(surfaceLine.BottomDitchPolderSide);
            Assert.IsNull(surfaceLine.DitchPolderSide);
        }
コード例 #26
0
ファイル: PipingInputTest.cs プロジェクト: Deltares/Riskeer
        public void IsEntryAndExitPointInputSynchronized_SurfaceLineAndInputNotInSync_ReturnFalse(Point3D newDikeToeAtRiver, Point3D newDikeToeAtPolder)
        {
            // Setup
            var surfaceLine = new PipingSurfaceLine(string.Empty);

            surfaceLine.SetGeometry(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)
            });
            surfaceLine.SetDikeToeAtRiverAt(new Point3D(2, 0, 3));
            surfaceLine.SetDikeToeAtPolderAt(new Point3D(3, 0, 0));

            var input = new TestPipingInput
            {
                SurfaceLine = surfaceLine
            };

            input.SurfaceLine.SetDikeToeAtRiverAt(newDikeToeAtRiver);
            input.SurfaceLine.SetDikeToeAtPolderAt(newDikeToeAtPolder);

            // Call
            bool synchronized = input.IsEntryAndExitPointInputSynchronized;

            // Assert
            Assert.IsFalse(synchronized);
        }
コード例 #27
0
        public void Create_HasSurfaceLineSet_EntityHasSurfaceLineEntity()
        {
            // Setup
            var surfaceLine = new PipingSurfaceLine(string.Empty)
            {
                ReferenceLineIntersectionWorldPoint = new Point2D(1.1, 2.2)
            };

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0.0, 0.0, 1.0),
                new Point3D(3.3, 6.6, 1.0)
            });

            var registry = new PersistenceRegistry();
            SurfaceLineEntity surfaceLineEntity = surfaceLine.Create(registry, 0);

            var calculation = new ProbabilisticPipingCalculationScenario
            {
                InputParameters =
                {
                    SurfaceLine = surfaceLine
                }
            };

            // Call
            ProbabilisticPipingCalculationEntity entity = calculation.Create(registry, 0);

            // Assert
            Assert.AreSame(surfaceLineEntity, entity.SurfaceLineEntity);
        }
コード例 #28
0
ファイル: PipingInputTest.cs プロジェクト: Deltares/Riskeer
        public void GivenSurfaceLineSet_WhenSurfaceLineNull_ThenEntryAndExitPointsNaN()
        {
            // Given
            var input = new TestPipingInput();

            var surfaceLine = new PipingSurfaceLine(string.Empty);

            surfaceLine.SetGeometry(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)
            });
            input.SurfaceLine = surfaceLine;
            input.ExitPointL  = (RoundedDouble)5;
            input.EntryPointL = (RoundedDouble)4;

            // When
            input.SurfaceLine = null;

            // Then
            Assert.IsNaN(input.EntryPointL);
            Assert.IsNaN(input.ExitPointL);
        }
コード例 #29
0
        /// <summary>
        /// Read the <see cref="SurfaceLineEntity"/> and use the information to construct
        /// a <see cref="PipingSurfaceLine"/>.
        /// </summary>
        /// <param name="entity">The <see cref="SurfaceLineEntity"/> to create
        /// <see cref="PipingSurfaceLine"/> for.</param>
        /// <param name="collector">The object keeping track of read operations.</param>
        /// <returns>A new <see cref="PipingSurfaceLine"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when <see cref="SurfaceLineEntity.PointsXml"/>
        /// of <paramref name="entity"/> is empty.</exception>
        /// <exception cref="InvalidEnumArgumentException">Thrown when the <paramref name="entity"/>
        /// contains an invalid type of characteristic point.</exception>
        /// <exception cref="NotSupportedException">Thrown when the <paramref name="entity"/> contains a
        /// characteristic point that is not supported.</exception>
        public static PipingSurfaceLine ReadAsPipingSurfaceLine(this SurfaceLineEntity entity,
                                                                ReadConversionCollector collector)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            if (collector == null)
            {
                throw new ArgumentNullException(nameof(collector));
            }

            if (collector.ContainsPipingSurfaceLine(entity))
            {
                return(collector.GetPipingSurfaceLine(entity));
            }

            var surfaceLine = new PipingSurfaceLine(entity.Name)
            {
                ReferenceLineIntersectionWorldPoint = GetReferenceLineIntersectionWorldPoint(entity)
            };

            surfaceLine.SetGeometry(ReadGeometryPoints(entity.PointsXml));
            entity.ReadCharacteristicPoints(surfaceLine);

            collector.Read(entity, surfaceLine);

            return(surfaceLine);
        }
コード例 #30
0
        public void Create_SurfaceLineWithoutGeometry_ReturnSurfaceLineEntityWithoutAddingPointEntities()
        {
            // Setup
            var random      = new Random(31);
            int order       = random.Next();
            var registry    = new PersistenceRegistry();
            var surfaceLine = new PipingSurfaceLine("Test")
            {
                ReferenceLineIntersectionWorldPoint = new Point2D(random.NextDouble(), random.NextDouble())
            };

            // Call
            SurfaceLineEntity entity = surfaceLine.Create(registry, order);

            // Assert
            Assert.AreEqual(surfaceLine.Name, entity.Name);
            Assert.AreEqual(surfaceLine.ReferenceLineIntersectionWorldPoint.X, entity.ReferenceLineIntersectionX);
            Assert.AreEqual(surfaceLine.ReferenceLineIntersectionWorldPoint.Y, entity.ReferenceLineIntersectionY);
            Assert.AreEqual(order, entity.Order);

            Assert.IsNull(entity.FailureMechanismEntity);
            IEnumerable <Point3D> points = new Point3D[0];
            string expectedXml           = new Point3DCollectionXmlSerializer().ToXml(points);

            Assert.AreEqual(expectedXml, entity.PointsXml);
        }