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.

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. 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 inline std::string GetName() const {
  88. return CName;
  89. }
  90. /// Returns the number of receiverpoints.
  91. int GetNumberOfPoints();
  92. /// Returns all the receiver locations as a 3 X matrix
  93. Vector3Xr GetLocations();
  94. /// Returns all the receiver locations as a general matrix, useful for python wrapper
  95. MatrixXr GetLocationsMat();
  96. /// Returns the E field for all locations
  97. /// nfreq is the freqency desired
  98. Vector3Xcr GetEfield(const int &nfreq);
  99. /// Returns the E field for all locations
  100. /// nfreq is the freqency desired, cast to general dynamic matrix, for python interoperability
  101. MatrixXcr GetEfieldMat(const int &nfreq);
  102. /// Returns the H field for all locations
  103. /// nfreq is the freqency desired, cast to general dynamic matrix, for python interoperability
  104. MatrixXcr GetHfieldMat(const int &nfreq);
  105. /// Returns the H field for all locations
  106. /// nfreq is the freqency desired
  107. Vector3Xcr GetHfield(const int &nfreq);
  108. /// Returns all of the computed H fields. Every frequency
  109. std::vector<Vector3Xcr> GetHfield( );
  110. /// Returns all of the computed E fields. Every frequency
  111. std::vector<Vector3Xcr> GetEfield( );
  112. /// Returns the E field of a single receiver as an Eigen Vector
  113. /// nfreq is the freqency desired
  114. Vector3cr GetEfield(const int &nfreq, const int& loc);
  115. /// Returns the H field of a single receiver as an Eigen Vector
  116. /// nfreq is the freqency desired
  117. Vector3cr GetHfield(const int &nfreq, const int& loc);
  118. /// Returns the B field of a single receiver as an Eigen Vector
  119. /// nfreq is the freqency desired
  120. Vector3cr GetBfield(const int &nfreq, const int& loc);
  121. #ifdef LEMMAUSEVTK
  122. /// Returns vtk Glyph actor that can be placed into scenes
  123. vtkActor* GetVtkGlyphActor(const FIELDTYPE &ftype,
  124. const Real& clip, const Real &scale,
  125. const int &nfreq);
  126. /// Returns a vtk Data Object that can easily be plotted
  127. vtkDataObject * GetVtkDataObject(const FIELDTYPE &ftype,
  128. const int& nbin,
  129. const int& start, const int& end,
  130. const FIELDCOMPONENT& fcomp,
  131. const SPATIALCOORDINANT& scord);
  132. /// Returns a vtk Data Object that can easily be plotted
  133. vtkDataObject * GetVtkDataObjectFreq(const FIELDTYPE &ftype,
  134. const int& nrec,
  135. const int& fstart, const int& fend,
  136. const FIELDCOMPONENT& fcomp,
  137. const VectorXr& Freqs);
  138. #endif
  139. /// Returns the location of a single receiver as an Eigen Vector
  140. Vector3r GetLocation(const int& loc);
  141. /// Returns the x component of the location
  142. Real GetLocationX(const int& loc);
  143. /// Returns the y component of the location
  144. Real GetLocationY(const int& loc);
  145. /// Returns the z component of the location
  146. Real GetLocationZ(const int& loc);
  147. /// Resets fields
  148. void ClearFields();
  149. /// Sets the mask variable to true for this point.
  150. void MaskPoint(const int& i);
  151. /// Turns the mask off for this point.
  152. void UnMaskPoint(const int& i);
  153. /// Removes making on all points
  154. void UnMaskAllPoints();
  155. /// Returns the mask for this point
  156. int GetMask(const int& i);
  157. protected:
  158. // ==================== OPERATIONS ===========================
  159. /// Sets the number of H bins. These bins are often frequencies.
  160. void SetNumberOfBinsH(const int& nbins);
  161. /// Sets the number of E bins. These bins are often frequencies.
  162. void SetNumberOfBinsE(const int& nbins);
  163. /** Internal function that resizes the EField data structure */
  164. void ResizeEField();
  165. /** Internal function that resizes the HField data structure */
  166. void ResizeHField();
  167. /// Sets the value of the E field
  168. void SetEfield(const int &nfreq, const int& loc,
  169. const Complex &ex, const Complex &ey, const Complex &ez);
  170. /// Sets the value of the H field
  171. void SetHfield(const int &nfreq, const int& loc,
  172. const Complex &hx, const Complex &hy, const Complex &hz);
  173. /// Appends the value of the E field. This method is not
  174. /// thread safe.
  175. void AppendEfield(const int&nfreq, const int& loc,
  176. const Complex &ex, const Complex &ey, const Complex &ez);
  177. /// Appends the value of the H field. This method is not
  178. /// thread safe.
  179. void AppendHfield(const int &nfreq, const int& loc,
  180. const Complex &hx, const Complex &hy, const Complex &hz);
  181. // ==================== DATA MEMBERS ===========================
  182. private:
  183. /// Number of receivers
  184. int NumberOfPoints;
  185. /// Number of fields
  186. int NumberOfBinsE;
  187. /// Number of fields
  188. int NumberOfBinsH;
  189. /// Used to mask this point so no computation is made at
  190. /// this point.
  191. VectorXi Mask;
  192. /// Locations of receivers
  193. Vector3Xr Locations;
  194. // NOTE, these are not serialized in output!
  195. /// Electric field at receiver locations
  196. std::vector<Vector3Xcr> Efield;
  197. /// H field at receiver locations
  198. std::vector<Vector3Xcr> Hfield;
  199. /** ASCII string representation of the class name */
  200. static constexpr auto CName = "FieldPoints";
  201. }; // ----- end of class FieldPoints -----
  202. }
  203. #endif // __FIELDPOINTS