Main Lemma Repository
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

RectilinearGrid.h 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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. \ingroup LemmaCore
  20. \brief Impliments a rectilinear grid.
  21. \details A rectilinear grid can vary regularily in space but must be
  22. constant variation across each dimension. In this way three
  23. vectors can define the entire grid, and each cell is right
  24. aligned with all its neighbours.
  25. */
  26. // ===================================================================
  27. class RectilinearGrid : public Grid {
  28. friend std::ostream &operator<<(std::ostream &stream,
  29. const RectilinearGrid &ob);
  30. public:
  31. // ==================== LIFECYCLE =======================
  32. /**
  33. * Factory method for generating concrete class.
  34. * @return a std::shared_ptr of type RectilinearGrid
  35. */
  36. static std::shared_ptr<RectilinearGrid> NewSP();
  37. /**
  38. * Uses YAML to serialize this object.
  39. * @return a YAML::Node
  40. */
  41. YAML::Node Serialize() const;
  42. /**
  43. * Constructs an object from a YAML::Node.
  44. */
  45. static std::shared_ptr< RectilinearGrid > DeSerialize(const YAML::Node& node);
  46. // ==================== OPERATORS =======================
  47. // ==================== OPERATIONS =======================
  48. /**
  49. * Sets the dimensions in x, y and z
  50. * @param[in] nx is the number of cells in x
  51. * @param[in] ny is the number of cells in y
  52. * @param[in] nz is the number of cells in z
  53. */
  54. void SetDimensions (const int &nx, const int &ny, const int &nz);
  55. /**
  56. * Sets the offset in x, y and z. This sets the corner position of the top SW corner.
  57. * @param[in] ox is the number of cells in x
  58. * @param[in] oy is the number of cells in y
  59. * @param[in] oz is the number of cells in z
  60. */
  61. void SetOffset (const Real &ox, const Real &oy, const Real &oz);
  62. /**
  63. * Sets the spacing in x, y and z
  64. * @param[in] dx is a Vector of cell spacing in x, must be same
  65. * size ad nx
  66. * @param[in] dy is a Vector of cell spacing in x, must be same
  67. * size ad ny
  68. * @param[in] dz is a Vector of cell spacing in x, must be same
  69. * size ad nz
  70. */
  71. void SetSpacing (const VectorXr &dx, const VectorXr &dy,
  72. const VectorXr &dz);
  73. // ==================== ACCESS =======================
  74. /** Returns the number of cells in x
  75. * @return number of cells in x
  76. */
  77. int GetNx();
  78. /** Returns the number of cells in y
  79. * @return number of cells in y
  80. */
  81. int GetNy();
  82. /** Returns the number of cells in z
  83. * @return number of cells in z
  84. */
  85. int GetNz();
  86. /** Returns the offset of cells in x
  87. * @return offset of cells in x
  88. */
  89. Real GetOx();
  90. /** Returns the number of cells in y
  91. * @return number of cells in y
  92. */
  93. Real GetOy();
  94. /** Returns the offset of cells in z
  95. * @return offset of cells in z
  96. */
  97. Real GetOz();
  98. /** Returns Spacing Vector
  99. * @return dx
  100. */
  101. VectorXr GetDx();
  102. /** Returns a spacing
  103. * @return dx[ix]
  104. */
  105. Real GetDx(const int& ix);
  106. /** Returns Spacing Vector
  107. * @return dy
  108. */
  109. VectorXr GetDy();
  110. /** Returns a spacing
  111. * @return dy[iy]
  112. */
  113. Real GetDy(const int& iy);
  114. /** Returns Spacing Vector
  115. * @return dz
  116. */
  117. VectorXr GetDz();
  118. /** Returns Spacing Vector
  119. * @return dz[iz]
  120. */
  121. Real GetDz(const int& iz);
  122. // ==================== INQUIRY =======================
  123. /** Returns the name of the underlying class, similiar to Python's type */
  124. virtual inline std::string GetName() const {
  125. return this->CName;
  126. }
  127. protected:
  128. // ==================== LIFECYCLE =======================
  129. /** Default protected constructor. */
  130. RectilinearGrid ( );
  131. /** Protected DeDerializing constructor, use factory DeSerialize method*/
  132. RectilinearGrid (const YAML::Node& node);
  133. /** Default protected constructor. */
  134. ~RectilinearGrid ();
  135. // ==================== DATA MEMBERS =========================
  136. /// Number of cells in the x dimension
  137. int nx;
  138. /// Number of cells in the y dimension
  139. int ny;
  140. /// Number of cells in the z dimension
  141. int nz;
  142. /// Grid offset in x dimension
  143. Real ox;
  144. /// Grid offset in y dimension
  145. Real oy;
  146. /// Grid offset in z dimension
  147. Real oz;
  148. /// Cell spacing in the x dimension
  149. VectorXr dx;
  150. /// Cell spacing in the y dimension
  151. VectorXr dy;
  152. /// Cell spacing in the z dimension
  153. VectorXr dz;
  154. private:
  155. /** ASCII string representation of the class name */
  156. static constexpr auto CName = "RectilinearGrid";
  157. }; // ----- end of class RectilinearGrid -----
  158. } // ----- end of Lemma name -----
  159. #endif // ----- #ifndef RECTILINEARGRID_INC -----
  160. /* vim: set tabstop=4 expandtab: */
  161. /* vim: set filetype=cpp: */