Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/Waternet/WaternetCalculator.cs
===================================================================
diff -u -r339fdc7d7dcf18dc48fc6af51a3f067e50c5a140 -r1ac34cc0c84df6f54d67ab8c1886ca96387dd7dd
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/Waternet/WaternetCalculator.cs (.../WaternetCalculator.cs) (revision 339fdc7d7dcf18dc48fc6af51a3f067e50c5a140)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/Waternet/WaternetCalculator.cs (.../WaternetCalculator.cs) (revision 1ac34cc0c84df6f54d67ab8c1886ca96387dd7dd)
@@ -38,9 +38,6 @@
///
public class WaternetCalculator : IWaternetCalculator
{
- private readonly WaternetCalculatorInput input;
- private readonly IMacroStabilityInwardsKernelFactory factory;
-
///
/// Creates a new instance of .
///
@@ -59,8 +56,8 @@
{
throw new ArgumentNullException(nameof(factory));
}
- this.input = input;
- this.factory = factory;
+ Input = input;
+ Factory = factory;
}
public WaternetCalculatorResult Calculate()
@@ -70,29 +67,17 @@
return WaternetCalculatorResultCreator.Create(waternetKernel.Waternet);
}
- private IWaternetKernel CalculateWaternet()
- {
- IWaternetKernel waternetKernel = CreateWaternetKernel();
+ protected WaternetCalculatorInput Input { get; }
- try
- {
- waternetKernel.Calculate();
- }
- catch (WaternetKernelWrapperException e)
- {
- throw new WaternetCalculatorException(e.Message, e);
- }
+ protected IMacroStabilityInwardsKernelFactory Factory { get; }
- return waternetKernel;
- }
-
- private IWaternetKernel CreateWaternetKernel()
+ protected virtual IWaternetKernel CreateWaternetKernel()
{
- IWaternetKernel waternetKernel = factory.CreateWaternetExtremeKernel();
+ IWaternetKernel waternetKernel = Factory.CreateWaternetExtremeKernel();
- Soil[] soils = SoilCreator.Create(input.SoilProfile);
+ Soil[] soils = SoilCreator.Create(Input.SoilProfile);
Dictionary layersWithSoils =
- input.SoilProfile.Layers
+ Input.SoilProfile.Layers
.Zip(soils, (layer, soil) => new
{
layer,
@@ -101,11 +86,27 @@
.ToDictionary(x => x.layer, x => x.soil);
waternetKernel.SoilModel = SoilModelCreator.Create(soils);
- waternetKernel.SoilProfile = SoilProfileCreator.Create(input.SoilProfile, layersWithSoils);
- waternetKernel.Location = WaternetStabilityLocationCreator.CreateExtreme(input);
- waternetKernel.SurfaceLine = SurfaceLineCreator.Create(input.SurfaceLine, input.LandwardDirection);
+ waternetKernel.SoilProfile = SoilProfileCreator.Create(Input.SoilProfile, layersWithSoils);
+ waternetKernel.Location = WaternetStabilityLocationCreator.CreateExtreme(Input);
+ waternetKernel.SurfaceLine = SurfaceLineCreator.Create(Input.SurfaceLine, Input.LandwardDirection);
return waternetKernel;
}
+
+ private IWaternetKernel CalculateWaternet()
+ {
+ IWaternetKernel waternetKernel = CreateWaternetKernel();
+
+ try
+ {
+ waternetKernel.Calculate();
+ }
+ catch (WaternetKernelWrapperException e)
+ {
+ throw new WaternetCalculatorException(e.Message, e);
+ }
+
+ return waternetKernel;
+ }
}
}
\ No newline at end of file
Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/Waternet/WaternetDailyCalculator.cs
===================================================================
diff -u
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/Waternet/WaternetDailyCalculator.cs (revision 0)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/Waternet/WaternetDailyCalculator.cs (revision 1ac34cc0c84df6f54d67ab8c1886ca96387dd7dd)
@@ -0,0 +1,72 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Deltares.WTIStability.Data.Geo;
+using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.Waternet.Input;
+using Ringtoets.MacroStabilityInwards.KernelWrapper.Creators.Input;
+using Ringtoets.MacroStabilityInwards.KernelWrapper.Kernels;
+using Ringtoets.MacroStabilityInwards.KernelWrapper.Kernels.Waternet;
+using SoilLayer = Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.Input.SoilLayer;
+
+namespace Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.Waternet
+{
+ ///
+ /// Class representing a Waternet calculator for daily circumstances.
+ ///
+ public class WaternetDailyCalculator : WaternetCalculator
+ {
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The containing all the values
+ /// required for performing the Waternet calculation.
+ /// The factory responsible for creating the Waternet kernel.
+ /// Thrown when or
+ /// is null.
+ public WaternetDailyCalculator(WaternetCalculatorInput input, IMacroStabilityInwardsKernelFactory factory)
+ : base(input, factory) {}
+
+ protected override IWaternetKernel CreateWaternetKernel()
+ {
+ IWaternetKernel waternetKernel = Factory.CreateWaternetDailyKernel();
+
+ Soil[] soils = SoilCreator.Create(Input.SoilProfile);
+ Dictionary layersWithSoils =
+ Input.SoilProfile.Layers
+ .Zip(soils, (layer, soil) => new
+ {
+ layer,
+ soil
+ })
+ .ToDictionary(x => x.layer, x => x.soil);
+
+ waternetKernel.SoilModel = SoilModelCreator.Create(soils);
+ waternetKernel.SoilProfile = SoilProfileCreator.Create(Input.SoilProfile, layersWithSoils);
+ waternetKernel.Location = WaternetStabilityLocationCreator.CreateDaily(Input);
+ waternetKernel.SurfaceLine = SurfaceLineCreator.Create(Input.SurfaceLine, Input.LandwardDirection);
+
+ return waternetKernel;
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Ringtoets.MacroStabilityInwards.KernelWrapper.csproj
===================================================================
diff -u -r89a646a8c35a7ba14474d1dc52ad3649ef6fd954 -r1ac34cc0c84df6f54d67ab8c1886ca96387dd7dd
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Ringtoets.MacroStabilityInwards.KernelWrapper.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.csproj) (revision 89a646a8c35a7ba14474d1dc52ad3649ef6fd954)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Ringtoets.MacroStabilityInwards.KernelWrapper.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.csproj) (revision 1ac34cc0c84df6f54d67ab8c1886ca96387dd7dd)
@@ -65,6 +65,7 @@
+
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Calculators/Waternet/WaternetDailyCalculatorTest.cs
===================================================================
diff -u
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Calculators/Waternet/WaternetDailyCalculatorTest.cs (revision 0)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Calculators/Waternet/WaternetDailyCalculatorTest.cs (revision 1ac34cc0c84df6f54d67ab8c1886ca96387dd7dd)
@@ -0,0 +1,214 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Core.Common.Base.Geometry;
+using Core.Common.TestUtil;
+using Deltares.WTIStability.Data.Geo;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.Input;
+using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.Waternet;
+using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.Waternet.Input;
+using Ringtoets.MacroStabilityInwards.KernelWrapper.Creators.Input;
+using Ringtoets.MacroStabilityInwards.KernelWrapper.Kernels;
+using Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.Kernels;
+using Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.Kernels.UpliftVan.Input;
+using Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.Kernels.Waternet;
+using Ringtoets.MacroStabilityInwards.Primitives;
+using Point2D = Core.Common.Base.Geometry.Point2D;
+using SoilLayer = Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.Input.SoilLayer;
+using SoilProfile = Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.Input.SoilProfile;
+using WtiStabilityWaternet = Deltares.WTIStability.Data.Geo.Waternet;
+
+namespace Ringtoets.MacroStabilityInwards.KernelWrapper.Test.Calculators.Waternet
+{
+ [TestFixture]
+ public class WaternetDailyCalculatorTest
+ {
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var factory = mocks.Stub();
+ mocks.ReplayAll();
+
+ WaternetCalculatorInput input = CreateValidCalculatorInput();
+
+ // Call
+ var calculator = new WaternetDailyCalculator(input, factory);
+
+ // Assert
+ Assert.IsInstanceOf(calculator);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Calculate_CalculatorWithCompleteInput_InputCorrectlySetToKernel()
+ {
+ // Setup
+ WaternetCalculatorInput input = CreateCompleteCalculatorInput();
+ var testMacroStabilityInwardsKernelFactory = new TestMacroStabilityInwardsKernelFactory();
+
+ WaternetKernelStub waternetKernel = testMacroStabilityInwardsKernelFactory.LastCreatedWaternetKernel;
+ SetKernelOutput(waternetKernel);
+
+ // Call
+ new WaternetDailyCalculator(input, testMacroStabilityInwardsKernelFactory).Calculate();
+
+ // Assert
+ Soil[] soils = SoilCreator.Create(input.SoilProfile);
+ Dictionary layersWithSoils =
+ input.SoilProfile.Layers
+ .Zip(soils, (layer, soil) => new
+ {
+ layer,
+ soil
+ })
+ .ToDictionary(x => x.layer, x => x.soil);
+
+ KernelInputAssert.AssertSoilModels(SoilModelCreator.Create(soils), waternetKernel.SoilModel);
+ KernelInputAssert.AssertSoilProfiles(SoilProfileCreator.Create(input.SoilProfile, layersWithSoils), waternetKernel.SoilProfile);
+ KernelInputAssert.AssertStabilityLocations(WaternetStabilityLocationCreator.CreateDaily(input), waternetKernel.Location);
+ KernelInputAssert.AssertSurfaceLines(SurfaceLineCreator.Create(input.SurfaceLine, input.LandwardDirection), waternetKernel.SurfaceLine);
+ }
+
+ private static void SetKernelOutput(WaternetKernelStub waternetKernel)
+ {
+ waternetKernel.Waternet = new WtiStabilityWaternet
+ {
+ PhreaticLine = new PhreaticLine()
+ };
+ }
+
+ private static WaternetCalculatorInput CreateCompleteCalculatorInput()
+ {
+ var random = new Random(21);
+
+ MacroStabilityInwardsSurfaceLine surfaceLine = CreateValidSurfaceLine();
+
+ return new WaternetCalculatorInput(new WaternetCalculatorInput.ConstructionProperties
+ {
+ AssessmentLevel = random.NextDouble(),
+ SurfaceLine = surfaceLine,
+ SoilProfile = CreateValidSoilProfile(surfaceLine),
+ DrainageConstruction = new DrainageConstruction(),
+ PhreaticLineOffsetsExtreme = new PhreaticLineOffsets(),
+ PhreaticLineOffsetsDaily = new PhreaticLineOffsets(),
+ WaterLevelRiverAverage = random.Next(),
+ WaterLevelPolderExtreme = random.Next(),
+ WaterLevelPolderDaily = random.Next(),
+ MinimumLevelPhreaticLineAtDikeTopRiver = random.Next(),
+ MinimumLevelPhreaticLineAtDikeTopPolder = random.Next(),
+ LeakageLengthOutwardsPhreaticLine3 = random.Next(),
+ LeakageLengthInwardsPhreaticLine3 = random.Next(),
+ LeakageLengthOutwardsPhreaticLine4 = random.Next(),
+ LeakageLengthInwardsPhreaticLine4 = random.Next(),
+ PiezometricHeadPhreaticLine2Outwards = random.Next(),
+ PiezometricHeadPhreaticLine2Inwards = random.Next(),
+ PenetrationLength = random.Next(),
+ AdjustPhreaticLine3And4ForUplift = random.NextBoolean(),
+ DikeSoilScenario = random.NextEnumValue()
+ });
+ }
+
+ private static WaternetCalculatorInput CreateValidCalculatorInput()
+ {
+ var random = new Random(21);
+
+ MacroStabilityInwardsSurfaceLine surfaceLine = CreateValidSurfaceLine();
+ return new WaternetCalculatorInput(new WaternetCalculatorInput.ConstructionProperties
+ {
+ AssessmentLevel = random.NextDouble(),
+ SurfaceLine = surfaceLine,
+ SoilProfile = CreateValidSoilProfile(surfaceLine),
+ DrainageConstruction = new DrainageConstruction(),
+ PhreaticLineOffsetsExtreme = new PhreaticLineOffsets(),
+ PhreaticLineOffsetsDaily = new PhreaticLineOffsets()
+ });
+ }
+
+ private static SoilProfile CreateValidSoilProfile(MacroStabilityInwardsSurfaceLine surfaceLine)
+ {
+ return new SoilProfile(new[]
+ {
+ new SoilLayer(
+ new[]
+ {
+ surfaceLine.LocalGeometry.First(),
+ surfaceLine.LocalGeometry.Last()
+ },
+ Enumerable.Empty(),
+ new SoilLayer.ConstructionProperties()),
+ new SoilLayer(
+ new[]
+ {
+ surfaceLine.LocalGeometry.First(),
+ surfaceLine.LocalGeometry.Last()
+ },
+ Enumerable.Empty(),
+ new SoilLayer.ConstructionProperties
+ {
+ IsAquifer = true
+ }),
+ new SoilLayer(
+ new[]
+ {
+ surfaceLine.LocalGeometry.First(),
+ surfaceLine.LocalGeometry.Last()
+ },
+ Enumerable.Empty(),
+ new SoilLayer.ConstructionProperties()),
+ new SoilLayer(
+ new[]
+ {
+ surfaceLine.LocalGeometry.First(),
+ surfaceLine.LocalGeometry.Last()
+ },
+ Enumerable.Empty(),
+ new SoilLayer.ConstructionProperties())
+ }, new[]
+ {
+ new PreconsolidationStress(new Point2D(0, 0), 1.1)
+ });
+ }
+
+ private static MacroStabilityInwardsSurfaceLine CreateValidSurfaceLine()
+ {
+ var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty);
+ var dikeToeAtRiver = new Point3D(1, 0, 8);
+
+ surfaceLine.SetGeometry(new[]
+ {
+ new Point3D(0, 0, 2),
+ dikeToeAtRiver,
+ new Point3D(2, 0, -1)
+ });
+
+ surfaceLine.SetDikeToeAtRiverAt(dikeToeAtRiver);
+
+ return surfaceLine;
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj
===================================================================
diff -u -r89a646a8c35a7ba14474d1dc52ad3649ef6fd954 -r1ac34cc0c84df6f54d67ab8c1886ca96387dd7dd
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj) (revision 89a646a8c35a7ba14474d1dc52ad3649ef6fd954)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj) (revision 1ac34cc0c84df6f54d67ab8c1886ca96387dd7dd)
@@ -83,6 +83,7 @@
+