Index: Demo/Ringtoets/src/Demo.Ringtoets/Commands/AddNewDemoDikeAssessmentSectionCommand.cs =================================================================== diff -u -r6a1df79cc36617a42d0016f9b7a9271020a2196e -rc0a3ced404197fd781c6fcbcfc21c6676592be57 --- Demo/Ringtoets/src/Demo.Ringtoets/Commands/AddNewDemoDikeAssessmentSectionCommand.cs (.../AddNewDemoDikeAssessmentSectionCommand.cs) (revision 6a1df79cc36617a42d0016f9b7a9271020a2196e) +++ Demo/Ringtoets/src/Demo.Ringtoets/Commands/AddNewDemoDikeAssessmentSectionCommand.cs (.../AddNewDemoDikeAssessmentSectionCommand.cs) (revision c0a3ced404197fd781c6fcbcfc21c6676592be57) @@ -1,4 +1,5 @@ -using System.IO; +using System.Collections.Generic; +using System.IO; using System.Linq; using Core.Common.Base.Data; using Core.Common.Controls.Commands; @@ -9,7 +10,6 @@ using Ringtoets.Integration.Forms.PresentationObjects; using Ringtoets.Integration.Plugin.FileImporters; using Ringtoets.Piping.Data; -using Ringtoets.Piping.Forms.Extensions; using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.Plugin.FileImporter; @@ -115,13 +115,34 @@ } var calculation = pipingFailureMechanism.CalculationsGroup.GetPipingCalculations().First(); - calculation.InputParameters.SetSurfaceLine(pipingFailureMechanism.SurfaceLines.First(sl => sl.Name == "PK001_0001")); - calculation.InputParameters.SetSoilProfile(pipingFailureMechanism.SoilProfiles.First(sl => sl.Name == "W1-6_0_1D1")); + calculation.InputParameters.SurfaceLine = pipingFailureMechanism.SurfaceLines.First(sl => sl.Name == "PK001_0001"); + calculation.InputParameters.SoilProfile = pipingFailureMechanism.SoilProfiles.First(sp => sp.Name == "W1-6_0_1D1"); + calculation.InputParameters.HydraulicBoundaryLocation = demoAssessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001); + + SetHydraulicBoundaryLocationValues(demoAssessmentSection.HydraulicBoundaryDatabase.Locations); calculation.InputParameters.PhreaticLevelExit.Mean = (RoundedDouble) 3; - calculation.InputParameters.HydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, string.Empty, 0.0, 0.0) - { - DesignWaterLevel = 0.0 - }; + calculation.InputParameters.NotifyObservers(); } + + private void SetHydraulicBoundaryLocationValues(ICollection locations) + { + locations.ElementAt(0).DesignWaterLevel = 5.78; + locations.ElementAt(1).DesignWaterLevel = 5.77; + locations.ElementAt(2).DesignWaterLevel = 5.77; + locations.ElementAt(3).DesignWaterLevel = 5.77; + locations.ElementAt(4).DesignWaterLevel = 5.77; + locations.ElementAt(5).DesignWaterLevel = 5.93; + locations.ElementAt(6).DesignWaterLevel = 5.93; + locations.ElementAt(7).DesignWaterLevel = 5.93; + locations.ElementAt(8).DesignWaterLevel = 5.93; + locations.ElementAt(9).DesignWaterLevel = 5.93; + locations.ElementAt(10).DesignWaterLevel = 5.93; + locations.ElementAt(11).DesignWaterLevel = 5.93; + locations.ElementAt(12).DesignWaterLevel = 5.93; + locations.ElementAt(13).DesignWaterLevel = 5.93; + locations.ElementAt(14).DesignWaterLevel = 5.93; + locations.ElementAt(15).DesignWaterLevel = 5.54; + locations.ElementAt(16).DesignWaterLevel = 5.86; + } } } \ No newline at end of file Index: Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/AddNewDemoDikeAssessmentSectionCommandTest.cs =================================================================== diff -u -rcc5634a5fa164bbb2f7ef4546c9a2e60f19e4b1a -rc0a3ced404197fd781c6fcbcfc21c6676592be57 --- Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/AddNewDemoDikeAssessmentSectionCommandTest.cs (.../AddNewDemoDikeAssessmentSectionCommandTest.cs) (revision cc5634a5fa164bbb2f7ef4546c9a2e60f19e4b1a) +++ Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/AddNewDemoDikeAssessmentSectionCommandTest.cs (.../AddNewDemoDikeAssessmentSectionCommandTest.cs) (revision c0a3ced404197fd781c6fcbcfc21c6676592be57) @@ -9,6 +9,7 @@ using Demo.Ringtoets.Commands; using NUnit.Framework; using Rhino.Mocks; +using Ringtoets.HydraRing.Data; using Ringtoets.Integration.Data; using Ringtoets.Piping.Calculation; using Ringtoets.Piping.Data; @@ -70,6 +71,7 @@ Assert.IsTrue(File.Exists(Path.Combine(Path.GetDirectoryName(demoAssessmentSection.HydraulicBoundaryDatabase.FilePath), "HLCD.sqlite"))); var hydraulicBoundaryLocations = demoAssessmentSection.HydraulicBoundaryDatabase.Locations.ToArray(); Assert.AreEqual(18, hydraulicBoundaryLocations.Length); + AssertValuesOnHydraulicBoundaryLocations(hydraulicBoundaryLocations); Assert.AreEqual(1669, demoAssessmentSection.ReferenceLine.Points.Count()); @@ -90,6 +92,28 @@ mocks.VerifyAll(); } + private void AssertValuesOnHydraulicBoundaryLocations(HydraulicBoundaryLocation[] hydraulicBoundaryLocations) + { + Assert.AreEqual(5.78, hydraulicBoundaryLocations[0].DesignWaterLevel); + Assert.AreEqual(5.77, hydraulicBoundaryLocations[1].DesignWaterLevel); + Assert.AreEqual(5.77, hydraulicBoundaryLocations[2].DesignWaterLevel); + Assert.AreEqual(5.77, hydraulicBoundaryLocations[3].DesignWaterLevel); + Assert.AreEqual(5.77, hydraulicBoundaryLocations[4].DesignWaterLevel); + Assert.AreEqual(5.93, hydraulicBoundaryLocations[5].DesignWaterLevel); + Assert.AreEqual(5.93, hydraulicBoundaryLocations[6].DesignWaterLevel); + Assert.AreEqual(5.93, hydraulicBoundaryLocations[7].DesignWaterLevel); + Assert.AreEqual(5.93, hydraulicBoundaryLocations[8].DesignWaterLevel); + Assert.AreEqual(5.93, hydraulicBoundaryLocations[9].DesignWaterLevel); + Assert.AreEqual(5.93, hydraulicBoundaryLocations[10].DesignWaterLevel); + Assert.AreEqual(5.93, hydraulicBoundaryLocations[11].DesignWaterLevel); + Assert.AreEqual(5.93, hydraulicBoundaryLocations[12].DesignWaterLevel); + Assert.AreEqual(5.93, hydraulicBoundaryLocations[13].DesignWaterLevel); + Assert.AreEqual(5.93, hydraulicBoundaryLocations[14].DesignWaterLevel); + Assert.AreEqual(5.54, hydraulicBoundaryLocations[15].DesignWaterLevel); + Assert.AreEqual(5.86, hydraulicBoundaryLocations[16].DesignWaterLevel); + Assert.IsNaN(hydraulicBoundaryLocations[17].DesignWaterLevel); + } + private void AssertCharacteristicPointsOnSurfaceLines(RingtoetsPipingSurfaceLine[] surfaceLines) { var surfaceLine1 = surfaceLines.FirstOrDefault(s => s.Name == "PK001_0001"); @@ -137,14 +161,17 @@ AssertExpectedPipingInput(inputParameters); Assert.IsTrue(PipingCalculationService.Validate(calculation)); + + PipingInputSynchronizer.Synchronize(inputParameters); + PipingCalculationService.Calculate(calculation); Assert.IsTrue(calculation.HasOutput); - Assert.AreEqual(99.0, calculation.Output.HeaveFactorOfSafety, 1e-3); - Assert.AreEqual(1.154, calculation.Output.HeaveZValue, 1e-3); - Assert.AreEqual(99.0, calculation.Output.UpliftFactorOfSafety, 1e-3); - Assert.AreEqual(9.296, calculation.Output.UpliftZValue, 1e-3); - Assert.AreEqual(-0.346, calculation.Output.SellmeijerFactorOfSafety, 1e-3); - Assert.AreEqual(4.171, calculation.Output.SellmeijerZValue, 1e-3); + Assert.AreEqual(0.108, calculation.Output.HeaveFactorOfSafety, 1e-3); + Assert.AreEqual(-2.489, calculation.Output.HeaveZValue, 1e-3); + Assert.AreEqual(0.267, calculation.Output.UpliftFactorOfSafety, 1e-3); + Assert.AreEqual(-11.870, calculation.Output.UpliftZValue, 1e-3); + Assert.AreEqual(0.400, calculation.Output.SellmeijerFactorOfSafety, 1e-3); + Assert.AreEqual(-1.609, calculation.Output.SellmeijerZValue, 1e-3); } private static void AssertExpectedPipingInput(PipingInput inputParameters) @@ -153,7 +180,6 @@ Assert.AreEqual(1.0, inputParameters.SellmeijerModelFactor, 1e-3); Assert.AreEqual(10.0, inputParameters.WaterVolumetricWeight, 1e-3); - Assert.AreEqual(0.0, inputParameters.AssessmentLevel, 1e-3); Assert.AreEqual(0.3, inputParameters.SellmeijerReductionFactor, 1e-3); Assert.AreEqual(16.5, inputParameters.SandParticlesVolumicWeight, 1e-3); Assert.AreEqual(0.25, inputParameters.WhitesDragCoefficient, 1e-3); @@ -164,21 +190,17 @@ Assert.AreEqual("PK001_0001", inputParameters.SurfaceLine.Name); Assert.AreEqual("W1-6_0_1D1", inputParameters.SoilProfile.Name); + Assert.AreEqual(1300001, inputParameters.HydraulicBoundaryLocation.Id); + Assert.AreEqual(5.78, inputParameters.HydraulicBoundaryLocation.DesignWaterLevel, 1e-3); Assert.AreEqual(3.661, PipingSemiProbabilisticDesignValueFactory.GetDampingFactorExit(inputParameters).GetDesignValue(), GetAccuracy(inputParameters.DampingFactorExit)); Assert.AreEqual(1.355, PipingSemiProbabilisticDesignValueFactory.GetPhreaticLevelExit(inputParameters).GetDesignValue(), GetAccuracy(inputParameters.PhreaticLevelExit)); - Assert.AreEqual(5.810, PipingSemiProbabilisticDesignValueFactory.GetThicknessCoverageLayer(inputParameters).GetDesignValue(), - GetAccuracy(inputParameters.ThicknessCoverageLayer)); - Assert.AreEqual(81.450, PipingSemiProbabilisticDesignValueFactory.GetSeepageLength(inputParameters).GetDesignValue(), - GetAccuracy(inputParameters.SeepageLength)); Assert.AreEqual(0.011, PipingSemiProbabilisticDesignValueFactory.GetDiameter70(inputParameters).GetDesignValue(), GetAccuracy(inputParameters.Diameter70)); Assert.AreEqual(2.347, PipingSemiProbabilisticDesignValueFactory.GetDarcyPermeability(inputParameters).GetDesignValue(), GetAccuracy(inputParameters.DarcyPermeability)); - Assert.AreEqual(20.290, PipingSemiProbabilisticDesignValueFactory.GetThicknessAquiferLayer(inputParameters).GetDesignValue(), - GetAccuracy(inputParameters.ThicknessAquiferLayer)); } private static double GetAccuracy(IDistribution distribution) Index: Ringtoets/Piping/src/Ringtoets.Piping.Calculation/PipingCalculator.cs =================================================================== diff -u -r3c10891728420f1c0aa0071574bbfb149710c556 -rc0a3ced404197fd781c6fcbcfc21c6676592be57 --- Ringtoets/Piping/src/Ringtoets.Piping.Calculation/PipingCalculator.cs (.../PipingCalculator.cs) (revision 3c10891728420f1c0aa0071574bbfb149710c556) +++ Ringtoets/Piping/src/Ringtoets.Piping.Calculation/PipingCalculator.cs (.../PipingCalculator.cs) (revision c0a3ced404197fd781c6fcbcfc21c6676592be57) @@ -274,7 +274,7 @@ { var calculator = factory.CreateHeaveCalculator(); calculator.Ich = input.CriticalHeaveGradient; - calculator.PhiExit = CalculatePiezometricHeadAtExit(); + calculator.PhiExit = input.PiezometricHeadExit; calculator.DTotal = input.ThicknessCoverageLayer; calculator.PhiPolder = input.PhreaticLevelExit; calculator.RExit = input.DampingFactorExit; @@ -291,7 +291,7 @@ calculator.ModelFactorUplift = input.UpliftModelFactor; calculator.EffectiveStress = effectiveStress; calculator.HRiver = input.AssessmentLevel; - calculator.PhiExit = CalculatePiezometricHeadAtExit(); + calculator.PhiExit = input.PiezometricHeadExit; calculator.RExit = input.DampingFactorExit; calculator.HExit = input.PhreaticLevelExit; calculator.PhiPolder = input.PhreaticLevelExit; Index: Ringtoets/Piping/src/Ringtoets.Piping.Calculation/PipingCalculatorInput.cs =================================================================== diff -u -r3c10891728420f1c0aa0071574bbfb149710c556 -rc0a3ced404197fd781c6fcbcfc21c6676592be57 --- Ringtoets/Piping/src/Ringtoets.Piping.Calculation/PipingCalculatorInput.cs (.../PipingCalculatorInput.cs) (revision 3c10891728420f1c0aa0071574bbfb149710c556) +++ Ringtoets/Piping/src/Ringtoets.Piping.Calculation/PipingCalculatorInput.cs (.../PipingCalculatorInput.cs) (revision c0a3ced404197fd781c6fcbcfc21c6676592be57) @@ -31,6 +31,7 @@ private readonly double waterVolumetricWeight; private readonly double upliftModelFactor; private readonly double assessmentLevel; + private readonly double piezometricHeadExit; private readonly double dampingFactorExit; private readonly double phreaticLevelExit; private readonly double criticalHeaveGradient; @@ -60,8 +61,10 @@ /// /// The calculation value used to account for uncertainty in the model for uplift. /// The outside high water level. [m] + /// The piezometric head at the exit point. [m] /// The damping factor at the exit point. /// The phreatic level at the exit point. [m] + /// The piezometric head in the hinterland. [m] /// The critical exit gradient for heave. /// The total thickness of the coverage layer at the exit point. [m] /// The calculation value used to account for uncertainty in the model for Sellmeijer. @@ -79,12 +82,13 @@ /// The x coordinate of the exit point. [m] /// The surface line. /// The profile which contains a 1 dimensional definition of soil layers with properties. - public PipingCalculatorInput(double waterVolumetricWeight, double saturatedVolumicWeightOfCoverageLayer, double upliftModelFactor, double assessmentLevel, double dampingFactorExit, double phreaticLevelExit, double criticalHeaveGradient, double thicknessCoverageLayer, double sellmeijerModelFactor, double sellmeijerReductionFactor, double seepageLength, double sandParticlesVolumicWeight, double whitesDragCoefficient, double diameter70, double darcyPermeability, double waterKinematicViscosity, double gravity, double thicknessAquiferLayer, double meanDiameter70, double beddingAngle, double exitPointXCoordinate, RingtoetsPipingSurfaceLine surfaceLine, PipingSoilProfile soilProfile) + public PipingCalculatorInput(double waterVolumetricWeight, double saturatedVolumicWeightOfCoverageLayer, double upliftModelFactor, double assessmentLevel, double piezometricHeadExit, double dampingFactorExit, double phreaticLevelExit, double criticalHeaveGradient, double thicknessCoverageLayer, double sellmeijerModelFactor, double sellmeijerReductionFactor, double seepageLength, double sandParticlesVolumicWeight, double whitesDragCoefficient, double diameter70, double darcyPermeability, double waterKinematicViscosity, double gravity, double thicknessAquiferLayer, double meanDiameter70, double beddingAngle, double exitPointXCoordinate, RingtoetsPipingSurfaceLine surfaceLine, PipingSoilProfile soilProfile) { this.waterVolumetricWeight = waterVolumetricWeight; this.saturatedVolumicWeightOfCoverageLayer = saturatedVolumicWeightOfCoverageLayer; this.upliftModelFactor = upliftModelFactor; this.assessmentLevel = assessmentLevel; + this.piezometricHeadExit = piezometricHeadExit; this.dampingFactorExit = dampingFactorExit; this.phreaticLevelExit = phreaticLevelExit; this.criticalHeaveGradient = criticalHeaveGradient; @@ -144,6 +148,18 @@ } /// + /// Gets the piezometric head at the exit point. + /// [m] + /// + public double PiezometricHeadExit + { + get + { + return piezometricHeadExit; + } + } + + /// /// Gets the damping factor at the exit point. /// public double DampingFactorExit @@ -367,7 +383,8 @@ /// /// Gets the volumic weight of the coverage layer when saturated. /// - public double SaturatedVolumicWeightOfCoverageLayer { + public double SaturatedVolumicWeightOfCoverageLayer + { get { return saturatedVolumicWeightOfCoverageLayer; Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingInput.cs =================================================================== diff -u -r3c10891728420f1c0aa0071574bbfb149710c556 -rc0a3ced404197fd781c6fcbcfc21c6676592be57 --- Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingInput.cs (.../PipingInput.cs) (revision 3c10891728420f1c0aa0071574bbfb149710c556) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingInput.cs (.../PipingInput.cs) (revision c0a3ced404197fd781c6fcbcfc21c6676592be57) @@ -20,10 +20,10 @@ // All rights reserved. using System; - +using System.Linq; using Core.Common.Base; using Core.Common.Base.Data; - +using Core.Common.Base.Geometry; using Ringtoets.HydraRing.Data; using Ringtoets.Piping.Data.Probabilistics; using Ringtoets.Piping.Data.Properties; @@ -36,12 +36,12 @@ /// public class PipingInput : Observable { - private const double seepageLengthStandardDeviationFraction = 0.1; private readonly GeneralPipingInput generalInputParameters; private RoundedDouble assessmentLevel; private RoundedDouble exitPointL; private RoundedDouble entryPointL; - private HydraulicBoundaryLocation hydraulicBoundaryLocation; + private RoundedDouble piezometricHeadExit; + private RingtoetsPipingSurfaceLine surfaceLine; /// /// Initializes a new instance of the class. @@ -62,6 +62,7 @@ exitPointL = new RoundedDouble(2, double.NaN); entryPointL = new RoundedDouble(2, double.NaN); assessmentLevel = new RoundedDouble(2, double.NaN); + piezometricHeadExit = new RoundedDouble(2, double.NaN); PhreaticLevelExit = new NormalDistribution(3); DampingFactorExit = new LognormalDistribution(3) @@ -104,13 +105,29 @@ { return assessmentLevel; } - private set + set { assessmentLevel = value.ToPrecision(assessmentLevel.NumberOfDecimalPlaces); } } /// + /// Gets or sets the piezometric head at the exit point. + /// [m] + /// + public RoundedDouble PiezometricHeadExit + { + get + { + return piezometricHeadExit; + } + set + { + piezometricHeadExit = value.ToPrecision(piezometricHeadExit.NumberOfDecimalPlaces); + } + } + + /// /// Gets or sets the l-coordinate of the entry point, which, together with /// the l-coordinate of the exit point, is used to determine the seepage /// length of . @@ -130,7 +147,6 @@ throw new ArgumentOutOfRangeException("value", Resources.PipingInput_EntryPointL_Value_must_be_greater_than_or_equal_to_zero); } entryPointL = value.ToPrecision(entryPointL.NumberOfDecimalPlaces); - UpdateSeepageLength(); } } @@ -154,14 +170,24 @@ throw new ArgumentOutOfRangeException("value", Resources.PipingInput_ExitPointL_Value_must_be_greater_than_zero); } exitPointL = value.ToPrecision(exitPointL.NumberOfDecimalPlaces); - UpdateSeepageLength(); } } /// /// Gets or sets the surface line. /// - public RingtoetsPipingSurfaceLine SurfaceLine { get; set; } + public RingtoetsPipingSurfaceLine SurfaceLine + { + get + { + return surfaceLine; + } + set + { + surfaceLine = value; + UpdateEntryAndExitPoint(); + } + } /// /// Gets or sets the profile which contains a 1 dimensional definition of soil layers with properties. @@ -171,18 +197,7 @@ /// /// Gets or set the hydraulic boundary location from which to use the assessment level. /// - public HydraulicBoundaryLocation HydraulicBoundaryLocation - { - get - { - return hydraulicBoundaryLocation; - } - set - { - AssessmentLevel = (RoundedDouble)value.DesignWaterLevel; - hydraulicBoundaryLocation = value; - } - } + public HydraulicBoundaryLocation HydraulicBoundaryLocation { get; set; } #region General input parameters @@ -313,23 +328,6 @@ } } - /// - /// Updates the mean of the seepage length stochast based on the and - /// . - /// - private void UpdateSeepageLength() - { - try - { - SeepageLength.Mean = ExitPointL - EntryPointL; - } - catch (ArgumentOutOfRangeException) - { - SeepageLength.Mean = (RoundedDouble)double.NaN; - } - SeepageLength.StandardDeviation = SeepageLength.Mean * seepageLengthStandardDeviationFraction; - } - #endregion #region Probabilistic parameters @@ -379,7 +377,39 @@ /// Gets or sets the volumic weight of the saturated coverage layer. /// public ShiftedLognormalDistribution SaturatedVolumicWeightOfCoverageLayer { get; set; } - + #endregion + + private void UpdateEntryAndExitPoint() + { + if (SurfaceLine == null) + { + ExitPointL = (RoundedDouble)double.NaN; + SeepageLength.Mean = (RoundedDouble)double.NaN; + } + else + { + int entryPointIndex = Array.IndexOf(SurfaceLine.Points, SurfaceLine.DikeToeAtRiver); + int exitPointIndex = Array.IndexOf(SurfaceLine.Points, SurfaceLine.DikeToeAtPolder); + + Point2D[] localGeometry = SurfaceLine.ProjectGeometryToLZ().ToArray(); + + double tempEntryPointL = localGeometry[0].X; + double tempExitPointL = localGeometry[localGeometry.Length - 1].X; + + bool isDifferentPoints = entryPointIndex < 0 || exitPointIndex < 0 || entryPointIndex < exitPointIndex; + if (isDifferentPoints && exitPointIndex > 0) + { + tempExitPointL = localGeometry.ElementAt(exitPointIndex).X; + } + if (isDifferentPoints && entryPointIndex > -1) + { + tempEntryPointL = localGeometry.ElementAt(entryPointIndex).X; + } + + ExitPointL = (RoundedDouble)tempExitPointL; + EntryPointL = (RoundedDouble)tempEntryPointL; + } + } } } \ No newline at end of file Fisheye: Tag c0a3ced404197fd781c6fcbcfc21c6676592be57 refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Forms/Extensions/PipingInputExtensions.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingInputContext.cs =================================================================== diff -u -rc2ba7fe7272ecdda1b319d1caa18340d6cf219e4 -rc0a3ced404197fd781c6fcbcfc21c6676592be57 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingInputContext.cs (.../PipingInputContext.cs) (revision c2ba7fe7272ecdda1b319d1caa18340d6cf219e4) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PresentationObjects/PipingInputContext.cs (.../PipingInputContext.cs) (revision c0a3ced404197fd781c6fcbcfc21c6676592be57) @@ -22,6 +22,7 @@ using System.Collections.Generic; using Ringtoets.Common.Data; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Service; namespace Ringtoets.Piping.Forms.PresentationObjects { @@ -34,6 +35,8 @@ { public PipingInputContext(PipingInput pipingInput, IEnumerable surfaceLines, IEnumerable soilProfiles, AssessmentSectionBase assessmentSection) : base(pipingInput, surfaceLines, soilProfiles, assessmentSection) - { } + { + PipingInputSynchronizer.Synchronize(pipingInput); + } } } \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingInputContextProperties.cs =================================================================== diff -u -r3c10891728420f1c0aa0071574bbfb149710c556 -rc0a3ced404197fd781c6fcbcfc21c6676592be57 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingInputContextProperties.cs (.../PipingInputContextProperties.cs) (revision 3c10891728420f1c0aa0071574bbfb149710c556) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingInputContextProperties.cs (.../PipingInputContextProperties.cs) (revision c0a3ced404197fd781c6fcbcfc21c6676592be57) @@ -30,7 +30,6 @@ using Ringtoets.Piping.Calculation; using Ringtoets.Piping.Data; using Ringtoets.Piping.Data.Probabilistics; -using Ringtoets.Piping.Forms.Extensions; using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.Forms.Properties; using Ringtoets.Piping.Forms.TypeConverters; @@ -104,7 +103,7 @@ { get { - return data.WrappedData.GetPiezometricHeadExit(); + return data.WrappedData.PiezometricHeadExit; } } @@ -141,7 +140,7 @@ } set { - data.WrappedData.SetSurfaceLine(value); + data.WrappedData.SurfaceLine = value; data.WrappedData.NotifyObservers(); } } @@ -158,7 +157,7 @@ } set { - data.WrappedData.SetSoilProfile(value); + data.WrappedData.SoilProfile = value; data.WrappedData.NotifyObservers(); } } @@ -174,7 +173,7 @@ } set { - data.WrappedData.SetEntryPointL(value); + data.WrappedData.EntryPointL = value; data.WrappedData.NotifyObservers(); } } @@ -190,7 +189,7 @@ } set { - data.WrappedData.SetExitPointL(value); + data.WrappedData.ExitPointL = value; data.WrappedData.NotifyObservers(); } } Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Ringtoets.Piping.Forms.csproj =================================================================== diff -u -r6a1df79cc36617a42d0016f9b7a9271020a2196e -rc0a3ced404197fd781c6fcbcfc21c6676592be57 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Ringtoets.Piping.Forms.csproj (.../Ringtoets.Piping.Forms.csproj) (revision 6a1df79cc36617a42d0016f9b7a9271020a2196e) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Ringtoets.Piping.Forms.csproj (.../Ringtoets.Piping.Forms.csproj) (revision c0a3ced404197fd781c6fcbcfc21c6676592be57) @@ -51,7 +51,6 @@ Properties\GlobalAssembly.cs - Index: Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingCalculationService.cs =================================================================== diff -u -r3c10891728420f1c0aa0071574bbfb149710c556 -rc0a3ced404197fd781c6fcbcfc21c6676592be57 --- Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingCalculationService.cs (.../PipingCalculationService.cs) (revision 3c10891728420f1c0aa0071574bbfb149710c556) +++ Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingCalculationService.cs (.../PipingCalculationService.cs) (revision c0a3ced404197fd781c6fcbcfc21c6676592be57) @@ -126,6 +126,7 @@ PipingSemiProbabilisticDesignValueFactory.GetSaturatedVolumicWeightOfCoverageLayer(inputParameters).GetDesignValue(), inputParameters.UpliftModelFactor, inputParameters.AssessmentLevel, + inputParameters.PiezometricHeadExit, PipingSemiProbabilisticDesignValueFactory.GetDampingFactorExit(inputParameters).GetDesignValue(), PipingSemiProbabilisticDesignValueFactory.GetPhreaticLevelExit(inputParameters).GetDesignValue(), inputParameters.CriticalHeaveGradient, Index: Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingInputSynchronizer.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingInputSynchronizer.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingInputSynchronizer.cs (revision c0a3ced404197fd781c6fcbcfc21c6676592be57) @@ -0,0 +1,141 @@ +using System; +using Core.Common.Base; +using Core.Common.Base.Data; +using Ringtoets.Piping.Data; + +namespace Ringtoets.Piping.Service +{ + public class PipingInputSynchronizer : IObserver + { + private const double seepageLengthStandardDeviationFraction = 0.1; + + private readonly PipingInput input; + + private PipingInputSynchronizer(PipingInput input) + { + if (input == null) + { + throw new ArgumentNullException("input", "Cannot create PipingInputSynchronizer without PipingInput."); + } + input.Attach(this); + this.input = input; + + SynchronizeDerivedProperties(); + } + + /// + /// Starts the synchronization of the given . + /// + /// The input to synchronize the values for. + public static void Synchronize(PipingInput input) + { + new PipingInputSynchronizer(input); + } + + public void UpdateObserver() + { + SynchronizeDerivedProperties(); + } + + private void SynchronizeDerivedProperties() + { + UpdateAssessmentLevel(); + UpdateSeepageLength(); + UpdateThicknessCoverageLayer(); + UpdateThicknessAquiferLayer(); + UpdatePiezometricHeadExit(); + } + + private void UpdateThicknessAquiferLayer() + { + PipingSoilProfile soilProfile = input.SoilProfile; + RingtoetsPipingSurfaceLine surfaceLine = input.SurfaceLine; + double exitPointL = input.ExitPointL; + + double thicknessTopAquiferLayer = GetThicknessTopAquiferLayer(soilProfile, surfaceLine, exitPointL); + TrySetThicknessAquiferLayerMean(input, thicknessTopAquiferLayer); + } + + private static double GetThicknessTopAquiferLayer(PipingSoilProfile soilProfile, RingtoetsPipingSurfaceLine surfaceLine, double exitPointL) + { + var thicknessTopAquiferLayer = double.NaN; + + if (soilProfile != null && surfaceLine != null && !double.IsNaN(exitPointL)) + { + thicknessTopAquiferLayer = TryGetThicknessTopAquiferLayer(soilProfile, surfaceLine, exitPointL); + } + + return thicknessTopAquiferLayer; + } + + private static double TryGetThicknessTopAquiferLayer(PipingSoilProfile soilProfile, RingtoetsPipingSurfaceLine surfaceLine, double exitPointL) + { + try + { + var zAtL = surfaceLine.GetZAtL(exitPointL); + return soilProfile.GetTopAquiferLayerThicknessBelowLevel(zAtL); + } + catch (ArgumentOutOfRangeException) + { + return double.NaN; + } + } + + private static void TrySetThicknessAquiferLayerMean(PipingInput input, double thicknessTopAquiferLayer) + { + try + { + input.ThicknessAquiferLayer.Mean = (RoundedDouble) thicknessTopAquiferLayer; + } + catch (ArgumentOutOfRangeException) + { + input.ThicknessAquiferLayer.Mean = (RoundedDouble) double.NaN; + } + } + + private void UpdateThicknessCoverageLayer() + { + try + { + input.ThicknessCoverageLayer.Mean = (RoundedDouble) PipingCalculationService.CalculateThicknessCoverageLayer(input); + } + catch (ArgumentOutOfRangeException) + { + input.ThicknessCoverageLayer.Mean = (RoundedDouble) double.NaN; + } + } + + private void UpdatePiezometricHeadExit() + { + try + { + input.PiezometricHeadExit = (RoundedDouble) PipingCalculationService.CalculatePiezometricHeadAtExit(input); + } + catch (ArgumentOutOfRangeException) + { + input.PiezometricHeadExit = (RoundedDouble) double.NaN; + } + } + + private void UpdateAssessmentLevel() + { + input.AssessmentLevel = + input.HydraulicBoundaryLocation == null ? + (RoundedDouble) double.NaN : + (RoundedDouble) input.HydraulicBoundaryLocation.DesignWaterLevel; + } + + private void UpdateSeepageLength() + { + try + { + input.SeepageLength.Mean = input.ExitPointL - input.EntryPointL; + } + catch (ArgumentOutOfRangeException) + { + input.SeepageLength.Mean = (RoundedDouble) double.NaN; + } + input.SeepageLength.StandardDeviation = input.SeepageLength.Mean*seepageLengthStandardDeviationFraction; + } + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Service/Ringtoets.Piping.Service.csproj =================================================================== diff -u -rf98cc7191a717793f69485dad2923cd34f6d48de -rc0a3ced404197fd781c6fcbcfc21c6676592be57 --- Ringtoets/Piping/src/Ringtoets.Piping.Service/Ringtoets.Piping.Service.csproj (.../Ringtoets.Piping.Service.csproj) (revision f98cc7191a717793f69485dad2923cd34f6d48de) +++ Ringtoets/Piping/src/Ringtoets.Piping.Service/Ringtoets.Piping.Service.csproj (.../Ringtoets.Piping.Service.csproj) (revision c0a3ced404197fd781c6fcbcfc21c6676592be57) @@ -54,6 +54,7 @@ + True @@ -76,6 +77,10 @@ {D4200F43-3F72-4F42-AF0A-8CED416A38EC} Ringtoets.Common.Data + + {70f8cc9c-5bc8-4fb2-b201-eae7fa8088c2} + Ringtoets.HydraRing.Data + {CE994CC9-6F6A-48AC-B4BE-02C30A21F4DB} Ringtoets.Piping.Data Index: Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/PipingCalculatorInputTest.cs =================================================================== diff -u -r3c10891728420f1c0aa0071574bbfb149710c556 -rc0a3ced404197fd781c6fcbcfc21c6676592be57 --- Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/PipingCalculatorInputTest.cs (.../PipingCalculatorInputTest.cs) (revision 3c10891728420f1c0aa0071574bbfb149710c556) +++ Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/PipingCalculatorInputTest.cs (.../PipingCalculatorInputTest.cs) (revision c0a3ced404197fd781c6fcbcfc21c6676592be57) @@ -17,6 +17,7 @@ double saturatedVolumicWeightOfCoverageLayer = random.NextDouble(); double modelFactorUpliftValue = random.NextDouble(); double hRiverValue = random.NextDouble(); + double phiExit = random.NextDouble(); double rExitValue = random.NextDouble(); double hExitValue = random.NextDouble(); double ichValue = random.NextDouble(); @@ -48,6 +49,7 @@ saturatedVolumicWeightOfCoverageLayer, modelFactorUpliftValue, hRiverValue, + phiExit, rExitValue, hExitValue, ichValue, @@ -72,6 +74,7 @@ Assert.AreEqual(saturatedVolumicWeightOfCoverageLayer, input.SaturatedVolumicWeightOfCoverageLayer); Assert.AreEqual(modelFactorUpliftValue, input.UpliftModelFactor); Assert.AreEqual(hRiverValue, input.AssessmentLevel); + Assert.AreEqual(phiExit, input.PiezometricHeadExit); Assert.AreEqual(rExitValue, input.DampingFactorExit); Assert.AreEqual(hExitValue, input.PhreaticLevelExit); Assert.AreEqual(ichValue, input.CriticalHeaveGradient); Index: Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/PipingCalculatorTest.cs =================================================================== diff -u -r3c10891728420f1c0aa0071574bbfb149710c556 -rc0a3ced404197fd781c6fcbcfc21c6676592be57 --- Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/PipingCalculatorTest.cs (.../PipingCalculatorTest.cs) (revision 3c10891728420f1c0aa0071574bbfb149710c556) +++ Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/PipingCalculatorTest.cs (.../PipingCalculatorTest.cs) (revision c0a3ced404197fd781c6fcbcfc21c6676592be57) @@ -140,8 +140,8 @@ // Setup PipingCalculatorInput input = new TestPipingInput { - AssessmentLevel = (RoundedDouble)level, - PhreaticLevelExit = level + PhreaticLevelExit = level, + PiezometricHeadExit = (RoundedDouble)level }.AsRealInput(); var calculation = new PipingCalculator(input, new PipingSubCalculatorFactory()); @@ -156,7 +156,7 @@ } [Test] - public void Validate_DampingFactorExitZero_TwoValidationMessageForRExitTwoValidationMessagesForPhiExitAndHExitDifference() + public void Validate_DampingFactorExitZero_TwoValidationMessageForRExit() { // Setup PipingCalculatorInput input = new TestPipingInput @@ -171,10 +171,8 @@ List validationMessages = calculation.Validate(); // Assert - Assert.AreEqual(4, validationMessages.Count); + Assert.AreEqual(2, validationMessages.Count); Assert.AreEqual(2, validationMessages.Count(message => message.Contains("Rexit"))); - Assert.AreEqual(1, validationMessages.Count(message => message.Contains("PhiExit - HExit"))); - Assert.AreEqual(1, validationMessages.Count(message => message.Contains("phiExit - hExit"))); } [Test] Index: Ringtoets/Piping/test/Ringtoets.Piping.Calculation.TestUtil/TestPipingInput.cs =================================================================== diff -u -r3c10891728420f1c0aa0071574bbfb149710c556 -rc0a3ced404197fd781c6fcbcfc21c6676592be57 --- Ringtoets/Piping/test/Ringtoets.Piping.Calculation.TestUtil/TestPipingInput.cs (.../TestPipingInput.cs) (revision 3c10891728420f1c0aa0071574bbfb149710c556) +++ Ringtoets/Piping/test/Ringtoets.Piping.Calculation.TestUtil/TestPipingInput.cs (.../TestPipingInput.cs) (revision c0a3ced404197fd781c6fcbcfc21c6676592be57) @@ -13,6 +13,7 @@ public double SaturatedVolumicWeightOfCoverageLayer; public double UpliftModelFactor; public RoundedDouble AssessmentLevel; + public RoundedDouble PiezometricHeadExit; public double DampingFactorExit; public double PhreaticLevelExit; public double CriticalHeaveGradient; @@ -42,6 +43,7 @@ SaturatedVolumicWeightOfCoverageLayer = NextIncrementalDouble(); UpliftModelFactor = NextIncrementalDouble(); AssessmentLevel = (RoundedDouble)NextIncrementalDouble(); + PiezometricHeadExit = (RoundedDouble)NextIncrementalDouble(); PhreaticLevelExit = NextIncrementalDouble(); DampingFactorExit = NextIncrementalDouble(); CriticalHeaveGradient = NextIncrementalDouble(); @@ -106,6 +108,7 @@ SaturatedVolumicWeightOfCoverageLayer, UpliftModelFactor, AssessmentLevel, + PiezometricHeadExit, DampingFactorExit, PhreaticLevelExit, CriticalHeaveGradient, Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingInputTest.cs =================================================================== diff -u -r3c10891728420f1c0aa0071574bbfb149710c556 -rc0a3ced404197fd781c6fcbcfc21c6676592be57 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingInputTest.cs (.../PipingInputTest.cs) (revision 3c10891728420f1c0aa0071574bbfb149710c556) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingInputTest.cs (.../PipingInputTest.cs) (revision c0a3ced404197fd781c6fcbcfc21c6676592be57) @@ -2,6 +2,7 @@ using Core.Common.Base; using Core.Common.Base.Data; +using Core.Common.Base.Geometry; using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.HydraRing.Data; @@ -100,6 +101,8 @@ Assert.AreEqual(2, inputParameters.ExitPointL.NumberOfDecimalPlaces); Assert.IsNaN(inputParameters.EntryPointL); Assert.AreEqual(2, inputParameters.EntryPointL.NumberOfDecimalPlaces); + Assert.IsNaN(inputParameters.PiezometricHeadExit); + Assert.AreEqual(2, inputParameters.PiezometricHeadExit.NumberOfDecimalPlaces); Assert.IsInstanceOf(inputParameters.AssessmentLevel); Assert.AreEqual(2, inputParameters.AssessmentLevel.NumberOfDecimalPlaces); @@ -187,59 +190,27 @@ } [Test] - [TestCase(double.NaN, double.NaN, double.NaN)] - [TestCase(double.NaN, 3, double.NaN)] - [TestCase(2, double.NaN, double.NaN)] - [TestCase(2, 4, 2.0)] - [TestCase(0, 3, 3.0)] - [TestCase(4e-3, 6, 6.0)] - public void SeepageLength_DifferentCombinationsOfEntryAndExitPoint_SeepageLengthUpdatedAsExpected(double entryPointL, double exitPointL, double expectedSeepageLength) + public void SurfaceLine_WithDikeToes_ThenExitPointLAndEntryPointLUpdated() { - // Setup - var pipingInput = new PipingInput(new GeneralPipingInput()); + // Given + var input = new PipingInput(new GeneralPipingInput()); - // Call - pipingInput.ExitPointL = (RoundedDouble)exitPointL; - pipingInput.EntryPointL = (RoundedDouble)entryPointL; - - // Assert - Assert.AreEqual(expectedSeepageLength, pipingInput.SeepageLength.Mean.Value); - Assert.AreEqual(expectedSeepageLength * 0.1, pipingInput.SeepageLength.StandardDeviation, GetErrorTolerance(pipingInput.SeepageLength.StandardDeviation)); - } - - [Test] - [TestCase(4, 2)] - [TestCase(3 + 1e-6, 3)] - public void SeepageLength_SettingEntryPastExitPoint_SeepageLengthSetToNaN(double entryPointL, double exitPointL) - { - // Setup - var pipingInput = new PipingInput(new GeneralPipingInput()); - pipingInput.ExitPointL = (RoundedDouble)exitPointL; - - // Call - pipingInput.EntryPointL = (RoundedDouble)entryPointL; - - // Assert - Assert.IsNaN(pipingInput.SeepageLength.Mean); - } - - [Test] - public void HydraulicBoundary_SetToNewValue_AssessmentLevelValueIsRounded() - { - // Setup - var pipingInput = new PipingInput(new GeneralPipingInput()); - var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, string.Empty, 0.0, 0.0) + var surfaceLine = new RingtoetsPipingSurfaceLine(); + surfaceLine.SetGeometry(new[] { - DesignWaterLevel = -8.29292 - }; - int originalNumberOfDecimalPlaces = pipingInput.AssessmentLevel.NumberOfDecimalPlaces; + new Point3D(0, 0, 0), + new Point3D(1, 0, 2), + new Point3D(2, 0, 3) + }); + surfaceLine.SetDikeToeAtRiverAt(new Point3D(1, 0, 2)); + surfaceLine.SetDikeToeAtPolderAt(new Point3D(2, 0, 3)); // Call - pipingInput.HydraulicBoundaryLocation = hydraulicBoundaryLocation; + input.SurfaceLine = surfaceLine; // Assert - Assert.AreEqual(originalNumberOfDecimalPlaces, pipingInput.AssessmentLevel.NumberOfDecimalPlaces); - Assert.AreEqual(-8.29, pipingInput.AssessmentLevel.Value); + Assert.AreEqual(new RoundedDouble(2, 1), input.EntryPointL); + Assert.AreEqual(new RoundedDouble(2, 2), input.ExitPointL); } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingCalculationFactory.cs =================================================================== diff -u -r3c10891728420f1c0aa0071574bbfb149710c556 -rc0a3ced404197fd781c6fcbcfc21c6676592be57 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingCalculationFactory.cs (.../PipingCalculationFactory.cs) (revision 3c10891728420f1c0aa0071574bbfb149710c556) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingCalculationFactory.cs (.../PipingCalculationFactory.cs) (revision c0a3ced404197fd781c6fcbcfc21c6676592be57) @@ -84,6 +84,7 @@ { Mean = (RoundedDouble)1.0 }, + PiezometricHeadExit = (RoundedDouble)2.1, SurfaceLine = surfaceLine, SoilProfile = soilProfile, HydraulicBoundaryLocation = hydraulicBoundaryLocation Fisheye: Tag c0a3ced404197fd781c6fcbcfc21c6676592be57 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Extensions/PipingInputExtensionsTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs =================================================================== diff -u -r3c10891728420f1c0aa0071574bbfb149710c556 -rc0a3ced404197fd781c6fcbcfc21c6676592be57 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs (.../PipingInputContextPropertiesTest.cs) (revision 3c10891728420f1c0aa0071574bbfb149710c556) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs (.../PipingInputContextPropertiesTest.cs) (revision c0a3ced404197fd781c6fcbcfc21c6676592be57) @@ -5,18 +5,15 @@ using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Core.Common.Gui.PropertyBag; -using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data; using Ringtoets.HydraRing.Data; using Ringtoets.Piping.Calculation.TestUtil; using Ringtoets.Piping.Data; using Ringtoets.Piping.Data.Probabilistics; -using Ringtoets.Piping.Forms.Extensions; using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.Forms.PropertyClasses; -using Ringtoets.Piping.Service; namespace Ringtoets.Piping.Forms.Test.PropertyClasses { @@ -58,8 +55,8 @@ { HydraulicBoundaryLocation = testHydraulicBoundaryLocation }; - inputParameters.SetSurfaceLine(surfaceLine); - inputParameters.SetSoilProfile(soilProfile); + inputParameters.SurfaceLine = surfaceLine; + inputParameters.SoilProfile = (soilProfile); var properties = new PipingInputContextProperties { @@ -78,7 +75,7 @@ Assert.AreSame(inputParameters.ThicknessAquiferLayer, properties.ThicknessAquiferLayer.Distribution); Assert.AreEqual(inputParameters.AssessmentLevel, properties.AssessmentLevel); - Assert.AreEqual(inputParameters.GetPiezometricHeadExit(), properties.PiezometricHeadExit); + Assert.AreEqual(inputParameters.PiezometricHeadExit, properties.PiezometricHeadExit); Assert.AreSame(inputParameters.SeepageLength, properties.SeepageLength.Distribution); Assert.AreEqual(inputParameters.SeepageLength.Mean, properties.ExitPointL - properties.EntryPointL); @@ -240,7 +237,7 @@ var surfaceLine = ValidSurfaceLine(0.0, 4.0); var inputParameters = new PipingInput(new GeneralPipingInput()); - inputParameters.SetSurfaceLine(surfaceLine); + inputParameters.SurfaceLine = surfaceLine; inputParameters.Attach(inputObserver); var properties = new PipingInputContextProperties @@ -312,7 +309,7 @@ var surfaceLine = ValidSurfaceLine(0.0, 4.0); var inputParameters = new PipingInput(new GeneralPipingInput()); - inputParameters.SetSurfaceLine(surfaceLine); + inputParameters.SurfaceLine = surfaceLine; var properties = new PipingInputContextProperties { Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Ringtoets.Piping.Forms.Test.csproj =================================================================== diff -u -r6a1df79cc36617a42d0016f9b7a9271020a2196e -rc0a3ced404197fd781c6fcbcfc21c6676592be57 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Ringtoets.Piping.Forms.Test.csproj (.../Ringtoets.Piping.Forms.Test.csproj) (revision 6a1df79cc36617a42d0016f9b7a9271020a2196e) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Ringtoets.Piping.Forms.Test.csproj (.../Ringtoets.Piping.Forms.Test.csproj) (revision c0a3ced404197fd781c6fcbcfc21c6676592be57) @@ -59,7 +59,6 @@ - Index: Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingCalculationServiceTest.cs =================================================================== diff -u -r3c10891728420f1c0aa0071574bbfb149710c556 -rc0a3ced404197fd781c6fcbcfc21c6676592be57 --- Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingCalculationServiceTest.cs (.../PipingCalculationServiceTest.cs) (revision 3c10891728420f1c0aa0071574bbfb149710c556) +++ Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingCalculationServiceTest.cs (.../PipingCalculationServiceTest.cs) (revision c0a3ced404197fd781c6fcbcfc21c6676592be57) @@ -8,7 +8,6 @@ using Ringtoets.Piping.Calculation.TestUtil; using NUnit.Framework; -using Ringtoets.HydraRing.Data; using Ringtoets.Piping.Calculation; using Ringtoets.Piping.Calculation.TestUtil.SubCalculator; using Ringtoets.Piping.Data; @@ -89,17 +88,14 @@ public void CalculateThicknessCoverageLayer_ValidInput_ReturnsThickness() { // Setup - PipingInput input = new PipingInput(new GeneralPipingInput()) + var surfaceLine = new RingtoetsPipingSurfaceLine(); + surfaceLine.SetGeometry(new[] { - ExitPointL = (RoundedDouble)10, - SurfaceLine = new RingtoetsPipingSurfaceLine() - }; - input.SurfaceLine.SetGeometry(new[] - { new Point3D(0, 0, 10), new Point3D(20, 0, 10) }); - input.SoilProfile = new PipingSoilProfile(string.Empty, 0, new[] + + var soilProfile = new PipingSoilProfile(string.Empty, 0, new[] { new PipingSoilLayer(5) { @@ -111,6 +107,13 @@ } }); + PipingInput input = new PipingInput(new GeneralPipingInput()) + { + ExitPointL = (RoundedDouble) 10, + SurfaceLine = surfaceLine, + SoilProfile = soilProfile + }; + // Call var thickness = PipingCalculationService.CalculateThicknessCoverageLayer(input); @@ -124,10 +127,7 @@ // Setup PipingInput input = new PipingInput(new GeneralPipingInput()) { - HydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, string.Empty, 0.0, 0.0) - { - DesignWaterLevel = (RoundedDouble) 0.0 - } + AssessmentLevel = (RoundedDouble) 0.0 }; // Call @@ -290,7 +290,6 @@ var heaveCalculator = testFactory.LastCreatedHeaveCalculator; var upliftCalculator = testFactory.LastCreatedUpliftCalculator; var sellmeijerCalculator = testFactory.LastCreatedSellmeijerCalculator; - var piezometricHeadAtExitCalculator = testFactory.LastCreatedPiezometricHeadAtExitCalculator; Assert.AreEqual(PipingSemiProbabilisticDesignValueFactory.GetThicknessCoverageLayer(input).GetDesignValue(), heaveCalculator.DTotal, GetAccuracy(input.ThicknessCoverageLayer.Mean)); @@ -299,15 +298,15 @@ Assert.AreEqual(input.CriticalHeaveGradient, heaveCalculator.Ich); Assert.AreEqual(PipingSemiProbabilisticDesignValueFactory.GetPhreaticLevelExit(input).GetDesignValue(), heaveCalculator.PhiPolder, GetAccuracy(input.PhreaticLevelExit.Mean)); - Assert.AreEqual(piezometricHeadAtExitCalculator.PhiExit, heaveCalculator.PhiExit); + Assert.AreEqual(input.PiezometricHeadExit.Value, heaveCalculator.PhiExit); Assert.AreEqual(PipingSemiProbabilisticDesignValueFactory.GetDampingFactorExit(input).GetDesignValue(), heaveCalculator.RExit, GetAccuracy(input.DampingFactorExit.Mean)); Assert.AreEqual(PipingSemiProbabilisticDesignValueFactory.GetPhreaticLevelExit(input).GetDesignValue(), upliftCalculator.HExit, GetAccuracy(input.PhreaticLevelExit.Mean)); Assert.AreEqual(input.AssessmentLevel.Value, upliftCalculator.HRiver); Assert.AreEqual(input.UpliftModelFactor, upliftCalculator.ModelFactorUplift); - Assert.AreEqual(piezometricHeadAtExitCalculator.PhiExit, upliftCalculator.PhiExit); + Assert.AreEqual(input.PiezometricHeadExit.Value, upliftCalculator.PhiExit); Assert.AreEqual(PipingSemiProbabilisticDesignValueFactory.GetPhreaticLevelExit(input).GetDesignValue(), upliftCalculator.PhiPolder, GetAccuracy(input.PhreaticLevelExit.Mean)); Assert.AreEqual(PipingSemiProbabilisticDesignValueFactory.GetDampingFactorExit(input).GetDesignValue(), upliftCalculator.RExit, Index: Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingInputSynchronizerTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingInputSynchronizerTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingInputSynchronizerTest.cs (revision c0a3ced404197fd781c6fcbcfc21c6676592be57) @@ -0,0 +1,510 @@ +using System; +using Core.Common.Base; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.HydraRing.Data; +using Ringtoets.Piping.Calculation; +using Ringtoets.Piping.Calculation.TestUtil.SubCalculator; +using Ringtoets.Piping.Data; +using Ringtoets.Piping.Service.TestUtil; + +namespace Ringtoets.Piping.Service.Test +{ + [TestFixture] + public class PipingInputSynchronizerTest + { + [Test] + public void Create_WithoutPipingInput_ArgumentNullException() + { + // Call + TestDelegate call = () => PipingInputSynchronizer.Synchronize(null); + + // Assert + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "Cannot create PipingInputSynchronizer without PipingInput."); + } + + [Test] + public void Create_WithPipingInput_InputDataSynchronized() + { + // Setup + var input = CreateInputWithAquiferAndCoverageLayer(1.0, 1.1); + double randomLevel = new Random(22).NextDouble(); + input.HydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, string.Empty, 0, 0) + { + DesignWaterLevel = randomLevel + }; + + // Call + PipingInputSynchronizer.Synchronize(input); + + // Assert + Assert.AreEqual(1.0, input.ThicknessAquiferLayer.Mean.Value); + Assert.AreEqual(1.1, input.ThicknessCoverageLayer.Mean.Value); + Assert.AreEqual(0.5, input.SeepageLength.Mean.Value); + Assert.AreEqual(new RoundedDouble(2, randomLevel), input.AssessmentLevel); + Assert.IsFalse(double.IsNaN(input.PiezometricHeadExit)); + } + + [Test] + public void NotifyObservers_InputHasNewHydraulicBoundaryLocationSet_AssessmentLevelUpdated() + { + // Setup + var input = new PipingInput(new GeneralPipingInput()); + PipingInputSynchronizer.Synchronize(input); + + double testLevel = new Random(21).NextDouble(); + + input.HydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, string.Empty, 0.0, 0.0) + { + DesignWaterLevel = testLevel + }; + + // Call + input.NotifyObservers(); + + // Assert + Assert.AreEqual(new RoundedDouble(2, testLevel), input.AssessmentLevel); + } + + [Test] + public void NotifyObservers_InputWithoutHydraulicBoundaryLocationSet_AssessmentLevelSetToNaN() + { + // Setup + var input = new PipingInput(new GeneralPipingInput()); + PipingInputSynchronizer.Synchronize(input); + + input.HydraulicBoundaryLocation = null; + + // Call + input.NotifyObservers(); + + // Assert + Assert.IsNaN(input.AssessmentLevel); + } + + [Test] + public void NotifyObservers_ValidInput_SetsParametersForCalculatorAndSetPiezometricHead() + { + // Setup + var input = new PipingInput(new GeneralPipingInput()); + PipingInputSynchronizer.Synchronize(input); + + using (new PipingCalculationServiceConfig()) + { + // Call + input.NotifyObservers(); + + // Assert + var result = input.PiezometricHeadExit; + Assert.AreEqual(2, result.NumberOfDecimalPlaces); + Assert.IsFalse(double.IsNaN(result)); + + var factory = (TestPipingSubCalculatorFactory)PipingCalculationService.SubCalculatorFactory; + var piezometricHeadAtExitCalculator = factory.LastCreatedPiezometricHeadAtExitCalculator; + + Assert.AreEqual(input.AssessmentLevel.Value, piezometricHeadAtExitCalculator.HRiver); + Assert.AreEqual(PipingSemiProbabilisticDesignValueFactory.GetPhreaticLevelExit(input).GetDesignValue(), piezometricHeadAtExitCalculator.PhiPolder, + GetAccuracy(input.PhreaticLevelExit.Mean)); + Assert.AreEqual(PipingSemiProbabilisticDesignValueFactory.GetDampingFactorExit(input).GetDesignValue(), piezometricHeadAtExitCalculator.RExit, + GetAccuracy(input.DampingFactorExit.Mean)); + } + } + + [Test] + public void NotifyObservers_InputWithAssessmentLevelMissing_PiezometricHeadSetToNaN() + { + // Setup + var input = CreateInputWithAquiferAndCoverageLayer(1.0, 1.0); + input.AssessmentLevel = (RoundedDouble) double.NaN; + PipingInputSynchronizer.Synchronize(input); + + // Call + input.NotifyObservers(); + + // Assert + Assert.IsNaN(input.PiezometricHeadExit); + } + + [Test] + public void GivenSynchronizerBoundToInputOutOfScope_WhenGarbageCollected_InputNotAlive() + { + // Given + WeakReference input; + + { + input = new WeakReference(new PipingInput(new GeneralPipingInput())); + PipingInputSynchronizer.Synchronize(input.Target as PipingInput); + } + + // When + GC.Collect(); + GC.WaitForFullGCComplete(); + + // Then + Assert.IsFalse(input.IsAlive); + } + + [Test] + public void NotifyObservers_SoilProfileSingleAquiferAndCoverageUnderSurfaceLine_MeansSet() + { + // Setup + var input = CreateInputWithAquiferAndCoverageLayer(); + PipingInputSynchronizer.Synchronize(input); + + // Call + input.NotifyObservers(); + + // Assert + Assert.AreEqual(1.0, input.ThicknessAquiferLayer.Mean.Value); + Assert.AreEqual(2.0, input.ThicknessCoverageLayer.Mean.Value); + } + + [Test] + public void NotifyObservers_InputWithoutSoilProfile_MeansSetToNaN() + { + // Setup + var input = CreateInputWithAquiferAndCoverageLayer(); + input.SoilProfile = null; + PipingInputSynchronizer.Synchronize(input); + + // Call + input.NotifyObservers(); + + // Assert + Assert.IsNaN(input.ThicknessAquiferLayer.Mean); + Assert.IsNaN(input.ThicknessCoverageLayer.Mean); + } + + [Test] + public void NotifyObservers_InputWithoutSurfaceLine_MeansSetToNaN() + { + // Setup + var input = CreateInputWithAquiferAndCoverageLayer(); + input.SurfaceLine = null; + PipingInputSynchronizer.Synchronize(input); + + // Call + input.NotifyObservers(); + + // Assert + Assert.IsNaN(input.ThicknessAquiferLayer.Mean); + Assert.IsNaN(input.ThicknessCoverageLayer.Mean); + } + + [Test] + [TestCase(1e-6)] + [TestCase(1)] + public void NotifyObservers_SoilProfileSingleAquiferAboveSurfaceLine_ThicknessAquiferLayerNaN(double deltaAboveSurfaceLine) + { + // Setup + var input = CreateInputWithSingleAquiferLayerAboveSurfaceLine(deltaAboveSurfaceLine); + PipingInputSynchronizer.Synchronize(input); + + // Call + input.NotifyObservers(); + + // Assert + Assert.IsNaN(input.ThicknessAquiferLayer.Mean); + } + + [Test] + public void NotifyObservers_SoilProfileMultipleAquiferUnderSurfaceLine_AquiferMeanSetToTopAquiferThickness() + { + // Setup + double expectedThickness; + var input = CreateInputWithMultipleAquiferLayersUnderSurfaceLine(out expectedThickness); + PipingInputSynchronizer.Synchronize(input); + + // Call + input.NotifyObservers(); + + // Assert + Assert.AreEqual(expectedThickness, input.ThicknessAquiferLayer.Mean, 1e-8); + } + + [Test] + public void NotifyObservers_MeanSetExitPointSetToNaN_ThicknessAquiferLayerNaN() + { + // Setup + var input = CreateInputWithAquiferAndCoverageLayer(); + input.ExitPointL = (RoundedDouble)double.NaN; + PipingInputSynchronizer.Synchronize(input); + + // Call + input.NotifyObservers(); + + // Assert + Assert.IsNaN(input.ThicknessAquiferLayer.Mean); + } + + [Test] + public void NotifyObservers_MeanSetSoilProfileSetToNull_ThicknessCoverageLayerNaN() + { + // Setup + var input = CreateInputWithAquiferAndCoverageLayer(); + PipingInputSynchronizer.Synchronize(input); + input.ThicknessCoverageLayer.Mean = new RoundedDouble(2, new Random(21).NextDouble() + 1); + + // Call + input.SoilProfile= null; + input.NotifyObservers(); + + // Assert + Assert.IsNaN(input.ThicknessCoverageLayer.Mean); + } + + [Test] + public void NotifyObservers_AquiferLayerThicknessZero_ThicknessCoverageLayerNaN() + { + // Setup + var input = CreateInputWithAquiferAndCoverageLayer(); + PipingInputSynchronizer.Synchronize(input); + input.SoilProfile = new PipingSoilProfile(String.Empty, 0, new[] + { + new PipingSoilLayer(2.0) + { + IsAquifer = true + }, + new PipingSoilLayer(2.0) + { + IsAquifer = false + } + }); + + // Call + input.NotifyObservers(); + + // Assert + Assert.IsNaN(input.ThicknessCoverageLayer.Mean); + } + + [Test] + public void NotifyObservers_ProfileWithoutAquiferLayer_ThicknessCoverageLayerNaN() + { + // Setup + var input = CreateInputWithAquiferAndCoverageLayer(); + PipingInputSynchronizer.Synchronize(input); + input.SoilProfile = new PipingSoilProfile(String.Empty, 0, new[] + { + new PipingSoilLayer(2.0) + { + IsAquifer = false + } + }); + + // Call + input.NotifyObservers(); + + // Assert + Assert.IsNaN(input.ThicknessCoverageLayer.Mean); + } + + [Test] + public void NotifyObservers_SoilProfileSingleAquiferUnderSurfaceLine_ThicknessAquiferLayerMeanSet() + { + // Setup + var input = CreateInputWithAquiferAndCoverageLayer(); + PipingInputSynchronizer.Synchronize(input); + + // Call + input.NotifyObservers(); + + // Assert + Assert.AreEqual(1.0, input.ThicknessAquiferLayer.Mean.Value); + } + + [Test] + [TestCase(1e-6)] + [TestCase(1)] + public void SetSoilProfile_SoilProfileSingleAquiferAboveSurfaceLine_ThicknessAquiferLayerNaN(double deltaAboveSurfaceLine) + { + // Setup + var input = CreateInputWithSingleAquiferLayerAboveSurfaceLine(deltaAboveSurfaceLine); + PipingInputSynchronizer.Synchronize(input); + + // Call + input.NotifyObservers(); + + // Assert + Assert.IsNaN(input.ThicknessAquiferLayer.Mean); + } + + [Test] + public void SetSoilProfile_SoilProfileMultipleAquiferUnderSurfaceLine_MeanSetToTopAquiferThickness() + { + // Setup + double expectedThickness; + var input = CreateInputWithMultipleAquiferLayersUnderSurfaceLine(out expectedThickness); + PipingInputSynchronizer.Synchronize(input); + + // Call + input.NotifyObservers(); + + // Assert + Assert.AreEqual(expectedThickness, input.ThicknessAquiferLayer.Mean, 1e-8); + } + + [Test] + public void SetSoilProfile_MeanSetSoilProfileSetToNull_ThicknessAquiferLayerNaN() + { + // Setup + var input = CreateInputWithAquiferAndCoverageLayer(); + PipingInputSynchronizer.Synchronize(input); + + input.SoilProfile = null; + + // Call + input.NotifyObservers(); + + // Assert + Assert.IsNaN(input.ThicknessAquiferLayer.Mean); + } + + [Test] + public void SetSoilProfile_InputResultsInZeroThickness_ThicknessAquiferLayerNaN() + { + // Setup + var input = CreateInputWithAquiferAndCoverageLayer(); + PipingInputSynchronizer.Synchronize(input); + input.SoilProfile = new PipingSoilProfile(String.Empty, 0, new[] + { + new PipingSoilLayer(2.0) + { + IsAquifer = false + }, + new PipingSoilLayer(0.0) + { + IsAquifer = true + } + }); + + // Call + input.NotifyObservers(); + + // Assert + Assert.IsNaN(input.ThicknessAquiferLayer.Mean); + } + + [Test] + public void SetSoilProfile_SurfaceLineHalfWayProfileLayer_ThicknessSetToLayerHeightUnderSurfaceLine() + { + // Setup + var input = CreateInputWithAquiferAndCoverageLayer(); + PipingInputSynchronizer.Synchronize(input); + input.SoilProfile = new PipingSoilProfile(String.Empty, 0, new[] + { + new PipingSoilLayer(2.5) + { + IsAquifer = true + }, + new PipingSoilLayer(1.5) + { + IsAquifer = true + } + }); + + // Call + input.NotifyObservers(); + + // Assert + Assert.AreEqual(0.5, input.ThicknessAquiferLayer.Mean.Value); + } + + private static PipingInput CreateInputWithAquiferAndCoverageLayer(double thicknessAquiferLayer = 1.0, double thicknessCoverageLayer = 2.0) + { + var surfaceLine = new RingtoetsPipingSurfaceLine(); + surfaceLine.SetGeometry(new[] + { + new Point3D(0, 0, thicknessCoverageLayer), + new Point3D(1.0, 0, thicknessCoverageLayer) + }); + var soilProfile = new PipingSoilProfile(String.Empty, -thicknessAquiferLayer, new[] + { + new PipingSoilLayer(thicknessCoverageLayer) + { + IsAquifer = false + }, + new PipingSoilLayer(0.0) + { + IsAquifer = true + } + }); + + return new PipingInput(new GeneralPipingInput()) + { + SurfaceLine = surfaceLine, + SoilProfile = soilProfile, + ExitPointL = (RoundedDouble) 0.5 + }; + } + + private static PipingInput CreateInputWithSingleAquiferLayerAboveSurfaceLine(double deltaAboveSurfaceLine) + { + var surfaceLine = new RingtoetsPipingSurfaceLine(); + var surfaceLineTopLevel = 2.0; + surfaceLine.SetGeometry(new[] + { + new Point3D(0, 0, surfaceLineTopLevel), + new Point3D(1.0, 0, surfaceLineTopLevel), + }); + var soilProfile = new PipingSoilProfile(String.Empty, 0, new[] + { + new PipingSoilLayer(surfaceLineTopLevel + deltaAboveSurfaceLine) + { + IsAquifer = false + }, + new PipingSoilLayer(surfaceLineTopLevel + deltaAboveSurfaceLine + 1) + { + IsAquifer = true + } + }); + var input = new PipingInput(new GeneralPipingInput()) + { + SurfaceLine = surfaceLine, + SoilProfile = soilProfile, + ExitPointL = (RoundedDouble)0.5 + }; + return input; + } + + private static PipingInput CreateInputWithMultipleAquiferLayersUnderSurfaceLine(out double expectedThickness) + { + var surfaceLine = new RingtoetsPipingSurfaceLine(); + surfaceLine.SetGeometry(new[] + { + new Point3D(0, 0, 3.3), + new Point3D(1.0, 0, 3.3), + }); + var soilProfile = new PipingSoilProfile(String.Empty, 0, new[] + { + new PipingSoilLayer(4.3) + { + IsAquifer = false + }, + new PipingSoilLayer(3.3) + { + IsAquifer = true + }, + new PipingSoilLayer(1.1) + { + IsAquifer = true + } + }); + var input = new PipingInput(new GeneralPipingInput()) + { + SurfaceLine = surfaceLine, + SoilProfile = soilProfile, + ExitPointL = (RoundedDouble)0.5 + }; + expectedThickness = 2.2; + return input; + } + + private static double GetAccuracy(RoundedDouble roundedDouble) + { + return Math.Pow(10.0, -roundedDouble.NumberOfDecimalPlaces); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/Ringtoets.Piping.Service.Test.csproj =================================================================== diff -u -r3c10891728420f1c0aa0071574bbfb149710c556 -rc0a3ced404197fd781c6fcbcfc21c6676592be57 --- Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/Ringtoets.Piping.Service.Test.csproj (.../Ringtoets.Piping.Service.Test.csproj) (revision 3c10891728420f1c0aa0071574bbfb149710c556) +++ Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/Ringtoets.Piping.Service.Test.csproj (.../Ringtoets.Piping.Service.Test.csproj) (revision c0a3ced404197fd781c6fcbcfc21c6676592be57) @@ -60,6 +60,7 @@ +