// 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.Linq; using Deltares.WTIStability.Data.Geo; using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.UpliftVan.Input; using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.UpliftVan.Output; using Ringtoets.MacroStabilityInwards.KernelWrapper.Creators.Input; using Ringtoets.MacroStabilityInwards.KernelWrapper.Creators.Output; using Ringtoets.MacroStabilityInwards.KernelWrapper.Kernels; using Ringtoets.MacroStabilityInwards.KernelWrapper.Kernels.UpliftVan; using Ringtoets.MacroStabilityInwards.Primitives.MacroStabilityInwardsSoilUnderSurfaceLine; namespace Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.UpliftVan { /// /// Class representing an Uplift Van calculator. /// public class UpliftVanCalculator : IUpliftVanCalculator { private readonly UpliftVanCalculatorInput input; private readonly IMacroStabilityInwardsKernelFactory factory; /// /// Creates a new instance of . /// /// The containing all the values required /// for performing the Uplift Van calculation. /// The factory responsible for creating the Uplift Van kernel. /// Thrown when or is null. public UpliftVanCalculator(UpliftVanCalculatorInput input, IMacroStabilityInwardsKernelFactory factory) { if (input == null) { throw new ArgumentNullException(nameof(input), @"UpliftVanCalculatorInput required for creating a UpliftVanCalculator."); } if (factory == null) { throw new ArgumentNullException(nameof(factory), @"IMacroStabilityInwardsKernelFactory required for creating a UpliftVanCalculator."); } this.input = input; this.factory = factory; } public UpliftVanCalculatorResult Calculate() { IUpliftVanKernel upliftVanKernel = CalculateUpliftVan(); return new UpliftVanCalculatorResult( UpliftVanSlidingCurveResultCreator.Create(upliftVanKernel.SlidingCurveResult), UpliftVanCalculationGridResultCreator.Create(upliftVanKernel.SlipPlaneResult), new UpliftVanCalculatorResult.ConstructionProperties { FactorOfStability = upliftVanKernel.FactorOfStability, ZValue = upliftVanKernel.ZValue, ForbiddenZonesXEntryMin = upliftVanKernel.ForbiddenZonesXEntryMin, ForbiddenZonesXEntryMax = upliftVanKernel.ForbiddenZonesXEntryMax, ForbiddenZonesAutomaticallyCalculated = upliftVanKernel.ForbiddenZonesAutomaticallyCalculated, GridAutomaticallyCalculated = upliftVanKernel.GridAutomaticallyCalculated }); } public List Validate() { return new List(); } private IUpliftVanKernel CalculateUpliftVan() { IUpliftVanKernel upliftVanKernel = CreateUpliftVanKernel(); try { upliftVanKernel.Calculate(); } catch (Exception e) { // Temporary do nothing } return upliftVanKernel; } private IUpliftVanKernel CreateUpliftVanKernel() { IUpliftVanKernel upliftVanKernel = factory.CreateUpliftVanKernel(); upliftVanKernel.MoveGrid = input.MoveGrid; upliftVanKernel.MaximumSliceWidth = input.MaximumSliceWidth; Soil[] soils = SoilCreator.Create(input.SoilProfile); upliftVanKernel.SoilModel = SoilModelCreator.Create(soils); Dictionary layersWithSoils = input.SoilProfile.Layers .Zip(soils, (layer, soil) => new { layer, soil }) .ToDictionary(x => x.layer, x => x.soil); upliftVanKernel.SoilProfile = SoilProfileCreator.Create(input.SoilProfile, layersWithSoils); upliftVanKernel.Location = StabilityLocationCreator.Create(input); upliftVanKernel.SurfaceLine = SurfaceLineCreator.Create(input.SurfaceLine); upliftVanKernel.SlipPlaneUpliftVan = SlipPlaneUpliftVanCreator.Create(input); upliftVanKernel.GridAutomaticDetermined = input.GridAutomaticDetermined; upliftVanKernel.CreateZones = input.CreateZones; upliftVanKernel.AutomaticForbiddenZones = input.AutomaticForbiddenZones; upliftVanKernel.SlipPlaneMinimumDepth = input.SlipPlaneMinimumDepth; upliftVanKernel.SlipPlaneMinimumLength = input.SlipPlaneMinimumLength; return upliftVanKernel; } } }