using System; using System.Runtime.Serialization; using Deltares.Geotechnics; using Deltares.Geotechnics.Soils; using Deltares.MStab; using Deltares.Stability.Calculation.Inner; using ShearStrengthModel = Deltares.Geotechnics.Soils.ShearStrengthModel; #if DELPHI using InterfaceData; using MStabDataTypes; using GeneticAlgorithmOptions; #else #endif namespace Deltares.Stability.Calculation { [Serializable] public class CalculationsException : 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 CalculationsException() {} public CalculationsException(string message) : base(message) {} public CalculationsException(string message, Exception inner) : base(message, inner) {} protected CalculationsException( SerializationInfo info, StreamingContext context) : base(info, context) {} } public static partial class LoadObjects { public static void LoadCalculations(MStabProject aMStabProject, ref TInterfaceData aStabilityObjects) { if (aMStabProject == null) { throw new CalculationsException("Empty aMStabProject"); } Calculations(aMStabProject, ref aStabilityObjects); } private static void Calculations(MStabProject aMStabProject, ref TInterfaceData aStabilityObjects) { if (aMStabProject.Stability == null) { throw new CalculationsException("Empty Stability object in Calculations"); } if (aMStabProject.SoilModel == null) { throw new CalculationsException("Empty SoilModel object in Calculations"); } if (aMStabProject.SoilModel.ModelFactor == null) { throw new CalculationsException("Empty ModelFactor object in Calculations"); } if (aMStabProject.Geotechnics == null) { throw new CalculationsException("Empty Waternet object in Calculations"); } StabilityModel model = aMStabProject.Stability; TCalculationOptions calcoptions = aStabilityObjects.GetCalculationOptions(); calcoptions.UseEndBearing = model.IsEndSectionFrictionUsed; calcoptions.StartValueSafetyFactor = model.StartValueSafetyFactor; calcoptions.SectionLength = aMStabProject.SoilModel.ModelFactor.SectionalLength; calcoptions.StriveSlice = model.RequestedNumberOfSlices; calcoptions.IsGridMoved = model.MoveGrid; calcoptions.SlipPlaneMinDepth = model.SlipPlaneConstraints.SlipPlaneMinDepth; calcoptions.SlipplaneMinLength = model.SlipPlaneConstraints.SlipPlaneMinLength; calcoptions.NumberOfAutogridMoves = model.NumberOfGridMoves; calcoptions.GeneticAlgorithm = model.SearchAlgorithm == SearchAlgorithm.Genetic; calcoptions.ProbabilisticCalculationType = (TProbCalculationType) model.ProbabilisticCalculationType; aStabilityObjects.SetCalculationOptions(calcoptions); aStabilityObjects.GeneticAlgorithmOptions = model.GeneticAlgorithmOptions; TModelData modelData = aStabilityObjects.GetModelData(); modelData.HasGlobalMeasurements = model.Measurement == Measurement.Global; modelData.HasZonePlot = model.HasZonePlot; modelData.CalcType = (TCalculationTypeSet) model.ModelOption; modelData.DefaultStrength = TMatStrengthTypeSet.mstNone; switch (model.DefaultShearStrengthModel) { case ShearStrengthModel.CPhi: modelData.DefaultStrength = TMatStrengthTypeSet.mstCphi; break; case ShearStrengthModel.CuCalculated: modelData.DefaultStrength = TMatStrengthTypeSet.mstCalculatedCu; break; case ShearStrengthModel.CuGradient: modelData.DefaultStrength = TMatStrengthTypeSet.mstGradientCu; break; case ShearStrengthModel.CuMeasured: modelData.DefaultStrength = TMatStrengthTypeSet.mstMeasuredCu; break; case ShearStrengthModel.PseudoValues: modelData.DefaultStrength = TMatStrengthTypeSet.mstPseudoStressTab; break; case ShearStrengthModel.StressTable: modelData.DefaultStrength = TMatStrengthTypeSet.mstStressTab; break; } modelData.IsProbabilistic = model.IsReliability; modelData.LeftSideIsActive = model.SlipPlaneUpliftVan.ActiveSide == ActiveSideType.Left; if (modelData.IsProbabilistic) { switch (model.DefaultInputModeAnalysisOption) { case ReliabilityAnalysisOption.Design: modelData.DefaultInputValues = TProbInputValuesSet.pivDesign; break; case ReliabilityAnalysisOption.Mean: modelData.DefaultInputValues = TProbInputValuesSet.pivMean; break; } } else { modelData.DefaultInputValues = TProbInputValuesSet.pivNone; } aStabilityObjects.SetModelData(modelData); } } }