// 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.ComponentModel;
using Core.Common.Base;
using Ringtoets.ClosingStructures.Data;
using Ringtoets.Common.Data;
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.Data.Contribution;
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.Common.Data.Hydraulics;
using Ringtoets.DuneErosion.Data;
using Ringtoets.GrassCoverErosionInwards.Data;
using Ringtoets.GrassCoverErosionOutwards.Data;
using Ringtoets.HeightStructures.Data;
using Ringtoets.Integration.Data.Properties;
using Ringtoets.Integration.Data.StandAlone;
using Ringtoets.MacroStabilityInwards.Data;
using Ringtoets.Piping.Data;
using Ringtoets.StabilityPointStructures.Data;
using Ringtoets.StabilityStoneCover.Data;
using Ringtoets.WaveImpactAsphaltCover.Data;
namespace Ringtoets.Integration.Data
{
///
/// The section to be assessed by the user for safety in regards of various failure mechanisms.
///
public sealed class AssessmentSection : Observable, IAssessmentSection
{
private const double defaultNorm = 1.0 / 30000;
private const RingtoetsWellKnownTileSource defaultWellKnownTileSource = RingtoetsWellKnownTileSource.BingAerial;
private readonly ObservableList waterLevelCalculationsForFactorizedSignalingNorm = new ObservableList();
private readonly ObservableList waterLevelCalculationsForSignalingNorm = new ObservableList();
private readonly ObservableList waterLevelCalculationsForLowerLimitNorm = new ObservableList();
private readonly ObservableList waterLevelCalculationsForFactorizedLowerLimitNorm = new ObservableList();
private readonly ObservableList waveHeightCalculationsForFactorizedSignalingNorm = new ObservableList();
private readonly ObservableList waveHeightCalculationsForSignalingNorm = new ObservableList();
private readonly ObservableList waveHeightCalculationsForLowerLimitNorm = new ObservableList();
private readonly ObservableList waveHeightCalculationsForFactorizedLowerLimitNorm = new ObservableList();
private ReferenceLine referenceLine;
///
/// Initializes a new instance of the class.
///
/// The composition of the assessment section, e.g. what
/// type of elements can be found within the assessment section.
/// The lower limit norm of the assessment section.
/// The signaling norm which of the assessment section.
/// Thrown when:
///
/// - is not in the interval [0.000001, 0.1] or is ;
/// - is not in the interval [0.000001, 0.1] or is ;
/// - The is larger than .
///
///
/// Thrown when
/// is not a valid enum value of .
/// Thrown when
/// is not supported.
public AssessmentSection(AssessmentSectionComposition composition,
double lowerLimitNorm = defaultNorm,
double signalingNorm = defaultNorm)
{
Name = Resources.AssessmentSection_DisplayName;
Comments = new Comment();
BackgroundData = new BackgroundData(new WellKnownBackgroundDataConfiguration(defaultWellKnownTileSource))
{
Name = defaultWellKnownTileSource.GetDisplayName()
};
HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase();
Piping = new PipingFailureMechanism();
GrassCoverErosionInwards = new GrassCoverErosionInwardsFailureMechanism();
MacroStabilityInwards = new MacroStabilityInwardsFailureMechanism();
MacroStabilityOutwards = new MacroStabilityOutwardsFailureMechanism();
Microstability = new MicrostabilityFailureMechanism();
StabilityStoneCover = new StabilityStoneCoverFailureMechanism();
WaveImpactAsphaltCover = new WaveImpactAsphaltCoverFailureMechanism();
WaterPressureAsphaltCover = new WaterPressureAsphaltCoverFailureMechanism();
GrassCoverErosionOutwards = new GrassCoverErosionOutwardsFailureMechanism();
GrassCoverSlipOffOutwards = new GrassCoverSlipOffOutwardsFailureMechanism();
GrassCoverSlipOffInwards = new GrassCoverSlipOffInwardsFailureMechanism();
HeightStructures = new HeightStructuresFailureMechanism();
ClosingStructures = new ClosingStructuresFailureMechanism();
StabilityPointStructures = new StabilityPointStructuresFailureMechanism();
StrengthStabilityLengthwiseConstruction = new StrengthStabilityLengthwiseConstructionFailureMechanism();
PipingStructure = new PipingStructureFailureMechanism();
DuneErosion = new DuneErosionFailureMechanism();
TechnicalInnovation = new TechnicalInnovationFailureMechanism();
const int otherContribution = 30;
FailureMechanismContribution = new FailureMechanismContribution(GetContributingFailureMechanisms(),
otherContribution,
lowerLimitNorm,
signalingNorm);
ChangeComposition(composition);
}
///
/// Gets or sets the "Dijken en dammen - Piping" failure mechanism.
///
public PipingFailureMechanism Piping { get; set; }
///
/// Gets or sets the "Dijken en dammen - Grasbekleding erosie kruin en binnentalud" failure mechanism.
///
public GrassCoverErosionInwardsFailureMechanism GrassCoverErosionInwards { get; set; }
///
/// Gets or sets the "Dijken en dammen - Macrostabiliteit binnenwaarts" failure mechanism.
///
public MacroStabilityInwardsFailureMechanism MacroStabilityInwards { get; set; }
///
/// Gets or sets the "Dijken en dammen - Macrostabiliteit buitenwaarts" failure mechanism.
///
public MacroStabilityOutwardsFailureMechanism MacroStabilityOutwards { get; set; }
///
/// Gets or sets the "Dijken en dammen - Microstabiliteit" failure mechanism.
///
public MicrostabilityFailureMechanism Microstability { get; set; }
///
/// Gets or sets the "Dijken en dammen - Stabiliteit steenzetting" failure mechanism.
///
public StabilityStoneCoverFailureMechanism StabilityStoneCover { get; set; }
///
/// Gets or sets the "Dijken en dammen - Golfklappen op asfaltbekledingen" failure mechanism.
///
public WaveImpactAsphaltCoverFailureMechanism WaveImpactAsphaltCover { get; set; }
///
/// Gets or sets the "Dijken en dammen - Wateroverdruk bij asfaltbekleding" failure mechanism.
///
public WaterPressureAsphaltCoverFailureMechanism WaterPressureAsphaltCover { get; set; }
///
/// Gets or sets the "Dijken en dammen - Grasbekleding erosie buitentalud" failure mechanism.
///
public GrassCoverErosionOutwardsFailureMechanism GrassCoverErosionOutwards { get; set; }
///
/// Gets or sets the "Dijken en dammen - Grasbekleding afschuiven buitentalud" failure mechanism.
///
public GrassCoverSlipOffOutwardsFailureMechanism GrassCoverSlipOffOutwards { get; set; }
///
/// Gets or sets the "Dijken en dammen - Grasbekleding afschuiven binnentalud" failure mechanism.
///
public GrassCoverSlipOffInwardsFailureMechanism GrassCoverSlipOffInwards { get; set; }
///
/// Gets or sets the "Kunstwerken - Hoogte kunstwerk" failure mechanism.
///
public HeightStructuresFailureMechanism HeightStructures { get; set; }
///
/// Gets or sets the "Kunstwerken - Betrouwbaarheid sluiting kunstwerk" failure mechanism.
///
public ClosingStructuresFailureMechanism ClosingStructures { get; set; }
///
/// Gets or sets the "Kunstwerken - Piping bij kunstwerk" failure mechanism.
///
public PipingStructureFailureMechanism PipingStructure { get; set; }
///
/// Gets or sets the "Kunstwerken - Sterkte en stabiliteit puntconstructies" failure mechanism.
///
public StabilityPointStructuresFailureMechanism StabilityPointStructures { get; set; }
///
/// Gets or sets the "Kunstwerken - Sterkte en stabiliteit langsconstructies" failure mechanism.
///
public StrengthStabilityLengthwiseConstructionFailureMechanism StrengthStabilityLengthwiseConstruction { get; set; }
///
/// Gets or sets the "Duinwaterkering - Duinafslag" failure mechanism.
///
public DuneErosionFailureMechanism DuneErosion { get; set; }
///
/// Gets or sets the "Technische innovaties - Technische innovaties" failure mechanism.
///
public TechnicalInnovationFailureMechanism TechnicalInnovation { get; set; }
public IObservableEnumerable WaterLevelCalculationsForFactorizedSignalingNorm
{
get
{
return waterLevelCalculationsForFactorizedSignalingNorm;
}
}
public IObservableEnumerable WaterLevelCalculationsForSignalingNorm
{
get
{
return waterLevelCalculationsForSignalingNorm;
}
}
public IObservableEnumerable WaterLevelCalculationsForLowerLimitNorm
{
get
{
return waterLevelCalculationsForLowerLimitNorm;
}
}
public IObservableEnumerable WaterLevelCalculationsForFactorizedLowerLimitNorm
{
get
{
return waterLevelCalculationsForFactorizedLowerLimitNorm;
}
}
public IObservableEnumerable WaveHeightCalculationsForFactorizedSignalingNorm
{
get
{
return waveHeightCalculationsForFactorizedSignalingNorm;
}
}
public IObservableEnumerable WaveHeightCalculationsForSignalingNorm
{
get
{
return waveHeightCalculationsForSignalingNorm;
}
}
public IObservableEnumerable WaveHeightCalculationsForLowerLimitNorm
{
get
{
return waveHeightCalculationsForLowerLimitNorm;
}
}
public IObservableEnumerable WaveHeightCalculationsForFactorizedLowerLimitNorm
{
get
{
return waveHeightCalculationsForFactorizedLowerLimitNorm;
}
}
public string Id { get; set; }
public string Name { get; set; }
public Comment Comments { get; }
public AssessmentSectionComposition Composition { get; private set; }
public ReferenceLine ReferenceLine
{
get
{
return referenceLine;
}
set
{
referenceLine = value;
double sectionLength = value?.Length ?? double.NaN;
Piping.PipingProbabilityAssessmentInput.SectionLength = sectionLength;
MacroStabilityInwards.MacroStabilityInwardsProbabilityAssessmentInput.SectionLength = sectionLength;
MacroStabilityOutwards.MacroStabilityOutwardsProbabilityAssessmentInput.SectionLength = sectionLength;
WaveImpactAsphaltCover.GeneralWaveImpactAsphaltCoverInput.SectionLength = sectionLength;
}
}
public FailureMechanismContribution FailureMechanismContribution { get; }
public HydraulicBoundaryDatabase HydraulicBoundaryDatabase { get; }
public BackgroundData BackgroundData { get; }
///
/// Sets hydraulic boundary location calculations for .
///
/// The hydraulic boundary locations to add calculations for.
/// Thrown when is null.
public void SetHydraulicBoundaryLocationCalculations(IEnumerable hydraulicBoundaryLocations)
{
if (hydraulicBoundaryLocations == null)
{
throw new ArgumentNullException(nameof(hydraulicBoundaryLocations));
}
ClearHydraulicBoundaryLocationCalculations();
foreach (HydraulicBoundaryLocation hydraulicBoundaryLocation in hydraulicBoundaryLocations)
{
AddHydraulicBoundaryLocationCalculations(hydraulicBoundaryLocation);
}
}
public IEnumerable GetFailureMechanisms()
{
yield return Piping;
yield return GrassCoverErosionInwards;
yield return MacroStabilityInwards;
yield return MacroStabilityOutwards;
yield return Microstability;
yield return StabilityStoneCover;
yield return WaveImpactAsphaltCover;
yield return WaterPressureAsphaltCover;
yield return GrassCoverErosionOutwards;
yield return GrassCoverSlipOffOutwards;
yield return GrassCoverSlipOffInwards;
yield return HeightStructures;
yield return ClosingStructures;
yield return PipingStructure;
yield return StabilityPointStructures;
yield return StrengthStabilityLengthwiseConstruction;
yield return DuneErosion;
yield return TechnicalInnovation;
}
///
/// Thrown when
/// is not a valid enum value of .
/// Thrown when
/// is not supported.
public void ChangeComposition(AssessmentSectionComposition newComposition)
{
if (!Enum.IsDefined(typeof(AssessmentSectionComposition), newComposition))
{
throw new InvalidEnumArgumentException(nameof(newComposition),
(int) newComposition,
typeof(AssessmentSectionComposition));
}
switch (newComposition)
{
case AssessmentSectionComposition.Dike:
Piping.Contribution = 24;
GrassCoverErosionInwards.Contribution = 24;
MacroStabilityInwards.Contribution = 4;
MacroStabilityOutwards.Contribution = 4;
StabilityStoneCover.Contribution = 5;
WaveImpactAsphaltCover.Contribution = 5;
GrassCoverErosionOutwards.Contribution = 5;
HeightStructures.Contribution = 24;
ClosingStructures.Contribution = 4;
PipingStructure.Contribution = 2;
StabilityPointStructures.Contribution = 2;
DuneErosion.Contribution = 0;
FailureMechanismContribution.UpdateContributions(GetContributingFailureMechanisms(), 30);
break;
case AssessmentSectionComposition.Dune:
Piping.Contribution = 0;
GrassCoverErosionInwards.Contribution = 0;
MacroStabilityInwards.Contribution = 0;
MacroStabilityOutwards.Contribution = 4;
StabilityStoneCover.Contribution = 0;
WaveImpactAsphaltCover.Contribution = 0;
GrassCoverErosionOutwards.Contribution = 0;
HeightStructures.Contribution = 0;
ClosingStructures.Contribution = 0;
PipingStructure.Contribution = 0;
StabilityPointStructures.Contribution = 0;
DuneErosion.Contribution = 70;
FailureMechanismContribution.UpdateContributions(GetContributingFailureMechanisms(), 30);
break;
case AssessmentSectionComposition.DikeAndDune:
Piping.Contribution = 24;
GrassCoverErosionInwards.Contribution = 24;
MacroStabilityInwards.Contribution = 4;
MacroStabilityOutwards.Contribution = 4;
StabilityStoneCover.Contribution = 5;
WaveImpactAsphaltCover.Contribution = 5;
GrassCoverErosionOutwards.Contribution = 5;
HeightStructures.Contribution = 24;
ClosingStructures.Contribution = 4;
PipingStructure.Contribution = 2;
StabilityPointStructures.Contribution = 2;
DuneErosion.Contribution = 10;
FailureMechanismContribution.UpdateContributions(GetContributingFailureMechanisms(), 20);
break;
default:
throw new NotSupportedException();
}
Composition = newComposition;
SetFailureMechanismRelevancy();
}
private void ClearHydraulicBoundaryLocationCalculations()
{
waterLevelCalculationsForFactorizedSignalingNorm.Clear();
waterLevelCalculationsForSignalingNorm.Clear();
waterLevelCalculationsForLowerLimitNorm.Clear();
waterLevelCalculationsForFactorizedLowerLimitNorm.Clear();
waveHeightCalculationsForFactorizedSignalingNorm.Clear();
waveHeightCalculationsForSignalingNorm.Clear();
waveHeightCalculationsForLowerLimitNorm.Clear();
waveHeightCalculationsForFactorizedLowerLimitNorm.Clear();
}
private void AddHydraulicBoundaryLocationCalculations(HydraulicBoundaryLocation hydraulicBoundaryLocation)
{
waterLevelCalculationsForFactorizedSignalingNorm.Add(new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation));
waterLevelCalculationsForSignalingNorm.Add(new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation));
waterLevelCalculationsForLowerLimitNorm.Add(new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation));
waterLevelCalculationsForFactorizedLowerLimitNorm.Add(new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation));
waveHeightCalculationsForFactorizedSignalingNorm.Add(new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation));
waveHeightCalculationsForSignalingNorm.Add(new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation));
waveHeightCalculationsForLowerLimitNorm.Add(new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation));
waveHeightCalculationsForFactorizedLowerLimitNorm.Add(new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation));
}
private void SetFailureMechanismRelevancy()
{
Piping.IsRelevant = Composition != AssessmentSectionComposition.Dune;
GrassCoverErosionInwards.IsRelevant = Composition != AssessmentSectionComposition.Dune;
MacroStabilityInwards.IsRelevant = Composition != AssessmentSectionComposition.Dune;
StabilityStoneCover.IsRelevant = Composition != AssessmentSectionComposition.Dune;
WaveImpactAsphaltCover.IsRelevant = Composition != AssessmentSectionComposition.Dune;
GrassCoverErosionOutwards.IsRelevant = Composition != AssessmentSectionComposition.Dune;
HeightStructures.IsRelevant = Composition != AssessmentSectionComposition.Dune;
ClosingStructures.IsRelevant = Composition != AssessmentSectionComposition.Dune;
StabilityPointStructures.IsRelevant = Composition != AssessmentSectionComposition.Dune;
PipingStructure.IsRelevant = Composition != AssessmentSectionComposition.Dune;
DuneErosion.IsRelevant = Composition != AssessmentSectionComposition.Dike;
}
private IEnumerable GetContributingFailureMechanisms()
{
yield return Piping;
yield return GrassCoverErosionInwards;
yield return MacroStabilityInwards;
yield return StabilityStoneCover;
yield return WaveImpactAsphaltCover;
yield return GrassCoverErosionOutwards;
yield return HeightStructures;
yield return ClosingStructures;
yield return PipingStructure;
yield return StabilityPointStructures;
yield return DuneErosion;
}
}
}