/// <summary>
        /// Creates a new instance of <see cref="MacroStabilityInwardsCalculationExporter"/>.
        /// </summary>
        /// <param name="calculation">The calculation to export.</param>
        /// <param name="generalInput">General calculation parameters that are the same across all calculations.</param>
        /// <param name="persistenceFactory">The persistence factory to use.</param>
        /// <param name="filePath">The file path to export to.</param>
        /// <param name="getNormativeAssessmentLevelFunc"><see cref="Func{TResult}"/>
        /// for obtaining the normative assessment level.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="calculation"/>,
        /// <paramref name="generalInput"/>, <paramref name="persistenceFactory"/> or
        /// <paramref name="getNormativeAssessmentLevelFunc"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when <paramref name="filePath"/> is invalid.</exception>
        /// <remarks>A valid path:
        /// <list type="bullet">
        /// <item>is not empty or <c>null</c>,</item>
        /// <item>does not consist out of only whitespace characters,</item>
        /// <item>does not contain an invalid character,</item>
        /// <item>does not end with a directory or path separator (empty file name).</item>
        /// </list></remarks>
        public MacroStabilityInwardsCalculationExporter(MacroStabilityInwardsCalculation calculation,
                                                        GeneralMacroStabilityInwardsInput generalInput,
                                                        IPersistenceFactory persistenceFactory,
                                                        string filePath, Func <RoundedDouble> getNormativeAssessmentLevelFunc)
        {
            if (calculation == null)
            {
                throw new ArgumentNullException(nameof(calculation));
            }

            if (generalInput == null)
            {
                throw new ArgumentNullException(nameof(generalInput));
            }

            if (persistenceFactory == null)
            {
                throw new ArgumentNullException(nameof(persistenceFactory));
            }

            if (getNormativeAssessmentLevelFunc == null)
            {
                throw new ArgumentNullException(nameof(getNormativeAssessmentLevelFunc));
            }

            IOUtils.ValidateFilePath(filePath);

            this.calculation        = calculation;
            this.generalInput       = generalInput;
            this.persistenceFactory = persistenceFactory;
            this.filePath           = filePath;
            this.getNormativeAssessmentLevelFunc = getNormativeAssessmentLevelFunc;
        }
Beispiel #2
0
        /// <summary>
        /// Creates a new instance of <see cref="MacroStabilityInwardsWaterStressesProperties"/>.
        /// </summary>
        /// <param name="data">The data of the properties.</param>
        /// <param name="generalInput">General calculation parameters that are the same across all calculations.</param>
        /// <param name="assessmentLevel">The assessment level at stake.</param>
        /// <param name="propertyChangeHandler">The handler responsible for handling effects of a property change.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="data"/>, <paramref name="generalInput"/>
        /// or <paramref name="propertyChangeHandler"/> is <c>null</c>.</exception>
        public MacroStabilityInwardsWaterStressesProperties(MacroStabilityInwardsInput data,
                                                            GeneralMacroStabilityInwardsInput generalInput,
                                                            RoundedDouble assessmentLevel,
                                                            IObservablePropertyChangeHandler propertyChangeHandler)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            if (generalInput == null)
            {
                throw new ArgumentNullException(nameof(generalInput));
            }

            if (propertyChangeHandler == null)
            {
                throw new ArgumentNullException(nameof(propertyChangeHandler));
            }

            this.data                  = data;
            this.generalInput          = generalInput;
            this.assessmentLevel       = assessmentLevel;
            this.propertyChangeHandler = propertyChangeHandler;
        }
        public void Constructor_ExpectedValues()
        {
            // Call
            var inputParameters = new GeneralMacroStabilityInwardsInput();

            // Assert
            Assert.IsInstanceOf <IGeneralMacroStabilityInwardsWaternetInput>(inputParameters);
            Assert.AreEqual(1.06, inputParameters.ModelFactor);
            Assert.AreEqual(9.81, inputParameters.WaterVolumetricWeight);
            Assert.IsTrue(inputParameters.ApplyLengthEffectInSection);
        }
        /// <summary>
        /// Creates a new <see cref="PersistableDataModel"/>.
        /// </summary>
        /// <param name="calculation">The calculation to get the data from.</param>
        /// <param name="generalInput">General calculation parameters that are the same across all calculations.</param>
        /// <param name="getNormativeAssessmentLevelFunc"><see cref="Func{TResult}"/>
        /// for obtaining the normative assessment level.</param>
        /// <param name="filePath">The filePath that is used.</param>
        /// <returns>A created <see cref="PersistableDataModel"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="calculation"/>,
        /// <paramref name="generalInput"/> or <paramref name="getNormativeAssessmentLevelFunc"/> is <c>null</c>.</exception>
        /// <exception cref="InvalidOperationException">Thrown when <paramref name="calculation"/>
        /// has no output.</exception>
        public static PersistableDataModel Create(MacroStabilityInwardsCalculation calculation,
                                                  GeneralMacroStabilityInwardsInput generalInput,
                                                  Func <RoundedDouble> getNormativeAssessmentLevelFunc,
                                                  string filePath)
        {
            if (calculation == null)
            {
                throw new ArgumentNullException(nameof(calculation));
            }

            if (generalInput == null)
            {
                throw new ArgumentNullException(nameof(generalInput));
            }

            if (getNormativeAssessmentLevelFunc == null)
            {
                throw new ArgumentNullException(nameof(getNormativeAssessmentLevelFunc));
            }

            if (!calculation.HasOutput)
            {
                throw new InvalidOperationException("Calculation must have output.");
            }

            var idFactory = new IdFactory();
            var registry  = new MacroStabilityInwardsExportRegistry();

            MacroStabilityInwardsInput input = calculation.InputParameters;
            IMacroStabilityInwardsSoilProfileUnderSurfaceLine soilProfile = input.SoilProfileUnderSurfaceLine;

            return(new PersistableDataModel
            {
                Info = PersistableProjectInfoFactory.Create(calculation, filePath),
                CalculationSettings = PersistableCalculationSettingsFactory.Create(calculation.Output.SlidingCurve, idFactory, registry),
                Soils = PersistableSoilCollectionFactory.Create(soilProfile, idFactory, registry),
                Geometry = PersistableGeometryFactory.Create(soilProfile, idFactory, registry),
                SoilLayers = PersistableSoilLayerCollectionFactory.Create(soilProfile, idFactory, registry),
                Waternets = PersistableWaternetFactory.Create(
                    DerivedMacroStabilityInwardsInput.GetWaternetDaily(input, generalInput),
                    DerivedMacroStabilityInwardsInput.GetWaternetExtreme(input, generalInput, GetEffectiveAssessmentLevel(input, getNormativeAssessmentLevelFunc)),
                    generalInput, idFactory, registry),
                WaternetCreatorSettings = PersistableWaternetCreatorSettingsFactory.Create(input, GetEffectiveAssessmentLevel(input, getNormativeAssessmentLevelFunc),
                                                                                           idFactory, registry),
                States = PersistableStateFactory.Create(soilProfile, idFactory, registry),
                Stages = PersistableStageFactory.Create(idFactory, registry)
            });
        }
Beispiel #5
0
        /// <summary>
        /// Creates a new instance of <see cref="MacroStabilityInwardsCalculationActivity"/>.
        /// </summary>
        /// <param name="calculation">The macro stability inwards calculation to perform.</param>
        /// <param name="generalInput">General calculation parameters that are the same across all calculations.</param>
        /// <param name="normativeAssessmentLevel">The normative assessment level to use in case the manual assessment level is not applicable.</param>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        public MacroStabilityInwardsCalculationActivity(MacroStabilityInwardsCalculation calculation,
                                                        GeneralMacroStabilityInwardsInput generalInput,
                                                        RoundedDouble normativeAssessmentLevel)
            : base(calculation)
        {
            if (generalInput == null)
            {
                throw new ArgumentNullException(nameof(generalInput));
            }

            this.calculation = calculation;
            this.normativeAssessmentLevel = normativeAssessmentLevel;
            this.generalInput             = generalInput;

            Description = string.Format(RiskeerCommonServiceResources.Perform_calculation_with_name_0_, calculation.Name);
        }
Beispiel #6
0
        /// <summary>
        /// Creates a new instance of <see cref="MacroStabilityInwardsWaterStressLinesProperties"/>.
        /// </summary>
        /// <param name="data">The data of the properties.</param>
        /// <param name="generalInput">General calculation parameters that are the same across all calculations.</param>
        /// <param name="assessmentLevel">The assessment level at stake.</param>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        public MacroStabilityInwardsWaterStressLinesProperties(MacroStabilityInwardsInput data, GeneralMacroStabilityInwardsInput generalInput, RoundedDouble assessmentLevel)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            if (generalInput == null)
            {
                throw new ArgumentNullException(nameof(generalInput));
            }

            this.data            = data;
            this.generalInput    = generalInput;
            this.assessmentLevel = assessmentLevel;
        }
        public void Constructor_ExpectedValues()
        {
            // Setup
            var failureMechanism = new MacroStabilityInwardsFailureMechanism();

            // Call
            var properties = new MacroStabilityInwardsFailureMechanismProperties(failureMechanism);

            // Assert
            Assert.IsInstanceOf <MacroStabilityInwardsFailureMechanismPropertiesBase>(properties);
            Assert.AreEqual(failureMechanism.Name, properties.Name);
            Assert.AreEqual(failureMechanism.Code, properties.Code);

            GeneralMacroStabilityInwardsInput generalInput = failureMechanism.GeneralInput;

            Assert.AreEqual(generalInput.WaterVolumetricWeight, properties.WaterVolumetricWeight);
            Assert.AreEqual(generalInput.ModelFactor, properties.ModelFactor);
        }
Beispiel #8
0
        /// <summary>
        /// Creates a new collection of <see cref="PersistableWaternet"/>.
        /// </summary>
        /// <param name="dailyWaternet">The daily Waternet to use.</param>
        /// <param name="extremeWaternet">The extreme Waternet to use.</param>
        /// <param name="generalInput">General calculation parameters that are the same across all calculations.</param>
        /// <param name="idFactory">The factory for creating IDs.</param>
        /// <param name="registry">The persistence registry.</param>
        /// <returns>A collection of <see cref="PersistableWaternet"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        public static IEnumerable <PersistableWaternet> Create(MacroStabilityInwardsWaternet dailyWaternet,
                                                               MacroStabilityInwardsWaternet extremeWaternet,
                                                               GeneralMacroStabilityInwardsInput generalInput,
                                                               IdFactory idFactory,
                                                               MacroStabilityInwardsExportRegistry registry)
        {
            if (dailyWaternet == null)
            {
                throw new ArgumentNullException(nameof(dailyWaternet));
            }

            if (extremeWaternet == null)
            {
                throw new ArgumentNullException(nameof(extremeWaternet));
            }

            if (idFactory == null)
            {
                throw new ArgumentNullException(nameof(idFactory));
            }

            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            if (generalInput == null)
            {
                throw new ArgumentNullException(nameof(generalInput));
            }

            createdHeadLines = new Dictionary <MacroStabilityInwardsPhreaticLine, PersistableHeadLine>(new PhreaticLineComparer());

            return(new[]
            {
                Create(dailyWaternet, generalInput, MacroStabilityInwardsExportStageType.Daily, idFactory, registry),
                Create(extremeWaternet, generalInput, MacroStabilityInwardsExportStageType.Extreme, idFactory, registry)
            });
        }
        /// <summary>
        /// Creates a <see cref="CalculatableActivity"/> based on the given <paramref name="calculation"/>.
        /// </summary>
        /// <param name="calculation">The calculation to create an activity for.</param>
        /// <param name="generalInput">General calculation parameters that are the same across all calculations.</param>
        /// <param name="assessmentSection">The assessment section the <paramref name="calculation"/>
        /// belongs to.</param>
        /// <returns>A <see cref="CalculatableActivity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        public static CalculatableActivity CreateCalculationActivity(MacroStabilityInwardsCalculation calculation,
                                                                     GeneralMacroStabilityInwardsInput generalInput,
                                                                     IAssessmentSection assessmentSection)
        {
            if (calculation == null)
            {
                throw new ArgumentNullException(nameof(calculation));
            }

            if (generalInput == null)
            {
                throw new ArgumentNullException(nameof(generalInput));
            }

            if (assessmentSection == null)
            {
                throw new ArgumentNullException(nameof(assessmentSection));
            }

            return(new MacroStabilityInwardsCalculationActivity(calculation,
                                                                generalInput,
                                                                assessmentSection.GetNormativeAssessmentLevel(calculation.InputParameters.HydraulicBoundaryLocation)));
        }
Beispiel #10
0
        /// <summary>
        /// Creates a new instance of <see cref="MacroStabilityInwardsOutputView"/>.
        /// </summary>
        /// <param name="data">The calculation to show the output for.</param>
        /// <param name="generalInput">General calculation parameters that are the same across all calculations.</param>
        /// <param name="getNormativeAssessmentLevelFunc"><see cref="Func{TResult}"/> for obtaining the normative assessment level.</param>
        /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception>
        public MacroStabilityInwardsOutputView(MacroStabilityInwardsCalculationScenario data,
                                               GeneralMacroStabilityInwardsInput generalInput,
                                               Func <RoundedDouble> getNormativeAssessmentLevelFunc)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            if (generalInput == null)
            {
                throw new ArgumentNullException(nameof(generalInput));
            }

            if (getNormativeAssessmentLevelFunc == null)
            {
                throw new ArgumentNullException(nameof(getNormativeAssessmentLevelFunc));
            }

            this.data         = data;
            this.generalInput = generalInput;
            this.getNormativeAssessmentLevelFunc = getNormativeAssessmentLevelFunc;

            InitializeComponent();

            calculationObserver = new Observer(UpdateViewData)
            {
                Observable = data
            };

            inputObserver = new Observer(UpdateViewData)
            {
                Observable = data.InputParameters
            };

            UpdateTableData();
        }
        /// <summary>
        /// Creates a collection of <see cref="CalculatableActivity"/> based on the calculations in
        /// <paramref name="calculationGroup"/>.
        /// </summary>
        /// <param name="calculationGroup">The calculation group to create activities for.</param>
        /// <param name="generalInput">General calculation parameters that are the same across all calculations.</param>
        /// <param name="assessmentSection">The assessment section the calculations in <paramref name="calculationGroup"/>
        /// belong to.</param>
        /// <returns>A collection of <see cref="CalculatableActivity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        public static IEnumerable <CalculatableActivity> CreateCalculationActivities(CalculationGroup calculationGroup,
                                                                                     GeneralMacroStabilityInwardsInput generalInput,
                                                                                     IAssessmentSection assessmentSection)
        {
            if (calculationGroup == null)
            {
                throw new ArgumentNullException(nameof(calculationGroup));
            }

            if (generalInput == null)
            {
                throw new ArgumentNullException(nameof(generalInput));
            }

            if (assessmentSection == null)
            {
                throw new ArgumentNullException(nameof(assessmentSection));
            }

            return(calculationGroup.GetCalculations()
                   .Cast <MacroStabilityInwardsCalculation>()
                   .Select(calc => CreateCalculationActivity(calc, generalInput, assessmentSection))
                   .ToArray());
        }
        /// <summary>
        /// Creates a new instance of <see cref="MacroStabilityInwardsCalculationGroupExporter"/>.
        /// </summary>
        /// <param name="calculationGroup">The calculation group to export.</param>
        /// <param name="generalInput">General calculation parameters that are the same across all calculations.</param>
        /// <param name="persistenceFactory">The persistence factory to use.</param>
        /// <param name="filePath">The file path to export to.</param>
        /// <param name="fileExtension">The extension of the files.</param>
        /// <param name="getNormativeAssessmentLevelFunc"><see cref="Func{T1,TResult}"/>
        /// for obtaining the normative assessment level.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="calculationGroup"/>, <paramref name="generalInput"/>,
        /// <paramref name="persistenceFactory"/>, or <paramref name="getNormativeAssessmentLevelFunc"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when <paramref name="filePath"/> is invalid.</exception>
        /// <remarks>A valid path:<list type="bullet">
        /// <item>is not empty or <c>null</c>,</item>
        /// <item>does not consist out of only whitespace characters,</item>
        /// <item>does not contain an invalid character,</item>
        /// <item>is not too long.</item>
        /// </list></remarks>
        public MacroStabilityInwardsCalculationGroupExporter(CalculationGroup calculationGroup, GeneralMacroStabilityInwardsInput generalInput,
                                                             IPersistenceFactory persistenceFactory, string filePath,
                                                             string fileExtension, Func <MacroStabilityInwardsCalculation, RoundedDouble> getNormativeAssessmentLevelFunc)
        {
            if (calculationGroup == null)
            {
                throw new ArgumentNullException(nameof(calculationGroup));
            }

            if (generalInput == null)
            {
                throw new ArgumentNullException(nameof(generalInput));
            }

            if (persistenceFactory == null)
            {
                throw new ArgumentNullException(nameof(persistenceFactory));
            }

            if (getNormativeAssessmentLevelFunc == null)
            {
                throw new ArgumentNullException(nameof(getNormativeAssessmentLevelFunc));
            }

            IOUtils.ValidateFilePath(filePath);

            this.calculationGroup   = calculationGroup;
            this.generalInput       = generalInput;
            this.persistenceFactory = persistenceFactory;
            this.filePath           = filePath;
            string folderPath = Path.GetDirectoryName(filePath);

            tempFolderPath     = Path.Combine(folderPath, "~temp");
            this.fileExtension = fileExtension;
            this.getNormativeAssessmentLevelFunc = getNormativeAssessmentLevelFunc;
        }
Beispiel #13
0
        /// <summary>
        /// Creates a new instance of <see cref="MacroStabilityInwardsOutputChartControl"/>.
        /// </summary>
        /// <param name="data">The calculation to show the output for.</param>
        /// <param name="generalInput">General calculation parameters that are the same across all calculations.</param>
        /// <param name="getNormativeAssessmentLevelFunc"><see cref="Func{TResult}"/> for obtaining the normative assessment level.</param>
        /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception>
        public MacroStabilityInwardsOutputChartControl(MacroStabilityInwardsCalculationScenario data,
                                                       GeneralMacroStabilityInwardsInput generalInput,
                                                       Func <RoundedDouble> getNormativeAssessmentLevelFunc)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            if (generalInput == null)
            {
                throw new ArgumentNullException(nameof(generalInput));
            }

            if (getNormativeAssessmentLevelFunc == null)
            {
                throw new ArgumentNullException(nameof(getNormativeAssessmentLevelFunc));
            }

            this.data         = data;
            this.generalInput = generalInput;
            this.getNormativeAssessmentLevelFunc = getNormativeAssessmentLevelFunc;

            InitializeComponent();

            chartDataCollection            = new ChartDataCollection(RiskeerCommonFormsResources.CalculationOutput_DisplayName);
            soilProfileChartData           = RiskeerChartDataFactory.CreateSoilProfileChartData();
            surfaceLineChartData           = RiskeerChartDataFactory.CreateSurfaceLineChartData();
            surfaceLevelInsideChartData    = MacroStabilityInwardsChartDataFactory.CreateSurfaceLevelInsideChartData();
            ditchPolderSideChartData       = RiskeerChartDataFactory.CreateDitchPolderSideChartData();
            bottomDitchPolderSideChartData = RiskeerChartDataFactory.CreateBottomDitchPolderSideChartData();
            bottomDitchDikeSideChartData   = RiskeerChartDataFactory.CreateBottomDitchDikeSideChartData();
            ditchDikeSideChartData         = RiskeerChartDataFactory.CreateDitchDikeSideChartData();
            dikeToeAtPolderChartData       = RiskeerChartDataFactory.CreateDikeToeAtPolderChartData();
            shoulderTopInsideChartData     = MacroStabilityInwardsChartDataFactory.CreateShoulderTopInsideChartData();
            shoulderBaseInsideChartData    = MacroStabilityInwardsChartDataFactory.CreateShoulderBaseInsideChartData();
            dikeTopAtPolderChartData       = MacroStabilityInwardsChartDataFactory.CreateDikeTopAtPolderChartData();
            dikeToeAtRiverChartData        = RiskeerChartDataFactory.CreateDikeToeAtRiverChartData();
            dikeTopAtRiverChartData        = MacroStabilityInwardsChartDataFactory.CreateDikeTopAtRiverChartData();
            surfaceLevelOutsideChartData   = MacroStabilityInwardsChartDataFactory.CreateSurfaceLevelOutsideChartData();
            waternetZonesExtremeChartData  = MacroStabilityInwardsChartDataFactory.CreateWaternetZonesExtremeChartDataCollection();
            waternetZonesDailyChartData    = MacroStabilityInwardsChartDataFactory.CreateWaternetZonesDailyChartDataCollection();
            tangentLinesChartData          = MacroStabilityInwardsChartDataFactory.CreateTangentLinesChartData();
            leftGridChartData          = MacroStabilityInwardsChartDataFactory.CreateLeftGridChartData();
            rightGridChartData         = MacroStabilityInwardsChartDataFactory.CreateRightGridChartData();
            slipPlaneChartData         = MacroStabilityInwardsChartDataFactory.CreateSlipPlaneChartData();
            leftCircleRadiusChartData  = MacroStabilityInwardsChartDataFactory.CreateActiveCircleRadiusChartData();
            rightCircleRadiusChartData = MacroStabilityInwardsChartDataFactory.CreatePassiveCircleRadiusChartData();
            slicesChartData            = MacroStabilityInwardsSliceChartDataFactory.CreateSlicesChartData();

            sliceParametersChartDataCollection = MacroStabilityInwardsSliceChartDataFactory.CreateSliceParametersChartDataCollection();
            sliceCohesionChartData             = MacroStabilityInwardsSliceChartDataFactory.CreateCohesionChartData();
            sliceEffectiveStressChartData      = MacroStabilityInwardsSliceChartDataFactory.CreateEffectiveStressChartData();
            sliceTotalPorePressureChartData    = MacroStabilityInwardsSliceChartDataFactory.CreateTotalPorePressureChartData();
            sliceWeightChartData = MacroStabilityInwardsSliceChartDataFactory.CreateWeightChartData();
            slicePiezometricPorePressureChartData = MacroStabilityInwardsSliceChartDataFactory.CreatePiezometricPorePressureChartData();
            slicePorePressureChartData            = MacroStabilityInwardsSliceChartDataFactory.CreatePorePressureChartData();
            sliceVerticalPorePressureChartData    = MacroStabilityInwardsSliceChartDataFactory.CreateVerticalPorePressureChartData();
            sliceHorizontalPorePressureChartData  = MacroStabilityInwardsSliceChartDataFactory.CreateHorizontalPorePressureChartData();
            sliceOverConsolidationRatioChartData  = MacroStabilityInwardsSliceChartDataFactory.CreateOverConsolidationRatioChartData();
            slicePopChartData          = MacroStabilityInwardsSliceChartDataFactory.CreatePopChartData();
            sliceNormalStressChartData = MacroStabilityInwardsSliceChartDataFactory.CreateNormalStressChartData();
            sliceShearStressChartData  = MacroStabilityInwardsSliceChartDataFactory.CreateShearStressChartData();
            sliceLoadStressChartData   = MacroStabilityInwardsSliceChartDataFactory.CreateLoadStressChartData();

            chartDataCollection.Add(soilProfileChartData);
            chartDataCollection.Add(surfaceLineChartData);
            chartDataCollection.Add(surfaceLevelInsideChartData);
            chartDataCollection.Add(ditchPolderSideChartData);
            chartDataCollection.Add(bottomDitchPolderSideChartData);
            chartDataCollection.Add(bottomDitchDikeSideChartData);
            chartDataCollection.Add(ditchDikeSideChartData);
            chartDataCollection.Add(dikeToeAtPolderChartData);
            chartDataCollection.Add(shoulderTopInsideChartData);
            chartDataCollection.Add(shoulderBaseInsideChartData);
            chartDataCollection.Add(dikeTopAtPolderChartData);
            chartDataCollection.Add(dikeToeAtRiverChartData);
            chartDataCollection.Add(dikeTopAtRiverChartData);
            chartDataCollection.Add(surfaceLevelOutsideChartData);
            chartDataCollection.Add(waternetZonesExtremeChartData);
            chartDataCollection.Add(waternetZonesDailyChartData);
            chartDataCollection.Add(tangentLinesChartData);
            chartDataCollection.Add(leftGridChartData);
            chartDataCollection.Add(rightGridChartData);
            chartDataCollection.Add(slicesChartData);
            chartDataCollection.Add(slipPlaneChartData);
            chartDataCollection.Add(leftCircleRadiusChartData);
            chartDataCollection.Add(rightCircleRadiusChartData);

            chartDataCollection.Add(sliceParametersChartDataCollection);
            sliceParametersChartDataCollection.Add(sliceLoadStressChartData);
            sliceParametersChartDataCollection.Add(sliceShearStressChartData);
            sliceParametersChartDataCollection.Add(sliceNormalStressChartData);
            sliceParametersChartDataCollection.Add(slicePopChartData);
            sliceParametersChartDataCollection.Add(sliceOverConsolidationRatioChartData);
            sliceParametersChartDataCollection.Add(sliceHorizontalPorePressureChartData);
            sliceParametersChartDataCollection.Add(sliceVerticalPorePressureChartData);
            sliceParametersChartDataCollection.Add(slicePorePressureChartData);
            sliceParametersChartDataCollection.Add(slicePiezometricPorePressureChartData);
            sliceParametersChartDataCollection.Add(sliceWeightChartData);
            sliceParametersChartDataCollection.Add(sliceTotalPorePressureChartData);
            sliceParametersChartDataCollection.Add(sliceEffectiveStressChartData);
            sliceParametersChartDataCollection.Add(sliceCohesionChartData);

            soilLayerChartDataLookup = new List <ChartMultipleAreaData>();

            phreaticLineExtremeLookup = new Dictionary <MacroStabilityInwardsPhreaticLine, ChartLineData>();
            phreaticLineDailyLookup   = new Dictionary <MacroStabilityInwardsPhreaticLine, ChartLineData>();
            waternetLineExtremeLookup = new Dictionary <MacroStabilityInwardsWaternetLine, ChartMultipleAreaData>();
            waternetLineDailyLookup   = new Dictionary <MacroStabilityInwardsWaternetLine, ChartMultipleAreaData>();

            UpdateChartData();

            chartControl.Data = chartDataCollection;
        }
Beispiel #14
0
        private static PersistableWaternet Create(MacroStabilityInwardsWaternet waternet, GeneralMacroStabilityInwardsInput generalInput, MacroStabilityInwardsExportStageType stageType,
                                                  IdFactory idFactory, MacroStabilityInwardsExportRegistry registry)
        {
            var persistableWaternet = new PersistableWaternet
            {
                Id = idFactory.Create(),
                UnitWeightWater = generalInput.WaterVolumetricWeight,
                HeadLines       = waternet.PhreaticLines.Select(pl => Create(pl, idFactory)).ToArray(),
                ReferenceLines  = waternet.WaternetLines.Select(wl => Create(wl, idFactory)).ToArray(),
                PhreaticLineId  = waternet.PhreaticLines.Any()
                                     ? createdHeadLines[waternet.PhreaticLines.First()].Id
                                     : null
            };

            registry.AddWaternet(stageType, persistableWaternet.Id);

            return(persistableWaternet);
        }
Beispiel #15
0
        /// <summary>
        /// Creates a new instance of <see cref="MacroStabilityInwardsInputView"/>.
        /// </summary>
        /// <param name="data">The calculation to show the input for.</param>
        /// <param name="generalInput">General calculation parameters that are the same across all calculations.</param>
        /// <param name="assessmentSection">The assessment section the calculation belongs to.</param>
        /// <param name="getHydraulicBoundaryLocationCalculationFunc">The <see cref="Func{TResult}"/> for
        /// obtaining the hydraulic boundary location calculation.</param>
        /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception>
        public MacroStabilityInwardsInputView(MacroStabilityInwardsCalculationScenario data,
                                              GeneralMacroStabilityInwardsInput generalInput,
                                              IAssessmentSection assessmentSection,
                                              Func <HydraulicBoundaryLocationCalculation> getHydraulicBoundaryLocationCalculationFunc)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            if (generalInput == null)
            {
                throw new ArgumentNullException(nameof(generalInput));
            }

            if (assessmentSection == null)
            {
                throw new ArgumentNullException(nameof(assessmentSection));
            }

            if (getHydraulicBoundaryLocationCalculationFunc == null)
            {
                throw new ArgumentNullException(nameof(getHydraulicBoundaryLocationCalculationFunc));
            }

            this.data         = data;
            this.generalInput = generalInput;
            this.getHydraulicBoundaryLocationCalculationFunc = getHydraulicBoundaryLocationCalculationFunc;

            InitializeComponent();

            calculationObserver = new Observer(UpdateChartTitle)
            {
                Observable = data
            };

            calculationInputObserver = new Observer(UpdateViewData)
            {
                Observable = data.InputParameters
            };

            hydraulicLocationCalculationObserver = new Observer(UpdateViewData)
            {
                Observable = getHydraulicBoundaryLocationCalculationFunc()
            };

            failureMechanismContributionObserver = new Observer(UpdateViewData)
            {
                Observable = assessmentSection.FailureMechanismContribution
            };

            chartDataCollection            = new ChartDataCollection(RiskeerCommonFormsResources.Calculation_Input);
            soilProfileChartData           = RiskeerChartDataFactory.CreateSoilProfileChartData();
            surfaceLineChartData           = RiskeerChartDataFactory.CreateSurfaceLineChartData();
            surfaceLevelInsideChartData    = MacroStabilityInwardsChartDataFactory.CreateSurfaceLevelInsideChartData();
            ditchPolderSideChartData       = RiskeerChartDataFactory.CreateDitchPolderSideChartData();
            bottomDitchPolderSideChartData = RiskeerChartDataFactory.CreateBottomDitchPolderSideChartData();
            bottomDitchDikeSideChartData   = RiskeerChartDataFactory.CreateBottomDitchDikeSideChartData();
            ditchDikeSideChartData         = RiskeerChartDataFactory.CreateDitchDikeSideChartData();
            dikeToeAtPolderChartData       = RiskeerChartDataFactory.CreateDikeToeAtPolderChartData();
            shoulderTopInsideChartData     = MacroStabilityInwardsChartDataFactory.CreateShoulderTopInsideChartData();
            shoulderBaseInsideChartData    = MacroStabilityInwardsChartDataFactory.CreateShoulderBaseInsideChartData();
            dikeTopAtPolderChartData       = MacroStabilityInwardsChartDataFactory.CreateDikeTopAtPolderChartData();
            dikeToeAtRiverChartData        = RiskeerChartDataFactory.CreateDikeToeAtRiverChartData();
            dikeTopAtRiverChartData        = MacroStabilityInwardsChartDataFactory.CreateDikeTopAtRiverChartData();
            surfaceLevelOutsideChartData   = MacroStabilityInwardsChartDataFactory.CreateSurfaceLevelOutsideChartData();
            tangentLinesData              = MacroStabilityInwardsChartDataFactory.CreateTangentLinesChartData();
            leftGridChartData             = MacroStabilityInwardsChartDataFactory.CreateLeftGridChartData();
            rightGridChartData            = MacroStabilityInwardsChartDataFactory.CreateRightGridChartData();
            waternetZonesExtremeChartData = MacroStabilityInwardsChartDataFactory.CreateWaternetZonesExtremeChartDataCollection();
            waternetZonesDailyChartData   = MacroStabilityInwardsChartDataFactory.CreateWaternetZonesDailyChartDataCollection();

            chartDataCollection.Add(soilProfileChartData);
            chartDataCollection.Add(surfaceLineChartData);
            chartDataCollection.Add(surfaceLevelInsideChartData);
            chartDataCollection.Add(ditchPolderSideChartData);
            chartDataCollection.Add(bottomDitchPolderSideChartData);
            chartDataCollection.Add(bottomDitchDikeSideChartData);
            chartDataCollection.Add(ditchDikeSideChartData);
            chartDataCollection.Add(dikeToeAtPolderChartData);
            chartDataCollection.Add(shoulderTopInsideChartData);
            chartDataCollection.Add(shoulderBaseInsideChartData);
            chartDataCollection.Add(dikeTopAtPolderChartData);
            chartDataCollection.Add(dikeToeAtRiverChartData);
            chartDataCollection.Add(dikeTopAtRiverChartData);
            chartDataCollection.Add(surfaceLevelOutsideChartData);
            chartDataCollection.Add(tangentLinesData);
            chartDataCollection.Add(leftGridChartData);
            chartDataCollection.Add(rightGridChartData);
            chartDataCollection.Add(waternetZonesExtremeChartData);
            chartDataCollection.Add(waternetZonesDailyChartData);

            soilLayerChartDataLookup = new List <ChartMultipleAreaData>();

            SetChartData();

            chartControl.Data = chartDataCollection;

            UpdateChartTitle();
            UpdateTableData();
        }
Beispiel #16
0
        /// <summary>
        /// Performs a macro stability inwards calculation based on the supplied <see cref="MacroStabilityInwardsCalculation"/>
        /// and sets <see cref="MacroStabilityInwardsCalculation.Output"/> based on the result if the calculation was successful.
        /// Error and status information is logged during the execution of the operation.
        /// </summary>
        /// <param name="calculation">The <see cref="MacroStabilityInwardsCalculation"/> to base the input for the calculation upon.</param>
        /// <param name="generalInput">General calculation parameters that are the same across all calculations.</param>
        /// <param name="normativeAssessmentLevel">The normative assessment level to use in case the manual assessment level is not applicable.</param>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        /// <exception cref="UpliftVanCalculatorException">Thrown when an error (both expected or unexpected) occurred during the calculation.</exception>
        /// <remarks>Consider calling <see cref="Validate"/> first to see if calculation is possible.</remarks>
        public static void Calculate(MacroStabilityInwardsCalculation calculation, GeneralMacroStabilityInwardsInput generalInput, RoundedDouble normativeAssessmentLevel)
        {
            if (calculation == null)
            {
                throw new ArgumentNullException(nameof(calculation));
            }

            if (generalInput == null)
            {
                throw new ArgumentNullException(nameof(generalInput));
            }

            UpliftVanCalculatorResult macroStabilityInwardsResult;

            CalculationServiceHelper.LogCalculationBegin();

            try
            {
                IUpliftVanCalculator calculator = GetCalculator(calculation, generalInput, normativeAssessmentLevel);

                macroStabilityInwardsResult = calculator.Calculate();
            }
            catch (UpliftVanCalculatorException e)
            {
                var stringBuilder = new StringBuilder();
                stringBuilder.AppendLine(Resources.MacroStabilityInwardsCalculationService_Calculate_Kernel_provides_messages);

                foreach (MacroStabilityInwardsKernelMessage kernelMessage in e.KernelMessages)
                {
                    stringBuilder.AppendLine(string.Format(Resources.MacroStabilityInwardsCalculationService_Calculate_LogMessageType_0_LogMessage_1, kernelMessage.Type, kernelMessage.Message));
                }

                CalculationServiceHelper.LogExceptionAsError($"{RiskeerCommonServiceResources.CalculationService_Calculate_unexpected_error} {stringBuilder}", e);
                CalculationServiceHelper.LogCalculationEnd();

                throw;
            }

            if (macroStabilityInwardsResult.CalculationMessages.Any(cm => cm.Type == MacroStabilityInwardsKernelMessageType.Error))
            {
                CalculationServiceHelper.LogMessagesAsError(new[]
                {
                    CreateAggregatedLogMessage(Resources.MacroStabilityInwardsCalculationService_Calculate_Errors_in_MacroStabilityInwards_calculation, macroStabilityInwardsResult)
                });

                CalculationServiceHelper.LogCalculationEnd();

                throw new UpliftVanCalculatorException();
            }

            if (macroStabilityInwardsResult.CalculationMessages.Any())
            {
                CalculationServiceHelper.LogMessagesAsWarning(new[]
                {
                    CreateAggregatedLogMessage(Resources.MacroStabilityInwardsCalculationService_Calculate_Warnings_in_MacroStabilityInwards_calculation, macroStabilityInwardsResult)
                });
            }

            calculation.Output = new MacroStabilityInwardsOutput(
                MacroStabilityInwardsSlidingCurveConverter.Convert(macroStabilityInwardsResult.SlidingCurveResult),
                MacroStabilityInwardsSlipPlaneUpliftVanConverter.Convert(macroStabilityInwardsResult.CalculationGridResult),
                new MacroStabilityInwardsOutput.ConstructionProperties
            {
                FactorOfStability       = macroStabilityInwardsResult.FactorOfStability,
                ForbiddenZonesXEntryMin = macroStabilityInwardsResult.ForbiddenZonesXEntryMin,
                ForbiddenZonesXEntryMax = macroStabilityInwardsResult.ForbiddenZonesXEntryMax
            });

            CalculationServiceHelper.LogCalculationEnd();
        }
Beispiel #17
0
        private static IUpliftVanCalculator GetCalculator(MacroStabilityInwardsCalculation calculation, GeneralMacroStabilityInwardsInput generalInput, RoundedDouble normativeAssessmentLevel)
        {
            UpliftVanCalculatorInput upliftVanCalculatorInput = CreateInputFromData(calculation.InputParameters, generalInput, normativeAssessmentLevel);
            IUpliftVanCalculator     calculator = MacroStabilityInwardsCalculatorFactory.Instance.CreateUpliftVanCalculator(upliftVanCalculatorInput, MacroStabilityInwardsKernelWrapperFactory.Instance);

            return(calculator);
        }
Beispiel #18
0
        /// <summary>
        /// Performs validation over the values on the given <paramref name="calculation"/>. Error and status information is logged during
        /// the execution of the operation.
        /// </summary>
        /// <param name="calculation">The <see cref="MacroStabilityInwardsCalculation"/> for which to validate the values.</param>
        /// <param name="generalInput">General calculation parameters that are the same across all calculations.</param>
        /// <param name="normativeAssessmentLevel">The normative assessment level to use in case the manual assessment level is not applicable.</param>
        /// <returns><c>false</c> if <paramref name="calculation"/> contains validation errors; <c>true</c> otherwise.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        public static bool Validate(MacroStabilityInwardsCalculation calculation, GeneralMacroStabilityInwardsInput generalInput, RoundedDouble normativeAssessmentLevel)
        {
            if (calculation == null)
            {
                throw new ArgumentNullException(nameof(calculation));
            }

            if (generalInput == null)
            {
                throw new ArgumentNullException(nameof(generalInput));
            }

            CalculationServiceHelper.LogValidationBegin();

            string[] inputValidationResults = MacroStabilityInwardsInputValidator.Validate(calculation.InputParameters, normativeAssessmentLevel).ToArray();

            if (inputValidationResults.Length > 0)
            {
                CalculationServiceHelper.LogMessagesAsError(inputValidationResults);
                CalculationServiceHelper.LogValidationEnd();

                return(false);
            }

            IEnumerable <MacroStabilityInwardsKernelMessage> waternetExtremeKernelMessages;
            IEnumerable <MacroStabilityInwardsKernelMessage> waternetDailyKernelMessages;

            try
            {
                waternetExtremeKernelMessages = ValidateWaternet(() => WaternetCalculationService.ValidateExtreme(
                                                                     calculation.InputParameters, generalInput, GetEffectiveAssessmentLevel(calculation.InputParameters, normativeAssessmentLevel)),
                                                                 Resources.MacroStabilityInwardsCalculationService_Validate_Waternet_extreme_validation_started);
                waternetDailyKernelMessages = ValidateWaternet(() => WaternetCalculationService.ValidateDaily(calculation.InputParameters, generalInput),
                                                               Resources.MacroStabilityInwardsCalculationService_Validate_Waternet_daily_validation_started);
            }
            catch (WaternetCalculationException e)
            {
                HandleExceptionOnValidation(e);

                return(false);
            }

            IEnumerable <MacroStabilityInwardsKernelMessage> kernelMessages = Enumerable.Empty <MacroStabilityInwardsKernelMessage>();

            if (!waternetExtremeKernelMessages.Any() && !waternetDailyKernelMessages.Any())
            {
                IUpliftVanCalculator calculator = GetCalculator(calculation, generalInput, normativeAssessmentLevel);

                try
                {
                    kernelMessages = calculator.Validate().ToArray();
                }
                catch (UpliftVanCalculatorException e)
                {
                    HandleExceptionOnValidation(e);

                    return(false);
                }

                LogKernelMessages(kernelMessages);
            }

            CalculationServiceHelper.LogValidationEnd();

            return(kernelMessages.Concat(waternetDailyKernelMessages)
                   .Concat(waternetExtremeKernelMessages)
                   .All(r => r.Type != MacroStabilityInwardsKernelMessageType.Error));
        }
Beispiel #19
0
        private static UpliftVanCalculatorInput CreateInputFromData(MacroStabilityInwardsInput inputParameters, GeneralMacroStabilityInwardsInput generalInput, RoundedDouble normativeAssessmentLevel)
        {
            RoundedDouble effectiveAssessmentLevel = GetEffectiveAssessmentLevel(inputParameters, normativeAssessmentLevel);

            return(new UpliftVanCalculatorInput(
                       new UpliftVanCalculatorInput.ConstructionProperties
            {
                AssessmentLevel = effectiveAssessmentLevel,
                SurfaceLine = inputParameters.SurfaceLine,
                SoilProfile = SoilProfileConverter.Convert(inputParameters.SoilProfileUnderSurfaceLine),
                DrainageConstruction = DrainageConstructionConverter.Convert(inputParameters),
                PhreaticLineOffsetsExtreme = PhreaticLineOffsetsConverter.Convert(inputParameters.LocationInputExtreme),
                PhreaticLineOffsetsDaily = PhreaticLineOffsetsConverter.Convert(inputParameters.LocationInputDaily),
                SlipPlane = UpliftVanSlipPlaneConverter.Convert(inputParameters),
                SlipPlaneConstraints = UpliftVanSlipPlaneConstraintsConverter.Convert(inputParameters),
                DikeSoilScenario = inputParameters.DikeSoilScenario,
                WaterLevelRiverAverage = inputParameters.WaterLevelRiverAverage,
                WaterLevelPolderExtreme = inputParameters.LocationInputExtreme.WaterLevelPolder,
                WaterLevelPolderDaily = inputParameters.LocationInputDaily.WaterLevelPolder,
                MinimumLevelPhreaticLineAtDikeTopRiver = inputParameters.MinimumLevelPhreaticLineAtDikeTopRiver,
                MinimumLevelPhreaticLineAtDikeTopPolder = inputParameters.MinimumLevelPhreaticLineAtDikeTopPolder,
                LeakageLengthOutwardsPhreaticLine3 = inputParameters.LeakageLengthOutwardsPhreaticLine3,
                LeakageLengthInwardsPhreaticLine3 = inputParameters.LeakageLengthInwardsPhreaticLine3,
                LeakageLengthOutwardsPhreaticLine4 = inputParameters.DikeSoilScenario != MacroStabilityInwardsDikeSoilScenario.ClayDikeOnSand
                                                             ? inputParameters.LeakageLengthOutwardsPhreaticLine4
                                                             : 1.0,
                LeakageLengthInwardsPhreaticLine4 = inputParameters.DikeSoilScenario != MacroStabilityInwardsDikeSoilScenario.ClayDikeOnSand
                                                            ? inputParameters.LeakageLengthInwardsPhreaticLine4
                                                            : 1.0,
                PiezometricHeadPhreaticLine2Outwards = inputParameters.PiezometricHeadPhreaticLine2Outwards,
                PiezometricHeadPhreaticLine2Inwards = inputParameters.PiezometricHeadPhreaticLine2Inwards,
                PenetrationLengthExtreme = inputParameters.LocationInputExtreme.PenetrationLength,
                PenetrationLengthDaily = inputParameters.LocationInputDaily.PenetrationLength,
                AdjustPhreaticLine3And4ForUplift = inputParameters.AdjustPhreaticLine3And4ForUplift,
                MoveGrid = inputParameters.MoveGrid,
                MaximumSliceWidth = inputParameters.MaximumSliceWidth,
                WaterVolumetricWeight = generalInput.WaterVolumetricWeight
            }));
        }