Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/DikesDesign/DesignCalculator.cs =================================================================== diff -u -r4331 -r4396 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/DikesDesign/DesignCalculator.cs (.../DesignCalculator.cs) (revision 4331) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/DikesDesign/DesignCalculator.cs (.../DesignCalculator.cs) (revision 4396) @@ -271,7 +271,7 @@ SurfaceLine2 orgLocationSurfaceLine = null; try { - orgLocationSurfaceLine = AdaptSurfaceLineWhenNeededForDesign(location, designScenario, analysisType, damKernelInput); + orgLocationSurfaceLine = AdaptSurfaceLineWhenNeededForDesign(location, analysisType, damKernelInput); PrepareResult prepareResult = kernelWrapper.Prepare(damKernelInput, 0, out kernelDataInput, out kernelDataOutput); @@ -341,29 +341,30 @@ } } - private SurfaceLine2 AdaptSurfaceLineWhenNeededForDesign(Location location, DesignScenario designScenario, - AnalysisType analysisType, DamKernelInput damKernelInput) + private SurfaceLine2 AdaptSurfaceLineWhenNeededForDesign(Location location, AnalysisType analysisType, + DamKernelInput damKernelInput) { SurfaceLine2 orgLocationSurfaceLine = null; - // Make sure that in case of AdaptGeometry (and RedesignDikeHeight), the surface line is adapted for the given DTH BEFORE the call to Prepare as - // otherwise the Prepare will be done on the original surface line which is wrong. + // Make sure that in case of AdaptGeometry (and RedesignDikeHeight), the surface line is adapted for the given DTH BEFORE + // the call to Prepare as otherwise the Prepare will be done on the original surface line which is wrong. if (analysisType == AnalysisType.AdaptGeometry && damKernelInput.Location.RedesignDikeHeight) { double? dikeHeight = location.SurfaceLine.GetDikeHeight(); if (dikeHeight.HasValue) { - if (designScenario.DikeTableHeight > dikeHeight.Value) + if (location.CurrentScenario.DikeTableHeight > dikeHeight.Value) { orgLocationSurfaceLine = location.SurfaceLine.FullDeepClone(); // Redesign the surface line to the desired Dike Table Height var surfaceLineHeightAdapter = - new SurfaceLineHeightAdapter(location.SurfaceLine, location, designScenario.PolderLevel); + new SurfaceLineHeightAdapter(location.SurfaceLine, location, location.CurrentScenario.PolderLevel); SurfaceLine2 adaptedSurfaceLine = surfaceLineHeightAdapter.ConstructNewSurfaceLine( - designScenario.DikeTableHeight ?? + location.CurrentScenario.DikeTableHeight ?? location.SurfaceLine.GetDefaultDikeTableHeight() ?? 0); - designScenario.SetRedesignedSurfaceLine(damKernelInput.SubSoilScenario.SoilProfile1D, - damKernelInput.SubSoilScenario.SoilProfile2D, adaptedSurfaceLine); + location.CurrentScenario.SetRedesignedSurfaceLine(damKernelInput.SubSoilScenario.SoilProfile1D, + damKernelInput.SubSoilScenario.SoilProfile2D, + adaptedSurfaceLine); damKernelInput.Location.SurfaceLine = adaptedSurfaceLine; } } @@ -382,33 +383,7 @@ { // Synchronize scenario data (Note: do not attempt to synchronize the ModelFactors as these are set by the direct // properties in the scenario such as the Required Safeties. ModelFactors is just a place holder. - location.CurrentScenario = new DesignScenario(); - location.CurrentScenario.LocationScenarioID = designScenario.LocationScenarioID; - location.CurrentScenario.PolderLevel = designScenario.PolderLevel; - location.CurrentScenario.RiverLevel = designScenario.RiverLevel; - location.CurrentScenario.RiverLevelLow = designScenario.RiverLevelLow; - location.CurrentScenario.DikeTableHeight = designScenario.DikeTableHeight; - location.CurrentScenario.RequiredSafetyFactorStabilityInnerSlope = - designScenario.RequiredSafetyFactorStabilityInnerSlope; - location.CurrentScenario.RequiredSafetyFactorStabilityOuterSlope = - designScenario.RequiredSafetyFactorStabilityOuterSlope; - location.CurrentScenario.RequiredSafetyFactorPiping = designScenario.RequiredSafetyFactorPiping; - location.CurrentScenario.UpliftCriterionPiping = designScenario.UpliftCriterionPiping; - location.CurrentScenario.UpliftCriterionStability = designScenario.UpliftCriterionStability; - location.CurrentScenario.PlLineOffsetBelowDikeTopAtPolder = designScenario.PlLineOffsetBelowDikeTopAtPolder; - location.CurrentScenario.PlLineOffsetBelowDikeTopAtRiver = designScenario.PlLineOffsetBelowDikeTopAtRiver; - location.CurrentScenario.PlLineOffsetBelowShoulderBaseInside = - designScenario.PlLineOffsetBelowShoulderBaseInside; - location.CurrentScenario.PlLineOffsetBelowDikeToeAtPolder = designScenario.PlLineOffsetBelowDikeToeAtPolder; - location.CurrentScenario.UsePlLineOffsetBelowDikeCrestMiddle = - designScenario.UsePlLineOffsetBelowDikeCrestMiddle; - location.CurrentScenario.PlLineOffsetBelowDikeCrestMiddle = designScenario.PlLineOffsetBelowDikeCrestMiddle; - location.CurrentScenario.UsePlLineOffsetFactorBelowShoulderCrest = designScenario.UsePlLineOffsetFactorBelowShoulderCrest; - location.CurrentScenario.PlLineOffsetFactorBelowShoulderCrest = designScenario.PlLineOffsetFactorBelowShoulderCrest; - location.CurrentScenario.HeadPl2 = designScenario.HeadPl2; - location.CurrentScenario.HeadPl3 = designScenario.HeadPl3; - location.CurrentScenario.HeadPl4 = designScenario.HeadPl4; - + location.CurrentScenario = location.SynchronizeCurrentScenarioWithScenarioData(designScenario); location.PlLineOffsetBelowDikeToeAtPolder = designScenario.PlLineOffsetBelowDikeToeAtPolder; location.PlLineOffsetBelowDikeTopAtPolder = designScenario.PlLineOffsetBelowDikeTopAtPolder; location.PlLineOffsetBelowDikeTopAtRiver = designScenario.PlLineOffsetBelowDikeTopAtRiver; Index: DamEngine/trunk/src/Deltares.DamEngine.Data/General/Location.cs =================================================================== diff -u -r4221 -r4396 --- DamEngine/trunk/src/Deltares.DamEngine.Data/General/Location.cs (.../Location.cs) (revision 4221) +++ DamEngine/trunk/src/Deltares.DamEngine.Data/General/Location.cs (.../Location.cs) (revision 4396) @@ -445,6 +445,39 @@ /// The current scenario. /// public DesignScenario CurrentScenario { get; set; } + + public DesignScenario SynchronizeCurrentScenarioWithScenarioData(DesignScenario designScenario) + { + // Synchronize scenario data (Note: do not attempt to synchronize the ModelFactors as these are set by the direct + // properties in the scenario such as the Required Safeties. ModelFactors is just a place holder. + var newCurrentScenario = new DesignScenario(); + newCurrentScenario.LocationScenarioID = designScenario.LocationScenarioID; + newCurrentScenario.PolderLevel = designScenario.PolderLevel; + newCurrentScenario.RiverLevel = designScenario.RiverLevel; + newCurrentScenario.RiverLevelLow = designScenario.RiverLevelLow; + newCurrentScenario.DikeTableHeight = designScenario.DikeTableHeight; + newCurrentScenario.RequiredSafetyFactorStabilityInnerSlope = + designScenario.RequiredSafetyFactorStabilityInnerSlope; + newCurrentScenario.RequiredSafetyFactorStabilityOuterSlope = + designScenario.RequiredSafetyFactorStabilityOuterSlope; + newCurrentScenario.RequiredSafetyFactorPiping = designScenario.RequiredSafetyFactorPiping; + newCurrentScenario.UpliftCriterionPiping = designScenario.UpliftCriterionPiping; + newCurrentScenario.UpliftCriterionStability = designScenario.UpliftCriterionStability; + newCurrentScenario.PlLineOffsetBelowDikeTopAtPolder = designScenario.PlLineOffsetBelowDikeTopAtPolder; + newCurrentScenario.PlLineOffsetBelowDikeTopAtRiver = designScenario.PlLineOffsetBelowDikeTopAtRiver; + newCurrentScenario.PlLineOffsetBelowShoulderBaseInside = + designScenario.PlLineOffsetBelowShoulderBaseInside; + newCurrentScenario.PlLineOffsetBelowDikeToeAtPolder = designScenario.PlLineOffsetBelowDikeToeAtPolder; + newCurrentScenario.UsePlLineOffsetBelowDikeCrestMiddle = + designScenario.UsePlLineOffsetBelowDikeCrestMiddle; + newCurrentScenario.PlLineOffsetBelowDikeCrestMiddle = designScenario.PlLineOffsetBelowDikeCrestMiddle; + newCurrentScenario.UsePlLineOffsetFactorBelowShoulderCrest = designScenario.UsePlLineOffsetFactorBelowShoulderCrest; + newCurrentScenario.PlLineOffsetFactorBelowShoulderCrest = designScenario.PlLineOffsetFactorBelowShoulderCrest; + newCurrentScenario.HeadPl2 = designScenario.HeadPl2; + newCurrentScenario.HeadPl3 = designScenario.HeadPl3; + newCurrentScenario.HeadPl4 = designScenario.HeadPl4; + return newCurrentScenario; + } /// /// Gets or sets the type of the dam project.