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.Stability; namespace Deltares.MStab.IO.Classic { [Serializable] public class SoilModelException : 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 SoilModelException() {} public SoilModelException(string message) : base(message) {} public SoilModelException(string message, Exception inner) : base(message, inner) {} protected SoilModelException( SerializationInfo info, StreamingContext context) : base(info, context) {} } internal class SoilModelInfo { private StabilityModel mStabProject = null; /// /// Create all SoilModel objects /// public void GetSoilModel(int handle, StabilityModel stabilityModel, Dictionary aSurfaceDictionary) { if (stabilityModel == null) { throw new SoilDataException("StabilityModel object not instantiated!"); } if (stabilityModel.SoilModel == null) { throw new SoilDataException("Soilmodel object not instantiated!"); } mStabProject = stabilityModel; try { GetConsolidationDegree(handle, aSurfaceDictionary); GetModelFactor(handle); //Stresscurves are already created in the Geometry } catch (SoilDataException e) { Debug.Assert(false, e.ToString()); } } /// /// Manders Create Consolidation degree. /// The consolidationdegree for each soil depends on the consolidationdegree for all other soils /// private void GetConsolidationDegree(int handle, Dictionary aSurfaceDictionary) { try { ClassicMStabFunctionDefinitions.MStabConsolidationDegree classicConsolidationDegree = null; GetClassicMStab.GetClassicConsolidationDegree(handle, ref classicConsolidationDegree); mStabProject.ConsolidationMatrix.UseUnderOverPressureabovephreaticLine = classicConsolidationDegree.capillair; int numberOfSurfaces = mStabProject.Geometry.Surfaces.Count; for (int surfaceRowIndex = 0; surfaceRowIndex < numberOfSurfaces; surfaceRowIndex++) { int layerRowIndex; if (aSurfaceDictionary.TryGetValue(mStabProject.Geometry.Surfaces[surfaceRowIndex], out layerRowIndex)) { int layerColumnIndex = 0; for (int surfaceColumnIndex = 0; surfaceColumnIndex < numberOfSurfaces; surfaceColumnIndex++) { if (aSurfaceDictionary.TryGetValue(mStabProject.Geometry.Surfaces[surfaceColumnIndex], out layerColumnIndex)) { ConsolidationValue consolidationValue = mStabProject.ConsolidationMatrix.GetConsolidationValue( mStabProject.SoilProfile.Surfaces[surfaceColumnIndex], mStabProject.SoilProfile.Surfaces[surfaceRowIndex]); if ( classicConsolidationDegree.consolidationLayer[layerRowIndex].loadDocLayer[ layerColumnIndex] != -1) { consolidationValue.Value = classicConsolidationDegree.consolidationLayer[layerRowIndex].loadDocLayer[ layerColumnIndex]; } } } } } } catch (SoilModelException e) { Debug.Assert(false, string.Format("Error found in Consolidation degree. {0}", e.ToString())); } } /// /// Manders Create the modelfactor. /// private void GetModelFactor(int handle) { ClassicMStabFunctionDefinitions.MStabModelFactor modelfactor = null; GetClassicMStab.GetClassicModelFactor(handle, ref modelfactor); mStabProject.SoilModel.ModelFactor.IsEndSecionUsed = modelfactor.isEndSectionUsed; mStabProject.SoilModel.ModelFactor.LatStressRatio = modelfactor.latStressRatioLength; mStabProject.SoilModel.ModelFactor.LimitValue = modelfactor.limitValue; mStabProject.SoilModel.ModelFactor.SectionalLength = modelfactor.sectionLength; mStabProject.SoilModel.ModelFactor.StandardDeviation = modelfactor.standardDeviation; mStabProject.SoilModel.ModelFactor.VarEdgeContribution = modelfactor.varEdgeContribution; } } }