// 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 Core.Common.Base;
using Core.Common.Base.Data;
using Ringtoets.Common.Data.Calculation;
using Ringtoets.Common.Data.Hydraulics;
using Ringtoets.MacroStabilityInwards.Data.Properties;
using Ringtoets.MacroStabilityInwards.Data.SoilProfile;
using Ringtoets.MacroStabilityInwards.Primitives;
namespace Ringtoets.MacroStabilityInwards.Data
{
///
/// Class that holds all macro stability inwards calculation specific input parameters, i.e. the values
/// that can differ across various calculations.
///
public class MacroStabilityInwardsInput : CloneableObservable, ICalculationInput, IMacroStabilityInwardsWaternetInput
{
private static readonly Range tangentLineNumberValidityRange = new Range(1, 50);
private RoundedDouble assessmentLevel;
private RoundedDouble slipPlaneMinimumDepth;
private RoundedDouble slipPlaneMinimumLength;
private RoundedDouble maximumSliceWidth;
private RoundedDouble waterLevelRiverAverage;
private RoundedDouble xCoordinateDrainageConstruction;
private RoundedDouble zCoordinateDrainageConstruction;
private RoundedDouble minimumLevelPhreaticLineAtDikeTopRiver;
private RoundedDouble minimumLevelPhreaticLineAtDikeTopPolder;
private RoundedDouble leakageLengthOutwardsPhreaticLine3;
private RoundedDouble leakageLengthInwardsPhreaticLine3;
private RoundedDouble leakageLengthOutwardsPhreaticLine4;
private RoundedDouble leakageLengthInwardsPhreaticLine4;
private RoundedDouble piezometricHeadPhreaticLine2Outwards;
private RoundedDouble piezometricHeadPhreaticLine2Inwards;
private RoundedDouble tangentLineZTop;
private RoundedDouble tangentLineZBottom;
private RoundedDouble zoneBoundaryLeft;
private RoundedDouble zoneBoundaryRight;
private int tangentLineNumber;
///
/// Initializes a new instance of the class.
///
/// The container of the properties for the
/// .
/// Thrown when
/// is null.
/// Thrown when either:
///
/// - is smaller than ;
/// - is larger than ;
/// - is smaller than ;
/// - is larger than ;
/// - is larger than .
///
///
public MacroStabilityInwardsInput(ConstructionProperties properties)
{
if (properties == null)
{
throw new ArgumentNullException(nameof(properties));
}
if (!IsSmallerEqualOrNaN(properties.TangentLineZBottom, properties.TangentLineZTop))
{
throw new ArgumentException(Resources.MacroStabilityInwardsInput_TangentLineZTop_should_be_larger_than_or_equal_to_TangentLineZBottom);
}
assessmentLevel = new RoundedDouble(2, double.NaN);
slipPlaneMinimumDepth = new RoundedDouble(2);
slipPlaneMinimumLength = new RoundedDouble(2);
maximumSliceWidth = new RoundedDouble(2, 1);
MoveGrid = true;
DikeSoilScenario = MacroStabilityInwardsDikeSoilScenario.ClayDikeOnClay;
waterLevelRiverAverage = new RoundedDouble(2, double.NaN);
xCoordinateDrainageConstruction = new RoundedDouble(2, double.NaN);
zCoordinateDrainageConstruction = new RoundedDouble(2, double.NaN);
minimumLevelPhreaticLineAtDikeTopRiver = new RoundedDouble(2, double.NaN);
minimumLevelPhreaticLineAtDikeTopPolder = new RoundedDouble(2, double.NaN);
LocationInputExtreme = new MacroStabilityInwardsLocationInputExtreme();
LocationInputDaily = new MacroStabilityInwardsLocationInputDaily();
AdjustPhreaticLine3And4ForUplift = true;
leakageLengthOutwardsPhreaticLine3 = new RoundedDouble(2, double.NaN);
leakageLengthInwardsPhreaticLine3 = new RoundedDouble(2, double.NaN);
leakageLengthOutwardsPhreaticLine4 = new RoundedDouble(2, double.NaN);
leakageLengthInwardsPhreaticLine4 = new RoundedDouble(2, double.NaN);
piezometricHeadPhreaticLine2Outwards = new RoundedDouble(2, double.NaN);
piezometricHeadPhreaticLine2Inwards = new RoundedDouble(2, double.NaN);
GridDeterminationType = MacroStabilityInwardsGridDeterminationType.Automatic;
TangentLineDeterminationType = MacroStabilityInwardsTangentLineDeterminationType.LayerSeparated;
tangentLineZTop = new RoundedDouble(2, properties.TangentLineZTop);
tangentLineZBottom = new RoundedDouble(2, properties.TangentLineZBottom);
tangentLineNumber = 1;
LeftGrid = new MacroStabilityInwardsGrid(properties.LeftGridXLeft,
properties.LeftGridXRight,
properties.LeftGridZTop,
properties.LeftGridZBottom);
RightGrid = new MacroStabilityInwardsGrid(properties.RightGridXLeft,
properties.RightGridXRight,
properties.RightGridZTop,
properties.RightGridZBottom);
CreateZones = true;
ZoningBoundariesDeterminationType = MacroStabilityInwardsZoningBoundariesDeterminationType.Automatic;
zoneBoundaryLeft = new RoundedDouble(2, double.NaN);
zoneBoundaryRight = new RoundedDouble(2, double.NaN);
}
///
/// Gets or sets the stochastic soil model which is linked to the .
///
public MacroStabilityInwardsStochasticSoilModel StochasticSoilModel { get; set; }
///
/// Gets or sets the profile which contains a definition of soil layers with properties.
///
public MacroStabilityInwardsStochasticSoilProfile StochasticSoilProfile { get; set; }
///
/// Gets or sets the hydraulic boundary location from which to use the assessment level.
///
public HydraulicBoundaryLocation HydraulicBoundaryLocation { get; set; }
///
/// Gets or sets whether the assessment level is manual input for the calculation.
///
public bool UseAssessmentLevelManualInput { get; set; }
///
/// Gets or sets the surface line.
///
public MacroStabilityInwardsSurfaceLine SurfaceLine { get; set; }
public override object Clone()
{
var clone = (MacroStabilityInwardsInput) base.Clone();
clone.LocationInputExtreme = (IMacroStabilityInwardsLocationInputExtreme) ((MacroStabilityInwardsLocationInputExtreme) LocationInputExtreme).Clone();
clone.LocationInputDaily = (IMacroStabilityInwardsLocationInputDaily) ((MacroStabilityInwardsLocationInputDaily) LocationInputDaily).Clone();
clone.LeftGrid = (MacroStabilityInwardsGrid) LeftGrid.Clone();
clone.RightGrid = (MacroStabilityInwardsGrid) RightGrid.Clone();
return clone;
}
private static bool IsSmallerEqualOrNaN(double value, double valueToCompareTo)
{
return double.IsNaN(value) || double.IsNaN(valueToCompareTo) || value.CompareTo(valueToCompareTo + 1e-3) <= 0;
}
///
/// Container for properties for constructing a .
///
public class ConstructionProperties
{
///
/// Creates a new instance of .
///
public ConstructionProperties()
{
LeftGridXLeft = double.NaN;
LeftGridXRight = double.NaN;
LeftGridZTop = double.NaN;
LeftGridZBottom = double.NaN;
RightGridXLeft = double.NaN;
RightGridXRight = double.NaN;
RightGridZTop = double.NaN;
RightGridZBottom = double.NaN;
TangentLineZTop = double.NaN;
TangentLineZBottom = double.NaN;
}
///
/// Gets or sets the left boundary of the left grid.
///
public double LeftGridXLeft { internal get; set; }
///
/// Gets or sets the right boundary of the left grid.
///
public double LeftGridXRight { internal get; set; }
///
/// Gets or sets the top boundary of the left grid.
///
public double LeftGridZTop { internal get; set; }
///
/// Gets or sets the bottom boundary of the left grid.
///
public double LeftGridZBottom { internal get; set; }
///
/// Gets or sets the left boundary of the right grid.
///
public double RightGridXLeft { internal get; set; }
///
/// Gets or sets the right boundary of the right grid.
///
public double RightGridXRight { internal get; set; }
///
/// Gets or sets the top boundary of the right grid.
///
public double RightGridZTop { internal get; set; }
///
/// Gets or sets the bottom boundary of the right grid.
///
public double RightGridZBottom { internal get; set; }
///
/// Gets or sets the tangent line top boundary.
///
public double TangentLineZTop { internal get; set; }
///
/// Gets or sets the tangent line bottom boundary.
///
public double TangentLineZBottom { internal get; set; }
}
#region Derived input
///
/// Gets or sets the outside high water level.
/// [m+NAP]
///
public RoundedDouble AssessmentLevel
{
get
{
return assessmentLevel;
}
set
{
assessmentLevel = value.ToPrecision(assessmentLevel.NumberOfDecimalPlaces);
}
}
public IMacroStabilityInwardsSoilProfileUnderSurfaceLine SoilProfileUnderSurfaceLine
{
get
{
return SurfaceLine != null && StochasticSoilProfile != null
? MacroStabilityInwardsSoilProfileUnderSurfaceLineFactory.Create(StochasticSoilProfile.SoilProfile, SurfaceLine)
: null;
}
}
///
/// Gets the derived waternet calculation output under extreme circumstances.
///
public MacroStabilityInwardsWaternet WaternetExtreme
{
get
{
return new DerivedMacroStabilityInwardsInput(this).WaternetExtreme;
}
}
///
/// Gets the derived waternet calculation output under daily circumstances.
///
public MacroStabilityInwardsWaternet WaternetDaily
{
get
{
return new DerivedMacroStabilityInwardsInput(this).WaternetDaily;
}
}
#endregion
#region Settings
///
/// Gets or sets the minimum depth of the slip plane.
/// [m]
///
public RoundedDouble SlipPlaneMinimumDepth
{
get
{
return slipPlaneMinimumDepth;
}
set
{
slipPlaneMinimumDepth = value.ToPrecision(slipPlaneMinimumDepth.NumberOfDecimalPlaces);
}
}
///
/// Gets or sets the minimum length of the slip plane.
/// [m]
///
public RoundedDouble SlipPlaneMinimumLength
{
get
{
return slipPlaneMinimumLength;
}
set
{
slipPlaneMinimumLength = value.ToPrecision(slipPlaneMinimumLength.NumberOfDecimalPlaces);
}
}
///
/// Gets or sets the maximum slice width.
/// [m]
///
public RoundedDouble MaximumSliceWidth
{
get
{
return maximumSliceWidth;
}
set
{
maximumSliceWidth = value.ToPrecision(maximumSliceWidth.NumberOfDecimalPlaces);
}
}
///
/// Gets or sets the value whether the grid should be moved.
///
public bool MoveGrid { get; set; }
///
/// Gets or sets the grid determination type.
///
public MacroStabilityInwardsGridDeterminationType GridDeterminationType { get; set; }
///
/// Gets or sets the tangent line determination type.
///
public MacroStabilityInwardsTangentLineDeterminationType TangentLineDeterminationType { get; set; }
///
/// Gets or sets the tangent line top boundary.
/// [m+NAP]
///
/// Thrown when is smaller
/// than and is not .
public RoundedDouble TangentLineZTop
{
get
{
return tangentLineZTop;
}
set
{
if (!IsSmallerEqualOrNaN(TangentLineZBottom, value))
{
throw new ArgumentException(Resources.MacroStabilityInwardsInput_TangentLineZTop_should_be_larger_than_or_equal_to_TangentLineZBottom);
}
tangentLineZTop = value.ToPrecision(tangentLineZTop.NumberOfDecimalPlaces);
}
}
///
/// Gets or sets the tangent line bottom boundary.
/// [m+NAP]
///
/// Thrown when is larger
/// than and is not .
public RoundedDouble TangentLineZBottom
{
get
{
return tangentLineZBottom;
}
set
{
if (!IsSmallerEqualOrNaN(value, TangentLineZTop))
{
throw new ArgumentException(Resources.MacroStabilityInwardsInput_TangentLineZBottom_should_be_smaller_than_or_equal_to_TangentLineZTop);
}
tangentLineZBottom = value.ToPrecision(tangentLineZBottom.NumberOfDecimalPlaces);
}
}
///
/// Gets or sets the number of tangent lines.
///
/// Thrown when
/// is not in the [1, 50] interval.
public int TangentLineNumber
{
get
{
return tangentLineNumber;
}
set
{
if (!tangentLineNumberValidityRange.InRange(value))
{
throw new ArgumentOutOfRangeException(null, string.Format(Resources.TangentLineNumber_Value_needs_to_be_in_Range_0_,
tangentLineNumberValidityRange));
}
tangentLineNumber = value;
}
}
///
/// Gets the left grid.
///
public MacroStabilityInwardsGrid LeftGrid { get; private set; }
///
/// Gets the right grid.
///
public MacroStabilityInwardsGrid RightGrid { get; private set; }
#endregion
#region Hydraulics
///
/// Gets or sets the dike soil scenario.
///
public MacroStabilityInwardsDikeSoilScenario DikeSoilScenario { get; set; }
///
/// Gets or sets the average river water level.
/// [m+NAP]
///
public RoundedDouble WaterLevelRiverAverage
{
get
{
return waterLevelRiverAverage;
}
set
{
waterLevelRiverAverage = value.ToPrecision(waterLevelRiverAverage.NumberOfDecimalPlaces);
}
}
///
/// Gets or sets whether a drainage construction is present.
///
public bool DrainageConstructionPresent { get; set; }
///
/// Gets or sets the x coordinate of the drainage construction.
/// [m]
///
public RoundedDouble XCoordinateDrainageConstruction
{
get
{
return xCoordinateDrainageConstruction;
}
set
{
xCoordinateDrainageConstruction = value.ToPrecision(xCoordinateDrainageConstruction.NumberOfDecimalPlaces);
}
}
///
/// Gets or sets the z coordinate of the drainage construction.
/// [m+NAP]
///
public RoundedDouble ZCoordinateDrainageConstruction
{
get
{
return zCoordinateDrainageConstruction;
}
set
{
zCoordinateDrainageConstruction = value.ToPrecision(zCoordinateDrainageConstruction.NumberOfDecimalPlaces);
}
}
///
/// Gets or sets the minimum level phreatic line at dike top river.
/// [m+NAP]
///
public RoundedDouble MinimumLevelPhreaticLineAtDikeTopRiver
{
get
{
return minimumLevelPhreaticLineAtDikeTopRiver;
}
set
{
minimumLevelPhreaticLineAtDikeTopRiver = value.ToPrecision(minimumLevelPhreaticLineAtDikeTopRiver.NumberOfDecimalPlaces);
}
}
///
/// Gets or sets the minimum level phreatic line at dike top polder.
/// [m+NAP]
///
public RoundedDouble MinimumLevelPhreaticLineAtDikeTopPolder
{
get
{
return minimumLevelPhreaticLineAtDikeTopPolder;
}
set
{
minimumLevelPhreaticLineAtDikeTopPolder = value.ToPrecision(minimumLevelPhreaticLineAtDikeTopPolder.NumberOfDecimalPlaces);
}
}
///
/// Gets or sets whether phreatic line 3 and 4 should be adjusted for Uplift.
///
public bool AdjustPhreaticLine3And4ForUplift { get; set; }
///
/// Gets or sets the leakage length outwards of phreatic line 3.
/// [m]
///
public RoundedDouble LeakageLengthOutwardsPhreaticLine3
{
get
{
return leakageLengthOutwardsPhreaticLine3;
}
set
{
leakageLengthOutwardsPhreaticLine3 = value.ToPrecision(leakageLengthOutwardsPhreaticLine3.NumberOfDecimalPlaces);
}
}
///
/// Gets or sets the leakage length inwards of phreatic line 3.
/// [m]
///
public RoundedDouble LeakageLengthInwardsPhreaticLine3
{
get
{
return leakageLengthInwardsPhreaticLine3;
}
set
{
leakageLengthInwardsPhreaticLine3 = value.ToPrecision(leakageLengthInwardsPhreaticLine3.NumberOfDecimalPlaces);
}
}
///
/// Gets or sets the leakage length outwards of phreatic line 4.
/// [m]
///
public RoundedDouble LeakageLengthOutwardsPhreaticLine4
{
get
{
return leakageLengthOutwardsPhreaticLine4;
}
set
{
leakageLengthOutwardsPhreaticLine4 = value.ToPrecision(leakageLengthOutwardsPhreaticLine4.NumberOfDecimalPlaces);
}
}
///
/// Gets or sets the leakage length inwards of phreatic line 4.
/// [m]
///
public RoundedDouble LeakageLengthInwardsPhreaticLine4
{
get
{
return leakageLengthInwardsPhreaticLine4;
}
set
{
leakageLengthInwardsPhreaticLine4 = value.ToPrecision(leakageLengthInwardsPhreaticLine4.NumberOfDecimalPlaces);
}
}
///
/// Gets or sets the piezometric head of the phreatic line 2 outwards.
/// [m+NAP]
///
public RoundedDouble PiezometricHeadPhreaticLine2Outwards
{
get
{
return piezometricHeadPhreaticLine2Outwards;
}
set
{
piezometricHeadPhreaticLine2Outwards = value.ToPrecision(piezometricHeadPhreaticLine2Outwards.NumberOfDecimalPlaces);
}
}
///
/// Gets or sets the piezometric head of the phreatic line 2 inwards.
/// [m+NAP]
///
public RoundedDouble PiezometricHeadPhreaticLine2Inwards
{
get
{
return piezometricHeadPhreaticLine2Inwards;
}
set
{
piezometricHeadPhreaticLine2Inwards = value.ToPrecision(piezometricHeadPhreaticLine2Inwards.NumberOfDecimalPlaces);
}
}
public IMacroStabilityInwardsLocationInputExtreme LocationInputExtreme { get; private set; }
public IMacroStabilityInwardsLocationInputDaily LocationInputDaily { get; private set; }
///
/// Gets or sets whether zones should be created.
///
public bool CreateZones { get; set; }
///
/// Gets or sets the zoning boundaries determination type.
///
public MacroStabilityInwardsZoningBoundariesDeterminationType ZoningBoundariesDeterminationType { get; set; }
///
/// Gets or sets the left zone boundary.
/// [m]
///
public RoundedDouble ZoneBoundaryLeft
{
get
{
return zoneBoundaryLeft;
}
set
{
zoneBoundaryLeft = value.ToPrecision(zoneBoundaryLeft.NumberOfDecimalPlaces);
}
}
///
/// Gets or sets the right zone boundary.
/// [m]
///
public RoundedDouble ZoneBoundaryRight
{
get
{
return zoneBoundaryRight;
}
set
{
zoneBoundaryRight = value.ToPrecision(zoneBoundaryRight.NumberOfDecimalPlaces);
}
}
#endregion
}
}