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.

receiverpoints.h 9.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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 12/02/2009
  9. @version $Id: receiverpoints.h 199 2014-12-29 19:25:20Z tirons $
  10. **/
  11. #ifndef __RECEIVERPOINTS_H
  12. #define __RECEIVERPOINTS_H
  13. #ifdef LEMMAUSEVTK
  14. #include "vtkPointData.h"
  15. #include "vtkFieldData.h"
  16. #include "vtkGlyph3D.h"
  17. #include "vtkArrowSource.h"
  18. #include "vtkActor.h"
  19. #include "vtkPolyDataMapper.h"
  20. #include "vtkPoints.h"
  21. #include "vtkPolyData.h"
  22. #include "vtkDoubleArray.h"
  23. #include "vtkDataObject.h"
  24. #endif
  25. #include "LemmaObject.h"
  26. #include "dipolesource.h"
  27. #ifdef HAVE_YAMLCPP
  28. #include "yaml-cpp/yaml.h"
  29. #endif
  30. namespace Lemma {
  31. // =======================================================================
  32. // Class: ReceiverPoints
  33. /// \brief Points in the subsurface to make EM calculations,
  34. /// more general than the grids.
  35. // =======================================================================
  36. class ReceiverPoints : public LemmaObject {
  37. public:
  38. // ==================== FRIENDS ===========================
  39. /** Stream operator printing out information about this class.
  40. */
  41. friend std::ostream &operator<<(std::ostream &stream,
  42. const ReceiverPoints &ob);
  43. friend class EMEarth1D;
  44. friend class DipoleSource;
  45. // ==================== LIFECYCLE ===========================
  46. /**
  47. * Returns pointer to new DipoleSource. Location is
  48. * initialized to (0,0,0) type and polarization are
  49. * initialized to nonworking values that will throw
  50. * exceptions if used.
  51. */
  52. static ReceiverPoints* New();
  53. /**
  54. * @copybrief LemmaObject::Delete()
  55. * @copydetails LemmaObject::Delete()
  56. */
  57. void Delete();
  58. // ==================== OPERATORS ===========================
  59. // ==================== OPERATIONS ===========================
  60. // ==================== ACCESS ===========================
  61. /// Sets the number of receivers
  62. virtual void SetNumberOfReceivers(const int &nrec);
  63. /// Returns the location of a single receiver as an Eigen Vector
  64. void SetLocation(const int& nrec, const Vector3r& loc);
  65. /// Returns the location of a single receiver as an Eigen Vector
  66. void SetLocation(const int& nrec, const Real& xp, const Real& yp,
  67. const Real& zp);
  68. // ==================== INQUIRY ===========================
  69. /// Returns the number of receiverpoints.
  70. int GetNumberOfReceivers();
  71. /// Returns all the receiver locations as a 3 X matrix
  72. Vector3Xr GetLocations();
  73. /// Returns all the receiver locations as a general matrix, useful for python wrapper
  74. MatrixXr GetLocationsMat();
  75. /// Returns the E field for all locations
  76. /// nfreq is the freqency desired
  77. Vector3Xcr GetEfield(const int &nfreq);
  78. /// Returns the E field for all locations
  79. /// nfreq is the freqency desired, cast to general dynamic matrix, for python interoperability
  80. MatrixXcr GetEfieldMat(const int &nfreq);
  81. /// Returns the H field for all locations
  82. /// nfreq is the freqency desired, cast to general dynamic matrix, for python interoperability
  83. MatrixXcr GetHfieldMat(const int &nfreq);
  84. /// Returns the H field for all locations
  85. /// nfreq is the freqency desired
  86. Vector3Xcr GetHfield(const int &nfreq);
  87. /// Returns all of the computed H fields. Every frequency
  88. std::vector<Vector3Xcr> GetHfield( );
  89. /// Returns all of the computed E fields. Every frequency
  90. std::vector<Vector3Xcr> GetEfield( );
  91. /// Returns the E field of a single receiver as an Eigen Vector
  92. /// nfreq is the freqency desired
  93. Vector3cr GetEfield(const int &nfreq, const int& loc);
  94. /// Returns the H field of a single receiver as an Eigen Vector
  95. /// nfreq is the freqency desired
  96. Vector3cr GetHfield(const int &nfreq, const int& loc);
  97. /// Returns the B field of a single receiver as an Eigen Vector
  98. /// nfreq is the freqency desired
  99. Vector3cr GetBfield(const int &nfreq, const int& loc);
  100. #ifdef LEMMAUSEVTK
  101. /// Returns vtk Glyph actor that can be placed into scenes
  102. vtkActor* GetVtkGlyphActor(const FIELDTYPE &ftype,
  103. const Real& clip, const Real &scale,
  104. const int &nfreq);
  105. /// Returns a vtk Data Object that can easily be plotted
  106. vtkDataObject * GetVtkDataObject(const FIELDTYPE &ftype,
  107. const int& nbin,
  108. const int& start, const int& end,
  109. const FIELDCOMPONENT& fcomp,
  110. const SPATIALCOORDINANT& scord);
  111. /// Returns a vtk Data Object that can easily be plotted
  112. vtkDataObject * GetVtkDataObjectFreq(const FIELDTYPE &ftype,
  113. const int& nrec,
  114. const int& fstart, const int& fend,
  115. const FIELDCOMPONENT& fcomp,
  116. const VectorXr& Freqs);
  117. #endif
  118. /// Returns the location of a single receiver as an Eigen Vector
  119. Vector3r GetLocation(const int& loc);
  120. /// Returns the x component of the location
  121. Real GetLocationX(const int& loc);
  122. /// Returns the y component of the location
  123. Real GetLocationY(const int& loc);
  124. /// Returns the z component of the location
  125. Real GetLocationZ(const int& loc);
  126. /// Resets fields
  127. void ClearFields();
  128. /// Sets the mask variable to true for this point.
  129. void MaskPoint(const int& i);
  130. /// Turns the mask off for this point.
  131. void UnMaskPoint(const int& i);
  132. /// Removes making on all points
  133. void UnMaskAllPoints();
  134. /// Returns the mask for this point
  135. int GetMask(const int& i);
  136. #ifdef HAVE_YAMLCPP
  137. /**
  138. * Uses YAML to serialize this object.
  139. * @return a YAML::Node
  140. */
  141. YAML::Node Serialize() const;
  142. /**
  143. * Constructs an object from a YAML::Node.
  144. */
  145. static ReceiverPoints* DeSerialize(const YAML::Node& node);
  146. #endif
  147. protected:
  148. // ==================== LIFECYCLE ===========================
  149. /// Default protected constructor.
  150. ReceiverPoints (const std::string& name);
  151. #ifdef HAVE_YAMLCPP
  152. /// Default protected constructor.
  153. ReceiverPoints (const YAML::Node& node);
  154. #endif
  155. /// Default protected constructor.
  156. ~ReceiverPoints ();
  157. /**
  158. * @copybrief LemmaObject::Release()
  159. * @copydetails LemmaObject::Release()
  160. */
  161. void Release();
  162. // ==================== OPERATIONS ===========================
  163. /// Sets the number of H bins. These bins are often frequencies.
  164. void SetNumberOfBinsH(const int& nbins);
  165. /// Sets the number of E bins. These bins are often frequencies.
  166. void SetNumberOfBinsE(const int& nbins);
  167. /** Internal function that resizes the EField data structure */
  168. void ResizeEField();
  169. /** Internal function that resizes the HField data structure */
  170. void ResizeHField();
  171. /// Sets the value of the E field
  172. void SetEfield(const int &nfreq, const int& loc,
  173. const Complex &ex, const Complex &ey, const Complex &ez);
  174. /// Sets the value of the H field
  175. void SetHfield(const int &nfreq, const int& loc,
  176. const Complex &hx, const Complex &hy, const Complex &hz);
  177. /// Appends the value of the E field. This method is not
  178. /// thread safe.
  179. void AppendEfield(const int&nfreq, const int& loc,
  180. const Complex &ex, const Complex &ey, const Complex &ez);
  181. /// Appends the value of the H field. This method is not
  182. /// thread safe.
  183. void AppendHfield(const int &nfreq, const int& loc,
  184. const Complex &hx, const Complex &hy, const Complex &hz);
  185. // ==================== DATA MEMBERS ===========================
  186. /// Number of receivers
  187. int NumberOfReceivers;
  188. /// Number of fields
  189. int NumberOfBinsE;
  190. /// Number of fields
  191. int NumberOfBinsH;
  192. /// Used to mask this point so no computation is made at
  193. /// this point.
  194. VectorXi Mask;
  195. /// Locations of receivers
  196. Vector3Xr Locations;
  197. private:
  198. // NOTE, these are not serialized in output!
  199. /// Electric field at receiver locations
  200. std::vector<Vector3Xcr> Efield;
  201. /// H field at receiver locations
  202. std::vector<Vector3Xcr> Hfield;
  203. }; // ----- end of class ReceiverPoints -----
  204. }
  205. #endif // __RECEIVERPOINTS