Surface NMR forward modelling
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

KernelV0.cpp 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. /* This file is part of Lemma, a geophysical modelling and inversion API.
  2. * More information is available at http://lemmasoftware.org
  3. */
  4. /* This Source Code Form is subject to the terms of the Mozilla Public
  5. * License, v. 2.0. If a copy of the MPL was not distributed with this
  6. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  7. */
  8. /**
  9. * @file
  10. * @date 11/11/2016 01:47:25 PM
  11. * @version $Id$
  12. * @author Trevor Irons (ti)
  13. * @email tirons@egi.utah.edu
  14. * @copyright Copyright (c) 2016, University of Utah
  15. * @copyright Copyright (c) 2016, Lemma Software, LLC
  16. */
  17. #include "KernelV0.h"
  18. #include "FieldPoints.h"
  19. namespace Lemma {
  20. // ==================== FRIEND METHODS =====================
  21. std::ostream &operator << (std::ostream &stream, const KernelV0 &ob) {
  22. stream << ob.Serialize() << "\n---\n"; // End of doc ---
  23. return stream;
  24. }
  25. // ==================== LIFECYCLE =======================
  26. //--------------------------------------------------------------------------------------
  27. // Class: KernelV0
  28. // Method: KernelV0
  29. // Description: constructor (locked)
  30. //--------------------------------------------------------------------------------------
  31. KernelV0::KernelV0 (const ctor_key&) : LemmaObject( ) {
  32. } // ----- end of method KernelV0::KernelV0 (constructor) -----
  33. //--------------------------------------------------------------------------------------
  34. // Class: KernelV0
  35. // Method: KernelV0
  36. // Description: DeSerializing constructor (locked)
  37. //--------------------------------------------------------------------------------------
  38. KernelV0::KernelV0 (const YAML::Node& node, const ctor_key&) : LemmaObject(node) {
  39. } // ----- end of method KernelV0::KernelV0 (constructor) -----
  40. //--------------------------------------------------------------------------------------
  41. // Class: KernelV0
  42. // Method: NewSP()
  43. // Description: public constructor returing a shared_ptr
  44. //--------------------------------------------------------------------------------------
  45. std::shared_ptr< KernelV0 > KernelV0::NewSP() {
  46. return std::make_shared< KernelV0 >( ctor_key() );
  47. }
  48. //--------------------------------------------------------------------------------------
  49. // Class: KernelV0
  50. // Method: ~KernelV0
  51. // Description: destructor (protected)
  52. //--------------------------------------------------------------------------------------
  53. KernelV0::~KernelV0 () {
  54. } // ----- end of method KernelV0::~KernelV0 (destructor) -----
  55. //--------------------------------------------------------------------------------------
  56. // Class: KernelV0
  57. // Method: Serialize
  58. //--------------------------------------------------------------------------------------
  59. YAML::Node KernelV0::Serialize ( ) const {
  60. YAML::Node node = LemmaObject::Serialize();
  61. node.SetTag( GetName() );
  62. // Coils Transmitters & Receivers
  63. for ( auto txm : TxRx) {
  64. node[txm.first] = txm.second->Serialize();
  65. }
  66. // LayeredEarthEM
  67. node["SigmaModel"] = SigmaModel->Serialize();
  68. return node;
  69. } // ----- end of method KernelV0::Serialize -----
  70. //--------------------------------------------------------------------------------------
  71. // Class: KernelV0
  72. // Method: DeSerialize
  73. //--------------------------------------------------------------------------------------
  74. std::shared_ptr<KernelV0> KernelV0::DeSerialize ( const YAML::Node& node ) {
  75. if (node.Tag() != "KernelV0" ) {
  76. throw DeSerializeTypeMismatch( "KernelV0", node.Tag());
  77. }
  78. return std::make_shared< KernelV0 > ( node, ctor_key() );
  79. } // ----- end of method KernelV0::DeSerialize -----
  80. //--------------------------------------------------------------------------------------
  81. // Class: KernelV0
  82. // Method: DeSerialize
  83. //--------------------------------------------------------------------------------------
  84. void KernelV0::CalculateK0 (const std::vector< std::string>& Tx, const std::vector<std::string >& Rx,
  85. bool vtkOutput ) {
  86. // Set up
  87. Larmor = SigmaModel->GetMagneticFieldMagnitude()*GAMMA; // in rad 2246.*2.*PI;
  88. // All EM calculations will share same field points
  89. cpoints = FieldPoints::NewSP();
  90. cpoints->SetNumberOfPoints(8);
  91. for (auto tx : Tx) {
  92. // Set up EMEarth
  93. EMEarths[tx] = EMEarth1D::NewSP();
  94. EMEarths[tx]->AttachWireAntenna(TxRx[tx]);
  95. EMEarths[tx]->AttachLayeredEarthEM(SigmaModel);
  96. EMEarths[tx]->AttachFieldPoints( cpoints );
  97. EMEarths[tx]->SetFieldsToCalculate(H);
  98. // TODO query for method, altough with flat antennae, this is fastest
  99. EMEarths[tx]->SetHankelTransformMethod(ANDERSON801);
  100. EMEarths[tx]->SetTxRxMode(TX);
  101. }
  102. for (auto rx : Rx) {
  103. if (EMEarths.count(rx)) {
  104. EMEarths[rx]->SetTxRxMode(TXRX);
  105. } else {
  106. EMEarths[rx] = EMEarth1D::NewSP();
  107. EMEarths[rx]->AttachWireAntenna(TxRx[rx]);
  108. EMEarths[rx]->AttachLayeredEarthEM(SigmaModel);
  109. EMEarths[rx]->AttachFieldPoints( cpoints );
  110. EMEarths[rx]->SetFieldsToCalculate(H);
  111. // TODO query for method, altough with flat antennae, this is fastest
  112. EMEarths[rx]->SetHankelTransformMethod(ANDERSON801);
  113. EMEarths[rx]->SetTxRxMode(RX);
  114. }
  115. }
  116. std::cout << "Calculating K0 kernel\n";
  117. MatrixXcr Kern = MatrixXcr::Zero( Interfaces.size() - 1, PulseI.size() );
  118. for (int ilay=0; ilay< Interfaces.size()-1; ++ilay) {
  119. for (int iq=0; iq< PulseI.size()-1; ++iq) {
  120. std::cout << "Layer " << ilay << " q " << iq << std::endl;
  121. Size(2) = Interfaces(ilay+1) - Interfaces(ilay);
  122. Origin(2) = Interfaces(ilay);
  123. Ip = PulseI(iq);
  124. Kern(ilay, iq) = IntegrateOnOctreeGrid( ilay, iq, vtkOutput );
  125. }
  126. }
  127. std::cout << "\rFinished KERNEL\n";
  128. std::cout << Kern << std::endl;
  129. //IntegrateOnOctreeGrid( vtkOutput );
  130. }
  131. //--------------------------------------------------------------------------------------
  132. // Class: KernelV0
  133. // Method: IntegrateOnOctreeGrid
  134. //--------------------------------------------------------------------------------------
  135. Complex KernelV0::IntegrateOnOctreeGrid( const int& ilay, const int& iq, bool vtkOutput) {
  136. Vector3r cpos = (Size-Origin).array() / 2.;
  137. SUM = 0;
  138. VOLSUM = 0;
  139. nleaves = 0;
  140. if (!vtkOutput) {
  141. EvaluateKids( Size, 0, cpos, 1e6 );
  142. } else {
  143. #ifdef LEMMAUSEVTK
  144. vtkHyperOctree* oct = vtkHyperOctree::New();
  145. oct->SetDimension(3);
  146. oct->SetOrigin( Origin(0), Origin(1), Origin(2) );
  147. oct->SetSize( Size(0), Size(1), Size(2) );
  148. vtkHyperOctreeCursor* curse = oct->NewCellCursor();
  149. curse->ToRoot();
  150. EvaluateKids2( Size, 0, cpos, 1e6, oct, curse );
  151. // Fill in leaf data
  152. vtkDoubleArray* kr = vtkDoubleArray::New();
  153. kr->SetNumberOfComponents(1);
  154. kr->SetName("Re($K_0$)");
  155. kr->SetNumberOfTuples( oct->GetNumberOfLeaves() );
  156. vtkDoubleArray* ki = vtkDoubleArray::New();
  157. ki->SetNumberOfComponents(1);
  158. ki->SetName("Im($K_0$)");
  159. ki->SetNumberOfTuples( oct->GetNumberOfLeaves() );
  160. vtkDoubleArray* km = vtkDoubleArray::New();
  161. km->SetNumberOfComponents(1);
  162. km->SetName("mod($K_0$)");
  163. km->SetNumberOfTuples( oct->GetNumberOfLeaves() );
  164. vtkIntArray* kid = vtkIntArray::New();
  165. kid->SetNumberOfComponents(1);
  166. kid->SetName("ID");
  167. kid->SetNumberOfTuples( oct->GetNumberOfLeaves() );
  168. vtkIntArray* kerr = vtkIntArray::New();
  169. kerr->SetNumberOfComponents(1);
  170. kerr->SetName("nleaf");
  171. for (auto leaf : LeafDict) {
  172. kr->InsertTuple1( leaf.first, std::real(leaf.second) );
  173. ki->InsertTuple1( leaf.first, std::imag(leaf.second) );
  174. km->InsertTuple1( leaf.first, std::abs(leaf.second) );
  175. kid->InsertTuple1( leaf.first, leaf.first );
  176. }
  177. for (auto leaf : LeafDictIdx) {
  178. kerr->InsertTuple1( leaf.first, leaf.second );
  179. }
  180. oct->GetLeafData()->AddArray(kr);
  181. oct->GetLeafData()->AddArray(ki);
  182. oct->GetLeafData()->AddArray(km);
  183. oct->GetLeafData()->AddArray(kid);
  184. oct->GetLeafData()->AddArray(kerr);
  185. auto write = vtkXMLHyperOctreeWriter::New();
  186. //write.SetDataModeToAscii()
  187. write->SetInputData(oct);
  188. std::string fname = std::string("octree-") + to_string(ilay)
  189. + std::string("-") + to_string(iq) + std::string(".vto");
  190. write->SetFileName(fname.c_str());
  191. write->Write();
  192. write->Delete();
  193. //kerr->Delete();
  194. kid->Delete();
  195. kr->Delete();
  196. ki->Delete();
  197. km->Delete();
  198. curse->Delete();
  199. oct->Delete();
  200. #else
  201. throw std::runtime_error("IntegrateOnOctreeGrid with vtkOutput requires Lemma with VTK support");
  202. #endif
  203. }
  204. std::cout << "\nVOLSUM=" << VOLSUM << "\tActual=" << Size(0)*Size(1)*Size(2)
  205. << "\tDifference=" << VOLSUM - (Size(0)*Size(1)*Size(2)) << std::endl;
  206. std::cout << "nleaves\t" << nleaves << std::endl;
  207. std::cout << "KSUM\t" << SUM << std::endl;
  208. return SUM;
  209. }
  210. //--------------------------------------------------------------------------------------
  211. // Class: KernelV0
  212. // Method: f
  213. //--------------------------------------------------------------------------------------
  214. Complex KernelV0::f( const Vector3r& r, const Real& volume, const Vector3cr& Ht, const Vector3cr& Hr ) {
  215. //return Complex(volume*Ht.dot(Hr));
  216. return ComputeV0Cell(MU0*Ht, MU0*Hr, volume, 1.0);
  217. }
  218. //--------------------------------------------------------------------------------------
  219. // Class: KernelV0
  220. // Method: ComputeV0Cell
  221. //--------------------------------------------------------------------------------------
  222. Complex KernelV0::ComputeV0Cell(const Vector3cr& Bt,
  223. const Vector3cr& Br, const Real& vol, const Real& phi) {
  224. // Compute the elliptic fields
  225. Vector3r B0hat = SigmaModel->GetMagneticFieldUnitVector();
  226. Vector3r B0 = SigmaModel->GetMagneticField();
  227. // Elliptic representation
  228. EllipticB EBT = EllipticFieldRep(Bt, B0hat);
  229. EllipticB EBR = EllipticFieldRep(Br, B0hat);
  230. // Compute Mn0
  231. Vector3r Mn0 = ComputeMn0(phi, B0);
  232. Real Mn0Abs = Mn0.norm();
  233. // Compute the tipping angle
  234. Real sintheta = std::sin(0.5*GAMMA*Ip*Taup*std::abs(EBT.alpha-EBT.beta));
  235. // Compute phase delay, TODO add transmiiter phase and delay time phase!
  236. Real phase = EBR.zeta+EBT.zeta;
  237. return ComputeV0Cell(EBT, EBR, sintheta, phase, Mn0Abs, vol);
  238. }
  239. //--------------------------------------------------------------------------------------
  240. // Class: KernelV0
  241. // Method: ComputeV0Cell
  242. //--------------------------------------------------------------------------------------
  243. Complex KernelV0::ComputeV0Cell(const EllipticB& EBT, const EllipticB& EBR,
  244. const Real& sintheta, const Real& phase, const Real& Mn0Abs,
  245. const Real& vol) {
  246. Vector3r B0hat = {1,0,0};
  247. // earth response of receiver adjoint field
  248. Complex ejztr = std::exp(Complex(0, EBR.zeta + EBT.zeta));
  249. Complex PhaseTerm = EBR.bhat.dot(EBT.bhat) +
  250. (B0hat.dot(EBR.bhat.cross(EBT.bhat) ));
  251. return -vol*Complex(0,Larmor)*Mn0Abs*(EBR.alpha+EBR.beta)*ejztr*sintheta*PhaseTerm;
  252. }
  253. //--------------------------------------------------------------------------------------
  254. // Class: KernelV0
  255. // Method: ComputeV0Cell
  256. //--------------------------------------------------------------------------------------
  257. Vector3r KernelV0::ComputeMn0(const Real& Porosity, const Vector3r& B0) {
  258. Real chi_n = NH2O*((GAMMA*GAMMA*HBAR*HBAR)/(4.*KB*Temperature));
  259. return chi_n*Porosity*B0;
  260. }
  261. //--------------------------------------------------------------------------------------
  262. // Class: KernelV0
  263. // Method: ComputeV0Cell
  264. //--------------------------------------------------------------------------------------
  265. EllipticB KernelV0::EllipticFieldRep (const Vector3cr& B, const Vector3r& B0hat) {
  266. EllipticB ElipB = EllipticB();
  267. Vector3cr Bperp = B.array() - B0hat.dot(B)*B0hat.array();
  268. Real BperpNorm = Bperp.norm();
  269. Complex Bp2 = Bperp.transpose() * Bperp;
  270. VectorXcr iB0 = Complex(0,1)*B0hat.cast<Complex>().array();
  271. ElipB.eizt = std::sqrt(Bp2 / std::abs(Bp2));
  272. ElipB.alpha = INVSQRT2*std::sqrt(BperpNorm*BperpNorm + std::abs(Bp2));
  273. ElipB.beta = sgn(std::real(iB0.dot(Bperp.cross(Bperp.conjugate())))) *
  274. (INVSQRT2)*std::sqrt(std::abs(BperpNorm*BperpNorm-std::abs(Bp2)));
  275. ElipB.bhat = ((Real)1./ElipB.alpha)*(((Real)1./ElipB.eizt)*Bperp.array()).real().array();
  276. ElipB.bhatp = B0hat.cross(ElipB.bhat);
  277. ElipB.zeta = std::real(std::log(ElipB.eizt)/Complex(0,1));
  278. return ElipB;
  279. }
  280. //--------------------------------------------------------------------------------------
  281. // Class: KernelV0
  282. // Method: EvaluateKids
  283. //--------------------------------------------------------------------------------------
  284. bool KernelV0::EvaluateKids( const Vector3r& size, const int& level, const Vector3r& cpos,
  285. const Complex& parentVal ) {
  286. std::cout << "\r" << (int)(1e2*VOLSUM/(Size[0]*Size[1]*Size[2])) << "\t" << nleaves;
  287. std::cout.flush();
  288. // Next level step, interested in one level below
  289. // bitshift requires one extra, faster than, and equivalent to std::pow(2, level+1)
  290. Vector3r step = size.array() / (Real)(1 << (level+1) );
  291. Vector3r step2 = size.array() / (Real)(1 << (level+2) );
  292. Real vol = (step2(0)*step2(1)*step2(2)); // volume of each child
  293. Vector3r pos = cpos - step/2.;
  294. Eigen::Matrix<Real, 8, 3> posadd = (Eigen::Matrix<Real, 8, 3>() <<
  295. 0, 0, 0,
  296. step[0], 0, 0,
  297. 0, step[1], 0,
  298. step[0], step[1], 0,
  299. 0, 0, step[2],
  300. step[0], 0, step[2],
  301. 0, step[1], step[2],
  302. step[0], step[1], step[2] ).finished();
  303. VectorXcr kvals(8); // individual kernel vals
  304. cpoints->ClearFields();
  305. for (int ichild=0; ichild<8; ++ichild) {
  306. Vector3r cp = pos; // Eigen complains about combining these
  307. cp += posadd.row(ichild);
  308. cpoints->SetLocation( ichild, cp );
  309. }
  310. Eigen::Matrix<Complex, 3, 8> Ht = Eigen::Matrix<Complex, 3, 8>::Zero();
  311. Eigen::Matrix<Complex, 3, 8> Hr = Eigen::Matrix<Complex, 3, 8>::Zero();
  312. //Eigen::Matrix< Complex, 8, 3 > Bt;
  313. for ( auto EMCalc : EMEarths ) {
  314. //EMCalc->GetFieldPoints()->ClearFields();
  315. EMCalc.second->CalculateWireAntennaFields();
  316. switch (EMCalc.second->GetTxRxMode()) {
  317. case TX:
  318. Ht += EMCalc.second->GetFieldPoints()->GetHfield(0);
  319. break;
  320. case RX:
  321. Hr += EMCalc.second->GetFieldPoints()->GetHfield(0);
  322. break;
  323. case TXRX:
  324. Ht += EMCalc.second->GetFieldPoints()->GetHfield(0);
  325. Hr += EMCalc.second->GetFieldPoints()->GetHfield(0);
  326. break;
  327. default:
  328. break;
  329. }
  330. }
  331. for (int ichild=0; ichild<8; ++ichild) {
  332. Vector3r cp = pos; // Eigen complains about combining these
  333. cp += posadd.row(ichild);
  334. kvals(ichild) = f(cp, vol, Ht.col(ichild), Hr.col(ichild));
  335. }
  336. Complex ksum = kvals.sum(); // Kernel sum
  337. // Evaluate whether or not furthur splitting is needed
  338. if ( std::abs(ksum - parentVal) > tol || level < minLevel && level < maxLevel ) {
  339. for (int ichild=0; ichild<8; ++ichild) {
  340. Vector3r cp = pos; // Eigen complains about combining these
  341. cp += posadd.row(ichild);
  342. bool isleaf = EvaluateKids( size, level+1, cp, kvals(ichild) );
  343. if (isleaf) { // Include result in final integral
  344. SUM += ksum;
  345. VOLSUM += 8.*vol;
  346. nleaves += 1;
  347. }
  348. }
  349. return false; // not leaf
  350. }
  351. // Save here instead?
  352. return true; // leaf
  353. }
  354. #ifdef LEMMAUSEVTK
  355. //--------------------------------------------------------------------------------------
  356. // Class: KernelV0
  357. // Method: EvaluateKids2 -- same as Evaluate Kids, but include VTK octree generation
  358. //--------------------------------------------------------------------------------------
  359. bool KernelV0::EvaluateKids2( const Vector3r& size, const int& level, const Vector3r& cpos,
  360. const Complex& parentVal, vtkHyperOctree* oct, vtkHyperOctreeCursor* curse) {
  361. std::cout << "\r" << (int)(1e2*VOLSUM/(Size[0]*Size[1]*Size[2])) << "\t" << nleaves;
  362. std::cout.flush();
  363. // Next level step, interested in one level below
  364. // bitshift requires one extra, faster than, and equivalent to std::pow(2, level+1)
  365. Vector3r step = size.array() / (Real)(1 << (level+1) );
  366. Vector3r step2 = size.array() / (Real)(1 << (level+2) );
  367. Real vol = (step2(0)*step2(1)*step2(2)); // volume of each child
  368. Vector3r pos = cpos - step/2.;
  369. Eigen::Matrix<Real, 8, 3> posadd = (Eigen::Matrix<Real, 8, 3>() <<
  370. 0, 0, 0,
  371. step[0], 0, 0,
  372. 0, step[1], 0,
  373. step[0], step[1], 0,
  374. 0, 0, step[2],
  375. step[0], 0, step[2],
  376. 0, step[1], step[2],
  377. step[0], step[1], step[2] ).finished();
  378. VectorXcr kvals(8); // individual kernel vals
  379. cpoints->ClearFields();
  380. for (int ichild=0; ichild<8; ++ichild) {
  381. Vector3r cp = pos; // Eigen complains about combining these
  382. cp += posadd.row(ichild);
  383. cpoints->SetLocation( ichild, cp );
  384. }
  385. Eigen::Matrix<Complex, 3, 8> Ht = Eigen::Matrix<Complex, 3, 8>::Zero();
  386. Eigen::Matrix<Complex, 3, 8> Hr = Eigen::Matrix<Complex, 3, 8>::Zero();
  387. for ( auto EMCalc : EMEarths ) {
  388. //EMCalc->GetFieldPoints()->ClearFields();
  389. EMCalc.second->CalculateWireAntennaFields();
  390. switch (EMCalc.second->GetTxRxMode()) {
  391. case TX:
  392. Ht += EMCalc.second->GetFieldPoints()->GetHfield(0);
  393. break;
  394. case RX:
  395. Hr += EMCalc.second->GetFieldPoints()->GetHfield(0);
  396. break;
  397. case TXRX:
  398. Ht += EMCalc.second->GetFieldPoints()->GetHfield(0);
  399. Hr += EMCalc.second->GetFieldPoints()->GetHfield(0);
  400. break;
  401. default:
  402. break;
  403. }
  404. }
  405. for (int ichild=0; ichild<8; ++ichild) {
  406. Vector3r cp = pos; // Eigen complains about combining these
  407. cp += posadd.row(ichild);
  408. kvals(ichild) = f(cp, vol, Ht.col(ichild), Hr.col(ichild));
  409. }
  410. Complex ksum = kvals.sum(); // Kernel sum
  411. // Evaluate whether or not furthur splitting is needed
  412. Real err = std::abs(ksum - parentVal);
  413. if ( std::abs(ksum - parentVal) > tol || level < minLevel && level < maxLevel ) {
  414. oct->SubdivideLeaf(curse);
  415. for (int ichild=0; ichild<8; ++ichild) {
  416. curse->ToChild(ichild);
  417. Vector3r cp = pos; // Eigen complains about combining these
  418. cp += posadd.row(ichild);
  419. /* Test for position via alternative means
  420. Real p[3];
  421. GetPosition(curse, p);
  422. std::cout << cp[0] << "\t" << p[0] << "\t" << cp[1] << "\t" << p[1]
  423. << "\t" << cp[2] << "\t" << p[2] << "\t" << vol<< std::endl;
  424. */
  425. bool isleaf = EvaluateKids2( size, level+1, cp, kvals(ichild), oct, curse );
  426. if (isleaf) { // Include result in final integral
  427. LeafDict[curse->GetLeafId()] = kvals(ichild); // VTK
  428. LeafDictIdx[curse->GetLeafId()] = nleaves; // VTK
  429. SUM += ksum;
  430. VOLSUM += 8*vol;
  431. nleaves += 1;
  432. }
  433. curse->ToParent();
  434. }
  435. return false; // not leaf
  436. }
  437. return true; // leaf
  438. }
  439. //--------------------------------------------------------------------------------------
  440. // Class: KernelV0
  441. // Method: GetPosition
  442. //--------------------------------------------------------------------------------------
  443. void KernelV0::GetPosition( vtkHyperOctreeCursor* Cursor, Real* p ) {
  444. Real ratio=1.0/(1<<(Cursor->GetCurrentLevel()));
  445. //step = ((Size).array() / std::pow(2.,Cursor->GetCurrentLevel()));
  446. p[0]=(Cursor->GetIndex(0)+.5)*ratio*this->Size[0]+this->Origin[0] ;//+ .5*step[0];
  447. p[1]=(Cursor->GetIndex(1)+.5)*ratio*this->Size[1]+this->Origin[1] ;//+ .5*step[1];
  448. p[2]=(Cursor->GetIndex(2)+.5)*ratio*this->Size[2]+this->Origin[2] ;//+ .5*step[2];
  449. }
  450. #endif
  451. } // ---- end of namespace Lemma ----
  452. /* vim: set tabstop=4 expandtab */
  453. /* vim: set filetype=cpp */