using System;
using Deltares.Geometry;
using Deltares.Geotechnics;
using Deltares.Geotechnics.SurfaceLines;
using Deltares.Standard;
using Deltares.Standard.Attributes;
using Deltares.Standard.EventPublisher;
using Deltares.Standard.Units;
using Deltares.Standard.Validation;
namespace Deltares.Stability
{
///
/// UniformLoads Data class
///
[Serializable]
public class UniformLoad : GeometryObject //, IUniformLoad
{
#region LoadTypeEnum enum
///
/// LoadType enum
///
public enum LoadTypeEnum
{
Permanent = 0,
Temporary = 1
}
#endregion
private double distriAngle = 0;
private LoadTypeEnum loadType;
private double magnitude = 0;
private SurfaceLine2 surfaceLine;
private double xEnd = 0;
private double xStart = 0;
public UniformLoad()
{
// setting default values
magnitude = 0;
xStart = 0;
xEnd = 0;
distriAngle = 0;
loadType = LoadTypeEnum.Permanent;
}
public SurfaceLine2 SurfaceLine2
{
get
{
return surfaceLine;
}
set
{
surfaceLine = value;
}
}
///
/// Magnitude of the UniformLoad
///
[Unit(UnitType.Pressure)]
[Minimum(-10000)]
[Maximum(100000)]
[PropertyOrder(1)]
[Format("F3")]
public double Magnitude
{
get
{
return magnitude;
}
set
{
DataEventPublisher.BeforeChange(this, "Magnitude");
magnitude = value;
DataEventPublisher.AfterChange(this, "Magnitude");
}
}
///
/// X Co-ordinate at Start of the UniformLoad
///
[Unit(UnitType.Length)]
[Minimum(-1.000e+06)]
[Maximum(1.000e+06)]
[PropertyOrder(2)]
[Format("F3")]
public double XStart
{
get
{
return xStart;
}
set
{
DataEventPublisher.BeforeChange(this, "XStart");
xStart = value;
DataEventPublisher.AfterChange(this, "XStart");
}
}
///
/// X Co-ordinate at end of the UniformLoad
///
[Unit(UnitType.Length)]
[Minimum(-1.000e+06)]
[Maximum(1.000e+06)]
[PropertyOrder(3)]
[Format("F3")]
public double XEnd
{
get
{
return xEnd;
}
set
{
DataEventPublisher.BeforeChange(this, "XEnd");
xEnd = value;
DataEventPublisher.AfterChange(this, "XEnd");
}
}
///
/// Distribution of the UniformLoad
///
[Unit(UnitType.Angle)]
[Minimum(0)]
[Maximum(90)]
[PropertyOrder(5)]
[Format("F3")]
public double DistributionAngle
{
get
{
return distriAngle;
}
set
{
DataEventPublisher.BeforeChange(this, "DistributionAngle");
distriAngle = value;
DataEventPublisher.AfterChange(this, "DistributionAngle");
}
}
///
/// Load type of the UniformLoad
///
///
//[Browsable(false)]
[PropertyOrder(6)]
public LoadTypeEnum LoadType
{
get
{
return loadType;
}
set
{
DataEventPublisher.BeforeChange(this, "LoadType");
loadType = value;
DataEventPublisher.AfterChange(this, "LoadType");
}
}
/*=======================================================================================================================
Description: Calculates the stress due to a uniform load at a point(AX,AY);
Date ID Modification
1999-03-04 Best Created
======================================================================================*/
public double GetStressAtPosition(double AX, double AY)
{
const double CPir = Math.PI/180.0;
double Ly1;
double Ly2;
double Ldx1;
double Ldx2;
double LLoadAfstand;
double result = 0.0;
// bepaal de y coordinaten van de belasting op het maaiveld
Ly1 = SurfaceLine2.Geometry.GetZAtX(xStart);
Ly2 = SurfaceLine2.Geometry.GetZAtX(xEnd);
// bepaal de breedte van het spreidings oppervlak op de gewenste diepte }
Ldx1 = (Ly1 - AY)*Math.Tan(distriAngle*CPir);
Ldx2 = (Ly2 - AY)*Math.Tan(distriAngle*CPir);
if (AX >= (xStart - Ldx1) && (AX <= (xEnd + Ldx2)))
{
// indien de x in het spreidings gebied ligt dan meenemen }
LLoadAfstand = xEnd - xStart;
if ((LLoadAfstand + Ldx1 + Ldx2) != 0.0)
{
result = magnitude*LLoadAfstand/(LLoadAfstand + Ldx1 + Ldx2);
}
}
return result;
}
public double GetMomentRoundX(double xCenter, double xCircleEntry, double xCircleExit)
{
double result;
double lXcl;
double lXcr;
double lLoadL;
double lloadR;
// Circelpunt links en rechts opsporen
if (xCircleEntry < xCircleExit)
{
lXcl = xCircleEntry;
lXcr = xCircleExit;
}
else
{
lXcr = xCircleEntry;
lXcl = xCircleExit;
}
// Load punten links en rechts opsporen
if (XStart < XEnd)
{
lLoadL = XStart;
lloadR = XEnd;
}
else
{
lloadR = XStart;
lLoadL = XEnd;
}
if (lXcr < lLoadL || lXcl > lloadR)
{
result = 0;
}
else
{
double lStart = Math.Max(lXcl, lLoadL);
double lEnd = Math.Min(lXcr, lloadR);
double lTotalLoad = (lEnd - lStart)*- Magnitude;
result = lTotalLoad*((lStart + lEnd)/2.0 - xCenter);
}
return result;
}
//#region Backwards compatibility
//[XmlIgnore]
//[Obsolete("Only exists for backwards compatibility; Use SurfaceLine2 instead.", true)]
//public BaseSurfaceLine SurfaceLine
//{
// get { return null; }
// set
// {
// var adapter = value as SurfaceLineAdapter;
// if (adapter != null)
// {
// surfaceLine = adapter.GetWrappedSurfaceLine();
// adapter.Dispose();
// }
// else
// {
// surfaceLine = new OldSurfaceLineToNewConverter().Convert(value);
// value.Dispose();
// }
// }
//}
//#endregion
}
}