using System; using System.Collections.Generic; using System.Diagnostics; using System.Runtime.Serialization; using Deltares.Geometry; using Deltares.Geotechnics; using Deltares.Geotechnics.Consolidation; using Deltares.Geotechnics.Soils; using Deltares.Stability; namespace Deltares.MStab.IO.Classic { [Serializable] public class LoadsException : Exception { // // For guidelines regarding the creation of new exception types, see // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp // and // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp // public LoadsException() {} public LoadsException(string message) : base(message) {} public LoadsException(string message, Exception inner) : base(message, inner) {} protected LoadsException( SerializationInfo info, StreamingContext context) : base(info, context) {} } internal class Loads { /// /// Manders Create loads objects (PressurePerLength, Uniformload, EarthQuake, EarthQuakeDegree and TreeOnSlope). /// /// public void GetLoads(int handle, StabilityModel stabilityModel, Dictionary surfaceDictionary) { try { //Lineloads ClassicMStabFunctionDefinitions.MStabLineLoads lineloads = null; GetClassicMStab.GetClassicLineLoads(handle, ref lineloads); for (int i = 0; i < lineloads.nLineLoads; i++) { var newlineload = new LineLoad(); newlineload.Name = lineloads.lineLoad[i].itemName; newlineload.Direction = lineloads.lineLoad[i].dirAngle; newlineload.Distribution = lineloads.lineLoad[i].distriAngle; newlineload.Magnitude = lineloads.lineLoad[i].magnitude; newlineload.X = lineloads.lineLoad[i].x; newlineload.Z = lineloads.lineLoad[i].y; newlineload.Y = 0.0; stabilityModel.Create(newlineload); } // Default nail ClassicMStabFunctionDefinitions.MStabDefaultNail defaultNail = null; GetClassicMStab.GetClassicDefaultNail(handle, ref defaultNail); stabilityModel.DefaultNail.Length = defaultNail.length; stabilityModel.DefaultNail.DiameterNail = defaultNail.diameterNail; stabilityModel.DefaultNail.DiameterGrout = defaultNail.diameterGrout; stabilityModel.DefaultNail.YieldForce = defaultNail.yieldForce; stabilityModel.DefaultNail.PlasticMoment = defaultNail.plasticMoment; stabilityModel.DefaultNail.BendingStiffness = defaultNail.bendingStiffness; stabilityModel.DefaultNail.UseFacing = defaultNail.bearingPlate == 0; stabilityModel.DefaultNail.MaxMom = defaultNail.plasticMoment; stabilityModel.DefaultNail.EI = defaultNail.bendingStiffness; stabilityModel.DefaultNail.MaxPullForce = defaultNail.yieldForce; //Nails ClassicMStabFunctionDefinitions.MStabNails nails = null; GetClassicMStab.GetClassicNail(handle, ref nails); for (int i = 0; i < nails.nNails; i++) { var newNail = new Nail(); newNail.Name = nails.nail[i].itemName; newNail.UseDefault = nails.nail[i].useDefault; //classic has counterclockwise direction and starts on east direction //DSL nail has clockwise direction and starts on south direction newNail.Direction = (-nails.nail[i].direction) - 90; //critical angle new per nail, old per nail group, always in radians newNail.CriticalAngle = (Math.PI/180)*nails.CriticalAngle; newNail.X = nails.nail[i].x; newNail.Z = nails.nail[i].y; newNail.Y = 0.0; newNail.HorizontalSpacing = nails.nail[i].horizontalSpacing; newNail.Length = nails.nail[i].length; newNail.DiameterNail = nails.nail[i].diameterNail; newNail.DiameterGrout = nails.nail[i].diameterGrout; newNail.YieldForce = nails.nail[i].yieldForce; newNail.PlasticMoment = nails.nail[i].plasticMoment; newNail.BendingStiffness = nails.nail[i].bendingStiffness; newNail.MaxMom = nails.nail[i].plasticMoment; newNail.EI = nails.nail[i].bendingStiffness; newNail.MaxPullForce = nails.nail[i].yieldForce; //NailTypeUseFacingOrBearingPlate newNail.UseFacing = nails.nail[i].bearingPlate != 0; double prevShDist = -1; double prevLtDist = -1; for (int j = 0; j < nails.nail[i].ShearDistance.Length; j++) { double shDistance = nails.nail[i].ShearDistance[j]; if (shDistance > prevShDist) { newNail.ShearStressCurve.AddShearStress(new ShearStress(shDistance, nails.nail[i].ShearSigma[j])); prevShDist = shDistance; } double ltDist = nails.nail[i].LateralDistance[j]; if (ltDist > prevLtDist) { newNail.LateralStressCurve.AddShearStress(new ShearStress(ltDist, nails.nail[i].LateralSigma[j])); prevLtDist = ltDist; } } if (stabilityModel.NailLateralStress == NailLateralStress.Ultimate) { newNail.UseLateralStress = true; } if (stabilityModel.NailShearStress == NailShearStress.Ultimate) { newNail.UseShearStress = true; } stabilityModel.Create(newNail); } //UniformLoads ClassicMStabFunctionDefinitions.MStabUniformLoads uniformloads = null; GetClassicMStab.GetClassicUniformLoads(handle, ref uniformloads); for (int i = 0; i < uniformloads.nUniformLoads; i++) { var newuniformload = new UniformLoad(); newuniformload.Name = uniformloads.uniformLoad[i].itemName; newuniformload.DistributionAngle = uniformloads.uniformLoad[i].distriAngle; newuniformload.LoadType = (UniformLoad.LoadTypeEnum) uniformloads.uniformLoad[i].loadType; newuniformload.Magnitude = uniformloads.uniformLoad[i].magnitude; newuniformload.XEnd = uniformloads.uniformLoad[i].xend; newuniformload.XStart = uniformloads.uniformLoad[i].xStart; stabilityModel.Create(newuniformload); } //EarthQuake ClassicMStabFunctionDefinitions.MStabEarthQuake earthquake = null; GetClassicMStab.GetClassicEarthQuake(handle, ref earthquake); var newEarthquake = new Earthquake(); newEarthquake.FreeWaterFact = earthquake.freeWaterFact; newEarthquake.HorQuakeFact = earthquake.horQuakeFact; newEarthquake.VerQuakeFact = earthquake.verQuakeFact; stabilityModel.Earthquake = newEarthquake; //TreeOnSlope ClassicMStabFunctionDefinitions.MStabTreeOnSlope treeOnSlope = null; GetClassicMStab.GetClassicTreeOnSlope(handle, ref treeOnSlope); var newTreeOnSlope = new TreeOnSlope(); newTreeOnSlope.AngleOfDistribution = treeOnSlope.angleOfDistribution; newTreeOnSlope.WidthOfRootZone = treeOnSlope.widthOfRootZone; newTreeOnSlope.WindForce = treeOnSlope.windForce; newTreeOnSlope.X = treeOnSlope.xCoordinate; newTreeOnSlope.Z = treeOnSlope.yCoordinate; newTreeOnSlope.Y = 0; stabilityModel.Create(newTreeOnSlope); //Consolidation degrees //EarthQuake degree ClassicMStabFunctionDefinitions.MStabEarthQuakeDegree earthquakedegree = null; GetClassicMStab.GetClassicEarthQuakeDegree(handle, ref earthquakedegree); for (int i = 0; i < stabilityModel.Geometry.Surfaces.Count; i++) { int layerindex; if (surfaceDictionary.TryGetValue(stabilityModel.Geometry.Surfaces[i], out layerindex)) { ConsolidationValue consolidationValue = stabilityModel.ConsolidationMatrix.GetConsolidationValue(stabilityModel.Earthquake, stabilityModel.SoilProfile.Surfaces[i]); consolidationValue.Value = earthquakedegree.quakeDocLayer[layerindex]; } } //Uniform degree ClassicMStabFunctionDefinitions.MStabTemporaryLoadsDegree temploads = null; GetClassicMStab.GetClassicTemporallyLoadsDegree(handle, ref temploads); for (int surfaceIndex = 0; surfaceIndex < stabilityModel.Geometry.Surfaces.Count; surfaceIndex++) { int layerindex; if (surfaceDictionary.TryGetValue(stabilityModel.Geometry.Surfaces[surfaceIndex], out layerindex)) { ConsolidationValue consolidationValue = stabilityModel.ConsolidationMatrix.GetConsolidationValue( stabilityModel.ConsolidationLoad, stabilityModel.SoilProfile.Surfaces[surfaceIndex]); consolidationValue.Value = temploads.loadDocLayer[layerindex]; } } } catch (LoadsException e) { Debug.Assert(false, string.Format("Error in loads {0}", e.ToString())); } } } }