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.

DipoleSource.cpp 74KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316
  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 12/02/2009
  9. @version $Id: dipolesource.cpp 203 2015-01-09 21:19:04Z tirons $
  10. **/
  11. #include "DipoleSource.h"
  12. #include "KernelEM1DManager.h"
  13. //#include "GroundedElectricDipole.h"
  14. //#include "UngroundedElectricDipole.h"
  15. //#include "MagneticDipole.h"
  16. #include "FieldPoints.h"
  17. #include "HankelTransform.h"
  18. namespace Lemma {
  19. // ==================== FRIENDS ======================
  20. std::ostream &operator<<(std::ostream &stream, const DipoleSource &ob) {
  21. stream << ob.Serialize() << "\n";
  22. return stream;
  23. }
  24. // ==================== LIFECYCLE ======================
  25. DipoleSource::DipoleSource( const ctor_key& key ) : LemmaObject( key ),
  26. Type(NOSOURCETYPE),
  27. irec(-1),
  28. Phase(0),
  29. Moment(1),
  30. KernelManager(nullptr),
  31. Receivers(nullptr),
  32. Earth(nullptr)
  33. {
  34. this->Location.setZero();
  35. this->Phat.setZero();
  36. }
  37. DipoleSource::~DipoleSource() {
  38. }
  39. std::shared_ptr<DipoleSource> DipoleSource::NewSP() {
  40. return std::make_shared<DipoleSource> ( ctor_key() );
  41. }
  42. YAML::Node DipoleSource::Serialize() const {
  43. YAML::Node node = DipoleSource::Serialize();
  44. node.SetTag( GetName() );
  45. /*
  46. node["LayerConductivity"] = LayerConductivity;
  47. node["LayerSusceptibility"] = LayerSusceptibility;
  48. node["LayerLowFreqSusceptibility"] = LayerLowFreqSusceptibility;
  49. node["LayerHighFreqSusceptibility"] = LayerHighFreqSusceptibility;
  50. node["LayerTauSusceptibility"] = LayerTauSusceptibility;
  51. node["LayerBreathSusceptibility"] = LayerBreathSusceptibility;
  52. node["LayerPermitivity"] = LayerPermitivity;
  53. node["LayerLowFreqPermitivity"] = LayerLowFreqPermitivity;
  54. node["LayerHighFreqPermitivity"] = LayerHighFreqPermitivity;
  55. node["LayerTauPermitivity"] = LayerTauPermitivity;
  56. node["LayerBreathPermitivity"] = LayerBreathPermitivity;
  57. */
  58. return node;
  59. }
  60. std::shared_ptr<DipoleSource> DipoleSource::Clone() {
  61. auto Obj = DipoleSource::NewSP();
  62. // copy
  63. Obj->Type = Type;
  64. Obj->irec = irec;
  65. Obj->lays = lays;
  66. Obj->layr = layr;
  67. Obj->Phase = Phase;
  68. Obj->Moment = Moment;
  69. Obj->xxp = xxp;
  70. Obj->yyp = yyp;
  71. Obj->rho = rho;
  72. Obj->sp = sp;
  73. Obj->cp = cp;
  74. Obj->scp = scp;
  75. Obj->sps = sps;
  76. Obj->cps = cps;
  77. Obj->c2p = c2p;
  78. Obj->FieldsToCalculate = FieldsToCalculate;
  79. Obj->f = f;
  80. Obj->ik = ik;
  81. Obj->Location = Location;
  82. Obj->Phat = Phat;
  83. Obj->Freqs = Freqs;
  84. return Obj;
  85. }
  86. //--------------------------------------------------------------------------------------
  87. // Class: DipoleSource
  88. // Method: GetName
  89. // Description: Class identifier
  90. //--------------------------------------------------------------------------------------
  91. inline std::string DipoleSource::GetName ( ) const {
  92. return CName;
  93. } // ----- end of method DipoleSource::GetName -----
  94. // ==================== ACCESS ======================
  95. void DipoleSource::SetLocation(const Vector3r &posin) {
  96. this->Location = posin;
  97. }
  98. void DipoleSource::SetLocation(const Real &xp, const Real &yp,
  99. const Real &zp) {
  100. this->Location = Vector3r(xp, yp, zp);
  101. }
  102. void DipoleSource::SetPhase(const Real &phase) {
  103. this->Phase = phase;
  104. }
  105. void DipoleSource::SetPolarity(const DipoleSourcePolarity &pol) {
  106. static bool called = false;
  107. if (!called) {
  108. std::cerr << "\n\n=================================================================\n"
  109. << "WARNING: Use of deprecated method DipoleSource::SetPolarity(pol)\n"
  110. << "Use more general SetPolarisation( Vector3r ) or SetPolarisation( x, y, z );\n"
  111. << "This method will be removed in future versions of Lemma"
  112. << "\n=================================================================\n";
  113. called = true;
  114. }
  115. // Polarity = pol;
  116. // switch (Polarity) {
  117. // case POSITIVE:
  118. // Moment = std::abs(Moment);
  119. // break;
  120. // case NEGATIVE:
  121. // Moment = -std::abs(Moment);
  122. // break;
  123. // default:
  124. // throw NonValidDipolePolarity();
  125. // };
  126. }
  127. void DipoleSource::SetType(const DipoleSourceType & stype) {
  128. switch (stype) {
  129. case (GROUNDEDELECTRICDIPOLE):
  130. this->Type = stype;
  131. break;
  132. case (UNGROUNDEDELECTRICDIPOLE):
  133. this->Type = stype;
  134. break;
  135. case (MAGNETICDIPOLE):
  136. this->Type = stype;
  137. break;
  138. default:
  139. throw NonValidDipoleTypeAssignment();
  140. }
  141. }
  142. void DipoleSource::SetPolarisation(const Vector3r& pol) {
  143. this->Phat = pol / pol.norm();
  144. }
  145. void DipoleSource::SetPolarisation(const Real& x, const Real& y, const Real& z) {
  146. Vector3r pol = (VectorXr(3) << x, y, z).finished();
  147. this->Phat = pol / pol.norm();
  148. }
  149. Vector3r DipoleSource::GetPolarisation() {
  150. return Phat;
  151. }
  152. DipoleSourceType DipoleSource::GetType() {
  153. return Type;
  154. }
  155. void DipoleSource::SetPolarisation(const
  156. DipoleSourcePolarisation &pol) {
  157. static bool called = false;
  158. if (!called) {
  159. std::cout << "\n\n========================================================================================\n"
  160. << "WARNING: Use of deprecated method DipoleSource::SetPolarisation(DipleSourcePolarisation)\n"
  161. << "Use more general SetPolarisation( Vector3r ) or SetPolarisation( x, y, z );\n"
  162. << "This method will be removed in future versions of Lemma"
  163. << "\n========================================================================================\n";
  164. called = true;
  165. }
  166. switch (pol) {
  167. case (XPOLARISATION):
  168. //this->Polarisation = pol;
  169. this->Phat = (VectorXr(3) << 1, 0, 0).finished();
  170. break;
  171. case (YPOLARISATION):
  172. //this->Polarisation = pol;
  173. this->Phat = (VectorXr(3) << 0, 1, 0).finished();
  174. break;
  175. case (ZPOLARISATION):
  176. //this->Polarisation = pol;
  177. this->Phat = (VectorXr(3) << 0, 0, 1).finished();
  178. break;
  179. default:
  180. throw NonValidDipolePolarisationAssignment();
  181. }
  182. }
  183. void DipoleSource::SetMoment(const Real &moment) {
  184. this->Moment = moment;
  185. }
  186. // ==================== OPERATIONS =====================
  187. void DipoleSource::SetKernels(const int& ifreq, const FIELDCALCULATIONS& Fields , std::shared_ptr<FieldPoints> ReceiversIn, const int& irecin,
  188. std::shared_ptr<LayeredEarthEM> EarthIn ) {
  189. if (Receivers != ReceiversIn) {
  190. Receivers = ReceiversIn;
  191. }
  192. if (Earth != EarthIn) {
  193. Earth = EarthIn;
  194. }
  195. if (irecin != irec) {
  196. irec = irecin;
  197. }
  198. if (FieldsToCalculate != Fields) {
  199. FieldsToCalculate = Fields;
  200. }
  201. xxp = Receivers->GetLocation(irec)[0] - Location[0];
  202. yyp = Receivers->GetLocation(irec)[1] - Location[1];
  203. rho = (Receivers->GetLocation(irec).head<2>() - Location.head<2>()).norm();
  204. sp = yyp/rho;
  205. cp = xxp/rho;
  206. scp = sp*cp;
  207. sps = sp*sp;
  208. cps = cp*cp;
  209. c2p = cps-sps;
  210. f = VectorXcr::Zero(13);
  211. ik = VectorXi::Zero(13);
  212. lays = Earth->GetLayerAtThisDepth(Location[2]);
  213. layr = Earth->GetLayerAtThisDepth(Receivers->GetLocation(irec)[2]);
  214. KernelManager = KernelEM1DManager::NewSP();
  215. KernelManager->SetEarth(Earth);
  216. // alternative is to use weak_ptr here, this is deep and internal, and we are safe.
  217. KernelManager->SetDipoleSource( shared_from_this().get() , ifreq, Receivers->GetLocation(irec)[2]);
  218. kernelFreq = Freqs(ifreq); // this is never used
  219. ReSetKernels( ifreq, Fields, Receivers, irec, Earth );
  220. return;
  221. }
  222. // TODO we could make the dipoles template specializations avoiding this rats nest of switch statements. Probably
  223. // not the most critical piece though
  224. void DipoleSource::ReSetKernels(const int& ifreq, const FIELDCALCULATIONS& Fields , std::shared_ptr<FieldPoints> Receivers, const int& irec,
  225. std::shared_ptr<LayeredEarthEM> Earth ) {
  226. Vector3r Pol = Phat;
  227. switch (Type) {
  228. case (GROUNDEDELECTRICDIPOLE):
  229. if (std::abs(Pol[2]) > 0) { // z dipole
  230. switch(FieldsToCalculate) {
  231. case E:
  232. if (lays == 0 && layr == 0) {
  233. ik[10] = KernelManager->AddKernel<TM, 10, INAIR, INAIR>( );
  234. ik[11] = KernelManager->AddKernel<TM, 11, INAIR, INAIR>( );
  235. } else if (lays == 0 && layr > 0) {
  236. ik[10] = KernelManager->AddKernel<TM, 10, INAIR, INGROUND>( );
  237. ik[11] = KernelManager->AddKernel<TM, 11, INAIR, INGROUND>( );
  238. } else if (lays > 0 && layr == 0) {
  239. ik[10] = KernelManager->AddKernel<TM, 10, INGROUND, INAIR>( );
  240. ik[11] = KernelManager->AddKernel<TM, 11, INGROUND, INAIR>( );
  241. } else {
  242. ik[10] = KernelManager->AddKernel<TM, 10, INGROUND, INGROUND>( );
  243. ik[11] = KernelManager->AddKernel<TM, 11, INGROUND, INGROUND>( );
  244. }
  245. break;
  246. case H:
  247. if (lays == 0 && layr == 0) {
  248. ik[12] = KernelManager->AddKernel<TM, 12, INAIR, INAIR>( );
  249. } else if (lays == 0 && layr > 0) {
  250. ik[12] = KernelManager->AddKernel<TM, 12, INAIR, INGROUND>( );
  251. } else if (lays > 0 && layr == 0) {
  252. ik[12] = KernelManager->AddKernel<TM, 12, INGROUND, INAIR>( );
  253. } else {
  254. ik[12] = KernelManager->AddKernel<TM, 12, INGROUND, INGROUND>( );
  255. }
  256. break;
  257. case BOTH:
  258. if ( lays == 0 && layr == 0) {
  259. ik[10] = KernelManager->AddKernel<TM, 10, INAIR, INAIR>( );
  260. ik[11] = KernelManager->AddKernel<TM, 11, INAIR, INAIR>( );
  261. ik[12] = KernelManager->AddKernel<TM, 12, INAIR, INAIR>( );
  262. } else if (lays == 0 && layr > 0) {
  263. ik[10] = KernelManager->AddKernel<TM, 10, INAIR, INGROUND>( );
  264. ik[11] = KernelManager->AddKernel<TM, 11, INAIR, INGROUND>( );
  265. ik[12] = KernelManager->AddKernel<TM, 12, INAIR, INGROUND>( );
  266. } else if (lays > 0 && layr == 0) {
  267. ik[10] = KernelManager->AddKernel<TM, 10, INGROUND, INAIR>( );
  268. ik[11] = KernelManager->AddKernel<TM, 11, INGROUND, INAIR>( );
  269. ik[12] = KernelManager->AddKernel<TM, 12, INGROUND, INAIR>( );
  270. } else {
  271. ik[10] = KernelManager->AddKernel<TM, 10, INGROUND, INGROUND>( );
  272. ik[11] = KernelManager->AddKernel<TM, 11, INGROUND, INGROUND>( );
  273. ik[12] = KernelManager->AddKernel<TM, 12, INGROUND, INGROUND>( );
  274. }
  275. }
  276. }
  277. if (std::abs(Pol[1]) > 0 || std::abs(Pol[0]) > 0) { // x or y grounded HED dipole
  278. switch(FieldsToCalculate) {
  279. case E:
  280. if ( lays == 0 && layr == 0) {
  281. ik[0] = KernelManager->AddKernel<TM, 0, INAIR, INAIR>( );
  282. ik[1] = KernelManager->AddKernel<TM, 1, INAIR, INAIR>( );
  283. ik[4] = KernelManager->AddKernel<TM, 4, INAIR, INAIR>( );
  284. ik[2] = KernelManager->AddKernel<TE, 2, INAIR, INAIR>( );
  285. ik[3] = KernelManager->AddKernel<TE, 3, INAIR, INAIR>( );
  286. } else if (lays == 0 && layr > 0) {
  287. ik[0] = KernelManager->AddKernel<TM, 0, INAIR, INGROUND>( );
  288. ik[1] = KernelManager->AddKernel<TM, 1, INAIR, INGROUND>( );
  289. ik[4] = KernelManager->AddKernel<TM, 4, INAIR, INGROUND>( );
  290. ik[2] = KernelManager->AddKernel<TE, 2, INAIR, INGROUND>( );
  291. ik[3] = KernelManager->AddKernel<TE, 3, INAIR, INGROUND>( );
  292. } else if (lays > 0 && layr == 0) {
  293. ik[0] = KernelManager->AddKernel<TM, 0, INGROUND, INAIR>( );
  294. ik[1] = KernelManager->AddKernel<TM, 1, INGROUND, INAIR>( );
  295. ik[4] = KernelManager->AddKernel<TM, 4, INGROUND, INAIR>( );
  296. ik[2] = KernelManager->AddKernel<TE, 2, INGROUND, INAIR>( );
  297. ik[3] = KernelManager->AddKernel<TE, 3, INGROUND, INAIR>( );
  298. } else {
  299. ik[0] = KernelManager->AddKernel<TM, 0, INGROUND, INGROUND>( );
  300. ik[1] = KernelManager->AddKernel<TM, 1, INGROUND, INGROUND>( );
  301. ik[4] = KernelManager->AddKernel<TM, 4, INGROUND, INGROUND>( );
  302. ik[2] = KernelManager->AddKernel<TE, 2, INGROUND, INGROUND>( );
  303. ik[3] = KernelManager->AddKernel<TE, 3, INGROUND, INGROUND>( );
  304. }
  305. break;
  306. case H:
  307. if (lays == 0 && layr == 0) {
  308. ik[5] = KernelManager->AddKernel<TM, 5, INAIR, INAIR>( );
  309. ik[6] = KernelManager->AddKernel<TM, 6, INAIR, INAIR>( );
  310. ik[7] = KernelManager->AddKernel<TE, 7, INAIR, INAIR>( );
  311. ik[8] = KernelManager->AddKernel<TE, 8, INAIR, INAIR>( );
  312. ik[9] = KernelManager->AddKernel<TE, 9, INAIR, INAIR>( );
  313. } else if (lays == 0 && layr > 0) {
  314. ik[5] = KernelManager->AddKernel<TM, 5, INAIR, INGROUND>( );
  315. ik[6] = KernelManager->AddKernel<TM, 6, INAIR, INGROUND>( );
  316. ik[7] = KernelManager->AddKernel<TE, 7, INAIR, INGROUND>( );
  317. ik[8] = KernelManager->AddKernel<TE, 8, INAIR, INGROUND>( );
  318. ik[9] = KernelManager->AddKernel<TE, 9, INAIR, INGROUND>( );
  319. } else if (lays > 0 && layr == 0) {
  320. ik[5] = KernelManager->AddKernel<TM, 5, INGROUND, INAIR>( );
  321. ik[6] = KernelManager->AddKernel<TM, 6, INGROUND, INAIR>( );
  322. ik[7] = KernelManager->AddKernel<TE, 7, INGROUND, INAIR>( );
  323. ik[8] = KernelManager->AddKernel<TE, 8, INGROUND, INAIR>( );
  324. ik[9] = KernelManager->AddKernel<TE, 9, INGROUND, INAIR>( );
  325. } else {
  326. ik[5] = KernelManager->AddKernel<TM, 5, INGROUND, INGROUND>( );
  327. ik[6] = KernelManager->AddKernel<TM, 6, INGROUND, INGROUND>( );
  328. ik[7] = KernelManager->AddKernel<TE, 7, INGROUND, INGROUND>( );
  329. ik[8] = KernelManager->AddKernel<TE, 8, INGROUND, INGROUND>( );
  330. ik[9] = KernelManager->AddKernel<TE, 9, INGROUND, INGROUND>( );
  331. }
  332. break;
  333. case BOTH:
  334. if (lays == 0 && layr == 0) {
  335. ik[0] = KernelManager->AddKernel<TM, 0, INAIR, INAIR>( );
  336. ik[1] = KernelManager->AddKernel<TM, 1, INAIR, INAIR>( );
  337. ik[4] = KernelManager->AddKernel<TM, 4, INAIR, INAIR>( );
  338. ik[2] = KernelManager->AddKernel<TE, 2, INAIR, INAIR>( );
  339. ik[3] = KernelManager->AddKernel<TE, 3, INAIR, INAIR>( );
  340. ik[5] = KernelManager->AddKernel<TM, 5, INAIR, INAIR>( );
  341. ik[6] = KernelManager->AddKernel<TM, 6, INAIR, INAIR>( );
  342. ik[7] = KernelManager->AddKernel<TE, 7, INAIR, INAIR>( );
  343. ik[8] = KernelManager->AddKernel<TE, 8, INAIR, INAIR>( );
  344. ik[9] = KernelManager->AddKernel<TE, 9, INAIR, INAIR>( );
  345. } else if (lays == 0 && layr > 0) {
  346. ik[0] = KernelManager->AddKernel<TM, 0, INAIR, INGROUND>( );
  347. ik[1] = KernelManager->AddKernel<TM, 1, INAIR, INGROUND>( );
  348. ik[4] = KernelManager->AddKernel<TM, 4, INAIR, INGROUND>( );
  349. ik[2] = KernelManager->AddKernel<TE, 2, INAIR, INGROUND>( );
  350. ik[3] = KernelManager->AddKernel<TE, 3, INAIR, INGROUND>( );
  351. ik[5] = KernelManager->AddKernel<TM, 5, INAIR, INGROUND>( );
  352. ik[6] = KernelManager->AddKernel<TM, 6, INAIR, INGROUND>( );
  353. ik[7] = KernelManager->AddKernel<TE, 7, INAIR, INGROUND>( );
  354. ik[8] = KernelManager->AddKernel<TE, 8, INAIR, INGROUND>( );
  355. ik[9] = KernelManager->AddKernel<TE, 9, INAIR, INGROUND>( );
  356. } else if (lays > 0 && layr == 0) {
  357. ik[0] = KernelManager->AddKernel<TM, 0, INGROUND, INAIR>( );
  358. ik[1] = KernelManager->AddKernel<TM, 1, INGROUND, INAIR>( );
  359. ik[4] = KernelManager->AddKernel<TM, 4, INGROUND, INAIR>( );
  360. ik[2] = KernelManager->AddKernel<TE, 2, INGROUND, INAIR>( );
  361. ik[3] = KernelManager->AddKernel<TE, 3, INGROUND, INAIR>( );
  362. ik[5] = KernelManager->AddKernel<TM, 5, INGROUND, INAIR>( );
  363. ik[6] = KernelManager->AddKernel<TM, 6, INGROUND, INAIR>( );
  364. ik[7] = KernelManager->AddKernel<TE, 7, INGROUND, INAIR>( );
  365. ik[8] = KernelManager->AddKernel<TE, 8, INGROUND, INAIR>( );
  366. ik[9] = KernelManager->AddKernel<TE, 9, INGROUND, INAIR>( );
  367. } else {
  368. ik[0] = KernelManager->AddKernel<TM, 0, INGROUND, INGROUND>( );
  369. ik[1] = KernelManager->AddKernel<TM, 1, INGROUND, INGROUND>( );
  370. ik[4] = KernelManager->AddKernel<TM, 4, INGROUND, INGROUND>( );
  371. ik[2] = KernelManager->AddKernel<TE, 2, INGROUND, INGROUND>( );
  372. ik[3] = KernelManager->AddKernel<TE, 3, INGROUND, INGROUND>( );
  373. ik[5] = KernelManager->AddKernel<TM, 5, INGROUND, INGROUND>( );
  374. ik[6] = KernelManager->AddKernel<TM, 6, INGROUND, INGROUND>( );
  375. ik[7] = KernelManager->AddKernel<TE, 7, INGROUND, INGROUND>( );
  376. ik[8] = KernelManager->AddKernel<TE, 8, INGROUND, INGROUND>( );
  377. ik[9] = KernelManager->AddKernel<TE, 9, INGROUND, INGROUND>( );
  378. }
  379. break;
  380. }
  381. }
  382. break;
  383. case (UNGROUNDEDELECTRICDIPOLE):
  384. if (std::abs(Pol[2]) > 0) { // z dipole
  385. switch(FieldsToCalculate) {
  386. case E:
  387. if (lays == 0 && layr == 0) {
  388. ik[11] = KernelManager->AddKernel<TM, 11, INAIR, INAIR>( );
  389. } else if (lays == 0 && layr > 0) {
  390. ik[11] = KernelManager->AddKernel<TM, 11, INAIR, INGROUND>( );
  391. } else if (lays > 0 && layr == 0) {
  392. ik[11] = KernelManager->AddKernel<TM, 11, INGROUND, INAIR>( );
  393. } else {
  394. ik[11] = KernelManager->AddKernel<TM, 11, INGROUND, INGROUND>( );
  395. }
  396. break;
  397. case H:
  398. if (lays == 0 && layr == 0) {
  399. ik[12] = KernelManager->AddKernel<TM, 12, INAIR, INAIR>( );
  400. } else if (lays == 0 && layr > 0) {
  401. ik[12] = KernelManager->AddKernel<TM, 12, INAIR, INGROUND>( );
  402. } else if (lays > 0 && layr == 0) {
  403. ik[12] = KernelManager->AddKernel<TM, 12, INGROUND, INAIR>( );
  404. } else {
  405. ik[12] = KernelManager->AddKernel<TM, 12, INGROUND, INGROUND>( );
  406. }
  407. break;
  408. case BOTH:
  409. if ( lays == 0 && layr == 0) {
  410. ik[11] = KernelManager->AddKernel<TM, 11, INAIR, INAIR>( );
  411. ik[12] = KernelManager->AddKernel<TM, 12, INAIR, INAIR>( );
  412. } else if (lays == 0 && layr > 0) {
  413. ik[11] = KernelManager->AddKernel<TM, 11, INAIR, INGROUND>( );
  414. ik[12] = KernelManager->AddKernel<TM, 12, INAIR, INGROUND>( );
  415. } else if (lays > 0 && layr == 0) {
  416. ik[11] = KernelManager->AddKernel<TM, 11, INGROUND, INAIR>( );
  417. ik[12] = KernelManager->AddKernel<TM, 12, INGROUND, INAIR>( );
  418. } else {
  419. ik[11] = KernelManager->AddKernel<TM, 11, INGROUND, INGROUND>( );
  420. ik[12] = KernelManager->AddKernel<TM, 12, INGROUND, INGROUND>( );
  421. }
  422. }
  423. }
  424. if (std::abs(Pol[1]) > 0 || std::abs(Pol[0]) > 0) { // x or y grounded HED dipole
  425. switch(FieldsToCalculate) {
  426. case E:
  427. if ( lays == 0 && layr == 0) {
  428. ik[2] = KernelManager->AddKernel<TE, 2, INAIR, INAIR>( );
  429. ik[3] = KernelManager->AddKernel<TE, 3, INAIR, INAIR>( );
  430. } else if (lays == 0 && layr > 0) {
  431. ik[2] = KernelManager->AddKernel<TE, 2, INAIR, INGROUND>( );
  432. ik[3] = KernelManager->AddKernel<TE, 3, INAIR, INGROUND>( );
  433. } else if (lays > 0 && layr == 0) {
  434. ik[2] = KernelManager->AddKernel<TE, 2, INGROUND, INAIR>( );
  435. ik[3] = KernelManager->AddKernel<TE, 3, INGROUND, INAIR>( );
  436. } else {
  437. ik[2] = KernelManager->AddKernel<TE, 2, INGROUND, INGROUND>( );
  438. ik[3] = KernelManager->AddKernel<TE, 3, INGROUND, INGROUND>( );
  439. }
  440. break;
  441. case H:
  442. if (lays == 0 && layr == 0) {
  443. ik[5] = KernelManager->AddKernel<TM, 5, INAIR, INAIR>( );
  444. ik[6] = KernelManager->AddKernel<TM, 6, INAIR, INAIR>( );
  445. ik[7] = KernelManager->AddKernel<TE, 7, INAIR, INAIR>( );
  446. ik[8] = KernelManager->AddKernel<TE, 8, INAIR, INAIR>( );
  447. ik[9] = KernelManager->AddKernel<TE, 9, INAIR, INAIR>( );
  448. } else if (lays == 0 && layr > 0) {
  449. ik[5] = KernelManager->AddKernel<TM, 5, INAIR, INGROUND>( );
  450. ik[6] = KernelManager->AddKernel<TM, 6, INAIR, INGROUND>( );
  451. ik[7] = KernelManager->AddKernel<TE, 7, INAIR, INGROUND>( );
  452. ik[8] = KernelManager->AddKernel<TE, 8, INAIR, INGROUND>( );
  453. ik[9] = KernelManager->AddKernel<TE, 9, INAIR, INGROUND>( );
  454. } else if (lays > 0 && layr == 0) {
  455. ik[5] = KernelManager->AddKernel<TM, 5, INGROUND, INAIR>( );
  456. ik[6] = KernelManager->AddKernel<TM, 6, INGROUND, INAIR>( );
  457. ik[7] = KernelManager->AddKernel<TE, 7, INGROUND, INAIR>( );
  458. ik[8] = KernelManager->AddKernel<TE, 8, INGROUND, INAIR>( );
  459. ik[9] = KernelManager->AddKernel<TE, 9, INGROUND, INAIR>( );
  460. } else {
  461. ik[5] = KernelManager->AddKernel<TM, 5, INGROUND, INGROUND>( );
  462. ik[6] = KernelManager->AddKernel<TM, 6, INGROUND, INGROUND>( );
  463. ik[7] = KernelManager->AddKernel<TE, 7, INGROUND, INGROUND>( );
  464. ik[8] = KernelManager->AddKernel<TE, 8, INGROUND, INGROUND>( );
  465. ik[9] = KernelManager->AddKernel<TE, 9, INGROUND, INGROUND>( );
  466. }
  467. break;
  468. case BOTH:
  469. if (lays == 0 && layr == 0) {
  470. ik[5] = KernelManager->AddKernel<TM, 5, INAIR, INAIR>( );
  471. ik[6] = KernelManager->AddKernel<TM, 6, INAIR, INAIR>( );
  472. ik[2] = KernelManager->AddKernel<TE, 2, INAIR, INAIR>( );
  473. ik[3] = KernelManager->AddKernel<TE, 3, INAIR, INAIR>( );
  474. ik[7] = KernelManager->AddKernel<TE, 7, INAIR, INAIR>( );
  475. ik[8] = KernelManager->AddKernel<TE, 8, INAIR, INAIR>( );
  476. ik[9] = KernelManager->AddKernel<TE, 9, INAIR, INAIR>( );
  477. } else if (lays == 0 && layr > 0) {
  478. ik[5] = KernelManager->AddKernel<TM, 5, INAIR, INGROUND>( );
  479. ik[6] = KernelManager->AddKernel<TM, 6, INAIR, INGROUND>( );
  480. ik[2] = KernelManager->AddKernel<TE, 2, INAIR, INGROUND>( );
  481. ik[3] = KernelManager->AddKernel<TE, 3, INAIR, INGROUND>( );
  482. ik[7] = KernelManager->AddKernel<TE, 7, INAIR, INGROUND>( );
  483. ik[8] = KernelManager->AddKernel<TE, 8, INAIR, INGROUND>( );
  484. ik[9] = KernelManager->AddKernel<TE, 9, INAIR, INGROUND>( );
  485. } else if (lays > 0 && layr == 0) {
  486. ik[5] = KernelManager->AddKernel<TM, 5, INGROUND, INAIR>( );
  487. ik[6] = KernelManager->AddKernel<TM, 6, INGROUND, INAIR>( );
  488. ik[2] = KernelManager->AddKernel<TE, 2, INGROUND, INAIR>( );
  489. ik[3] = KernelManager->AddKernel<TE, 3, INGROUND, INAIR>( );
  490. ik[7] = KernelManager->AddKernel<TE, 7, INGROUND, INAIR>( );
  491. ik[8] = KernelManager->AddKernel<TE, 8, INGROUND, INAIR>( );
  492. ik[9] = KernelManager->AddKernel<TE, 9, INGROUND, INAIR>( );
  493. } else {
  494. ik[5] = KernelManager->AddKernel<TM, 5, INGROUND, INGROUND>( );
  495. ik[6] = KernelManager->AddKernel<TM, 6, INGROUND, INGROUND>( );
  496. ik[2] = KernelManager->AddKernel<TE, 2, INGROUND, INGROUND>( );
  497. ik[3] = KernelManager->AddKernel<TE, 3, INGROUND, INGROUND>( );
  498. ik[7] = KernelManager->AddKernel<TE, 7, INGROUND, INGROUND>( );
  499. ik[8] = KernelManager->AddKernel<TE, 8, INGROUND, INGROUND>( );
  500. ik[9] = KernelManager->AddKernel<TE, 9, INGROUND, INGROUND>( );
  501. }
  502. break;
  503. }
  504. }
  505. break;
  506. case (MAGNETICDIPOLE):
  507. if (std::abs(Pol[2]) > 0) { // z dipole
  508. switch (FieldsToCalculate) {
  509. case E:
  510. if (lays == 0 && layr == 0) {
  511. ik[12] = KernelManager->AddKernel<TE, 12, INAIR, INAIR>( );
  512. } else if (lays == 0 && layr > 0) {
  513. ik[12] = KernelManager->AddKernel<TE, 12, INAIR, INGROUND>( );
  514. } else if (lays > 0 && layr == 0) {
  515. ik[12] = KernelManager->AddKernel<TE, 12, INGROUND, INAIR>( );
  516. } else {
  517. ik[12] = KernelManager->AddKernel<TE, 12, INGROUND, INGROUND>( );
  518. }
  519. break;
  520. case H:
  521. if (lays == 0 && layr == 0) {
  522. ik[10] = KernelManager->AddKernel<TE, 10, INAIR, INAIR>( );
  523. ik[11] = KernelManager->AddKernel<TE, 11, INAIR, INAIR>( );
  524. } else if (lays == 0 && layr > 0) {
  525. ik[10] = KernelManager->AddKernel<TE, 10, INAIR, INGROUND>( );
  526. ik[11] = KernelManager->AddKernel<TE, 11, INAIR, INGROUND>( );
  527. } else if (lays > 0 && layr == 0) {
  528. ik[10] = KernelManager->AddKernel<TE, 10, INGROUND, INAIR>( );
  529. ik[11] = KernelManager->AddKernel<TE, 11, INGROUND, INAIR>( );
  530. } else {
  531. ik[10] = KernelManager->AddKernel<TE, 10, INGROUND, INGROUND>( );
  532. ik[11] = KernelManager->AddKernel<TE, 11, INGROUND, INGROUND>( );
  533. }
  534. break;
  535. case BOTH:
  536. if (lays == 0 && layr == 0) {
  537. ik[12] = KernelManager->AddKernel<TE, 12, INAIR, INAIR>( );
  538. ik[10] = KernelManager->AddKernel<TE, 10, INAIR, INAIR>( );
  539. ik[11] = KernelManager->AddKernel<TE, 11, INAIR, INAIR>( );
  540. } else if (lays == 0 && layr > 0) {
  541. ik[12] = KernelManager->AddKernel<TE, 12, INAIR, INGROUND>( );
  542. ik[10] = KernelManager->AddKernel<TE, 10, INAIR, INGROUND>( );
  543. ik[11] = KernelManager->AddKernel<TE, 11, INAIR, INGROUND>( );
  544. } else if (lays > 0 && layr == 0) {
  545. ik[12] = KernelManager->AddKernel<TE, 12, INGROUND, INAIR>( );
  546. ik[10] = KernelManager->AddKernel<TE, 10, INGROUND, INAIR>( );
  547. ik[11] = KernelManager->AddKernel<TE, 11, INGROUND, INAIR>( );
  548. } else {
  549. ik[12] = KernelManager->AddKernel<TE, 12, INGROUND, INGROUND>( );
  550. ik[10] = KernelManager->AddKernel<TE, 10, INGROUND, INGROUND>( );
  551. ik[11] = KernelManager->AddKernel<TE, 11, INGROUND, INGROUND>( );
  552. }
  553. }
  554. }
  555. if (std::abs(Pol[1]) > 0 || std::abs(Pol[0]) > 0) { // x or y grounded HED dipole
  556. switch (FieldsToCalculate) {
  557. case E:
  558. if ( lays == 0 && layr == 0) {
  559. ik[5] = KernelManager->AddKernel<TE, 5, INAIR, INAIR>( );
  560. ik[6] = KernelManager->AddKernel<TE, 6, INAIR, INAIR>( );
  561. ik[7] = KernelManager->AddKernel<TM, 7, INAIR, INAIR>( );
  562. ik[8] = KernelManager->AddKernel<TM, 8, INAIR, INAIR>( );
  563. ik[9] = KernelManager->AddKernel<TM, 9, INAIR, INAIR>( );
  564. } else if (lays == 0 && layr > 0) {
  565. ik[5] = KernelManager->AddKernel<TE, 5, INAIR, INGROUND>( );
  566. ik[6] = KernelManager->AddKernel<TE, 6, INAIR, INGROUND>( );
  567. ik[7] = KernelManager->AddKernel<TM, 7, INAIR, INGROUND>( );
  568. ik[8] = KernelManager->AddKernel<TM, 8, INAIR, INGROUND>( );
  569. ik[9] = KernelManager->AddKernel<TM, 9, INAIR, INGROUND>( );
  570. } else if (lays > 0 && layr == 0) {
  571. ik[5] = KernelManager->AddKernel<TE, 5, INGROUND, INAIR>( );
  572. ik[6] = KernelManager->AddKernel<TE, 6, INGROUND, INAIR>( );
  573. ik[7] = KernelManager->AddKernel<TM, 7, INGROUND, INAIR>( );
  574. ik[8] = KernelManager->AddKernel<TM, 8, INGROUND, INAIR>( );
  575. ik[9] = KernelManager->AddKernel<TM, 9, INGROUND, INAIR>( );
  576. } else {
  577. ik[5] = KernelManager->AddKernel<TE, 5, INGROUND, INGROUND>( );
  578. ik[6] = KernelManager->AddKernel<TE, 6, INGROUND, INGROUND>( );
  579. ik[7] = KernelManager->AddKernel<TM, 7, INGROUND, INGROUND>( );
  580. ik[8] = KernelManager->AddKernel<TM, 8, INGROUND, INGROUND>( );
  581. ik[9] = KernelManager->AddKernel<TM, 9, INGROUND, INGROUND>( );
  582. }
  583. break;
  584. case H:
  585. if ( lays == 0 && layr == 0) {
  586. ik[0] = KernelManager->AddKernel<TE, 0, INAIR, INAIR>( );
  587. ik[1] = KernelManager->AddKernel<TE, 1, INAIR, INAIR>( );
  588. ik[4] = KernelManager->AddKernel<TE, 4, INAIR, INAIR>( );
  589. ik[2] = KernelManager->AddKernel<TM, 2, INAIR, INAIR>( );
  590. ik[3] = KernelManager->AddKernel<TM, 3, INAIR, INAIR>( );
  591. } else if (lays == 0 && layr > 0) {
  592. ik[0] = KernelManager->AddKernel<TE, 0, INAIR, INGROUND>( );
  593. ik[1] = KernelManager->AddKernel<TE, 1, INAIR, INGROUND>( );
  594. ik[4] = KernelManager->AddKernel<TE, 4, INAIR, INGROUND>( );
  595. ik[2] = KernelManager->AddKernel<TM, 2, INAIR, INGROUND>( );
  596. ik[3] = KernelManager->AddKernel<TM, 3, INAIR, INGROUND>( );
  597. } else if (lays > 0 && layr == 0) {
  598. ik[0] = KernelManager->AddKernel<TE, 0, INGROUND, INAIR>( );
  599. ik[1] = KernelManager->AddKernel<TE, 1, INGROUND, INAIR>( );
  600. ik[4] = KernelManager->AddKernel<TE, 4, INGROUND, INAIR>( );
  601. ik[2] = KernelManager->AddKernel<TM, 2, INGROUND, INAIR>( );
  602. ik[3] = KernelManager->AddKernel<TM, 3, INGROUND, INAIR>( );
  603. } else {
  604. ik[0] = KernelManager->AddKernel<TE, 0, INGROUND, INGROUND>( );
  605. ik[1] = KernelManager->AddKernel<TE, 1, INGROUND, INGROUND>( );
  606. ik[4] = KernelManager->AddKernel<TE, 4, INGROUND, INGROUND>( );
  607. ik[2] = KernelManager->AddKernel<TM, 2, INGROUND, INGROUND>( );
  608. ik[3] = KernelManager->AddKernel<TM, 3, INGROUND, INGROUND>( );
  609. }
  610. break;
  611. case BOTH:
  612. if ( lays == 0 && layr == 0) {
  613. ik[5] = KernelManager->AddKernel<TE, 5, INAIR, INAIR>( );
  614. ik[6] = KernelManager->AddKernel<TE, 6, INAIR, INAIR>( );
  615. ik[7] = KernelManager->AddKernel<TM, 7, INAIR, INAIR>( );
  616. ik[8] = KernelManager->AddKernel<TM, 8, INAIR, INAIR>( );
  617. ik[9] = KernelManager->AddKernel<TM, 9, INAIR, INAIR>( );
  618. ik[0] = KernelManager->AddKernel<TE, 0, INAIR, INAIR>( );
  619. ik[1] = KernelManager->AddKernel<TE, 1, INAIR, INAIR>( );
  620. ik[4] = KernelManager->AddKernel<TE, 4, INAIR, INAIR>( );
  621. ik[2] = KernelManager->AddKernel<TM, 2, INAIR, INAIR>( );
  622. ik[3] = KernelManager->AddKernel<TM, 3, INAIR, INAIR>( );
  623. } else if (lays == 0 && layr > 0) {
  624. ik[5] = KernelManager->AddKernel<TE, 5, INAIR, INGROUND>( );
  625. ik[6] = KernelManager->AddKernel<TE, 6, INAIR, INGROUND>( );
  626. ik[7] = KernelManager->AddKernel<TM, 7, INAIR, INGROUND>( );
  627. ik[8] = KernelManager->AddKernel<TM, 8, INAIR, INGROUND>( );
  628. ik[9] = KernelManager->AddKernel<TM, 9, INAIR, INGROUND>( );
  629. ik[0] = KernelManager->AddKernel<TE, 0, INAIR, INGROUND>( );
  630. ik[1] = KernelManager->AddKernel<TE, 1, INAIR, INGROUND>( );
  631. ik[4] = KernelManager->AddKernel<TE, 4, INAIR, INGROUND>( );
  632. ik[2] = KernelManager->AddKernel<TM, 2, INAIR, INGROUND>( );
  633. ik[3] = KernelManager->AddKernel<TM, 3, INAIR, INGROUND>( );
  634. } else {
  635. ik[5] = KernelManager->AddKernel<TE, 5, INGROUND, INGROUND>( );
  636. ik[6] = KernelManager->AddKernel<TE, 6, INGROUND, INGROUND>( );
  637. ik[7] = KernelManager->AddKernel<TM, 7, INGROUND, INGROUND>( );
  638. ik[8] = KernelManager->AddKernel<TM, 8, INGROUND, INGROUND>( );
  639. ik[9] = KernelManager->AddKernel<TM, 9, INGROUND, INGROUND>( );
  640. ik[0] = KernelManager->AddKernel<TE, 0, INGROUND, INGROUND>( );
  641. ik[1] = KernelManager->AddKernel<TE, 1, INGROUND, INGROUND>( );
  642. ik[4] = KernelManager->AddKernel<TE, 4, INGROUND, INGROUND>( );
  643. ik[2] = KernelManager->AddKernel<TM, 2, INGROUND, INGROUND>( );
  644. ik[3] = KernelManager->AddKernel<TM, 3, INGROUND, INGROUND>( );
  645. }
  646. break;
  647. }
  648. }
  649. break;
  650. default:
  651. std::cerr << "Dipole type incorrect, in dipolesource.cpp";
  652. exit(EXIT_FAILURE);
  653. }
  654. }
  655. void DipoleSource::UpdateFields( const int& ifreq, HankelTransform* Hankel, const Real& wavef) {
  656. Vector3r Pol = Phat;
  657. switch (Type) {
  658. case (GROUNDEDELECTRICDIPOLE):
  659. //Hankel->ComputeRelated(rho, KernelManager);
  660. if (std::abs(Pol[2]) > 0) { // z dipole
  661. switch(FieldsToCalculate) {
  662. case E:
  663. f(10) = Hankel->Zgauss(10, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[10])) / KernelManager->GetRAWKernel(ik[10])->GetYm();
  664. f(11) = Hankel->Zgauss(11, TM, 0, rho, wavef, KernelManager->GetRAWKernel(ik[11])) / KernelManager->GetRAWKernel(ik[11])->GetYm();
  665. std::cout.precision(12);
  666. this->Receivers->AppendEfield(ifreq, irec,
  667. -Pol[2]*QPI*cp*f(10)*Moment,
  668. -Pol[2]*QPI*sp*f(10)*Moment,
  669. Pol[2]*QPI*f(11)*Moment);
  670. break;
  671. case H:
  672. f(12) = Hankel->Zgauss(12, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[12]));
  673. this->Receivers->AppendHfield(ifreq, irec,
  674. -Pol[2]*QPI*sp*f(12)*Moment,
  675. Pol[2]*QPI*cp*f(12)*Moment,
  676. 0. );
  677. break;
  678. case BOTH:
  679. f(10) = Hankel->Zgauss(10, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[10])) / KernelManager->GetRAWKernel(ik[10])->GetYm();
  680. f(11) = Hankel->Zgauss(11, TM, 0, rho, wavef, KernelManager->GetRAWKernel(ik[11])) / KernelManager->GetRAWKernel(ik[11])->GetYm();
  681. this->Receivers->AppendEfield(ifreq, irec,
  682. -Pol[2]*QPI*cp*f(10)*Moment,
  683. -Pol[2]*QPI*sp*f(10)*Moment,
  684. Pol[2]*QPI*f(11)*Moment );
  685. f(12) = Hankel->Zgauss(12, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[12]));
  686. this->Receivers->AppendHfield(ifreq, irec,
  687. -Pol[2]*QPI*sp*f(12)*Moment,
  688. Pol[2]*QPI*cp*f(12)*Moment,
  689. 0. );
  690. } // Fields to calculate Z polarity Electric dipole
  691. }
  692. if (std::abs(Pol[1]) > 0 || std::abs(Pol[0]) > 0) { // y dipole
  693. switch(FieldsToCalculate) {
  694. case E:
  695. f(2) = Hankel->Zgauss(2, TE, 0, rho, wavef, KernelManager->GetRAWKernel(ik[2])) * KernelManager->GetRAWKernel(ik[2])->GetZs();
  696. f(3) = Hankel->Zgauss(3, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[3])) * KernelManager->GetRAWKernel(ik[3])->GetZs();
  697. f(0) = Hankel->Zgauss(0, TM, 0, rho, wavef, KernelManager->GetRAWKernel(ik[0])) / KernelManager->GetRAWKernel(ik[0])->GetYm();
  698. f(1) = Hankel->Zgauss(1, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[1])) / KernelManager->GetRAWKernel(ik[1])->GetYm();
  699. f(4) = Hankel->Zgauss(4, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[4])) / KernelManager->GetRAWKernel(ik[4])->GetYm();
  700. if (std::abs(Pol[1]) > 0) {
  701. this->Receivers->AppendEfield(ifreq, irec,
  702. Pol[1]*QPI*scp*((f(0)-(Real)(2.)*f(1)/rho)+(f(2)-(Real)(2.)*f(3)/rho))*Moment,
  703. Pol[1]*QPI*((sps*f(0)+c2p*f(1)/rho)-(cps*f(2)-c2p*f(3)/rho))*Moment,
  704. Pol[1]*QPI*sp*f(4)*Moment);
  705. }
  706. if (std::abs(Pol[0]) > 0) {
  707. this->Receivers->AppendEfield(ifreq, irec,
  708. Pol[0]*Moment*QPI*((cps*f(0)-c2p*f(1)/rho)-(sps*f(2)+c2p*f(3)/rho)),
  709. Pol[0]*Moment*QPI*scp*((f(0)-(Real)(2.)*f(1)/rho)+(f(2)-(Real)(2.)*f(3)/rho)),
  710. Pol[0]*Moment*QPI*cp*f(4) );
  711. }
  712. break;
  713. case H:
  714. f(5) = Hankel->Zgauss(5, TM, 0, rho, wavef, KernelManager->GetRAWKernel(ik[5]));
  715. f(6) = Hankel->Zgauss(6, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[6]));
  716. f(7) = Hankel->Zgauss(7, TE, 0, rho, wavef, KernelManager->GetRAWKernel(ik[7]))*KernelManager->GetRAWKernel(ik[7])->GetZs()/KernelManager->GetRAWKernel(ik[7])->GetZm();
  717. f(8) = Hankel->Zgauss(8, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[8]))*KernelManager->GetRAWKernel(ik[8])->GetZs()/KernelManager->GetRAWKernel(ik[8])->GetZm();
  718. f(9) = Hankel->Zgauss(9, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[9]))*KernelManager->GetRAWKernel(ik[9])->GetZs()/KernelManager->GetRAWKernel(ik[9])->GetZm();
  719. if (std::abs(Pol[1]) > 0) {
  720. this->Receivers->AppendHfield(ifreq, irec,
  721. Pol[1]*QPI*(sps*f(5)+c2p*f(6)/rho-cps*f(7)+c2p*f(8)/rho)*Moment,
  722. Pol[1]*QPI*scp*(-f(5)+(Real)(2.)*f(6)/rho-f(7)+(Real)(2.)*f(8)/rho)*Moment,
  723. -Pol[1]*QPI*cp*f(9)*Moment );
  724. }
  725. if (std::abs(Pol[0]) > 0) {
  726. this->Receivers->AppendHfield(ifreq, irec,
  727. Pol[0]*Moment*QPI*scp*(f(5)-(Real)(2.)*f(6)/rho+f(7)-(Real)(2.)*f(8)/rho),
  728. Pol[0]*Moment*QPI*(-cps*f(5)+c2p*f(6)/rho+sps*f(7)+c2p*f(8)/rho),
  729. Pol[0]*Moment*QPI*sp*f(9) );
  730. }
  731. break;
  732. case BOTH:
  733. f(0) = Hankel->Zgauss(0, TM, 0, rho, wavef, KernelManager->GetRAWKernel(ik[0])) / KernelManager->GetRAWKernel(ik[0])->GetYm();
  734. f(1) = Hankel->Zgauss(1, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[1])) / KernelManager->GetRAWKernel(ik[1])->GetYm();
  735. f(4) = Hankel->Zgauss(4, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[4])) / KernelManager->GetRAWKernel(ik[4])->GetYm();
  736. f(2) = Hankel->Zgauss(2, TE, 0, rho, wavef, KernelManager->GetRAWKernel(ik[2])) * KernelManager->GetRAWKernel(ik[2])->GetZs();
  737. f(3) = Hankel->Zgauss(3, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[3])) * KernelManager->GetRAWKernel(ik[3])->GetZs();
  738. f(5) = Hankel->Zgauss(5, TM, 0, rho, wavef, KernelManager->GetRAWKernel(ik[5]));
  739. f(6) = Hankel->Zgauss(6, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[6]));
  740. f(7) = Hankel->Zgauss(7, TE, 0, rho, wavef, KernelManager->GetRAWKernel(ik[7]))*KernelManager->GetRAWKernel(ik[7])->GetZs()/KernelManager->GetRAWKernel(ik[7])->GetZm();
  741. f(8) = Hankel->Zgauss(8, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[8]))*KernelManager->GetRAWKernel(ik[8])->GetZs()/KernelManager->GetRAWKernel(ik[8])->GetZm();
  742. f(9) = Hankel->Zgauss(9, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[9]))*KernelManager->GetRAWKernel(ik[9])->GetZs()/KernelManager->GetRAWKernel(ik[9])->GetZm();
  743. if (std::abs(Pol[1]) > 0) {
  744. this->Receivers->AppendEfield(ifreq, irec,
  745. Pol[1]*QPI*scp*((f(0)-(Real)(2.)*f(1)/rho)+(f(2)-(Real)(2.)*f(3)/rho))*Moment ,
  746. Pol[1]*QPI*((sps*f(0)+c2p*f(1)/rho)-(cps*f(2)-c2p*f(3)/rho))*Moment,
  747. Pol[1]*QPI*sp*f(4)*Moment);
  748. this->Receivers->AppendHfield(ifreq, irec,
  749. Pol[1]*QPI*(sps*f(5)+c2p*f(6)/rho-cps*f(7)+c2p*f(8)/rho)*Moment,
  750. Pol[1]*QPI*scp*(-f(5)+(Real)(2.)*f(6)/rho-f(7)+(Real)(2.)*f(8)/rho)*Moment,
  751. -Pol[1]*QPI*cp*f(9)*Moment );
  752. }
  753. if (std::abs(Pol[0]) > 0) {
  754. this->Receivers->AppendEfield(ifreq, irec,
  755. Pol[0]*Moment*QPI*((cps*f(0)-c2p*f(1)/rho)-(sps*f(2)+c2p*f(3)/rho)),
  756. Pol[0]*Moment*QPI*scp*((f(0)-(Real)(2.)*f(1)/rho)+(f(2)-(Real)(2.)*f(3)/rho)),
  757. Pol[0]*Moment*QPI*cp*f(4) );
  758. this->Receivers->AppendHfield(ifreq, irec,
  759. Pol[0]*Moment*QPI*scp*(f(5)-(Real)(2.)*f(6)/rho+f(7)-(Real)(2.)*f(8)/rho),
  760. Pol[0]*Moment*QPI*(-cps*f(5)+c2p*f(6)/rho+sps*f(7)+c2p*f(8)/rho),
  761. Pol[0]*Moment*QPI*sp*f(9) );
  762. }
  763. break;
  764. }
  765. }
  766. break; // GROUNDEDELECTRICDIPOLE
  767. case UNGROUNDEDELECTRICDIPOLE:
  768. if (std::abs(Pol[2]) > 0) { // z dipole
  769. switch(FieldsToCalculate) {
  770. case E:
  771. f(10) = 0;
  772. f(11) = Hankel->Zgauss(11, TM, 0, rho, wavef, KernelManager->GetRAWKernel(ik[11])) / KernelManager->GetRAWKernel(ik[11])->GetYm();
  773. this->Receivers->AppendEfield(ifreq, irec,
  774. -Pol[2]*QPI*cp*f(10)*Moment,
  775. -Pol[2]*QPI*sp*f(10)*Moment,
  776. Pol[2]*QPI*f(11)*Moment);
  777. break;
  778. case H:
  779. f(12) = Hankel->Zgauss(12, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[12]));
  780. this->Receivers->AppendHfield(ifreq, irec,
  781. -Pol[2]*QPI*sp*f(12)*Moment,
  782. Pol[2]*QPI*cp*f(12)*Moment,
  783. 0. );
  784. break;
  785. case BOTH:
  786. f(10) = 0;
  787. f(11) = Hankel->Zgauss(11, TM, 0, rho, wavef, KernelManager->GetRAWKernel(ik[11])) / KernelManager->GetRAWKernel(ik[11])->GetYm();
  788. this->Receivers->AppendEfield(ifreq, irec,
  789. -Pol[2]*QPI*cp*f(10)*Moment,
  790. -Pol[2]*QPI*sp*f(10)*Moment,
  791. Pol[2]*QPI*f(11)*Moment );
  792. f(12) = Hankel->Zgauss(12, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[12]));
  793. this->Receivers->AppendHfield(ifreq, irec,
  794. -Pol[2]*QPI*sp*f(12)*Moment,
  795. Pol[2]*QPI*cp*f(12)*Moment,
  796. 0. );
  797. } // Fields to calculate Z polarity Electric dipole
  798. }
  799. if (std::abs(Pol[1]) > 0 || std::abs(Pol[0]) > 0) { // x or y dipole
  800. switch(FieldsToCalculate) {
  801. case E:
  802. f(0) = 0;
  803. f(1) = 0;
  804. f(2) = Hankel->Zgauss(2, TE, 0, rho, wavef, KernelManager->GetRAWKernel(ik[2])) * KernelManager->GetRAWKernel(ik[2])->GetZs();
  805. f(3) = Hankel->Zgauss(3, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[3])) * KernelManager->GetRAWKernel(ik[3])->GetZs();
  806. f(4) = 0;
  807. if (std::abs(Pol[1]) > 0) {
  808. this->Receivers->AppendEfield(ifreq, irec,
  809. Pol[1]*QPI*scp*((f(0)-(Real)(2.)*f(1)/rho)+(f(2)-(Real)(2.)*f(3)/rho))*Moment,
  810. Pol[1]*QPI*((sps*f(0)+c2p*f(1)/rho)-(cps*f(2)-c2p*f(3)/rho))*Moment,
  811. Pol[1]*QPI*sp*f(4)*Moment);
  812. }
  813. if (std::abs(Pol[0]) > 0) {
  814. this->Receivers->AppendEfield(ifreq, irec,
  815. Pol[0]*Moment*QPI*((cps*f(0)-c2p*f(1)/rho)-(sps*f(2)+c2p*f(3)/rho)),
  816. Pol[0]*Moment*QPI*scp*((f(0)-(Real)(2.)*f(1)/rho)+(f(2)-(Real)(2.)*f(3)/rho)),
  817. Pol[0]*Moment*QPI*cp*f(4) );
  818. }
  819. break;
  820. case H:
  821. f(5) = Hankel->Zgauss(5, TM, 0, rho, wavef, KernelManager->GetRAWKernel(ik[5]));
  822. f(6) = Hankel->Zgauss(6, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[6]));
  823. f(7) = Hankel->Zgauss(7, TE, 0, rho, wavef, KernelManager->GetRAWKernel(ik[7]))*KernelManager->GetRAWKernel(ik[7])->GetZs()/KernelManager->GetRAWKernel(ik[7])->GetZm();
  824. f(8) = Hankel->Zgauss(8, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[8]))*KernelManager->GetRAWKernel(ik[8])->GetZs()/KernelManager->GetRAWKernel(ik[8])->GetZm();
  825. f(9) = Hankel->Zgauss(9, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[9]))*KernelManager->GetRAWKernel(ik[9])->GetZs()/KernelManager->GetRAWKernel(ik[9])->GetZm();
  826. if (std::abs(Pol[1]) > 0) {
  827. this->Receivers->AppendHfield(ifreq, irec,
  828. Pol[1]*QPI*(sps*f(5)+c2p*f(6)/rho-cps*f(7)+c2p*f(8)/rho)*Moment,
  829. Pol[1]*QPI*scp*(-f(5)+(Real)(2.)*f(6)/rho-f(7)+(Real)(2.)*f(8)/rho)*Moment,
  830. -Pol[1]*QPI*cp*f(9)*Moment );
  831. // Analytic whole space solution could go here
  832. }
  833. if (std::abs(Pol[0]) > 0) {
  834. this->Receivers->AppendHfield(ifreq, irec,
  835. Pol[0]*Moment*QPI*scp*(f(5)-(Real)(2.)*f(6)/rho+f(7)-(Real)(2.)*f(8)/rho),
  836. Pol[0]*Moment*QPI*(-cps*f(5)+c2p*f(6)/rho+sps*f(7)+c2p*f(8)/rho),
  837. Pol[0]*Moment*QPI*sp*f(9) );
  838. // Analytic whole space solution
  839. }
  840. break;
  841. case BOTH:
  842. f(0) = 0;
  843. f(1) = 0;
  844. f(4) = 0;
  845. f(2) = Hankel->Zgauss(2, TE, 0, rho, wavef, KernelManager->GetRAWKernel(ik[2])) * KernelManager->GetRAWKernel(0)->GetZs();
  846. f(3) = Hankel->Zgauss(3, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[3])) * KernelManager->GetRAWKernel(1)->GetZs();
  847. f(5) = Hankel->Zgauss(5, TM, 0, rho, wavef, KernelManager->GetRAWKernel(ik[5]));
  848. f(6) = Hankel->Zgauss(6, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[6]));
  849. f(7) = Hankel->Zgauss(7, TE, 0, rho, wavef, KernelManager->GetRAWKernel(ik[7]))*KernelManager->GetRAWKernel(ik[7])->GetZs()/KernelManager->GetRAWKernel(ik[7])->GetZm();
  850. f(8) = Hankel->Zgauss(8, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[8]))*KernelManager->GetRAWKernel(ik[8])->GetZs()/KernelManager->GetRAWKernel(ik[8])->GetZm();
  851. f(9) = Hankel->Zgauss(9, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[9]))*KernelManager->GetRAWKernel(ik[9])->GetZs()/KernelManager->GetRAWKernel(ik[9])->GetZm();
  852. if (std::abs(Pol[1]) > 0) {
  853. this->Receivers->AppendEfield(ifreq, irec,
  854. Pol[1]*QPI*scp*((f(0)-(Real)(2.)*f(1)/rho)+(f(2)-(Real)(2.)*f(3)/rho))*Moment ,
  855. Pol[1]*QPI*((sps*f(0)+c2p*f(1)/rho)-(cps*f(2)-c2p*f(3)/rho))*Moment,
  856. Pol[1]*QPI*sp*f(4)*Moment);
  857. this->Receivers->AppendHfield(ifreq, irec,
  858. Pol[1]*QPI*(sps*f(5)+c2p*f(6)/rho-cps*f(7)+c2p*f(8)/rho)*Moment,
  859. Pol[1]*QPI*scp*(-f(5)+(Real)(2.)*f(6)/rho-f(7)+(Real)(2.)*f(8)/rho)*Moment,
  860. -Pol[1]*QPI*cp*f(9)*Moment );
  861. }
  862. if (std::abs(Pol[0]) > 0) {
  863. this->Receivers->AppendEfield(ifreq, irec,
  864. Pol[0]*Moment*QPI*((cps*f(0)-c2p*f(1)/rho)-(sps*f(2)+c2p*f(3)/rho)),
  865. Pol[0]*Moment*QPI*scp*((f(0)-(Real)(2.)*f(1)/rho)+(f(2)-(Real)(2.)*f(3)/rho)),
  866. Pol[0]*Moment*QPI*cp*f(4) );
  867. this->Receivers->AppendHfield(ifreq, irec,
  868. Pol[0]*Moment*QPI*scp*(f(5)-(Real)(2.)*f(6)/rho+f(7)-(Real)(2.)*f(8)/rho),
  869. Pol[0]*Moment*QPI*(-cps*f(5)+c2p*f(6)/rho+sps*f(7)+c2p*f(8)/rho),
  870. Pol[0]*Moment*QPI*sp*f(9) );
  871. }
  872. break;
  873. }
  874. }
  875. break; // UNGROUNDEDELECTRICDIPOLE
  876. case MAGNETICDIPOLE:
  877. //Hankel->ComputeRelated(rho, KernelManager);
  878. if (std::abs(Pol[2]) > 0) { // z dipole
  879. switch(FieldsToCalculate) {
  880. case E:
  881. f(12)=Hankel->Zgauss(12, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[12]))*KernelManager->GetRAWKernel(ik[12])->GetZs();
  882. this->Receivers->AppendEfield(ifreq, irec,
  883. Pol[2]*Moment*QPI*sp*f(12),
  884. -Pol[2]*Moment*QPI*cp*f(12),
  885. 0);
  886. break;
  887. case H:
  888. f(10)=Hankel->Zgauss(10, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[10]))*KernelManager->GetRAWKernel(ik[10])->GetZs()/KernelManager->GetRAWKernel(ik[10])->GetZm();
  889. f(11)=Hankel->Zgauss(11, TE, 0, rho, wavef, KernelManager->GetRAWKernel(ik[11]))*KernelManager->GetRAWKernel(ik[11])->GetZs()/KernelManager->GetRAWKernel(ik[11])->GetZm();
  890. this->Receivers->AppendHfield(ifreq, irec,
  891. -Pol[2]*Moment*QPI*cp*f(10),
  892. -Pol[2]*Moment*QPI*sp*f(10),
  893. Pol[2]*Moment*QPI*f(11) );
  894. break;
  895. case BOTH:
  896. f(12)=Hankel->Zgauss(12, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[12]))*KernelManager->GetRAWKernel(ik[12])->GetZs();
  897. f(10)=Hankel->Zgauss(10, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[10]))*KernelManager->GetRAWKernel(ik[10])->GetZs()/KernelManager->GetRAWKernel(ik[10])->GetZm();
  898. f(11)=Hankel->Zgauss(11, TE, 0, rho, wavef, KernelManager->GetRAWKernel(ik[11]))*KernelManager->GetRAWKernel(ik[11])->GetZs()/KernelManager->GetRAWKernel(ik[11])->GetZm();
  899. this->Receivers->AppendEfield(ifreq, irec,
  900. Pol[2]*Moment*QPI*sp*f(12),
  901. -Pol[2]*Moment*QPI*cp*f(12),
  902. 0);
  903. this->Receivers->AppendHfield(ifreq, irec,
  904. -Pol[2]*Moment*QPI*cp*f(10),
  905. -Pol[2]*Moment*QPI*sp*f(10),
  906. Pol[2]*Moment*QPI*f(11) );
  907. break;
  908. }
  909. }
  910. if (std::abs(Pol[1]) > 0 || std::abs(Pol[0]) > 0) { // x or y grounded HED dipole
  911. switch (FieldsToCalculate) {
  912. case E:
  913. f(5) = Hankel->Zgauss(5, TE, 0, rho, wavef, KernelManager->GetRAWKernel(ik[5]))*KernelManager->GetRAWKernel(ik[5])->GetZs();
  914. f(6) = Hankel->Zgauss(6, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[6]))*KernelManager->GetRAWKernel(ik[6])->GetZs();
  915. f(7) = Hankel->Zgauss(7, TM, 0, rho, wavef, KernelManager->GetRAWKernel(ik[7]))*KernelManager->GetRAWKernel(ik[7])->GetKs()/KernelManager->GetRAWKernel(ik[7])->GetYm();
  916. f(8) = Hankel->Zgauss(8, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[8]))*KernelManager->GetRAWKernel(ik[8])->GetKs()/KernelManager->GetRAWKernel(ik[8])->GetYm();
  917. f(9) = Hankel->Zgauss(9, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[9]))*KernelManager->GetRAWKernel(ik[9])->GetKs()/KernelManager->GetRAWKernel(ik[9])->GetYm();
  918. if (std::abs(Pol[0]) > 0) {
  919. this->Receivers->AppendEfield(ifreq, irec,
  920. Pol[0]*Moment*QPI*scp*((-f(5)+(Real)(2.)*f(6)/rho)+(f(7)-(Real)(2.)*f(8)/rho)),
  921. Pol[0]*Moment*QPI*((cps*f(5)-c2p*f(6)/rho)+(sps*f(7)+c2p*f(8)/rho)),
  922. Pol[0]*Moment*QPI*sp*f(9));
  923. }
  924. if (std::abs(Pol[1]) > 0) {
  925. this->Receivers->AppendEfield(ifreq, irec,
  926. Pol[1]*Moment*QPI*(-(sps*f(5)+c2p*f(6)/rho)-(cps*f(7)-c2p*f(8)/rho)),
  927. Pol[1]*Moment*QPI*scp*((f(5)-(Real)(2.)*f(6)/rho)-(f(7)-(Real)(2.)*f(8)/rho)),
  928. -Pol[1]*Moment*QPI*cp*f(9) );
  929. }
  930. break;
  931. case H:
  932. f(0) = Hankel->Zgauss(0, TE, 0, rho, wavef, KernelManager->GetRAWKernel(ik[0]))*KernelManager->GetRAWKernel(ik[0])->GetZs()/KernelManager->GetRAWKernel(ik[0])->GetZm();
  933. f(1) = Hankel->Zgauss(1, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[1]))*KernelManager->GetRAWKernel(ik[1])->GetZs()/KernelManager->GetRAWKernel(ik[1])->GetZm();
  934. f(4) = Hankel->Zgauss(4, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[4]))*KernelManager->GetRAWKernel(ik[4])->GetZs()/KernelManager->GetRAWKernel(ik[4])->GetZm();
  935. f(2) = Hankel->Zgauss(2, TM, 0, rho, wavef, KernelManager->GetRAWKernel(ik[2]))*KernelManager->GetRAWKernel(ik[2])->GetKs();
  936. f(3) = Hankel->Zgauss(3, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[3]))*KernelManager->GetRAWKernel(ik[3])->GetKs();
  937. if (std::abs(Pol[0]) > 0) {
  938. this->Receivers->AppendHfield(ifreq, irec,
  939. Pol[0]*Moment*QPI*(cps*f(0)-c2p*f(1)/rho+(sps*f(2)+c2p*f(3)/rho)),
  940. Pol[0]*Moment*QPI*scp*(f(0)-(Real)(2.)*f(1)/rho-(f(2)-(Real)(2.)*f(3)/rho)),
  941. Pol[0]*Moment*QPI*cp*f(4) );
  942. }
  943. if (std::abs(Pol[1]) > 0) {
  944. this->Receivers->AppendHfield(ifreq, irec,
  945. Pol[1]*Moment*QPI*scp*(f(0)-(Real)(2.)*f(1)/rho-(f(2)-(Real)(2.)*f(3)/rho)),
  946. Pol[1]*Moment*QPI*(sps*f(0)+c2p*f(1)/rho+(cps*f(2)-c2p*f(3)/rho)),
  947. Pol[1]*Moment*QPI*sp*f(4));
  948. }
  949. break;
  950. case BOTH:
  951. f(5) = Hankel->Zgauss(5, TE, 0, rho, wavef, KernelManager->GetRAWKernel(ik[5]))*KernelManager->GetRAWKernel(ik[5])->GetZs();
  952. f(6) = Hankel->Zgauss(6, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[6]))*KernelManager->GetRAWKernel(ik[6])->GetZs();
  953. f(7) = Hankel->Zgauss(7, TM, 0, rho, wavef, KernelManager->GetRAWKernel(ik[7]))*KernelManager->GetRAWKernel(ik[7])->GetKs()/KernelManager->GetRAWKernel(ik[7])->GetYm();
  954. f(8) = Hankel->Zgauss(8, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[8]))*KernelManager->GetRAWKernel(ik[8])->GetKs()/KernelManager->GetRAWKernel(ik[8])->GetYm();
  955. f(9) = Hankel->Zgauss(9, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[9]))*KernelManager->GetRAWKernel(ik[9])->GetKs()/KernelManager->GetRAWKernel(ik[9])->GetYm();
  956. f(0) = Hankel->Zgauss(0, TE, 0, rho, wavef, KernelManager->GetRAWKernel(ik[0]))*KernelManager->GetRAWKernel(ik[0])->GetZs()/KernelManager->GetRAWKernel(ik[0])->GetZm();
  957. f(1) = Hankel->Zgauss(1, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[1]))*KernelManager->GetRAWKernel(ik[1])->GetZs()/KernelManager->GetRAWKernel(ik[1])->GetZm();
  958. f(4) = Hankel->Zgauss(4, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[4]))*KernelManager->GetRAWKernel(ik[4])->GetZs()/KernelManager->GetRAWKernel(ik[4])->GetZm();
  959. f(2) = Hankel->Zgauss(2, TM, 0, rho, wavef, KernelManager->GetRAWKernel(ik[2]))*KernelManager->GetRAWKernel(ik[2])->GetKs();
  960. f(3) = Hankel->Zgauss(3, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[3]))*KernelManager->GetRAWKernel(ik[3])->GetKs();
  961. if (std::abs(Pol[0]) > 0) {
  962. this->Receivers->AppendEfield(ifreq, irec,
  963. Pol[0]*Moment*QPI*scp*((-f(5)+(Real)(2.)*f(6)/rho)+(f(7)-(Real)(2.)*f(8)/rho)),
  964. Pol[0]*Moment*QPI*((cps*f(5)-c2p*f(6)/rho)+(sps*f(7)+c2p*f(8)/rho)),
  965. Pol[0]*Moment*QPI*sp*f(9));
  966. this->Receivers->AppendHfield(ifreq, irec,
  967. Pol[0]*Moment*QPI*(cps*f(0)-c2p*f(1)/rho+(sps*f(2)+c2p*f(3)/rho)),
  968. Pol[0]*Moment*QPI*scp*(f(0)-(Real)(2.)*f(1)/rho-(f(2)-(Real)(2.)*f(3)/rho)),
  969. Pol[0]*Moment*QPI*cp*f(4) );
  970. }
  971. if (std::abs(Pol[1]) > 0) {
  972. this->Receivers->AppendEfield(ifreq, irec,
  973. Pol[1]*Moment*QPI*(-(sps*f(5)+c2p*f(6)/rho)-(cps*f(7)-c2p*f(8)/rho)),
  974. Pol[1]*Moment*QPI*scp*((f(5)-(Real)(2.)*f(6)/rho)-(f(7)-(Real)(2.)*f(8)/rho)),
  975. -Pol[1]*Moment*QPI*cp*f(9) );
  976. this->Receivers->AppendHfield(ifreq, irec,
  977. Pol[1]*Moment*QPI*scp*(f(0)-(Real)(2.)*f(1)/rho-(f(2)-(Real)(2.)*f(3)/rho)),
  978. Pol[1]*Moment*QPI*(sps*f(0)+c2p*f(1)/rho+(cps*f(2)-c2p*f(3)/rho)),
  979. Pol[1]*Moment*QPI*sp*f(4));
  980. }
  981. break;
  982. }
  983. }
  984. break;
  985. case NOSOURCETYPE:
  986. throw NonValidDipoleType(this);
  987. } // Source Type Switch
  988. }
  989. // ==================== INQUIRY ======================
  990. std::shared_ptr<KernelEM1DManager> DipoleSource::GetKernelManager() {
  991. return KernelManager;
  992. }
  993. Vector3r DipoleSource::GetLocation() {
  994. return this->Location;
  995. }
  996. #ifdef LEMMAUSEVTK
  997. vtkActor* DipoleSource::GetVtkActor() {
  998. vtkActor* vActor;
  999. vtkLineSource* vLineSource;
  1000. vtkTubeFilter* vTube;
  1001. vtkPolyDataMapper* vMapper;
  1002. vtkRegularPolygonSource* vCircleSource;
  1003. vLineSource = vtkLineSource::New();
  1004. vTube = vtkTubeFilter::New();
  1005. vMapper = vtkPolyDataMapper::New();
  1006. vCircleSource = vtkRegularPolygonSource::New();
  1007. VectorXr M0 = Location - .5*Moment*Phat;
  1008. VectorXr M1 = Location + .5*Moment*Phat;
  1009. vActor = vtkActor::New();
  1010. switch (Type) {
  1011. case GROUNDEDELECTRICDIPOLE:
  1012. vLineSource->SetPoint1( M0(0), M0(1), M0(2));
  1013. vLineSource->SetPoint2( M1(0), M1(1), M1(2));
  1014. vTube->SetInputConnection(vLineSource->GetOutputPort());
  1015. vTube->SetRadius(.1 * std::abs(Moment));
  1016. vTube->SetNumberOfSides(6);
  1017. vTube->SetCapping(1);
  1018. vMapper->SetInputConnection(vTube->GetOutputPort());
  1019. vActor->SetMapper(vMapper);
  1020. vActor->GetProperty()->SetColor(Phat[0], Phat[1], Phat[2]);
  1021. break;
  1022. case UNGROUNDEDELECTRICDIPOLE:
  1023. vLineSource->SetPoint1( M0(0), M0(1), M0(2));
  1024. vLineSource->SetPoint2( M1(0), M1(1), M1(2));
  1025. vTube->SetInputConnection(vLineSource->GetOutputPort());
  1026. vTube->SetRadius(.1 * std::abs(Moment));
  1027. vTube->SetNumberOfSides(6);
  1028. vTube->SetCapping(1);
  1029. vMapper->SetInputConnection(vTube->GetOutputPort());
  1030. vActor->SetMapper(vMapper);
  1031. //vActor->GetProperty()->SetColor(Phat[0], Phat[1], Phat[2]);
  1032. vActor->GetProperty()->SetColor(rand()/(Real)(RAND_MAX), rand()/(Real)(RAND_MAX), rand()/(Real)(RAND_MAX));
  1033. vActor->GetProperty()->SetOpacity(1.);
  1034. break;
  1035. case MAGNETICDIPOLE:
  1036. vCircleSource->SetCenter(Location(0), Location(1),
  1037. Location(2));
  1038. vCircleSource->SetNumberOfSides(360);
  1039. vCircleSource->SetNormal(Phat[0], Phat[1], Phat[2]);
  1040. vCircleSource->SetRadius(0.2); // .2 m radius
  1041. vCircleSource->SetGeneratePolygon(false);
  1042. vCircleSource->SetGeneratePolyline(true);
  1043. vCircleSource->Update();
  1044. vTube->SetInputConnection(vCircleSource->GetOutputPort());
  1045. //vTube->SetRadius( max((float)(*xCoords->GetTuple(nx)),
  1046. // (float)(*yCoords->GetTuple(ny))) / 100);
  1047. vTube->SetRadius(.1*std::abs(Moment));
  1048. vTube->SetNumberOfSides(6);
  1049. vTube->SetCapping(1);
  1050. vMapper->SetInputConnection(vTube->GetOutputPort());
  1051. vActor->SetMapper(vMapper);
  1052. vActor->GetProperty()->SetColor(.9,.2,.9);
  1053. break;
  1054. default:
  1055. throw NonValidDipoleType();
  1056. }
  1057. vLineSource->Delete();
  1058. vCircleSource->Delete();
  1059. vTube->Delete();
  1060. vMapper->Delete();
  1061. return vActor;
  1062. }
  1063. #endif
  1064. Real DipoleSource::GetLocation(const int& coordinate) {
  1065. switch (coordinate) {
  1066. case (0):
  1067. return this->Location.x();
  1068. break;
  1069. case (1):
  1070. return this->Location.y();
  1071. break;
  1072. case (2):
  1073. return this->Location.z();
  1074. break;
  1075. default:
  1076. throw NonValidLocationCoordinate( );
  1077. }
  1078. }
  1079. DipoleSourceType DipoleSource::GetDipoleSourceType() {
  1080. return this->Type;
  1081. }
  1082. //DipoleSourcePolarisation DipoleSource::GetDipoleSourcePolarisation() {
  1083. // return this->Polarisation;
  1084. //}
  1085. Real DipoleSource::GetAngularFrequency(const int& ifreq) {
  1086. return 2.*PI*this->Freqs(ifreq);
  1087. }
  1088. Real DipoleSource::GetFrequency(const int& ifreq) {
  1089. return this->Freqs(ifreq);
  1090. }
  1091. VectorXr DipoleSource::GetFrequencies( ) {
  1092. return this->Freqs;
  1093. }
  1094. Real DipoleSource::GetPhase() {
  1095. return this->Phase;
  1096. }
  1097. Real DipoleSource::GetMoment() {
  1098. return this->Moment;
  1099. }
  1100. int DipoleSource::GetNumberOfFrequencies() {
  1101. return this->Freqs.size();
  1102. }
  1103. void DipoleSource::SetNumberOfFrequencies(const int &nfreq){
  1104. Freqs.resize(nfreq);
  1105. Freqs.setZero();
  1106. }
  1107. void DipoleSource::SetFrequency(const int &ifreq, const Real &freq){
  1108. Freqs(ifreq) = freq;
  1109. }
  1110. void DipoleSource::SetFrequencies(const VectorXr &freqs){
  1111. Freqs = freqs;
  1112. }
  1113. /////////////////////////////////////////////////////////////////
  1114. /////////////////////////////////////////////////////////////////
  1115. // Error classes
  1116. NullDipoleSource::NullDipoleSource() :
  1117. runtime_error( "NULL VALUED DIPOLE SOURCE") {}
  1118. NonValidDipoleTypeAssignment::NonValidDipoleTypeAssignment( ) :
  1119. runtime_error( "NON VALID DIPOLE TYPE ASSIGNMENT") { }
  1120. NonValidDipoleType::NonValidDipoleType( LemmaObject* ptr ) :
  1121. runtime_error( "NON VALID DIPOLE TYPE") {
  1122. std::cout << "Thrown by instance of "
  1123. << ptr->GetName() << std::endl;
  1124. }
  1125. NonValidDipoleType::NonValidDipoleType( ) :
  1126. runtime_error( "NON VALID DIPOLE TYPE") { }
  1127. NonValidDipolePolarity::NonValidDipolePolarity () :
  1128. runtime_error( "NON VALID DIPOLE POLARITY") { }
  1129. NonValidDipolePolarisation::NonValidDipolePolarisation( ) :
  1130. runtime_error( "NON VALID DIPOLE TYPE") { }
  1131. NonValidDipolePolarisationAssignment::
  1132. NonValidDipolePolarisationAssignment( ) :
  1133. runtime_error( "NON VALID DIPOLE POLARISATION ASSIGNMENT") { }
  1134. NonValidLocationCoordinate::NonValidLocationCoordinate( ) :
  1135. runtime_error( "NON VALID LOCATION COORDINATE REQUESTED") { }
  1136. }