Main Lemma Repository
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

EMEarth1D.h 8.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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. **/
  10. #ifndef __EMEARTH1D_H
  11. #define __EMEARTH1D_H
  12. // forward declare these due to include cycle
  13. //#include "LayeredEarthEM.h"
  14. //#include "DipoleSource.h"
  15. //#include "FieldPoints.h"
  16. //#include "WireAntenna.h"
  17. //#include "PolygonalWireAntenna.h"
  18. //#include "KernelEM1DManager.h"
  19. #include "KernelEM1DSpec.h"
  20. #include "HankelTransformFactory.h"
  21. #include "GQChave.h"
  22. #include "FHTAnderson801.h"
  23. #include "FHTKey201.h"
  24. #include "FHTKey101.h"
  25. #include "FHTKey51.h"
  26. #include "QWEKey.h"
  27. #include "CubicSplineInterpolator.h"
  28. #ifdef HAVE_BOOST_PROGRESS
  29. #include "boost/progress.hpp"
  30. #endif
  31. namespace Lemma {
  32. enum TXRXMODE { TX, RX, TXRX, NOMODE };
  33. class WireAntenna;
  34. class PolygonalWireAntenna;
  35. class FieldPoints;
  36. class DipoleSource;
  37. class LayeredEarthEM;
  38. // =======================================================================
  39. // Class: EmEarth1D
  40. /// \ingroup FDEM1D
  41. /// \brief Implimentation of 1D EM solution.
  42. /// \details We've done a lot of different things.
  43. // =======================================================================
  44. class EMEarth1D : public LemmaObject {
  45. friend std::ostream &operator<<(std::ostream &stream,
  46. const EMEarth1D &ob);
  47. public:
  48. //friend class KernelEm1D;
  49. // ==================== LIFECYCLE ===========================
  50. /** Default protected constructor. */
  51. explicit EMEarth1D ( const ctor_key& );
  52. /** Default protected constructor. */
  53. EMEarth1D ( const YAML::Node& node, const ctor_key& );
  54. /** Default protected constructor. */
  55. ~EMEarth1D ();
  56. /**
  57. * Returns pointer to new EMEarth1D. Location is
  58. * initialized to (0,0,0) type and polarization are
  59. * initialized to nonworking values that will throw
  60. * exceptions if used.
  61. */
  62. static std::shared_ptr<EMEarth1D> NewSP();
  63. /** stream debugging info to std::out
  64. */
  65. void Query();
  66. /** YAML Serializing method
  67. */
  68. YAML::Node Serialize() const;
  69. //static EMEarth1D* DeSerialize(const YAML::Node& node);
  70. // ==================== OPERATORS ===========================
  71. // ==================== OPERATIONS ===========================
  72. /// Calculates the field(s) due to an ungrounded dipole source
  73. /// Calls FORTRAN library em1d (em1dnew.for)
  74. #ifdef KIHALEE_EM1D
  75. void MakeCalc();
  76. #endif
  77. /** C++ wrapper for em1dnew.for, serial */
  78. void MakeCalc3();
  79. /** Calculates the field(s) due to a wire antennae */
  80. void CalculateWireAntennaFields(bool progressbar=false);
  81. // ==================== ACCESS ===========================
  82. /** Attaches an antennae */
  83. void AttachWireAntenna( std::shared_ptr<WireAntenna> antennae);
  84. /** Attaches a dipole for calculation */
  85. void AttachDipoleSource( std::shared_ptr<DipoleSource> dipole);
  86. /** Attaches a layered earth model for calculation */
  87. void AttachLayeredEarthEM( std::shared_ptr<LayeredEarthEM> Earth);
  88. /** Attaches a set of receiver points for calculation */
  89. void AttachFieldPoints( std::shared_ptr<FieldPoints> Receivers);
  90. /** Sets the fields that are calcultated, E,H or BOTH */
  91. void SetFieldsToCalculate(const FIELDCALCULATIONS &calc);
  92. /** Sets the method to use to evaluate the Hankel integral,
  93. */
  94. void SetHankelTransformMethod(const HANKELTRANSFORMTYPE &type);
  95. /**
  96. * Accesor for field points
  97. */
  98. inline FieldPoints* GetFieldPoints() {
  99. return this->Receivers.get();
  100. }
  101. /**
  102. * Sets the Mode enum tag.
  103. */
  104. void SetTxRxMode( const TXRXMODE& ModeSet ) {
  105. this->Mode = ModeSet;
  106. }
  107. // ==================== INQUIRY ===========================
  108. /**
  109. * Returns the name of the underlying class, similiar to Python's type
  110. * @return string of class name
  111. */
  112. virtual std::string GetName() const;
  113. /**
  114. * Returns the Mode enum tag.
  115. */
  116. inline TXRXMODE GetTxRxMode() const {
  117. return Mode;
  118. }
  119. protected:
  120. // ==================== OPERATIONS ===========================
  121. /** Used internally, this is the innermost loop of the MakeCalc3,
  122. * and CalculateWireAntennaField routines.
  123. */
  124. void SolveSingleTxRxPair(const int &irec,
  125. HankelTransform* Hankel,
  126. const Real &wavef, const int &ifreq,
  127. DipoleSource* tDipole);
  128. // void SolveSingleTxRxPair(const int &irec,
  129. // std::shared_ptr<HankelTransform> Hankel,
  130. // const Real &wavef, const int &ifreq,
  131. // std::shared_ptr<DipoleSource> tDipole);
  132. /** Used internally, this is the innermost loop of the MakeCalc3,
  133. * and CalculateWireAntennaField routines.
  134. */
  135. void SolveLaggedTxRxPair(const int &irec, HankelTransform* Hankel,
  136. const Real &wavef, const int &ifreq,
  137. PolygonalWireAntenna* antenna);
  138. // ==================== DATA MEMBERS ===========================
  139. /** Computes field due to dipole */
  140. std::shared_ptr<DipoleSource> Dipole;
  141. /** Earth model (Cole-cole) */
  142. std::shared_ptr<LayeredEarthEM> Earth;
  143. /** Receiver points */
  144. std::shared_ptr<FieldPoints> Receivers;
  145. /** Wire antennae tx */
  146. std::shared_ptr<WireAntenna> Antenna;
  147. /** What fields are wanted */
  148. FIELDCALCULATIONS FieldsToCalculate;
  149. /** The type of Hankel transform to use, default to digital
  150. * filtering
  151. */
  152. HANKELTRANSFORMTYPE HankelType;
  153. /** Counter for number of caclulations made
  154. */
  155. int icalcinner;
  156. /** Counter for number of caclulations made
  157. */
  158. int icalc;
  159. /**
  160. * Convenience tag that can be used for marking whether these
  161. * fields are part of a transmit or receive array.
  162. */
  163. TXRXMODE Mode = NOMODE;
  164. /** ASCII string representation of the class name */
  165. static constexpr auto CName = "EMEarth1D";
  166. }; // ----- end of class EMEarth1D -----
  167. /////////////////////////////////////////
  168. // Exception classes
  169. /** If a Receivers Class is NULL valued, throw this.
  170. */
  171. class NullReceivers : public std::runtime_error {
  172. /** Thrown when Receivers pointer is NULL
  173. */
  174. public: NullReceivers();
  175. };
  176. /** If an Antenna is NULL valued, throw this error.
  177. */
  178. class NullAntenna : public std::runtime_error {
  179. /** Thrown when an antenna pointer is NULL
  180. */
  181. public: NullAntenna();
  182. };
  183. /** If an Instrument is NULL valued, throw this error.
  184. */
  185. class NullInstrument : public std::runtime_error {
  186. /** thrown when an instrument pointer is NULL.
  187. * @param[in] ptr is a pointer to the class throwing the exception.
  188. */
  189. public: NullInstrument(LemmaObject* ptr);
  190. };
  191. /** If a dipole source is specified, but a method calling a wire antenna is
  192. * called, throw this.
  193. */
  194. class DipoleSourceSpecifiedForWireAntennaCalc : public std::runtime_error {
  195. /** Thrown when a dipole source is specified when a wire antenna is
  196. * expected
  197. */
  198. public: DipoleSourceSpecifiedForWireAntennaCalc();
  199. };
  200. } // Namespace Lemma
  201. #endif // __EMEARTH1D_H