// Copyright (C) Stichting Deltares 2018. 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 System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Deltares.DamEngine.Calculators.PlLinesCreator;
using Deltares.DamEngine.Data.General;
using Deltares.DamEngine.Data.General.PlLines;
using Deltares.DamEngine.Data.Geotechnics;
namespace Deltares.DamEngine.Calculators.KernelWrappers.Common
{
///
/// Helper for Pl Lines
///
public class PlLinesHelper
{
///
/// Creates the pl lines.
///
/// The location.
/// The soil profile.
/// The water level.
/// The uplift situation.
///
public static PLLines CreatePlLinesForStability(Location location, SoilGeometryProbability subSoilScenario,
double waterLevel, string soilGeometry2DName, double waterLevelRiverLow, out UpliftSituation upliftSituation)
{
var plLinesCreator = new PLLinesCreator
{
WaterLevelRiverLow = waterLevelRiverLow,
IsUseLowWaterLevel = !double.IsNaN(waterLevelRiverLow),
WaterLevelRiverHigh = waterLevel,
SurfaceLine = location.SurfaceLine,
WaterLevelPolder = location.PolderLevel,
HeadInPLLine2 = location.HeadPl2,
HeadInPLLine3 = location.HeadPl3,
HeadInPLLine4 = location.HeadPl4,
ModelParametersForPLLines = location.ModelParametersForPLLines,
SoilProfile = subSoilScenario.SoilProfile1D,
SoilProfileType = subSoilScenario.SoilProfileType,
SoilGeometry2DName = soilGeometry2DName,
GaugePLLines = null, // TODO: Operational
Gauges = null, // TODO: Operational
IsAdjustPL3AndPL4SoNoUpliftWillOccurEnabled = true, // for stability this must be set to true
PlLineOffsetBelowDikeTopAtRiver = location.PlLineOffsetBelowDikeTopAtRiver,
PlLineOffsetBelowDikeTopAtPolder = location.PlLineOffsetBelowDikeTopAtPolder,
PlLineOffsetBelowShoulderBaseInside = location.PlLineOffsetBelowShoulderBaseInside,
PlLineOffsetBelowDikeToeAtPolder = location.PlLineOffsetBelowDikeToeAtPolder,
DikeEmbankmentMaterial = location.GetDikeEmbankmentSoil(),
IsHydraulicShortcut = false, // TODO: Regional
XSoilGeometry2DOrigin = location.XSoilGeometry2DOrigin,
SoilList = location.SoilList
};
var plLines = plLinesCreator.CreateAllPLLines(location);
upliftSituation.Pl3HeadAdjusted = plLinesCreator.Pl3HeadAdjusted;
upliftSituation.Pl3LocationXMinUplift = plLinesCreator.Pl3LocationXMinUplift;
upliftSituation.Pl3MinUplift = plLinesCreator.Pl3MinUplift;
upliftSituation.Pl4HeadAdjusted = plLinesCreator.Pl4HeadAdjusted;
upliftSituation.Pl4LocationXMinUplift = plLinesCreator.Pl4LocationXMinUplift;
upliftSituation.Pl4MinUplift = plLinesCreator.Pl4MinUplift;
upliftSituation.IsUplift = false; // must be determined later on; just to avoid compiler error
return plLines;
}
///
/// Creates the pl lines.
///
/// The location.
/// The soil profile.
/// The water level.
/// The uplift situation.
///
public static PLLines CreatePlLines(Location location, SoilProfile1D soilProfile, double waterLevel, out UpliftSituation upliftSituation)
{
var plLinesCreator = new PLLinesCreator
{
WaterLevelRiverHigh = waterLevel,
SurfaceLine = location.SurfaceLine,
WaterLevelPolder = location.PolderLevel,
HeadInPLLine2 = location.HeadPl2,
HeadInPLLine3 = location.HeadPl3,
HeadInPLLine4 = location.HeadPl4,
ModelParametersForPLLines = location.ModelParametersForPLLines,
SoilProfile = soilProfile,
GaugePLLines = null, // TODO: Operational
Gauges = null, // TODO: Operational
IsAdjustPL3AndPL4SoNoUpliftWillOccurEnabled = false, // for piping this must be set to false
PlLineOffsetBelowDikeTopAtRiver = location.PlLineOffsetBelowDikeTopAtRiver,
PlLineOffsetBelowDikeTopAtPolder = location.PlLineOffsetBelowDikeTopAtPolder,
DikeEmbankmentMaterial = location.GetDikeEmbankmentSoil(),
IsHydraulicShortcut = false, // TODO: Regional
XSoilGeometry2DOrigin = location.XSoilGeometry2DOrigin
};
var plLines = plLinesCreator.CreateAllPLLines(location);
upliftSituation.Pl3HeadAdjusted = plLinesCreator.Pl3HeadAdjusted;
upliftSituation.Pl3LocationXMinUplift = plLinesCreator.Pl3LocationXMinUplift;
upliftSituation.Pl3MinUplift = plLinesCreator.Pl3MinUplift;
upliftSituation.Pl4HeadAdjusted = plLinesCreator.Pl4HeadAdjusted;
upliftSituation.Pl4LocationXMinUplift = plLinesCreator.Pl4LocationXMinUplift;
upliftSituation.Pl4MinUplift = plLinesCreator.Pl4MinUplift;
upliftSituation.IsUplift = false; // must be determined later on; just to avoid compiler error
return plLines;
}
}
}