Index: DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/DikesDesign/DesignCalculator.cs =================================================================== diff -u -r4225 -r4289 --- DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/DikesDesign/DesignCalculator.cs (.../DesignCalculator.cs) (revision 4225) +++ DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/DikesDesign/DesignCalculator.cs (.../DesignCalculator.cs) (revision 4289) @@ -25,6 +25,7 @@ using System.IO; using Deltares.DamEngine.Calculators.General; using Deltares.DamEngine.Calculators.KernelWrappers.Common; +using Deltares.DamEngine.Calculators.KernelWrappers.DamMacroStabilityCommon; using Deltares.DamEngine.Calculators.KernelWrappers.Interfaces; using Deltares.DamEngine.Calculators.Properties; using Deltares.DamEngine.Data.Design; @@ -53,72 +54,101 @@ public void Execute(DamProjectData damProjectData) { progressDelegate?.Invoke(0); - damProjectData.DesignCalculations = new List(); - if (damProjectData.CalculationMessages == null) - { - damProjectData.CalculationMessages = new List(); - } - else - { - damProjectData.CalculationMessages.Clear(); - } - // Prepare the designCalculatorTasks var designCalculatorTasks = new List(); var relevantCombinationsCount = 0; - for (int locationIndex = 0; locationIndex < damProjectData.Dike.Locations.Count; locationIndex++) + //string taskStr = "Content InputTasks for " + damProjectData.MaxCalculationCores.ToString() + Environment.NewLine; + lock (damProjectData) { - var location = damProjectData.Dike.Locations[locationIndex].Copy(); - if (location.Segment.SoilProfileProbabilities.Count == 0) + damProjectData.DesignCalculations = new List(); + if (damProjectData.CalculationMessages == null) { - var message = new LogMessage(); - message.Message = string.Format(Resources.DesignCalculatorNoSoilProfilesAvailableForLocation, location.Name); - message.MessageType = LogMessageType.Warning; - damProjectData.CalculationMessages.Add(message); + damProjectData.CalculationMessages = new List(); } else { - for (int subSoilScenarioIndex = 0; subSoilScenarioIndex < location.Segment.SoilProfileProbabilities.Count; subSoilScenarioIndex++) + damProjectData.CalculationMessages.Clear(); + } + + foreach (var originalLocation in damProjectData.Dike.Locations) + { + var location = originalLocation.Copy(); + if (location.Segment.SoilProfileProbabilities.Count == 0) { - // Check if the subSoilScenario is applicable for the failuremechanism that is being calculated - if (location.Segment.SoilProfileProbabilities[subSoilScenarioIndex].SegmentFailureMechanismType.Value.In( - ConversionHelper.ConvertToSegmentFailureMechanismType(damProjectData.DamProjectCalculationSpecification.CurrentSpecification.FailureMechanismSystemType), - SegmentFailureMechanismType.All)) + var message = new LogMessage(); + message.Message = string.Format(Resources.DesignCalculatorNoSoilProfilesAvailableForLocation, + location.Name); + message.MessageType = LogMessageType.Warning; + damProjectData.CalculationMessages.Add(message); + } + else + { + var projectPath = damProjectData.ProjectPath != "" ? damProjectData.ProjectPath + : Directory.GetCurrentDirectory(); + int subSoilScenarioIndex = 0; + for (; + subSoilScenarioIndex < location.Segment.SoilProfileProbabilities.Count; + subSoilScenarioIndex++) { - var soiProfileProbability = location.Segment.SoilProfileProbabilities[subSoilScenarioIndex]; - for (int designScenarioIndex = 0; designScenarioIndex < location.Scenarios.Count; designScenarioIndex++) + // Check if the subSoilScenario is applicable for the failuremechanism that is being calculated + if (location.Segment.SoilProfileProbabilities[subSoilScenarioIndex] + .SegmentFailureMechanismType.Value.In( + ConversionHelper.ConvertToSegmentFailureMechanismType(damProjectData + .DamProjectCalculationSpecification.CurrentSpecification + .FailureMechanismSystemType), + SegmentFailureMechanismType.All)) { - DesignScenario designScenario = location.Scenarios[designScenarioIndex]; - designScenario.Location = location; - var projectPath = damProjectData.ProjectPath != "" ? damProjectData.ProjectPath : Directory.GetCurrentDirectory(); - var designResults = new List(); - var calculationMessages = new List(); - designCalculatorTasks.Add(new DesignCalculatorTask() + var soiProfileProbability = + location.Segment.SoilProfileProbabilities[subSoilScenarioIndex]; + for (int designScenarioIndex = 0; + designScenarioIndex < location.Scenarios.Count; + designScenarioIndex++) { - Location = location, - SoiProfileProbability = soiProfileProbability, - DesignScenario = designScenario, - ProjectPath = projectPath, - CalculationMap = damProjectData.CalculationMap, - FailureMechanismeCalculationSpecification = damProjectData.DamProjectCalculationSpecification.CurrentSpecification.Copy(), - DesignResults = designResults, - CalculationMessages = calculationMessages - }); + DesignScenario designScenario = location.Scenarios[designScenarioIndex]; + designScenario.Location = location; + var designResults = new List(); + var calculationMessages = new List(); + designCalculatorTasks.Add(new DesignCalculatorTask() + { + Location = location, + SoiProfileProbability = soiProfileProbability, + DesignScenario = designScenario, + ProjectPath = projectPath, + CalculationMap = damProjectData.CalculationMap, + FailureMechanismeCalculationSpecification = damProjectData + .DamProjectCalculationSpecification.CurrentSpecification.Copy(), + DesignResults = designResults, + CalculationMessages = calculationMessages + }); + // taskStr = taskStr + location + " prob: " + soiProfileProbability.ToString() + + // " scen: " + designScenario.LocationScenarioID + " headPL3 = " + + // designScenario.HeadPl3 + Environment.NewLine; + } + + relevantCombinationsCount++; } - relevantCombinationsCount++; } } } } + //File.WriteAllText("DumpInput" + damProjectData.MaxCalculationCores.ToString() + ".txt", taskStr); if (relevantCombinationsCount > 0) { - // Perform the calculation + // var designDump = "Content DesignTasks for " + damProjectData.MaxCalculationCores.ToString() + Environment.NewLine; + // // Perform the calculation + // foreach (var calculatorTask in designCalculatorTasks) + // { + // designDump = designDump + calculatorTask.Location + " prob: " + calculatorTask.SoiProfileProbability.ToString() + + // " scen: " + calculatorTask.DesignScenario.LocationScenarioID + " headPL3 = " + + // calculatorTask.DesignScenario.HeadPl3 + Environment.NewLine; + // } + // File.WriteAllText("DumpTaskData" + damProjectData.MaxCalculationCores.ToString() + ".txt", designDump); Parallel.Run(designCalculatorTasks, RunDesignCalculatorTask, progressDelegate, damProjectData.MaxCalculationCores); - foreach (var desigCalculatorTask in designCalculatorTasks) + foreach (var designCalculatorTask in designCalculatorTasks) { - damProjectData.CalculationMessages.AddRange(desigCalculatorTask.CalculationMessages); - damProjectData.DesignCalculations.AddRange(desigCalculatorTask.DesignResults); + damProjectData.CalculationMessages.AddRange(designCalculatorTask.CalculationMessages); + damProjectData.DesignCalculations.AddRange(designCalculatorTask.DesignResults); } } else @@ -149,6 +179,13 @@ { try { + string content = "HeadPl3 at location before sync does not exist" + Environment.NewLine + + "HeadPl3 at current scenario before sync does not exist" + Environment.NewLine + + "HeadPl3 at scenario itself =" + designScenario.HeadPl3 + Environment.NewLine + + "ScenID at scenario itself =" + designScenario.LocationScenarioID + Environment.NewLine; + File.WriteAllText("DCStartDumpPl3_" + location.Name + "_" + + designScenario.LocationScenarioID + "_" + + soiProfileProbability.SoilProfile1DName + ".txt", content); // Prepare input var damKernelInput = new DamKernelInput(); damKernelInput.ProjectDir = projectPath; @@ -198,10 +235,30 @@ } } } - - PrepareResult prepareResult = - kernelWrapper.Prepare(damKernelInput, 0, out kernelDataInput, out kernelDataOutput); - + string content2 = "HeadPl3 direct dKI= " + damKernelInput.Location.HeadPl3 + Environment.NewLine + + "HeadPl3 scenar dKI= " + damKernelInput.Location.CurrentScenario.HeadPl3 + Environment.NewLine+ + "ID from locCUR dKI=" + damKernelInput.Location.CurrentScenario.LocationScenarioID + Environment.NewLine; + content2 = content2 + "HeadPl3 direct Input= " + location.HeadPl3 + Environment.NewLine + + "HeadPl3 scenar Input= " + location.CurrentScenario.HeadPl3 + Environment.NewLine + + "HeadPl3 from scen =" + designScenario.HeadPl3 + Environment.NewLine + + "ID from scen =" + designScenario.LocationScenarioID + Environment.NewLine + + "ID from locCUR =" + location.CurrentScenario.LocationScenarioID + Environment.NewLine; + File.WriteAllText("DCDumpPl3_Pre_" + location.Name + "_" + + designScenario.LocationScenarioID + "_" + + soiProfileProbability.SoilProfile1DName + ".txt", content2); + PrepareResult prepareResult; + lock (damKernelInput) + { + prepareResult = + kernelWrapper.Prepare(damKernelInput, 0, out kernelDataInput, out kernelDataOutput); + } + + content2 = content2 + "Uplift Pl3 adj = " + (kernelDataOutput as DamMacroStabilityOutput).UpliftSituation.Pl3HeadAdjusted + Environment.NewLine; + var ts = DateTime.Now; + File.WriteAllText("A_"+ ts.Minute + "_" + ts.Millisecond + "DCDumpPl3_Post_" + location.Name + + "_" + designScenario.LocationScenarioID + "_" + + soiProfileProbability.SoilProfile1DName + ".txt", content2); + // Sometimes the kernelDataInput is not created (e.g. when SoilProfileProbability is meant for // stability where Piping calc is wanted). In that case, do nothing but just skip. if (prepareResult == PrepareResult.Successful) @@ -321,7 +378,36 @@ private void SynchronizeScenarioDataWithLocationData(DesignScenario designScenario, Location location) { // Synchronize PlLine parameters - location.CurrentScenario = designScenario; + //location.CurrentScenario = designScenario; + location.CurrentScenario = new DesignScenario(); + //location.CurrentScenario.Location = designScenario.Location; + location.CurrentScenario.HeadPl3 = designScenario.HeadPl3; + location.CurrentScenario.HeadPl4 = designScenario.HeadPl4; + location.CurrentScenario.LocationScenarioID = designScenario.LocationScenarioID; + location.CurrentScenario.ModelFactors = designScenario.ModelFactors; + location.CurrentScenario.RiverLevel = designScenario.RiverLevel; + location.CurrentScenario.DikeTableHeight = designScenario.DikeTableHeight; + location.CurrentScenario.RiverLevelLow = designScenario.RiverLevelLow; + location.CurrentScenario.UpliftCriterionPiping = designScenario.UpliftCriterionPiping; + location.CurrentScenario.UpliftCriterionStability = designScenario.UpliftCriterionStability; + location.CurrentScenario.RequiredSafetyFactorPiping = designScenario.RequiredSafetyFactorPiping; + location.CurrentScenario.RequiredSafetyFactorStabilityInnerSlope = + designScenario.RequiredSafetyFactorStabilityInnerSlope; + location.CurrentScenario.RequiredSafetyFactorStabilityOuterSlope = + designScenario.RequiredSafetyFactorStabilityOuterSlope; + location.CurrentScenario.PlLineOffsetBelowDikeCrestMiddle = designScenario.PlLineOffsetBelowDikeCrestMiddle; + location.CurrentScenario.PlLineOffsetBelowShoulderBaseInside = + designScenario.PlLineOffsetBelowShoulderBaseInside; + location.CurrentScenario.PlLineOffsetFactorBelowShoulderCrest = + designScenario.PlLineOffsetFactorBelowShoulderCrest; + location.CurrentScenario.PlLineOffsetBelowDikeTopAtPolder = designScenario.PlLineOffsetBelowDikeToeAtPolder; + location.CurrentScenario.PlLineOffsetBelowDikeTopAtRiver = designScenario.PlLineOffsetBelowDikeTopAtRiver; + location.CurrentScenario.UsePlLineOffsetBelowDikeCrestMiddle = + designScenario.UsePlLineOffsetBelowDikeCrestMiddle; + location.CurrentScenario.UsePlLineOffsetFactorBelowShoulderCrest = + designScenario.UsePlLineOffsetFactorBelowShoulderCrest; + location.CurrentScenario.PlLineOffsetBelowDikeToeAtPolder = designScenario.PlLineOffsetBelowDikeToeAtPolder; + location.PlLineOffsetBelowDikeToeAtPolder = designScenario.PlLineOffsetBelowDikeToeAtPolder; location.PlLineOffsetBelowDikeTopAtPolder = designScenario.PlLineOffsetBelowDikeTopAtPolder; location.PlLineOffsetBelowDikeTopAtRiver = designScenario.PlLineOffsetBelowDikeTopAtRiver; Index: DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/PlLinesCreator/PlLinesCreator.cs =================================================================== diff -u -r3737 -r4289 --- DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/PlLinesCreator/PlLinesCreator.cs (.../PlLinesCreator.cs) (revision 3737) +++ DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/PlLinesCreator/PlLinesCreator.cs (.../PlLinesCreator.cs) (revision 4289) @@ -109,7 +109,7 @@ if (HeadInPlLine3 == null) { return waterLevel; - } + } // ### BKA getest, heeft (nu) geen invloed op probleem WF. return HeadInPlLine3.Value; } Index: DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/KernelWrappers/Common/UpliftHelper.cs =================================================================== diff -u -r3737 -r4289 --- DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/KernelWrappers/Common/UpliftHelper.cs (.../UpliftHelper.cs) (revision 3737) +++ DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/KernelWrappers/Common/UpliftHelper.cs (.../UpliftHelper.cs) (revision 4289) @@ -19,6 +19,9 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using System.IO; +using System.Security.Cryptography.X509Certificates; using Deltares.DamEngine.Calculators.Uplift; using Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.General.PlLines; @@ -65,8 +68,27 @@ SensorPlLineCreatorSettings sensorPlLineCreatorSettings = new SensorPlLineCreatorSettings(); sensorPlLineCreatorSettings.SensorLocation = damKernelInput.Location.SensorLocation; sensorPlLineCreatorSettings.DateTime = damKernelInput.TimeStepDateTime; + string content = "HeadPl3 direct = " + damKernelInput.Location.HeadPl3 + Environment.NewLine + + "HeadPl3 scenar = " + damKernelInput.Location.CurrentScenario.HeadPl3 + Environment.NewLine + + "ID curscen=" + damKernelInput.Location.CurrentScenario.LocationScenarioID + Environment.NewLine; + var ts = DateTime.Now; + // File.WriteAllText("A_"+ ts.Minute + "_" + ts.Millisecond+ "DumpPl3_Pre_" + damKernelInput.Location.Name + "_" + + // damKernelInput.Location.CurrentScenario.LocationScenarioID + "_" + + // damKernelInput.SubSoilScenario.SoilProfile1DName + ".txt", content); + //### BKA hier vooraf headpl3 van scenario (Currentscenario in location) dumpen en na de call de Y-waarde van pl3 var plLines = PlLinesHelper.CreatePlLinesForStability(damKernelInput.Location, damKernelInput.SubSoilScenario, riverLevel, riverLevelLow, sensorPlLineCreatorSettings, out upliftSituation); + content = content + "Z point1 Pl3 = " + plLines.Lines[PlLineType.Pl3].Points[0].Z + Environment.NewLine; + int nrPoints = plLines.Lines[PlLineType.Pl3].Points.Count; + if (nrPoints > 1) + { + content = content + "Z endpoint Pl3 = " + plLines.Lines[PlLineType.Pl3].Points[nrPoints - 1].Z; + } + + ts = DateTime.Now; + File.WriteAllText("A_"+ ts.Minute + "_" + ts.Millisecond+ "DumpPl3_Post_" + damKernelInput.Location.Name + "_" + + damKernelInput.Location.CurrentScenario.LocationScenarioID + "_" + + damKernelInput.SubSoilScenario.SoilProfile1DName + ".txt", content); return plLines; } Index: DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/KernelWrappers/DamMacroStabilityInwards/DamMacroStabilityInwardsKernelWrapper.cs =================================================================== diff -u -r3737 -r4289 --- DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/KernelWrappers/DamMacroStabilityInwards/DamMacroStabilityInwardsKernelWrapper.cs (.../DamMacroStabilityInwardsKernelWrapper.cs) (revision 3737) +++ DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/KernelWrappers/DamMacroStabilityInwards/DamMacroStabilityInwardsKernelWrapper.cs (.../DamMacroStabilityInwardsKernelWrapper.cs) (revision 4289) @@ -64,6 +64,13 @@ /// public PrepareResult Prepare(DamKernelInput damKernelInput, int iterationIndex, out IKernelDataInput kernelDataInput, out IKernelDataOutput kernelDataOutput) { + string content = "HeadPl3 direct = " + damKernelInput.Location.HeadPl3 + Environment.NewLine + + "HeadPl3 scenar = " + damKernelInput.Location.CurrentScenario.HeadPl3 + Environment.NewLine + + "ID curscen=" + damKernelInput.Location.CurrentScenario.LocationScenarioID + Environment.NewLine; + var ts = DateTime.Now; + File.WriteAllText("A_"+ ts.Minute + "_" + ts.Millisecond+ "DumpPrepare_PL3_" + damKernelInput.Location.Name + "_" + + damKernelInput.Location.CurrentScenario.LocationScenarioID + "_" + + damKernelInput.SubSoilScenario.SoilProfile1DName + ".txt", content); var damMacroStabilityOutput = new DamMacroStabilityOutput() { StabilityOutputItems = new List(),