Main Lemma Repository
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

WireAntenna.h 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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/16/2009
  9. @version $Id: WireAntenna.h 201 2015-01-03 00:07:47Z tirons $
  10. **/
  11. #ifndef __WIREANTENNA_H
  12. #define __WIREANTENNA_H
  13. #include "DipoleSource.h"
  14. #ifdef LEMMAUSEVTK
  15. #include "vtkActor.h"
  16. #endif
  17. namespace Lemma {
  18. // ===================================================================
  19. /** Class: WireAntenna
  20. * \brief Class representing a wire antennae.
  21. * \details This is an abstract class.
  22. */
  23. // ===================================================================
  24. class WireAntenna : public LemmaObject {
  25. friend std::ostream &operator<<(std::ostream &stream, const WireAntenna &ob);
  26. struct ctor_key {};
  27. public:
  28. // ==================== LIFECYCLE =======================
  29. /** Locked default constructor */
  30. explicit WireAntenna ( const ctor_key& );
  31. /** Locked deserializing constructor */
  32. WireAntenna ( const YAML::Node& node, const ctor_key& );
  33. /** Destructor */
  34. virtual ~WireAntenna();
  35. /**
  36. * Initialises antenna to contain no points, with no current
  37. * and no frequency. NumberOfTurns set to 1
  38. */
  39. static std::shared_ptr<WireAntenna> NewSP();
  40. /**
  41. * Provides deep copy
  42. */
  43. virtual std::shared_ptr<WireAntenna> Clone();
  44. /**
  45. * Uses YAML to serialize this object.
  46. * @return a YAML::Node
  47. */
  48. YAML::Node Serialize() const;
  49. /**
  50. * Constructs an object from a YAML::Node.
  51. */
  52. static std::shared_ptr<WireAntenna> DeSerialize( const YAML::Node& node );
  53. // ==================== OPERATORS =======================
  54. // ==================== OPERATIONS =======================
  55. /**
  56. * Approximates with evenly spaced electric dipoles around loop
  57. * @param[in] delta is the spacing between moments
  58. */
  59. virtual void ApproximateWithElectricDipoles(const Real &delta);
  60. // ==================== ACCESS =======================
  61. /**
  62. * Sets the number of turns in the loop, default is 1
  63. * @param[in] nturns is the number of turns of the loop.
  64. */
  65. void SetNumberOfTurns(const int &nturns);
  66. /**
  67. * Sets the number of points in the loop
  68. */
  69. void SetNumberOfPoints(const int &np);
  70. /**
  71. * Sets a corner point of the loop. Counting starts at 0. It
  72. * is not required to have the loop be closed right now, but
  73. * its a good idea.
  74. */
  75. void SetPoint(const int &p, const Vector3r &pos);
  76. /**
  77. * Sets a corner point of the loop. Counting starts at 0. It
  78. * is not required to have the loop be closed right now, but
  79. * its a good idea.
  80. */
  81. void SetPoint(const int &p, const Real&x, const Real& y, const Real& z);
  82. /** Sets the frequency of the current in the loop, default is 0
  83. * @param[in] ifreq is the frequency number to set
  84. * @param[in] freq is the frequency (Hz) of the current
  85. */
  86. void SetFrequency(const int& ifreq, const Real &freq);
  87. /**
  88. * Sets the number of frequencies.
  89. * @param[in] nfreq is the number of frequencies that will be
  90. * computed.
  91. */
  92. void SetNumberOfFrequencies(const int& nfreq);
  93. /**
  94. * Sets the current in the loop, default is 0
  95. * @param[in] amp is the current in the loop, in Amperes
  96. */
  97. void SetCurrent(const Real &amp);
  98. // ==================== INQUIRY =======================
  99. /**
  100. * Returns the number of turns
  101. * @return the number of turns of the loop.
  102. */
  103. int GetNumberOfTurns( );
  104. /**
  105. * Returns all of the points
  106. */
  107. Vector3Xr GetPoints();
  108. /**
  109. * Returns all of the points in a general matrix, useful for python wrapper
  110. */
  111. MatrixXr GetPointsMat();
  112. /**
  113. * Returns the frequency in the loop.
  114. * @return is the frequency in the loop in Hz
  115. */
  116. Real GetFrequency(const int& ifreq);
  117. /**
  118. * Returns the current in the loop.
  119. * @return is the Current
  120. */
  121. Real GetCurrent( );
  122. /**
  123. * Returns pointer to a dipole source
  124. */
  125. std::shared_ptr<DipoleSource> GetDipoleSource(const int &dip);
  126. /**
  127. * returns number of dipoles used to approximate this
  128. * loop
  129. */
  130. int GetNumberOfDipoles();
  131. /**
  132. * @return the number of frequencies of this wire loop.
  133. */
  134. int GetNumberOfFrequencies();
  135. #ifdef LEMMAUSEVTK
  136. /** Returns an actor that can be placed into a vtk scene easily
  137. * Note that this function throws a pointer, it is the
  138. * receivers job to manage this memory!
  139. */
  140. vtkActor* GetVtkActor(const int &idip);
  141. #endif
  142. /** Returns true or false if loop is horizontally planar
  143. */
  144. bool IsHorizontallyPlanar();
  145. /** Returns the name of the underlying class, similiar to Python's type */
  146. virtual inline std::string GetName() const {
  147. return CName;
  148. }
  149. protected:
  150. // ==================== DATA MEMBERS =======================
  151. /**
  152. * Number of points that define the loop
  153. */
  154. int NumberOfPoints;
  155. /**
  156. * Current in antennae (Amps)
  157. */
  158. Real Current;
  159. /**
  160. * Number of turns
  161. */
  162. int NumberOfTurns;
  163. /**
  164. * List of the dipoles
  165. */
  166. std::vector< std::shared_ptr<DipoleSource> > Dipoles;
  167. /**
  168. * Points that define this loop
  169. */
  170. Vector3Xr Points;
  171. /**
  172. * Frequencies of the loop.
  173. */
  174. VectorXr Freqs;
  175. private:
  176. static constexpr auto CName = "WireAntenna";
  177. }; // ----- end of class WireAntenna -----
  178. }
  179. #endif // __WIREANTENNA_H