// Copyright (C) Stichting Deltares 2017. All rights reserved. // // This file is part of the application DAM - UI. // // DAM - UI 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 Deltares.Geometry; using Deltares.Geotechnics; using System.IO; using Deltares.Dam.Data; using Deltares.Geotechnics.Soils; using Deltares.Geotechnics.SurfaceLines; using Deltares.Geotechnics.TestUtils; using Segment = Deltares.Dam.Data.Segment; namespace Deltares.Dam.TestHelper { public static class FactoryForStabilityTests { public const string cSoilDatabaseName = @"TestData\soilmaterials.mdb"; public static Dike CreateDike() { var dike = new Dike(); var surfaceLineTutorial1 = FactoryForSurfaceLineTests.CreateSurfaceLineTutorial1(); Location location = CreateLocation(surfaceLineTutorial1); dike.Locations.Add(location); dike.SurfaceLines2.Add(surfaceLineTutorial1); // Define soil probability of 1.0 for single profile for stability var soilGeometryProbability = new SoilGeometryProbability() { SoilProfile = CreateSoilProfile(), Probability = 1.0, SegmentFailureMechanismType = FailureMechanismSystemType.StabilityInside }; // Define segment var segment = new Segment(); segment.Name = "SegmentName"; segment.SoilProfileProbabilities.Add(soilGeometryProbability); // dike.Segments.Add(segment); dike.Locations[0].Segment = segment; dike.SoilDatabaseName = cSoilDatabaseName; dike.CreateSoilBase(); return dike; } /// /// Create location for tests /// /// The instance to be set on . /// public static Location CreateLocation(SurfaceLine2 surfaceLine) { Location location = new Location(); location.Name = "LocationName"; location.DamType = DamType.Regional; location.DikeEmbankmentMaterial = "OB1"; location.ShoulderEmbankmentMaterial = "OB2"; location.SoildatabaseName = Path.Combine(@".\", cSoilDatabaseName); location.SurfaceLine2 = surfaceLine; SurfaceLine2 localSurfaceLine = location.SurfaceLine2.FullDeepClone(); CoordinateSystemConverter coordinateSystemConverter = new CoordinateSystemConverter(); coordinateSystemConverter.ConvertGlobalXYZToLocalXZ(localSurfaceLine.Geometry); location.LocalXZSurfaceLine2 = localSurfaceLine; location.ModelFactors.RequiredSafetyFactorStabilityInnerSlope = 1; return location; } /// /// Create scenario with location for tests /// /// public static Scenario CreateScenarioForLocation(Location location, SurfaceLine2 surfaceLine) { Scenario scenario = new Scenario(); scenario.Location = location; scenario.Location.DamType = DamType.Regional; scenario.Location.Name = "LocationName"; scenario.Location.DikeEmbankmentMaterial = "OB1"; scenario.Location.ShoulderEmbankmentMaterial = "OB2"; scenario.Location.SoildatabaseName = Path.Combine(@".\", cSoilDatabaseName); scenario.Location.SoilList = scenario.Location.SoilbaseDB.CreateSoilList(); scenario.LocationScenarioID = "ScenarioID"; scenario.Location.SurfaceLine2 = surfaceLine; CoordinateSystemConverter coordinateSystemConverter = new CoordinateSystemConverter(); var localSurfaceLine = scenario.Location.SurfaceLine2.FullDeepClone(); coordinateSystemConverter.ConvertGlobalXYZToLocalXZ(localSurfaceLine.Geometry); scenario.Location.LocalXZSurfaceLine2 = localSurfaceLine; return scenario; } /// /// Create standard 4 layer soilprofile for tests /// /// public static SoilProfile1D CreateSoilProfile() { SoilProfile1D soilProfile = FactoryForSoilProfileTests.CreateClaySandClaySandProfile(); soilProfile.Name = "SoilProfileName"; soilProfile.Layers[0].Soil.Name = "DKN3"; soilProfile.Layers[1].Soil.Name = "zand"; soilProfile.Layers[2].Soil.Name = "DKN3"; soilProfile.Layers[3].Soil.Name = "zand"; return soilProfile; } /// /// Create standard calculation parameters for tests /// /// public static MStabParameters CreateMStabParameters() { MStabParameters mstabParameters = new MStabParameters(); mstabParameters.Model = MStabModelType.Bishop; mstabParameters.ShearStrength = MStabShearStrength.CPhi; mstabParameters.IsProbabilistic = false; mstabParameters.SoilDatabaseName = Path.Combine(@".\", cSoilDatabaseName); mstabParameters.SearchMethod = MStabSearchMethod.GeneticAlgorithm; mstabParameters.GridPosition = MStabGridPosition.Right; mstabParameters.CalculationOptions = new MStabCalculationOptions(); return mstabParameters; } } }