Index: DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/General/Parallel.cs =================================================================== diff -u -r3737 -r4290 --- DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/General/Parallel.cs (.../Parallel.cs) (revision 3737) +++ DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/General/Parallel.cs (.../Parallel.cs) (revision 4290) @@ -108,14 +108,20 @@ { var thread = new Thread(RunTask); threads.Add(thread); - - thread.Start(Context.CurrentContext); // Pass the current context as task context + + // Pass the current context as task context + thread.Start(Context.CurrentContext); if (i == 0) { - // Delay after the first trhead is started to give DGSMStabDam.dll time to initiliaze - // If this is not included DGSMStabDam.dll crashes, because it is trying to initilialize muliple times + // Delay is started to give DGSMStabDam.dll time to initialize at first. + // If this is not included DGSMStabDam.dll crashes System.Threading.Thread.Sleep(1000); } + else + { + // Delay is started to give DGSMStabDam.dll time to run without file clashes. + System.Threading.Thread.Sleep(10); + } } foreach (var thread in threads) Index: DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/KernelWrappers/DamMacroStabilityInwards/DamMacroStabilityInwardsKernelWrapper.cs =================================================================== diff -u -r4289 -r4290 --- DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/KernelWrappers/DamMacroStabilityInwards/DamMacroStabilityInwardsKernelWrapper.cs (.../DamMacroStabilityInwardsKernelWrapper.cs) (revision 4289) +++ DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/KernelWrappers/DamMacroStabilityInwards/DamMacroStabilityInwardsKernelWrapper.cs (.../DamMacroStabilityInwardsKernelWrapper.cs) (revision 4290) @@ -21,6 +21,7 @@ using System; using System.Collections.Generic; +using System.Data; using System.IO; using System.Xml.Linq; using Deltares.DamEngine.Calculators.DikesDesign; @@ -64,13 +65,6 @@ /// 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(), Index: DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/DikesDesign/DesignCalculator.cs =================================================================== diff -u -r4289 -r4290 --- DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/DikesDesign/DesignCalculator.cs (.../DesignCalculator.cs) (revision 4289) +++ DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/DikesDesign/DesignCalculator.cs (.../DesignCalculator.cs) (revision 4290) @@ -23,9 +23,7 @@ using System.Collections.Generic; using System.Diagnostics; 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; @@ -35,6 +33,7 @@ using Deltares.DamEngine.Data.Standard; using Deltares.DamEngine.Data.Standard.Calculation; using Deltares.DamEngine.Data.Standard.Logging; +using Parallel = Deltares.DamEngine.Calculators.General.Parallel; namespace Deltares.DamEngine.Calculators.DikesDesign { @@ -57,7 +56,7 @@ // Prepare the designCalculatorTasks var designCalculatorTasks = new List(); var relevantCombinationsCount = 0; - //string taskStr = "Content InputTasks for " + damProjectData.MaxCalculationCores.ToString() + Environment.NewLine; + lock (damProjectData) { damProjectData.DesignCalculations = new List(); @@ -120,9 +119,6 @@ DesignResults = designResults, CalculationMessages = calculationMessages }); - // taskStr = taskStr + location + " prob: " + soiProfileProbability.ToString() + - // " scen: " + designScenario.LocationScenarioID + " headPL3 = " + - // designScenario.HeadPl3 + Environment.NewLine; } relevantCombinationsCount++; @@ -132,18 +128,8 @@ } } - //File.WriteAllText("DumpInput" + damProjectData.MaxCalculationCores.ToString() + ".txt", taskStr); if (relevantCombinationsCount > 0) { - // 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 designCalculatorTask in designCalculatorTasks) { @@ -179,14 +165,6 @@ { 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; damKernelInput.CalculationDir = Path.Combine(projectPath, calculationMap); @@ -235,32 +213,13 @@ } } } - 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) { switch (analysisType) @@ -378,35 +337,7 @@ private void SynchronizeScenarioDataWithLocationData(DesignScenario designScenario, Location location) { // Synchronize PlLine parameters - //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.CurrentScenario = designScenario; location.PlLineOffsetBelowDikeToeAtPolder = designScenario.PlLineOffsetBelowDikeToeAtPolder; location.PlLineOffsetBelowDikeTopAtPolder = designScenario.PlLineOffsetBelowDikeTopAtPolder; Index: DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/KernelWrappers/Common/UpliftHelper.cs =================================================================== diff -u -r4289 -r4290 --- DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/KernelWrappers/Common/UpliftHelper.cs (.../UpliftHelper.cs) (revision 4289) +++ DamEngine/branches/DamEngine 19.3/src/Deltares.DamEngine.Calculators/KernelWrappers/Common/UpliftHelper.cs (.../UpliftHelper.cs) (revision 4290) @@ -19,9 +19,6 @@ // 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; @@ -68,27 +65,8 @@ 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; }