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));
        }
        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));
        }
Exemplo n.º 3
0
        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());
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        public void Create_SurfaceLineWithGeometryWithoutCharacteristicPoints_ReturnSurfaceLineEntityWithPointEntities()
        {
            // Setup
            var random      = new Random(31);
            int order       = random.Next();
            var registry    = new PersistenceRegistry();
            var surfaceLine = new PipingSurfaceLine("Test")
            {
                ReferenceLineIntersectionWorldPoint = new Point2D(1.1, 2.2)
            };

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble()),
                new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble()),
                new Point3D(random.NextDouble(), 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);

            string expectedXml = new Point3DCollectionXmlSerializer().ToXml(surfaceLine.Points);

            Assert.AreEqual(expectedXml, entity.PointsXml);

            Assert.IsNull(entity.FailureMechanismEntity);
        }
Exemplo n.º 8
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();
        }
Exemplo n.º 9
0
        private static PipingSurfaceLine GetSurfaceLine(Point3D[] points)
        {
            var surfaceLine = new PipingSurfaceLine("Surface line name");

            surfaceLine.SetGeometry(points);
            return(surfaceLine);
        }
Exemplo n.º 10
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()
            };
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
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
            });
        }
        /// <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
                }
            });
        }
Exemplo n.º 15
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);
        }
Exemplo n.º 16
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);
        }
Exemplo n.º 17
0
        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);
        }
Exemplo n.º 18
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);
        }
        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);
        }
        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);
        }
        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);
        }
Exemplo n.º 22
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
            });
        }
Exemplo n.º 23
0
        public void GivenViewWithCalculationGroupData_WhenCalculationGroupUpdatedAndNotified_ThenMapDataUpdated()
        {
            // Given
            var failureMechanism = new PipingFailureMechanism();

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

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

            var surfaceLineA = new PipingSurfaceLine(string.Empty);

            surfaceLineA.SetGeometry(new[]
            {
                new Point3D(0.0, 0.0, 1.0),
                new Point3D(3.0, 0.0, 1.7)
            });

            var surfaceLineB = new PipingSurfaceLine(string.Empty);

            surfaceLineB.SetGeometry(new[]
            {
                new Point3D(0.0, 0.0, 1.5),
                new Point3D(3.0, 0.0, 1.8)
            });
            surfaceLineA.ReferenceLineIntersectionWorldPoint = new Point2D(1.3, 1.3);
            surfaceLineB.ReferenceLineIntersectionWorldPoint = new Point2D(1.5, 1.5);

            var calculationA =
                SemiProbabilisticPipingCalculationTestFactory.CreateCalculationWithValidInput <SemiProbabilisticPipingCalculationScenario>(
                    new TestHydraulicBoundaryLocation());
            var calculationB =
                ProbabilisticPipingCalculationTestFactory.CreateCalculationWithValidInput <ProbabilisticPipingCalculationScenario>(
                    new TestHydraulicBoundaryLocation());

            calculationA.InputParameters.SurfaceLine = surfaceLineA;
            calculationB.InputParameters.SurfaceLine = surfaceLineB;

            failureMechanism.CalculationsGroup.Children.Add(calculationA);
            failureMechanism.CalculationsGroup.Children.Add(calculationB);

            var probabilisticCalculationMapData     = (MapLineData)map.Data.Collection.ElementAt(probabilisticCalculationsIndex);
            var semiProbabilisticCalculationMapData = (MapLineData)map.Data.Collection.ElementAt(semiProbabilisticCalculationsIndex);

            var mocks = new MockRepository();

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

            // When
            failureMechanism.CalculationsGroup.Children.Add(calculationB);
            failureMechanism.CalculationsGroup.NotifyObservers();

            // Then
            AssertSemiProbabilisticCalculationsMapData(failureMechanism.Calculations.OfType <SemiProbabilisticPipingCalculationScenario>(), semiProbabilisticCalculationMapData);
            AssertProbabilisticCalculationsMapData(failureMechanism.Calculations.OfType <ProbabilisticPipingCalculationScenario>(), probabilisticCalculationMapData);
            mocks.VerifyAll();
        }
        public void GenerateCalculationItemsStructure_SurfaceLineIntersectingSoilModelAndGenerateSemiProbabilisticAndProbabilisticFalse_ReturnEmptyCollection()
        {
            // Setup
            var soilProfile1 = new PipingStochasticSoilProfile(
                0.3, new PipingSoilProfile("Profile 1", -10.0, new[]
            {
                new PipingSoilLayer(-5.0),
                new PipingSoilLayer(-2.0),
                new PipingSoilLayer(1.0)
            }, SoilProfileType.SoilProfile1D)
                );
            var soilProfile2 = new PipingStochasticSoilProfile(0.7, new PipingSoilProfile("Profile 2", -8.0, new[]
            {
                new PipingSoilLayer(-4.0),
                new PipingSoilLayer(0.0),
                new PipingSoilLayer(4.0)
            }, SoilProfileType.SoilProfile1D)
                                                               );

            var soilModel = new PipingStochasticSoilModel("A", new[]
            {
                new Point2D(1.0, 0.0),
                new Point2D(5.0, 0.0)
            }, new[]
            {
                soilProfile1,
                soilProfile2
            });

            PipingStochasticSoilModel[] availableSoilModels =
            {
                soilModel
            };

            var surfaceLine = new PipingSurfaceLine("surface line");

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(3.0, 5.0, 0.0),
                new Point3D(3.0, 0.0, 1.0),
                new Point3D(3.0, -5.0, 0.0)
            });

            PipingSurfaceLine[] surfaceLines =
            {
                surfaceLine
            };

            // Call
            IEnumerable <ICalculationBase> result = PipingCalculationConfigurationHelper.GenerateCalculationItemsStructure(
                surfaceLines, false, false,
                availableSoilModels).ToArray();

            // Assert
            CollectionAssert.IsEmpty(result);
        }
            public void Import_StochasticSoilProfileUnknown_LogMessageAndContinueImport()
            {
                // Setup
                string filePath = TestHelper.GetScratchPadPath(nameof(Import_StochasticSoilProfileUnknown_LogMessageAndContinueImport));

                SetCalculationType(Path.Combine(importerPath, "validConfigurationCalculationContainingUnknownSoilProfile.xml"), filePath);

                var calculationGroup = new CalculationGroup();
                var surfaceLine      = new PipingSurfaceLine("Profielschematisatie");

                surfaceLine.SetGeometry(new[]
                {
                    new Point3D(3.0, 5.0, 0.0),
                    new Point3D(3.0, 0.0, 1.0),
                    new Point3D(3.0, -5.0, 0.0)
                });
                PipingStochasticSoilModel stochasticSoilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(
                    "Ondergrondmodel",
                    new[]
                {
                    new Point2D(1.0, 0.0),
                    new Point2D(5.0, 0.0)
                });

                var pipingFailureMechanism = new PipingFailureMechanism();

                pipingFailureMechanism.SurfaceLines.AddRange(new[]
                {
                    surfaceLine
                }, "readerPath");
                pipingFailureMechanism.StochasticSoilModels.AddRange(new[]
                {
                    stochasticSoilModel
                }, "readerPath");

                var importer = new PipingCalculationConfigurationImporter(
                    filePath, calculationGroup, new HydraulicBoundaryLocation[0], pipingFailureMechanism);

                try
                {
                    // Call
                    var successful            = false;
                    void Call() => successful = importer.Import();

                    // Assert
                    const string expectedMessage = "De ondergrondschematisatie 'Ondergrondschematisatie' bestaat niet binnen het stochastische ondergrondmodel 'Ondergrondmodel'. " +
                                                   "Berekening 'Calculation' is overgeslagen.";
                    TestHelper.AssertLogMessageIsGenerated(Call, expectedMessage, 2);
                    Assert.IsTrue(successful);
                    CollectionAssert.IsEmpty(calculationGroup.Children);
                }
                finally
                {
                    File.Delete(filePath);
                }
            }
        public void GetStochasticSoilModelsForSurfaceLine_SurfaceLineIntersectingSoilModel_ReturnSoilModel()
        {
            // Setup
            var soilProfile1 = new PipingStochasticSoilProfile(
                0.3, new PipingSoilProfile("Profile 1", -10.0, new[]
            {
                new PipingSoilLayer(-5.0),
                new PipingSoilLayer(-2.0),
                new PipingSoilLayer(1.0)
            }, SoilProfileType.SoilProfile1D));
            var soilProfile2 = new PipingStochasticSoilProfile(
                0.7, new PipingSoilProfile("Profile 2", -8.0, new[]
            {
                new PipingSoilLayer(-4.0),
                new PipingSoilLayer(0.0),
                new PipingSoilLayer(4.0)
            }, SoilProfileType.SoilProfile1D));

            var soilModel = new PipingStochasticSoilModel("A", new[]
            {
                new Point2D(1.0, 0.0),
                new Point2D(5.0, 0.0)
            }, new[]
            {
                soilProfile1,
                soilProfile2
            });

            PipingStochasticSoilModel[] availableSoilModels =
            {
                soilModel
            };

            var surfaceLine = new PipingSurfaceLine("surface line");

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(3.0, 5.0, 0.0),
                new Point3D(3.0, 0.0, 1.0),
                new Point3D(3.0, -5.0, 0.0)
            });

            // Call
            IEnumerable <PipingStochasticSoilModel> result = PipingCalculationConfigurationHelper.GetStochasticSoilModelsForSurfaceLine(
                surfaceLine,
                availableSoilModels);

            // Assert
            PipingStochasticSoilModel[] expected =
            {
                soilModel
            };
            CollectionAssert.AreEquivalent(expected, result);
        }
Exemplo n.º 27
0
        public void Create_SurfaceLineWithCharacteristicPointsOnSameGeometryPoint_ReturnSurfaceLineEntityWithPointEntitiesAndCharactersisticPointReferences()
        {
            // Setup
            var random   = new Random(31);
            var registry = new PersistenceRegistry();
            var geometry = new[]
            {
                new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble())
            };
            var surfaceLine = new PipingSurfaceLine("Test")
            {
                ReferenceLineIntersectionWorldPoint = new Point2D(random.NextDouble(), random.NextDouble())
            };

            surfaceLine.SetGeometry(geometry);
            surfaceLine.SetBottomDitchDikeSideAt(geometry[0]);
            surfaceLine.SetBottomDitchPolderSideAt(geometry[0]);
            surfaceLine.SetDikeToeAtPolderAt(geometry[0]);
            surfaceLine.SetDikeToeAtRiverAt(geometry[0]);
            surfaceLine.SetDitchDikeSideAt(geometry[0]);
            surfaceLine.SetDitchPolderSideAt(geometry[0]);

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

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

            string expectedXml = new Point3DCollectionXmlSerializer().ToXml(geometry);

            Assert.AreEqual(expectedXml, entity.PointsXml);

            Assert.AreEqual(6, entity.PipingCharacteristicPointEntities.Count);

            CollectionAssert.AreEquivalent(new[]
            {
                (byte)PipingCharacteristicPointType.DikeToeAtRiver,
                (byte)PipingCharacteristicPointType.DikeToeAtPolder,
                (byte)PipingCharacteristicPointType.DitchDikeSide,
                (byte)PipingCharacteristicPointType.BottomDitchDikeSide,
                (byte)PipingCharacteristicPointType.BottomDitchPolderSide,
                (byte)PipingCharacteristicPointType.DitchPolderSide
            }, entity.PipingCharacteristicPointEntities
                                           .Select(cpe => cpe.Type));

            foreach (PipingCharacteristicPointEntity characteristicPointEntity in entity.PipingCharacteristicPointEntities)
            {
                Assert.AreEqual(geometry[0].X, characteristicPointEntity.X);
                Assert.AreEqual(geometry[0].Y, characteristicPointEntity.Y);
                Assert.AreEqual(geometry[0].Z, characteristicPointEntity.Z);
            }
        }
Exemplo n.º 28
0
        private static PipingSurfaceLine CreateSurfaceLine()
        {
            var surfaceLine = new PipingSurfaceLine(string.Empty);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0, 0, 0),
                new Point3D(2, 0, 2)
            });

            return(surfaceLine);
        }
        private static PipingSurfaceLine GetSurfaceLineWithGeometry()
        {
            var surfaceLine = new PipingSurfaceLine("surface line");

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(1.2, 2.3, 4.0),
                new Point3D(2.7, 2.8, 6.0)
            });

            return(surfaceLine);
        }
Exemplo n.º 30
0
        private static void CreateTestGeometry(Point3D testPoint, PipingSurfaceLine surfaceLine)
        {
            var random = new Random(21);
            var points = new[]
            {
                new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble()),
                new Point3D(testPoint),
                new Point3D(2 + random.NextDouble(), random.NextDouble(), random.NextDouble())
            };

            surfaceLine.SetGeometry(points);
        }