// 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 Deltares.DamEngine.Calculators.Properties;
using Deltares.DamEngine.Calculators.Uplift;
using Deltares.DamEngine.Data.General;
using Deltares.DamEngine.Data.General.PlLines;
using Deltares.DamEngine.Data.Geometry;
using Deltares.DamEngine.Data.Geotechnics;
using Deltares.DamEngine.Data.Standard;
namespace Deltares.DamEngine.Calculators.KernelWrappers.Common
{
///
/// Helper for Dam Piping kernels
///
public static class DamPipingHelper
{
///
/// Determines the total thickness of the cover layer.
///
/// The top level aquifer.
/// The surface level.
///
public static double DetermineHeightCoverLayer(double topLevelAquifer, double surfaceLevel)
{
var d = surfaceLevel - topLevelAquifer;
// if d is negative then top of aquifer is higher than surface layer.
// This means that the aquifer is exposed on the surface.
// In this case d = 0
d = Math.Max(0, d);
return d;
}
///
/// Determines the pl-lines and the uplift location.
///
/// The dam kernel input.
/// The point.
/// The pl lines.
/// The uplift location and result.
public static void DeterminePlLinesAndUpliftLocation(DamKernelInput damKernelInput, GeometryPoint point, out PlLines plLines, out UpliftLocationAndResult upliftLocationAndResult)
{
Location location = damKernelInput.Location;
SoilProfile1D soilProfile = damKernelInput.SubSoilScenario.SoilProfile1D;
SurfaceLine2 surfaceLine = damKernelInput.Location.SurfaceLine;
ThrowHelper.ThrowWhenConditionIsTrue(
string.Format(Resources.NoSoilProfile1DDefinedForLocation, location.Name),
() => (soilProfile == null || soilProfile.Layers.Count < 1));
ThrowHelper.ThrowIfArgumentNull(soilProfile, string.Format(Resources.NoSurfaceLineDefinedForLocation, location.Name));
GeometryPoint entryPoint = surfaceLine.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtRiver);
ThrowHelper.ThrowIfArgumentNull(entryPoint, string.Format(Resources.NoDikeToeDefinedForLocation, location.Name));
ThrowHelper.ThrowIfArgumentNull(soilProfile.BottomAquiferLayer, string.Format(Resources.NoBottomAquiferLayer, soilProfile.Name));
UpliftSituation upliftSituation;
plLines = PlLinesHelper.CreatePlLinesForPiping(damKernelInput.Location, damKernelInput.SubSoilScenario.SoilProfile1D,
damKernelInput.RiverLevelHigh,
damKernelInput.DamFailureMechanismeCalculationSpecification.AssessmentScenarioJobSettings.HydraulicShortcutType,
out upliftSituation);
UpliftLocationDeterminator upliftLocationDeterminator = new UpliftLocationDeterminator
{
PlLines = plLines,
SoilProfile = soilProfile,
SurfaceLine = surfaceLine,
DikeEmbankmentMaterial = location.GetDikeEmbankmentSoil(),
XSoilGeometry2DOrigin = location.XSoilGeometry2DOrigin
};
upliftLocationAndResult = upliftLocationDeterminator.GetUpliftFactorAtPoint(point);
}
}
}