Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/MacroStabilityInwardsCalculator.cs =================================================================== diff -u -r67d3117861b4e393093753aaa3e9a28125a4a74f -re53ef4c278a378cb5b3973dc939a19896f94b1cc --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/MacroStabilityInwardsCalculator.cs (.../MacroStabilityInwardsCalculator.cs) (revision 67d3117861b4e393093753aaa3e9a28125a4a74f) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/MacroStabilityInwardsCalculator.cs (.../MacroStabilityInwardsCalculator.cs) (revision e53ef4c278a378cb5b3973dc939a19896f94b1cc) @@ -21,7 +21,11 @@ using System; using System.Collections.Generic; +using System.Linq; +using Deltares.WTIStability.Data.Geo; +using Deltares.WTIStability.Data.Standard; using Ringtoets.MacroStabilityInwards.KernelWrapper.SubCalculator; +using Ringtoets.MacroStabilityInwards.Primitives; namespace Ringtoets.MacroStabilityInwards.KernelWrapper { @@ -86,10 +90,36 @@ private IUpliftVanCalculator CreateUpliftVanCalculator() { IUpliftVanCalculator calculator = factory.CreateUpliftVanCalculator(); - calculator.SoilProfile = input.SoilProfile; + Soil[] soils = MacroStabilityInwardsSoilCreator.Create(input.SoilProfile); + calculator.SoilModel = CreateSoilModel(soils); + calculator.SoilProfile = CreateSoilProfile(input.SoilProfile.LayersUnderSurfaceLine.ToArray(), soils); return calculator; } + private SoilProfile2D CreateSoilProfile(IList layers, IList soils) + { + var profile = new SoilProfile2D(); + + for (int i = 0; i < layers.Count; i++) + { + profile.Surfaces.Add(new SoilLayer2D + { + IsAquifer = layers[i].Properties.IsAquifer, + Soil = soils[i] + }); + } + + return profile; + } + + private SoilModel CreateSoilModel(IEnumerable soils) + { + var soilModel = new SoilModel(); + soilModel.Soils.AddRange(soils); + + return soilModel; + } + /// /// 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 kernel. Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/MacroStabilityInwardsSoilCreator.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/MacroStabilityInwardsSoilCreator.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/MacroStabilityInwardsSoilCreator.cs (revision e53ef4c278a378cb5b3973dc939a19896f94b1cc) @@ -0,0 +1,69 @@ +// 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.Linq; +using Deltares.WTIStability.Data.Geo; +using Ringtoets.MacroStabilityInwards.Primitives; + +namespace Ringtoets.MacroStabilityInwards.KernelWrapper +{ + /// + /// Creates instances which are required by the . + /// + internal static class MacroStabilityInwardsSoilCreator + { + /// + /// Creates a based on information contained in the profiled , + /// which can be used in the . + /// + /// The from + /// which to take the information. + /// A new with information taken from the . + /// Thrown when + /// has an type that can't be converted to . + public static Soil[] Create(MacroStabilityInwardsSoilProfileUnderSurfaceLine profile) + { + return profile.LayersUnderSurfaceLine.Select(l => new Soil(l.Properties.MaterialName) + { + UsePop = l.Properties.UsePop, + ShearStrengthModel = ConvertShearStrengthModel(l.Properties.ShearStrengthModel) + }).ToArray(); + } + + private static ShearStrengthModel ConvertShearStrengthModel(MacroStabilityInwardsShearStrengthModel shearStrengthModel) + { + switch (shearStrengthModel) + { + case MacroStabilityInwardsShearStrengthModel.None: + return ShearStrengthModel.None; + case MacroStabilityInwardsShearStrengthModel.SuCalculated: + return ShearStrengthModel.CuCalculated; + case MacroStabilityInwardsShearStrengthModel.CPhi: + return ShearStrengthModel.CPhi; + case MacroStabilityInwardsShearStrengthModel.CPhiOrSuCalculated: + return ShearStrengthModel.CPhiOrCuCalculated; + default: + throw new NotSupportedException(); + } + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Ringtoets.MacroStabilityInwards.KernelWrapper.csproj =================================================================== diff -u -r815d6acccf30d1310d695a0b4a90d33a6cdd497a -re53ef4c278a378cb5b3973dc939a19896f94b1cc --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Ringtoets.MacroStabilityInwards.KernelWrapper.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.csproj) (revision 815d6acccf30d1310d695a0b4a90d33a6cdd497a) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Ringtoets.MacroStabilityInwards.KernelWrapper.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.csproj) (revision e53ef4c278a378cb5b3973dc939a19896f94b1cc) @@ -46,6 +46,7 @@ + Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/SubCalculator/IUpliftVanCalculator.cs =================================================================== diff -u -rd90619dfb54877db8067f27218c45ad4e5dab55d -re53ef4c278a378cb5b3973dc939a19896f94b1cc --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/SubCalculator/IUpliftVanCalculator.cs (.../IUpliftVanCalculator.cs) (revision d90619dfb54877db8067f27218c45ad4e5dab55d) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/SubCalculator/IUpliftVanCalculator.cs (.../IUpliftVanCalculator.cs) (revision e53ef4c278a378cb5b3973dc939a19896f94b1cc) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using Deltares.WTIStability.Data.Geo; using Ringtoets.MacroStabilityInwards.Primitives; namespace Ringtoets.MacroStabilityInwards.KernelWrapper.SubCalculator @@ -33,6 +34,14 @@ /// void Calculate(); - MacroStabilityInwardsSoilProfileUnderSurfaceLine SoilProfile { set; } + /// + /// Sets the soil model. + /// + SoilModel SoilModel { set; } + + /// + /// Sets the soil profile. + /// + SoilProfile2D SoilProfile { set; } } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/SubCalculator/UpliftVanCalculator.cs =================================================================== diff -u -rd90619dfb54877db8067f27218c45ad4e5dab55d -re53ef4c278a378cb5b3973dc939a19896f94b1cc --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/SubCalculator/UpliftVanCalculator.cs (.../UpliftVanCalculator.cs) (revision d90619dfb54877db8067f27218c45ad4e5dab55d) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/SubCalculator/UpliftVanCalculator.cs (.../UpliftVanCalculator.cs) (revision e53ef4c278a378cb5b3973dc939a19896f94b1cc) @@ -41,7 +41,10 @@ public UpliftVanCalculator() { wrappedCalculator = new WTIStabilityCalculation(); - calculatorInput = new StabilityModel(); + calculatorInput = new StabilityModel + { + ModelOption = ModelOptions.UpliftVan + }; } public void Calculate() @@ -50,12 +53,20 @@ wrappedCalculator.Run(); } - public MacroStabilityInwardsSoilProfileUnderSurfaceLine SoilProfile + public SoilModel SoilModel { set { - + calculatorInput.SoilModel = value; } } + + public SoilProfile2D SoilProfile + { + set + { + calculatorInput.SoilProfile = value; + } + } } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/MacroStabilityInwardsSoilCreatorTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/MacroStabilityInwardsSoilCreatorTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/MacroStabilityInwardsSoilCreatorTest.cs (revision e53ef4c278a378cb5b3973dc939a19896f94b1cc) @@ -0,0 +1,122 @@ +// 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.Linq; +using Deltares.WTIStability.Data.Geo; +using NUnit.Framework; +using Ringtoets.MacroStabilityInwards.Primitives; +using Point2D = Core.Common.Base.Geometry.Point2D; + +namespace Ringtoets.MacroStabilityInwards.KernelWrapper.Test +{ + [TestFixture] + public class MacroStabilityInwardsSoilCreatorTest + { + [Test] + public void Create_ProfileWithLayers_ReturnsProfileWithLayers() + { + // Setup + var profile = new MacroStabilityInwardsSoilProfileUnderSurfaceLine(new[] + { + new MacroStabilityInwardsSoilLayerUnderSurfaceLine(new[] + { + new Point2D(0, 0), + new Point2D(1, 1) + }, new MacroStabilityInwardsSoilLayerProperties + { + UsePop = true, + ShearStrengthModel = MacroStabilityInwardsShearStrengthModel.CPhi, + MaterialName = "Sand" + }), + new MacroStabilityInwardsSoilLayerUnderSurfaceLine(new[] + { + new Point2D(0, 0), + new Point2D(1, 1) + }, new MacroStabilityInwardsSoilLayerProperties + { + UsePop = false, + ShearStrengthModel = MacroStabilityInwardsShearStrengthModel.None, + MaterialName = "Mud" + }), + new MacroStabilityInwardsSoilLayerUnderSurfaceLine(new[] + { + new Point2D(0, 0), + new Point2D(1, 1) + }, new MacroStabilityInwardsSoilLayerProperties + { + UsePop = true, + ShearStrengthModel = MacroStabilityInwardsShearStrengthModel.CPhiOrSuCalculated, + MaterialName = "Clay" + }), + new MacroStabilityInwardsSoilLayerUnderSurfaceLine(new[] + { + new Point2D(0, 0), + new Point2D(1, 1) + }, new MacroStabilityInwardsSoilLayerProperties + { + UsePop = true, + ShearStrengthModel = MacroStabilityInwardsShearStrengthModel.SuCalculated, + MaterialName = "Grass" + }) + }); + + // Call + Soil[] soils = MacroStabilityInwardsSoilCreator.Create(profile); + + // Assert + Assert.AreEqual(4, soils.Length); + + CollectionAssert.AreEqual(profile.LayersUnderSurfaceLine.Select(l => l.Properties.UsePop), soils.Select(s => s.UsePop)); + CollectionAssert.AreEqual(profile.LayersUnderSurfaceLine.Select(l => l.Properties.MaterialName), soils.Select(s => s.Name)); + CollectionAssert.AreEqual(new[] + { + ShearStrengthModel.CPhi, + ShearStrengthModel.None, + ShearStrengthModel.CPhiOrCuCalculated, + ShearStrengthModel.CuCalculated, + }, soils.Select(s => s.ShearStrengthModel)); + } + + [Test] + public void Create_InvalidShearStrengthModel_ThrowNotSupportedException() + { + // Setup + var profile = new MacroStabilityInwardsSoilProfileUnderSurfaceLine(new[] + { + new MacroStabilityInwardsSoilLayerUnderSurfaceLine(new[] + { + new Point2D(0, 0), + new Point2D(1, 1) + }, new MacroStabilityInwardsSoilLayerProperties + { + ShearStrengthModel = (MacroStabilityInwardsShearStrengthModel) 99, + }) + }); + + // Call + TestDelegate test = () => MacroStabilityInwardsSoilCreator.Create(profile); + + // Assert + Assert.Throws(test); + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj =================================================================== diff -u -r815d6acccf30d1310d695a0b4a90d33a6cdd497a -re53ef4c278a378cb5b3973dc939a19896f94b1cc --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj) (revision 815d6acccf30d1310d695a0b4a90d33a6cdd497a) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj) (revision e53ef4c278a378cb5b3973dc939a19896f94b1cc) @@ -51,6 +51,10 @@ + + False + ..\..\..\..\lib\Plugins\Wti\WTIStability.dll + @@ -59,6 +63,7 @@ + Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.csproj =================================================================== diff -u -r4304327f96a967967877c287ed20f85d51255b41 -re53ef4c278a378cb5b3973dc939a19896f94b1cc --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.csproj) (revision 4304327f96a967967877c287ed20f85d51255b41) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.csproj) (revision e53ef4c278a378cb5b3973dc939a19896f94b1cc) @@ -43,6 +43,10 @@ + + False + ..\..\..\..\lib\Plugins\Wti\WTIStability.dll + Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/SubCalculator/UpliftVanCalculatorStub.cs =================================================================== diff -u -rd90619dfb54877db8067f27218c45ad4e5dab55d -re53ef4c278a378cb5b3973dc939a19896f94b1cc --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/SubCalculator/UpliftVanCalculatorStub.cs (.../UpliftVanCalculatorStub.cs) (revision d90619dfb54877db8067f27218c45ad4e5dab55d) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/SubCalculator/UpliftVanCalculatorStub.cs (.../UpliftVanCalculatorStub.cs) (revision e53ef4c278a378cb5b3973dc939a19896f94b1cc) @@ -19,8 +19,8 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using Deltares.WTIStability.Data.Geo; using Ringtoets.MacroStabilityInwards.KernelWrapper.SubCalculator; -using Ringtoets.MacroStabilityInwards.Primitives; namespace Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.SubCalculator { @@ -34,8 +34,10 @@ /// public bool Calculated { get; private set; } - public MacroStabilityInwardsSoilProfileUnderSurfaceLine SoilProfile { get; set; } + public SoilModel SoilModel { get; set; } + public SoilProfile2D SoilProfile { get; set; } + public void Calculate() { Calculated = true;