Main Lemma Repository
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RectilinearGrid.cpp 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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.cpp 193 2014-11-10 23:51:41Z tirons $
  10. **/
  11. #include "RectilinearGrid.h"
  12. namespace Lemma {
  13. std::ostream &operator << (std::ostream &stream, const RectilinearGrid &ob) {
  14. stream << ob.Serialize() << "\n---\n"; // End of doc --- as a direct stream should encapulste thingy
  15. return stream;
  16. }
  17. /*
  18. std::ostream &operator<<(std::ostream &stream, const
  19. RectilinearGrid &ob) {
  20. stream << *(LemmaObject*)(&ob);
  21. stream << "\tnx=" << ob.nx << "\tny=" << ob.ny << "\tnz=" << ob.nz << std::endl;
  22. stream << "\tox=" << ob.ox << "\toy=" << ob.oy << "\toz=" << ob.oz << std::endl;
  23. stream << "\tdx=" << ob.dx.transpose() << std::endl;
  24. stream << "\tdy=" << ob.dy.transpose() << std::endl;
  25. stream << "\tdz=" << ob.dz.transpose() << std::endl;
  26. return stream;
  27. }
  28. */
  29. // ==================== LIFECYCLE =======================
  30. RectilinearGrid::RectilinearGrid(const std::string& name) :
  31. Grid(name), nx(0), ny(0), nz(0) {
  32. }
  33. RectilinearGrid::~RectilinearGrid() {
  34. }
  35. std::shared_ptr< RectilinearGrid > RectilinearGrid::NewSP() {
  36. std::shared_ptr<RectilinearGrid> sp(new RectilinearGrid("RectilinearGrid"), LemmaObjectDeleter() );
  37. return sp;
  38. }
  39. // ==================== OPERATIONS =======================
  40. void RectilinearGrid::SetDimensions (const int &inx, const int &iny,
  41. const int &inz) {
  42. dx.resize(inx);
  43. dy.resize(iny);
  44. dz.resize(inz);
  45. nx = inx;
  46. ny = iny;
  47. nz = inz;
  48. }
  49. void RectilinearGrid::SetOffset (const Real& iox, const Real& ioy, const Real& ioz) {
  50. ox = iox;
  51. oy = ioy;
  52. oz = ioz;
  53. }
  54. void RectilinearGrid::SetSpacing (const VectorXr &idx, const VectorXr &idy,
  55. const VectorXr &idz) {
  56. nx = idx.size();
  57. ny = idy.size();
  58. nz = idz.size();
  59. dx = idx;
  60. dy = idy;
  61. dz = idz;
  62. }
  63. //--------------------------------------------------------------------------------------
  64. // Class: RectilinearGrid
  65. // Method: GetNx
  66. //--------------------------------------------------------------------------------------
  67. int RectilinearGrid::GetNx ( ) {
  68. return nx;
  69. } // ----- end of method RectilinearGrid::GetNx -----
  70. //--------------------------------------------------------------------------------------
  71. // Class: RectilinearGrid
  72. // Method: GetNy
  73. //--------------------------------------------------------------------------------------
  74. int RectilinearGrid::GetNy ( ) {
  75. return ny;
  76. } // ----- end of method RectilinearGrid::GetNy -----
  77. //--------------------------------------------------------------------------------------
  78. // Class: RectilinearGrid
  79. // Method: GetNz
  80. //--------------------------------------------------------------------------------------
  81. int RectilinearGrid::GetNz ( ) {
  82. return nz;
  83. } // ----- end of method RectilinearGrid::GetNz -----
  84. //--------------------------------------------------------------------------------------
  85. // Class: RectilinearGrid
  86. // Method: GetOx
  87. //--------------------------------------------------------------------------------------
  88. Real RectilinearGrid::GetOx ( ) {
  89. return ox;
  90. } // ----- end of method RectilinearGrid::GetOx -----
  91. //--------------------------------------------------------------------------------------
  92. // Class: RectilinearGrid
  93. // Method: GetOy
  94. //--------------------------------------------------------------------------------------
  95. Real RectilinearGrid::GetOy ( ) {
  96. return oy;
  97. } // ----- end of method RectilinearGrid::GetOy -----
  98. //--------------------------------------------------------------------------------------
  99. // Class: RectilinearGrid
  100. // Method: GetOz
  101. //--------------------------------------------------------------------------------------
  102. Real RectilinearGrid::GetOz ( ) {
  103. return oz;
  104. } // ----- end of method RectilinearGrid::GetOz -----
  105. //--------------------------------------------------------------------------------------
  106. // Class: RectilinearGrid
  107. // Method: GetDx
  108. //--------------------------------------------------------------------------------------
  109. VectorXr RectilinearGrid::GetDx ( ) {
  110. return dx;
  111. } // ----- end of method RectilinearGrid::GetDx -----
  112. //--------------------------------------------------------------------------------------
  113. // Class: RectilinearGrid
  114. // Method: GetDx
  115. //--------------------------------------------------------------------------------------
  116. Real RectilinearGrid::GetDx ( const int& ix ) {
  117. return dx[ix];
  118. } // ----- end of method RectilinearGrid::GetDx -----
  119. //--------------------------------------------------------------------------------------
  120. // Class: RectilinearGrid
  121. // Method: GetDy
  122. //--------------------------------------------------------------------------------------
  123. VectorXr RectilinearGrid::GetDy ( ) {
  124. return dy;
  125. } // ----- end of method RectilinearGrid::GetDy -----
  126. //--------------------------------------------------------------------------------------
  127. // Class: RectilinearGrid
  128. // Method: GetDy
  129. //--------------------------------------------------------------------------------------
  130. Real RectilinearGrid::GetDy ( const int& iy ) {
  131. return dy[iy];
  132. } // ----- end of method RectilinearGrid::GetDy -----
  133. //--------------------------------------------------------------------------------------
  134. // Class: RectilinearGrid
  135. // Method: GetDz
  136. //--------------------------------------------------------------------------------------
  137. VectorXr RectilinearGrid::GetDz ( ) {
  138. return dz;
  139. } // ----- end of method RectilinearGrid::GetDz -----
  140. //--------------------------------------------------------------------------------------
  141. // Class: RectilinearGrid
  142. // Method: GetDz
  143. //--------------------------------------------------------------------------------------
  144. Real RectilinearGrid::GetDz ( const int& iz ) {
  145. return dz[iz];
  146. } // ----- end of method RectilinearGrid::GetDz -----
  147. } // ----- end of Lemma name -----