Main Lemma Repository
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

TEMTransmitter.cpp 7.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /* This file is part of Lemma, a geophysical modelling and inversion API.
  2. * More information is available at http://lemmasoftware.org
  3. */
  4. /* This Source Code Form is subject to the terms of the Mozilla Public
  5. * License, v. 2.0. If a copy of the MPL was not distributed with this
  6. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  7. */
  8. /**
  9. * @file
  10. * @date 09/29/2014 11:43:28 AM
  11. * @version $Id$
  12. * @author Trevor Irons (ti)
  13. * @email Trevor.Irons@xri-geo.com
  14. * @copyright Copyright (c) 2014, XRI Geophysics, LLC
  15. * @copyright Copyright (c) 2014, Trevor Irons
  16. */
  17. #include "TEMTransmitter.h"
  18. namespace Lemma {
  19. // ==================== FRIEND METHODS =====================
  20. std::ostream &operator << (std::ostream &stream, const TEMTransmitter &ob) {
  21. stream << ob.Serialize() << "\n";
  22. return stream;
  23. }
  24. // ==================== LIFECYCLE =======================
  25. //--------------------------------------------------------------------------------------
  26. // Class: TEMTransmitter
  27. // Method: TEMTransmitter
  28. // Description: constructor (protected)
  29. //--------------------------------------------------------------------------------------
  30. TEMTransmitter::TEMTransmitter (const ctor_key& key) :
  31. PolygonalWireAntenna(key), repFreq(0), repFreqUnits(HZ)
  32. {
  33. } // ----- end of method TEMTransmitter::TEMTransmitter (constructor) -----
  34. //--------------------------------------------------------------------------------------
  35. // Class: TEMTransmitter
  36. // Method: TEMTransmitter
  37. // Description: Deserializing constructor (protected)
  38. //--------------------------------------------------------------------------------------
  39. TEMTransmitter::TEMTransmitter (const YAML::Node& node, const ctor_key& key) :
  40. PolygonalWireAntenna(node, key)
  41. {
  42. repFreq = node["repFreq"].as<Real>();
  43. repFreqUnits = string2Enum<FREQUENCYUNITS>( node["repFreqUnits"].as<std::string>() );
  44. wfmTimes = node["wfmTimes"].as<VectorXr>();
  45. wfmTimes = node["wfmAmps"].as<VectorXr>();
  46. } // ----- end of method TEMTransmitter::TEMTransmitter (constructor) -----
  47. //--------------------------------------------------------------------------------------
  48. // Class: TEMTransmitter
  49. // Method: New()
  50. // Description: public constructor
  51. //--------------------------------------------------------------------------------------
  52. std::shared_ptr<TEMTransmitter> TEMTransmitter::NewSP() {
  53. return std::make_shared<TEMTransmitter>( ctor_key() );
  54. }
  55. //--------------------------------------------------------------------------------------
  56. // Class: TEMTransmitter
  57. // Method: Clone
  58. //--------------------------------------------------------------------------------------
  59. std::shared_ptr<TEMTransmitter> TEMTransmitter::Clone ( ) {
  60. auto copy = TEMTransmitter::NewSP();
  61. //copy->AttachTo(copy); // NO! Attached above!
  62. copy->NumberOfPoints = this->NumberOfPoints;
  63. copy->Freqs = this->Freqs;
  64. copy->Current = this->Current;
  65. copy->NumberOfTurns = this->NumberOfTurns;
  66. copy->Points = this->Points;
  67. //copy->Dipoles = this->Dipoles; // no, disaster
  68. copy->repFreq = this->repFreq;
  69. copy->repFreqUnits = this->repFreqUnits;
  70. copy->wfmTimes = this->wfmTimes;
  71. copy->wfmAmps = this->wfmAmps;
  72. return copy;
  73. } // ----- end of method TEMTransmitter::Clone -----
  74. //--------------------------------------------------------------------------------------
  75. // Class: TEMTransmitter
  76. // Method: ~TEMTransmitter
  77. // Description: destructor (protected)
  78. //--------------------------------------------------------------------------------------
  79. TEMTransmitter::~TEMTransmitter () {
  80. } // ----- end of method TEMTransmitter::~TEMTransmitter (destructor) -----
  81. //--------------------------------------------------------------------------------------
  82. // Class: TEMTransmitter
  83. // Method: Serialize
  84. //--------------------------------------------------------------------------------------
  85. YAML::Node TEMTransmitter::Serialize ( ) const {
  86. YAML::Node node = PolygonalWireAntenna::Serialize();
  87. node.SetTag( this->GetName() );
  88. //node["address"] = ss.str();
  89. node["repFreq"] = this->repFreq;
  90. node["repFreqUnits"] = enum2String(repFreqUnits);
  91. node["wfmTimes"] = wfmTimes;
  92. node["wfmAmps"] = wfmAmps;
  93. return node;
  94. } // ----- end of method TEMTransmitter::Serialize -----
  95. //--------------------------------------------------------------------------------------
  96. // Class: TEMTransmitter
  97. // Method: DeSerialize
  98. //--------------------------------------------------------------------------------------
  99. std::shared_ptr<TEMTransmitter> TEMTransmitter::DeSerialize ( const YAML::Node& node ) {
  100. if (node.Tag() != "TEMTransmitter") {
  101. throw DeSerializeTypeMismatch( "TEMTransmitter", node.Tag());
  102. }
  103. return std::make_shared<TEMTransmitter> ( node, ctor_key() );
  104. } // ----- end of method TEMTransmitter::DeSerialize -----
  105. // ==================== INQUIRY =======================
  106. //--------------------------------------------------------------------------------------
  107. // Class: TEMTransmitter
  108. // Method: SetRepFrequency
  109. //--------------------------------------------------------------------------------------
  110. void TEMTransmitter::SetRepFrequency ( const Real& fr, const FREQUENCYUNITS& units ) {
  111. repFreq = fr;
  112. repFreqUnits = units;
  113. return ;
  114. } // ----- end of method TEMTransmitter::SetRepFrequency -----
  115. //--------------------------------------------------------------------------------------
  116. // Class: TEMTransmitter
  117. // Method: SetWaveform
  118. //--------------------------------------------------------------------------------------
  119. void TEMTransmitter::SetWaveform ( const VectorXr& times, const VectorXr& amps, const TIMEUNITS& units ) {
  120. // switch units ?
  121. switch (units) {
  122. case SEC:
  123. wfmTimes = times;
  124. break;
  125. case MILLISEC:
  126. wfmTimes = times*1e-3 ;
  127. break;
  128. case MICROSEC:
  129. wfmTimes = times*1e-6 ;
  130. break;
  131. case NANOSEC:
  132. wfmTimes = times*1e-9 ;
  133. break;
  134. case PICOSEC:
  135. wfmTimes = times*1e-12 ;
  136. break;
  137. };
  138. wfmAmps = amps;
  139. return ;
  140. } // ----- end of method TEMTransmitter::SetWaveform -----
  141. //--------------------------------------------------------------------------------------
  142. // Class: TEMTransmitter
  143. // Method: GetWfmAmps
  144. //--------------------------------------------------------------------------------------
  145. VectorXr TEMTransmitter::GetWfmAmps ( ) {
  146. return wfmAmps;
  147. } // ----- end of method TEMTransmitter::GetWfmAmps -----
  148. //--------------------------------------------------------------------------------------
  149. // Class: TEMTransmitter
  150. // Method: GetWfmTimes
  151. //--------------------------------------------------------------------------------------
  152. VectorXr TEMTransmitter::GetWfmTimes ( ) {
  153. return wfmTimes;
  154. } // ----- end of method TEMTransmitter::GetWfmTimes -----
  155. } // namespace Lemma