Lemma is an Electromagnetics API
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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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( ) : Grid( ), nx(0), ny(0), nz(0) {
  31. }
  32. RectilinearGrid::~RectilinearGrid() {
  33. }
  34. std::shared_ptr< RectilinearGrid > RectilinearGrid::NewSP() {
  35. std::shared_ptr<RectilinearGrid> sp(new RectilinearGrid( ), LemmaObjectDeleter() );
  36. return sp;
  37. }
  38. // ==================== OPERATIONS =======================
  39. void RectilinearGrid::SetDimensions (const int &inx, const int &iny,
  40. const int &inz) {
  41. dx.resize(inx);
  42. dy.resize(iny);
  43. dz.resize(inz);
  44. nx = inx;
  45. ny = iny;
  46. nz = inz;
  47. }
  48. void RectilinearGrid::SetOffset (const Real& iox, const Real& ioy, const Real& ioz) {
  49. ox = iox;
  50. oy = ioy;
  51. oz = ioz;
  52. }
  53. void RectilinearGrid::SetSpacing (const VectorXr &idx, const VectorXr &idy,
  54. const VectorXr &idz) {
  55. nx = idx.size();
  56. ny = idy.size();
  57. nz = idz.size();
  58. dx = idx;
  59. dy = idy;
  60. dz = idz;
  61. }
  62. //--------------------------------------------------------------------------------------
  63. // Class: RectilinearGrid
  64. // Method: GetNx
  65. //--------------------------------------------------------------------------------------
  66. int RectilinearGrid::GetNx ( ) {
  67. return nx;
  68. } // ----- end of method RectilinearGrid::GetNx -----
  69. //--------------------------------------------------------------------------------------
  70. // Class: RectilinearGrid
  71. // Method: GetNy
  72. //--------------------------------------------------------------------------------------
  73. int RectilinearGrid::GetNy ( ) {
  74. return ny;
  75. } // ----- end of method RectilinearGrid::GetNy -----
  76. //--------------------------------------------------------------------------------------
  77. // Class: RectilinearGrid
  78. // Method: GetNz
  79. //--------------------------------------------------------------------------------------
  80. int RectilinearGrid::GetNz ( ) {
  81. return nz;
  82. } // ----- end of method RectilinearGrid::GetNz -----
  83. //--------------------------------------------------------------------------------------
  84. // Class: RectilinearGrid
  85. // Method: GetOx
  86. //--------------------------------------------------------------------------------------
  87. Real RectilinearGrid::GetOx ( ) {
  88. return ox;
  89. } // ----- end of method RectilinearGrid::GetOx -----
  90. //--------------------------------------------------------------------------------------
  91. // Class: RectilinearGrid
  92. // Method: GetOy
  93. //--------------------------------------------------------------------------------------
  94. Real RectilinearGrid::GetOy ( ) {
  95. return oy;
  96. } // ----- end of method RectilinearGrid::GetOy -----
  97. //--------------------------------------------------------------------------------------
  98. // Class: RectilinearGrid
  99. // Method: GetOz
  100. //--------------------------------------------------------------------------------------
  101. Real RectilinearGrid::GetOz ( ) {
  102. return oz;
  103. } // ----- end of method RectilinearGrid::GetOz -----
  104. //--------------------------------------------------------------------------------------
  105. // Class: RectilinearGrid
  106. // Method: GetDx
  107. //--------------------------------------------------------------------------------------
  108. VectorXr RectilinearGrid::GetDx ( ) {
  109. return dx;
  110. } // ----- end of method RectilinearGrid::GetDx -----
  111. //--------------------------------------------------------------------------------------
  112. // Class: RectilinearGrid
  113. // Method: GetDx
  114. //--------------------------------------------------------------------------------------
  115. Real RectilinearGrid::GetDx ( const int& ix ) {
  116. return dx[ix];
  117. } // ----- end of method RectilinearGrid::GetDx -----
  118. //--------------------------------------------------------------------------------------
  119. // Class: RectilinearGrid
  120. // Method: GetDy
  121. //--------------------------------------------------------------------------------------
  122. VectorXr RectilinearGrid::GetDy ( ) {
  123. return dy;
  124. } // ----- end of method RectilinearGrid::GetDy -----
  125. //--------------------------------------------------------------------------------------
  126. // Class: RectilinearGrid
  127. // Method: GetDy
  128. //--------------------------------------------------------------------------------------
  129. Real RectilinearGrid::GetDy ( const int& iy ) {
  130. return dy[iy];
  131. } // ----- end of method RectilinearGrid::GetDy -----
  132. //--------------------------------------------------------------------------------------
  133. // Class: RectilinearGrid
  134. // Method: GetDz
  135. //--------------------------------------------------------------------------------------
  136. VectorXr RectilinearGrid::GetDz ( ) {
  137. return dz;
  138. } // ----- end of method RectilinearGrid::GetDz -----
  139. //--------------------------------------------------------------------------------------
  140. // Class: RectilinearGrid
  141. // Method: GetDz
  142. //--------------------------------------------------------------------------------------
  143. Real RectilinearGrid::GetDz ( const int& iz ) {
  144. return dz[iz];
  145. } // ----- end of method RectilinearGrid::GetDz -----
  146. } // ----- end of Lemma name -----