Main Lemma Repository
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

kernelem1dmanager.cpp 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 $Id: kernelem1dmanager.cpp 193 2014-11-10 23:51:41Z tirons $
  10. **/
  11. #include "kernelem1dmanager.h"
  12. namespace Lemma {
  13. std::ostream &operator<<(std::ostream &stream,
  14. const KernelEM1DManager &ob) {
  15. stream << *(LemmaObject*)(&ob);
  16. return stream;
  17. }
  18. // ==================== LIFECYCLE =======================
  19. KernelEM1DManager::KernelEM1DManager(const std::string& name) :
  20. LemmaObject(name), TEReflBase(NULL), TMReflBase(NULL), Earth(NULL), Dipole(NULL) {
  21. }
  22. KernelEM1DManager::~KernelEM1DManager() {
  23. if (this->NumberOfReferences != 0)
  24. throw DeleteObjectWithReferences(this);
  25. // if (Earth != NULL) {
  26. // Earth->DetachFrom(this);
  27. // }
  28. //
  29. // if (Dipole != NULL) {
  30. // Dipole->DetachFrom(this);
  31. // }
  32. for (unsigned int ik=0; ik<KernelVec.size(); ++ik) {
  33. KernelVec[ik]->Delete();
  34. }
  35. if (TEReflBase != NULL) TEReflBase->Delete();
  36. if (TMReflBase != NULL) TMReflBase->Delete();
  37. }
  38. KernelEM1DManager* KernelEM1DManager::New() {
  39. KernelEM1DManager* Obj = new KernelEM1DManager("KernelEM1DManager");
  40. Obj->AttachTo(Obj);
  41. return Obj;
  42. }
  43. void KernelEM1DManager::Delete() {
  44. this->DetachFrom(this);
  45. }
  46. void KernelEM1DManager::Release() {
  47. delete this;
  48. }
  49. // ==================== ACCESS =======================
  50. // A race condition can develop with these. It's OK to not attach, since this is an internal class, and
  51. // we know what is going on.
  52. void KernelEM1DManager::SetEarth(LayeredEarthEM* Earthin) {
  53. //if (Earth != NULL) {
  54. // Earth->DetachFrom(this);
  55. //}
  56. //Earthin->AttachTo(this);
  57. Earth = Earthin;
  58. }
  59. void KernelEM1DManager::SetDipoleSource(DipoleSource* DipoleIn, const int& ifreqin,
  60. const Real& rx_zin) {
  61. //if (Dipole != NULL) {
  62. // Dipole->DetachFrom(this);
  63. //}
  64. //DipoleIn->AttachTo(this);
  65. Dipole = DipoleIn;
  66. ifreq = ifreqin;
  67. rx_z = rx_zin;
  68. }
  69. KernelEm1DBase* KernelEM1DManager::GetKernel(const unsigned int& ik) {
  70. return KernelVec[ik];
  71. }
  72. DipoleSource* KernelEM1DManager::GetDipole( ) {
  73. return Dipole;
  74. }
  75. // ==================== OPERATIONS =======================
  76. void KernelEM1DManager::ComputeReflectionCoeffs(const Real& lambda, const int& idx, const Real& rho0) {
  77. if (TEReflBase != NULL) {
  78. TEReflBase->ComputeReflectionCoeffs(lambda);
  79. TEReflBase->PreComputePotentialTerms( );
  80. }
  81. if (TMReflBase != NULL) {
  82. TMReflBase->ComputeReflectionCoeffs(lambda);
  83. TMReflBase->PreComputePotentialTerms( );
  84. }
  85. }
  86. void KernelEM1DManager::ResetSource(const int& ifreq) {
  87. if (TEReflBase != NULL) {
  88. TEReflBase->SetUpSource(Dipole, ifreq);
  89. }
  90. if (TMReflBase != NULL) {
  91. TMReflBase->SetUpSource(Dipole, ifreq);
  92. }
  93. }
  94. } // ----- end of Lemma name -----