Main Lemma Repository
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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. @version $Id: emearth1d.h 266 2015-04-01 03:24:00Z tirons $
  10. **/
  11. #ifndef __EMEARTH1D_H
  12. #define __EMEARTH1D_H
  13. // forward declare these due to include cycle
  14. //#include "LayeredEarthEM.h"
  15. //#include "DipoleSource.h"
  16. //#include "FieldPoints.h"
  17. //#include "WireAntenna.h"
  18. //#include "PolygonalWireAntenna.h"
  19. //#include "KernelEM1DManager.h"
  20. #include "KernelEM1DSpec.h"
  21. #include "hankeltransformgaussianquadrature.h"
  22. #include "hankeltransformhankel2.h"
  23. #include "FHTKey.h"
  24. #include "FHTKey51.h"
  25. #include "FHTKey101.h"
  26. #include "QWEKey.h"
  27. #include "CubicSplineInterpolator.h"
  28. #ifdef HAVEBOOSTPROGRESS
  29. #include "boost/progress.hpp"
  30. #endif
  31. namespace Lemma {
  32. class WireAntenna;
  33. class PolygonalWireAntenna;
  34. class FieldPoints;
  35. class DipoleSource;
  36. class LayeredEarthEM;
  37. // =======================================================================
  38. // Class: EmEarth1D
  39. /// \brief Implimentation of 1D EM solution.
  40. /// \details We've done a lot of different things.
  41. // =======================================================================
  42. class EMEarth1D : public LemmaObject {
  43. friend std::ostream &operator<<(std::ostream &stream,
  44. const EMEarth1D &ob);
  45. struct ctor_key{};
  46. public:
  47. //friend class KernelEm1D;
  48. // ==================== LIFECYCLE ===========================
  49. /** Default protected constructor. */
  50. EMEarth1D ( const ctor_key& );
  51. /** Default protected constructor. */
  52. EMEarth1D ( const YAML::Node& node, const ctor_key& );
  53. /** Default protected constructor. */
  54. ~EMEarth1D ();
  55. /**
  56. * Returns pointer to new EMEarth1D. Location is
  57. * initialized to (0,0,0) type and polarization are
  58. * initialized to nonworking values that will throw
  59. * exceptions if used.
  60. */
  61. static std::shared_ptr<EMEarth1D> NewSP();
  62. /** stream debugging info to std::out
  63. */
  64. void Query();
  65. /** YAML Serializing method
  66. */
  67. YAML::Node Serialize() const;
  68. //static EMEarth1D* DeSerialize(const YAML::Node& node);
  69. // ==================== OPERATORS ===========================
  70. // ==================== OPERATIONS ===========================
  71. /// Calculates the field(s) due to an ungrounded dipole source
  72. /// Calls FORTRAN library em1d (em1dnew.for)
  73. #ifdef COMPILE_FORTRAN
  74. void MakeCalc();
  75. #endif
  76. /** C++ wrapper for em1dnew.for, serial */
  77. void MakeCalc3();
  78. /** Calculates the field(s) due to a wire antennae */
  79. void CalculateWireAntennaFields(bool progressbar=false);
  80. // ==================== ACCESS ===========================
  81. /** Attaches an antennae */
  82. void AttachWireAntenna(WireAntenna *antennae);
  83. /** Attaches a dipole for calculation */
  84. void AttachDipoleSource( std::shared_ptr<DipoleSource> dipole);
  85. /** Attaches a layered earth model for calculation */
  86. void AttachLayeredEarthEM( std::shared_ptr<LayeredEarthEM> Earth);
  87. /** Attaches a set of receiver points for calculation */
  88. void AttachFieldPoints( std::shared_ptr<FieldPoints> Receivers);
  89. /** Sets the fields that are calcultated, E,H or BOTH */
  90. void SetFieldsToCalculate(const FIELDCALCULATIONS &calc);
  91. /** Sets the method to use to evaluate the Hankel integral,
  92. */
  93. void SetHankelTransformMethod(const HANKELTRANSFORMTYPE &type);
  94. // ==================== INQUIRY ===========================
  95. protected:
  96. // ==================== OPERATIONS ===========================
  97. /** Used internally, this is the innermost loop of the MakeCalc3,
  98. * and CalculateWireAntennaField routines.
  99. */
  100. void SolveSingleTxRxPair(const int &irec,
  101. std::shared_ptr<HankelTransform> Hankel,
  102. const Real &wavef, const int &ifreq,
  103. std::shared_ptr<DipoleSource> tDipole);
  104. /** Used internally, this is the innermost loop of the MakeCalc3,
  105. * and CalculateWireAntennaField routines.
  106. */
  107. void SolveLaggedTxRxPair(const int &irec, std::shared_ptr<Hankel2> Hankel,
  108. const Real &wavef, const int &ifreq,
  109. std::shared_ptr<PolygonalWireAntenna> antenna);
  110. /** Removes all connections */
  111. void DetachAll();
  112. // ==================== DATA MEMBERS ===========================
  113. /** Computes field due to dipole */
  114. std::shared_ptr<DipoleSource> Dipole;
  115. /** Earth model (Cole-cole) */
  116. std::shared_ptr<LayeredEarthEM> Earth;
  117. /** Receiver points */
  118. std::shared_ptr<FieldPoints> Receivers;
  119. /** Wire antennae tx */
  120. std::shared_ptr<WireAntenna> Antenna;
  121. /** What fields are wanted */
  122. FIELDCALCULATIONS FieldsToCalculate;
  123. /** The type of Hankel transform to use, default to digital
  124. * filtering
  125. */
  126. HANKELTRANSFORMTYPE HankelType;
  127. /** Counter for number of caclulations made
  128. */
  129. int icalcinner;
  130. /** Counter for number of caclulations made
  131. */
  132. int icalc;
  133. }; // ----- end of class EMEarth1D -----
  134. /////////////////////////////////////////
  135. // Exception classes
  136. /** If a Receivers Class is NULL valued, throw this.
  137. */
  138. class NullReceivers : public std::runtime_error {
  139. /** Thrown when Receivers pointer is NULL
  140. */
  141. public: NullReceivers();
  142. };
  143. /** If an Antenna is NULL valued, throw this error.
  144. */
  145. class NullAntenna : public std::runtime_error {
  146. /** Thrown when an antenna pointer is NULL
  147. */
  148. public: NullAntenna();
  149. };
  150. /** If an Instrument is NULL valued, throw this error.
  151. */
  152. class NullInstrument : public std::runtime_error {
  153. /** thrown when an instrument pointer is NULL.
  154. * @param[in] ptr is a pointer to the class throwing the exception.
  155. */
  156. public: NullInstrument(LemmaObject* ptr);
  157. };
  158. /** If a dipole source is specified, but a method calling a wire antenna is
  159. * called, throw this.
  160. */
  161. class DipoleSourceSpecifiedForWireAntennaCalc : public std::runtime_error {
  162. /** Thrown when a dipole source is specified when a wire antenna is
  163. * expected
  164. */
  165. public: DipoleSourceSpecifiedForWireAntennaCalc();
  166. };
  167. } // Namespace Lemma
  168. #endif // __EMEARTH1D_H