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

PolygonalWireAntenna.h 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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 05/18/2010
  9. **/
  10. #ifndef POLYGONALWIREANTENNA_INC
  11. #define POLYGONALWIREANTENNA_INC
  12. #include "DipoleSource.h"
  13. #include "WireAntenna.h"
  14. namespace Lemma {
  15. // ===================================================================
  16. // Class: PolygonalWireAntenna
  17. /// \ingroup FDEM1D
  18. /// \brief Class representing polygonal wire antennae.
  19. /// \details For EM calculations, dipoles representing this loop are
  20. /// created dynamically, depending on receiver location.
  21. /// @todo enforce minimum dipole moment.
  22. // ===================================================================
  23. class PolygonalWireAntenna : public WireAntenna {
  24. friend std::ostream &operator << (std::ostream &stream, const PolygonalWireAntenna &ob);
  25. public:
  26. // ==================== LIFECYCLE =======================
  27. /// Default protected constructor.
  28. explicit PolygonalWireAntenna ( const ctor_key& );
  29. /// Default protected constructor.
  30. PolygonalWireAntenna (const YAML::Node& node, const ctor_key& );
  31. /// Default protected constructor.
  32. virtual ~PolygonalWireAntenna ();
  33. /**
  34. * Declares all memory and returns a new instance.
  35. */
  36. static std::shared_ptr<PolygonalWireAntenna> NewSP();
  37. /// Makes a deep copy of this antenna with all connections except
  38. /// the dipole approximation.
  39. virtual std::shared_ptr<WireAntenna> Clone() const ;
  40. /// Makes a deep copy of this antenna with all connections except
  41. /// the dipole approximation.
  42. virtual std::shared_ptr<PolygonalWireAntenna> ClonePA() const ;
  43. /**
  44. * Uses YAML to serialize this object.
  45. * @return a YAML::Node
  46. */
  47. YAML::Node Serialize() const;
  48. /**
  49. * Constructs an object from a YAML::Node.
  50. */
  51. static std::shared_ptr<PolygonalWireAntenna> DeSerialize(const YAML::Node& node);
  52. /**
  53. * Constructs an object from a string representation of a YAML::Node. This is primarily
  54. * used in Python wrapping
  55. */
  56. static std::shared_ptr<PolygonalWireAntenna> DeSerialize( const std::string& node ) {
  57. return PolygonalWireAntenna::DeSerialize(YAML::LoadFile(node));
  58. }
  59. // ==================== OPERATORS =======================
  60. // ==================== OPERATIONS =======================
  61. /// Approximates with ungrounded electrical dipoles, such that
  62. /// minDipoleRatio is satisfied.
  63. virtual void ApproximateWithElectricDipoles(const Vector3r &rp);
  64. /** Sets the minimum ratio for dipole moments to be used to
  65. * approximate the loop. A smaller ratio yields a more accurate
  66. * result, but is more expensive. Default is (1/5).
  67. */
  68. void SetMinDipoleRatio(const Real& ratio);
  69. /** Sets the minimum moment for dipole moments to be used to
  70. * approximate the loop.
  71. */
  72. void SetMinDipoleMoment(const Real& m);
  73. /** Sets the minimum moment for dipole moments to be used to
  74. * approximate the loop.
  75. */
  76. void SetMaxDipoleMoment(const Real& m);
  77. // ==================== ACCESS =======================
  78. // ==================== INQUIRY =======================
  79. /** Returns the name of the underlying class, similiar to Python's type */
  80. virtual std::string GetName() const ;
  81. protected:
  82. // ==================== DATA MEMBERS =======================
  83. /// minimum ratio of dipole moment to distance to receiver point
  84. Real minDipoleRatio;
  85. /// Maximum dipole moment allowed
  86. Real minDipoleMoment;
  87. /// Maximum dipole moment allowed
  88. Real maxDipoleMoment;
  89. /// appends
  90. void PushXYZDipoles( const Vector3r &step, const Vector3r &cp,
  91. const Vector3r &dir,
  92. std::vector< std::shared_ptr<DipoleSource> > &Dipoles) ;
  93. /// corrects for overstep
  94. void CorrectOverstepXYZDipoles( const Vector3r &step,
  95. const Vector3r &cp,
  96. const Vector3r &dir,
  97. std::vector< std::shared_ptr<DipoleSource> > &Dipoles );
  98. // ==================== OPERATIONS =======================
  99. /// Returns the nearest point on a line segment to another point.
  100. /// if the point is not on the line-segment, return the
  101. /// nearest end-point
  102. /// @param[in] p0, p1 define the line segement
  103. /// @param[in] rp is a point in space. The function returns the
  104. /// closest point on the line to this point.
  105. /// @return The point (Lemma::Vector3r) on the line defined by p0,
  106. /// and p1, closest to rp
  107. Vector3r ClosestPointOnLine(const Vector3r &p0, const Vector3r &p1,
  108. const Vector3r &rp);
  109. /// Interpolates dipoles along line segment defined by p0 and p1.
  110. void InterpolateLineSegment(const Vector3r &p0, const Vector3r &p1, const Vector3r &rp,
  111. std::vector< std::shared_ptr<DipoleSource> > &Dipoles );
  112. private:
  113. Vector3r rRepeat;
  114. static constexpr auto CName = "PolygonalWireAntenna";
  115. }; // ----- end of class PolygonalWireAntenna -----
  116. } // ----- end of Lemma name -----
  117. #endif // ----- #ifndef POLYGONALWIREANTENNA_INC -----