using System; using System.Collections.Generic; // ======================================================================================================================= // Class name: // // Description: // // Copyright (c) 2008 Deltares // // Date ID Modification // 2008-04-23 Best Created // ======================================================================================================================= namespace Deltares.Stability.Calculation.Inner { // Only needed for determine vertical data // ... Calls to User Interface data ... // uses TestStabilityCSharp; public class EDSoilError : Exception { //@ Constructor auto-generated public EDSoilError(String message) : base(message) {} //@ Constructor auto-generated public EDSoilError(String message, Exception innerException) : base(message, innerException) {} } // end EDSoilError public class EDLayerError : Exception { //@ Constructor auto-generated public EDLayerError(String message) : base(message) {} //@ Constructor auto-generated public EDLayerError(String message, Exception innerException) : base(message, innerException) {} } // end EDLayerError public class TInterfaceCalls { private readonly IDictionary, int> layerNumberDictionary = new Dictionary, int>(); private readonly IDictionary, int> soilNumberDictionary = new Dictionary, int>(); private readonly IDictionary, TVerticalData> verticalDataCache = new Dictionary, TVerticalData>(); private readonly IDictionary, double> zBottomLayerDict = new Dictionary, double>(); private readonly IDictionary, double[]> zTopLayerDict = new Dictionary, double[]>(); private TDetermPorePressureDegreeOfConsolidationLayers FDetermPorePressureDegreeOfConsolidationLayersDelegate = null; private TDetermPorePressurePiezometricLevels FDetermPorePressurePiezometricLevels = null; private TDetermTotalstress FDetermTotalstressDelegate = null; private TDetermVerticalData FDetermVerticalDataDelegate = null; private TDetermZReferencelevelCuCalculated FDetermZReferencelevelCuCalculatedDelegate = null; private TDetermineCentreOfGravity FDetermineCentreOfGravityDelegate = null; private TDeterminePreConsolidationTotalStress FDeterminePreConsolidationTotalStressDelegate = null; private TGetZBottomFromLayer FGetZBottomFromLayerDelegate = null; private TGetZTopFromLayer FGetZTopFromLayerDelegate = null; private TGetZTopFromLayers FGetZTopFromLayersDelegate = null; private TIntersectPhreatic FIntersectPhreaticLine = null; private TLayerNumberFromPoint FLayerNumberFromPointDelegate = null; private TSoilNumberFromPoint FSoilNumberFromPointDelegate = null; // called once // ======================================================================================================================= // From UI give all the geometry points // // Out LNCoords : Number of geometry points // XCoords : array 0 : LNCoords - 1 of double; // ZCoords : array 0 : LNCoords - 1 of double; // // Date ID Modification // 2008-04-22 Best Created // ======================================================================================================================= public void FillGeometryPoints(ref int GeometryPointCount, ref double[] XCoords, ref double[] ZCoords) { XCoords = new double[0]; ZCoords = new double[0]; } // ======================================================================================================================= // From UI give all the PLLine points // // Out LNCoords : Number of PLLine points // XCoords : array 0 : LNCoords - 1 of double; // ZCoords : array 0 : LNCoords - 1 of double; // // Date ID Modification // 2008-04-22 Best Created // ======================================================================================================================= public void FillPLLinePoints(ref int PLLineGeometryPointCount, ref double[] XCoords, ref double[] ZCoords) {} // ======================================================================================================================= // From UI give the surface line // // Out PHreaticLinePointCount : Number of nodes in lsurfacer // XCoords : array 0 : LNCoords - 1 of double; // ZCoords : array 0 : LNCoords - 1 of double; // // Date ID Modification // 2008-03-31 Best Created // ======================================================================================================================= public void FillFreaticLinePoints(ref int FreaticLinePointCount, ref double[] XCoords, ref double[] ZCoords) { XCoords = new double[0]; ZCoords = new double[0]; } // ======================================================================================================================= // From UI give the surface line // // Out LNCoords : Number of nodes in lsurfacer // XCoords : array 0 : LNCoords - 1 of double; // ZCoords : array 0 : LNCoords - 1 of double; // // Date ID Modification // 2008-03-31 Best Created // ======================================================================================================================= public void FillSurfacePoints(ref int SurfacepointCount, ref double[] XCoords, ref double[] ZCoords) { XCoords = new double[0]; ZCoords = new double[0]; } // function DetermineNumberofLayers: Integer; // (* // {======================================================================================================================= // From UI give the total number of layers in this geometry // // out Number of layers : Integer; // // Date ID Modification // 2008-04-22 Best Created // =======================================================================================================================} // function TInterfaceCalls.DetermineNumberofLayers: Integer; // begin // // Result := FillObjects.get_Geometry.GetNumberOfSurfaces; // end; // *) // ======================================================================================================================= // From UI give for layer number ALayerNumber the coordinates // // In Layer Number : Integer // // Out LNCoords : Number of nodes in layer // XCoords : array 0 : LNCoords - 1 of double; // ZCoords : array 0 : LNCoords - 1 of double; // // Date ID Modification // 2008-04-22 Best Created // ======================================================================================================================= public void CoordinatesFromLayer(int ALayerNumber, ref int LNCoords, ref double[] XCoords, ref double[] ZCoords) { LNCoords = 0; XCoords = new double[0]; ZCoords = new double[0]; } // function DetermineNumberofWaterLines: Integer; // (* // {======================================================================================================================= // From UI give the total number of waterlines in this geometry // // out Number of waterlines : Integer; // // Date ID Modification // 2008-04-22 Best Created // =======================================================================================================================} // function TInterfaceCalls.DetermineNumberofWaterLines: Integer; // begin // // end; // *) // ======================================================================================================================= // From UI give for layer number ALayerNumber the coordinates // // In Layer Number : Integer // // Out LNCoords : Number of nodes in layer // XCoords : array 0 : LNCoords - 1 of double; // ZCoords : array 0 : LNCoords - 1 of double; // // Date ID Modification // 2008-04-22 Best Created // ======================================================================================================================= public void CoordinatesFromWaterline(int AWaterlineNumber, ref int LNCoords, ref double[] XCoords, ref double[] ZCoords) {} // ======================================================================================================================= // Date ID Modification // 2008-05-28 Best Created // ======================================================================================================================= public void EarthQuakefactors(ref double AFreeWaterFactor, ref double AHorizontalQuakeFactor, ref double VerticalQuakeFactor, ref double[] DegreeOfConsolidation) {} // ======================================================================================================================= // Date ID Modification // 2008-05-28 Best Created // ======================================================================================================================= public void FetchDegreeOfconsolidationLoads(ref double[] ADegreeOfConsolidationLoads) {} // procedure FetchDegreeOfconsolidation(var aDocOn: TDegreeOfConsolidationOn); // Called frequently // (* // {======================================================================================================================= // Description Determines the degree of consolidation from all layers on the others. // ADocOn[i,j] is the effect from j on i // // Date ID Modification // 2008-08-11 Best Created // =======================================================================================================================} // procedure TInterfaceCalls.FetchDegreeOfconsolidation(var aDOCOn: TDegreeOfConsolidationOn); // var // LNLayers: Integer; // i: Integer; // LOn: Integer; // LFrom: Integer; // begin // LNLayers := DetermineNumberOfLayers; // // {create the dimensions of degree of consolidation} // Setlength(aDOCOn, LNLayers); // for i := 0 to LNLayers - 1 do // begin // setLength(aDOCOn[i], LNLayers); // end; // // {now fill the degree of consolidation} // for LOn := 0 to LNLayers - 1 do // begin // for LFrom := 0 to LNLayers - 1 do // begin // {here the effect of layer "from" on layer "on" } // {Value maust be between 0 and 100 Default 100} // ADocOn[LOn, LFrom] := 100; // end; // end; // end; // *) // ======================================================================================================================= // From UI Determines the soil number from point. This is needed to get the soil parameters // // Date ID Modification // 2008-04-23 Best Created // ======================================================================================================================= public int DetermineSoilNumberFromPoint(double AX, double AZ) { int result; const double CDelta = 0.001; result = GetSoilNumber(AX, AZ); if ((result < -100)) { // invalid point found probably on boundary result = GetSoilNumber(AX, AZ - CDelta); } if ((result < -100)) { result = GetSoilNumber(AX, AZ + CDelta); } if ((result < -100)) { throw new EDSoilError("ErrorNoSoilFound"); } return result; } public int DetermineLayerNumberFromPoint(double AX, double AZ) { int result; const double CDelta = 0.001; result = FLayerNumberFromPointDelegate(AX, AZ); if ((result < -100)) { // invalid point found probably on boundary result = GetLayerNumber(AX, AZ - CDelta); } if ((result < -100)) { result = GetLayerNumber(AX, AZ + CDelta); } if ((result < -100)) { throw new EDLayerError("ErrorNoLayerFound"); } return result; } // ======================================================================================================================= // From UI Determines the total stress at a position // // Date ID Modification // 2008-05-06 Best Created // ======================================================================================================================= public double DetermineTotalstress(double AX, double AZ) { return FDetermTotalstressDelegate(AX, AZ); } // ======================================================================================================================= // Date ID Modification // 2008-08-07 Best Created // ======================================================================================================================= public void DetermineVerticalData(double AX, double AZ, ref TVerticalData VerticalData) { var point = new Tuple(AX, AZ); if (verticalDataCache.ContainsKey(point)) { VerticalData = verticalDataCache[point]; return; } const double LDelta = 0.00001; int i; // Find the top level double[] LTopLayers = GetZTop(AX, AZ); double LBottomLevel = GetZBottom(AX, AZ + LDelta); int LNDim = LTopLayers.Length; if ((LNDim == 0)) { LNDim = 1; LTopLayers = new double[LNDim]; LTopLayers[0] = AZ; } VerticalData.SoilData = new TSoilrecord[LNDim]; for (i = 0; i < LNDim; i++) { VerticalData.SoilData[i].Toplevel = LTopLayers[LNDim - 1 - i]; } // Find the bottom levels for (i = 0; i <= LNDim - 2; i++) { VerticalData.SoilData[i].Bottomlevel = VerticalData.SoilData[i + 1].Toplevel; } // The bottom level from the lowest layer beware of points on boundary VerticalData.SoilData[LNDim - 1].Bottomlevel = LBottomLevel; // Fill the soil numbers for (i = 0; i < LNDim; i++) { double LZ = 0.5*(VerticalData.SoilData[i].Bottomlevel + VerticalData.SoilData[i].Toplevel); VerticalData.SoilData[i].Soilnumber = GetSoilNumber(AX, LZ); if ((VerticalData.SoilData[i].Soilnumber < -100)) { VerticalData.SoilData[i].Soilnumber = GetSoilNumber(AX, LZ - LDelta); } VerticalData.SoilData[i].LayerNumber = GetLayerNumber(AX, LZ); if ((VerticalData.SoilData[i].LayerNumber < -100)) { VerticalData.SoilData[i].LayerNumber = GetLayerNumber(AX, LZ - LDelta); } } verticalDataCache.Add(point, VerticalData); } // function DeterminePorePressureDegreeOfConsolidationLayers(AX, AZ: Double): Double; // (* // {======================================================================================================================= // Description Determines the pore pressures due to the degree of consolidation From the layers above // this point // // Date ID Modification // 2008-05-28 Best Created // =======================================================================================================================} // function TInterfaceCalls.DeterminePorePressureDegreeOfConsolidationLayers(AX, AZ: Double): Double; // begin // // // // // end; // *) // ======================================================================================================================= // Description Determines the pore pressures from the waternet // // Date ID Modification // 2008-05-28 Best Created // ======================================================================================================================= public double DeterminePorePressurePiezometricLevels(double AX, double AZ) { double result; result = FDetermPorePressurePiezometricLevels(AX, AZ); return result; } // ======================================================================================================================= // Description A reference level must be given to calculate the pre load stress. // This line must have the same specifications as a surface layer // It is not necessary to start end end at the boundary of the geometry. // If it is not present at a position the actual surface is taken // // Date ID Modification // 2008-05-28 Best Created // ======================================================================================================================= public double DetermineZReferencelevelCuCalculated(double AX) { double result; result = FDetermZReferencelevelCuCalculatedDelegate(AX); return result; } // function DeterminePreConsolidationTotalStress(AX, AZ, AZTop: Double): Double; // ======================================================================================================================= // Determine the Total stress from ATop to AZ // // Date ID Modification // 2008-05-28 Best Created // ======================================================================================================================= // function TInterfaceCalls.DeterminePreConsolidationTotalStress(AX, AZ, AZTop: Double): Double; // begin // end; // ======================================================================================================================= // Description Returnes a Z coordinate at the centre of gravity from the layers above AZBottom. // Meaning that at a vertical Depending on the unit weight of the layers an gravity center is calculated // // Date ID Modification // 2008-06-03 Best Created // ======================================================================================================================= public double DetermineCentreOfGravity(double AX, double AZBottom) { return FDetermineCentreOfGravityDelegate(AX, AZBottom); } // ======================================================================================================================= // Description Returnes a Z coordinate from the top of the layer (in a slice) from ax and az // It is possible that a certain layer occures more than 0nce in a slice, the other // occurences are neglected for this purpose // // Date ID Modification // 2008-06-05 Best Created // ======================================================================================================================= public double GetZTopFromLayer(double AX, double AZ) { return FGetZTopFromLayerDelegate(AX, AZ); } // ======================================================================================================================= // Date ID Modification // 2008-12-01 Manders Created // ======================================================================================================================= public double[] GetZTopFromLayers(double AX, double AZ) { return GetZTop(AX, AZ); //FGetZTopFromLayersDelegate(AX, AZ); } // ======================================================================================================================= // Description Returnes a Z coordinate from the bottom of the layer from ax and az // It is possible that a certain layer occures more than 0nce in a slice, the other // occurences are neglected for this purpose // // Date ID Modification // 2008-06-05 Best Created // ======================================================================================================================= public double GetZBottomFromLayer(double AX, double AZ) { return GetZBottom(AX, AZ); //FGetZBottomFromLayerDelegate(AX, AZ); } public double GetIntersectPhreaticLine(double AX, double AZ) { return FIntersectPhreaticLine(AX, AZ); } // ======================================================================================================================= // Date ID Modification // 2008-11-14 Manders Created // ======================================================================================================================= public void SetSoilNumberFromPointDelegate(TSoilNumberFromPoint ASoilNumberFromPointDelegate) { FSoilNumberFromPointDelegate = ASoilNumberFromPointDelegate; } // ======================================================================================================================= // Date ID Modification // 2008-11-14 Manders Created // ======================================================================================================================= public void SetLayerNumberFromPointDelegate(TLayerNumberFromPoint ALayerNumberFromPointDelegate) { FLayerNumberFromPointDelegate = ALayerNumberFromPointDelegate; } // ======================================================================================================================= // Date ID Modification // 2008-11-14 Manders Created // ======================================================================================================================= public void SetDetermTotalstressDelegate(TDetermTotalstress ADetermTotalstress) { FDetermTotalstressDelegate = ADetermTotalstress; } // ======================================================================================================================= // Date ID Modification // 2008-11-14 Manders Created // ======================================================================================================================= public void SetDetermVerticalDataDelegate(TDetermVerticalData ADetermVerticalData) { FDetermVerticalDataDelegate = ADetermVerticalData; } public void SetDetermPorePressureDegreeOfConsolidationLayersDelegate(TDetermPorePressureDegreeOfConsolidationLayers ADetermPorePressureDegreeOfConsolidationLayers) { FDetermPorePressureDegreeOfConsolidationLayersDelegate = ADetermPorePressureDegreeOfConsolidationLayers; } // ======================================================================================================================= // Date ID Modification // 2008-11-14 Manders Created // ======================================================================================================================= public void SetDetermZReferencelevelCuCalculatedDelegate(TDetermZReferencelevelCuCalculated ADetermZReferencelevelCuCalculated) { FDetermZReferencelevelCuCalculatedDelegate = ADetermZReferencelevelCuCalculated; } // ======================================================================================================================= // Date ID Modification // 2008-11-14 Manders Created // ======================================================================================================================= public void SetDeterminePreConsolidationTotalStressDelegate(TDeterminePreConsolidationTotalStress ADeterminePreConsolidationTotalStress) { FDeterminePreConsolidationTotalStressDelegate = ADeterminePreConsolidationTotalStress; } // ======================================================================================================================= // Date ID Modification // 2008-11-14 Manders Created // ======================================================================================================================= public void SetDetermineCentreOfGravityDelegate(TDetermineCentreOfGravity ADetermineCentreOfGravity) { FDetermineCentreOfGravityDelegate = ADetermineCentreOfGravity; } // ======================================================================================================================= // Date ID Modification // 2008-11-14 Manders Created // ======================================================================================================================= public void SetGetZTopFromLayerDelegate(TGetZTopFromLayer AGetZTopFromLayer) { FGetZTopFromLayerDelegate = AGetZTopFromLayer; } // ======================================================================================================================= // Date ID Modification // 2008-12-01 Manders Created // ======================================================================================================================= public void SetGetZTopFromLayersDelegate(TGetZTopFromLayers AGetZTopFromLayers) { FGetZTopFromLayersDelegate = AGetZTopFromLayers; } // ======================================================================================================================= // Date ID Modification // 2008-11-14 Manders Created // ======================================================================================================================= public void SetGetZBottomFromLayerDelegate(TGetZBottomFromLayer AGetZBottomFromLayer) { FGetZBottomFromLayerDelegate = AGetZBottomFromLayer; } // ======================================================================================================================= // Date ID Modification // 2008-12-01 Manders Created // ======================================================================================================================= public void SetIntersectPhreaticDelegate(TIntersectPhreatic AGetIntersectHeadline) { FIntersectPhreaticLine = AGetIntersectHeadline; } // ======================================================================================================================= // Date ID Modification // 2008-11-19 Manders Created // ======================================================================================================================= public void SetDetermPorePressurePiezometricLevels(TDetermPorePressurePiezometricLevels ADetermPorePressurePiezometricLevels) { FDetermPorePressurePiezometricLevels = ADetermPorePressurePiezometricLevels; } private double GetZBottom(double ax, double az) { var point = new Tuple(ax, az); if (!zBottomLayerDict.ContainsKey(point)) { zBottomLayerDict.Add(point, FGetZBottomFromLayerDelegate(ax, az)); } return zBottomLayerDict[point]; } private double[] GetZTop(double ax, double az) { var point = new Tuple(ax, az); if (!zTopLayerDict.ContainsKey(point)) { zTopLayerDict.Add(point, FGetZTopFromLayersDelegate(ax, az)); } return zTopLayerDict[point]; } private int GetLayerNumber(double ax, double lz) { var point = new Tuple(ax, lz); if (!layerNumberDictionary.ContainsKey(point)) { layerNumberDictionary.Add(point, FLayerNumberFromPointDelegate(ax, lz)); } return layerNumberDictionary[point]; } private int GetSoilNumber(double ax, double lz) { var point = new Tuple(ax, lz); if (!soilNumberDictionary.ContainsKey(point)) { soilNumberDictionary.Add(point, FSoilNumberFromPointDelegate(ax, lz)); } return soilNumberDictionary[point]; } } // end TInterfaceCalls public delegate int TSoilNumberFromPoint(double AX, double AZ); public delegate int TLayerNumberFromPoint(double AX, double AZ); public delegate double TDetermTotalstress(double AX, double AZ); public delegate void TDetermVerticalData(double aX, ref TVerticalData VerticalData); public delegate double TDetermPorePressureDegreeOfConsolidationLayers(double AX, double AZ); public delegate double TDetermZReferencelevelCuCalculated(double AX); public delegate double TDeterminePreConsolidationTotalStress(double AX, double AZ, double AZTop); public delegate double TDetermineCentreOfGravity(double AX, double AZBottom); public delegate double TGetZTopFromLayer(double AX, double AZ); public delegate double[] TGetZTopFromLayers(double AX, double AZ); public delegate double TGetZBottomFromLayer(double AX, double AZ); public delegate double TDetermPorePressurePiezometricLevels(double AX, double AZ); public delegate double TIntersectPhreatic(double AX, double AZ); }