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.cpp 7.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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
  15. return stream;
  16. }
  17. // ==================== LIFECYCLE =======================
  18. RectilinearGrid::RectilinearGrid( const ctor_key& ) : Grid( ), nx(0), ny(0), nz(0) {
  19. }
  20. RectilinearGrid::RectilinearGrid( const YAML::Node& node, const ctor_key& ) : Grid(node) {
  21. nx = node["nx"].as<int>( );
  22. ny = node["ny"].as<int>( );
  23. nz = node["nz"].as<int>( );
  24. ox = node["ox"].as<Real>( );
  25. oy = node["oy"].as<Real>( );
  26. oz = node["oz"].as<Real>( );
  27. dx = node["dx"].as< VectorXr >();
  28. dy = node["dy"].as< VectorXr >();
  29. dz = node["dz"].as< VectorXr >();
  30. }
  31. RectilinearGrid::~RectilinearGrid() {
  32. }
  33. std::shared_ptr< RectilinearGrid > RectilinearGrid::NewSP() {
  34. return std::make_shared< RectilinearGrid > ( ctor_key() );
  35. }
  36. YAML::Node RectilinearGrid::Serialize() const {
  37. YAML::Node node = Grid::Serialize();
  38. node["nx"] = nx;
  39. node["ny"] = ny;
  40. node["nz"] = nz;
  41. node["ox"] = ox;
  42. node["oy"] = oy;
  43. node["oz"] = oz;
  44. node["dx"] = dx;
  45. node["dy"] = dy;
  46. node["dz"] = dz;
  47. node.SetTag( this->GetName() );
  48. return node;
  49. }
  50. //--------------------------------------------------------------------------------------
  51. // Class: RectilinearGrid
  52. // Method: DeSerialize
  53. //--------------------------------------------------------------------------------------
  54. std::shared_ptr<RectilinearGrid> RectilinearGrid::DeSerialize ( const YAML::Node& node ) {
  55. if (node.Tag() != "RectilinearGrid") {
  56. throw DeSerializeTypeMismatch( "RectilinearGrid", node.Tag());
  57. }
  58. return std::make_shared< RectilinearGrid > ( node, ctor_key() );
  59. }
  60. // ==================== OPERATIONS =======================
  61. void RectilinearGrid::SetDimensions (const int &inx, const int &iny,
  62. const int &inz) {
  63. dx.resize(inx);
  64. dy.resize(iny);
  65. dz.resize(inz);
  66. nx = inx;
  67. ny = iny;
  68. nz = inz;
  69. }
  70. void RectilinearGrid::SetOffset (const Real& iox, const Real& ioy, const Real& ioz) {
  71. ox = iox;
  72. oy = ioy;
  73. oz = ioz;
  74. }
  75. void RectilinearGrid::SetSpacing (const VectorXr &idx, const VectorXr &idy,
  76. const VectorXr &idz) {
  77. nx = idx.size();
  78. ny = idy.size();
  79. nz = idz.size();
  80. dx = idx;
  81. dy = idy;
  82. dz = idz;
  83. }
  84. //--------------------------------------------------------------------------------------
  85. // Class: RectilinearGrid
  86. // Method: GetNx
  87. //--------------------------------------------------------------------------------------
  88. int RectilinearGrid::GetNx ( ) {
  89. return nx;
  90. } // ----- end of method RectilinearGrid::GetNx -----
  91. //--------------------------------------------------------------------------------------
  92. // Class: RectilinearGrid
  93. // Method: GetNy
  94. //--------------------------------------------------------------------------------------
  95. int RectilinearGrid::GetNy ( ) {
  96. return ny;
  97. } // ----- end of method RectilinearGrid::GetNy -----
  98. //--------------------------------------------------------------------------------------
  99. // Class: RectilinearGrid
  100. // Method: GetNz
  101. //--------------------------------------------------------------------------------------
  102. int RectilinearGrid::GetNz ( ) {
  103. return nz;
  104. } // ----- end of method RectilinearGrid::GetNz -----
  105. //--------------------------------------------------------------------------------------
  106. // Class: RectilinearGrid
  107. // Method: GetOx
  108. //--------------------------------------------------------------------------------------
  109. Real RectilinearGrid::GetOx ( ) {
  110. return ox;
  111. } // ----- end of method RectilinearGrid::GetOx -----
  112. //--------------------------------------------------------------------------------------
  113. // Class: RectilinearGrid
  114. // Method: GetOy
  115. //--------------------------------------------------------------------------------------
  116. Real RectilinearGrid::GetOy ( ) {
  117. return oy;
  118. } // ----- end of method RectilinearGrid::GetOy -----
  119. //--------------------------------------------------------------------------------------
  120. // Class: RectilinearGrid
  121. // Method: GetOz
  122. //--------------------------------------------------------------------------------------
  123. Real RectilinearGrid::GetOz ( ) {
  124. return oz;
  125. } // ----- end of method RectilinearGrid::GetOz -----
  126. //--------------------------------------------------------------------------------------
  127. // Class: RectilinearGrid
  128. // Method: GetDx
  129. //--------------------------------------------------------------------------------------
  130. VectorXr RectilinearGrid::GetDx ( ) {
  131. return dx;
  132. } // ----- end of method RectilinearGrid::GetDx -----
  133. //--------------------------------------------------------------------------------------
  134. // Class: RectilinearGrid
  135. // Method: GetDx
  136. //--------------------------------------------------------------------------------------
  137. Real RectilinearGrid::GetDx ( const int& ix ) {
  138. return dx[ix];
  139. } // ----- end of method RectilinearGrid::GetDx -----
  140. //--------------------------------------------------------------------------------------
  141. // Class: RectilinearGrid
  142. // Method: GetDy
  143. //--------------------------------------------------------------------------------------
  144. VectorXr RectilinearGrid::GetDy ( ) {
  145. return dy;
  146. } // ----- end of method RectilinearGrid::GetDy -----
  147. //--------------------------------------------------------------------------------------
  148. // Class: RectilinearGrid
  149. // Method: GetDy
  150. //--------------------------------------------------------------------------------------
  151. Real RectilinearGrid::GetDy ( const int& iy ) {
  152. return dy[iy];
  153. } // ----- end of method RectilinearGrid::GetDy -----
  154. //--------------------------------------------------------------------------------------
  155. // Class: RectilinearGrid
  156. // Method: GetDz
  157. //--------------------------------------------------------------------------------------
  158. VectorXr RectilinearGrid::GetDz ( ) {
  159. return dz;
  160. } // ----- end of method RectilinearGrid::GetDz -----
  161. //--------------------------------------------------------------------------------------
  162. // Class: RectilinearGrid
  163. // Method: GetDz
  164. //--------------------------------------------------------------------------------------
  165. Real RectilinearGrid::GetDz ( const int& iz ) {
  166. return dz[iz];
  167. } // ----- end of method RectilinearGrid::GetDz -----
  168. } // ----- end of Lemma name -----
  169. /* vim: set tabstop=4 expandtab: */
  170. /* vim: set filetype=cpp: syntax=cpp.doxygen*/