Lemma is an Electromagnetics API
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.

WireAntenna.h 6.7KB

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