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

KernelEM1DManager.h 7.7KB

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