// 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; using Deltares.WTIStability.Data.Geo; using Deltares.WTIStability.Data.Standard; using Ringtoets.MacroStabilityInwards.KernelWrapper.Creators; using Ringtoets.MacroStabilityInwards.KernelWrapper.SubCalculator; using Ringtoets.MacroStabilityInwards.Primitives; using Ringtoets.MacroStabilityInwards.Primitives.MacroStabilityInwardsSoilUnderSurfaceLine; namespace Ringtoets.MacroStabilityInwards.KernelWrapper { /// /// This class represents a combination of macro stability inwards sub calculations, which together can be used /// to assess based on macro stability inwards. /// public class MacroStabilityInwardsCalculator { private readonly MacroStabilityInwardsCalculatorInput input; private readonly IMacroStabilityInwardsSubCalculatorFactory factory; private GeometryData geometryData; /// /// Constructs a new . The is used to /// obtain the parameters used in the different sub calculations. /// /// The containing all the values required /// for performing a macro stability inwards calculation. /// The factory responsible for creating the sub calculators. /// or is null. public MacroStabilityInwardsCalculator(MacroStabilityInwardsCalculatorInput input, IMacroStabilityInwardsSubCalculatorFactory factory) { if (input == null) { throw new ArgumentNullException(nameof(input), @"MacroStabilityInwardsCalculatorInput required for creating a MacroStabilityInwardsCalculator."); } if (factory == null) { throw new ArgumentNullException(nameof(factory), @"IMacroStabilityInwardsSubCalculatorFactory required for creating a MacroStabilityInwardsCalculator."); } this.input = input; this.factory = factory; } /// /// Performs the actual sub calculations and returns a , which /// contains the results of all sub calculations. /// /// A containing the results of the sub calculations. public MacroStabilityInwardsCalculatorResult Calculate() { IUpliftVanCalculator upliftVanCalculator = CalculateUpliftVan(); return new MacroStabilityInwardsCalculatorResult(); } private IUpliftVanCalculator CalculateUpliftVan() { IUpliftVanCalculator upliftVanCalculator = CreateUpliftVanCalculator(); upliftVanCalculator.Calculate(); return upliftVanCalculator; } private IUpliftVanCalculator CreateUpliftVanCalculator() { IUpliftVanCalculator calculator = factory.CreateUpliftVanCalculator(); calculator.MoveGrid = input.MoveGrid; calculator.MaximumSliceWidth = input.MaximumSliceWidth; Soil[] soils = SoilCreator.Create(input.SoilProfile); calculator.SoilModel = SoilModelCreator.Create(soils); Dictionary layersWithSoils = input.SoilProfile.LayersUnderSurfaceLine .Zip(soils, (layer, soil) => new { layer, soil }) .ToDictionary(x => x.layer, x => x.soil); calculator.SoilProfile = SoilProfileCreator.Create(input.SoilProfile, layersWithSoils); calculator.Location = StabilityLocationCreator.Create(input); calculator.SurfaceLine = SurfaceLineCreator.Create(input.SurfaceLine); calculator.SlipPlaneUpliftVan = SlipPlaneUpliftVanCreator.Create(input); calculator.GridAutomaticDetermined = input.GridAutomaticDetermined; return calculator; } /// /// Returns a list of validation messages. The validation messages are based on the values of the /// which was provided to this and are determined by the kernel. /// public List Validate() { return new List(); } } }