public void CreateSegmentsMultipleCrossSectionsAndFixedPoint() { IHydroNetwork network = CreateSegmentTestNetwork(); var branch1 = network.Channels.First(); var discretization = new Discretization() { Network = network, SegmentGenerationMethod = SegmentGenerationMethod.SegmentBetweenLocations }; HydroNetworkHelper.GenerateDiscretization(discretization, // networkCoverage branch1, // branch 5.0, // minimumDistance false, // gridAtStructure 0.5, // structureDistance false, // gridAtCrossSection true, // gridAtFixedLength 2); // fixedLength Assert.AreEqual(51, discretization.Locations.Values.Count); INetworkLocation networkLocation = discretization.Locations.Values.Where(nl => nl.Offset == 8).First(); //DiscretizationHelper.SetUserDefinedGridPoint(networkLocation, true); discretization.ToggleFixedPoint(networkLocation); networkLocation = discretization.Locations.Values.Where(nl => nl.Offset == 32).First(); discretization.ToggleFixedPoint(networkLocation); AddTestCrossSectionAt(network, branch1, 10.0); AddTestCrossSectionAt(network, branch1, 20.0); AddTestCrossSectionAt(network, branch1, 30.0); HydroNetworkHelper.GenerateDiscretization(discretization, // networkCoverage branch1, // branch 5.0, // minimumDistance false, // gridAtStructure 0.5, // structureDistance true, // gridAtCrossSection false, // gridAtFixedLength -1); // fixedLength // expect gridpoints at: // begin and end 0 and 100 // fixed locations 8 and 32. // 20 for the cross section, 10 and 30 should not be generated due to existing // fixed points and minimium distance 0f 5. Assert.AreEqual(5, discretization.Locations.Values.Count); Assert.AreEqual(0.0, discretization.Locations.Values[0].Offset, 1.0e-6); Assert.AreEqual(8.0, discretization.Locations.Values[1].Offset, 1.0e-6); Assert.AreEqual(20.0, discretization.Locations.Values[2].Offset, 1.0e-6); Assert.AreEqual(32.0, discretization.Locations.Values[3].Offset, 1.0e-6); Assert.AreEqual(100.0, discretization.Locations.Values[4].Offset, 1.0e-6); }
public void CreateSegmentsFixedLocations() { IHydroNetwork network = CreateSegmentTestNetwork(); var branch1 = network.Channels.First(); var discretization = new Discretization() { Network = network, SegmentGenerationMethod = SegmentGenerationMethod.SegmentBetweenLocations }; HydroNetworkHelper.GenerateDiscretization(discretization, // networkCoverage branch1, // branch 0.5, // minimumDistance false, // gridAtStructure 0.5, // structureDistance false, // gridAtCrossSection true, // gridAtFixedLength 10); // fixedLength Assert.AreEqual(11, discretization.Locations.Values.Count); Assert.AreEqual(0.0, discretization.Locations.Values[0].Offset, 1.0e-6); Assert.AreEqual(50.0, discretization.Locations.Values[5].Offset, 1.0e-6); Assert.AreEqual(100.0, discretization.Locations.Values[10].Offset, 1.0e-6); INetworkLocation networkLocation = discretization.Locations.Values[7]; Assert.AreEqual(70.0, networkLocation.Offset, 1.0e-6); discretization.ToggleFixedPoint(networkLocation); //DiscretizationHelper.SetUserDefinedGridPoint(networkLocation, true); HydroNetworkHelper.GenerateDiscretization(discretization, // networkCoverage branch1, // branch 0.5, // minimumDistance false, // gridAtStructure 0.5, // structureDistance false, // gridAtCrossSection true, // gridAtFixedLength 40); // fixedLength // expect values at // - 0 and 100 start and end // - 70 for fixed location // - none between 70 and 100 // - (0 - 70) > 40, divide in equal parts -> 35 Assert.AreEqual(4, discretization.Locations.Values.Count); Assert.AreEqual(0.0, discretization.Locations.Values[0].Offset, 1.0e-6); Assert.AreEqual(35.0, discretization.Locations.Values[1].Offset, 1.0e-6); Assert.AreEqual(70.0, discretization.Locations.Values[2].Offset, 1.0e-6); Assert.AreEqual(100.0, discretization.Locations.Values[3].Offset, 1.0e-6); }
public void CreateSegmentsMultipleStructuresAndFixedPoint() { IHydroNetwork network = CreateSegmentTestNetwork(); var branch1 = network.Channels.First(); var discretization = new Discretization() { Network = network, SegmentGenerationMethod = SegmentGenerationMethod.SegmentBetweenLocations }; HydroNetworkHelper.GenerateDiscretization(discretization, // networkCoverage branch1, // branch 5.0, // minimumDistance false, // gridAtStructure 0.5, // structureDistance false, // gridAtCrossSection true, // gridAtFixedLength 2); // fixedLength Assert.AreEqual(51, discretization.Locations.Values.Count); INetworkLocation networkLocation = discretization.Locations.Values.Where(nl => nl.Offset == 8).First(); //DiscretizationHelper.SetUserDefinedGridPoint(networkLocation, true); discretization.ToggleFixedPoint(networkLocation); networkLocation = discretization.Locations.Values.Where(nl => nl.Offset == 32).First(); discretization.ToggleFixedPoint(networkLocation); //DiscretizationHelper.SetUserDefinedGridPoint(networkLocation, true); AddTestStructureAt(network, branch1, 10.0); AddTestStructureAt(network, branch1, 20.0); AddTestStructureAt(network, branch1, 30.0); HydroNetworkHelper.GenerateDiscretization(discretization, // networkCoverage branch1, // branch 6.0, // minimumDistance true, // gridAtStructure 4.0, // structureDistance false, // gridAtCrossSection false, // gridAtFixedLength -1); // fixedLength // expect gridpoints with no minimumDistance // 0 8 (6 14) (16 24) (26 34) 32 100 // 0 6 8 14 16 24 26 32 34 100 // 10 20 30 // structure locations // 0 8 14 24 32 100 // result // fixed locations 8 and 32. // first structure (6) and 14 // second structure 16 and 24; 16 will be merged into 14 -> 15 // third structure 26 and (34); 26 will be merged into 24 -> 25 // fixed points and minimium distance 0f 5. Assert.AreEqual(6, discretization.Locations.Values.Count); Assert.AreEqual(0.0, discretization.Locations.Values[0].Offset, 1.0e-6); Assert.AreEqual(8.0, discretization.Locations.Values[1].Offset, 1.0e-6); Assert.AreEqual(15.0, discretization.Locations.Values[2].Offset, 1.0e-6); Assert.AreEqual(25.0, discretization.Locations.Values[3].Offset, 1.0e-6); Assert.AreEqual(32.0, discretization.Locations.Values[4].Offset, 1.0e-6); Assert.AreEqual(100.0, discretization.Locations.Values[5].Offset, 1.0e-6); }