// Copyright (C) Stichting Deltares 2025. All rights reserved. // // This file is part of the Dam Engine. // // The Dam Engine is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero 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 Affero General Public License for more details. // // You should have received a copy of the GNU Affero 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.DamEngine.Data.Design; using Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.Geometry; using Deltares.DamEngine.Data.Geotechnics; using Deltares.DamEngine.TestHelpers.Factories; namespace Deltares.DamEngine.Calculators.Tests.KernelWrappers.TestHelpers; /// /// Factory which creates instances of Dam data which can be used for testing. /// public static class DamEngineDataTestFactory { /// /// Creates the location for testing. /// /// The surface line. /// public static Location CreateLocation(SurfaceLine2 surfaceLine) { var location = new Location(); var scenario = new DesignScenario(); location.CurrentScenario = scenario; location.Name = "LocationName"; location.DikeEmbankmentMaterial = "OB1"; location.ShoulderEmbankmentMaterial = "OB2"; location.SoilList = CreateSoilList(); Point2D dikeToe = surfaceLine.CharacteristicPoints.GetPoint2D(CharacteristicPointType.DikeToeAtRiver); dikeToe.Z = dikeToe.Z - 0.01; location.SurfaceLine = surfaceLine; return location; } /// /// Creates a 2D soil profile for the tests. /// /// public static SoilProfile2D CreateSoilProfile2D(SoilList soiList) { var soilProfile2D = new SoilProfile2D(); var geometry = new GeometryData(); geometry.Left = 0; geometry.Right = 100; geometry.Bottom = -10; soilProfile2D.Geometry = geometry; SoilLayer2D layer1 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(1, -5, 0, 100, soilProfile2D, null, true); layer1.Name = "Layer 1"; layer1.Soil = soiList != null ? soiList.GetSoilByName("OA") : new Soil("OA", 18, 17); layer1.Soil.ShearStrengthModel = ShearStrengthModel.CPhi; layer1.WaterpressureInterpolationModel = WaterpressureInterpolationModel.Hydrostatic; soilProfile2D.Geometry.Surfaces.Add(layer1.GeometrySurface); soilProfile2D.Surfaces.Add(layer1); SoilLayer2D layer2 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(-5, -10, 0, 100, soilProfile2D, null, true); layer2.Name = "Layer 2"; layer2.Soil = soiList != null ? soiList.GetSoilByName("LM") : new Soil("LM", 18, 17); layer2.Soil.ShearStrengthModel = ShearStrengthModel.CPhi; layer2.WaterpressureInterpolationModel = WaterpressureInterpolationModel.Hydrostatic; soilProfile2D.Geometry.Surfaces.Add(layer2.GeometrySurface); soilProfile2D.Surfaces.Add(layer2); SoilLayer2D layer3 = FactoryForSoilProfiles.CreateRectangularSoilLayer2D(-10, -15, 0, 100, soilProfile2D); soilProfile2D.Geometry.Surfaces.Add(layer3.GeometrySurface); soilProfile2D.Surfaces.Add(layer3); return soilProfile2D; } /// /// Creates a 1D soil profile for the tests. /// /// public static SoilProfile1D CreateSoilProfile1D(SoilList soiList) { var soilProfile1D = new SoilProfile1D(); soilProfile1D.BottomLevel = -40; var layer = new SoilLayer1D { Name = "Layer 1", Soil = soiList.GetSoilByName("OA") }; layer.TopLevel = -3; layer.IsAquifer = true; soilProfile1D.Layers.Add(layer); layer = new SoilLayer1D { Name = "Layer 2", Soil = soiList.GetSoilByName("LM") }; layer.TopLevel = -5; layer.IsAquifer = true; soilProfile1D.Layers.Add(layer); layer = new SoilLayer1D { Name = "Layer 3", Soil = soiList.GetSoilByName("LM") }; layer.TopLevel = -10; layer.IsAquifer = true; soilProfile1D.Layers.Add(layer); return soilProfile1D; } /// /// Creates the soil list for the tests. /// /// private static SoilList CreateSoilList() { var soilList = new SoilList(); var s1 = new Soil("OA") { AbovePhreaticLevel = 18.00, BelowPhreaticLevel = 20.00, ShearStrengthModel = ShearStrengthModel.CPhi, FrictionAngle = 30, Cohesion = 0 }; soilList.Soils.Add(s1); var s2 = new Soil("LM") { AbovePhreaticLevel = 17.00, BelowPhreaticLevel = 17.50, ShearStrengthModel = ShearStrengthModel.CPhi, FrictionAngle = 10, Cohesion = 5 }; soilList.Soils.Add(s2); var s3 = new Soil("OB1") { AbovePhreaticLevel = 18.10, BelowPhreaticLevel = 20.10, ShearStrengthModel = ShearStrengthModel.CPhi, FrictionAngle = 31, Cohesion = 0 }; soilList.Soils.Add(s3); var s4 = new Soil("OB2") { AbovePhreaticLevel = 17.50, BelowPhreaticLevel = 19.50, ShearStrengthModel = ShearStrengthModel.CPhi, FrictionAngle = 34, Cohesion = 0 }; soilList.Soils.Add(s4); return soilList; } }