Main Lemma Repository
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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