// 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.ComponentModel;
using Deltares.WaternetCreator;
using Deltares.WTIStability;
using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.UpliftVan.Input;
using Ringtoets.MacroStabilityInwards.KernelWrapper.Kernels.UpliftVan;
using Ringtoets.MacroStabilityInwards.Primitives;
using PlLineCreationMethod = Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.Input.PlLineCreationMethod;
using WaternetCreationMode = Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.Input.WaternetCreationMode;
using WTIStabilityPlLineCreationMethod = Deltares.WaternetCreator.PlLineCreationMethod;
using WTIStabilityWaternetCreationMode = Deltares.WaternetCreator.WaternetCreationMode;
namespace Ringtoets.MacroStabilityInwards.KernelWrapper.Creators.Input
{
///
/// Creates instances which are required by .
///
internal static class StabilityLocationCreator
{
///
/// Creates a based on the given under extreme circumstances,
/// which can be used by .
///
/// The to get the information from.
/// A new with the given information from .
/// Thrown when is null.
/// Thrown when ,
/// or
/// is an invalid value.
/// Thrown when ,
/// or
/// is a valid value but unsupported.
public static StabilityLocation CreateExtreme(UpliftVanCalculatorInput input)
{
if (input == null)
{
throw new ArgumentNullException(nameof(input));
}
return new StabilityLocation
{
DikeSoilScenario = ConvertDikeSoilScenario(input.DikeSoilScenario),
WaternetCreationMode = ConvertWaternetCreationMode(input.WaternetCreationMode),
PlLineCreationMethod = ConvertPlLineCreationMethod(input.PlLineCreationMethod),
WaterLevelRiver = input.AssessmentLevel,
WaterLevelRiverAverage = input.WaterLevelRiverAverage,
WaterLevelPolder = input.WaterLevelPolderExtreme,
DrainageConstructionPresent = input.DrainageConstruction.IsPresent,
XCoordMiddleDrainageConstruction = input.DrainageConstruction.XCoordinate,
ZCoordMiddleDrainageConstruction = input.DrainageConstruction.ZCoordinate,
MinimumLevelPhreaticLineAtDikeTopRiver = input.MinimumLevelPhreaticLineAtDikeTopRiver,
MinimumLevelPhreaticLineAtDikeTopPolder = input.MinimumLevelPhreaticLineAtDikeTopPolder,
UseDefaultOffsets = input.PhreaticLineOffsetsExtreme.UseDefaults,
PlLineOffsetBelowPointBRingtoetsWti2017 = input.PhreaticLineOffsetsExtreme.BelowDikeTopAtRiver,
PlLineOffsetBelowDikeTopAtPolder = input.PhreaticLineOffsetsExtreme.BelowDikeTopAtPolder,
PlLineOffsetBelowShoulderBaseInside = input.PhreaticLineOffsetsExtreme.BelowShoulderBaseInside,
PlLineOffsetBelowDikeToeAtPolder = input.PhreaticLineOffsetsExtreme.BelowDikeToeAtPolder,
AdjustPl3And4ForUplift = input.AdjustPhreaticLine3And4ForUplift,
LeakageLengthOutwardsPl3 = input.LeakageLengthOutwardsPhreaticLine3,
LeakageLengthInwardsPl3 = input.LeakageLengthInwardsPhreaticLine3,
LeakageLengthOutwardsPl4 = input.LeakageLengthOutwardsPhreaticLine4,
LeakageLengthInwardsPl4 = input.LeakageLengthInwardsPhreaticLine4,
HeadInPlLine2Outwards = input.PiezometricHeadPhreaticLine2Outwards,
HeadInPlLine2Inwards = input.PiezometricHeadPhreaticLine2Inwards,
PenetrationLength = input.PenetrationLength
};
}
///
/// Creates a based on the given under daily circumstances,
/// which can be used by .
///
/// The to get the information from.
/// A new with the given information from .
/// Thrown when is null.
/// Thrown when ,
/// or
/// is an invalid value.
/// Thrown when ,
/// or
/// is a valid value but unsupported.
public static StabilityLocation CreateDaily(UpliftVanCalculatorInput input)
{
if (input == null)
{
throw new ArgumentNullException(nameof(input));
}
return new StabilityLocation
{
DikeSoilScenario = ConvertDikeSoilScenario(input.DikeSoilScenario),
WaternetCreationMode = ConvertWaternetCreationMode(input.WaternetCreationMode),
PlLineCreationMethod = ConvertPlLineCreationMethod(input.PlLineCreationMethod),
WaterLevelRiver = input.WaterLevelRiverAverage,
WaterLevelRiverAverage = input.WaterLevelRiverAverage,
WaterLevelPolder = input.WaterLevelPolderDaily,
DrainageConstructionPresent = input.DrainageConstruction.IsPresent,
XCoordMiddleDrainageConstruction = input.DrainageConstruction.XCoordinate,
ZCoordMiddleDrainageConstruction = input.DrainageConstruction.ZCoordinate,
MinimumLevelPhreaticLineAtDikeTopRiver = input.MinimumLevelPhreaticLineAtDikeTopRiver,
MinimumLevelPhreaticLineAtDikeTopPolder = input.MinimumLevelPhreaticLineAtDikeTopPolder,
UseDefaultOffsets = input.PhreaticLineOffsetsDaily.UseDefaults,
PlLineOffsetBelowPointBRingtoetsWti2017 = input.PhreaticLineOffsetsDaily.BelowDikeTopAtRiver,
PlLineOffsetBelowDikeTopAtPolder = input.PhreaticLineOffsetsDaily.BelowDikeTopAtPolder,
PlLineOffsetBelowShoulderBaseInside = input.PhreaticLineOffsetsDaily.BelowShoulderBaseInside,
PlLineOffsetBelowDikeToeAtPolder = input.PhreaticLineOffsetsDaily.BelowDikeToeAtPolder,
AdjustPl3And4ForUplift = input.AdjustPhreaticLine3And4ForUplift,
LeakageLengthOutwardsPl3 = input.LeakageLengthOutwardsPhreaticLine3,
LeakageLengthInwardsPl3 = input.LeakageLengthInwardsPhreaticLine3,
LeakageLengthOutwardsPl4 = input.LeakageLengthOutwardsPhreaticLine4,
LeakageLengthInwardsPl4 = input.LeakageLengthInwardsPhreaticLine4,
HeadInPlLine2Outwards = input.PiezometricHeadPhreaticLine2Outwards,
HeadInPlLine2Inwards = input.PiezometricHeadPhreaticLine2Inwards,
PenetrationLength = 0.0
};
}
///
/// Converts a into a .
///
/// The to convert.
/// A based on .
/// Thrown when
/// is an invalid value.
/// Thrown when
/// is a valid value but unsupported.
private static DikeSoilScenario ConvertDikeSoilScenario(MacroStabilityInwardsDikeSoilScenario dikeSoilScenario)
{
if (!Enum.IsDefined(typeof(MacroStabilityInwardsDikeSoilScenario), dikeSoilScenario))
{
throw new InvalidEnumArgumentException(nameof(dikeSoilScenario),
(int) dikeSoilScenario,
typeof(MacroStabilityInwardsDikeSoilScenario));
}
switch (dikeSoilScenario)
{
case MacroStabilityInwardsDikeSoilScenario.ClayDikeOnClay:
return DikeSoilScenario.ClayDikeOnClay;
case MacroStabilityInwardsDikeSoilScenario.SandDikeOnClay:
return DikeSoilScenario.SandDikeOnClay;
case MacroStabilityInwardsDikeSoilScenario.ClayDikeOnSand:
return DikeSoilScenario.ClayDikeOnSand;
case MacroStabilityInwardsDikeSoilScenario.SandDikeOnSand:
return DikeSoilScenario.SandDikeOnSand;
default:
throw new NotSupportedException();
}
}
///
/// Converts a into a .
///
/// The to convert.
/// A based on .
/// Thrown when
/// is an invalid value.
/// Thrown when
/// is a valid value but unsupported.
private static WTIStabilityWaternetCreationMode ConvertWaternetCreationMode(WaternetCreationMode waternetCreationMode)
{
if (!Enum.IsDefined(typeof(WaternetCreationMode), waternetCreationMode))
{
throw new InvalidEnumArgumentException(nameof(waternetCreationMode),
(int) waternetCreationMode,
typeof(WaternetCreationMode));
}
switch (waternetCreationMode)
{
case WaternetCreationMode.CreateWaternet:
return WTIStabilityWaternetCreationMode.CreateWaternet;
case WaternetCreationMode.FillInWaternetValues:
return WTIStabilityWaternetCreationMode.FillInWaternetValues;
default:
throw new NotSupportedException();
}
}
///
/// Converts a into a .
///
/// The to convert.
/// A based on .
/// Thrown when
/// is an invalid value.
/// Thrown when
/// is a valid value but unsupported.
private static WTIStabilityPlLineCreationMethod ConvertPlLineCreationMethod(PlLineCreationMethod plLineCreationMethod)
{
if (!Enum.IsDefined(typeof(PlLineCreationMethod), plLineCreationMethod))
{
throw new InvalidEnumArgumentException(nameof(plLineCreationMethod),
(int) plLineCreationMethod,
typeof(PlLineCreationMethod));
}
switch (plLineCreationMethod)
{
case PlLineCreationMethod.ExpertKnowledgeRrd:
return WTIStabilityPlLineCreationMethod.ExpertKnowledgeRrd;
case PlLineCreationMethod.ExpertKnowledgeLinearInDike:
return WTIStabilityPlLineCreationMethod.ExpertKnowledgeLinearInDike;
case PlLineCreationMethod.RingtoetsWti2017:
return WTIStabilityPlLineCreationMethod.RingtoetsWti2017;
case PlLineCreationMethod.DupuitStatic:
return WTIStabilityPlLineCreationMethod.DupuitStatic;
case PlLineCreationMethod.DupuitDynamic:
return WTIStabilityPlLineCreationMethod.DupuitDynamic;
case PlLineCreationMethod.Sensors:
return WTIStabilityPlLineCreationMethod.Sensors;
case PlLineCreationMethod.None:
return WTIStabilityPlLineCreationMethod.None;
default:
throw new NotSupportedException();
}
}
}
}