Main Lemma Repository
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

KernelEM1DManager.h 7.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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 06/26/2012
  9. @version 0.0
  10. **/
  11. #ifndef KERNELEM1DMANAGER_INC
  12. #define KERNELEM1DMANAGER_INC
  13. #include "KernelEM1DBase.h"
  14. #include "KernelEM1DSpec.h"
  15. namespace Lemma {
  16. class DipoleSource;
  17. class KernelEM1DReflBase;
  18. // ===================================================================
  19. // Class: KernelEM1DManager
  20. /**
  21. @class
  22. \brief
  23. \details
  24. */
  25. // ===================================================================
  26. class KernelEM1DManager : public LemmaObject {
  27. /** Recursively streams information about this class */
  28. friend std::ostream &operator<<(std::ostream &stream, const KernelEM1DManager &ob);
  29. public:
  30. // ==================== LIFECYCLE =======================
  31. /** Default protected constructor. */
  32. KernelEM1DManager ( const ctor_key& );
  33. /** Default protected constructor. */
  34. ~KernelEM1DManager ();
  35. /** Returns a pointer to a new object of type KernelEM1DManager.
  36. * It allocates all necessary memory.
  37. */
  38. static std::shared_ptr<KernelEM1DManager> NewSP();
  39. // ==================== OPERATORS =======================
  40. // ==================== OPERATIONS =======================
  41. template<EMMODE Mode, int Ikernel, DIPOLE_LOCATION Isource, DIPOLE_LOCATION Irecv>
  42. int AddKernel( );
  43. /*
  44. {
  45. KernelEM1DSpec<Mode, Ikernel, Isource, Irecv>* NewKern =
  46. KernelEM1DSpec<Mode, Ikernel, Isource, Irecv>::New();
  47. KernelVec.push_back( NewKern );
  48. NewKern->managerIdx = KernelVec.size()-1;
  49. switch (Mode) {
  50. case TE:
  51. if (TEReflBase == NULL) {
  52. TEReflBase = KernelEM1DReflSpec<TE, Isource, Irecv>::New();
  53. TEReflBase->Initialise(Earth);
  54. TEReflBase->SetUpSource(Dipole, ifreq);
  55. TEReflBase->SetUpReceiver( rx_z );
  56. }
  57. NewKern->SetReflBase(TEReflBase);
  58. break;
  59. case TM:
  60. if (TMReflBase == NULL) {
  61. TMReflBase = KernelEM1DReflSpec<TM, Isource, Irecv>::New();
  62. TMReflBase->Initialise(Earth);
  63. TMReflBase->SetUpSource(Dipole, ifreq);
  64. TMReflBase->SetUpReceiver( rx_z );
  65. }
  66. NewKern->SetReflBase(TMReflBase);
  67. break;
  68. }
  69. return static_cast<int>(KernelVec.size()-1);
  70. }
  71. */
  72. void ResetSource(const int& ifreq);
  73. /** For use in related Kernel calculations. This function calles
  74. * ComputeReflectionCoeffs on TEReflBase and TMReflBase, if they
  75. * exist. After this has been called, KernelEM1DBase::RelBesselArg() may be safely
  76. * called. This method stores solutions of the same idx. rho0 is the intial lambda argument
  77. */
  78. void ComputeReflectionCoeffs(const Real& lambda, const int& idx, const Real& rho0);
  79. /** Clears the vector of kernels */
  80. void ClearVec() {
  81. KernelVec.clear();
  82. }
  83. // ==================== ACCESS =======================
  84. /** Sets the LayeredEarthEM class that will be used by the kernels.
  85. */
  86. void SetEarth( std::shared_ptr<LayeredEarthEM> Earth);
  87. /** Sets the source of the kernels */
  88. void SetDipoleSource( DipoleSource* Dipole, const int& ifreq, const Real& rx_zin);
  89. /** Returns pointer to specified kernel indice. Indices are assigned in the same
  90. order as they are created by AddKernel.
  91. */
  92. std::shared_ptr<KernelEM1DBase> GetKernel(const unsigned int& ik);
  93. /** Returns RAW pointer to specified kernel indice. Indices are assigned in the same
  94. order as they are created by AddKernel.
  95. */
  96. KernelEM1DBase* GetRAWKernel(const unsigned int& ik);
  97. /** Returns pointer to connected dipole.
  98. */
  99. DipoleSource* GetDipole( );
  100. inline std::vector< std::shared_ptr<KernelEM1DBase> > GetSTLVector() {
  101. return KernelVec;
  102. }
  103. // ==================== INQUIRY =======================
  104. /** Returns the name of the underlying class, similiar to Python's type */
  105. virtual inline std::string GetName() const ;
  106. protected:
  107. // ==================== LIFECYCLE =======================
  108. // ==================== DATA MEMBERS =========================
  109. /** List of KernelEm1D instances */
  110. std::vector< std::shared_ptr<KernelEM1DBase> > KernelVec;
  111. /** Reflection base used for TE mode */
  112. std::shared_ptr<KernelEM1DReflBase> TEReflBase = nullptr;
  113. /** Reflection base used for TM mode */
  114. std::shared_ptr<KernelEM1DReflBase> TMReflBase = nullptr;
  115. /** EmEarth Class */
  116. std::shared_ptr<LayeredEarthEM> Earth;
  117. /** EM dipole souce */
  118. DipoleSource* Dipole;
  119. /** Frequency index for the sources */
  120. int ifreq;
  121. /** Receiver height */
  122. Real rx_z;
  123. private:
  124. static constexpr auto CName = "KernelEM1DManager";
  125. }; // ----- end of class KernelEM1DManager -----
  126. // template methods
  127. template<EMMODE Mode, int Ikernel, DIPOLE_LOCATION Isource, DIPOLE_LOCATION Irecv>
  128. int KernelEM1DManager::AddKernel( ) {
  129. auto NewKern = KernelEM1DSpec<Mode, Ikernel, Isource, Irecv>::NewSP();
  130. NewKern->managerIdx = KernelVec.size();
  131. switch (Mode) {
  132. case TE:
  133. if (TEReflBase == nullptr) {
  134. TEReflBase = KernelEM1DReflSpec<TE, Isource, Irecv>::NewSP();
  135. TEReflBase->Initialise(Earth);
  136. TEReflBase->SetUpSource(Dipole, ifreq);
  137. TEReflBase->SetUpReceiver( rx_z );
  138. }
  139. NewKern->SetReflBase(TEReflBase);
  140. break;
  141. case TM:
  142. if (TMReflBase == nullptr) {
  143. TMReflBase = KernelEM1DReflSpec<TM, Isource, Irecv>::NewSP();
  144. TMReflBase->Initialise(Earth);
  145. TMReflBase->SetUpSource(Dipole, ifreq);
  146. TMReflBase->SetUpReceiver( rx_z );
  147. }
  148. NewKern->SetReflBase(TMReflBase);
  149. break;
  150. }
  151. KernelVec.push_back( std::move(NewKern) );
  152. return static_cast<int>(KernelVec.size()-1);
  153. }
  154. // /** Clears the vector of kernels */
  155. // void ClearVec() {
  156. // for (unsigned int ik=0; ik<this->KernelVec.size(); ++ik) {
  157. // this->KernelVec[ik]->Delete();
  158. // }
  159. // KernelVec.clear();
  160. // }
  161. } // ----- end of Lemma name -----
  162. #endif // ----- #ifndef KERNELEM1DMANAGER_INC -----