Main Lemma Repository
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

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