Main Lemma Repository
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

DipoleSource.cpp 74KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321
  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. //Hankel->ComputeRelated(rho, KernelManager);
  769. if (std::abs(Pol[2]) > 0) { // z dipole
  770. switch(FieldsToCalculate) {
  771. case E:
  772. f(10) = 0;
  773. f(11) = Hankel->Zgauss(11, TM, 0, rho, wavef, KernelManager->GetRAWKernel(ik[11])) / KernelManager->GetRAWKernel(ik[11])->GetYm();
  774. this->Receivers->AppendEfield(ifreq, irec,
  775. -Pol[2]*QPI*cp*f(10)*Moment,
  776. -Pol[2]*QPI*sp*f(10)*Moment,
  777. Pol[2]*QPI*f(11)*Moment);
  778. break;
  779. case H:
  780. f(12) = Hankel->Zgauss(12, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[12]));
  781. this->Receivers->AppendHfield(ifreq, irec,
  782. -Pol[2]*QPI*sp*f(12)*Moment,
  783. Pol[2]*QPI*cp*f(12)*Moment,
  784. 0. );
  785. break;
  786. case BOTH:
  787. f(10) = 0;
  788. f(11) = Hankel->Zgauss(11, TM, 0, rho, wavef, KernelManager->GetRAWKernel(ik[11])) / KernelManager->GetRAWKernel(ik[11])->GetYm();
  789. this->Receivers->AppendEfield(ifreq, irec,
  790. -Pol[2]*QPI*cp*f(10)*Moment,
  791. -Pol[2]*QPI*sp*f(10)*Moment,
  792. Pol[2]*QPI*f(11)*Moment );
  793. f(12) = Hankel->Zgauss(12, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[12]));
  794. this->Receivers->AppendHfield(ifreq, irec,
  795. -Pol[2]*QPI*sp*f(12)*Moment,
  796. Pol[2]*QPI*cp*f(12)*Moment,
  797. 0. );
  798. } // Fields to calculate Z polarity Electric dipole
  799. }
  800. if (std::abs(Pol[1]) > 0 || std::abs(Pol[0]) > 0) { // y dipole
  801. switch(FieldsToCalculate) {
  802. case E:
  803. f(0) = 0;
  804. f(1) = 0;
  805. f(2) = Hankel->Zgauss(2, TE, 0, rho, wavef, KernelManager->GetRAWKernel(ik[2])) * KernelManager->GetRAWKernel(ik[2])->GetZs();
  806. f(3) = Hankel->Zgauss(3, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[3])) * KernelManager->GetRAWKernel(ik[3])->GetZs();
  807. f(4) = 0;
  808. if (std::abs(Pol[1]) > 0) {
  809. this->Receivers->AppendEfield(ifreq, irec,
  810. Pol[1]*QPI*scp*((f(0)-(Real)(2.)*f(1)/rho)+(f(2)-(Real)(2.)*f(3)/rho))*Moment,
  811. Pol[1]*QPI*((sps*f(0)+c2p*f(1)/rho)-(cps*f(2)-c2p*f(3)/rho))*Moment,
  812. Pol[1]*QPI*sp*f(4)*Moment);
  813. }
  814. if (std::abs(Pol[0]) > 0) {
  815. this->Receivers->AppendEfield(ifreq, irec,
  816. Pol[0]*Moment*QPI*((cps*f(0)-c2p*f(1)/rho)-(sps*f(2)+c2p*f(3)/rho)),
  817. Pol[0]*Moment*QPI*scp*((f(0)-(Real)(2.)*f(1)/rho)+(f(2)-(Real)(2.)*f(3)/rho)),
  818. Pol[0]*Moment*QPI*cp*f(4) );
  819. }
  820. break;
  821. case H:
  822. f(5) = Hankel->Zgauss(5, TM, 0, rho, wavef, KernelManager->GetRAWKernel(ik[5]));
  823. f(6) = Hankel->Zgauss(6, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[6]));
  824. f(7) = Hankel->Zgauss(7, TE, 0, rho, wavef, KernelManager->GetRAWKernel(ik[7]))*KernelManager->GetRAWKernel(ik[7])->GetZs()/KernelManager->GetRAWKernel(ik[7])->GetZm();
  825. f(8) = Hankel->Zgauss(8, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[8]))*KernelManager->GetRAWKernel(ik[8])->GetZs()/KernelManager->GetRAWKernel(ik[8])->GetZm();
  826. f(9) = Hankel->Zgauss(9, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[9]))*KernelManager->GetRAWKernel(ik[9])->GetZs()/KernelManager->GetRAWKernel(ik[9])->GetZm();
  827. if (std::abs(Pol[1]) > 0) {
  828. this->Receivers->AppendHfield(ifreq, irec,
  829. Pol[1]*QPI*(sps*f(5)+c2p*f(6)/rho-cps*f(7)+c2p*f(8)/rho)*Moment,
  830. Pol[1]*QPI*scp*(-f(5)+(Real)(2.)*f(6)/rho-f(7)+(Real)(2.)*f(8)/rho)*Moment,
  831. -Pol[1]*QPI*cp*f(9)*Moment );
  832. // Analytic whole space solution could go here
  833. }
  834. if (std::abs(Pol[0]) > 0) {
  835. this->Receivers->AppendHfield(ifreq, irec,
  836. Pol[0]*Moment*QPI*scp*(f(5)-(Real)(2.)*f(6)/rho+f(7)-(Real)(2.)*f(8)/rho),
  837. Pol[0]*Moment*QPI*(-cps*f(5)+c2p*f(6)/rho+sps*f(7)+c2p*f(8)/rho),
  838. Pol[0]*Moment*QPI*sp*f(9) );
  839. // Analytic whole space solution
  840. }
  841. break;
  842. case BOTH:
  843. f(0) = 0;
  844. f(1) = 0;
  845. f(4) = 0;
  846. f(2) = Hankel->Zgauss(2, TE, 0, rho, wavef, KernelManager->GetRAWKernel(ik[2])) * KernelManager->GetRAWKernel(0)->GetZs();
  847. f(3) = Hankel->Zgauss(3, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[3])) * KernelManager->GetRAWKernel(1)->GetZs();
  848. f(5) = Hankel->Zgauss(5, TM, 0, rho, wavef, KernelManager->GetRAWKernel(ik[5]));
  849. f(6) = Hankel->Zgauss(6, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[6]));
  850. f(7) = Hankel->Zgauss(7, TE, 0, rho, wavef, KernelManager->GetRAWKernel(ik[7]))*KernelManager->GetRAWKernel(ik[7])->GetZs()/KernelManager->GetRAWKernel(ik[7])->GetZm();
  851. f(8) = Hankel->Zgauss(8, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[8]))*KernelManager->GetRAWKernel(ik[8])->GetZs()/KernelManager->GetRAWKernel(ik[8])->GetZm();
  852. f(9) = Hankel->Zgauss(9, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[9]))*KernelManager->GetRAWKernel(ik[9])->GetZs()/KernelManager->GetRAWKernel(ik[9])->GetZm();
  853. if (std::abs(Pol[1]) > 0) {
  854. this->Receivers->AppendEfield(ifreq, irec,
  855. Pol[1]*QPI*scp*((f(0)-(Real)(2.)*f(1)/rho)+(f(2)-(Real)(2.)*f(3)/rho))*Moment ,
  856. Pol[1]*QPI*((sps*f(0)+c2p*f(1)/rho)-(cps*f(2)-c2p*f(3)/rho))*Moment,
  857. Pol[1]*QPI*sp*f(4)*Moment);
  858. this->Receivers->AppendHfield(ifreq, irec,
  859. Pol[1]*QPI*(sps*f(5)+c2p*f(6)/rho-cps*f(7)+c2p*f(8)/rho)*Moment,
  860. Pol[1]*QPI*scp*(-f(5)+(Real)(2.)*f(6)/rho-f(7)+(Real)(2.)*f(8)/rho)*Moment,
  861. -Pol[1]*QPI*cp*f(9)*Moment );
  862. }
  863. if (std::abs(Pol[0]) > 0) {
  864. this->Receivers->AppendEfield(ifreq, irec,
  865. Pol[0]*Moment*QPI*((cps*f(0)-c2p*f(1)/rho)-(sps*f(2)+c2p*f(3)/rho)),
  866. Pol[0]*Moment*QPI*scp*((f(0)-(Real)(2.)*f(1)/rho)+(f(2)-(Real)(2.)*f(3)/rho)),
  867. Pol[0]*Moment*QPI*cp*f(4) );
  868. this->Receivers->AppendHfield(ifreq, irec,
  869. Pol[0]*Moment*QPI*scp*(f(5)-(Real)(2.)*f(6)/rho+f(7)-(Real)(2.)*f(8)/rho),
  870. Pol[0]*Moment*QPI*(-cps*f(5)+c2p*f(6)/rho+sps*f(7)+c2p*f(8)/rho),
  871. Pol[0]*Moment*QPI*sp*f(9) );
  872. }
  873. break;
  874. }
  875. }
  876. break; // UNGROUNDEDELECTRICDIPOLE
  877. case MAGNETICDIPOLE:
  878. //Hankel->ComputeRelated(rho, KernelManager);
  879. if (std::abs(Pol[2]) > 0) { // z dipole
  880. switch(FieldsToCalculate) {
  881. case E:
  882. f(12)=Hankel->Zgauss(12, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[12]))*KernelManager->GetRAWKernel(ik[12])->GetZs();
  883. this->Receivers->AppendEfield(ifreq, irec,
  884. Pol[2]*Moment*QPI*sp*f(12),
  885. -Pol[2]*Moment*QPI*cp*f(12),
  886. 0);
  887. break;
  888. case H:
  889. f(10)=Hankel->Zgauss(10, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[10]))*KernelManager->GetRAWKernel(ik[10])->GetZs()/KernelManager->GetRAWKernel(ik[10])->GetZm();
  890. f(11)=Hankel->Zgauss(11, TE, 0, rho, wavef, KernelManager->GetRAWKernel(ik[11]))*KernelManager->GetRAWKernel(ik[11])->GetZs()/KernelManager->GetRAWKernel(ik[11])->GetZm();
  891. this->Receivers->AppendHfield(ifreq, irec,
  892. -Pol[2]*Moment*QPI*cp*f(10),
  893. -Pol[2]*Moment*QPI*sp*f(10),
  894. Pol[2]*Moment*QPI*f(11) );
  895. break;
  896. case BOTH:
  897. f(12)=Hankel->Zgauss(12, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[12]))*KernelManager->GetRAWKernel(ik[12])->GetZs();
  898. f(10)=Hankel->Zgauss(10, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[10]))*KernelManager->GetRAWKernel(ik[10])->GetZs()/KernelManager->GetRAWKernel(ik[10])->GetZm();
  899. f(11)=Hankel->Zgauss(11, TE, 0, rho, wavef, KernelManager->GetRAWKernel(ik[11]))*KernelManager->GetRAWKernel(ik[11])->GetZs()/KernelManager->GetRAWKernel(ik[11])->GetZm();
  900. this->Receivers->AppendEfield(ifreq, irec,
  901. Pol[2]*Moment*QPI*sp*f(12),
  902. -Pol[2]*Moment*QPI*cp*f(12),
  903. 0);
  904. this->Receivers->AppendHfield(ifreq, irec,
  905. -Pol[2]*Moment*QPI*cp*f(10),
  906. -Pol[2]*Moment*QPI*sp*f(10),
  907. Pol[2]*Moment*QPI*f(11) );
  908. break;
  909. }
  910. }
  911. if (std::abs(Pol[1]) > 0 || std::abs(Pol[0]) > 0) { // x or y grounded HED dipole
  912. switch (FieldsToCalculate) {
  913. case E:
  914. f(5) = Hankel->Zgauss(5, TE, 0, rho, wavef, KernelManager->GetRAWKernel(ik[5]))*KernelManager->GetRAWKernel(ik[5])->GetZs();
  915. f(6) = Hankel->Zgauss(6, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[6]))*KernelManager->GetRAWKernel(ik[6])->GetZs();
  916. f(7) = Hankel->Zgauss(7, TM, 0, rho, wavef, KernelManager->GetRAWKernel(ik[7]))*KernelManager->GetRAWKernel(ik[7])->GetKs()/KernelManager->GetRAWKernel(ik[7])->GetYm();
  917. f(8) = Hankel->Zgauss(8, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[8]))*KernelManager->GetRAWKernel(ik[8])->GetKs()/KernelManager->GetRAWKernel(ik[8])->GetYm();
  918. f(9) = Hankel->Zgauss(9, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[9]))*KernelManager->GetRAWKernel(ik[9])->GetKs()/KernelManager->GetRAWKernel(ik[9])->GetYm();
  919. if (std::abs(Pol[0]) > 0) {
  920. this->Receivers->AppendEfield(ifreq, irec,
  921. Pol[0]*Moment*QPI*scp*((-f(5)+(Real)(2.)*f(6)/rho)+(f(7)-(Real)(2.)*f(8)/rho)),
  922. Pol[0]*Moment*QPI*((cps*f(5)-c2p*f(6)/rho)+(sps*f(7)+c2p*f(8)/rho)),
  923. Pol[0]*Moment*QPI*sp*f(9));
  924. }
  925. if (std::abs(Pol[1]) > 0) {
  926. this->Receivers->AppendEfield(ifreq, irec,
  927. Pol[1]*Moment*QPI*(-(sps*f(5)+c2p*f(6)/rho)-(cps*f(7)-c2p*f(8)/rho)),
  928. Pol[1]*Moment*QPI*scp*((f(5)-(Real)(2.)*f(6)/rho)-(f(7)-(Real)(2.)*f(8)/rho)),
  929. -Pol[1]*Moment*QPI*cp*f(9) );
  930. }
  931. break;
  932. case H:
  933. f(0) = Hankel->Zgauss(0, TE, 0, rho, wavef, KernelManager->GetRAWKernel(ik[0]))*KernelManager->GetRAWKernel(ik[0])->GetZs()/KernelManager->GetRAWKernel(ik[0])->GetZm();
  934. f(1) = Hankel->Zgauss(1, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[1]))*KernelManager->GetRAWKernel(ik[1])->GetZs()/KernelManager->GetRAWKernel(ik[1])->GetZm();
  935. f(4) = Hankel->Zgauss(4, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[4]))*KernelManager->GetRAWKernel(ik[4])->GetZs()/KernelManager->GetRAWKernel(ik[4])->GetZm();
  936. f(2) = Hankel->Zgauss(2, TM, 0, rho, wavef, KernelManager->GetRAWKernel(ik[2]))*KernelManager->GetRAWKernel(ik[2])->GetKs();
  937. f(3) = Hankel->Zgauss(3, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[3]))*KernelManager->GetRAWKernel(ik[3])->GetKs();
  938. if (std::abs(Pol[0]) > 0) {
  939. this->Receivers->AppendHfield(ifreq, irec,
  940. Pol[0]*Moment*QPI*(cps*f(0)-c2p*f(1)/rho+(sps*f(2)+c2p*f(3)/rho)),
  941. Pol[0]*Moment*QPI*scp*(f(0)-(Real)(2.)*f(1)/rho-(f(2)-(Real)(2.)*f(3)/rho)),
  942. Pol[0]*Moment*QPI*cp*f(4) );
  943. }
  944. if (std::abs(Pol[1]) > 0) {
  945. this->Receivers->AppendHfield(ifreq, irec,
  946. Pol[1]*Moment*QPI*scp*(f(0)-(Real)(2.)*f(1)/rho-(f(2)-(Real)(2.)*f(3)/rho)),
  947. Pol[1]*Moment*QPI*(sps*f(0)+c2p*f(1)/rho+(cps*f(2)-c2p*f(3)/rho)),
  948. Pol[1]*Moment*QPI*sp*f(4));
  949. }
  950. break;
  951. case BOTH:
  952. f(5) = Hankel->Zgauss(5, TE, 0, rho, wavef, KernelManager->GetRAWKernel(ik[5]))*KernelManager->GetRAWKernel(ik[5])->GetZs();
  953. f(6) = Hankel->Zgauss(6, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[6]))*KernelManager->GetRAWKernel(ik[6])->GetZs();
  954. f(7) = Hankel->Zgauss(7, TM, 0, rho, wavef, KernelManager->GetRAWKernel(ik[7]))*KernelManager->GetRAWKernel(ik[7])->GetKs()/KernelManager->GetRAWKernel(ik[7])->GetYm();
  955. f(8) = Hankel->Zgauss(8, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[8]))*KernelManager->GetRAWKernel(ik[8])->GetKs()/KernelManager->GetRAWKernel(ik[8])->GetYm();
  956. f(9) = Hankel->Zgauss(9, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[9]))*KernelManager->GetRAWKernel(ik[9])->GetKs()/KernelManager->GetRAWKernel(ik[9])->GetYm();
  957. f(0) = Hankel->Zgauss(0, TE, 0, rho, wavef, KernelManager->GetRAWKernel(ik[0]))*KernelManager->GetRAWKernel(ik[0])->GetZs()/KernelManager->GetRAWKernel(ik[0])->GetZm();
  958. f(1) = Hankel->Zgauss(1, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[1]))*KernelManager->GetRAWKernel(ik[1])->GetZs()/KernelManager->GetRAWKernel(ik[1])->GetZm();
  959. f(4) = Hankel->Zgauss(4, TE, 1, rho, wavef, KernelManager->GetRAWKernel(ik[4]))*KernelManager->GetRAWKernel(ik[4])->GetZs()/KernelManager->GetRAWKernel(ik[4])->GetZm();
  960. f(2) = Hankel->Zgauss(2, TM, 0, rho, wavef, KernelManager->GetRAWKernel(ik[2]))*KernelManager->GetRAWKernel(ik[2])->GetKs();
  961. f(3) = Hankel->Zgauss(3, TM, 1, rho, wavef, KernelManager->GetRAWKernel(ik[3]))*KernelManager->GetRAWKernel(ik[3])->GetKs();
  962. if (std::abs(Pol[0]) > 0) {
  963. this->Receivers->AppendEfield(ifreq, irec,
  964. Pol[0]*Moment*QPI*scp*((-f(5)+(Real)(2.)*f(6)/rho)+(f(7)-(Real)(2.)*f(8)/rho)),
  965. Pol[0]*Moment*QPI*((cps*f(5)-c2p*f(6)/rho)+(sps*f(7)+c2p*f(8)/rho)),
  966. Pol[0]*Moment*QPI*sp*f(9));
  967. this->Receivers->AppendHfield(ifreq, irec,
  968. Pol[0]*Moment*QPI*(cps*f(0)-c2p*f(1)/rho+(sps*f(2)+c2p*f(3)/rho)),
  969. Pol[0]*Moment*QPI*scp*(f(0)-(Real)(2.)*f(1)/rho-(f(2)-(Real)(2.)*f(3)/rho)),
  970. Pol[0]*Moment*QPI*cp*f(4) );
  971. }
  972. if (std::abs(Pol[1]) > 0) {
  973. this->Receivers->AppendEfield(ifreq, irec,
  974. Pol[1]*Moment*QPI*(-(sps*f(5)+c2p*f(6)/rho)-(cps*f(7)-c2p*f(8)/rho)),
  975. Pol[1]*Moment*QPI*scp*((f(5)-(Real)(2.)*f(6)/rho)-(f(7)-(Real)(2.)*f(8)/rho)),
  976. -Pol[1]*Moment*QPI*cp*f(9) );
  977. this->Receivers->AppendHfield(ifreq, irec,
  978. Pol[1]*Moment*QPI*scp*(f(0)-(Real)(2.)*f(1)/rho-(f(2)-(Real)(2.)*f(3)/rho)),
  979. Pol[1]*Moment*QPI*(sps*f(0)+c2p*f(1)/rho+(cps*f(2)-c2p*f(3)/rho)),
  980. Pol[1]*Moment*QPI*sp*f(4));
  981. }
  982. break;
  983. }
  984. }
  985. break;
  986. case NOSOURCETYPE:
  987. throw NonValidDipoleType(this);
  988. } // Source Type Switch
  989. }
  990. // ==================== INQUIRY ======================
  991. std::shared_ptr<KernelEM1DManager> DipoleSource::GetKernelManager() {
  992. return KernelManager;
  993. }
  994. Vector3r DipoleSource::GetLocation() {
  995. return this->Location;
  996. }
  997. #ifdef LEMMAUSEVTK
  998. vtkActor* DipoleSource::GetVtkActor() {
  999. vtkActor* vActor;
  1000. vtkLineSource* vLineSource;
  1001. vtkTubeFilter* vTube;
  1002. vtkPolyDataMapper* vMapper;
  1003. vtkRegularPolygonSource* vCircleSource;
  1004. vLineSource = vtkLineSource::New();
  1005. vTube = vtkTubeFilter::New();
  1006. vMapper = vtkPolyDataMapper::New();
  1007. vCircleSource = vtkRegularPolygonSource::New();
  1008. VectorXr M0 = Location - .5*Moment*Phat;
  1009. VectorXr M1 = Location + .5*Moment*Phat;
  1010. vActor = vtkActor::New();
  1011. switch (Type) {
  1012. case GROUNDEDELECTRICDIPOLE:
  1013. vLineSource->SetPoint1( M0(0), M0(1), M0(2));
  1014. vLineSource->SetPoint2( M1(0), M1(1), M1(2));
  1015. vTube->SetInputConnection(vLineSource->GetOutputPort());
  1016. vTube->SetRadius(.1 * std::abs(Moment));
  1017. vTube->SetNumberOfSides(6);
  1018. vTube->SetCapping(1);
  1019. vMapper->SetInputConnection(vTube->GetOutputPort());
  1020. vActor->SetMapper(vMapper);
  1021. vActor->GetProperty()->SetColor(Phat[0], Phat[1], Phat[2]);
  1022. break;
  1023. case UNGROUNDEDELECTRICDIPOLE:
  1024. vLineSource->SetPoint1( M0(0), M0(1), M0(2));
  1025. vLineSource->SetPoint2( M1(0), M1(1), M1(2));
  1026. vTube->SetInputConnection(vLineSource->GetOutputPort());
  1027. vTube->SetRadius(.1 * std::abs(Moment));
  1028. vTube->SetNumberOfSides(6);
  1029. vTube->SetCapping(1);
  1030. vMapper->SetInputConnection(vTube->GetOutputPort());
  1031. vActor->SetMapper(vMapper);
  1032. //vActor->GetProperty()->SetColor(Phat[0], Phat[1], Phat[2]);
  1033. vActor->GetProperty()->SetColor(rand()/(Real)(RAND_MAX), rand()/(Real)(RAND_MAX), rand()/(Real)(RAND_MAX));
  1034. vActor->GetProperty()->SetOpacity(1.);
  1035. break;
  1036. case MAGNETICDIPOLE:
  1037. vCircleSource->SetCenter(Location(0), Location(1),
  1038. Location(2));
  1039. vCircleSource->SetNumberOfSides(360);
  1040. vCircleSource->SetNormal(Phat[0], Phat[1], Phat[2]);
  1041. vCircleSource->SetRadius(0.2); // .2 m radius
  1042. vCircleSource->SetGeneratePolygon(false);
  1043. vCircleSource->SetGeneratePolyline(true);
  1044. vCircleSource->Update();
  1045. vTube->SetInputConnection(vCircleSource->GetOutputPort());
  1046. //vTube->SetRadius( max((float)(*xCoords->GetTuple(nx)),
  1047. // (float)(*yCoords->GetTuple(ny))) / 100);
  1048. vTube->SetRadius(.1*std::abs(Moment));
  1049. vTube->SetNumberOfSides(6);
  1050. vTube->SetCapping(1);
  1051. vMapper->SetInputConnection(vTube->GetOutputPort());
  1052. vActor->SetMapper(vMapper);
  1053. vActor->GetProperty()->SetColor(.9,.2,.9);
  1054. break;
  1055. default:
  1056. throw NonValidDipoleType();
  1057. }
  1058. vLineSource->Delete();
  1059. vCircleSource->Delete();
  1060. vTube->Delete();
  1061. vMapper->Delete();
  1062. return vActor;
  1063. }
  1064. #endif
  1065. Real DipoleSource::GetLocation(const int& coordinate) {
  1066. switch (coordinate) {
  1067. case (0):
  1068. return this->Location.x();
  1069. break;
  1070. case (1):
  1071. return this->Location.y();
  1072. break;
  1073. case (2):
  1074. return this->Location.z();
  1075. break;
  1076. default:
  1077. throw NonValidLocationCoordinate( );
  1078. }
  1079. }
  1080. DipoleSourceType DipoleSource::GetDipoleSourceType() {
  1081. return this->Type;
  1082. }
  1083. //DipoleSourcePolarisation DipoleSource::GetDipoleSourcePolarisation() {
  1084. // return this->Polarisation;
  1085. //}
  1086. Real DipoleSource::GetAngularFrequency(const int& ifreq) {
  1087. return 2.*PI*this->Freqs(ifreq);
  1088. }
  1089. Real DipoleSource::GetFrequency(const int& ifreq) {
  1090. return this->Freqs(ifreq);
  1091. }
  1092. VectorXr DipoleSource::GetFrequencies( ) {
  1093. return this->Freqs;
  1094. }
  1095. Real DipoleSource::GetPhase() {
  1096. return this->Phase;
  1097. }
  1098. Real DipoleSource::GetMoment() {
  1099. return this->Moment;
  1100. }
  1101. int DipoleSource::GetNumberOfFrequencies() {
  1102. return this->Freqs.size();
  1103. }
  1104. void DipoleSource::SetNumberOfFrequencies(const int &nfreq){
  1105. Freqs.resize(nfreq);
  1106. Freqs.setZero();
  1107. }
  1108. void DipoleSource::SetFrequency(const int &ifreq, const Real &freq){
  1109. Freqs(ifreq) = freq;
  1110. }
  1111. void DipoleSource::SetFrequencies(const VectorXr &freqs){
  1112. Freqs = freqs;
  1113. }
  1114. /////////////////////////////////////////////////////////////////
  1115. /////////////////////////////////////////////////////////////////
  1116. // Error classes
  1117. NullDipoleSource::NullDipoleSource() :
  1118. runtime_error( "NULL VALUED DIPOLE SOURCE") {}
  1119. NonValidDipoleTypeAssignment::NonValidDipoleTypeAssignment( ) :
  1120. runtime_error( "NON VALID DIPOLE TYPE ASSIGNMENT") { }
  1121. NonValidDipoleType::NonValidDipoleType( LemmaObject* ptr ) :
  1122. runtime_error( "NON VALID DIPOLE TYPE") {
  1123. std::cout << "Thrown by instance of "
  1124. << ptr->GetName() << std::endl;
  1125. }
  1126. NonValidDipoleType::NonValidDipoleType( ) :
  1127. runtime_error( "NON VALID DIPOLE TYPE") { }
  1128. NonValidDipolePolarity::NonValidDipolePolarity () :
  1129. runtime_error( "NON VALID DIPOLE POLARITY") { }
  1130. NonValidDipolePolarisation::NonValidDipolePolarisation( ) :
  1131. runtime_error( "NON VALID DIPOLE TYPE") { }
  1132. NonValidDipolePolarisationAssignment::
  1133. NonValidDipolePolarisationAssignment( ) :
  1134. runtime_error( "NON VALID DIPOLE POLARISATION ASSIGNMENT") { }
  1135. NonValidLocationCoordinate::NonValidLocationCoordinate( ) :
  1136. runtime_error( "NON VALID LOCATION COORDINATE REQUESTED") { }
  1137. }