Lemma is an Electromagnetics API
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

WireAntenna.h 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. /**
  20. * \ingroup FDEM1D
  21. * \brief Class representing a wire antennae.
  22. * \details This is an abstract class.
  23. */
  24. // ===================================================================
  25. class WireAntenna : public LemmaObject {
  26. friend std::ostream &operator<<(std::ostream &stream, const WireAntenna &ob);
  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() const ;
  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. /**
  54. * Constructs an object from a string representation of a YAML::Node. This is primarily
  55. * used in Python wrapping
  56. */
  57. static std::shared_ptr<WireAntenna> DeSerialize( const std::string& node ) {
  58. return WireAntenna::DeSerialize(YAML::LoadFile(node));
  59. }
  60. // ==================== OPERATORS =======================
  61. // ==================== OPERATIONS =======================
  62. /**
  63. * Approximates with evenly spaced electric dipoles around loop
  64. * @param[in] delta is the spacing between moments
  65. */
  66. virtual void ApproximateWithElectricDipoles(const Real &delta);
  67. // ==================== ACCESS =======================
  68. /**
  69. * Sets the number of turns in the loop, default is 1
  70. * @param[in] nturns is the number of turns of the loop.
  71. */
  72. void SetNumberOfTurns(const int &nturns);
  73. /**
  74. * Sets the number of points in the loop
  75. */
  76. void SetNumberOfPoints(const int &np);
  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 Vector3r &pos);
  83. /**
  84. * Sets a corner point of the loop. Counting starts at 0. It
  85. * is not required to have the loop be closed right now, but
  86. * its a good idea.
  87. */
  88. void SetPoint(const int &p, const Real&x, const Real& y, const Real& z);
  89. /** Sets the frequency of the current in the loop, default is 0
  90. * @param[in] ifreq is the frequency number to set
  91. * @param[in] freq is the frequency (Hz) of the current
  92. */
  93. void SetFrequency(const int& ifreq, const Real &freq);
  94. /**
  95. * Sets the number of frequencies.
  96. * @param[in] nfreq is the number of frequencies that will be
  97. * computed.
  98. */
  99. void SetNumberOfFrequencies(const int& nfreq);
  100. /**
  101. * Sets the current in the loop, default is 0
  102. * @param[in] amp is the current in the loop, in Amperes
  103. */
  104. void SetCurrent(const Real &amp);
  105. // ==================== INQUIRY =======================
  106. /**
  107. * Returns the number of turns
  108. * @return the number of turns of the loop.
  109. */
  110. int GetNumberOfTurns( );
  111. /**
  112. * Returns all of the points
  113. */
  114. Vector3Xr GetPoints();
  115. /**
  116. * Returns all of the points in a general matrix, useful for python wrapper
  117. */
  118. MatrixXr GetPointsMat();
  119. /**
  120. * Returns the frequency in the loop.
  121. * @return is the frequency in the loop in Hz
  122. */
  123. Real GetFrequency(const int& ifreq);
  124. /**
  125. * Returns the current in the loop.
  126. * @return is the Current
  127. */
  128. Real GetCurrent( );
  129. /**
  130. * Returns pointer to a dipole source
  131. */
  132. std::shared_ptr<DipoleSource> GetDipoleSource(const int &dip);
  133. /**
  134. * returns number of dipoles used to approximate this
  135. * loop
  136. */
  137. size_t GetNumberOfDipoles();
  138. /**
  139. * @return the number of frequencies of this wire loop.
  140. */
  141. int GetNumberOfFrequencies();
  142. #ifdef LEMMAUSEVTK
  143. /** Returns an actor that can be placed into a vtk scene easily
  144. * Note that this function throws a pointer, it is the
  145. * receivers job to manage this memory!
  146. */
  147. vtkActor* GetVtkActor(const int &idip);
  148. #endif
  149. /** Returns true or false if loop is horizontally planar
  150. */
  151. bool IsHorizontallyPlanar();
  152. /** Returns the name of the underlying class, similiar to Python's type */
  153. virtual std::string GetName() const;
  154. protected:
  155. // ==================== DATA MEMBERS =======================
  156. /**
  157. * Number of points that define the loop
  158. */
  159. int NumberOfPoints;
  160. /**
  161. * Current in antennae (Amps)
  162. */
  163. Real Current;
  164. /**
  165. * Number of turns
  166. */
  167. int NumberOfTurns;
  168. /**
  169. * List of the dipoles
  170. */
  171. std::vector< std::shared_ptr<DipoleSource> > Dipoles;
  172. /**
  173. * Points that define this loop
  174. */
  175. Vector3Xr Points;
  176. /**
  177. * Frequencies of the loop.
  178. */
  179. VectorXr Freqs;
  180. private:
  181. static constexpr auto CName = "WireAntenna";
  182. }; // ----- end of class WireAntenna -----
  183. }
  184. #endif // __WIREANTENNA_H