Index: DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Calculators/PlLinesCreator/PlLinesCreator.cs =================================================================== diff -u -r2054 -r2055 --- DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Calculators/PlLinesCreator/PlLinesCreator.cs (.../PlLinesCreator.cs) (revision 2054) +++ DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Calculators/PlLinesCreator/PlLinesCreator.cs (.../PlLinesCreator.cs) (revision 2055) @@ -1023,7 +1023,12 @@ .NonWaterRetainingObjectPoint4); if ((nwo1 != null) && (nwo2 != null) && (nwo3 != null) && (nwo4 != null)) { + if (nwo1.X < this.surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeTopAtRiver).X) + { + NWOPhreaticAdaption = PhreaticAdaptionType.None; + } + // Find all points in the Pl line that (might) coincide with the NWO IEnumerable plPointsToBeMoved = FindAllPlLinePointsAtNWOLocation(pl1Line); @@ -2017,9 +2022,18 @@ /// /// /// - private void ValidatePhreaticBelowDike(PlLine phreaticLine) + private void ValidatePhreaticBelowDike(PlLine phreaticLine)// { - int startIndex = SurfaceLine.Geometry.Points.IndexOf(SurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeTopAtRiver)); + int startIndex; + if (this.IsUseLowWaterLevel) + { + startIndex = SurfaceLine.Geometry.Points.IndexOf(SurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtRiver)); + } + else + { + startIndex = SurfaceLine.Geometry.Points.IndexOf(SurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeTopAtRiver)); + } + int stopIndex = SurfaceLine.Geometry.Points.IndexOf(SurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtPolder)); bool stopIteration = false; // This code can go into an endless loop Index: DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Calculators/KernelWrappers/Interfaces/PythonInterface.cs =================================================================== diff -u --- DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Calculators/KernelWrappers/Interfaces/PythonInterface.cs (revision 0) +++ DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Calculators/KernelWrappers/Interfaces/PythonInterface.cs (revision 2055) @@ -0,0 +1,172 @@ + +using System.Diagnostics; +using System.IO; +using System.Linq; +using Deltares.DamEngine.Calculators.KernelWrappers.Common; +using Deltares.DamEngine.Calculators.Uplift; +using Deltares.DamEngine.Data.General; +using Deltares.DamEngine.Data.Geometry; +using Deltares.DamEngine.Data.Geotechnics; + +namespace Deltares.DamEngine.Calculators.KernelWrappers.Interfaces +{ + /// + /// Defines the interface between DAM and python scripts + /// + public class PythonInterface + { + public string PythonInformationPath = Directory.GetCurrentDirectory() + "//PythonInformation"; + public string PythonPath = ""; + public string PythonScriptsLocation = ""; + public bool AddForbiddenLine = false; + public bool AddMaxXEntrance = false; + + /// + /// Finds the path where the python exe is stored. Where the path location is read from a txt file + /// + private void GetPythonInformation() + { + + if (File.Exists(PythonInformationPath)) + { + + System.IO.StreamReader pythonInfoFile = + new System.IO.StreamReader(PythonInformationPath); + + PythonPath = pythonInfoFile.ReadLine(); + PythonScriptsLocation = pythonInfoFile.ReadLine(); + + string addForbiddenLineString = pythonInfoFile.ReadLine(); + string addMaxXEntranceString = pythonInfoFile.ReadLine(); + + AddForbiddenLine = addForbiddenLineString.Split(' ').Last().Equals("1"); + AddMaxXEntrance = addMaxXEntranceString.Split(' ').Last().Equals("1"); + + } + + } + + + /// + /// Add a forbidden line and fill in the maxXentrance in the sti file + /// + /// + /// + private void AddForbiddenLineToSti(DamKernelInput damKernelInput, string stiFileName) + { + GeometryPoint forbiddenLinePoint1; + GeometryPoint forbiddenLinePoint2; + + if (damKernelInput.DamFailureMechanismeCalculationSpecification.FailureMechanismSystemType == + FailureMechanismSystemType.StabilityOutside) + { + forbiddenLinePoint1 = + damKernelInput.Location.SurfaceLine.CharacteristicPoints.GetGeometryPoint( + CharacteristicPointType.NonWaterRetainingObjectPoint4); + forbiddenLinePoint2 = + damKernelInput.Location.SurfaceLine.CharacteristicPoints.GetGeometryPoint( + CharacteristicPointType.NonWaterRetainingObjectPoint3); + } + else + { + forbiddenLinePoint1 = + damKernelInput.Location.SurfaceLine.CharacteristicPoints.GetGeometryPoint( + CharacteristicPointType.NonWaterRetainingObjectPoint1); + forbiddenLinePoint2 = + damKernelInput.Location.SurfaceLine.CharacteristicPoints.GetGeometryPoint( + CharacteristicPointType.NonWaterRetainingObjectPoint2); + } + + + + if (forbiddenLinePoint1 != null && forbiddenLinePoint2 != null) + { + + if (damKernelInput.SubSoilScenario.SoilProfileType == SoilProfileType.ProfileType1D) + { + forbiddenLinePoint2.Z = damKernelInput.SubSoilScenario.SoilProfile1D.TopAquiferLayer.TopLevel; + } + + if (damKernelInput.SubSoilScenario.SoilProfileType == SoilProfileType.ProfileType2D) + { + forbiddenLinePoint2.Z = damKernelInput.SubSoilScenario.SoilProfile2D.GetSoilProfile1D(forbiddenLinePoint2.X) + .TopAquiferLayer.TopLevel; + } + + stiFileName = '"' + stiFileName + '"'; + + + + string pythonScriptName = PythonScriptsLocation+"//AddForbiddenLine.py"; + Process process = new Process(); + process.StartInfo.FileName = PythonPath; + process.StartInfo.RedirectStandardOutput = true; + process.StartInfo.UseShellExecute = false; + process.StartInfo.Arguments = pythonScriptName + " " + + forbiddenLinePoint1.X + " " + forbiddenLinePoint2.X + " " + forbiddenLinePoint1.Z + " " + forbiddenLinePoint2.Z + " " + stiFileName; // start the python program + process.Start(); + process.WaitForExit(); + } + } + + private void DefineMaxXEntranceInSti(DamKernelInput damKernelInput, string stiFileName) + { + string isStabilityOutside = "False"; + GeometryPoint dikeTop; + if (damKernelInput.DamFailureMechanismeCalculationSpecification.FailureMechanismSystemType == + FailureMechanismSystemType.StabilityOutside) + { + dikeTop = damKernelInput.Location.SurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeTopAtRiver); + + isStabilityOutside = "True"; + } + else + { + dikeTop = damKernelInput.Location.SurfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeTopAtPolder); + } + + if (dikeTop != null) + { + stiFileName = '"' + stiFileName + '"'; + + string pythonScriptName = PythonScriptsLocation+ "//DefineXEntryMax.py"; + Process process = new Process(); + process.StartInfo.FileName = PythonPath; + process.StartInfo.RedirectStandardOutput = true; + process.StartInfo.UseShellExecute = false; + process.StartInfo.Arguments = pythonScriptName + " " + dikeTop.X + " " + isStabilityOutside + " " + stiFileName; // start the python program + process.Start(); + process.WaitForExit(); + } + } + + /// + /// Perform all required actions in python scripts + /// + /// + /// + public void PerformPythonActions(DamKernelInput damKernelInput, string stiFileName="") + { + GetPythonInformation(); + if (AddForbiddenLine) + { + AddForbiddenLineToSti(damKernelInput, stiFileName); + } + if (AddMaxXEntrance) + { + DefineMaxXEntranceInSti(damKernelInput, stiFileName); + } + } + /// + /// Delete the python information + /// + public void ClearPythonActions() + { + if (File.Exists(PythonInformationPath)) + { + File.Delete(PythonInformationPath); + } + } + + } +} Index: DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Data/General/PlLines/PlLine.cs =================================================================== diff -u -r1848 -r2055 --- DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Data/General/PlLines/PlLine.cs (.../PlLine.cs) (revision 1848) +++ DamEngine/branches/nwo_18.1/src/Deltares.DamEngine.Data/General/PlLines/PlLine.cs (.../PlLine.cs) (revision 2055) @@ -120,7 +120,6 @@ { get { return this.Points.OrderBy(p => p.X); } } - } }