Lemma is an Electromagnetics API
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

RectilinearGrid.h 7.3KB

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