Main Lemma Repository
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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. /** Returns a pointer to a new object of type RectilinearGrid.
  32. * It allocates all necessary memory.
  33. */
  34. static RectilinearGrid* New();
  35. /**
  36. * @copybrief LemmaObject::Delete()
  37. * @copydetails LemmaObject::Delete()
  38. */
  39. void Delete();
  40. // ==================== OPERATORS =======================
  41. // ==================== OPERATIONS =======================
  42. /**
  43. * Sets the dimensions in x, y and z
  44. * @param[in] nx is the number of cells in x
  45. * @param[in] ny is the number of cells in y
  46. * @param[in] nz is the number of cells in z
  47. */
  48. void SetDimensions (const int &nx, const int &ny, const int &nz);
  49. /**
  50. * Sets the offset in x, y and z. This sets the corner position of the top SW corner.
  51. * @param[in] ox is the number of cells in x
  52. * @param[in] oy is the number of cells in y
  53. * @param[in] oz is the number of cells in z
  54. */
  55. void SetOffset (const Real &ox, const Real &oy, const Real &oz);
  56. /**
  57. * Sets the spacing in x, y and z
  58. * @param[in] dx is a Vector of cell spacing in x, must be same
  59. * size ad nx
  60. * @param[in] dy is a Vector of cell spacing in x, must be same
  61. * size ad ny
  62. * @param[in] dz is a Vector of cell spacing in x, must be same
  63. * size ad nz
  64. */
  65. void SetSpacing (const VectorXr &dx, const VectorXr &dy,
  66. const VectorXr &dz);
  67. // ==================== ACCESS =======================
  68. /** Returns the number of cells in x
  69. * @return number of cells in x
  70. */
  71. int GetNx();
  72. /** Returns the number of cells in y
  73. * @return number of cells in y
  74. */
  75. int GetNy();
  76. /** Returns the number of cells in z
  77. * @return number of cells in z
  78. */
  79. int GetNz();
  80. /** Returns the offset of cells in x
  81. * @return offset of cells in x
  82. */
  83. Real GetOx();
  84. /** Returns the number of cells in y
  85. * @return number of cells in y
  86. */
  87. Real GetOy();
  88. /** Returns the offset of cells in z
  89. * @return offset of cells in z
  90. */
  91. Real GetOz();
  92. /** Returns Spacing Vector
  93. * @return dx
  94. */
  95. VectorXr GetDx();
  96. /** Returns a spacing
  97. * @return dx[ix]
  98. */
  99. Real GetDx(const int& ix);
  100. /** Returns Spacing Vector
  101. * @return dy
  102. */
  103. VectorXr GetDy();
  104. /** Returns a spacing
  105. * @return dy[iy]
  106. */
  107. Real GetDy(const int& iy);
  108. /** Returns Spacing Vector
  109. * @return dz
  110. */
  111. VectorXr GetDz();
  112. /** Returns Spacing Vector
  113. * @return dz[iz]
  114. */
  115. Real GetDz(const int& iz);
  116. // ==================== INQUIRY =======================
  117. protected:
  118. // ==================== LIFECYCLE =======================
  119. /// Default protected constructor.
  120. RectilinearGrid (const std::string &name);
  121. /// Default protected constructor.
  122. ~RectilinearGrid ();
  123. /**
  124. * @copybrief LemmaObject::Release()
  125. * @copydetails LemmaObject::Release()
  126. */
  127. void Release();
  128. // ==================== DATA MEMBERS =========================
  129. /// Number of cells in the x dimension
  130. int nx;
  131. /// Number of cells in the y dimension
  132. int ny;
  133. /// Number of cells in the z dimension
  134. int nz;
  135. /// Grid offset in x dimension
  136. Real ox;
  137. /// Grid offset in y dimension
  138. Real oy;
  139. /// Grid offset in z dimension
  140. Real oz;
  141. /// Cell spacing in the x dimension
  142. VectorXr dx;
  143. /// Cell spacing in the y dimension
  144. VectorXr dy;
  145. /// Cell spacing in the z dimension
  146. VectorXr dz;
  147. /* @todo find a good way to store models that works with portions threadprivate
  148. /// Container holding Vectors of Real data at centre of cell.
  149. std::vector<VectorXr> RealCellData;
  150. /// Container holding names of Real data
  151. std::vector<std::string> RealCellDataNames;
  152. /// Container holding Vectors of Real data on edges.
  153. std::vector<VectorXr> RealEdgeData;
  154. /// Container holding names of Real data on edges
  155. std::vector<std::string> RealEdgeDataNames;
  156. /// Container holding Vectors of Complex data on edges.
  157. std::vector<VectorXcr> ComplexEdgeData;
  158. /// Container holding names of Real data on edges
  159. std::vector<std::string> ComplexEdgeDataNames;
  160. /// Container holding Vectors of Real properties.
  161. std::vector<VectorXr> RealCellProperties;
  162. /// Container holding names of Real cell properties
  163. std::vector<std::string> RealCellPropertyNames;
  164. /// Container holding Vectors of Real data.
  165. std::vector<VectorXcr> ComplexCellData;
  166. /// Container holding names of Real data
  167. std::vector<std::string> ComplexCellDataNames;
  168. /// Container holding Vectors of Complex properties.
  169. std::vector<VectorXcr> ComplexCellProperties;
  170. /// Container holding names of Real cell properties
  171. std::vector<std::string> ComplexCellPropertyNames;
  172. */
  173. private:
  174. }; // ----- end of class RectilinearGrid -----
  175. } // ----- end of Lemma name -----
  176. #endif // ----- #ifndef RECTILINEARGRID_INC -----