// Copyright (C) Stichting Deltares 2018. 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 System.Collections.Generic;
using System.IO;
using Deltares.Dam.Data;
using Deltares.Dam.Data.DataPlugins.Configuration;
namespace Deltares.Dam.Tests
{
public class DamIntegrationTestHelper
{
///
/// Read dam data from folder with csv files
///
///
///
public static DamProjectData CreateDamProjectDataFromCsvFiles(string cFolderName)
{
var damProject = new DamProject();
damProject.DamProjectData = new DamProjectData();
var source = new DataSource();
source.DataSourceType = DataSourceType.CsvFiles;
source.DataLocation = "";
var soilSource = new DataSource();
soilSource.DataSourceType = DataSourceType.MSoilBase;
soilSource.DataLocation = "./soilmaterials.mdb";
var container = new DataSourceContainer();
container.DataSourceList.AddRange(new[] {source, soilSource});
damProject.Import(cFolderName, container, new [] {"Dike from CSV"}, DamType.Regional, DamProjectType.Design, null);
return damProject.DamProjectData;
}
///
/// Specifies the locations to calculate.
///
/// The dam project data.
/// The location ids.
public static void SpecifyLocationsToCalculate(DamProjectData damProjectData, IList locationIds)
{
foreach (var locationJob in damProjectData.LocationJobs)
{
locationJob.Run = (locationIds.Contains(locationJob.Location.Name));
}
}
///
/// Add calculaton specifications to Dam project data
///
///
public static void AddCalculationSpecificationsToDamProjectData(DamProjectData damProjectData)
{
MStabParameters mstabParameters = CreateMStabParameters();
mstabParameters.SoilDatabaseName = damProjectData.WaterBoard.Dikes[0].SoilDatabaseName;
var damCalculationSpecification = new DamFailureMechanismeCalculationSpecification()
{
FailureMechanismSystemType = FailureMechanismSystemType.StabilityInside,
FailureMechanismeParamatersMStab = new FailureMechanismeParamatersMStab()
{
MStabParameters = mstabParameters
}
};
DamProjectCalculationSpecification.SelectedAnalysisType = AnalysisType.NoAdaption;
damProjectData.DamProjectCalculationSpecification.SelectedProbabilisticType = ProbabilisticType.Deterministic;
damProjectData.DamProjectCalculationSpecification.DamCalculationSpecifications.Add(damCalculationSpecification);
}
///
/// Create standard calculation parameters for tests
///
///
public static MStabParameters CreateMStabParameters()
{
const string cSoilDatabaseName = @"soilmaterials.mdb";
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;
}
}
}