Index: DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Calculators/KernelWrappers/DamMacroStabilityInwards/DamMacroStabilityInwardsKernelWrapper.cs =================================================================== diff -u -r1979 -r2054 --- DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Calculators/KernelWrappers/DamMacroStabilityInwards/DamMacroStabilityInwardsKernelWrapper.cs (.../DamMacroStabilityInwardsKernelWrapper.cs) (revision 1979) +++ DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Calculators/KernelWrappers/DamMacroStabilityInwards/DamMacroStabilityInwardsKernelWrapper.cs (.../DamMacroStabilityInwardsKernelWrapper.cs) (revision 2054) @@ -25,6 +25,7 @@ using System.Diagnostics; using System.IO; using System.Linq; +using System.Xml; using System.Xml.Linq; using Deltares.DamEngine.Calculators.DikesDesign; using Deltares.DamEngine.Calculators.KernelWrappers.Common; @@ -139,7 +140,7 @@ // Write xml file XDocument xmlDocument = CreateMstabDamXmlDocument(damKernelInput, damMacroStabilityInput); // Use xml file to create sti file - CreateStiFile(xmlDocument, damKernelInput); + CreateStiFile(xmlDocument, damKernelInput, damMacroStabilityInput); // now check if second calculation for BishopUpliftVan is needed, if so perform prepare. if (bishopUpliftVan) @@ -157,7 +158,7 @@ // Write xml file xmlDocument = CreateMstabDamXmlDocument(damKernelInput, damMacroStabilityInput); // Use xml file to create sti file - CreateStiFile(xmlDocument, damKernelInput);//// + CreateStiFile(xmlDocument, damKernelInput, damMacroStabilityInput);//// } finally { @@ -345,7 +346,7 @@ return mstabXml; } - internal void CreateStiFile(XDocument xmlDocument, DamKernelInput damKernelInput) + internal void CreateStiFile(XDocument xmlDocument, DamKernelInput damKernelInput, DamMacroStabilityInput damMacroStabilityInput) { DGSMStabDAMInterface mstabDamDll = new DGSMStabDAMInterface(); var result = mstabDamDll.CreateProjectFile(xmlDocument.ToString()); @@ -357,6 +358,11 @@ where element.Name.LocalName == DamMStabAssembler.XmlElementNameInput select element).Single(); XAttribute mstabFileName = inputElement.Attribute(DamMStabAssembler.XmlAttributeMStabFileName); + + // var test = DamMStabAssembler.XmlElementExternalPLLines; + // damKernelInput.DamFailureMechanismeCalculationSpecification.FailureMechanismParametersMStab.PlLines + // DamMStabAssembler.XmlElementPLPoint. + // XAttribute PLLines = inputElement.E(DamMStabAssembler.XmlElementExternalPLLines); if (mstabFileName!= null) { string stiFileName = mstabFileName.Value; @@ -365,6 +371,9 @@ { PythonInterface pythonInterface = new PythonInterface(); pythonInterface.PerformPythonActions(damKernelInput, stiFileName); + + // var test = FailureMechanismParametersMStab.PlLines.Lines.Values; + // var test2 = 1; } } } @@ -635,7 +644,7 @@ mstabXML.Save(mstabProjectFilename + ".xml"); damMacroStabilityInput.DGeoStabilityInputFileName = mstabProjectFilename; - CreateStiFile(mstabXML, damKernelInput); + CreateStiFile(mstabXML, damKernelInput, damMacroStabilityInput); if (!File.Exists(mstabProjectFilename)) Index: DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Calculators/KernelWrappers/Common/PlLinesHelper.cs =================================================================== diff -u -r1848 -r2054 --- DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Calculators/KernelWrappers/Common/PlLinesHelper.cs (.../PlLinesHelper.cs) (revision 1848) +++ DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Calculators/KernelWrappers/Common/PlLinesHelper.cs (.../PlLinesHelper.cs) (revision 2054) @@ -142,7 +142,9 @@ IsHydraulicShortcut = (regionalAssessmentScenarioJobSettings.HydraulicShortcutType == HydraulicShortcutType.HydraulicShortcut), XSoilGeometry2DOrigin = location.XSoilGeometry2DOrigin, IsUseOvenDryUnitWeight = (regionalAssessmentScenarioJobSettings.DikeDrySensitivity == DikeDrySensitivity.Dry), - SoilList = location.SoilList + SoilList = location.SoilList, + NWOPhreaticAdaption = PhreaticAdaptionType.MakeEmpty + }; if ((regionalAssessmentScenarioJobSettings.DikeDrySensitivity == DikeDrySensitivity.Dry) && (regionalAssessmentScenarioJobSettings.LoadSituation == LoadSituation.Dry)) @@ -210,6 +212,5 @@ upliftSituation.IsUplift = false; // must be determined later on; just to avoid compiler error return plLines; } - } } Index: DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Data/General/DAMEnumerations.cs =================================================================== diff -u -r1848 -r2054 --- DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Data/General/DAMEnumerations.cs (.../DAMEnumerations.cs) (revision 1848) +++ DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Data/General/DAMEnumerations.cs (.../DAMEnumerations.cs) (revision 2054) @@ -306,4 +306,10 @@ HydroStatic, SemiTimeDependent } + + public enum PhreaticAdaptionType + { + MakeEmpty, + None + } } Index: DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Calculators/PlLinesCreator/PlLinesCreator.cs =================================================================== diff -u -r1850 -r2054 --- DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Calculators/PlLinesCreator/PlLinesCreator.cs (.../PlLinesCreator.cs) (revision 1850) +++ DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Calculators/PlLinesCreator/PlLinesCreator.cs (.../PlLinesCreator.cs) (revision 2054) @@ -88,6 +88,7 @@ public double? PlLineOffsetFactorBelowShoulderCrest { get; set; } public bool? UsePlLineOffsetBelowDikeCrestMiddle { get; set; } public bool? UsePlLineOffsetFactorBelowShoulderCrest { get; set; } + public PhreaticAdaptionType NWOPhreaticAdaption { get; set; } private double WaterLevelToUse() { @@ -1031,9 +1032,18 @@ PlLinePoint nwo3Pl = null; PlLinePoint nwo4Pl = null; + PlLinePoint intersectionPoint = null; + PlLinePoint intersectionPoint2 = null; + GeometryPoint intersectPoint = new GeometryPoint(); GeometryPoint intersectPoint2 = new GeometryPoint(); + GeometryPointString pl1GeometryPointString = new GeometryPointString(); + foreach (PlLinePoint point in pl1Line.Points) + { + pl1GeometryPointString.CalcPoints.Add(new Point2D(point.X, point.Z)); + } + // For NWO point, determine whether a pl point has to be added if (pl1Line.PositionXzOfPointRelatedToPlLine(nwo1) != PlLinePointPositionXzType.AbovePlLine) { @@ -1072,11 +1082,12 @@ intersection1 = LineHelper.GetStrictIntersectionPoint(phreaticPolderPartialLine, lineNwo, ref intersectPoint); + IList intersectionPoints = pl1GeometryPointString.IntersectionPointsXzWithLineXz(lineNwo); + intersectionPoint = new PlLinePoint(intersectionPoints.First().X, intersectionPoints.First().Z); + } - - // Intersection between nwo point3 and nwo point4 only when nwo point3 is below pl line and nwo point4 is above plLine // PlLinePoint intersection2 = null; bool intersection2 = false; @@ -1093,78 +1104,78 @@ intersection2 = LineHelper.GetStrictIntersectionPoint(phreaticPolderPartialLine, lineNwo, ref intersectPoint2); + IList intersectionPoints2 = pl1GeometryPointString.IntersectionPointsXzWithLineXz(lineNwo); + + intersectionPoint = new PlLinePoint(intersectionPoints2.First().X, intersectionPoints2.First().Z); } //// Handle making the NWO empty - //if ((NWOPhreaticAdaption != null) && (NWOPhreaticAdaption == PhreaticAdaptionType.MakeEmpty)) - //{ - // // for the polderside, the pl line is always allowed to be adapted. For the riverside, the pl line may only be adapted when the original waterlevel is runs through the nwo. - // RemoveAllWaterFromNonWaterRetainingObject(nwo1, pl1Line, nwo1Pl, nwo2Pl, nwo3Pl, nwo4Pl, - // intersectPoint, intersectPoint2, plPointsToBeMoved); - //} + if ((NWOPhreaticAdaption != null) && (NWOPhreaticAdaption == PhreaticAdaptionType.MakeEmpty)) + { + // for the polderside, the pl line is always allowed to be adapted. For the riverside, the pl line may only be adapted when the original waterlevel is runs through the nwo. + RemoveAllWaterFromNonWaterRetainingObject(nwo1, pl1Line, nwo1Pl, nwo2Pl, nwo3Pl, nwo4Pl, + intersectionPoint, intersectionPoint2, plPointsToBeMoved); + } //// Handle making the waterlevel horizontal in the NWO at the Riverside when needed (Polderside is already done when needed, see CreatePhreaticLineSegmentsInShoulderAndPolder. - //if ((NWOPhreaticAdaption != null) && (NWOPhreaticAdaption == PhreaticAdaptionType.None)) - //{ - // if (nwo1Pl == null && nwo2Pl != null && nwo3Pl != null && nwo4Pl == null) - //{ - // For the riverside, the pl line may only be adapted when the original waterlevel is runs through the nwo and is not already level. - if ((nwo1.X <= this.surfaceLine.CharacteristicPoints - .GetGeometryPoint(CharacteristicPointType.DikeToeAtRiver).X) && - ((intersection1) || (intersection2))) + if ((NWOPhreaticAdaption != null) && (NWOPhreaticAdaption == PhreaticAdaptionType.None)) { - double requiredWaterLevel; - // Check whether adaption of intersection points is needed - if (!intersection2) + if (nwo1Pl == null && nwo2Pl != null && nwo3Pl != null && nwo4Pl == null) { - // only intersection 1 avaialable so add intersection 2 - // first see if nwo3/4 intersects, if not try nwo2/3. If still no intersection found valid level not possible, raise error - MakeWaterLevelHorizontalInNWOAtRiverSideUsingInterSection1(nwo2, nwo3, nwo4, pl1Line, - nwo3Pl, nwo4Pl, intersectPoint); - requiredWaterLevel = intersectPoint.Z; - } - else if (!intersection1) - { - // only intersection 2 avaialable so add intersection 1 - // first see if nwo1/2 intersects, if not try nwo2/3. If still no intersection found valid level not possible, raise error - MakeWaterLevelHorizontalInNWOAtRiverSideUsingInterSection2(nwo1, nwo2, nwo3, - pl1Line, nwo1Pl, nwo2Pl, nwo3Pl, intersectPoint2); - requiredWaterLevel = intersectPoint2.Z; - } - else - { - // intersection 1 and intersection 2 available. Only act when levels were different. - requiredWaterLevel = Math.Min(intersectPoint.Z, intersectPoint2.Z); - if ((Math.Abs(intersectPoint.Z - intersectPoint2.Z) > GeometryPoint.Precision)) + // For the riverside, the pl line may only be adapted when the original waterlevel is runs through the nwo and is not already level. + if ((nwo1.X <= this.surfaceLine.CharacteristicPoints + .GetGeometryPoint(CharacteristicPointType.DikeToeAtRiver).X) && + ((intersection1) || (intersection2))) { - if (intersectPoint.Z < intersectPoint2.Z) + double requiredWaterLevel; + // Check whether adaption of intersection points is needed + if (!intersection2) { - // make level in NWO intersection1.Z - MakeWaterLevelHorizontalInNWOAtRiverSideUsingInterSection1And2(nwo2, nwo3, - nwo4, pl1Line, nwo3Pl, intersectPoint, intersectPoint2); + // only intersection 1 avaialable so add intersection 2 + // first see if nwo3/4 intersects, if not try nwo2/3. If still no intersection found valid level not possible, raise error + MakeWaterLevelHorizontalInNWOAtRiverSideUsingInterSection1(nwo2, nwo3, nwo4, pl1Line, + nwo3Pl, nwo4Pl, intersectPoint); + requiredWaterLevel = intersectPoint.Z; } + else if (!intersection1) + { + // only intersection 2 avaialable so add intersection 1 + // first see if nwo1/2 intersects, if not try nwo2/3. If still no intersection found valid level not possible, raise error + MakeWaterLevelHorizontalInNWOAtRiverSideUsingInterSection2(nwo1, nwo2, nwo3, + pl1Line, nwo1Pl, nwo2Pl, nwo3Pl, intersectPoint2); + requiredWaterLevel = intersectPoint2.Z; + } else { - // make level in NWO intersection2.Z - MakeWaterLevelHorizontalInNWOAtRiverSideUsingInterSection2And1(nwo1, nwo2, - nwo3, pl1Line, nwo2Pl, intersectPoint, intersectPoint2); + // intersection 1 and intersection 2 available. Only act when levels were different. + requiredWaterLevel = Math.Min(intersectPoint.Z, intersectPoint2.Z); + if ((Math.Abs(intersectPoint.Z - intersectPoint2.Z) > GeometryPoint.Precision)) + { + if (intersectPoint.Z < intersectPoint2.Z) + { + // make level in NWO intersection1.Z + MakeWaterLevelHorizontalInNWOAtRiverSideUsingInterSection1And2(nwo2, nwo3, + nwo4, pl1Line, nwo3Pl, intersectPoint, intersectPoint2); + } + else + { + // make level in NWO intersection2.Z + MakeWaterLevelHorizontalInNWOAtRiverSideUsingInterSection2And1(nwo1, nwo2, + nwo3, pl1Line, nwo2Pl, intersectPoint, intersectPoint2); + } + } } + // Move all the points in the pl line itself that need to be moved to the horizontal proper level. + foreach (var plLinePoint in plPointsToBeMoved) + { + plLinePoint.Z = requiredWaterLevel; + } + pl1Line.DeleteCoinsidingPoints(GeometryPoint.Precision); } } - - - // Move all the points in the pl line itself that need to be moved to the horizontal proper level. - foreach (var plLinePoint in plPointsToBeMoved) - { - plLinePoint.Z = requiredWaterLevel; - } - - pl1Line.DeleteCoinsidingPoints(GeometryPoint.Precision); } - // } - // } } } @@ -1209,7 +1220,7 @@ private void MakeWaterLevelHorizontalInNWOAtRiverSideUsingInterSection1And2(GeometryPoint nwo2, GeometryPoint nwo3, GeometryPoint nwo4, PlLine pl1Line, PlLinePoint nwo3Pl, GeometryPoint intersection1, GeometryPoint intersection2) { - var lineNWO = new Line{ BeginPoint = new Point2D(nwo3.X,nwo3.Z), EndPoint = new Point2D(nwo4.X, nwo4.Z) }; + var lineNWO = new Line { BeginPoint = new Point2D(nwo3.X, nwo3.Z), EndPoint = new Point2D(nwo4.X, nwo4.Z) }; var linePL = new Line { BeginPoint = new Point2D(intersection1.X, intersection1.Z), EndPoint = new Point2D(nwo4.X, intersection1.Z) }; var isp = new GeometryPoint(); if (LineHelper.GetStrictIntersectionPoint(lineNWO, linePL, ref isp)) @@ -1223,7 +1234,7 @@ } else { - var lineNWOb = new Line{ BeginPoint = new Point2D(nwo2.X, nwo2.Z), EndPoint = new Point2D(nwo3.X, nwo3.Z) }; + var lineNWOb = new Line { BeginPoint = new Point2D(nwo2.X, nwo2.Z), EndPoint = new Point2D(nwo3.X, nwo3.Z) }; if (LineHelper.GetStrictIntersectionPoint(lineNWOb, linePL, ref isp)) { var newP1 = pl1Line.EnsurePointAtX(intersection1.X, GeometryPoint.Precision); @@ -1292,7 +1303,7 @@ private void MakeWaterLevelHorizontalInNWOAtRiverSideUsingInterSection2(GeometryPoint nwo1, GeometryPoint nwo2, GeometryPoint nwo3, PlLine pl1Line, PlLinePoint nwo1Pl, PlLinePoint nwo2Pl, PlLinePoint nwo3Pl, GeometryPoint intersection2) { var lineNWO = new Line { BeginPoint = new Point2D(nwo1.X, nwo1.Z), EndPoint = new Point2D(nwo2.X, nwo2.Z) }; - var linePL = new Line { BeginPoint = new Point2D(nwo1.X, intersection2.Z), EndPoint = new Point2D(intersection2.X,intersection2.Z) }; + var linePL = new Line { BeginPoint = new Point2D(nwo1.X, intersection2.Z), EndPoint = new Point2D(intersection2.X, intersection2.Z) }; var isp = new GeometryPoint(); if (LineHelper.GetStrictIntersectionPoint(lineNWO, linePL, ref isp)) { @@ -1336,7 +1347,7 @@ private void MakeWaterLevelHorizontalInNWOAtRiverSideUsingInterSection1(GeometryPoint nwo2, GeometryPoint nwo3, GeometryPoint nwo4, PlLine pl1Line, PlLinePoint nwo3Pl, PlLinePoint nwo4Pl, GeometryPoint intersection1) { var lineNWO = new Line { BeginPoint = new Point2D(nwo3.X, nwo3.Z), EndPoint = new Point2D(nwo4.X, nwo4.Z) }; - var linePL = new Line { BeginPoint = new Point2D(intersection1.X,intersection1.Z), EndPoint = new Point2D(nwo4.X, intersection1.Z) }; + var linePL = new Line { BeginPoint = new Point2D(intersection1.X, intersection1.Z), EndPoint = new Point2D(nwo4.X, intersection1.Z) }; var isp = new GeometryPoint(); if (LineHelper.GetStrictIntersectionPoint(lineNWO, linePL, ref isp)) { @@ -1382,9 +1393,7 @@ foreach (var plLinePoint in plPointsToBeMoved) { // Determine which of these points must be moved and move them - if (this.surfaceLine.Geometry.GetZatX(plLinePoint.X) - cOffsetPhreaticLineBelowSurface > plLinePoint.Z ) - //.PositionXzOfPointRelatedToExtrapolatedLine(plLinePoint) != - // RelativeXzPosition.BelowGeometricLine) + if (this.surfaceLine.Geometry.GetZatX(plLinePoint.X) - cOffsetPhreaticLineBelowSurface > plLinePoint.Z) { plLinePoint.Z = this.surfaceLine.Geometry.GetZatX(plLinePoint.X) - cOffsetPhreaticLineBelowSurface; } Index: DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStabilityInwards/DamMacroStabilityInwardsKernelWrapperTests.cs =================================================================== diff -u -r1979 -r2054 --- DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStabilityInwards/DamMacroStabilityInwardsKernelWrapperTests.cs (.../DamMacroStabilityInwardsKernelWrapperTests.cs) (revision 1979) +++ DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStabilityInwards/DamMacroStabilityInwardsKernelWrapperTests.cs (.../DamMacroStabilityInwardsKernelWrapperTests.cs) (revision 2054) @@ -202,7 +202,7 @@ var xDocument = ModifiedXmlDocument(xmlFileName, stiFileName, soilDbName, geometryFileName); var kernelWrapper = new DamMacroStabilityInwardsKernelWrapper(); - kernelWrapper.CreateStiFile(xDocument,null); + kernelWrapper.CreateStiFile(xDocument,null,null); Assert.IsTrue(File.Exists(stiFileName)); Assert.AreEqual(ContentOfStiFile(expectedStiFileName), ContentOfStiFile(stiFileName)); } @@ -213,7 +213,7 @@ { var kernelWrapper = new DamMacroStabilityInwardsKernelWrapper(); XDocument xDocument = new XDocument(); - kernelWrapper.CreateStiFile(xDocument,null); + kernelWrapper.CreateStiFile(xDocument,null,null); } private string ContentOfStiFile(string stiFileName)