Main Lemma Repository
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

RectilinearGrid.h 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /* This file is part of Lemma, a geophysical modelling and inversion API */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. /**
  6. @file
  7. @author Trevor Irons
  8. @date 10/28/2010
  9. @version $Id: rectilineargrid.h 193 2014-11-10 23:51:41Z tirons $
  10. **/
  11. #ifndef RECTILINEARGRID_INC
  12. #define RECTILINEARGRID_INC
  13. #include "Grid.h"
  14. namespace Lemma {
  15. // ===================================================================
  16. // Class: RectilinearGrid
  17. /**
  18. @class
  19. \brief Impliments a rectilinear grid.
  20. \details A rectilinear grid can vary regularily in space but must be
  21. constant variation across each dimension. In this way three
  22. vectors can define the entire grid, and each cell is right
  23. aligned with all its neighbours.
  24. */
  25. // ===================================================================
  26. class RectilinearGrid : public Grid {
  27. friend std::ostream &operator<<(std::ostream &stream,
  28. const RectilinearGrid &ob);
  29. public:
  30. // ==================== LIFECYCLE =======================
  31. /**
  32. * Factory method for generating concrete class.
  33. * @return a std::shared_ptr of type RectilinearGrid
  34. */
  35. static std::shared_ptr<RectilinearGrid> NewSP();
  36. // ==================== OPERATORS =======================
  37. // ==================== OPERATIONS =======================
  38. /**
  39. * Sets the dimensions in x, y and z
  40. * @param[in] nx is the number of cells in x
  41. * @param[in] ny is the number of cells in y
  42. * @param[in] nz is the number of cells in z
  43. */
  44. void SetDimensions (const int &nx, const int &ny, const int &nz);
  45. /**
  46. * Sets the offset in x, y and z. This sets the corner position of the top SW corner.
  47. * @param[in] ox is the number of cells in x
  48. * @param[in] oy is the number of cells in y
  49. * @param[in] oz is the number of cells in z
  50. */
  51. void SetOffset (const Real &ox, const Real &oy, const Real &oz);
  52. /**
  53. * Sets the spacing in x, y and z
  54. * @param[in] dx is a Vector of cell spacing in x, must be same
  55. * size ad nx
  56. * @param[in] dy is a Vector of cell spacing in x, must be same
  57. * size ad ny
  58. * @param[in] dz is a Vector of cell spacing in x, must be same
  59. * size ad nz
  60. */
  61. void SetSpacing (const VectorXr &dx, const VectorXr &dy,
  62. const VectorXr &dz);
  63. // ==================== ACCESS =======================
  64. /** Returns the number of cells in x
  65. * @return number of cells in x
  66. */
  67. int GetNx();
  68. /** Returns the number of cells in y
  69. * @return number of cells in y
  70. */
  71. int GetNy();
  72. /** Returns the number of cells in z
  73. * @return number of cells in z
  74. */
  75. int GetNz();
  76. /** Returns the offset of cells in x
  77. * @return offset of cells in x
  78. */
  79. Real GetOx();
  80. /** Returns the number of cells in y
  81. * @return number of cells in y
  82. */
  83. Real GetOy();
  84. /** Returns the offset of cells in z
  85. * @return offset of cells in z
  86. */
  87. Real GetOz();
  88. /** Returns Spacing Vector
  89. * @return dx
  90. */
  91. VectorXr GetDx();
  92. /** Returns a spacing
  93. * @return dx[ix]
  94. */
  95. Real GetDx(const int& ix);
  96. /** Returns Spacing Vector
  97. * @return dy
  98. */
  99. VectorXr GetDy();
  100. /** Returns a spacing
  101. * @return dy[iy]
  102. */
  103. Real GetDy(const int& iy);
  104. /** Returns Spacing Vector
  105. * @return dz
  106. */
  107. VectorXr GetDz();
  108. /** Returns Spacing Vector
  109. * @return dz[iz]
  110. */
  111. Real GetDz(const int& iz);
  112. // ==================== INQUIRY =======================
  113. protected:
  114. // ==================== LIFECYCLE =======================
  115. /// Default protected constructor.
  116. RectilinearGrid (const std::string &name);
  117. /// Default protected constructor.
  118. ~RectilinearGrid ();
  119. // ==================== DATA MEMBERS =========================
  120. /// Number of cells in the x dimension
  121. int nx;
  122. /// Number of cells in the y dimension
  123. int ny;
  124. /// Number of cells in the z dimension
  125. int nz;
  126. /// Grid offset in x dimension
  127. Real ox;
  128. /// Grid offset in y dimension
  129. Real oy;
  130. /// Grid offset in z dimension
  131. Real oz;
  132. /// Cell spacing in the x dimension
  133. VectorXr dx;
  134. /// Cell spacing in the y dimension
  135. VectorXr dy;
  136. /// Cell spacing in the z dimension
  137. VectorXr dz;
  138. /* @todo find a good way to store models that works with portions threadprivate
  139. /// Container holding Vectors of Real data at centre of cell.
  140. std::vector<VectorXr> RealCellData;
  141. /// Container holding names of Real data
  142. std::vector<std::string> RealCellDataNames;
  143. /// Container holding Vectors of Real data on edges.
  144. std::vector<VectorXr> RealEdgeData;
  145. /// Container holding names of Real data on edges
  146. std::vector<std::string> RealEdgeDataNames;
  147. /// Container holding Vectors of Complex data on edges.
  148. std::vector<VectorXcr> ComplexEdgeData;
  149. /// Container holding names of Real data on edges
  150. std::vector<std::string> ComplexEdgeDataNames;
  151. /// Container holding Vectors of Real properties.
  152. std::vector<VectorXr> RealCellProperties;
  153. /// Container holding names of Real cell properties
  154. std::vector<std::string> RealCellPropertyNames;
  155. /// Container holding Vectors of Real data.
  156. std::vector<VectorXcr> ComplexCellData;
  157. /// Container holding names of Real data
  158. std::vector<std::string> ComplexCellDataNames;
  159. /// Container holding Vectors of Complex properties.
  160. std::vector<VectorXcr> ComplexCellProperties;
  161. /// Container holding names of Real cell properties
  162. std::vector<std::string> ComplexCellPropertyNames;
  163. */
  164. private:
  165. }; // ----- end of class RectilinearGrid -----
  166. } // ----- end of Lemma name -----
  167. #endif // ----- #ifndef RECTILINEARGRID_INC -----