Main Lemma Repository
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

FieldPoints.h 9.7KB

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