Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Data/WaveConditionsInput.cs
===================================================================
diff -u -rf37230ff653580eb90dd878e6ecc4f15511a11d6 -r619e1c9f14861454e4cbe0109445de3bce0d7a75
--- Ringtoets/Revetment/src/Ringtoets.Revetment.Data/WaveConditionsInput.cs (.../WaveConditionsInput.cs) (revision f37230ff653580eb90dd878e6ecc4f15511a11d6)
+++ Ringtoets/Revetment/src/Ringtoets.Revetment.Data/WaveConditionsInput.cs (.../WaveConditionsInput.cs) (revision 619e1c9f14861454e4cbe0109445de3bce0d7a75)
@@ -20,8 +20,10 @@
// All rights reserved.
using System.Linq;
+using Core.Common.Base;
using Core.Common.Base.Data;
using Core.Common.Base.Geometry;
+using Ringtoets.Common.Data.Calculation;
using Ringtoets.Common.Data.DikeProfiles;
using Ringtoets.HydraRing.Data;
@@ -30,23 +32,32 @@
///
/// Class that holds all wave conditions calculation specific input paramaters.
///
- public class WaveConditionsInput
+ public class WaveConditionsInput : Observable, ICalculationInput
{
+ private readonly RoundedDouble designWaterLevelSubstraction;
+
private DikeProfile dikeProfile;
- private RoundedDouble upperLevel;
- private RoundedDouble lowerLevel;
+ private HydraulicBoundaryLocation hydraulicBoundaryLocation;
+ private RoundedDouble upperRevetmentLevel;
+ private RoundedDouble lowerRevetmentLevel;
+ private RoundedDouble lowerWaterLevel;
+ private RoundedDouble upperWaterLevel;
private RoundedDouble stepSize;
///
/// Creates a new instance of .
///
public WaveConditionsInput()
{
- upperLevel = new RoundedDouble(2);
- lowerLevel = new RoundedDouble(2);
+ upperRevetmentLevel = new RoundedDouble(2);
+ lowerRevetmentLevel = new RoundedDouble(2);
+ lowerWaterLevel = new RoundedDouble(2);
+ upperWaterLevel = new RoundedDouble(2);
stepSize = new RoundedDouble(1);
- UpdateProfileParameters();
+ designWaterLevelSubstraction = new RoundedDouble(2, 0.01);
+
+ UpdateDikeProfileParameters();
}
///
@@ -61,14 +72,25 @@
set
{
dikeProfile = value;
- UpdateProfileParameters();
+ UpdateDikeProfileParameters();
}
}
///
/// Gets or set the hydraulic boundary location from which to use the assessment level.
///
- public HydraulicBoundaryLocation HydraulicBoundaryLocation { get; set; }
+ public HydraulicBoundaryLocation HydraulicBoundaryLocation
+ {
+ get
+ {
+ return hydraulicBoundaryLocation;
+ }
+ set
+ {
+ hydraulicBoundaryLocation = value;
+ UpdateUpperWaterLevel();
+ }
+ }
///
/// Gets or sets if needs to be taken into account.
@@ -98,30 +120,54 @@
}
}
- public RoundedDouble UpperLevel
+ ///
+ /// Gets or sets the upper level of the revetment.
+ ///
+ public RoundedDouble UpperRevetmentLevel
{
get
{
- return upperLevel;
+ return upperRevetmentLevel;
}
set
{
- upperLevel = value.ToPrecision(upperLevel.NumberOfDecimalPlaces);
+ upperRevetmentLevel = value.ToPrecision(upperRevetmentLevel.NumberOfDecimalPlaces);
}
}
- public RoundedDouble LowerLevel
+ ///
+ /// Gets or sets the lower level of the revetment.
+ ///
+ public RoundedDouble LowerRevetmentLevel
{
get
{
- return lowerLevel;
+ return lowerRevetmentLevel;
}
set
{
- lowerLevel = value.ToPrecision(lowerLevel.NumberOfDecimalPlaces);
+ lowerRevetmentLevel = value.ToPrecision(lowerRevetmentLevel.NumberOfDecimalPlaces);
}
}
+ ///
+ /// Gets or sets the lower water level.
+ ///
+ public RoundedDouble LowerWaterLevel
+ {
+ get
+ {
+ return lowerWaterLevel;
+ }
+ set
+ {
+ lowerWaterLevel = value.ToPrecision(lowerWaterLevel.NumberOfDecimalPlaces);
+ }
+ }
+
+ ///
+ /// Gets or sets the step size for wave conditions calculations.
+ ///
public RoundedDouble StepSize
{
get
@@ -134,8 +180,35 @@
}
}
- private void UpdateProfileParameters()
+ ///
+ /// Gets the upper water level.
+ ///
+ public RoundedDouble UpperWaterLevel
{
+ get
+ {
+ return upperWaterLevel;
+ }
+ private set
+ {
+ upperWaterLevel = value.ToPrecision(upperWaterLevel.NumberOfDecimalPlaces);
+ }
+ }
+
+ private void UpdateUpperWaterLevel()
+ {
+ if (hydraulicBoundaryLocation != null && !double.IsNaN(hydraulicBoundaryLocation.DesignWaterLevel))
+ {
+ UpperWaterLevel = hydraulicBoundaryLocation.DesignWaterLevel - designWaterLevelSubstraction;
+ }
+ else
+ {
+ UpperWaterLevel = (RoundedDouble) 0;
+ }
+ }
+
+ private void UpdateDikeProfileParameters()
+ {
if (dikeProfile == null)
{
UseForeshore = false;
Index: Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/Ringtoets.Revetment.Data.Test.csproj
===================================================================
diff -u -r48e1ce89dde79fee454de1157cf61b1c5525506a -r619e1c9f14861454e4cbe0109445de3bce0d7a75
--- Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/Ringtoets.Revetment.Data.Test.csproj (.../Ringtoets.Revetment.Data.Test.csproj) (revision 48e1ce89dde79fee454de1157cf61b1c5525506a)
+++ Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/Ringtoets.Revetment.Data.Test.csproj (.../Ringtoets.Revetment.Data.Test.csproj) (revision 619e1c9f14861454e4cbe0109445de3bce0d7a75)
@@ -66,6 +66,10 @@
{d4200f43-3f72-4f42-af0a-8ced416a38ec}
Ringtoets.Common.Data
+
+ {4843D6E5-066F-4795-94F5-1D53932DD03C}
+ Ringtoets.Common.Data.TestUtil
+
{70f8cc9c-5bc8-4fb2-b201-eae7fa8088c2}
Ringtoets.HydraRing.Data
Index: Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/WaveConditionsInputTest.cs
===================================================================
diff -u -rf37230ff653580eb90dd878e6ecc4f15511a11d6 -r619e1c9f14861454e4cbe0109445de3bce0d7a75
--- Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/WaveConditionsInputTest.cs (.../WaveConditionsInputTest.cs) (revision f37230ff653580eb90dd878e6ecc4f15511a11d6)
+++ Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/WaveConditionsInputTest.cs (.../WaveConditionsInputTest.cs) (revision 619e1c9f14861454e4cbe0109445de3bce0d7a75)
@@ -20,10 +20,13 @@
// All rights reserved.
using System.Collections.Generic;
+using Core.Common.Base;
using Core.Common.Base.Data;
using Core.Common.Base.Geometry;
using NUnit.Framework;
+using Ringtoets.Common.Data.Calculation;
using Ringtoets.Common.Data.DikeProfiles;
+using Ringtoets.Common.Data.TestUtil;
using Ringtoets.HydraRing.Data;
namespace Ringtoets.Revetment.Data.Test
@@ -38,15 +41,19 @@
var input = new WaveConditionsInput();
// Assert
+ Assert.IsInstanceOf(input);
+ Assert.IsInstanceOf(input);
Assert.IsNull(input.HydraulicBoundaryLocation);
Assert.IsNull(input.DikeProfile);
Assert.IsFalse(input.UseBreakWater);
Assert.AreEqual(BreakWaterType.Dam, input.BreakWater.Type);
Assert.AreEqual(new RoundedDouble(2), input.BreakWater.Height);
Assert.IsFalse(input.UseForeshore);
CollectionAssert.IsEmpty(input.ForeshoreGeometry);
- Assert.AreEqual(new RoundedDouble(2), input.UpperLevel);
- Assert.AreEqual(new RoundedDouble(2), input.LowerLevel);
+ Assert.AreEqual(new RoundedDouble(2), input.UpperRevetmentLevel);
+ Assert.AreEqual(new RoundedDouble(2), input.LowerRevetmentLevel);
+ Assert.AreEqual(new RoundedDouble(2), input.LowerWaterLevel);
+ Assert.AreEqual(new RoundedDouble(2), input.UpperWaterLevel);
Assert.AreEqual(new RoundedDouble(1), input.StepSize);
}
@@ -158,38 +165,54 @@
}
[Test]
- public void UpperLevel_SetNewValue_ValueIsRounded()
+ public void UpperRevetmentLevel_SetNewValue_ValueIsRounded()
{
// Setup
var input = new WaveConditionsInput();
- int originalNumberOfDecimalPlaces = input.UpperLevel.NumberOfDecimalPlaces;
+ int originalNumberOfDecimalPlaces = input.UpperRevetmentLevel.NumberOfDecimalPlaces;
// Call
- input.UpperLevel = new RoundedDouble(5, 1.23456);
+ input.UpperRevetmentLevel = new RoundedDouble(5, 1.23456);
// Assert
- Assert.AreEqual(originalNumberOfDecimalPlaces, input.UpperLevel.NumberOfDecimalPlaces);
- Assert.AreEqual(1.23, input.UpperLevel.Value);
+ Assert.AreEqual(originalNumberOfDecimalPlaces, input.UpperRevetmentLevel.NumberOfDecimalPlaces);
+ Assert.AreEqual(1.23, input.UpperRevetmentLevel.Value);
}
[Test]
- public void LowerLevel_SetNewValue_ValueIsRounded()
+ public void LowerRevetmentLevel_SetNewValue_ValueIsRounded()
{
// Setup
var input = new WaveConditionsInput();
- int originalNumberOfDecimalPlaces = input.LowerLevel.NumberOfDecimalPlaces;
+ int originalNumberOfDecimalPlaces = input.LowerRevetmentLevel.NumberOfDecimalPlaces;
// Call
- input.LowerLevel = new RoundedDouble(5, 1.23456);
+ input.LowerRevetmentLevel = new RoundedDouble(5, 1.23456);
// Assert
- Assert.AreEqual(originalNumberOfDecimalPlaces, input.LowerLevel.NumberOfDecimalPlaces);
- Assert.AreEqual(1.23, input.LowerLevel.Value);
+ Assert.AreEqual(originalNumberOfDecimalPlaces, input.LowerRevetmentLevel.NumberOfDecimalPlaces);
+ Assert.AreEqual(1.23, input.LowerRevetmentLevel.Value);
}
[Test]
+ public void LowerWaterLevel_SetNewValue_ValueIsRounded()
+ {
+ // Setup
+ var input = new WaveConditionsInput();
+
+ int originalNumberOfDecimalPlaces = input.LowerWaterLevel.NumberOfDecimalPlaces;
+
+ // Call
+ input.LowerWaterLevel = new RoundedDouble(5, 1.23456);
+
+ // Assert
+ Assert.AreEqual(originalNumberOfDecimalPlaces, input.LowerWaterLevel.NumberOfDecimalPlaces);
+ Assert.AreEqual(1.23, input.LowerWaterLevel.Value);
+ }
+
+ [Test]
public void StepSize_SetNewValue_ValueIsRounded()
{
// Setup
@@ -204,5 +227,81 @@
Assert.AreEqual(originalNumberOfDecimalPlaces, input.StepSize.NumberOfDecimalPlaces);
Assert.AreEqual(1.2, input.StepSize.Value);
}
+
+ [Test]
+ public void HydraulicBoundaryLocation_SetNewValue_UpperWaterLevelUpdated()
+ {
+ // Setup
+ var input = new WaveConditionsInput();
+ var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0, 0)
+ {
+ DesignWaterLevel = new RoundedDouble(2, 6.34)
+ };
+
+ // Call
+ input.HydraulicBoundaryLocation = hydraulicBoundaryLocation;
+
+ // Assert
+ Assert.AreEqual(6.33, input.UpperWaterLevel, input.UpperWaterLevel.GetAccuracy());
+ }
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void HydraulicBoundaryLocation_WithoutDesignWaterLevel_UpperWaterLevelSetToDefault(bool withDesignWaterLevel)
+ {
+ // Setup
+ var input = new WaveConditionsInput();
+
+ if (withDesignWaterLevel)
+ {
+ var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0, 0)
+ {
+ DesignWaterLevel = new RoundedDouble(2, 6.34)
+ };
+
+ input.HydraulicBoundaryLocation = hydraulicBoundaryLocation;
+
+ // Precondition
+ Assert.AreEqual(6.33, input.UpperWaterLevel, input.UpperWaterLevel.GetAccuracy());
+ }
+
+ var newHydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0, 0);
+
+ // Call
+ input.HydraulicBoundaryLocation = newHydraulicBoundaryLocation;
+
+ // Assert
+ Assert.AreEqual(new RoundedDouble(2), input.UpperWaterLevel);
+ }
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void HydraulicBoundaryLocation_HydraulicBoundaryLocationNull_UpperWaterLevelSetToDefault(bool withDesignWaterLevel)
+ {
+ // Setup
+ var input = new WaveConditionsInput();
+
+ if (withDesignWaterLevel)
+ {
+ var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0, 0)
+ {
+ DesignWaterLevel = new RoundedDouble(2, 6.34)
+ };
+
+ input.HydraulicBoundaryLocation = hydraulicBoundaryLocation;
+
+ // Precondition
+ Assert.AreEqual(6.33, input.UpperWaterLevel, input.UpperWaterLevel.GetAccuracy());
+ }
+
+
+ // Call
+ input.HydraulicBoundaryLocation = null;
+
+ // Assert
+ Assert.AreEqual(new RoundedDouble(2), input.UpperWaterLevel);
+ }
}
}
\ No newline at end of file