Main Lemma Repository
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.

TEMTransmitter.cpp 8.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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. #ifdef HAVE_YAMLCPP
  21. std::ostream &operator << (std::ostream &stream, const TEMTransmitter &ob) {
  22. stream << ob.Serialize() << "\n---\n"; // End of doc --- as a direct stream should encapulste thingy
  23. return stream;
  24. }
  25. // TODO CONSIDER INPUT OPERATOR TOO!
  26. //std::ostream &operator << (std::ostream &stream, const TEMTransmitter &ob) {
  27. // stream << ob.Serialize() << "\n---\n"; // End of doc --- as a direct stream should encapulste thingy
  28. // return stream;
  29. //}
  30. #else
  31. std::ostream &operator << (std::ostream &stream, const TEMTransmitter &ob) {
  32. stream << *(PolygonalWireAntenna*)(&ob);
  33. stream << "YOU SHOULD COMPILE WITH YAML-CPP\n";
  34. return stream;
  35. }
  36. #endif
  37. // ==================== LIFECYCLE =======================
  38. //--------------------------------------------------------------------------------------
  39. // Class: TEMTransmitter
  40. // Method: TEMTransmitter
  41. // Description: constructor (protected)
  42. //--------------------------------------------------------------------------------------
  43. TEMTransmitter::TEMTransmitter (const std::string& name) : PolygonalWireAntenna(name),
  44. repFreq(0), repFreqUnits(HZ) {
  45. } // ----- end of method TEMTransmitter::TEMTransmitter (constructor) -----
  46. #ifdef HAVE_YAMLCPP
  47. //--------------------------------------------------------------------------------------
  48. // Class: TEMTransmitter
  49. // Method: TEMTransmitter
  50. // Description: Deserializing constructor (protected)
  51. //--------------------------------------------------------------------------------------
  52. TEMTransmitter::TEMTransmitter (const YAML::Node& node) : PolygonalWireAntenna(node) {
  53. repFreq = node["repFreq"].as<Real>();
  54. repFreqUnits = string2Enum<FREQUENCYUNITS>( node["repFreqUnits"].as<std::string>() );
  55. wfmTimes = node["wfmTimes"].as<VectorXr>();
  56. wfmTimes = node["wfmAmps"].as<VectorXr>();
  57. } // ----- end of method TEMTransmitter::TEMTransmitter (constructor) -----
  58. #endif
  59. //--------------------------------------------------------------------------------------
  60. // Class: TEMTransmitter
  61. // Method: New()
  62. // Description: public constructor
  63. //--------------------------------------------------------------------------------------
  64. TEMTransmitter* TEMTransmitter::New() {
  65. TEMTransmitter* Obj = new TEMTransmitter("TEMTransmitter");
  66. Obj->AttachTo(Obj);
  67. return Obj;
  68. }
  69. //--------------------------------------------------------------------------------------
  70. // Class: TEMTransmitter
  71. // Method: Clone
  72. //--------------------------------------------------------------------------------------
  73. TEMTransmitter* TEMTransmitter::Clone ( ) {
  74. TEMTransmitter* copy = TEMTransmitter::New();
  75. //copy->AttachTo(copy); // NO! Attached above!
  76. copy->NumberOfPoints = this->NumberOfPoints;
  77. copy->Freqs = this->Freqs;
  78. copy->Current = this->Current;
  79. copy->NumberOfTurns = this->NumberOfTurns;
  80. copy->Points = this->Points;
  81. //copy->Dipoles = this->Dipoles; // no, disaster
  82. copy->repFreq = this->repFreq;
  83. copy->repFreqUnits = this->repFreqUnits;
  84. copy->wfmTimes = this->wfmTimes;
  85. copy->wfmAmps = this->wfmAmps;
  86. return copy;
  87. } // ----- end of method TEMTransmitter::Clone -----
  88. //--------------------------------------------------------------------------------------
  89. // Class: TEMTransmitter
  90. // Method: ~TEMTransmitter
  91. // Description: destructor (protected)
  92. //--------------------------------------------------------------------------------------
  93. TEMTransmitter::~TEMTransmitter () {
  94. } // ----- end of method TEMTransmitter::~TEMTransmitter (destructor) -----
  95. //--------------------------------------------------------------------------------------
  96. // Class: TEMTransmitter
  97. // Method: Delete
  98. // Description: public destructor
  99. //--------------------------------------------------------------------------------------
  100. void TEMTransmitter::Delete() {
  101. this->DetachFrom(this);
  102. }
  103. //--------------------------------------------------------------------------------------
  104. // Class: TEMTransmitter
  105. // Method: Release
  106. // Description: destructor (protected)
  107. //--------------------------------------------------------------------------------------
  108. void TEMTransmitter::Release() {
  109. delete this;
  110. }
  111. //--------------------------------------------------------------------------------------
  112. // Class: TEMTransmitter
  113. // Method: Serialize
  114. //--------------------------------------------------------------------------------------
  115. #ifdef HAVE_YAMLCPP
  116. YAML::Node TEMTransmitter::Serialize ( ) const {
  117. YAML::Node node = PolygonalWireAntenna::Serialize();
  118. // or we could do just like below. Same basic uglyness
  119. node.SetTag( this->Name) ; //((PolygonalWireAntenna*)(&ob))->GetName() );
  120. //node["address"] = ss.str();
  121. node["repFreq"] = this->repFreq;
  122. node["repFreqUnits"] = enum2String(repFreqUnits);
  123. node["wfmTimes"] = wfmTimes;
  124. node["wfmAmps"] = wfmAmps;
  125. return node;
  126. } // ----- end of method TEMTransmitter::Serialize -----
  127. //--------------------------------------------------------------------------------------
  128. // Class: TEMTransmitter
  129. // Method: DeSerialize
  130. //--------------------------------------------------------------------------------------
  131. TEMTransmitter* TEMTransmitter::DeSerialize ( const YAML::Node& node ) {
  132. TEMTransmitter* Object = new TEMTransmitter(node);
  133. Object->AttachTo(Object);
  134. DESERIALIZECHECK( node, Object )
  135. return Object;
  136. } // ----- end of method TEMTransmitter::DeSerialize -----
  137. #endif
  138. // ==================== INQUIRY =======================
  139. //--------------------------------------------------------------------------------------
  140. // Class: TEMTransmitter
  141. // Method: SetRepFrequency
  142. //--------------------------------------------------------------------------------------
  143. void TEMTransmitter::SetRepFrequency ( const Real& fr, const FREQUENCYUNITS& units ) {
  144. repFreq = fr;
  145. repFreqUnits = units;
  146. return ;
  147. } // ----- end of method TEMTransmitter::SetRepFrequency -----
  148. //--------------------------------------------------------------------------------------
  149. // Class: TEMTransmitter
  150. // Method: SetWaveform
  151. //--------------------------------------------------------------------------------------
  152. void TEMTransmitter::SetWaveform ( const VectorXr& times, const VectorXr& amps, const TIMEUNITS& units ) {
  153. // switch units ?
  154. switch (units) {
  155. case SEC:
  156. wfmTimes = times;
  157. break;
  158. case MILLISEC:
  159. wfmTimes = times*1e-3 ;
  160. break;
  161. case MICROSEC:
  162. wfmTimes = times*1e-6 ;
  163. break;
  164. case NANOSEC:
  165. wfmTimes = times*1e-9 ;
  166. break;
  167. case PICOSEC:
  168. wfmTimes = times*1e-12 ;
  169. break;
  170. };
  171. wfmAmps = amps;
  172. return ;
  173. } // ----- end of method TEMTransmitter::SetWaveform -----
  174. //--------------------------------------------------------------------------------------
  175. // Class: TEMTransmitter
  176. // Method: GetWfmAmps
  177. //--------------------------------------------------------------------------------------
  178. VectorXr TEMTransmitter::GetWfmAmps ( ) {
  179. return wfmAmps;
  180. } // ----- end of method TEMTransmitter::GetWfmAmps -----
  181. //--------------------------------------------------------------------------------------
  182. // Class: TEMTransmitter
  183. // Method: GetWfmTimes
  184. //--------------------------------------------------------------------------------------
  185. VectorXr TEMTransmitter::GetWfmTimes ( ) {
  186. return wfmTimes;
  187. } // ----- end of method TEMTransmitter::GetWfmTimes -----
  188. } // namespace Lemma