Lemma is an Electromagnetics API
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

kernelem1dmanager.h 7.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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. public:
  30. friend std::ostream &operator<<(std::ostream &stream,
  31. const KernelEM1DManager &ob);
  32. // ==================== LIFECYCLE =======================
  33. /** Returns a pointer to a new object of type KernelEM1DManager.
  34. * It allocates all necessary memory.
  35. */
  36. static KernelEM1DManager* New();
  37. /** Deletes this object. Delete also disconnects any
  38. * attachments to this object.
  39. */
  40. void Delete();
  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. for (unsigned int ik=0; ik<this->KernelVec.size(); ++ik) {
  84. this->KernelVec[ik]->Delete();
  85. }
  86. KernelVec.clear();
  87. }
  88. // ==================== ACCESS =======================
  89. /** Sets the LayeredEarthEM class that will be used by the kernels.
  90. */
  91. void SetEarth( LayeredEarthEM* Earth);
  92. /** Sets the source of the kernels */
  93. void SetDipoleSource( DipoleSource* Dipole, const int& ifreq, const Real& rx_zin);
  94. /** Returns pointer to specified kernel indice. Indices are assigned in the same
  95. order as they are created by AddKernel.
  96. */
  97. KernelEm1DBase* GetKernel(const unsigned int& ik);
  98. /** Returns pointer to connected dipole.
  99. */
  100. DipoleSource* GetDipole( );
  101. inline std::vector<KernelEm1DBase*> GetSTLVector() {
  102. return KernelVec;
  103. }
  104. // ==================== INQUIRY =======================
  105. protected:
  106. // ==================== LIFECYCLE =======================
  107. /** Default protected constructor. */
  108. KernelEM1DManager (const std::string& name);
  109. /** Default protected constructor. */
  110. ~KernelEM1DManager ();
  111. /**
  112. * @copybrief LemmaObject::Release()
  113. * @copydetails LemmaObject::Release()
  114. */
  115. void Release();
  116. // ==================== DATA MEMBERS =========================
  117. /** List of KernelEm1D instances */
  118. std::vector<KernelEm1DBase*> KernelVec;
  119. /** Reflection base used for TE mode */
  120. KernelEM1DReflBase* TEReflBase;
  121. /** Reflection base used for TM mode */
  122. KernelEM1DReflBase* TMReflBase;
  123. /** EmEarth Class */
  124. LayeredEarthEM* Earth;
  125. /** EM dipole souce */
  126. DipoleSource* Dipole;
  127. /** Frequency index for the sources */
  128. int ifreq;
  129. /** Receiver height */
  130. Real rx_z;
  131. private:
  132. }; // ----- end of class KernelEM1DManager -----
  133. // template methods
  134. template<EMMODE Mode, int Ikernel, DIPOLE_LOCATION Isource, DIPOLE_LOCATION Irecv>
  135. int KernelEM1DManager::AddKernel( ) {
  136. KernelEm1DSpec<Mode, Ikernel, Isource, Irecv>* NewKern =
  137. KernelEm1DSpec<Mode, Ikernel, Isource, Irecv>::New();
  138. KernelVec.push_back( NewKern );
  139. NewKern->managerIdx = KernelVec.size()-1;
  140. switch (Mode) {
  141. case TE:
  142. if (TEReflBase == NULL) {
  143. TEReflBase = KernelEM1DReflSpec<TE, Isource, Irecv>::New();
  144. TEReflBase->Initialise(Earth);
  145. TEReflBase->SetUpSource(Dipole, ifreq);
  146. TEReflBase->SetUpReceiver( rx_z );
  147. }
  148. NewKern->SetReflBase(TEReflBase);
  149. break;
  150. case TM:
  151. if (TMReflBase == NULL) {
  152. TMReflBase = KernelEM1DReflSpec<TM, Isource, Irecv>::New();
  153. TMReflBase->Initialise(Earth);
  154. TMReflBase->SetUpSource(Dipole, ifreq);
  155. TMReflBase->SetUpReceiver( rx_z );
  156. }
  157. NewKern->SetReflBase(TMReflBase);
  158. break;
  159. }
  160. return static_cast<int>(KernelVec.size()-1);
  161. }
  162. // /** Clears the vector of kernels */
  163. // void ClearVec() {
  164. // for (unsigned int ik=0; ik<this->KernelVec.size(); ++ik) {
  165. // this->KernelVec[ik]->Delete();
  166. // }
  167. // KernelVec.clear();
  168. // }
  169. } // ----- end of Lemma name -----
  170. #endif // ----- #ifndef KERNELEM1DMANAGER_INC -----