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

FieldPoints.h 9.9KB

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