Main Lemma Repository
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

RectilinearGrid.h 7.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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. /** Returns the name of the underlying class, similiar to Python's type */
  114. virtual inline std::string GetName() const {
  115. return this->CName;
  116. }
  117. protected:
  118. // ==================== LIFECYCLE =======================
  119. /// Default protected constructor.
  120. RectilinearGrid ( );
  121. /// Default protected constructor.
  122. ~RectilinearGrid ();
  123. // ==================== DATA MEMBERS =========================
  124. /// Number of cells in the x dimension
  125. int nx;
  126. /// Number of cells in the y dimension
  127. int ny;
  128. /// Number of cells in the z dimension
  129. int nz;
  130. /// Grid offset in x dimension
  131. Real ox;
  132. /// Grid offset in y dimension
  133. Real oy;
  134. /// Grid offset in z dimension
  135. Real oz;
  136. /// Cell spacing in the x dimension
  137. VectorXr dx;
  138. /// Cell spacing in the y dimension
  139. VectorXr dy;
  140. /// Cell spacing in the z dimension
  141. VectorXr dz;
  142. /* @todo find a good way to store models that works with portions threadprivate
  143. /// Container holding Vectors of Real data at centre of cell.
  144. std::vector<VectorXr> RealCellData;
  145. /// Container holding names of Real data
  146. std::vector<std::string> RealCellDataNames;
  147. /// Container holding Vectors of Real data on edges.
  148. std::vector<VectorXr> RealEdgeData;
  149. /// Container holding names of Real data on edges
  150. std::vector<std::string> RealEdgeDataNames;
  151. /// Container holding Vectors of Complex data on edges.
  152. std::vector<VectorXcr> ComplexEdgeData;
  153. /// Container holding names of Real data on edges
  154. std::vector<std::string> ComplexEdgeDataNames;
  155. /// Container holding Vectors of Real properties.
  156. std::vector<VectorXr> RealCellProperties;
  157. /// Container holding names of Real cell properties
  158. std::vector<std::string> RealCellPropertyNames;
  159. /// Container holding Vectors of Real data.
  160. std::vector<VectorXcr> ComplexCellData;
  161. /// Container holding names of Real data
  162. std::vector<std::string> ComplexCellDataNames;
  163. /// Container holding Vectors of Complex properties.
  164. std::vector<VectorXcr> ComplexCellProperties;
  165. /// Container holding names of Real cell properties
  166. std::vector<std::string> ComplexCellPropertyNames;
  167. */
  168. private:
  169. /** ASCII string representation of the class name */
  170. static constexpr auto CName = "RectilinearGrid";
  171. }; // ----- end of class RectilinearGrid -----
  172. } // ----- end of Lemma name -----
  173. #endif // ----- #ifndef RECTILINEARGRID_INC -----