Index: Ringtoets/Demo/test/Ringtoets.Demo.Test/Commands/AddNewDemoDikeAssessmentSectionCommandTest.cs =================================================================== diff -u -r4f48ea35b4937263954973396e267934ca7bdb55 -r3479f17e22ed8f8f44470972f85f9478707af683 --- Ringtoets/Demo/test/Ringtoets.Demo.Test/Commands/AddNewDemoDikeAssessmentSectionCommandTest.cs (.../AddNewDemoDikeAssessmentSectionCommandTest.cs) (revision 4f48ea35b4937263954973396e267934ca7bdb55) +++ Ringtoets/Demo/test/Ringtoets.Demo.Test/Commands/AddNewDemoDikeAssessmentSectionCommandTest.cs (.../AddNewDemoDikeAssessmentSectionCommandTest.cs) (revision 3479f17e22ed8f8f44470972f85f9478707af683) @@ -10,7 +10,7 @@ using Ringtoets.Demo.Commands; using Ringtoets.Integration.Data; -using Ringtoets.Piping.Calculation.Piping; +using Ringtoets.Piping.Calculation; using Ringtoets.Piping.Data; using Ringtoets.Piping.Service; Fisheye: Tag 3479f17e22ed8f8f44470972f85f9478707af683 refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Calculation/Piping/PipingCalculation.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 3479f17e22ed8f8f44470972f85f9478707af683 refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Calculation/Piping/PipingCalculationException.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 3479f17e22ed8f8f44470972f85f9478707af683 refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Calculation/Piping/PipingCalculationInput.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 3479f17e22ed8f8f44470972f85f9478707af683 refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Calculation/Piping/PipingCalculationResult.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 3479f17e22ed8f8f44470972f85f9478707af683 refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Calculation/Piping/PipingProfileCreator.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 3479f17e22ed8f8f44470972f85f9478707af683 refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Calculation/Piping/PipingProfileCreatorException.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 3479f17e22ed8f8f44470972f85f9478707af683 refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Calculation/Piping/PipingSemiProbabilisticDesignValueFactory.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 3479f17e22ed8f8f44470972f85f9478707af683 refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Calculation/Piping/PipingSurfaceLineCreator.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/src/Ringtoets.Piping.Calculation/PipingCalculation.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Calculation/PipingCalculation.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Calculation/PipingCalculation.cs (revision 3479f17e22ed8f8f44470972f85f9478707af683) @@ -0,0 +1,259 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +using Deltares.WTIPiping; + +using Ringtoets.Piping.Calculation.Properties; + +namespace Ringtoets.Piping.Calculation +{ + /// + /// This class represents a combination of piping sub-calculations, which together can be used + /// to assess based on piping. + /// + public class PipingCalculation + { + private readonly PipingCalculationInput input; + + /// + /// Constructs a new . The is used to + /// obtain the parameters used in the different sub calculations. + /// + /// The containing all the values required + /// for performing a piping calculation. + public PipingCalculation(PipingCalculationInput input) + { + this.input = input; + } + + /// + /// Performs the actual sub calculations and returns a , which + /// contains the results of all sub calculations. + /// + /// A containing the results of the sub calculations. + /// Thrown when any of the invocations of the sub-calculations from the kernel throws an Exception. + public PipingCalculationResult Calculate() + { + var upliftResult = CalculateUplift(); + var heaveResult = CalculateHeave(); + var sellmeijerResult = CalculateSellmeijer(); + + return new PipingCalculationResult( + upliftResult.Zu, + upliftResult.FoSu, + heaveResult.Zh, + heaveResult.FoSh, + sellmeijerResult.Zp, + sellmeijerResult.FoSp + ); + } + + /// + /// Returns a list of validation messages. The validation messages are based on the values of the + /// which was provided to this and are determined by the Piping kernel. + /// + public List Validate() + { + List soilProfileValidationResults = ValidateSoilProfile(); + List surfaceLineValidationResults = ValidateSurfaceLine(); + List upliftCalculatorValidationResults = new List(); + if (soilProfileValidationResults.Count == 0 && surfaceLineValidationResults.Count == 0) + { + upliftCalculatorValidationResults = ValidateUpliftCalculator(); + } + List heaveCalculatorValidationResults = CreateHeaveCalculator().Validate(); + List sellmeijerCalculatorValidationResults = CreateSellmeijerCalculator().Validate(); + + return upliftCalculatorValidationResults + .Concat(surfaceLineValidationResults) + .Concat(soilProfileValidationResults) + .Concat(heaveCalculatorValidationResults) + .Concat(sellmeijerCalculatorValidationResults) + .ToList(); + } + + private List ValidateSurfaceLine() + { + var validationResults = new List(); + if (input.SurfaceLine == null) + { + validationResults.Add(Resources.PipingCalculation_Validate_Lacks_surfaceline_uplift); + } + else + { + try + { + PipingSurfaceLineCreator.Create(input.SurfaceLine).Validate(); + } + catch (PipingSurfaceLineException e) + { + validationResults.Add(e.Message); + } + } + return validationResults; + } + + private List ValidateSoilProfile() + { + var validationResults = new List(); + if (input.SoilProfile == null) + { + validationResults.Add(Resources.PipingCalculation_Validate_Lacks_SoilProfile_uplift); + } + else + { + try + { + PipingProfileCreator.Create(input.SoilProfile).Validate(); + } + catch (PipingProfileException e) + { + validationResults.Add(e.Message); + } + } + return validationResults; + } + + private List ValidateUpliftCalculator() + { + try + { + EffectiveThicknessCalculator effectiveThicknessCalculator = CalculateEffectiveThickness(); + return CreateUpliftCalculator(effectiveThicknessCalculator.EffectiveStress).Validate(); + } + catch (Exception exception) + { + return new List + { + exception.Message + }; + } + } + + private Sellmeijer2011Calculator CalculateSellmeijer() + { + Sellmeijer2011Calculator sellmeijerCalculator = CreateSellmeijerCalculator(); + + try + { + sellmeijerCalculator.Calculate(); + } + catch (PipingException e) + { + throw new PipingCalculationException(e.Message, e); + } + catch (PipingException e) + { + throw new PipingCalculationException(e.Message, e); + } + + return sellmeijerCalculator; + } + + private HeaveCalculator CalculateHeave() + { + var heaveCalculator = CreateHeaveCalculator(); + + try + { + heaveCalculator.Calculate(); + } + catch (PipingException e) + { + throw new PipingCalculationException(e.Message, e); + } + + return heaveCalculator; + } + + private WTIUpliftCalculator CalculateUplift() + { + EffectiveThicknessCalculator calculatedEffectiveStressResult = CalculateEffectiveThickness(); + WTIUpliftCalculator upliftCalculator = CreateUpliftCalculator(calculatedEffectiveStressResult.EffectiveStress); + + try + { + upliftCalculator.Calculate(); + } + catch (WTIUpliftCalculatorException e) + { + throw new PipingCalculationException(e.Message, e); + } + catch (PipingException e) + { + throw new PipingCalculationException(e.Message, e); + } + + return upliftCalculator; + } + + private HeaveCalculator CreateHeaveCalculator() + { + var calculator = new HeaveCalculator + { + Ich = input.CriticalHeaveGradient, + PhiExit = input.PiezometricHeadExit, + DTotal = input.ThicknessCoverageLayer, + PhiPolder = input.PiezometricHeadPolder, + RExit = input.DampingFactorExit, + HExit = input.PhreaticLevelExit + }; + return calculator; + } + + private WTIUpliftCalculator CreateUpliftCalculator(double effectiveStress) + { + var calculator = new WTIUpliftCalculator + { + VolumetricWeightOfWater = input.WaterVolumetricWeight, + ModelFactorUplift = input.UpliftModelFactor, + EffectiveStress = effectiveStress, + HRiver = input.AssessmentLevel, + PhiExit = input.PiezometricHeadExit, + RExit = input.DampingFactorExit, + HExit = input.PhreaticLevelExit, + PhiPolder = input.PiezometricHeadPolder + }; + return calculator; + } + + private Sellmeijer2011Calculator CreateSellmeijerCalculator() + { + var calculator = new Sellmeijer2011Calculator + { + ModelFactorPiping = input.SellmeijerModelFactor, + HRiver = input.AssessmentLevel, + HExit = input.PhreaticLevelExit, + Rc = input.SellmeijerReductionFactor, + DTotal = input.ThicknessCoverageLayer, + SeepageLength = input.SeepageLength, + GammaSubParticles = input.SandParticlesVolumicWeight, + WhitesDragCoefficient = input.WhitesDragCoefficient, + D70 = input.Diameter70, + VolumetricWeightOfWater = input.WaterVolumetricWeight, + DarcyPermeability = input.DarcyPermeability, + KinematicViscosityWater = input.WaterKinematicViscosity, + Gravity = input.Gravity, + DAquifer = input.ThicknessAquiferLayer, + D70Mean = input.MeanDiameter70, + BeddingAngle = input.BeddingAngle + }; + return calculator; + } + + private EffectiveThicknessCalculator CalculateEffectiveThickness() + { + var calculator = new EffectiveThicknessCalculator + { + ExitPointXCoordinate = input.ExitPointXCoordinate, + PhreaticLevel = input.PhreaticLevelExit, + SoilProfile = PipingProfileCreator.Create(input.SoilProfile), + SurfaceLine = PipingSurfaceLineCreator.Create(input.SurfaceLine), + VolumicWeightOfWater = input.WaterVolumetricWeight + }; + calculator.Calculate(); + return calculator; + } + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Calculation/PipingCalculationException.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Calculation/PipingCalculationException.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Calculation/PipingCalculationException.cs (revision 3479f17e22ed8f8f44470972f85f9478707af683) @@ -0,0 +1,35 @@ +using System; + +namespace Ringtoets.Piping.Calculation +{ + /// + /// Exception thrown when something went wrong in the + /// + public class PipingCalculationException : Exception + { + /// + /// Initializes a new instance of the class. + /// + public PipingCalculationException() + { + } + + /// + /// Initializes a new instance of the class + /// with a specified error message. + /// + /// The message that describes the error. + public PipingCalculationException(string message) : base (message) + { + } + + /// + /// Initializes a new instance of the System.Exception class with a specified error message + /// and a reference to the inner exception that is the cause of this exception. + /// + /// The error message that explains the reason for the exception. + /// The exception that is the cause of the current exception, or a + /// null reference if no inner exception is specified. + public PipingCalculationException(string message, Exception innerException) : base(message, innerException) {} + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Calculation/PipingCalculationInput.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Calculation/PipingCalculationInput.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Calculation/PipingCalculationInput.cs (revision 3479f17e22ed8f8f44470972f85f9478707af683) @@ -0,0 +1,375 @@ +using Ringtoets.Piping.Data; + +namespace Ringtoets.Piping.Calculation +{ + /// + /// This class contains all the parameters that are required to perform a piping assessment. + /// + public class PipingCalculationInput + { + 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 piezometricHeadPolder; + private readonly double criticalHeaveGradient; + private readonly double thicknessCoverageLayer; + private readonly double sellmeijerModelFactor; + private readonly double sellmeijerReductionFactor; + private readonly double seepageLength; + private readonly double sandParticlesVolumicWeight; + private readonly double whitesDragCoefficient; + private readonly double diameter70; + private readonly double darcyPermeability; + private readonly double waterKinematicViscosity; + private readonly double gravity; + private readonly double thicknessAquiferLayer; + private readonly double meanDiameter70; + private readonly double beddingAngle; + private readonly double exitPointXCoordinate; + private readonly RingtoetsPipingSurfaceLine surfaceLine; + private readonly PipingSoilProfile soilProfile; + + /// + /// Constructs a new , which contains values for the parameters used + /// in the piping sub calculations. + /// + /// The volumetric weight of water. [kN/m³] + /// 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. + /// The reduction factor Sellmeijer. + /// The horizontal distance between entree and exit point. [m] + /// The (lowerbound) volumic weight of sand grain material of a sand layer under water. [kN/m³] + /// The White's drag coefficient. + /// The sieve size through which 70% fraction of the grains of the top part of the aquifer passes. [m] + /// The Darcy-speed with which water flows through the aquifer layer. [m/s] + /// The kinematic viscosity of water at 10 degrees Celsius. [m²/s] + /// The gravitational acceleration. [m/s²] + /// The thickness of the aquifer layer. [m] + /// The mean diameter of small scale tests applied to different kinds of sand, on which the formula of Sellmeijer has been fit. [m] + /// The angle of the force balance representing the amount in which sand grains resist rolling. [°] + /// 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 PipingCalculationInput(double waterVolumetricWeight, double upliftModelFactor, double assessmentLevel, double piezometricHeadExit, double dampingFactorExit, double phreaticLevelExit, double piezometricHeadPolder, 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.upliftModelFactor = upliftModelFactor; + this.assessmentLevel = assessmentLevel; + this.piezometricHeadExit = piezometricHeadExit; + this.dampingFactorExit = dampingFactorExit; + this.phreaticLevelExit = phreaticLevelExit; + this.piezometricHeadPolder = piezometricHeadPolder; + this.criticalHeaveGradient = criticalHeaveGradient; + this.thicknessCoverageLayer = thicknessCoverageLayer; + this.sellmeijerModelFactor = sellmeijerModelFactor; + this.sellmeijerReductionFactor = sellmeijerReductionFactor; + this.seepageLength = seepageLength; + this.sandParticlesVolumicWeight = sandParticlesVolumicWeight; + this.whitesDragCoefficient = whitesDragCoefficient; + this.diameter70 = diameter70; + this.darcyPermeability = darcyPermeability; + this.waterKinematicViscosity = waterKinematicViscosity; + this.gravity = gravity; + this.thicknessAquiferLayer = thicknessAquiferLayer; + this.meanDiameter70 = meanDiameter70; + this.beddingAngle = beddingAngle; + this.exitPointXCoordinate = exitPointXCoordinate; + this.surfaceLine = surfaceLine; + this.soilProfile = soilProfile; + } + + #region properties + + /// + /// Gets the volumetric weight of water. + /// [kN/m³] + /// + public double WaterVolumetricWeight + { + get + { + return waterVolumetricWeight; + } + } + + /// + /// Gets the calculation value used to account for uncertainty in the model for uplift. + /// + public double UpliftModelFactor + { + get + { + return upliftModelFactor; + } + } + + /// + /// Gets the outside high water level. + /// [m] + /// + public double AssessmentLevel + { + get + { + return assessmentLevel; + } + } + + /// + /// 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 + { + get + { + return dampingFactorExit; + } + } + + /// + /// Gets the phreatic level at the exit point. + /// [m] + /// + public double PhreaticLevelExit + { + get + { + return phreaticLevelExit; + } + } + + /// + /// Gets the piezometric head in the hinterland. + /// [m] + /// + public double PiezometricHeadPolder + { + get + { + return piezometricHeadPolder; + } + } + + /// + /// Gets the critical exit gradient for heave. + /// + public double CriticalHeaveGradient + { + get + { + return criticalHeaveGradient; + } + } + + /// + /// Gets the total thickness of the coverage layer at the exit point. + /// [m] + /// + public double ThicknessCoverageLayer + { + get + { + return thicknessCoverageLayer; + } + } + + /// + /// Gets the calculation value used to account for uncertainty in the model for Sellmeijer. + /// + public double SellmeijerModelFactor + { + get + { + return sellmeijerModelFactor; + } + } + + /// + /// Gets the reduction factor Sellmeijer. + /// + public double SellmeijerReductionFactor + { + get + { + return sellmeijerReductionFactor; + } + } + + /// + /// Gets the horizontal distance between entree and exit point. + /// [m] + /// + public double SeepageLength + { + get + { + return seepageLength; + } + } + + /// + /// Gets the (lowerbound) volumic weight of sand grain material of a sand layer under water. + /// [kN/m³] + /// + public double SandParticlesVolumicWeight + { + get + { + return sandParticlesVolumicWeight; + } + } + + /// + /// Gets the White's drag coefficient. + /// + public double WhitesDragCoefficient + { + get + { + return whitesDragCoefficient; + } + } + + /// + /// Gets the sieve size through which 70% fraction of the grains of the top part of the aquifer passes. + /// [m] + /// + public double Diameter70 + { + get + { + return diameter70; + } + } + + /// + /// Gets the Darcy-speed with which water flows through the aquifer layer. + /// [m/s] + /// + public double DarcyPermeability + { + get + { + return darcyPermeability; + } + } + + /// + /// Gets the kinematic viscosity of water at 10 degrees Celsius. + /// [m²/s] + /// + public double WaterKinematicViscosity + { + get + { + return waterKinematicViscosity; + } + } + + /// + /// Gets the gravitational acceleration. + /// [m/s²] + /// + public double Gravity + { + get + { + return gravity; + } + } + + /// + /// Gets the thickness of the aquifer layer. + /// [m] + /// + public double ThicknessAquiferLayer + { + get + { + return thicknessAquiferLayer; + } + } + + /// + /// Gets the mean diameter of small scale tests applied to different kinds of sand, on which the formula of Sellmeijer has been fit. + /// [m] + /// + public double MeanDiameter70 + { + get + { + return meanDiameter70; + } + } + + /// + /// Gets the angle of the force balance representing the amount in which sand grains resist rolling. + /// [°] + /// + public double BeddingAngle + { + get + { + return beddingAngle; + } + } + + /// + /// Gets the x coordinate of the exit point. + /// [m] + /// + public double ExitPointXCoordinate + { + get + { + return exitPointXCoordinate; + } + } + + /// + /// Gets the surface line. + /// + public RingtoetsPipingSurfaceLine SurfaceLine + { + get + { + return surfaceLine; + } + } + + /// + /// Gets the profile which contains a 1 dimensional definition of soil layers with properties. + /// + public PipingSoilProfile SoilProfile + { + get + { + return soilProfile; + } + } + + #endregion + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Calculation/PipingCalculationResult.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Calculation/PipingCalculationResult.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Calculation/PipingCalculationResult.cs (revision 3479f17e22ed8f8f44470972f85f9478707af683) @@ -0,0 +1,104 @@ +namespace Ringtoets.Piping.Calculation +{ + /// + /// This class contains all the results of a complete piping calculation. + /// + public class PipingCalculationResult + { + private readonly double upliftZValue; + private readonly double upliftFactorOfSafety; + private readonly double heaveZValue; + private readonly double heaveFactorOfSafety; + private readonly double sellmeijerZValue; + private readonly double sellmeijerFactorOfSafety; + + /// + /// Constructs a new . The result will hold all the values which were given. + /// + /// The z-value of the Uplift sub calculation. + /// The factory of safety of the Uplift sub calculation. + /// The z-value of the Heave sub calculation. + /// The factory of safety of the Heave sub calculation. + /// The z-value of the Sellmeijer sub calculation. + /// The factory of safety of the Sellmeijer sub calculation. + public PipingCalculationResult(double upliftZValue, double upliftFactorOfSafety, double heaveZValue, double heaveFactorOfSafety, double sellmeijerZValue, double sellmeijerFactorOfSafety) + { + this.upliftZValue = upliftZValue; + this.upliftFactorOfSafety = upliftFactorOfSafety; + this.heaveZValue = heaveZValue; + this.heaveFactorOfSafety = heaveFactorOfSafety; + this.sellmeijerZValue = sellmeijerZValue; + this.sellmeijerFactorOfSafety = sellmeijerFactorOfSafety; + } + + #region properties + + /// + /// Gets the z-value of the Uplift sub calculation. + /// + public double UpliftZValue + { + get + { + return upliftZValue; + } + } + + /// + /// Gets the factory of safety of the Uplift sub calculation. + /// + public double UpliftFactorOfSafety + { + get + { + return upliftFactorOfSafety; + } + } + + /// + /// Gets the z-value of the Heave sub calculation. + /// + public double HeaveZValue + { + get + { + return heaveZValue; + } + } + + /// + /// Gets the factory of safety of the Heave sub calculation. + /// + public double HeaveFactorOfSafety + { + get + { + return heaveFactorOfSafety; + } + } + + /// + /// Gets the z-value of the Sellmeijer sub calculation. + /// + public double SellmeijerZValue + { + get + { + return sellmeijerZValue; + } + } + + /// + /// Gets the factory of safety of the Sellmeijer sub calculation. + /// + public double SellmeijerFactorOfSafety + { + get + { + return sellmeijerFactorOfSafety; + } + } + + #endregion + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Calculation/PipingProfileCreator.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Calculation/PipingProfileCreator.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Calculation/PipingProfileCreator.cs (revision 3479f17e22ed8f8f44470972f85f9478707af683) @@ -0,0 +1,49 @@ +using Deltares.WTIPiping; + +using Ringtoets.Piping.Data; + +namespace Ringtoets.Piping.Calculation +{ + /// + /// Creates instances which are required by the . + /// + internal static class PipingProfileCreator + { + /// + /// Creates a based on information contained in the provided , + /// which can then be used in the . + /// + /// The from which to take the information. + /// A new with information taken from the . + public static PipingProfile Create(PipingSoilProfile soilProfile) + { + var profile = new PipingProfile + { + BottomLevel = soilProfile.Bottom + }; + foreach (PipingSoilLayer layer in soilProfile.Layers) + { + var pipingLayer = new PipingLayer + { + TopLevel = layer.Top, + IsAquifer = layer.IsAquifer + }; + if (layer.AbovePhreaticLevel.HasValue) + { + pipingLayer.AbovePhreaticLevel = layer.AbovePhreaticLevel.Value; + } + if(layer.BelowPhreaticLevel.HasValue) + { + pipingLayer.BelowPhreaticLevel = layer.BelowPhreaticLevel.Value; + } + if(layer.DryUnitWeight.HasValue) + { + pipingLayer.DryUnitWeight = layer.DryUnitWeight.Value; + } + profile.Layers.Add(pipingLayer); + } + + return profile; + } + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Calculation/PipingProfileCreatorException.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Calculation/PipingProfileCreatorException.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Calculation/PipingProfileCreatorException.cs (revision 3479f17e22ed8f8f44470972f85f9478707af683) @@ -0,0 +1,36 @@ +using System; + +namespace Ringtoets.Piping.Calculation +{ + /// + /// Exception thrown when something went wrong in the + /// + public class PipingProfileCreatorException : Exception + { + /// + /// Initializes a new instance of the class. + /// + public PipingProfileCreatorException() + { + } + + /// + /// Initializes a new instance of the class + /// with a specified error message. + /// + /// The message that describes the error. + public PipingProfileCreatorException(string message) + : base(message) + { + } + + /// + /// Initializes a new instance of the class with + /// a specified error message and a reference to the inner exception that is the cause of this exception. + /// + /// The error message that explains the reason for the exception. + /// The exception that is the cause of the current exception, or a + /// null reference if no inner exception is specified. + public PipingProfileCreatorException(string message, Exception innerException) : base(message, innerException) { } + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Calculation/PipingSemiProbabilisticDesignValueFactory.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Calculation/PipingSemiProbabilisticDesignValueFactory.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Calculation/PipingSemiProbabilisticDesignValueFactory.cs (revision 3479f17e22ed8f8f44470972f85f9478707af683) @@ -0,0 +1,91 @@ +using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.Probabilistics; + +namespace Ringtoets.Piping.Calculation +{ + /// + /// Factory for creating design variables based on probabilistic distributions. + /// + public static class PipingSemiProbabilisticDesignValueFactory + { + #region General parameters + + /// + /// Creates the design variable for . + /// + public static DesignVariable GetThicknessCoverageLayer(PipingInputParameters parameters) + { + return CreateDesignVariable(parameters.ThicknessCoverageLayer, 0.05); + } + + /// + /// Creates the design variable for . + /// + public static DesignVariable GetPhreaticLevelExit(PipingInputParameters parameters) + { + return CreateDesignVariable(parameters.PhreaticLevelExit, 0.05); + } + + /// + /// Creates the design variable for . + /// + public static DesignVariable GetDampingFactorExit(PipingInputParameters parameters) + { + return CreateDesignVariable(parameters.DampingFactorExit, 0.95); + } + + #endregion + + #region Piping parameters + + /// + /// Creates the design variable for . + /// + public static DesignVariable GetSeepageLength(PipingInputParameters parameters) + { + return CreateDesignVariable(parameters.SeepageLength, 0.05); + } + + /// + /// Creates the design variable for . + /// + public static DesignVariable GetDiameter70(PipingInputParameters parameters) + { + return CreateDesignVariable(parameters.Diameter70, 0.05); + } + + /// + /// Creates the design variable for . + /// + public static DesignVariable GetDarcyPermeability(PipingInputParameters parameters) + { + return CreateDesignVariable(parameters.DarcyPermeability, 0.95); + } + + /// + /// Creates the design variable for . + /// + public static DesignVariable GetThicknessAquiferLayer(PipingInputParameters parameters) + { + return CreateDesignVariable(parameters.ThicknessAquiferLayer, 0.95); + } + + #endregion + + private static DesignVariable CreateDesignVariable(NormalDistribution distribution, double percentile) + { + return new NormalDistributionDesignVariable(distribution) + { + Percentile = percentile + }; + } + + private static DesignVariable CreateDesignVariable(LognormalDistribution distribution, double percentile) + { + return new LognormalDistributionDesignVariable(distribution) + { + Percentile = percentile + }; + } + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Calculation/PipingSurfaceLineCreator.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Calculation/PipingSurfaceLineCreator.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Calculation/PipingSurfaceLineCreator.cs (revision 3479f17e22ed8f8f44470972f85f9478707af683) @@ -0,0 +1,40 @@ +using System.Collections.Generic; +using System.Linq; + +using Deltares.WTIPiping; + +using Ringtoets.Piping.Data; + +namespace Ringtoets.Piping.Calculation +{ + /// + /// Creates instances which are required by the . + /// + internal static class PipingSurfaceLineCreator + { + /// + /// Creates a for the kernel + /// given different surface line. + /// + /// The surface line configured in the Ringtoets application. + /// The surface line to be consumed by the kernel. + public static PipingSurfaceLine Create(RingtoetsPipingSurfaceLine line) + { + var surfaceLine = new PipingSurfaceLine + { + Name = line.Name + }; + if (line.Points.Any()) + { + surfaceLine.Points.AddRange(CreatePoints(line)); + } + + return surfaceLine; + } + + private static IEnumerable CreatePoints(RingtoetsPipingSurfaceLine line) + { + return line.ProjectGeometryToLZ().Select(p => new PipingPoint(p.X, 0.0, p.Y)); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Calculation/Ringtoets.Piping.Calculation.csproj =================================================================== diff -u -rfcf04bfe765cc56c90a010b4b4790cab0ac5b2c6 -r3479f17e22ed8f8f44470972f85f9478707af683 --- Ringtoets/Piping/src/Ringtoets.Piping.Calculation/Ringtoets.Piping.Calculation.csproj (.../Ringtoets.Piping.Calculation.csproj) (revision fcf04bfe765cc56c90a010b4b4790cab0ac5b2c6) +++ Ringtoets/Piping/src/Ringtoets.Piping.Calculation/Ringtoets.Piping.Calculation.csproj (.../Ringtoets.Piping.Calculation.csproj) (revision 3479f17e22ed8f8f44470972f85f9478707af683) @@ -57,14 +57,14 @@ Properties\GlobalAssembly.cs - - - - - - - - + + + + + + + + True Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingInputParametersContextProperties.cs =================================================================== diff -u -rb214a6d9050c59707de8e8e5c9aec3e3800fb4a0 -r3479f17e22ed8f8f44470972f85f9478707af683 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingInputParametersContextProperties.cs (.../PipingInputParametersContextProperties.cs) (revision b214a6d9050c59707de8e8e5c9aec3e3800fb4a0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingInputParametersContextProperties.cs (.../PipingInputParametersContextProperties.cs) (revision 3479f17e22ed8f8f44470972f85f9478707af683) @@ -5,7 +5,7 @@ using Core.Common.Gui; using Core.Common.Utils; -using Ringtoets.Piping.Calculation.Piping; +using Ringtoets.Piping.Calculation; using Ringtoets.Piping.Data; using Ringtoets.Piping.Data.Probabilistics; using Ringtoets.Piping.Forms.PresentationObjects; Index: Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingCalculationService.cs =================================================================== diff -u -r4f48ea35b4937263954973396e267934ca7bdb55 -r3479f17e22ed8f8f44470972f85f9478707af683 --- Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingCalculationService.cs (.../PipingCalculationService.cs) (revision 4f48ea35b4937263954973396e267934ca7bdb55) +++ Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingCalculationService.cs (.../PipingCalculationService.cs) (revision 3479f17e22ed8f8f44470972f85f9478707af683) @@ -2,7 +2,7 @@ using log4net; -using Ringtoets.Piping.Calculation.Piping; +using Ringtoets.Piping.Calculation; using Ringtoets.Piping.Data; using Ringtoets.Piping.Service.Properties; Fisheye: Tag 3479f17e22ed8f8f44470972f85f9478707af683 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/Piping/PipingCalculationExceptionTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 3479f17e22ed8f8f44470972f85f9478707af683 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/Piping/PipingCalculationInputTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 3479f17e22ed8f8f44470972f85f9478707af683 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/Piping/PipingCalculationResultTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 3479f17e22ed8f8f44470972f85f9478707af683 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/Piping/PipingCalculationTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 3479f17e22ed8f8f44470972f85f9478707af683 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/Piping/PipingProfileCreatorExceptionTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 3479f17e22ed8f8f44470972f85f9478707af683 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/Piping/PipingProfileCreatorTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 3479f17e22ed8f8f44470972f85f9478707af683 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/Piping/PipingSemiProbabilisticDesignValueFactoryTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 3479f17e22ed8f8f44470972f85f9478707af683 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/Piping/PipingSurfaceLineCreatorTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/PipingCalculationExceptionTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/PipingCalculationExceptionTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/PipingCalculationExceptionTest.cs (revision 3479f17e22ed8f8f44470972f85f9478707af683) @@ -0,0 +1,52 @@ +using System; + +using NUnit.Framework; + +namespace Ringtoets.Piping.Calculation.Test +{ + public class PipingCalculationExceptionTest + { + [Test] + public void DefaultConstructor_InnerExceptionNullAndMessageDefault() + { + // Setup + var expectedMessage = String.Format("Exception of type '{0}' was thrown.", typeof(PipingCalculationException).FullName); + + // Call + var exception = new PipingCalculationException(); + + // Assert + Assert.IsNull(exception.InnerException); + Assert.AreEqual(expectedMessage, exception.Message); + } + + [Test] + public void Constructor_WithCustomMessage_InnerExceptionNullAndMessageSetToCustom() + { + // Setup + var expectedMessage ="Some exception message"; + + // Call + var exception = new PipingCalculationException(expectedMessage); + + // Assert + Assert.IsNull(exception.InnerException); + Assert.AreEqual(expectedMessage, exception.Message); + } + + [Test] + public void Constructor_WithCustomMessageAndInnerException_InnerExceptionSetAndMessageSetToCustom() + { + // Setup + var expectedMessage = "Some exception message"; + var expectedInnerException = new Exception(); + + // Call + var exception = new PipingCalculationException(expectedMessage, expectedInnerException); + + // Assert + Assert.AreSame(expectedInnerException, exception.InnerException); + Assert.AreEqual(expectedMessage, exception.Message); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/PipingCalculationInputTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/PipingCalculationInputTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/PipingCalculationInputTest.cs (revision 3479f17e22ed8f8f44470972f85f9478707af683) @@ -0,0 +1,99 @@ +using System; + +using NUnit.Framework; + +using Ringtoets.Piping.Data; + +namespace Ringtoets.Piping.Calculation.Test +{ + public class PipingCalculationInputTest + { + [Test] + public void GivenSomeRandomValues_WhenPipingCalculationInputConstructedFromInput_ThenPropertiesAreSet() + { + var random = new Random(22); + + double volumetricWeightOfWaterValue = random.NextDouble(); + double modelFactorUpliftValue = random.NextDouble(); + double hRiverValue = random.NextDouble(); + double phiExitValue = random.NextDouble(); + double rExitValue = random.NextDouble(); + double hExitValue = random.NextDouble(); + double phiPolderValue = random.NextDouble(); + double ichValue = random.NextDouble(); + double dTotalValue = random.NextDouble(); + double sellmeijerModelFactorValue = random.NextDouble(); + double reductionFactorValue = random.NextDouble(); + double seepageLengthValue = random.NextDouble(); + double sandParticlesVolumicWeightValue = random.NextDouble(); + double whitesDragCoefficientValue = random.NextDouble(); + double diameter70Value = random.NextDouble(); + double darcyPermeabilityValue = random.NextDouble(); + double waterKinematicViscosityValue = random.NextDouble(); + double gravityValue = random.NextDouble(); + double thicknessAquiferLayerValue = random.NextDouble(); + double meanDiameter70Value = random.NextDouble(); + double beddingAngleValue = random.NextDouble(); + double exitPointXCoordinate = random.NextDouble(); + var surfaceLine = new RingtoetsPipingSurfaceLine(); + var soilProfile = new PipingSoilProfile(string.Empty, random.NextDouble(), new [] + { + new PipingSoilLayer(random.NextDouble()) + { + IsAquifer = true + } + }); + + var input = new PipingCalculationInput( + volumetricWeightOfWaterValue, + modelFactorUpliftValue, + hRiverValue, + phiExitValue, + rExitValue, + hExitValue, + phiPolderValue, + ichValue, + dTotalValue, + sellmeijerModelFactorValue, + reductionFactorValue, + seepageLengthValue, + sandParticlesVolumicWeightValue, + whitesDragCoefficientValue, + diameter70Value, + darcyPermeabilityValue, + waterKinematicViscosityValue, + gravityValue, + thicknessAquiferLayerValue, + meanDiameter70Value, + beddingAngleValue, + exitPointXCoordinate, + surfaceLine, + soilProfile); + + Assert.AreEqual(volumetricWeightOfWaterValue, input.WaterVolumetricWeight); + Assert.AreEqual(modelFactorUpliftValue, input.UpliftModelFactor); + Assert.AreEqual(hRiverValue, input.AssessmentLevel); + Assert.AreEqual(phiExitValue, input.PiezometricHeadExit); + Assert.AreEqual(rExitValue, input.DampingFactorExit); + Assert.AreEqual(hExitValue, input.PhreaticLevelExit); + Assert.AreEqual(phiPolderValue, input.PiezometricHeadPolder); + Assert.AreEqual(ichValue, input.CriticalHeaveGradient); + Assert.AreEqual(dTotalValue, input.ThicknessCoverageLayer); + Assert.AreEqual(sellmeijerModelFactorValue, input.SellmeijerModelFactor); + Assert.AreEqual(reductionFactorValue, input.SellmeijerReductionFactor); + Assert.AreEqual(seepageLengthValue, input.SeepageLength); + Assert.AreEqual(sandParticlesVolumicWeightValue, input.SandParticlesVolumicWeight); + Assert.AreEqual(whitesDragCoefficientValue, input.WhitesDragCoefficient); + Assert.AreEqual(diameter70Value, input.Diameter70); + Assert.AreEqual(darcyPermeabilityValue, input.DarcyPermeability); + Assert.AreEqual(waterKinematicViscosityValue, input.WaterKinematicViscosity); + Assert.AreEqual(gravityValue, input.Gravity); + Assert.AreEqual(thicknessAquiferLayerValue, input.ThicknessAquiferLayer); + Assert.AreEqual(meanDiameter70Value, input.MeanDiameter70); + Assert.AreEqual(beddingAngleValue, input.BeddingAngle); + Assert.AreEqual(exitPointXCoordinate, input.ExitPointXCoordinate); + Assert.AreSame(surfaceLine, input.SurfaceLine); + Assert.AreSame(soilProfile, input.SoilProfile); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/PipingCalculationResultTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/PipingCalculationResultTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/PipingCalculationResultTest.cs (revision 3479f17e22ed8f8f44470972f85f9478707af683) @@ -0,0 +1,30 @@ +using System; + +using NUnit.Framework; + +namespace Ringtoets.Piping.Calculation.Test +{ + public class PipingCalculationResultTest + { + [Test] + public void GivenSomeValues_WhenConstructedWithValues_ThenPropertiesAreSet() + { + var random = new Random(22); + var zuValue = random.NextDouble(); + var foSuValue = random.NextDouble(); + var zhValue = random.NextDouble(); + var foShValue = random.NextDouble(); + var zsValue = random.NextDouble(); + var foSsValue = random.NextDouble(); + + var actual = new PipingCalculationResult(zuValue, foSuValue, zhValue, foShValue, zsValue, foSsValue); + + Assert.That(actual.UpliftZValue, Is.EqualTo(zuValue)); + Assert.That(actual.UpliftFactorOfSafety, Is.EqualTo(foSuValue)); + Assert.That(actual.HeaveZValue, Is.EqualTo(zhValue)); + Assert.That(actual.HeaveFactorOfSafety, Is.EqualTo(foShValue)); + Assert.That(actual.SellmeijerZValue, Is.EqualTo(zsValue)); + Assert.That(actual.SellmeijerFactorOfSafety, Is.EqualTo(foSsValue)); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/PipingCalculationTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/PipingCalculationTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/PipingCalculationTest.cs (revision 3479f17e22ed8f8f44470972f85f9478707af683) @@ -0,0 +1,346 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +using NUnit.Framework; + +using Ringtoets.Piping.Calculation.TestUtil; +using Ringtoets.Piping.Data; + +namespace Ringtoets.Piping.Calculation.Test +{ + [TestFixture] + public class PipingCalculationTest + { + [Test] + public void Calculate_CompleteValidInput_ReturnsResultWithNoNaN() + { + PipingCalculationInput input = new TestPipingInput().AsRealInput(); + + PipingCalculationResult actual = new PipingCalculation(input).Calculate(); + + Assert.IsNotNull(actual); + Assert.IsFalse(double.IsNaN(actual.UpliftZValue)); + Assert.IsFalse(double.IsNaN(actual.UpliftFactorOfSafety)); + Assert.IsFalse(double.IsNaN(actual.HeaveZValue)); + Assert.IsFalse(double.IsNaN(actual.HeaveFactorOfSafety)); + Assert.IsFalse(double.IsNaN(actual.SellmeijerZValue)); + Assert.IsFalse(double.IsNaN(actual.SellmeijerFactorOfSafety)); + } + + [Test] + public void Validate_CompleteValidInput_ReturnsNoValidationMessages() + { + // Setup + PipingCalculationInput input = new TestPipingInput().AsRealInput(); + var calculation = new PipingCalculation(input); + + // Call + List validationMessages = calculation.Validate(); + + // Assert + Assert.AreEqual(0, validationMessages.Count); + } + + [Test] + [TestCase(0)] + [TestCase(-1e-6)] + [TestCase(-100)] + public void Validate_ZeroOrNegativeSeepageLength_ValidationMessageForPipingLength(double seepageLength) + { + // Setup + PipingCalculationInput input = new TestPipingInput + { + SeepageLength = seepageLength + }.AsRealInput(); + + var calculation = new PipingCalculation(input); + + // Call + List validationMessages = calculation.Validate(); + + // Assert + Assert.AreEqual(1, validationMessages.Count); + Assert.IsTrue(validationMessages.Any(message => message.Contains("Piping length"))); + } + + [Test] + [TestCase(0)] + [TestCase(-1e-6)] + [TestCase(-100)] + public void Validate_ZeroOrNegativeAquiferThickness_ValidationMessageForDAquifer(double aquiferThickness) + { + // Setup + PipingCalculationInput input = new TestPipingInput + { + ThicknessAquiferLayer = aquiferThickness + }.AsRealInput(); + + var calculation = new PipingCalculation(input); + + // Call + List validationMessages = calculation.Validate(); + + // Assert + Assert.AreEqual(1, validationMessages.Count); + Assert.IsTrue(validationMessages.Any(message => message.Contains("DAquifer"))); + } + + [Test] + [TestCase(-1e-6)] + [TestCase(-100)] + public void Validate_NegativeBeddingAngle_ValidationMessageForBeddingAngle(double beddingAngle) + { + // Setup + PipingCalculationInput input = new TestPipingInput + { + BeddingAngle = beddingAngle + }.AsRealInput(); + + var calculation = new PipingCalculation(input); + + // Call + List validationMessages = calculation.Validate(); + + // Assert + Assert.AreEqual(1, validationMessages.Count); + Assert.IsTrue(validationMessages.Any(message => message.Contains("Bedding angle"))); + } + + [Test] + [TestCase(-1e-6)] + [TestCase(-100)] + public void Validate_PiezometricHeadExitSameAsPhreaticLevelExit_ValidationMessageForPhiExitAndHExit(double level) + { + // Setup + PipingCalculationInput input = new TestPipingInput + { + PiezometricHeadExit = level, + PhreaticLevelExit = level + }.AsRealInput(); + + var calculation = new PipingCalculation(input); + + // Call + List validationMessages = calculation.Validate(); + + // Assert + Assert.AreEqual(2, validationMessages.Count); + Assert.IsTrue(validationMessages.Any(message => message.Contains("PhiExit - HExit"))); + Assert.IsTrue(validationMessages.Any(message => message.Contains("phiExit - hExit"))); + } + + [Test] + public void Validate_PhreaticLevelExitZero_TwoValidationMessageForRExit() + { + // Setup + PipingCalculationInput input = new TestPipingInput + { + DampingFactorExit = 0 + }.AsRealInput(); + + var calculation = new PipingCalculation(input); + + // Call + List validationMessages = calculation.Validate(); + + // Assert + Assert.AreEqual(2, validationMessages.Count); + Assert.AreEqual(2, validationMessages.Count(message => message.Contains("Rexit"))); + } + + [Test] + public void Validate_ThicknessCoverageLayerZero_ValidationMessageForDTotal() + { + // Setup + PipingCalculationInput input = new TestPipingInput + { + ThicknessCoverageLayer = 0 + }.AsRealInput(); + + var calculation = new PipingCalculation(input); + + // Call + List validationMessages = calculation.Validate(); + + // Assert + Assert.AreEqual(1, validationMessages.Count); + Assert.IsTrue(validationMessages.Any(message => message.Contains("Dtotal"))); + } + + [Test] + public void Validate_ThicknessAquiferLayerZero_ValidationMessageForDAquifer() + { + // Setup + PipingCalculationInput input = new TestPipingInput + { + ThicknessAquiferLayer = 0 + }.AsRealInput(); + + var calculation = new PipingCalculation(input); + + // Call + List validationMessages = calculation.Validate(); + + // Assert + Assert.AreEqual(1, validationMessages.Count); + Assert.IsTrue(validationMessages.Any(message => message.Contains("DAquifer"))); + } + + [Test] + public void Validate_VolumetricWeightWaterZero_ValidationMessageForVolumetricWeightWater() + { + // Setup + PipingCalculationInput input = new TestPipingInput + { + WaterVolumetricWeight = 0 + }.AsRealInput(); + + var calculation = new PipingCalculation(input); + + // Call + List validationMessages = calculation.Validate(); + + // Assert + Assert.AreEqual(1, validationMessages.Count); + Assert.IsTrue(validationMessages.Any(message => message.Contains("Volumetric weight water"))); + } + + [Test] // Validate_DifferenceAssessmentLevelAndPhreaticLevelExitEqualToSellmeijerReductionFactorTimesThicknessCoverageLayer_ValidationMessageForHRiverHExitRcDTotal + [TestCase(2, 1, 2, 0.5, TestName = "AssessmntLvlPhreaticLevelExitEqualsSellmeijerReductionFactorTimesThicknessCoverageLayer_ValidateMsgHRiverHExitRcDTotal(2,1,2,0.5)")] + [TestCase(1, 1, 0, 2, TestName = "AssessmntLvlPhreaticLevelExitEqualsSellmeijerReductionFactorTimesThicknessCoverageLayer_ValidateMsgHRiverHExitRcDTotal(1,1,0,2)")] + [TestCase(8, 4, 2, 2, TestName = "AssessmntLvlPhreaticLevelExitEqualsSellmeijerReductionFactorTimesThicknessCoverageLayer_ValidateMsgHRiverHExitRcDTotal(8,4,2,2)")] + public void Validate_DifferenceAssessmentLevelAndPhreaticLevelExitEqualToSellmeijerReductionFactorTimesThicknessCoverageLayer_ValidationMessageForHRiverHExitRcDTotal( + double assessmentLevel, double phreaticLevelExit, double sellmeijerReductionFactor, double thicknessCoverageLayer) + { + // Setup + PipingCalculationInput input = new TestPipingInput + { + AssessmentLevel = assessmentLevel, + PhreaticLevelExit = phreaticLevelExit, + SellmeijerReductionFactor = sellmeijerReductionFactor, + ThicknessCoverageLayer = thicknessCoverageLayer + }.AsRealInput(); + + var calculation = new PipingCalculation(input); + + // Call + List validationMessages = calculation.Validate(); + + // Assert + Assert.AreEqual(1, validationMessages.Count); + Assert.IsTrue(validationMessages.Any(message => message.Contains("HRiver - HExit - (Rc*DTotal)"))); + } + + [Test] + public void Validate_NoSurfaceLineSet_ValidationMessageForHavingNoSurfaceLineSelected() + { + // Setup + PipingCalculationInput input = new TestPipingInput + { + SurfaceLine = null, + }.AsRealInput(); + + var calculation = new PipingCalculation(input); + + // Call + List validationMessages = calculation.Validate(); + + // Assert + Assert.AreEqual(1, validationMessages.Count); + Assert.AreEqual("Een dwarsdoorsnede moet geselecteerd zijn om een Uplift berekening uit te kunnen voeren.", validationMessages[0]); + } + + [Test] + public void Validate_NoSoilProfileSet_ValidationMessageForHavingNoSoilProfileSelected() + { + // Setup + PipingCalculationInput input = new TestPipingInput + { + SoilProfile = null, + }.AsRealInput(); + + var calculation = new PipingCalculation(input); + + // Call + List validationMessages = calculation.Validate(); + + // Assert + Assert.AreEqual(1, validationMessages.Count); + Assert.AreEqual("Een ondergrondprofiel moet geselecteerd zijn om een Uplift berekening uit te kunnen voeren.", validationMessages[0]); + } + + [Test] + public void Validate_SoilProfileWithoutAquiferSet_ValidationWithDefaultNullReferenceMessage() + { + // Setup + PipingCalculationInput input = new TestPipingInput + { + SoilProfile = new PipingSoilProfile(String.Empty, -1.0,new [] + { + new PipingSoilLayer(0) + }) + }.AsRealInput(); + + var calculation = new PipingCalculation(input); + + // Call + List validationMessages = calculation.Validate(); + + // Assert + Assert.AreEqual(1, validationMessages.Count); + var nullReferenceException = new NullReferenceException(); + Assert.IsTrue(validationMessages.Any(vm => vm.Contains(nullReferenceException.Message))); + } + + [Test] + [TestCase(-1e-8)] + [TestCase(0)] + public void Validate_SoilProfileBottomAtTopLevel_ValidationMessageForHavingTooHighBottom(double bottom) + { + // Setup + var top = 0; + PipingCalculationInput input = new TestPipingInput + { + SoilProfile = new PipingSoilProfile(String.Empty, bottom, new[] + { + new PipingSoilLayer(top) + }) + }.AsRealInput(); + + var calculation = new PipingCalculation(input); + + // Call + List validationMessages = calculation.Validate(); + + // Assert + var message = string.Format("The bottomlevel ({0}) of the profile is not deep enough. It must be below at least {1} m below the toplevel of the deepest layer ({2}).", bottom, 0.001, top); + Assert.AreEqual(1, validationMessages.Count); + Assert.IsTrue(validationMessages.Any(vm => vm.Contains(message))); + } + + [Test] + public void Validate_AssessmentLevelPhreaticLevelExitSellmeijerReductionFactorThicknessCoverageLayerZero_ValidationMessageForHRiverHExitRcDTotalAndDTotal() + { + // Setup + PipingCalculationInput input = new TestPipingInput + { + AssessmentLevel = 0, + PhreaticLevelExit = 0, + SellmeijerReductionFactor = 0, + ThicknessCoverageLayer = 0 + }.AsRealInput(); + + var calculation = new PipingCalculation(input); + + // Call + List validationMessages = calculation.Validate(); + + // Assert + Assert.AreEqual(2, validationMessages.Count); + Assert.IsTrue(validationMessages.Any(message => message.Contains("HRiver - HExit - (Rc*DTotal)"))); + Assert.IsTrue(validationMessages.Any(message => message.Contains("Dtotal"))); + } + + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/PipingProfileCreatorExceptionTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/PipingProfileCreatorExceptionTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/PipingProfileCreatorExceptionTest.cs (revision 3479f17e22ed8f8f44470972f85f9478707af683) @@ -0,0 +1,52 @@ +using System; + +using NUnit.Framework; + +namespace Ringtoets.Piping.Calculation.Test +{ + public class PipingProfileCreatorExceptionTest + { + [Test] + public void DefaultConstructor_InnerExceptionNullAndMessageDefault() + { + // Setup + var expectedMessage = String.Format("Exception of type '{0}' was thrown.", typeof(PipingProfileCreatorException).FullName); + + // Call + var exception = new PipingProfileCreatorException(); + + // Assert + Assert.IsNull(exception.InnerException); + Assert.AreEqual(expectedMessage, exception.Message); + } + + [Test] + public void Constructor_WithCustomMessage_InnerExceptionNullAndMessageSetToCustom() + { + // Setup + var expectedMessage ="Some exception message"; + + // Call + var exception = new PipingProfileCreatorException(expectedMessage); + + // Assert + Assert.IsNull(exception.InnerException); + Assert.AreEqual(expectedMessage, exception.Message); + } + + [Test] + public void Constructor_WithCustomMessageAndInnerException_InnerExceptionSetAndMessageSetToCustom() + { + // Setup + var expectedMessage = "Some exception message"; + var expectedInnerException = new Exception(); + + // Call + var exception = new PipingProfileCreatorException(expectedMessage, expectedInnerException); + + // Assert + Assert.AreSame(expectedInnerException, exception.InnerException); + Assert.AreEqual(expectedMessage, exception.Message); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/PipingProfileCreatorTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/PipingProfileCreatorTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/PipingProfileCreatorTest.cs (revision 3479f17e22ed8f8f44470972f85f9478707af683) @@ -0,0 +1,248 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +using Deltares.WTIPiping; + +using NUnit.Framework; + +using Ringtoets.Piping.Data; + +namespace Ringtoets.Piping.Calculation.Test +{ + public class PipingProfileCreatorTest + { + [Test] + public void Create_ProfileWithOneLayer_ReturnsProfileWithSingleLayer() + { + // Setup + var random = new Random(22); + var expectedTop = random.NextDouble(); + var expectedBottom = random.NextDouble(); + var belowPhreaticLevel = random.NextDouble(); + var abovePhreaticLevel = random.NextDouble(); + var dryUnitWeight = random.NextDouble(); + IEnumerable layers = new [] + { + new PipingSoilLayer(expectedTop) + { + IsAquifer = true, + BelowPhreaticLevel = belowPhreaticLevel, + AbovePhreaticLevel = abovePhreaticLevel, + DryUnitWeight = dryUnitWeight + }, + }; + var soilProfile = new PipingSoilProfile(String.Empty, expectedBottom, layers); + + // Call + PipingProfile actual = PipingProfileCreator.Create(soilProfile); + + // Assert + Assert.IsNotNull(actual.Layers); + Assert.IsNotNull(actual.BottomAquiferLayer); + Assert.IsNotNull(actual.TopAquiferLayer); + Assert.AreEqual(1, actual.Layers.Count); + Assert.AreEqual(expectedTop, actual.Layers[0].TopLevel); + Assert.AreEqual(expectedTop, actual.TopLevel); + Assert.AreEqual(expectedBottom, actual.BottomLevel); + + PipingLayer pipingLayer = actual.Layers.First(); + Assert.IsTrue(pipingLayer.IsAquifer); + Assert.AreEqual(belowPhreaticLevel, pipingLayer.BelowPhreaticLevel); + Assert.AreEqual(abovePhreaticLevel, pipingLayer.AbovePhreaticLevel); + Assert.AreEqual(dryUnitWeight, pipingLayer.DryUnitWeight); + } + + [Test] + public void Create_ProfileWithDecreasingTops_ReturnsProfileWithMultipleLayers() + { + // Setup + var random = new Random(22); + var expectedTopA = random.NextDouble(); + var expectedTopB = expectedTopA - random.NextDouble(); + var expectedTopC = expectedTopB - random.NextDouble(); + var expectedBottom = random.NextDouble(); + IEnumerable layers = new[] + { + new PipingSoilLayer(expectedTopA) + { + IsAquifer = true + }, + new PipingSoilLayer(expectedTopB), + new PipingSoilLayer(expectedTopC) + }; + + var soilProfile = new PipingSoilProfile(String.Empty, expectedBottom, layers); + + // Call + PipingProfile actual = PipingProfileCreator.Create(soilProfile); + + // Assert + Assert.AreEqual(3, actual.Layers.Count); + IEnumerable expectedAquifers = new[] + { + true, + false, + false, + }; + CollectionAssert.AreEqual(expectedAquifers, actual.Layers.Select(l => l.IsAquifer)); + CollectionAssert.AreEqual(new[] { expectedTopA, expectedTopB, expectedTopC }, actual.Layers.Select(l => l.TopLevel)); + Assert.AreEqual(expectedBottom, actual.BottomLevel); + } + + [Test] + public void Create_ProfileWithMultipleLayers_ReturnsProfileWithOrderedMultipleLayers() + { + // Setup + var random = new Random(22); + var expectedTopA = random.NextDouble(); + var expectedTopB = random.NextDouble() + expectedTopA; + var expectedTopC = random.NextDouble() + expectedTopB; + var expectedBottom = random.NextDouble(); + IEnumerable layers = new[] + { + new PipingSoilLayer(expectedTopA) + { + IsAquifer = true + }, + new PipingSoilLayer(expectedTopB), + new PipingSoilLayer(expectedTopC) + }; + var soilProfile = new PipingSoilProfile(string.Empty, expectedBottom, layers); + + // Precondition + CollectionAssert.AreNotEqual(layers, layers.OrderByDescending(l => l.Top), "Layer collection should not be in descending order by the Top property."); + + // Call + PipingProfile actual = PipingProfileCreator.Create(soilProfile); + + // Assert + IEnumerable ordered = actual.Layers.OrderByDescending(l => l.TopLevel); + CollectionAssert.AreEqual(ordered, actual.Layers); + + Assert.AreEqual(3, actual.Layers.Count); + IEnumerable expectedAquifers = new[] + { + false, + false, + true, + + }; + CollectionAssert.AreEqual(expectedAquifers, actual.Layers.Select(l => l.IsAquifer)); + CollectionAssert.AreEqual(new []{ expectedTopC, expectedTopB, expectedTopA }, actual.Layers.Select(l => l.TopLevel)); + Assert.AreEqual(expectedBottom, actual.BottomLevel); + } + + [Test] + public void Create_ProfileWithLayerBelowPhreaticLevelSet_ReturnsLayersWithBelowPhreaticLevel() + { + // Setup + var random = new Random(22); + var levelA = random.NextDouble(); + var levelB = random.NextDouble(); + var levelC = random.NextDouble(); + + IEnumerable layers = new[] + { + new PipingSoilLayer(1) + { + BelowPhreaticLevel = levelA + }, + new PipingSoilLayer(0) + { + BelowPhreaticLevel = levelB + }, + new PipingSoilLayer(-1) + { + BelowPhreaticLevel = levelC + } + }; + var soilProfile = new PipingSoilProfile(string.Empty, -2, layers); + + // Call + PipingProfile actual = PipingProfileCreator.Create(soilProfile); + + CollectionAssert.AreEqual(new[] + { + levelA, + levelB, + levelC + }, actual.Layers.Select(l => l.BelowPhreaticLevel)); + } + + [Test] + public void Create_ProfileWithLayerAbovePhreaticLevelSet_ReturnsLayersWithBelowPhreaticLevel() + { + // Setup + var random = new Random(22); + var levelA = random.NextDouble(); + var levelB = random.NextDouble(); + var levelC = random.NextDouble(); + + IEnumerable layers = new[] + { + new PipingSoilLayer(1) + { + AbovePhreaticLevel = levelA + }, + new PipingSoilLayer(0) + { + AbovePhreaticLevel = levelB + }, + new PipingSoilLayer(-1) + { + AbovePhreaticLevel = levelC + } + }; + var soilProfile = new PipingSoilProfile(string.Empty, -2, layers); + + // Call + PipingProfile actual = PipingProfileCreator.Create(soilProfile); + + CollectionAssert.AreEqual(new[] + { + levelA, + levelB, + levelC + }, actual.Layers.Select(l => l.AbovePhreaticLevel)); + } + + [Test] + public void Create_ProfileWithLayerDryUnitWeightSet_ReturnsLayersWithBelowPhreaticLevel() + { + // Setup + var random = new Random(22); + var weightA = random.NextDouble(); + var weightB = random.NextDouble(); + var weightC = random.NextDouble(); + + IEnumerable layers = new[] + { + new PipingSoilLayer(1) + { + DryUnitWeight = weightA + }, + new PipingSoilLayer(0) + { + DryUnitWeight = weightB + }, + new PipingSoilLayer(-1) + { + DryUnitWeight = weightC + } + }; + var soilProfile = new PipingSoilProfile(string.Empty, -2, layers); + + // Call + PipingProfile actual = PipingProfileCreator.Create(soilProfile); + + CollectionAssert.AreEqual(new[] + { + weightA, + weightB, + weightC + }, actual.Layers.Select(l => l.DryUnitWeight)); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/PipingSemiProbabilisticDesignValueFactoryTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/PipingSemiProbabilisticDesignValueFactoryTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/PipingSemiProbabilisticDesignValueFactoryTest.cs (revision 3479f17e22ed8f8f44470972f85f9478707af683) @@ -0,0 +1,116 @@ +using NUnit.Framework; + +using Ringtoets.Piping.Data; + +namespace Ringtoets.Piping.Calculation.Test +{ + [TestFixture] + public class PipingSemiProbabilisticDesignValueFactoryTest + { + #region General parameters + + [Test] + public void GetThicknessCoverageLayer_ValidPipingData_CreateDesignVariableForThicknessCoverageLayer() + { + // Setup + var inputParameters = new PipingInputParameters(); + + // Call + var thicknessCoverageLayer = PipingSemiProbabilisticDesignValueFactory.GetThicknessCoverageLayer(inputParameters); + + // Assert + Assert.AreSame(inputParameters.ThicknessCoverageLayer, thicknessCoverageLayer.Distribution); + Assert.AreEqual(0.05, thicknessCoverageLayer.Percentile); + } + + [Test] + public void GetPhreaticLevelExit_ValidPipingData_CreateDesignVariableForPhreaticLevelExit() + { + // Setup + var inputParameters = new PipingInputParameters(); + + // Call + var freaticLevelExit = PipingSemiProbabilisticDesignValueFactory.GetPhreaticLevelExit(inputParameters); + + // Assert + Assert.AreSame(inputParameters.PhreaticLevelExit, freaticLevelExit.Distribution); + Assert.AreEqual(0.05, freaticLevelExit.Percentile); + } + + [Test] + public void GetDampingFactorExit_ValidPipingData_CreateDesignVariableForDampingFactorExit() + { + // Setup + var inputParameters = new PipingInputParameters(); + + // Call + var dampingFactorExit = PipingSemiProbabilisticDesignValueFactory.GetDampingFactorExit(inputParameters); + + // Assert + Assert.AreSame(inputParameters.DampingFactorExit, dampingFactorExit.Distribution); + Assert.AreEqual(0.95, dampingFactorExit.Percentile); + } + + #endregion + + #region Piping parameters + + [Test] + public void GetSeepageLength_ValidPipingData_CreateDesignVariableForSeepageLength() + { + // Setup + var inputParameters = new PipingInputParameters(); + + // Call + var seepageLength = PipingSemiProbabilisticDesignValueFactory.GetSeepageLength(inputParameters); + + // Assert + Assert.AreSame(inputParameters.SeepageLength, seepageLength.Distribution); + Assert.AreEqual(0.05, seepageLength.Percentile); + } + + [Test] + public void GetDiameter70_ValidPipingData_CreateDesignVariableForDiameter70() + { + // Setup + var inputParameters = new PipingInputParameters(); + + // Call + var d70 = PipingSemiProbabilisticDesignValueFactory.GetDiameter70(inputParameters); + + // Assert + Assert.AreSame(inputParameters.Diameter70, d70.Distribution); + Assert.AreEqual(0.05, d70.Percentile); + } + + [Test] + public void GetDarcyPermeability_ValidPipingData_CreateDesignVariableForDarcyPermeability() + { + // Setup + var inputParameters = new PipingInputParameters(); + + // Call + var darcyPermeability = PipingSemiProbabilisticDesignValueFactory.GetDarcyPermeability(inputParameters); + + // Assert + Assert.AreSame(inputParameters.DarcyPermeability, darcyPermeability.Distribution); + Assert.AreEqual(0.95, darcyPermeability.Percentile); + } + + [Test] + public void GetThicknessAquiferLayer_ValidPipingData_CreateDesignVariableForThicknessAquiferLayer() + { + // Setup + var inputParameters = new PipingInputParameters(); + + // Call + var thicknessAquiferLayer = PipingSemiProbabilisticDesignValueFactory.GetThicknessAquiferLayer(inputParameters); + + // Assert + Assert.AreSame(inputParameters.ThicknessAquiferLayer, thicknessAquiferLayer.Distribution); + Assert.AreEqual(0.95, thicknessAquiferLayer.Percentile); + } + + #endregion + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/PipingSurfaceLineCreatorTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/PipingSurfaceLineCreatorTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/PipingSurfaceLineCreatorTest.cs (revision 3479f17e22ed8f8f44470972f85f9478707af683) @@ -0,0 +1,152 @@ +using System; +using System.Linq; + +using Deltares.WTIPiping; + +using NUnit.Framework; + +using Ringtoets.Piping.Data; + +namespace Ringtoets.Piping.Calculation.Test +{ + public class PipingSurfaceLineCreatorTest + { + [Test] + public void Create_NormalizedLocalSurfaceLine_ReturnsSurfaceLineWithIdenticalPoints() + { + // Setup + const string name = "Local coordinate surfaceline"; + var surfaceLine = new RingtoetsPipingSurfaceLine + { + Name = name + }; + surfaceLine.SetGeometry(new[] + { + new Point3D { X = 0.0, Y = 0.0, Z = 1.1 }, + new Point3D { X = 2.2, Y = 0.0, Z = 3.3 }, + new Point3D { X = 4.4, Y = 0.0, Z = 5.5 } + }); + + // Call + PipingSurfaceLine actual = PipingSurfaceLineCreator.Create(surfaceLine); + + // Assert + Assert.AreEqual(name, actual.Name); + CollectionAssert.AreEqual(surfaceLine.Points.Select(p => p.X).ToArray(), actual.Points.Select(p => p.X).ToArray()); + CollectionAssert.AreEqual(surfaceLine.Points.Select(p => p.Y).ToArray(), actual.Points.Select(p => p.Y).ToArray()); + CollectionAssert.AreEqual(surfaceLine.Points.Select(p => p.Z).ToArray(), actual.Points.Select(p => p.Z).ToArray()); + CollectionAssert.AreEqual(Enumerable.Repeat(PipingCharacteristicPointType.None, surfaceLine.Points.Count()), actual.Points.Select(p => p.Type)); + } + + [Test] + public void Create_LocalSurfaceLineNotNormalized_TranslateAllPointsToMakeFirstCoordinateZeroX() + { + // Setup + const string name = "Local coordinate surfaceline"; + var surfaceLine = new RingtoetsPipingSurfaceLine + { + Name = name + }; + const double firstX = 4.6; + surfaceLine.SetGeometry(new[] + { + new Point3D { X = firstX, Y = 0.0, Z = 1.1 }, + new Point3D { X = 7.8, Y = 0.0, Z = 3.3 }, + new Point3D { X = 9.9, Y = 0.0, Z = 5.5 } + }); + + // Call + PipingSurfaceLine actual = PipingSurfaceLineCreator.Create(surfaceLine); + + // Assert + var expectedCoordinatesX = surfaceLine.Points.Select(p => p.X - firstX).ToArray(); + Assert.AreEqual(name, actual.Name); + CollectionAssert.AreEqual(expectedCoordinatesX, actual.Points.Select(p => p.X).ToArray()); + CollectionAssert.AreEqual(surfaceLine.Points.Select(p => p.Y).ToArray(), actual.Points.Select(p => p.Y).ToArray()); + CollectionAssert.AreEqual(surfaceLine.Points.Select(p => p.Z).ToArray(), actual.Points.Select(p => p.Z).ToArray()); + CollectionAssert.AreEqual(Enumerable.Repeat(PipingCharacteristicPointType.None, surfaceLine.Points.Count()), actual.Points.Select(p => p.Type)); + } + + [Test] + public void Create_GlobalSurfaceLine_ProjectSurfaceLineIntoLZPlaneSpannedByFirstAndLastPoint() + { + // Setup + const string name = "Global coordinate surfaceline"; + var surfaceLine = new RingtoetsPipingSurfaceLine + { + Name = name + }; + surfaceLine.SetGeometry(new[] + { + new Point3D { X = 1.0, Y = 1.0, Z = 2.2 }, + new Point3D { X = 2.0, Y = 3.0, Z = 4.4 }, // Outlier from line specified by extrema + new Point3D { X = 3.0, Y = 4.0, Z = 7.7 }, + }); + + // Call + PipingSurfaceLine actual = PipingSurfaceLineCreator.Create(surfaceLine); + + // Assert + var length = Math.Sqrt(2 * 2 + 3 * 3); + const double secondCoordinateFactor = (2.0 * 1.0 + 3.0 * 2.0) / (2.0 * 2.0 + 3.0 * 3.0); + var expectedCoordinatesX = new[] + { + 0.0, + secondCoordinateFactor * length, + length + }; + Assert.AreEqual(name, actual.Name); + CollectionAssert.AreEqual(expectedCoordinatesX, actual.Points.Select(p => p.X).ToArray()); + CollectionAssert.AreEqual(Enumerable.Repeat(0, surfaceLine.Points.Count()).ToArray(), actual.Points.Select(p => p.Y).ToArray()); + CollectionAssert.AreEqual(surfaceLine.Points.Select(p => p.Z).ToArray(), actual.Points.Select(p => p.Z).ToArray()); + CollectionAssert.AreEqual(Enumerable.Repeat(PipingCharacteristicPointType.None, surfaceLine.Points.Count()), actual.Points.Select(p => p.Type)); + } + + [Test] + public void Create_SurfaceLineWithOnlyOnePoint_CreatePipingSurfaceLineWithOnePoint() + { + // Setup + const string name = "Global coordinate surfaceline"; + var surfaceLine = new RingtoetsPipingSurfaceLine + { + Name = name + }; + surfaceLine.SetGeometry(new[] + { + new Point3D { X = 1.0, Y = 1.0, Z = 2.2 }, + }); + + // Call + PipingSurfaceLine actual = PipingSurfaceLineCreator.Create(surfaceLine); + + // Assert + var expectedCoordinatesX = new[] + { + 0.0, + }; + Assert.AreEqual(name, actual.Name); + CollectionAssert.AreEqual(expectedCoordinatesX, actual.Points.Select(p => p.X).ToArray()); + CollectionAssert.AreEqual(Enumerable.Repeat(0, surfaceLine.Points.Count()).ToArray(), actual.Points.Select(p => p.Y).ToArray()); + CollectionAssert.AreEqual(surfaceLine.Points.Select(p => p.Z).ToArray(), actual.Points.Select(p => p.Z).ToArray()); + CollectionAssert.AreEqual(Enumerable.Repeat(PipingCharacteristicPointType.None, surfaceLine.Points.Count()), actual.Points.Select(p => p.Type)); + } + + [Test] + public void Create_SurfaceLineWithoutPoints_CreateSurfaceLineWithoutPoints() + { + // Setup + const string name = "Surfaceline without points"; + var surfaceLine = new RingtoetsPipingSurfaceLine + { + Name = name + }; + + // Call + PipingSurfaceLine actual = PipingSurfaceLineCreator.Create(surfaceLine); + + // Assert + Assert.AreEqual(name, actual.Name); + CollectionAssert.IsEmpty(actual.Points); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/Ringtoets.Piping.Calculation.Test.csproj =================================================================== diff -u -r3aa69a0ff858d591479a1b33ef1ad36ae76a5052 -r3479f17e22ed8f8f44470972f85f9478707af683 --- Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/Ringtoets.Piping.Calculation.Test.csproj (.../Ringtoets.Piping.Calculation.Test.csproj) (revision 3aa69a0ff858d591479a1b33ef1ad36ae76a5052) +++ Ringtoets/Piping/test/Ringtoets.Piping.Calculation.Test/Ringtoets.Piping.Calculation.Test.csproj (.../Ringtoets.Piping.Calculation.Test.csproj) (revision 3479f17e22ed8f8f44470972f85f9478707af683) @@ -53,14 +53,14 @@ - - - - - - - - + + + + + + + + Index: Ringtoets/Piping/test/Ringtoets.Piping.Calculation.TestUtil/TestPipingInput.cs =================================================================== diff -u -r2a49b7243807fe0b95136efd55652201164a6c74 -r3479f17e22ed8f8f44470972f85f9478707af683 --- Ringtoets/Piping/test/Ringtoets.Piping.Calculation.TestUtil/TestPipingInput.cs (.../TestPipingInput.cs) (revision 2a49b7243807fe0b95136efd55652201164a6c74) +++ Ringtoets/Piping/test/Ringtoets.Piping.Calculation.TestUtil/TestPipingInput.cs (.../TestPipingInput.cs) (revision 3479f17e22ed8f8f44470972f85f9478707af683) @@ -1,6 +1,5 @@ using System; -using Ringtoets.Piping.Calculation.Piping; using Ringtoets.Piping.Data; namespace Ringtoets.Piping.Calculation.TestUtil Index: Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/ImportSoilProfileFromDatabaseTest.cs =================================================================== diff -u -r30e82ab47f11b8600eff4b173b72db772ade03dc -r3479f17e22ed8f8f44470972f85f9478707af683 --- Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/ImportSoilProfileFromDatabaseTest.cs (.../ImportSoilProfileFromDatabaseTest.cs) (revision 30e82ab47f11b8600eff4b173b72db772ade03dc) +++ Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/ImportSoilProfileFromDatabaseTest.cs (.../ImportSoilProfileFromDatabaseTest.cs) (revision 3479f17e22ed8f8f44470972f85f9478707af683) @@ -3,7 +3,8 @@ using Core.Common.TestUtils; using Deltares.WTIPiping; using NUnit.Framework; -using Ringtoets.Piping.Calculation.Piping; + +using Ringtoets.Piping.Calculation; using Ringtoets.Piping.Data; using Ringtoets.Piping.Plugin.FileImporter;