Index: DamEngine/branches/Sliding/src/Deltares.DamEngine.Calculators/KernelWrappers/DamSliding/DamPipingBlighInput.cs =================================================================== diff -u -r1302 -r1305 --- DamEngine/branches/Sliding/src/Deltares.DamEngine.Calculators/KernelWrappers/DamSliding/DamPipingBlighInput.cs (.../DamPipingBligh/DamPipingBlighInput.cs) (revision 1302) +++ DamEngine/branches/Sliding/src/Deltares.DamEngine.Calculators/KernelWrappers/DamSliding/DamPipingBlighInput.cs (.../DamSliding/DamSlidingInput.cs) (revision 1305) @@ -20,56 +20,18 @@ // All rights reserved. using Deltares.DamEngine.Calculators.KernelWrappers.Interfaces; +using Deltares.DamEngine.Data.Geometry; +using System.Collections.Generic; -namespace Deltares.DamEngine.Calculators.KernelWrappers.DamPipingBligh +namespace Deltares.DamEngine.Calculators.KernelWrappers.DamSliding { /// /// Input parameters for Piping bligh /// /// - public class DamPipingBlighInput : IKernelDataInput + public class DamSlidingInput : IKernelDataInput { - /// - /// Gets or sets the River level . - /// - /// - /// The h river. - /// - public double HRiver { get; set; } - /// - /// Gets or sets the head at exitpoint. - /// - /// - /// The h exit. - /// - public double HExit { get; set; } - /// - /// Gets or sets the reduction factor. - /// - /// - /// The rc. - /// - public double Rc { get; set; } - /// - /// Gets or sets the total thickness of cover layer . - /// - /// - /// The d total. - /// - public double DTotal { get; set; } - /// - /// Gets or sets the seepagelength. - /// - /// - /// The length of the seepage. - /// - public double SeepageLength { get; set; } - /// - /// Gets or sets the D70. - /// - /// - /// The D70. - /// - public double D70 { get; set; } + public string Directory { get; set; } + public List Coordinates = new List(); } } Index: DamEngine/branches/Sliding/src/Deltares.DamEngine.Calculators/Deltares.DamEngine.Calculators.csproj =================================================================== diff -u -r1302 -r1305 --- DamEngine/branches/Sliding/src/Deltares.DamEngine.Calculators/Deltares.DamEngine.Calculators.csproj (.../Deltares.DamEngine.Calculators.csproj) (revision 1302) +++ DamEngine/branches/Sliding/src/Deltares.DamEngine.Calculators/Deltares.DamEngine.Calculators.csproj (.../Deltares.DamEngine.Calculators.csproj) (revision 1305) @@ -65,6 +65,9 @@ + + + Index: DamEngine/branches/Sliding/src/Deltares.DamEngine.Calculators/KernelWrappers/Common/KernelWrapperHelper.cs =================================================================== diff -u -r1302 -r1305 --- DamEngine/branches/Sliding/src/Deltares.DamEngine.Calculators/KernelWrappers/Common/KernelWrapperHelper.cs (.../KernelWrapperHelper.cs) (revision 1302) +++ DamEngine/branches/Sliding/src/Deltares.DamEngine.Calculators/KernelWrappers/Common/KernelWrapperHelper.cs (.../KernelWrapperHelper.cs) (revision 1305) @@ -26,6 +26,7 @@ using Deltares.DamEngine.Calculators.KernelWrappers.DamPipingBligh; using Deltares.DamEngine.Calculators.KernelWrappers.DamPipingSellmeijer4Forces; using Deltares.DamEngine.Calculators.KernelWrappers.DamPipingSellmeijerVnk; +using Deltares.DamEngine.Calculators.KernelWrappers.DamSliding; using Deltares.DamEngine.Calculators.KernelWrappers.Interfaces; using Deltares.DamEngine.Calculators.Properties; using Deltares.DamEngine.Data.General; @@ -78,6 +79,10 @@ throw new NotImplementedException(Resources.DesignCalculatorKernelNotImplemented); } break; + case FailureMechanismSystemType.Sliding: + kernelWrapper = new DamSlidingKernelWrapper(); + break; + } return kernelWrapper; } Index: DamEngine/branches/Sliding/src/Deltares.DamEngine.Calculators/KernelWrappers/DamSliding/DamPipingBlighKernelWrapper.cs =================================================================== diff -u -r1302 -r1305 --- DamEngine/branches/Sliding/src/Deltares.DamEngine.Calculators/KernelWrappers/DamSliding/DamPipingBlighKernelWrapper.cs (.../DamPipingBligh/DamPipingBlighKernelWrapper.cs) (revision 1302) +++ DamEngine/branches/Sliding/src/Deltares.DamEngine.Calculators/KernelWrappers/DamSliding/DamPipingBlighKernelWrapper.cs (.../DamSliding/DamSlidingKernelWrapper.cs) (revision 1305) @@ -22,8 +22,12 @@ using System; using System.Collections.Generic; using System.Data; +using System.Diagnostics; +using System.Globalization; +using System.IO; using Deltares.DamEngine.Calculators.DikesDesign; using Deltares.DamEngine.Calculators.KernelWrappers.Common; +using Deltares.DamEngine.Calculators.KernelWrappers.DamSliding; using Deltares.DamEngine.Calculators.KernelWrappers.Interfaces; using Deltares.DamEngine.Calculators.Properties; using Deltares.DamEngine.Calculators.Uplift; @@ -34,20 +38,28 @@ using Deltares.DamEngine.Data.Geometry; using Deltares.DamEngine.Data.Geotechnics; using Deltares.DamEngine.Data.Standard.Calculation; +using Deltares.DamEngine.Data.Standard.Language; using Deltares.DamEngine.Data.Standard.Logging; using Deltares.DamPiping.BlighCalculator; +using log4net; -namespace Deltares.DamEngine.Calculators.KernelWrappers.DamPipingBligh +namespace Deltares.DamEngine.Calculators.KernelWrappers.DamSliding { + /// /// Wrapper around Bligh piping kernel /// /// - public class DamPipingBlighKernelWrapper : IKernelWrapper + public class DamSlidingKernelWrapper : IKernelWrapper { + const string python = @"c:\anaconda27\python.exe"; + const string damSafeDirectory = @"D:\Internship M. Pasqualini\calculations\main_dam\MAIN_DAM"; + private const double defaultFluidisationGradient = 0.3; private const double defaultMaxReturnValue = 90.0; + private Dictionary> processMessages = new Dictionary>(); + /// /// Create the kernel input. /// @@ -60,85 +72,19 @@ /// public PrepareResult Prepare(DamKernelInput damKernelInput, int iterationIndex, out IKernelDataInput kernelDataInput, out IKernelDataOutput kernelDataOutput) { - var damPipingBlighOutput = new DamPipingBlighOutput() + var damSlidingOutput = new DamSlidingOutput() { CalculationResult = CalculationResult.NoRun, - FoSp = defaultMaxReturnValue }; - kernelDataOutput = damPipingBlighOutput; - if (damKernelInput.SubSoilScenario.SegmentFailureMechanismType == FailureMechanismSystemType.Piping) - { - var damPipingBlighInput = new DamPipingBlighInput(); - var soilProfile1D = damKernelInput.SubSoilScenario.SoilProfile1D; - var location = damKernelInput.Location; - double waterLevel = damKernelInput.RiverLevelHigh; - UpliftSituation upliftSituation; - PlLines plLines = PlLinesHelper.CreatePlLinesForPiping(location, soilProfile1D, waterLevel, - damKernelInput.DamFailureMechanismeCalculationSpecification.AssessmentScenarioJobSettings.HydraulicShortcutType, - out upliftSituation); - EvaluateUpliftSituation(damKernelInput, out kernelDataInput, plLines, damPipingBlighInput, waterLevel, damPipingBlighOutput); - return PrepareResult.Successful; - } - kernelDataInput = null; - return PrepareResult.NotRelevant; - } + kernelDataOutput = damSlidingOutput; + var damSlidingInput = new DamSlidingInput(); - private static void EvaluateUpliftSituation(DamKernelInput damKernelInput, out IKernelDataInput kernelDataInput, PlLines plLines, DamPipingBlighInput damPipingBlighInput, double waterLevel, DamPipingBlighOutput damPipingBlighOutput) - { - const double upliftCriterionTolerance = 0.000000001; - SoilProfile1D soilProfile1D = damKernelInput.SubSoilScenario.SoilProfile1D; - SurfaceLine2 surfaceLine = damKernelInput.Location.SurfaceLine; - Location location = damKernelInput.Location; - UpliftSituation upliftSituation = new UpliftSituation(); - UpliftLocationDeterminator upliftLocationDeterminator = new UpliftLocationDeterminator - { - PlLines = plLines, - SoilProfile = soilProfile1D, - SurfaceLine = surfaceLine, - DikeEmbankmentMaterial = location.GetDikeEmbankmentSoil(), - XSoilGeometry2DOrigin = location.XSoilGeometry2DOrigin - }; - // The tolerance is built in because after design it could be that the value that is designed to, is not reached by this margin - double upliftCriterion = location.UpliftCriterionPiping.Value - upliftCriterionTolerance; - var upliftLocationAndResult = upliftLocationDeterminator.GetLocationAndResult(upliftCriterion); - upliftSituation.IsUplift = (upliftLocationAndResult != null); - double xEntry = surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtRiver).X; - double xExit = 0.0; - double surfaceLevel = 0.0; - double d70 = 0.0; - double dCoverLayer = 0.0; - double? upliftFactor = null; - if (upliftLocationAndResult != null) - { - xExit = upliftLocationAndResult.X; - surfaceLevel = surfaceLine.Geometry.GetZatX(upliftLocationAndResult.X); - SoilLayer1D heaveLayer = soilProfile1D.GetLayerWithName(upliftLocationAndResult.LayerWhereUpliftOccuresId); - d70 = Physics.FactorMeterToMicroMeter * heaveLayer.Soil.DiameterD70; - var topLevelAquifer = soilProfile1D.GetLayerWithName(upliftLocationAndResult.LayerWhereUpliftOccuresId).TopLevel; - dCoverLayer = DamPipingHelper.DetermineHeightCoverLayer(topLevelAquifer, surfaceLevel); - upliftFactor = upliftLocationAndResult.UpliftFactor; - } - double seepageLength = xExit - xEntry; - damPipingBlighInput.HRiver = waterLevel; - // Reference level is highest value of surfaceLevel or PolderLevel - // Uit TR Zandmeevoerende wellen (1999): "Het verval dH is gelijk aan het verschil tussen buitenwaterstand (het ontwerppeil(OP)) - // bij zeedijken en de maatgevende hoogwaterstand (MHW bij rivierdijken) en de waterstand binnendijks ter plaatse van het uittredepunt, - // rekening houdend met zeespiegelrijzing etc.(zie paragraaf 3.7.2). In dien ter plaatse van het uittreepunt of de opbarstlocatie - // geen vrije waterstand heerst kan gerekend worden met het maaiveldniveau, rekening houdend met eventuele maaiveld daling (zie paragraaf 3.7.2)." - var referenceLevel = Math.Max(location.PolderLevel, surfaceLevel); - kernelDataInput = new DamPipingBlighInput() - { - HRiver = waterLevel, - HExit = referenceLevel, - Rc = defaultFluidisationGradient, - DTotal = dCoverLayer, - SeepageLength = seepageLength, - D70 = d70, - }; - damPipingBlighOutput.ExitPointX = xExit; - damPipingBlighOutput.UpliftFactor = upliftFactor; - damPipingBlighOutput.UpliftSituation = upliftSituation; + damSlidingInput.Directory = damKernelInput.CalculationDir; + damSlidingInput.Coordinates.AddRange(damKernelInput.Location.SurfaceLine.Geometry.Points); + kernelDataInput = damSlidingInput; + + return PrepareResult.Successful; } /// @@ -152,23 +98,8 @@ /// public int Validate(IKernelDataInput kernelDataInput, IKernelDataOutput kernelDataOutput, out List messages) { - DamPipingBlighOutput damPipingBlighOutput = (DamPipingBlighOutput) kernelDataOutput; - var calculatorBligh = CreatePipingCalculatorBligh(kernelDataInput); - List kernelMessages = calculatorBligh.Validate(); messages = new List(); - foreach (string stringMessage in kernelMessages) - { - messages.Add(new LogMessage() - { - Message = stringMessage, - MessageType = LogMessageType.Error - }); - } - if (messages.Count > 0) - { - damPipingBlighOutput.CalculationResult = CalculationResult.InvalidInputData; - } - return messages.Count; + return 0; } /// @@ -180,59 +111,68 @@ /// No input object defined for Bligh public void Execute(IKernelDataInput kernelDataInput, IKernelDataOutput kernelDataOutput, out List messages) { - DamPipingBlighInput damPipingBlighInput = kernelDataInput as DamPipingBlighInput; - DamPipingBlighOutput damPipingBlighOutput = (DamPipingBlighOutput)kernelDataOutput; - ThrowWhenKernelInputNull(damPipingBlighInput); - ThrowWhenKernelOutputNull(damPipingBlighOutput); - PerformSingleCalculationBligh(out messages, damPipingBlighOutput, damPipingBlighInput); + DamSlidingInput damSlidingInput = kernelDataInput as DamSlidingInput; + DamSlidingOutput damSlidingOutput = (DamSlidingOutput)kernelDataOutput; + ThrowWhenKernelInputNull(damSlidingInput); + ThrowWhenKernelOutputNull(damSlidingOutput); + Calculate(out messages, damSlidingOutput, damSlidingInput); } - private static void PerformSingleCalculationBligh(out List messages, DamPipingBlighOutput damPipingBlighOutput, DamPipingBlighInput damPipingBlighInput) + private void Calculate(out List messages, DamSlidingOutput damSlidingOutput, DamSlidingInput damSlidingInput) { - damPipingBlighOutput.CalculationResult = CalculationResult.NoRun; - damPipingBlighOutput.FoSp = defaultMaxReturnValue; + damSlidingOutput.CalculationResult = CalculationResult.NoRun; messages = new List(); + try { - if (damPipingBlighOutput.UpliftSituation.IsUplift) + string workDirectory = damSlidingInput.Directory; + + CopyDirectory(damSafeDirectory, workDirectory); + + //Coord X Coord Z + //0; 589.48 + //4.1148; 598.624 + //6.858; 607.768 + //9.2964; 619.96 + List lines = new List(); + lines.Add("Coord X Coord Z"); + foreach (GeometryPoint point in damSlidingInput.Coordinates) { - var calculatorBligh = CreatePipingCalculatorBligh(damPipingBlighInput); - calculatorBligh.Calculate(); - damPipingBlighOutput.FoSp = calculatorBligh.FoSp; - damPipingBlighOutput.Hc = calculatorBligh.Hc; - damPipingBlighOutput.CalculationResult = CalculationResult.Succeeded; + lines.Add(string.Format("{0:F4}; {1:F4}", point.X, point.Z * 100)); } + File.WriteAllLines(Path.Combine(workDirectory, "inputs", "dam_nonOverFlow.txt"), lines); + + Process process = StartProcess(python, workDirectory, Path.Combine(workDirectory, "MAINDAM_CALC.py"), messages); + + WaitForExit(process); + + string outputFile = Path.Combine(workDirectory, "results", "report_NonOverflow_section.txt"); + + //----------------- + //| SF_slid = 2.185 | + //| SF_over = 1.724 | + //----------------- + + foreach (string line in File.ReadAllLines(outputFile)) + { + if (line.StartsWith("| SF_slid =")) + { + damSlidingOutput.Sliding = Double.Parse(line.Split("=|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)[1], CultureInfo.InvariantCulture); + } + if (line.StartsWith("| SF_over =")) + { + damSlidingOutput.Overtopping = Double.Parse(line.Split("=|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)[1], CultureInfo.InvariantCulture); + } + } } catch (Exception e) { - damPipingBlighOutput.CalculationResult = CalculationResult.UnexpectedError; + damSlidingOutput.CalculationResult = CalculationResult.UnexpectedError; messages.Add(new LogMessage(LogMessageType.Error, null, e.Message)); } } /// - /// Creates the piping calculator bligh based on kernel input. - /// - /// The kernel data input. - /// - /// No input object defined for Bligh - private static PipingCalculatorBligh CreatePipingCalculatorBligh(IKernelDataInput kernelDataInput) - { - DamPipingBlighInput damPipingBlighInput = kernelDataInput as DamPipingBlighInput; - ThrowWhenKernelInputNull(damPipingBlighInput); - var calculator = new PipingCalculatorBligh - { - HRiver = damPipingBlighInput.HRiver, - HExit = damPipingBlighInput.HExit, - Rc = damPipingBlighInput.Rc, - DTotal = damPipingBlighInput.DTotal, - SeepageLength = damPipingBlighInput.SeepageLength, - D70 = damPipingBlighInput.D70 - }; - return calculator; - } - - /// /// Fills the design results from the kernel output. /// /// The dam kernel input. @@ -245,152 +185,245 @@ DesignScenario designScenario, string resultMessage, out List designResults) { - DamPipingBlighOutput damPipingBlighOutput = kernelDataOutput as DamPipingBlighOutput; + DamSlidingOutput damSlidingOutput = kernelDataOutput as DamSlidingOutput; ThrowWhenDamKernelInputNull(damKernelInput); - ThrowWhenKernelOutputNull(damPipingBlighOutput); + ThrowWhenKernelOutputNull(damSlidingOutput); designResults = new List(); - var designResult = new DesignResult(damKernelInput.DamFailureMechanismeCalculationSpecification, + + var designResult = new DesignResult(damKernelInput.DamFailureMechanismeCalculationSpecification, designScenario, damKernelInput.SubSoilScenario.SoilProfile1D, null) { - CalculationResult = damPipingBlighOutput.CalculationResult + CalculationResult = damSlidingOutput.CalculationResult }; - var pipingDesignResults = new PipingDesignResults(PipingModelType.Bligh); - designResult.PipingDesignResults = pipingDesignResults; - pipingDesignResults.ResultMessage = resultMessage; - pipingDesignResults.BlighFactor = damPipingBlighOutput.FoSp; - pipingDesignResults.BlighHcritical = damPipingBlighOutput.Hc; - pipingDesignResults.RedesignedSurfaceLine = damKernelInput.Location.SurfaceLine; - pipingDesignResults.UpliftSituation = damPipingBlighOutput.UpliftSituation; - pipingDesignResults.LocalExitPointX = damPipingBlighOutput.ExitPointX; - pipingDesignResults.UpliftFactor = damPipingBlighOutput.UpliftFactor; + + var slidingResults = new SlidingResults(); + slidingResults.Sliding = damSlidingOutput.Sliding; + slidingResults.Overtopping = damSlidingOutput.Overtopping; + + designResult.SlidingResults = slidingResults; + designResults.Add(designResult); } + public void PrepareDesign(IKernelDataInput kernelDataInput, IKernelDataOutput kernelDataOutput, DamKernelInput damKernelInput, + int iterationIndex, out EmbankmentDesignParameters embankmentDesignParameters) + { + embankmentDesignParameters = null; + } + + public ShoulderDesign CalculateDesignAtPoint(DamKernelInput damKernelInput, IKernelDataInput kernelDataInput, IKernelDataOutput kernelDataOutput, GeometryPoint point, out List messages) + { + throw new NotImplementedException(); + } + /// - /// Calculates the design at point. + /// Gets the design strategy /// - /// The dam kernel input. - /// The kernel data input. - /// The kernel data output. - /// The point. - /// The messages. + /// /// - public ShoulderDesign CalculateDesignAtPoint(DamKernelInput damKernelInput, IKernelDataInput kernelDataInput, IKernelDataOutput kernelDataOutput, GeometryPoint point, out List messages) + public DesignStrategy GetDesignStrategy(DamKernelInput damKernelInput) { - messages = new List(); - DamPipingBlighInput damPipingBlighInput = kernelDataInput as DamPipingBlighInput; - DamPipingBlighOutput damPipingBlighOutput = (DamPipingBlighOutput)kernelDataOutput; - ThrowWhenDamKernelInputNull(damKernelInput); - ThrowWhenKernelOutputNull(damPipingBlighOutput); - Location location = damKernelInput.Location; - SoilProfile1D soilProfile = damKernelInput.SubSoilScenario.SoilProfile1D; - SurfaceLine2 surfaceLine = damKernelInput.Location.SurfaceLine; + return DesignStrategy.NoDesignPossible; + } - PlLines plLines; - UpliftLocationAndResult upliftLocationAndResult; - DamPipingHelper.DeterminePlLinesAndUpliftLocation(damKernelInput, point, out plLines, out upliftLocationAndResult); + public bool EvaluateDesign(DamKernelInput damKernelInput, IKernelDataInput kernelDataInput, IKernelDataOutput kernelDataOutput, + out DesignAdvise designAdvise, out string evaluationMessage) + { + throw new NotImplementedException(); + } - double requiredFoS = location.ModelFactors.RequiredSafetyFactorPiping.Value; - double upliftCriterion = location.UpliftCriterionPiping.Value; - // if there is no uplift, then there is no piping so return null - if (upliftLocationAndResult != null) + private static void ThrowWhenKernelInputNull(DamSlidingInput damSlidingInput) + { + if (damSlidingInput == null) { - double xEntry = surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtRiver).X; - double xExit = upliftLocationAndResult.X; - damPipingBlighInput.SeepageLength = xExit - xEntry; - var topLevelAquifer = soilProfile.GetLayerWithName(upliftLocationAndResult.LayerWhereUpliftOccuresId).TopLevel; + throw new NoNullAllowedException(); + } + } - // The following 2 parameters are dependent on the position of the point and have to be recalculated for the current point - double dCoverLayer = DamPipingHelper.DetermineHeightCoverLayer(topLevelAquifer, point.Z); // point.Z is surfacelevel - damPipingBlighInput.DTotal = dCoverLayer; - double referenceLevel = Math.Max(location.PolderLevel, point.Z); // point.Z is surfacelevel - damPipingBlighInput.HExit = referenceLevel; + private static void ThrowWhenKernelOutputNull(DamSlidingOutput damSlidingOutput) + { + if (damSlidingOutput == null) + { + throw new NoNullAllowedException(); + } + } - // Calculate the piping safety factor using the level of the given point - PerformSingleCalculationBligh(out messages, damPipingBlighOutput, damPipingBlighInput); + private static void ThrowWhenDamKernelInputNull(DamKernelInput damKernelInput) + { + if (damKernelInput == null) + { + throw new NoNullAllowedException(); + } + } - // If too low, then determine required height and length (from uplift) - if (damPipingBlighOutput.FoSp < requiredFoS) + /// + /// Copies a directory and all of its contents + /// + /// + /// + public static void CopyDirectory(string source, string target) + { + if (!Directory.Exists(target)) + { + Directory.CreateDirectory(target); + } + + string[] sysEntries = Directory.Exists(source) ? Directory.GetFileSystemEntries(source) : new string[0]; + + foreach (var sysEntry in sysEntries) + { + string fileName = Path.GetFileName(sysEntry); + string targetPath = Path.Combine(target, fileName); + if (Directory.Exists(sysEntry)) { - // Finally, determine the required shoulderheight - double currentShoulderHeight = upliftLocationAndResult.Z - - surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtPolder).Z; - var shoulderDesign = new ShoulderDesign( - upliftLocationAndResult.X - surfaceLine.GetDikeToeInward().X, - currentShoulderHeight + ShoulderDesignHelper.CalculateExtraShoulderHeight(soilProfile, plLines, upliftLocationAndResult, upliftCriterion)); - return shoulderDesign; + CopyDirectory(sysEntry, targetPath); } + else + { + File.Copy(sysEntry, targetPath, true); + } } - return null; } /// - /// Evaluates the design (current factor greater than desired factor) + /// Deletes a directory and all of its contents /// - /// The dam kernel input. - /// The kernel data input. - /// The kernel data output. - /// The design advise. - /// The evaluation message. - /// - /// if the design was succesful - /// - /// - public bool EvaluateDesign(DamKernelInput damKernelInput, IKernelDataInput kernelDataInput, IKernelDataOutput kernelDataOutput, - out DesignAdvise designAdvise, out string evaluationMessage) + /// + public static void DeleteDirectory(string path) { - DamPipingBlighInput damPipingBlighInput = kernelDataInput as DamPipingBlighInput; - DamPipingBlighOutput damPipingBlighOutput = (DamPipingBlighOutput)kernelDataOutput; - ThrowWhenKernelInputNull(damPipingBlighInput); - ThrowWhenDamKernelInputNull(damKernelInput); - ThrowWhenKernelOutputNull(damPipingBlighOutput); - double fosRequired = damKernelInput.Location.ModelFactors.RequiredSafetyFactorPiping.Value; - double fosAchieved = damPipingBlighOutput.FoSp; - evaluationMessage = String.Format(Resources.FactorAchievedVsFactorRequired, fosAchieved, fosRequired); - designAdvise = DesignAdvise.None; - return (fosAchieved >= fosRequired); + var subfolders = Directory.GetDirectories(path); + foreach (var s in subfolders) + { + DeleteDirectory(s); + } + + // Get all files of the folder + var files = Directory.GetFiles(path); + foreach (var f in files) + { + // Get the attributes of the file + var attr = File.GetAttributes(f); + + // Is this file marked as 'read-only'? + if ((attr & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) + { + // Yes... Remove the 'read-only' attribute, then + File.SetAttributes(f, attr ^ FileAttributes.ReadOnly); + } + + // Delete the file + File.Delete(f); + } + + // When we get here, all the files of the folder were + // already deleted, so we just delete the empty folder + try + { + Directory.Delete(path); + } + catch + { + } } - public void PrepareDesign(IKernelDataInput kernelDataInput, IKernelDataOutput kernelDataOutput, DamKernelInput damKernelInput, - int iterationIndex, out EmbankmentDesignParameters embankmentDesignParameters) + public static string GetTemporaryDirectory() { - throw new NotImplementedException(); + while (true) + { + string tempDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); + if (!Directory.Exists(tempDirectory)) + { + Directory.CreateDirectory(tempDirectory); + return tempDirectory; + } + } } - /// - /// Gets the design strategy - /// - /// - /// - public DesignStrategy GetDesignStrategy(DamKernelInput damKernelInput) + private Process StartProcess(string executable, string workingDirectory, string arguments, List messages) { - return DesignStrategy.ShoulderPerPoint; + var startInfo = new ProcessStartInfo + { + FileName = executable, + Arguments = arguments, + WorkingDirectory = workingDirectory, + }; + + startInfo.UseShellExecute = false; + startInfo.RedirectStandardError = true; + startInfo.RedirectStandardOutput = true; + startInfo.RedirectStandardInput = false; + startInfo.CreateNoWindow = true; + startInfo.WindowStyle = ProcessWindowStyle.Hidden; + + var process = new Process + { + StartInfo = startInfo + }; + + processMessages[process] = messages; + + process.OutputDataReceived += process_OutputDataReceived; + process.ErrorDataReceived += process_ErrorDataReceived; + + process.Start(); + + process.BeginErrorReadLine(); + process.BeginOutputReadLine(); + + return process; } - private static void ThrowWhenKernelInputNull(DamPipingBlighInput damPipingBlighInput) + private int WaitForExit(Process process) { - if (damPipingBlighInput == null) + try { - throw new NoNullAllowedException(Resources.DamPipingBlighKernelWrapper_NoInputObjectDefinedForBligh); + process.WaitForExit(); } + catch + { + if (!process.HasExited) + { + process.Kill(); + } + return 2; + } + + var exitCode = process.ExitCode; + process.Close(); + + process.OutputDataReceived -= process_OutputDataReceived; + process.ErrorDataReceived -= process_ErrorDataReceived; + + processMessages.Remove(process); + + return exitCode; } - private static void ThrowWhenKernelOutputNull(DamPipingBlighOutput damPipingBlighOutput) + + private void process_OutputDataReceived(object sender, DataReceivedEventArgs e) { - if (damPipingBlighOutput == null) + if (!string.IsNullOrEmpty(e.Data)) { - throw new NoNullAllowedException(Resources.DamPipingBlighKernelWrapper_NoOutputObjectDefinedForBligh); + LogMessage logMessage = new LogMessage(LogMessageType.Info, null, e.Data); + + if (processMessages.ContainsKey((Process)sender)) + { + processMessages[(Process)sender].Add(logMessage); + } } } - private static void ThrowWhenDamKernelInputNull(DamKernelInput damKernelInput) + private void process_ErrorDataReceived(object sender, DataReceivedEventArgs e) { - if (damKernelInput == null) + if (!string.IsNullOrEmpty(e.Data) && e.Data.Trim() != "0") { - throw new NoNullAllowedException(Resources.DamPipingBlighKernelWrapper_NoDamInputObjectDefinedForBligh); + LogMessage logMessage = new LogMessage(LogMessageType.Error, null, e.Data); + if (processMessages.ContainsKey((Process)sender)) + { + processMessages[(Process)sender].Add(logMessage); + } } } - } } Index: DamEngine/branches/Sliding/src/Deltares.DamEngine.Data/General/Results/DesignResult.cs =================================================================== diff -u -r1302 -r1305 --- DamEngine/branches/Sliding/src/Deltares.DamEngine.Data/General/Results/DesignResult.cs (.../DesignResult.cs) (revision 1302) +++ DamEngine/branches/Sliding/src/Deltares.DamEngine.Data/General/Results/DesignResult.cs (.../DesignResult.cs) (revision 1305) @@ -46,6 +46,7 @@ private StabilityDesignResults stabilityDesignResults; private PipingDesignResults pipingDesignResults; + private SlidingResults slidingResults; /// /// Gets the safety factor (derived result). @@ -266,6 +267,18 @@ } } + public SlidingResults SlidingResults + { + get + { + return slidingResults; + } + set + { + slidingResults = value; + } + } + /// /// Copy data /// Index: DamEngine/branches/Sliding/xsd/GenerateClasses.bat =================================================================== diff -u -r1302 -r1305 --- DamEngine/branches/Sliding/xsd/GenerateClasses.bat (.../GenerateClasses.bat) (revision 1302) +++ DamEngine/branches/Sliding/xsd/GenerateClasses.bat (.../GenerateClasses.bat) (revision 1305) @@ -1,5 +1,7 @@ -xsd /c /l:cs /n:Deltares.DamEngine.Io.XmlInput DamInput.xsd +"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\xsd.exe" /c /l:cs /n:Deltares.DamEngine.Io.XmlInput DamInput.xsd copy DamInput.cs ..\src\Deltares.DamEngine.Io\DamInput.cs -xsd /c /l:cs /n:Deltares.DamEngine.Io.XmlOutput DamOutput.xsd +"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\xsd.exe" /c /l:cs /n:Deltares.DamEngine.Io.XmlOutput DamOutput.xsd copy DamOutput.cs ..\src\Deltares.DamEngine.Io\DamOutput.cs + +pause Index: DamEngine/branches/Sliding/src/Deltares.DamEngine.Interface/ConversionHelper.cs =================================================================== diff -u -r1302 -r1305 --- DamEngine/branches/Sliding/src/Deltares.DamEngine.Interface/ConversionHelper.cs (.../ConversionHelper.cs) (revision 1302) +++ DamEngine/branches/Sliding/src/Deltares.DamEngine.Interface/ConversionHelper.cs (.../ConversionHelper.cs) (revision 1305) @@ -337,6 +337,7 @@ public const int InputFailureMechanismStabilityOutside = 1; public const int InputFailureMechanismPiping = 2; public const int InputFailureMechanismHorizontalBalance = 3; + public const int InputFailureMechanismSliding = 4; /// /// Converts the Dam failure mechanism type to the input failure mechanism type . @@ -350,7 +351,8 @@ {FailureMechanismSystemType.StabilityInside, InputFailureMechanismStabilityInside}, {FailureMechanismSystemType.StabilityOutside, InputFailureMechanismStabilityOutside}, {FailureMechanismSystemType.Piping, InputFailureMechanismPiping}, - {FailureMechanismSystemType.HorizontalBalance, InputFailureMechanismHorizontalBalance} + {FailureMechanismSystemType.HorizontalBalance, InputFailureMechanismHorizontalBalance}, + {FailureMechanismSystemType.Sliding, InputFailureMechanismHorizontalBalance} }; return translationTable[segmentFailureMechanismType]; } @@ -367,7 +369,8 @@ {InputFailureMechanismStabilityInside, FailureMechanismSystemType.StabilityInside}, {InputFailureMechanismStabilityOutside, FailureMechanismSystemType.StabilityOutside}, {InputFailureMechanismPiping, FailureMechanismSystemType.Piping}, - {InputFailureMechanismHorizontalBalance, FailureMechanismSystemType.HorizontalBalance} + {InputFailureMechanismHorizontalBalance, FailureMechanismSystemType.HorizontalBalance}, + {InputFailureMechanismSliding, FailureMechanismSystemType.Sliding} }; return translationTable[failureMechanismSystemType]; } Index: DamEngine/branches/Sliding/xsd/DamDesignResult.xsd =================================================================== diff -u -r1302 -r1305 --- DamEngine/branches/Sliding/xsd/DamDesignResult.xsd (.../DamDesignResult.xsd) (revision 1302) +++ DamEngine/branches/Sliding/xsd/DamDesignResult.xsd (.../DamDesignResult.xsd) (revision 1305) @@ -5,6 +5,12 @@ + + + + + + Index: DamEngine/branches/Sliding/src/Deltares.DamEngine.Data/General/DAMEnumerations.cs =================================================================== diff -u -r1302 -r1305 --- DamEngine/branches/Sliding/src/Deltares.DamEngine.Data/General/DAMEnumerations.cs (.../DAMEnumerations.cs) (revision 1302) +++ DamEngine/branches/Sliding/src/Deltares.DamEngine.Data/General/DAMEnumerations.cs (.../DAMEnumerations.cs) (revision 1305) @@ -91,7 +91,8 @@ StabilityInside, StabilityOutside, Piping, - HorizontalBalance + HorizontalBalance, + Sliding } // TODO: FM this is failure mechanism specific code and should be moved to ..\KernelWrappers Index: DamEngine/branches/Sliding/src/Deltares.DamEngine.Interface/FillXmlOutputFromDam.cs =================================================================== diff -u -r1302 -r1305 --- DamEngine/branches/Sliding/src/Deltares.DamEngine.Interface/FillXmlOutputFromDam.cs (.../FillXmlOutputFromDam.cs) (revision 1302) +++ DamEngine/branches/Sliding/src/Deltares.DamEngine.Interface/FillXmlOutputFromDam.cs (.../FillXmlOutputFromDam.cs) (revision 1305) @@ -96,6 +96,10 @@ { CreateDesignResultsStabilityOutput(desResult, designResult); } + if (designResult.SlidingResults != null) + { + CreateDesignResultsSlidingOutput(desResult, designResult); + } output.Results.CalculationResults.DesignResults[designResultCount] = desResult; designResultCount++; } @@ -191,7 +195,6 @@ } } - private static void CreateDesignResultsStabilityOutput(DesignResult desResult, Data.General.Results.DesignResult designResult) { desResult.StabilityDesignResults = new DesignResultStabilityDesignResults() @@ -265,6 +268,17 @@ } } + private static void CreateDesignResultsSlidingOutput(DesignResult desResult, Data.General.Results.DesignResult designResult) + { + desResult.SlidingDesignResults = new DesignResultSlidingDesignResults(); + + desResult.SlidingDesignResults.OvertoppingSpecified = designResult.SlidingResults.Overtopping.HasValue; + if (designResult.SlidingResults.Overtopping.HasValue) desResult.SlidingDesignResults.Overtopping = designResult.SlidingResults.Overtopping.Value; + + desResult.SlidingDesignResults.SlidingSpecified = designResult.SlidingResults.Sliding.HasValue; + if (designResult.SlidingResults.Sliding.HasValue) desResult.SlidingDesignResults.Sliding = designResult.SlidingResults.Sliding.Value; + } + private static void CreateLocationResultsOutput(DamProjectData damProjectData, Output output) { // Calculation results (per location) Index: DamEngine/branches/Sliding/src/Deltares.DamEngine.Calculators/KernelWrappers/DamSliding/DamPipingBlighOutput.cs =================================================================== diff -u -r1302 -r1305 --- DamEngine/branches/Sliding/src/Deltares.DamEngine.Calculators/KernelWrappers/DamSliding/DamPipingBlighOutput.cs (.../DamPipingBligh/DamPipingBlighOutput.cs) (revision 1302) +++ DamEngine/branches/Sliding/src/Deltares.DamEngine.Calculators/KernelWrappers/DamSliding/DamPipingBlighOutput.cs (.../DamSliding/DamSlidingOutput.cs) (revision 1305) @@ -23,13 +23,13 @@ using Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.Standard.Calculation; -namespace Deltares.DamEngine.Calculators.KernelWrappers.DamPipingBligh +namespace Deltares.DamEngine.Calculators.KernelWrappers.DamSliding { /// /// Output class for piping Bligh /// /// - public class DamPipingBlighOutput : IKernelDataOutput + public class DamSlidingOutput : IKernelDataOutput { /// /// Gets or sets the calculation result. @@ -38,40 +38,8 @@ /// The calculation result. /// public CalculationResult CalculationResult { get; set; } - /// - /// Gets or sets the safetyfactor for Bligh. - /// - /// - /// The fo sp. - /// - public double FoSp { get; set; } - /// - /// Gets or sets the H-critical. - /// - /// - /// The hc. - /// - public double Hc { get; set; } - /// - /// Gets or sets the uplift factor. - /// - /// - /// The uplift factor. - /// - public double? UpliftFactor { get; set; } - /// - /// Gets or sets the x-coordinate of the exit point. - /// - /// - /// The exit point x. - /// - public double ExitPointX { get; set; } - /// - /// Gets or sets the uplift situation. - /// - /// - /// The uplift situation. - /// - public UpliftSituation UpliftSituation { get; set; } + + public double Sliding { get; set; } + public double Overtopping { get; set; } } } Index: DamEngine/branches/Sliding/src/Deltares.DamEngine.Data/Deltares.DamEngine.Data.csproj =================================================================== diff -u -r1302 -r1305 --- DamEngine/branches/Sliding/src/Deltares.DamEngine.Data/Deltares.DamEngine.Data.csproj (.../Deltares.DamEngine.Data.csproj) (revision 1302) +++ DamEngine/branches/Sliding/src/Deltares.DamEngine.Data/Deltares.DamEngine.Data.csproj (.../Deltares.DamEngine.Data.csproj) (revision 1305) @@ -68,6 +68,7 @@ + Index: DamEngine/branches/Sliding/src/Deltares.DamEngine.Io/DamOutput.cs =================================================================== diff -u -r1302 -r1305 --- DamEngine/branches/Sliding/src/Deltares.DamEngine.Io/DamOutput.cs (.../DamOutput.cs) (revision 1302) +++ DamEngine/branches/Sliding/src/Deltares.DamEngine.Io/DamOutput.cs (.../DamOutput.cs) (revision 1305) @@ -770,6 +770,8 @@ [System.ComponentModel.DesignerCategoryAttribute("code")] public partial class DesignResult { + private DesignResultSlidingDesignResults slidingDesignResultsField; + private DesignResultStabilityDesignResults stabilityDesignResultsField; private DesignResultPipingDesignResults pipingDesignResultsField; @@ -787,6 +789,16 @@ private int calculationResultField; /// + public DesignResultSlidingDesignResults SlidingDesignResults { + get { + return this.slidingDesignResultsField; + } + set { + this.slidingDesignResultsField = value; + } + } + + /// public DesignResultStabilityDesignResults StabilityDesignResults { get { return this.stabilityDesignResultsField; @@ -879,6 +891,67 @@ [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] + public partial class DesignResultSlidingDesignResults { + + private double slidingField; + + private bool slidingFieldSpecified; + + private double overtoppingField; + + private bool overtoppingFieldSpecified; + + /// + [System.Xml.Serialization.XmlAttributeAttribute()] + public double Sliding { + get { + return this.slidingField; + } + set { + this.slidingField = value; + } + } + + /// + [System.Xml.Serialization.XmlIgnoreAttribute()] + public bool SlidingSpecified { + get { + return this.slidingFieldSpecified; + } + set { + this.slidingFieldSpecified = value; + } + } + + /// + [System.Xml.Serialization.XmlAttributeAttribute()] + public double Overtopping { + get { + return this.overtoppingField; + } + set { + this.overtoppingField = value; + } + } + + /// + [System.Xml.Serialization.XmlIgnoreAttribute()] + public bool OvertoppingSpecified { + get { + return this.overtoppingFieldSpecified; + } + set { + this.overtoppingFieldSpecified = value; + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] public partial class DesignResultStabilityDesignResults { private UpliftSituation upliftSituationField; Index: DamEngine/branches/Sliding/src/Deltares.DamEngine.Data/General/Results/PipingResults.cs =================================================================== diff -u -r1302 -r1305 --- DamEngine/branches/Sliding/src/Deltares.DamEngine.Data/General/Results/PipingResults.cs (.../PipingResults.cs) (revision 1302) +++ DamEngine/branches/Sliding/src/Deltares.DamEngine.Data/General/Results/PipingResults.cs (.../SlidingResults.cs) (revision 1305) @@ -21,20 +21,11 @@ namespace Deltares.DamEngine.Data.General.Results { - public struct PipingResults + public class SlidingResults { public string CalculationName { get; set; } public string CalculationSubDir { get; set; } - public double? BlighPipingFactor { get; set; } - public double? BlighHCritical { get; set; } - public double? Sellmeijer4ForcesPipingFactor { get; set; } - public double? Sellmeijer4ForcesHCritical { get; set; } - public double? SellmeijerVnkPipingFactor { get; set; } - public double? SellmeijerVnkHCritical { get; set; } - public double? Wti2017PipingFactor { get; set; } - public double? Wti2017HCritical { get; set; } - public double? PipingExitPointX { get; set; } - public double? UpliftFactor { get; set; } - public double? HeaveFactor { get; set; } + public double? Sliding { get; set; } + public double? Overtopping { get; set; } } } \ No newline at end of file