Lemma is an Electromagnetics API
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

temintegrationkernel.cpp 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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 M. Andy Kass
  8. @date 02/10/2011
  9. @version $Id: temintegrationkernel.cpp 266 2015-04-01 03:24:00Z tirons $
  10. **/
  11. #include "temintegrationkernel.h"
  12. namespace Lemma {
  13. //std::ostream &operator<<(std::ostream &stream,
  14. // const TemIntegrationKernel &ob) {
  15. //stream << *(IntegrationKernel<Real>*)(&ob);
  16. //return stream;
  17. //}
  18. // ======================= Lifecycle ==================================
  19. TemIntegrationKernel::TemIntegrationKernel(const std::string &name) :
  20. IntegrationKernel<Real>(name), component(ZCOMPONENT), EmEarthInt(NULL), Trans(NULL),
  21. DipoleS(NULL), Receivers(NULL) {
  22. }
  23. TemIntegrationKernel::~TemIntegrationKernel() {
  24. if (NumberOfReferences != 0) {
  25. throw DeleteObjectWithReferences(this);
  26. }
  27. }
  28. TemIntegrationKernel* TemIntegrationKernel::New() {
  29. TemIntegrationKernel* Obj = new TemIntegrationKernel("TemIntegrationKernel");
  30. Obj->AttachTo(Obj);
  31. return Obj;
  32. }
  33. void TemIntegrationKernel::Delete() {
  34. this->DetachFrom(this);
  35. if ( EmEarthInt != NULL ) {
  36. EmEarthInt->DetachFrom(this);
  37. }
  38. if (Trans != NULL) {
  39. Trans->DetachFrom(this);
  40. }
  41. if (DipoleS != NULL) {
  42. DipoleS->DetachFrom(this);
  43. }
  44. if (Receivers != NULL) {
  45. Receivers->DetachFrom(this);
  46. }
  47. }
  48. void TemIntegrationKernel::Release() {
  49. delete this;
  50. }
  51. Real TemIntegrationKernel::Argument(const Real& w, const int& iRelated) {
  52. // Finally, the meat of things!
  53. // You can't beat the meat.
  54. // Use this to define the Argument of the cosine transform, sans
  55. // cosine.
  56. //std::cout << "In Argument" << std::endl;
  57. Real nu = w / (2.*PI);
  58. Receivers->ClearFields();
  59. if (this->Trans != NULL && this->DipoleS == NULL) {
  60. this->Trans->SetFrequency(0, nu);
  61. this->EmEarthInt->CalculateWireAntennaFields();
  62. } else if (this->DipoleS != NULL && this->Trans==NULL) {
  63. this->DipoleS->SetFrequency(0, nu);
  64. this->EmEarthInt->MakeCalc3();
  65. }
  66. /*
  67. if ( std::abs(std::imag(Receivers->GetHfield(0)(component))) <= 0.) {
  68. std::cout << "DOOM! " << Receivers->GetHfield(0).transpose() << "\t" << nu << std::endl;
  69. std::cout << "this " << this << std::endl;
  70. std::cout << "trans: " << this->Trans << std::endl;
  71. std::cout << "EmEarthInt: " << this->EmEarthInt << std::endl;
  72. std::cout << "TEMIntegrationKernel.cpp" << std::endl;
  73. EmEarthInt->Query();
  74. exit(EXIT_FAILURE);
  75. //return Argument(w, iRelated);
  76. }
  77. */
  78. // TODO return a MatrixXr instead so we can have multiple receivers/components
  79. return std::imag(Receivers->GetHfield(0)(component)) / w;
  80. //answer = std::imag(temp); // dH/dt step response, H impulse response
  81. //answer = std::imag(temp) / ( w ); // dH/dt impulse response, H step response (TI)
  82. }
  83. void TemIntegrationKernel::SetEMEarth1D(EMEarth1D* earth) {
  84. if (this->EmEarthInt != NULL) {
  85. this->EmEarthInt->DetachFrom(this);
  86. }
  87. earth->AttachTo(this);
  88. this->EmEarthInt=earth;
  89. }
  90. void TemIntegrationKernel::SetTransmitter(WireAntenna *antennae) {
  91. if (this->Trans != NULL) {
  92. this->Trans->DetachFrom(this);
  93. }
  94. antennae->AttachTo(this);
  95. this->Trans=antennae;
  96. if (this->DipoleS != NULL) {
  97. this->DipoleS->DetachFrom(this);
  98. DipoleS = NULL;
  99. }
  100. }
  101. void TemIntegrationKernel::SetDipole(DipoleSource* dipolesource) {
  102. if (this->DipoleS != NULL) {
  103. this->DipoleS->DetachFrom(this);
  104. }
  105. dipolesource->AttachTo(this);
  106. this->DipoleS = dipolesource;
  107. if (this->Trans != NULL) {
  108. this->Trans->DetachFrom(this);
  109. Trans = NULL;
  110. }
  111. }
  112. void TemIntegrationKernel::SetReceiver(ReceiverPoints* receiver) {
  113. if (this->Receivers != NULL) {
  114. this->Receivers->DetachFrom(this);
  115. }
  116. receiver->AttachTo(this);
  117. this->Receivers=receiver;
  118. }
  119. int TemIntegrationKernel::GetNumRel() {
  120. //int temp;
  121. return 1;
  122. }
  123. void TemIntegrationKernel::SetComponent(const FIELDCOMPONENT& comp) {
  124. component = comp;
  125. }
  126. } // end namespace Lemma