Surface NMR forward modelling
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

KernelV0.h 7.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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:34 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. #ifndef KERNELV0_INC
  18. #define KERNELV0_INC
  19. #pragma once
  20. #include "LemmaObject.h"
  21. #include "LayeredEarthEM.h"
  22. #include "PolygonalWireAntenna.h"
  23. #include "EMEarth1D.h"
  24. #ifdef LEMMAUSEVTK
  25. #include "vtkHyperOctree.h"
  26. #include "vtkHyperOctreeCursor.h"
  27. #include "vtkXMLHyperOctreeWriter.h"
  28. #include "vtkDoubleArray.h"
  29. #endif
  30. namespace Lemma {
  31. /**
  32. * \ingroup Merlin
  33. * \brief
  34. * \details
  35. */
  36. class KernelV0 : public LemmaObject {
  37. friend std::ostream &operator<<(std::ostream &stream, const KernelV0 &ob);
  38. protected:
  39. /*
  40. * This key is used to lock the constructor. It is protected so that inhereted
  41. * classes also have the key to contruct their base class.
  42. */
  43. struct ctor_key {};
  44. public:
  45. // ==================== LIFECYCLE =======================
  46. /**
  47. * Default constructor.
  48. * @note This method is locked, and cannot be called directly.
  49. * The reason that the method is public is to enable the use
  50. * of make_shared whilst enforcing the use of shared_ptr,
  51. * in c++-17, this curiosity may be resolved.
  52. * @see KernelV0::NewSP
  53. */
  54. explicit KernelV0 ( const ctor_key& );
  55. /**
  56. * DeSerializing constructor.
  57. * @note This method is locked, and cannot be called directly.
  58. * The reason that the method is public is to enable the use
  59. * of make_shared whilst enforcing the use of shared_ptr,
  60. * in c++-17, this curiosity may be resolved.
  61. * @see KernelV0::DeSerialize
  62. */
  63. KernelV0 ( const YAML::Node& node, const ctor_key& );
  64. /**
  65. * Default destructor.
  66. * @note This method should never be called due to the mandated
  67. * use of smart pointers. It is necessary to keep the method
  68. * public in order to allow for the use of the more efficient
  69. * make_shared constructor.
  70. */
  71. virtual ~KernelV0 ();
  72. /**
  73. * Uses YAML to serialize this object.
  74. * @return a YAML::Node
  75. * @see KernelV0::DeSerialize
  76. */
  77. virtual YAML::Node Serialize() const;
  78. /*
  79. * Factory method for generating concrete class.
  80. * @return a std::shared_ptr of type KernelV0
  81. */
  82. static std::shared_ptr< KernelV0 > NewSP();
  83. /**
  84. * Constructs an KernelV0 object from a YAML::Node.
  85. * @see KernelV0::Serialize
  86. */
  87. static std::shared_ptr<KernelV0> DeSerialize(const YAML::Node& node);
  88. // ==================== OPERATORS =======================
  89. // ==================== OPERATIONS =======================
  90. /**
  91. * @return std::shared_ptr<LayeredEarthEM>
  92. */
  93. inline std::shared_ptr<LayeredEarthEM> GetSigmaModel ( ) {
  94. return SigmaModel;
  95. } // ----- end of method KernelV0::get_SigmaModel -----
  96. /**
  97. * @param[in] value the 1D-EM model used for calculations
  98. */
  99. inline void SetLayeredEarthEM ( std::shared_ptr< LayeredEarthEM > value ) {
  100. SigmaModel = value;
  101. return ;
  102. } // ----- end of method KernelV0::set_SigmaModel -----
  103. /**
  104. * Assign transmiter coils
  105. */
  106. inline void PushCoil( const std::string& label, std::shared_ptr<PolygonalWireAntenna> ant ) {
  107. TxRx[label] = ant;
  108. }
  109. /**
  110. * Calculates a single imaging kernel, however, phased arrays are supported
  111. * so that more than one transmitter and/or receiver can be specified.
  112. * @param[in] tx is the list of transmitters to use for a kernel, use the same labels as
  113. * used in PushCoil.
  114. * @param[in] rx is the list of receivers to use for a kernel, use the same labels as
  115. * used in PushCoil. @see PushCoil
  116. * @param[in] vtkOutput generates a VTK hyperoctree file as well, useful for visualization.
  117. * requires compilation of Lemma with VTK.
  118. */
  119. void CalculateK0 (const std::vector< std::string >& tx, const std::vector< std::string >& rx,
  120. bool vtkOutput=false );
  121. // ==================== INQUIRY =======================
  122. /**
  123. * Returns the name of the underlying class, similiar to Python's type
  124. * @return string of class name
  125. */
  126. virtual inline std::string GetName() const {
  127. return CName;
  128. }
  129. protected:
  130. // ==================== LIFECYCLE =======================
  131. /** Copy is disabled */
  132. KernelV0( const KernelV0& ) = delete;
  133. private:
  134. /**
  135. * Returns the kernel value for an input prism
  136. */
  137. Complex f( const Vector3r& r, const Real& volume , const Vector3cr& Bt);
  138. void IntegrateOnOctreeGrid( const Real& tolerance , bool vtkOutput=false );
  139. /**
  140. * Recursive call to integrate a function on an adaptive Octree Grid.
  141. * For efficiency's sake the octree grid is not stored, as only the
  142. * integral (sum) is of interest. The logic for grid refinement is based
  143. * on an Octree representation of the domain. If an Octree representation
  144. * of the kernel is desired, call alternative version @see EvaluateKids2
  145. * @param[in] size gives the domain size, in metres
  146. * @param[in] level gives the current level of the octree grid, call with 0 initially
  147. * @param[in] cpos is the centre position of the parent cuboid
  148. */
  149. bool EvaluateKids( const Vector3r& size, const int& level, const Vector3r& cpos,
  150. const Complex& parentVal );
  151. #ifdef LEMMAUSEVTK
  152. /**
  153. * Same functionality as @see EvaluateKids, but includes generation of a VTK
  154. * HyperOctree, which is useful for visualization.
  155. */
  156. bool EvaluateKids2( const Vector3r& size, const int& level, const Vector3r& cpos,
  157. const Complex& parentVal, vtkHyperOctree* octree, vtkHyperOctreeCursor* curse );
  158. void GetPosition( vtkHyperOctreeCursor* Cursor, Real* p );
  159. #endif
  160. // ==================== DATA MEMBERS =========================
  161. Complex SUM;
  162. Real VOLSUM;
  163. Real tol=1e-3;
  164. int nleaves;
  165. Vector3r Size;
  166. Vector3r Origin;
  167. std::shared_ptr< LayeredEarthEM > SigmaModel = nullptr;
  168. std::map< std::string , std::shared_ptr< PolygonalWireAntenna > > TxRx;
  169. std::vector< std::shared_ptr<EMEarth1D> > EMEarths;
  170. #ifdef LEMMAUSEVTK
  171. std::map< int, Complex > LeafDict;
  172. #endif
  173. /** ASCII string representation of the class name */
  174. static constexpr auto CName = "KernelV0";
  175. }; // ----- end of class KernelV0 -----
  176. } // ----- end of namespace Lemma ----
  177. /* vim: set tabstop=4 expandtab */
  178. /* vim: set filetype=cpp */
  179. #endif // ----- #ifndef KERNELV0_INC -----