Lemma is an Electromagnetics API
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

KernelEM1DManager.h 7.5KB

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 "dipolesource.h"
  14. //#include "kernelem1dreflbase.h"
  15. #include "kernelem1dbase.h"
  16. #include "KernelEM1DSpec.h"
  17. namespace Lemma {
  18. class DipoleSource;
  19. class KernelEM1DReflBase;
  20. // ===================================================================
  21. // Class: KernelEM1DManager
  22. /**
  23. @class
  24. \brief
  25. \details
  26. */
  27. // ===================================================================
  28. class KernelEM1DManager : public LemmaObject {
  29. struct ctor_key {};
  30. friend std::ostream &operator<<(std::ostream &stream, const KernelEM1DManager &ob);
  31. public:
  32. // ==================== LIFECYCLE =======================
  33. /** Default protected constructor. */
  34. KernelEM1DManager (const std::string& name);
  35. /** Default protected constructor. */
  36. ~KernelEM1DManager ();
  37. /** Returns a pointer to a new object of type KernelEM1DManager.
  38. * It allocates all necessary memory.
  39. */
  40. static std::shared_ptr<KernelEM1DManager> NewSP();
  41. // ==================== OPERATORS =======================
  42. // ==================== OPERATIONS =======================
  43. template<EMMODE Mode, int Ikernel, DIPOLE_LOCATION Isource, DIPOLE_LOCATION Irecv>
  44. int AddKernel( );
  45. /*
  46. {
  47. KernelEM1DSpec<Mode, Ikernel, Isource, Irecv>* NewKern =
  48. KernelEM1DSpec<Mode, Ikernel, Isource, Irecv>::New();
  49. KernelVec.push_back( NewKern );
  50. NewKern->managerIdx = KernelVec.size()-1;
  51. switch (Mode) {
  52. case TE:
  53. if (TEReflBase == NULL) {
  54. TEReflBase = KernelEM1DReflSpec<TE, Isource, Irecv>::New();
  55. TEReflBase->Initialise(Earth);
  56. TEReflBase->SetUpSource(Dipole, ifreq);
  57. TEReflBase->SetUpReceiver( rx_z );
  58. }
  59. NewKern->SetReflBase(TEReflBase);
  60. break;
  61. case TM:
  62. if (TMReflBase == NULL) {
  63. TMReflBase = KernelEM1DReflSpec<TM, Isource, Irecv>::New();
  64. TMReflBase->Initialise(Earth);
  65. TMReflBase->SetUpSource(Dipole, ifreq);
  66. TMReflBase->SetUpReceiver( rx_z );
  67. }
  68. NewKern->SetReflBase(TMReflBase);
  69. break;
  70. }
  71. return static_cast<int>(KernelVec.size()-1);
  72. }
  73. */
  74. void ResetSource(const int& ifreq);
  75. /** For use in related Kernel calculations. This function calles
  76. * ComputeReflectionCoeffs on TEReflBase and TMReflBase, if they
  77. * exist. After this has been called, KernelEM1DBase::RelBesselArg() may be safely
  78. * called. This method stores solutions of the same idx. rho0 is the intial lambda argument
  79. */
  80. void ComputeReflectionCoeffs(const Real& lambda, const int& idx, const Real& rho0);
  81. /** Clears the vector of kernels */
  82. void ClearVec() {
  83. KernelVec.clear();
  84. }
  85. // ==================== ACCESS =======================
  86. /** Sets the LayeredEarthEM class that will be used by the kernels.
  87. */
  88. void SetEarth( std::shared_ptr<LayeredEarthEM> Earth);
  89. /** Sets the source of the kernels */
  90. void SetDipoleSource( std::shared_ptr<DipoleSource> Dipole, const int& ifreq, const Real& rx_zin);
  91. /** Returns pointer to specified kernel indice. Indices are assigned in the same
  92. order as they are created by AddKernel.
  93. */
  94. std::shared_ptr<KernelEm1DBase> GetKernel(const unsigned int& ik);
  95. /** Returns pointer to connected dipole.
  96. */
  97. std::shared_ptr<DipoleSource> GetDipole( );
  98. inline std::vector< std::shared_ptr<KernelEm1DBase> > GetSTLVector() {
  99. return KernelVec;
  100. }
  101. // ==================== INQUIRY =======================
  102. /** Returns the name of the underlying class, similiar to Python's type */
  103. virtual inline std::string GetName() const {
  104. return CName;
  105. }
  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;
  113. /** Reflection base used for TM mode */
  114. std::shared_ptr<KernelEM1DReflBase> TMReflBase;
  115. /** EmEarth Class */
  116. std::shared_ptr<LayeredEarthEM> Earth;
  117. /** EM dipole souce */
  118. std::shared_ptr<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. KernelVec.push_back( NewKern );
  131. NewKern->managerIdx = KernelVec.size()-1;
  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. 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 -----