// Copyright (C) Stichting Deltares 2018. All rights reserved.
//
// This file is part of the Dam Engine.
//
// The Dam Engine is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero 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.ComponentModel;
using System.Globalization;
using System.Linq;
using Deltares.DamEngine.Data.Design;
using Deltares.DamEngine.Data.General.Gauges;
using Deltares.DamEngine.Data.General.PlLines;
using Deltares.DamEngine.Data.General.Sensors;
using Deltares.DamEngine.Data.Geometry;
using Deltares.DamEngine.Data.Geotechnics;
using Deltares.DamEngine.Data.Probabilistic;
using Deltares.DamEngine.Data.Standard.Language;
using Deltares.DamEngine.Data.Standard.Validation;
namespace Deltares.DamEngine.Data.General
{
public class Location
{
// Added initial value as these properties must be tested for real values on import
private const double BoezemLevelNotSetValue = -987654321.0;
private const double newDikeTopWidthMinValue = 0.1;
private const double newDikeSlopeInsideMinValue = 0.01;
private const double newDikeSlopeOutsideMinValue = 0.01;
private const double penetrationLenghtMinValue = 0.00;
private static DamProjectType damProjectType = DamProjectType.Operational;
private readonly List scenarios = new List();
private bool areLocalXZObjectsCreated = false;
private double boezemLevelHbp = BoezemLevelNotSetValue;
private double boezemLevelLbp = BoezemLevelNotSetValue;
private double boezemLevelTp = BoezemLevelNotSetValue;
private ModelParametersForPLLines modelParametersForPLLines = new ModelParametersForPLLines();
private DamType damType = DamType.Primary;
private string description = "";
private double detrimentFactor = 0.95;
private string dikeEmbankmentMaterial = "";
private SoilType dikeMaterialType = SoilType.Clay;
private double dikeTableHeight = 0.0;
private double dredgingDepth = 0;
private IList gaugePLLines = new List();
private IList gauges = new List();
private double? headPL2 = null;
private double? headPL3 = null;
private double? headPL4 = null;
private bool isUseOriginalPLLineAssignments = false;
private double layerHeightDeviation = 0;
private DistributionType layerHeightDistribution = 0;
// Start of parameters that are also defined in modelparameters
private double levelReductionInside = 0;
private double levelReductionOutside = 0;
private PL1Line localXZPL1Line;
private GeometryPoint localXZSheetPilePoint;
private StabilityOptions stabilityOptions;
private ModelFactors modelFactors = new ModelFactors();
private string name = "";
private double newDepthDitch = 1.0;
private double newDikeSlopeInside = 1.0/3.0; // as tangent
private double newDikeSlopeOutside = 1.0/3.0; // as tangent
private double newDikeTopWidth = 5.0;
private double newMaxHeightShoulderAsFraction = 2.0/3.0; // as tangent
private double newMinDistanceDikeToeStartDitch = 5.0;
private double newShoulderBaseSlope = 1.0/3.0; // as tangent
private double newShoulderTopSlope = 1.0/20.0; // as tangent
private double newSlopeAngleDitch = 1.0/0.5; // as tangent
private double newWidthDitchBottom = 1.0;
private PL1Line pL1Line;
private double pLLineOffsetBelowDikeToeAtPolder = 0.1;
private double pLLineOffsetBelowDikeTopAtPolder = 1.5;
private double pLLineOffsetBelowDikeTopAtRiver = 0.5;
private double pLLineOffsetBelowShoulderBaseInside = 0.1;
private double pLLineOffsetDryBelowDikeToeAtPolder = 0.1;
private double pLLineOffsetDryBelowDikeTopAtPolder = 1.5;
private double pLLineOffsetDryBelowDikeTopAtRiver = 0.5;
private double pLLineOffsetDryBelowShoulderBaseInside = 0.1;
private double polderLevel = 0;
private double polderLevelLow = 0;
private bool redesignDikeHeight = true;
private bool redesignDikeShoulder = true;
private double rwBankProtectionBottomLevel = 0;
private double scenarioRiverLevel = 0;
private Segment segment;
private SensorLocation sensorData;
private double sheetPileLength = 0;
private GeometryPoint sheetPilePoint = new GeometryPoint();
private string shoulderEmbankmentMaterial = "";
private double slopeAdaptionEndCotangent = 6.0;
private double slopeAdaptionStartCotangent = 3.0;
private double slopeAdaptionStepCotangent = 0.5;
private double slopeDampingPiezometricHeightPolderSide = 0.0;
private SoilSurfaceProfile soilSurfaceProfile = null;
private string soildatabaseName = "";
private StabilityDesignMethod stabilityDesignMethod = StabilityDesignMethod.OptimizedSlopeAndShoulderAdaption;
private double stabilityShoulderGrowDeltaX = 2.0;
private double stabilityShoulderGrowSlope = 1.0/3;
private double stabilitySlopeAdaptionDeltaX = 2.0;
private string surfaceLineId = "";
private bool useNewDikeSlopeInside;
private bool useNewDikeSlopeOutside;
private bool useNewDikeTopWidth;
private bool useNewDitchDefinition;
private bool useNewMaxHeightShoulderAsFraction;
private bool useNewMinDistanceDikeToeStartDitch;
private bool useNewShoulderBaseSlope;
private bool useNewShoulderTopSlope;
private double xRdDikeLine;
private double xSoilGeometry2DOrigin = 0;
private double xrd = 0;
private double yrd = 0;
private double? plLineOffsetFactorBelowShoulderCrest;
private double? plLineOffsetBelowDikeCrestMiddle;
private double? plLineOffsetDryFactorBelowShoulderCrest;
private double? plLineOffsetDryBelowDikeCrestMiddle;
private IntrusionVerticalWaterPressureType? intrusionVerticalWaterPressure = IntrusionVerticalWaterPressureType.Standard;
public Location()
{
SoilList = null;
}
///
/// Initializes a new instance of the class.
///
/// The name.
public Location(string name) : this()
{
this.name = name;
}
public bool HasSensorData
{
get
{
return sensorData != null;
}
}
public virtual SensorLocation SensorData
{
get
{
return sensorData;
}
set
{
sensorData = value;
sensorData.Location = this;
}
}
public virtual bool AreLocalXZObjectsCreated
{
get
{
return areLocalXZObjectsCreated;
}
set
{
areLocalXZObjectsCreated = value;
}
}
public virtual string Name
{
get
{
return name;
}
set
{
name = value;
}
}
public virtual string Description
{
get
{
return description;
}
set
{
description = value;
}
}
public virtual double XRd
{
get
{
return xrd;
}
set
{
xrd = value;
}
}
public virtual double YRd
{
get
{
return yrd;
}
set
{
yrd = value;
}
}
public virtual double XRdDikeLine
{
get
{
return xRdDikeLine;
}
set
{
xRdDikeLine = value;
}
}
public virtual double XSoilGeometry2DOrigin
{
get
{
return xSoilGeometry2DOrigin;
}
set
{
xSoilGeometry2DOrigin = value;
}
}
public virtual double DredgingDepth
{
get
{
return dredgingDepth;
}
set
{
dredgingDepth = value;
}
}
public virtual SoilType DikeMaterialType
{
get
{
return dikeMaterialType;
}
set
{
dikeMaterialType = value;
}
}
public virtual GeometryPoint SheetPilePoint
{
get
{
return sheetPilePoint;
}
set
{
sheetPilePoint = value;
}
}
public virtual double SheetPilePointX
{
get
{
return SheetPilePoint.X;
}
set
{
SheetPilePoint.X = value;
}
}
public virtual double SheetPilePointY
{
get
{
return SheetPilePoint.Y;
}
set
{
SheetPilePoint.Y = value;
}
}
[Browsable(false)]public virtual double SheetPilePointZ
{
get
{
return SheetPilePoint.Z;
}
set
{
SheetPilePoint.Z = value;
}
}
public virtual double SheetPileLength
{
get
{
return sheetPileLength;
}
set
{
sheetPileLength = value;
}
}
public virtual double RwBankProtectionBottomLevel
{
get
{
return rwBankProtectionBottomLevel;
}
set
{
rwBankProtectionBottomLevel = value;
}
}
public virtual bool IsUseOriginalPLLineAssignments
{
get
{
return isUseOriginalPLLineAssignments;
}
set
{
isUseOriginalPLLineAssignments = value;
}
}
public virtual PL1Line PL1Line
{
get
{
return pL1Line;
}
set
{
pL1Line = value;
}
}
public virtual PL1Line LocalXZPL1Line
{
get
{
return localXZPL1Line;
}
set
{
localXZPL1Line = value;
}
}
///
/// The surfaceline in local coordinates
///
/// Composite relationship.
[Validate]
public virtual SurfaceLine2 SurfaceLine { get; set; }
public virtual GeometryPoint LocalXZSheetPilePoint
{
get
{
return localXZSheetPilePoint;
}
set
{
localXZSheetPilePoint = value;
}
}
///
/// Gets or sets the Segment
///
public virtual Segment Segment
{
get
{
return segment;
}
set
{
segment = value;
}
}
public virtual double LevelReductionInside
{
get
{
return levelReductionInside;
}
set
{
levelReductionInside = value;
}
}
public virtual double LevelReductionOutside
{
get
{
return levelReductionOutside;
}
set
{
levelReductionOutside = value;
}
}
public virtual ModelFactors ModelFactors
{
get
{
return modelFactors;
}
set
{
modelFactors = value;
}
}
public virtual double? UpliftCriterionStability
{
get
{
return ModelFactors.UpliftCriterionStability;
}
set
{
ModelFactors.UpliftCriterionStability = value;
}
}
public virtual double? UpliftCriterionPiping
{
get
{
return ModelFactors.UpliftCriterionPiping;
}
set
{
ModelFactors.UpliftCriterionPiping = value;
}
}
public virtual DistributionType LayerHeightDistribution
{
get
{
return layerHeightDistribution;
}
set
{
layerHeightDistribution = value;
}
}
public virtual double LayerHeightDeviation
{
get
{
return layerHeightDeviation;
}
set
{
layerHeightDeviation = value;
}
}
public virtual double DetrimentFactor
{
get
{
return detrimentFactor;
}
set
{
detrimentFactor = value;
}
}
public virtual double SlopeDampingPiezometricHeightPolderSide
{
get
{
return slopeDampingPiezometricHeightPolderSide;
}
set
{
slopeDampingPiezometricHeightPolderSide = value;
}
}
public virtual double DikeTableHeight
{
get
{
return dikeTableHeight;
}
set
{
dikeTableHeight = value;
}
}
public DamType DamType
{
get
{
return damType;
}
set
{
damType = value;
}
}
public string SurfaceLineId
{
get
{
return surfaceLineId;
}
set
{
surfaceLineId = value;
}
}
public string SoildatabaseName
{
get
{
return soildatabaseName;
}
set
{
soildatabaseName = value;
}
}
public SoilList SoilList { get; set; }
public virtual IList Gauges
{
get
{
return gauges;
}
set
{
gauges = value;
}
}
public virtual IList GaugePLLines
{
get
{
return gaugePLLines;
}
set
{
gaugePLLines = value;
}
}
public bool UsesGauges
{
get
{
return GaugePLLines != null && GaugePLLines.Count > 0 && Gauges != null;
}
}
public double GaugeMissVal { get; set; }
public bool RedesignDikeHeight
{
get
{
return redesignDikeHeight;
}
set
{
redesignDikeHeight = value;
}
}
public bool RedesignDikeShoulder
{
get
{
return redesignDikeShoulder;
}
set
{
redesignDikeShoulder = value;
}
}
public StabilityDesignMethod StabilityDesignMethod
{
get
{
return stabilityDesignMethod;
}
set
{
stabilityDesignMethod = value;
}
}
public double SlopeAdaptionStartCotangent
{
get
{
return slopeAdaptionStartCotangent;
}
set
{
slopeAdaptionStartCotangent = value;
}
}
public double SlopeAdaptionEndCotangent
{
get
{
return slopeAdaptionEndCotangent;
}
set
{
slopeAdaptionEndCotangent = value;
}
}
public double SlopeAdaptionStepCotangent
{
get
{
return slopeAdaptionStepCotangent;
}
set
{
slopeAdaptionStepCotangent = value;
}
}
public bool UseNewDikeTopWidth
{
get
{
return useNewDikeTopWidth;
}
set
{
useNewDikeTopWidth = value;
}
}
public double NewDikeTopWidth
{
get
{
return newDikeTopWidth;
}
set
{
newDikeTopWidth = value;
}
}
public bool UseNewDikeSlopeInside
{
get
{
return useNewDikeSlopeInside;
}
set
{
useNewDikeSlopeInside = value;
}
}
public double NewDikeSlopeInside
{
get
{
return newDikeSlopeInside;
}
set
{
newDikeSlopeInside = value;
}
}
public bool UseNewDikeSlopeOutside
{
get
{
return useNewDikeSlopeOutside;
}
set
{
useNewDikeSlopeOutside = value;
}
}
public double NewDikeSlopeOutside
{
get
{
return newDikeSlopeOutside;
}
set
{
newDikeSlopeOutside = value;
}
}
public bool UseNewShoulderTopSlope
{
get
{
return useNewShoulderTopSlope;
}
set
{
useNewShoulderTopSlope = value;
}
}
public double NewShoulderTopSlope
{
get
{
return newShoulderTopSlope;
}
set
{
newShoulderTopSlope = value;
}
}
public bool UseNewShoulderBaseSlope
{
get
{
return useNewShoulderBaseSlope;
}
set
{
useNewShoulderBaseSlope = value;
}
}
public double NewShoulderBaseSlope
{
get
{
return newShoulderBaseSlope;
}
set
{
newShoulderBaseSlope = value;
}
}
public bool UseNewMaxHeightShoulderAsFraction
{
get
{
return useNewMaxHeightShoulderAsFraction;
}
set
{
useNewMaxHeightShoulderAsFraction = value;
}
}
public double NewMaxHeightShoulderAsFraction
{
get
{
return newMaxHeightShoulderAsFraction;
}
set
{
newMaxHeightShoulderAsFraction = value;
}
}
public bool UseNewMinDistanceDikeToeStartDitch
{
get
{
return useNewMinDistanceDikeToeStartDitch;
}
set
{
useNewMinDistanceDikeToeStartDitch = value;
}
}
public double NewMinDistanceDikeToeStartDitch
{
get
{
return newMinDistanceDikeToeStartDitch;
}
set
{
newMinDistanceDikeToeStartDitch = value;
}
}
public bool UseNewDitchDefinition
{
get
{
return useNewDitchDefinition;
}
set
{
useNewDitchDefinition = value;
}
}
public double NewWidthDitchBottom
{
get
{
return newWidthDitchBottom;
}
set
{
newWidthDitchBottom = value;
}
}
public double NewSlopeAngleDitch
{
get
{
return newSlopeAngleDitch;
}
set
{
newSlopeAngleDitch = value;
}
}
public double NewDepthDitch
{
get
{
return newDepthDitch;
}
set
{
newDepthDitch = value;
}
}
[Validate]
public List Scenarios
{
get
{
return scenarios;
}
}
public static DamProjectType DamProjectType
{
get
{
return damProjectType;
}
set
{
damProjectType = value;
}
}
#region IGeographic Members
public StabilityOptions StabilityOptions
{
get
{
return stabilityOptions;
}
set
{
stabilityOptions = value;
}
}
public double X
{
get
{
return XRd;
}
set
{
XRd = value;
}
}
public double Y
{
get
{
return YRd;
}
set
{
YRd = value;
}
}
///
/// Ensure proper Safety Factors for zone type areas by always using the detriment factor.
///
public void EnsureProperZoneSafetyFactors()
{
if (modelFactors != null)
{
// For regional assessment, automatically fill with the detriment factor instead of error message and repairer (MWDAM-748)
if (DamType == DamType.Regional && DamProjectType == DamProjectType.Assessment)
{
modelFactors.RequiredSafetyFactorStabilityInnerSlope = detrimentFactor;
}
}
}
///
/// Checks whether the required safety (stability inner slope) is given as that is needed to work with zone areas.
///
///
[Validate]
public ValidationResult[] IsRequiredSafetySetForZoneTypeArea()
{
if (stabilityOptions != null && stabilityOptions.StabilityZoneType == MStabZonesType.ZoneAreas)
{
// For design projects, the safetey must be defined per scenario, not per location
if (DamProjectType == DamProjectType.Design && scenarios != null && scenarios.Count > 0)
{
foreach (var scenario in scenarios)
{
if (scenario.ModelFactors.RequiredSafetyFactorStabilityInnerSlope == null)
{
return new[]
{
new ValidationResult(ValidationResultType.Error, LocalizationManager.GetTranslatedText(
this, "NoRequiredSafetyForZonesScenario"), scenario)
};
}
}
}
else
{
if (modelFactors.RequiredSafetyFactorStabilityInnerSlope == null)
{
return new[]
{
new ValidationResult(ValidationResultType.Error, LocalizationManager.GetTranslatedText(
this, "NoRequiredSafetyForZones"), this)
};
}
}
}
return new ValidationResult[0];
}
[Validate]
public ValidationResult[] ValidateDikeEmbankmentMaterial()
{
if (DamProjectType == DamProjectType.Design && !HasValidDikeEmbankmentMaterial())
{
return new[]
{
new ValidationResult(ValidationResultType.Error, LocalizationManager.GetTranslatedText(
this, "NoDikeEmbankmentMaterial"), this)
};
}
else
{
return new ValidationResult[0];
}
}
[Validate]
public ValidationResult[] ValidateLocationNewDikeTopWidth()
{
if (DamProjectType == DamProjectType.Design)
{
if ((UseNewDikeTopWidth) && (NewDikeTopWidth < newDikeTopWidthMinValue))
{
return new[]
{
new ValidationResult(ValidationResultType.Error, String.Format(
LocalizationManager.GetTranslatedText(this, "NewDikeTopWidthRangeError"),
newDikeTopWidthMinValue), this)
};
}
}
return new ValidationResult[0];
}
[Validate]
public ValidationResult[] ValidateLocationNewDikeSlopeInside()
{
if (DamProjectType == DamProjectType.Design)
{
if ((UseNewDikeSlopeInside) && (NewDikeSlopeInside < newDikeSlopeInsideMinValue))
{
return new[]
{
new ValidationResult(ValidationResultType.Error, String.Format(
LocalizationManager.GetTranslatedText(this, "NewDikeSlopeInsideRangeError"),
newDikeSlopeInsideMinValue), this)
};
}
}
return new ValidationResult[0];
}
[Validate]
public ValidationResult[] ValidateLocationNewDikeSlopeOutside()
{
if (DamProjectType == DamProjectType.Design)
{
if ((UseNewDikeSlopeOutside) && (NewDikeSlopeOutside < newDikeSlopeOutsideMinValue))
{
return new[]
{
new ValidationResult(ValidationResultType.Error, String.Format(LocalizationManager.
GetTranslatedText(this, "NewDikeSlopeOutsideRangeError"),
newDikeSlopeOutsideMinValue), this)
};
}
}
return new ValidationResult[0];
}
///
/// Validates the use of the penetration length.
///
/// Validation result
[Validate]
public ValidationResult[] ValidateLocationUseOfPenetrationLength()
{
if (modelParametersForPLLines.PenetrationLength > 0)
{
// It may be used on 1D geometries
if (!String.IsNullOrEmpty(this.Segment.GetMostProbableGeometry2DName(FailureMechanismSystemType.StabilityInside)))
{
// It may be used on 2D geometries only if condition below is true
if (this.IntrusionVerticalWaterPressure != IntrusionVerticalWaterPressureType.SemiTimeDependent)
{
return new[]
{
new ValidationResult(ValidationResultType.Error, String.Format(
LocalizationManager.GetTranslatedText(this, "UseOfPenetrationLengthError"),
penetrationLenghtMinValue), this)
};
}
}
}
return new ValidationResult[0];
}
[Validate]
public ValidationResult[] ValidateShoulderEmbankmentMaterial()
{
if (DamProjectType == DamProjectType.Design && !HasValidShoulderEmbankmentMaterial())
{
return new[]
{
new ValidationResult(ValidationResultType.Error, LocalizationManager.GetTranslatedText(
this, "NewDikeTopWidth"), this)
};
}
else
{
return new ValidationResult[0];
}
}
///
/// Validates the location has segment.
///
///
[Validate]
public ValidationResult[] ValidateLocationHasSegment()
{
if (Segment == null)
{
return new[]
{
new ValidationResult(ValidationResultType.Error,
LocalizationManager.GetTranslatedText(this, "LocationHasNoSegment"),
this)
};
}
else
{
return new ValidationResult[0];
}
}
///
/// Validates the location has valid essential assessment values.
///
///
[Validate]
public ValidationResult[] ValidateLocationHasValidEssentialAssessmentValues()
{
if (DamProjectType == DamProjectType.Assessment)
{
if (Math.Abs(BoezemLevelTp - BoezemLevelNotSetValue) < Double.Epsilon)
{
return new[]
{
new ValidationResult(ValidationResultType.Error,
LocalizationManager.GetTranslatedText(this, "LocationInvalidBoezemLevelTp"),
this)
};
}
if (Math.Abs(boezemLevelHbp - BoezemLevelNotSetValue) < Double.Epsilon)
{
return new[]
{
new ValidationResult(ValidationResultType.Error,
LocalizationManager.GetTranslatedText(this, "LocationInvalidBoezemLevelHbp"),
this)
};
}
if (Math.Abs(boezemLevelLbp - BoezemLevelNotSetValue) < Double.Epsilon)
{
return new[]
{
new ValidationResult(ValidationResultType.Error,
LocalizationManager.GetTranslatedText(this, "LocationInvalidBoezemLevelLbp"),
this)
};
}
}
return new ValidationResult[0];
}
[Validate]
public ValidationResult[] ValidateDikeEmbankmentMaterialDefinedIfSurfacelineAboveSoilProfile()
{
if (IsSurfaceLineAboveSoilProfile() && !HasValidDikeEmbankmentMaterial())
{
return new[]
{
new ValidationResult(ValidationResultType.Error,
LocalizationManager.GetTranslatedText(this, "NoDikeEmbankmentMaterialAndNeeded"),
this)
};
}
else
{
return new ValidationResult[0];
}
}
///
/// Determines whether [is pl line offset factor below shoulder crest valid].
///
///
[Validate]
public ValidationResult[] IsPlLineOffsetFactorBelowShoulderCrestValid()
{
if (!IsDesign() && ArePlLineCreationExpertKnowledgeParametersNeeded() && UsePlLineOffsetFactorBelowShoulderCrest.HasValue && UsePlLineOffsetFactorBelowShoulderCrest.Value &&
PlLineOffsetFactorBelowShoulderCrest.HasValue)
{
if (PlLineOffsetFactorBelowShoulderCrest.Value < DamGlobalConstants.PlLineOffsetFactorBelowShoulderCrestMinValue)
{
return new[]
{
new ValidationResult(ValidationResultType.Error,
LocalizationManager.GetTranslatedText(this, "PlLineOffsetFactorBelowShoulderCrestTooSmall"),
this)
};
}
if (PlLineOffsetFactorBelowShoulderCrest.Value > DamGlobalConstants.PlLineOffsetFactorBelowShoulderCrestMaxValue)
{
return new[]
{
new ValidationResult(ValidationResultType.Error,
LocalizationManager.GetTranslatedText(this, "PlLineOffsetFactorBelowShoulderCrestTooLarge"),
this)
};
}
}
return new ValidationResult[0];
}
///
/// Check if DikeEmbankmentMaterial is defined and is available as soil
///
///
private bool HasValidDikeEmbankmentMaterial()
{
return !String.IsNullOrEmpty(DikeEmbankmentMaterial) && GetDikeEmbankmentSoil() != null;
}
///
/// Check if ShoulderEmbankmentMaterial is defined and is available as soil
///
///
private bool HasValidShoulderEmbankmentMaterial()
{
return !String.IsNullOrEmpty(ShoulderEmbankmentMaterial) && GetShoulderEmbankmentSoil() != null;
}
///
/// Determine if surfaceline is higher than any of the 1D soilprofiles
///
///
private bool IsSurfaceLineAboveSoilProfile()
{
bool isSurfaceLineAboveSoilProfile = false;
if (Segment != null)
{
foreach (var soilGeometryProbability in Segment.SoilProfileProbabilities)
{
SoilProfile1D soilProfile = soilGeometryProbability.SoilProfile1D;
if (soilProfile != null)
{
isSurfaceLineAboveSoilProfile = isSurfaceLineAboveSoilProfile || (SurfaceLine.Geometry.GetMaxZ() > soilGeometryProbability.SoilProfile1D.TopLevel);
}
}
}
return isSurfaceLineAboveSoilProfile;
}
#endregion
#region Design parameters
public virtual string DikeEmbankmentMaterial
{
get
{
return dikeEmbankmentMaterial;
}
set
{
dikeEmbankmentMaterial = value;
}
}
public virtual string ShoulderEmbankmentMaterial
{
get
{
return shoulderEmbankmentMaterial;
}
set
{
shoulderEmbankmentMaterial = value;
}
}
public virtual double StabilityShoulderGrowSlope
{
get
{
return stabilityShoulderGrowSlope;
}
set
{
stabilityShoulderGrowSlope = value;
}
}
public virtual double StabilityShoulderGrowDeltaX
{
get
{
return stabilityShoulderGrowDeltaX;
}
set
{
stabilityShoulderGrowDeltaX = value;
}
}
public virtual double StabilitySlopeAdaptionDeltaX
{
get
{
return stabilitySlopeAdaptionDeltaX;
}
set
{
stabilitySlopeAdaptionDeltaX = value;
}
}
#endregion
#region PLLine creation parameters
///
/// Gets or sets the head pl 2.
///
///
/// The head pl 2.
///
public virtual double? HeadPl2
{
get
{
return headPL2;
}
set
{
headPL2 = value;
}
}
///
/// Gets or sets the head PL3.
///
///
/// The head PL3.
///
public virtual double? HeadPl3
{
get
{
return headPL3;
}
set
{
headPL3 = value;
}
}
///
/// Gets or sets the head PL4.
///
///
/// The head PL4.
///
public virtual double? HeadPl4
{
get
{
return headPL4;
}
set
{
headPL4 = value;
}
}
///
/// Gets or sets the pl line offset below dike top at river.
///
///
/// The pl line offset below dike top at river.
///
public virtual double PlLineOffsetBelowDikeTopAtRiver
{
get
{
return pLLineOffsetBelowDikeTopAtRiver;
}
set
{
pLLineOffsetBelowDikeTopAtRiver = value;
}
}
///
/// Gets or sets the pl line offset below dike top at polder.
///
///
/// The pl line offset below dike top at polder.
///
public virtual double PlLineOffsetBelowDikeTopAtPolder
{
get
{
return pLLineOffsetBelowDikeTopAtPolder;
}
set
{
pLLineOffsetBelowDikeTopAtPolder = value;
}
}
///
/// Gets or sets the pl line offset below shoulder base inside.
///
///
/// The pl line offset below shoulder base inside.
///
public virtual double PlLineOffsetBelowShoulderBaseInside
{
get
{
return pLLineOffsetBelowShoulderBaseInside;
}
set
{
pLLineOffsetBelowShoulderBaseInside = value;
}
}
///
/// Gets or sets the pl line offset below dike toe at polder.
///
///
/// The pl line offset below dike toe at polder.
///
public virtual double PlLineOffsetBelowDikeToeAtPolder
{
get
{
return pLLineOffsetBelowDikeToeAtPolder;
}
set
{
pLLineOffsetBelowDikeToeAtPolder = value;
}
}
///
/// Gets or sets the pl line offset dry below dike top at river.
///
///
/// The pl line offset dry below dike top at river.
///
public virtual double PLLineOffsetDryBelowDikeTopAtRiver
{
get
{
return pLLineOffsetDryBelowDikeTopAtRiver;
}
set
{
pLLineOffsetDryBelowDikeTopAtRiver = value;
}
}
///
/// Gets or sets the pl line offset dry below dike top at polder.
///
///
/// The pl line offset dry below dike top at polder.
///
public virtual double PLLineOffsetDryBelowDikeTopAtPolder
{
get
{
return pLLineOffsetDryBelowDikeTopAtPolder;
}
set
{
pLLineOffsetDryBelowDikeTopAtPolder = value;
}
}
///
/// Gets or sets the pl line offset dry below shoulder base inside.
///
///
/// The pl line offset dry below shoulder base inside.
///
public virtual double PLLineOffsetDryBelowShoulderBaseInside
{
get
{
return pLLineOffsetDryBelowShoulderBaseInside;
}
set
{
pLLineOffsetDryBelowShoulderBaseInside = value;
}
}
///
/// Gets or sets the pl line offset dry below dike toe at polder.
///
///
/// The pl line offset dry below dike toe at polder.
///
public virtual double PLLineOffsetDryBelowDikeToeAtPolder
{
get
{
return pLLineOffsetDryBelowDikeToeAtPolder;
}
set
{
pLLineOffsetDryBelowDikeToeAtPolder = value;
}
}
///
/// Gets or sets the use pl line offset below dike crest middle.
///
///
/// The use pl line offset below dike crest middle.
///
public bool? UsePlLineOffsetBelowDikeCrestMiddle { get; set; }
///
/// Gets or sets the pl line offset below dike crest middle.
///
///
/// The pl line offset below dike crest middle.
///
public double? PlLineOffsetBelowDikeCrestMiddle
{
get { return plLineOffsetBelowDikeCrestMiddle; }
set
{
plLineOffsetBelowDikeCrestMiddle = value;
}
}
///
/// Gets or sets the use pl line offset factor below shoulder crest.
///
///
/// The use pl line offset factor below shoulder crest.
///
public bool? UsePlLineOffsetFactorBelowShoulderCrest { get; set; }
///
/// Gets or sets the pl line offset factor below shoulder crest.
///
///
/// The pl line offset factor below shoulder crest.
///
public double? PlLineOffsetFactorBelowShoulderCrest
{
get { return plLineOffsetFactorBelowShoulderCrest; }
set
{
plLineOffsetFactorBelowShoulderCrest = value;
}
}
///
/// Gets or sets the use pl line offset dry below dike crest middle.
///
///
/// The use pl line offset dry below dike crest middle.
///
public bool? UsePlLineOffsetDryBelowDikeCrestMiddle { get; set; }
///
/// Gets or sets the pl line offset dry below dike crest middle.
///
///
/// The pl line offset dry below dike crest middle.
///
public double? PlLineOffsetDryBelowDikeCrestMiddle
{
get { return plLineOffsetDryBelowDikeCrestMiddle; }
set
{
plLineOffsetDryBelowDikeCrestMiddle = value;
}
}
///
/// Gets or sets the use pl line offset dry factor below shoulder crest.
///
///
/// The use pl line offset dry factor below shoulder crest.
///
public bool? UsePlLineOffsetDryFactorBelowShoulderCrest { get; set; }
///
/// Gets or sets the pl line offset dry factor below shoulder crest.
///
///
/// The pl line offset dry factor below shoulder crest.
///
public double? PlLineOffsetDryFactorBelowShoulderCrest
{
get { return plLineOffsetDryFactorBelowShoulderCrest; }
set
{
plLineOffsetDryFactorBelowShoulderCrest = value;
}
}
///
/// Gets or sets the intrusion vertical water pressure.
///
///
/// The intrusion vertical water pressure.
///
public IntrusionVerticalWaterPressureType? IntrusionVerticalWaterPressure
{
get { return intrusionVerticalWaterPressure; }
set
{
intrusionVerticalWaterPressure = value;
}
}
#endregion
#region Waterlevels
public virtual double BoezemLevelTp
{
get
{
return boezemLevelTp;
}
set
{
boezemLevelTp = value;
}
}
public virtual double BoezemLevelHbp
{
get
{
return boezemLevelHbp;
}
set
{
boezemLevelHbp = value;
}
}
public virtual double BoezemLevelLbp
{
get
{
return boezemLevelLbp;
}
set
{
boezemLevelLbp = value;
}
}
public virtual double PolderLevel
{
get
{
return polderLevel;
}
set
{
polderLevel = value;
}
}
public virtual double PolderLevelLow
{
get
{
return polderLevelLow;
}
set
{
polderLevelLow = value;
}
}
public virtual double RiverLevel
{
get
{
return scenarioRiverLevel;
}
set
{
scenarioRiverLevel = value;
}
}
#endregion
[Validate]
public ValidationResult[] AscendingLocalXZSurfaceLine()
{
if (SurfaceLine != null)
{
return new SurfaceLine2Validator().ValidateCharacteristicPointsAreOrdered(SurfaceLine).ToArray();
}
else
{
return new ValidationResult[0];
}
}
///
/// Gets the dike embankment soil.
///
///
public Soil GetDikeEmbankmentSoil()
{
if (String.IsNullOrEmpty(SoildatabaseName) || String.IsNullOrEmpty(DikeEmbankmentMaterial))
{
return null;
}
else
{
return SoilList.GetSoilByName(DikeEmbankmentMaterial);
}
}
///
/// Gets the shoulder embankment soil.
///
///
public Soil GetShoulderEmbankmentSoil()
{
if (String.IsNullOrEmpty(SoildatabaseName) || String.IsNullOrEmpty(ShoulderEmbankmentMaterial))
{
return null;
}
else
{
return SoilList.GetSoilByName(ShoulderEmbankmentMaterial);
}
}
///
/// Gets the most probable profile. If there are no elements in the it returns null
/// and leave the handling over to the caller
///
/// The soil profile
public SoilProfile1D GetMostProbableProfile(FailureMechanismSystemType? segmentFailureMechanismType)
{
// if (Segment == null)
// {
// throw new ArgumentNullException(String.Format(ThrowHelper.GetResourceString(StringResourceNames.LocationHasNoSegment), Name));
// }
return Segment.GetMostProbableProfile(segmentFailureMechanismType);
}
///
/// Gets the most probable profile. If there are no elements in the it returns null
/// and leave the handling over to the caller
///
/// The soil profile
public string GetMostProbableGeometry2DName(FailureMechanismSystemType? segmentFailureMechanismType)
{
// if (Segment == null)
// {
// throw new ArgumentNullException(String.Format(ThrowHelper.GetResourceString(StringResourceNames.LocationHasNoSegment), Name));
// }
return Segment.GetMostProbableGeometry2DName(segmentFailureMechanismType);
}
///
/// Gets a sorted list of soil geometry probabilities for a certain failure mechanism type
///
/// The failure mechanism type
/// List of geometry probabilities
public List GetGeometryProbabilities(FailureMechanismSystemType failureMechanismType)
{
var geometryProbabilities = new List();
if (Segment != null)
{
foreach (var existingGeometryProbability in Segment.SoilProfileProbabilities)
{
if (existingGeometryProbability.SegmentFailureMechanismType.HasValue && existingGeometryProbability.SegmentFailureMechanismType.Value == failureMechanismType)
{
geometryProbabilities.Add(existingGeometryProbability);
}
}
geometryProbabilities.Sort();
}
return geometryProbabilities;
}
///
/// Gets the combination of the surface line and soil profile for a given failure mechanism and index
///
/// Failure mechanism type
/// The index indicates the ranking in probability
/// The probability of the soil surface profile
/// The soil surface profile
public SoilSurfaceProfile GetSoilSurfaceProfile(FailureMechanismSystemType failureMechanismType, int index, out double probability)
{
List soilGeometryProbabilities = GetGeometryProbabilities(failureMechanismType);
SoilGeometryProbability soilGeometryProbability = index < soilGeometryProbabilities.Count ? soilGeometryProbabilities[index] : null;
SoilProfile1D originalProfile = soilGeometryProbability != null ? soilGeometryProbability.SoilProfile1D : null;
probability = soilGeometryProbability != null ? soilGeometryProbability.Probability : 0;
if (soilSurfaceProfile == null || soilSurfaceProfile.SoilProfile != originalProfile || soilSurfaceProfile.SurfaceLine2 != SurfaceLine)
{
Soil dikeSoil = SoilList.GetSoilByName(DikeEmbankmentMaterial);
if (soilSurfaceProfile == null)
{
soilSurfaceProfile = new SoilSurfaceProfile();
}
// Do not assign the orginal soilprofile, because it will be changed in the class SoilSurfaceProfile
SoilProfile1D soilProfile1D;
if (originalProfile == null)
{
soilProfile1D = new SoilProfile1D(SurfaceLine.Geometry.GetMaxZ(), -10, dikeSoil);
}
else
{
soilProfile1D = new SoilProfile1D();
soilProfile1D.Assign(originalProfile);
}
soilSurfaceProfile.SoilProfile = soilProfile1D;
soilSurfaceProfile.SurfaceLine2 = SurfaceLine;
soilSurfaceProfile.DikeEmbankmentMaterial = GetDikeEmbankmentSoil();
foreach (SoilLayer2D layer in soilSurfaceProfile.Surfaces)
{
if (layer.Soil == null)
{
layer.Soil = dikeSoil;
}
}
}
return soilSurfaceProfile;
}
public void AlignBoundaryPointsOfPL1LineWithAdaptedSurfaceLine(SurfaceLine2 adaptedSurfaceLine)
{
if ((LocalXZPL1Line != null) && (LocalXZPL1Line.Points.Count > 1))
{
GeometryPoint lastPointPL1Line = LocalXZPL1Line.Points.Last();
GeometryPoint lastPointSurfaceLine = adaptedSurfaceLine.Geometry.Points.Last();
lastPointPL1Line.X = lastPointSurfaceLine.X;
GeometryPoint firstPointPL1Line = LocalXZPL1Line.Points.First();
GeometryPoint firstPointSurfaceLine = adaptedSurfaceLine.Geometry.Points.First();
firstPointPL1Line.X = firstPointSurfaceLine.X;
}
}
public ModelParametersForPLLines ModelParametersForPLLines
{
get
{
return modelParametersForPLLines;
}
set
{
modelParametersForPLLines = value;
}
}
private bool IsDesign()
{
bool isDesign = (DamProjectType == DamProjectType.Design);
return isDesign;
}
private bool ArePlLineCreationExpertKnowledgeParametersNeeded()
{
bool arePlLineCreationExpertKnowledgeParametersNeeded = modelParametersForPLLines.PLLineCreationMethod ==
PLLineCreationMethod.ExpertKnowledgeRRD ||
modelParametersForPLLines.PLLineCreationMethod ==
PLLineCreationMethod.GaugesWithFallbackToExpertKnowledgeRRD;
return arePlLineCreationExpertKnowledgeParametersNeeded;
}
public override string ToString()
{
return Name;
/* StringBuilder sb = new StringBuilder();
sb.Append(this.Name);
if (this.Segment != null)
sb.Append(String.Format(" @ Segment {0}", this.Segment.Name));
if (this.SurfaceLine != null)
sb.Append(String.Format(" with {0})", this.SurfaceLine.Name));
sb.Append(String.Format(" | X={0}, Y={1}, PolderLevel={2:F2}, HeadPL2={3:F2}, HeadPl3={4:F2}", this.XRd, this.YRd, this.PolderLevel, this.HeadPL2, this.HeadPl3));
return sb.ToString();*/
}
}
}