Lemma is an Electromagnetics API
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

KernelEM1DManager.h 7.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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( std::shared_ptr<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 pointer to connected dipole.
  95. */
  96. std::shared_ptr<DipoleSource> GetDipole( );
  97. inline std::vector< std::shared_ptr<KernelEm1DBase> > GetSTLVector() {
  98. return KernelVec;
  99. }
  100. // ==================== INQUIRY =======================
  101. /** Returns the name of the underlying class, similiar to Python's type */
  102. virtual inline std::string GetName() const {
  103. return CName;
  104. }
  105. protected:
  106. // ==================== LIFECYCLE =======================
  107. // ==================== DATA MEMBERS =========================
  108. /** List of KernelEm1D instances */
  109. std::vector< std::shared_ptr<KernelEm1DBase> > KernelVec;
  110. /** Reflection base used for TE mode */
  111. std::shared_ptr<KernelEM1DReflBase> TEReflBase;
  112. /** Reflection base used for TM mode */
  113. std::shared_ptr<KernelEM1DReflBase> TMReflBase;
  114. /** EmEarth Class */
  115. std::shared_ptr<LayeredEarthEM> Earth;
  116. /** EM dipole souce */
  117. std::shared_ptr<DipoleSource> Dipole;
  118. /** Frequency index for the sources */
  119. int ifreq;
  120. /** Receiver height */
  121. Real rx_z;
  122. private:
  123. static constexpr auto CName = "KernelEM1DManager";
  124. }; // ----- end of class KernelEM1DManager -----
  125. // template methods
  126. template<EMMODE Mode, int Ikernel, DIPOLE_LOCATION Isource, DIPOLE_LOCATION Irecv>
  127. int KernelEM1DManager::AddKernel( ) {
  128. auto NewKern = KernelEM1DSpec<Mode, Ikernel, Isource, Irecv>::NewSP();
  129. KernelVec.push_back( NewKern );
  130. NewKern->managerIdx = KernelVec.size()-1;
  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. return static_cast<int>(KernelVec.size()-1);
  152. }
  153. // /** Clears the vector of kernels */
  154. // void ClearVec() {
  155. // for (unsigned int ik=0; ik<this->KernelVec.size(); ++ik) {
  156. // this->KernelVec[ik]->Delete();
  157. // }
  158. // KernelVec.clear();
  159. // }
  160. } // ----- end of Lemma name -----
  161. #endif // ----- #ifndef KERNELEM1DMANAGER_INC -----