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.6KB

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