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.

Coupling.h 9.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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. * @author Trevor Irons (ti)
  12. * @email tirons@egi.utah.edu
  13. * @copyright Copyright (c) 2016, University of Utah
  14. * @copyright Copyright (c) 2016, Lemma Software, LLC
  15. * @copyright Copyright (c) 2008, Colorado School of Mines
  16. */
  17. #ifndef COUPLING_INC
  18. #define COUPLING_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 Coupling : public LemmaObject {
  37. friend std::ostream &operator<<(std::ostream &stream, const Coupling &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 Coupling::NewSP
  53. */
  54. explicit Coupling ( 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 Coupling::DeSerialize
  62. */
  63. Coupling ( 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 ~Coupling ();
  72. /**
  73. * Uses YAML to serialize this object.
  74. * @return a YAML::Node
  75. * @see Coupling::DeSerialize
  76. */
  77. virtual YAML::Node Serialize() const;
  78. /*
  79. * Factory method for generating concrete class.
  80. * @return a std::shared_ptr of type Coupling
  81. */
  82. static std::shared_ptr< Coupling > NewSP();
  83. /**
  84. * Constructs an Coupling object from a YAML::Node.
  85. * @see Coupling::Serialize
  86. */
  87. static std::shared_ptr<Coupling> 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 Coupling::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 Coupling::set_SigmaModel -----
  103. /**
  104. *
  105. */
  106. inline void SetIntegrationSize ( const Vector3r& size ) {
  107. Size = size;
  108. return ;
  109. } // ----- end of method Coupling::SetIntegrationSize -----
  110. /**
  111. *
  112. */
  113. inline void SetIntegrationOrigin ( const Vector3r& origin ) {
  114. Origin = origin;
  115. return ;
  116. } // ----- end of method Coupling::SetIntegrationOrigin -----
  117. /**
  118. * Assign transmiter coils
  119. */
  120. inline void PushCoil( const std::string& label, std::shared_ptr<PolygonalWireAntenna> ant ) {
  121. TxRx[label] = ant;
  122. }
  123. /**
  124. * Calculates a single imaging kernel, however, phased arrays are supported
  125. * so that more than one transmitter and/or receiver can be specified.
  126. * @param[in] tx is the list of transmitters to use for a kernel, use the same labels as
  127. * used in PushCoil.
  128. * @param[in] rx is the list of receivers to use for a kernel, use the same labels as
  129. * used in PushCoil. @see PushCoil
  130. * @param[in] vtkOutput generates a VTK hyperoctree file as well, useful for visualization.
  131. * requires compilation of Lemma with VTK.
  132. */
  133. Complex Calculate (const std::vector< std::string >& tx, const std::vector< std::string >& rx,
  134. bool vtkOutput=false );
  135. /**
  136. * Sets the tolerance to use for making the adaptive mesh
  137. *
  138. */
  139. inline void SetTolerance(const Real& ttol) {
  140. tol = ttol;
  141. }
  142. inline void SetPulseDuration(const Real& taup) {
  143. Taup = taup;
  144. }
  145. // ==================== INQUIRY =======================
  146. /**
  147. * Returns the name of the underlying class, similiar to Python's type
  148. * @return string of class name
  149. */
  150. virtual inline std::string GetName() const {
  151. return CName;
  152. }
  153. protected:
  154. // ==================== LIFECYCLE =======================
  155. /** Copy is disabled */
  156. Coupling( const Coupling& ) = delete;
  157. private:
  158. /**
  159. * Returns the kernel value for an input prism
  160. */
  161. Complex f( const Vector3r& r, const Real& volume , const Vector3cr& Ht, const Vector3cr& Hr);
  162. void IntegrateOnOctreeGrid( bool vtkOutput=false );
  163. /**
  164. * Recursive call to integrate a function on an adaptive Octree Grid.
  165. * For efficiency's sake the octree grid is not stored, as only the
  166. * integral (sum) is of interest. The logic for grid refinement is based
  167. * on an Octree representation of the domain. If an Octree representation
  168. * of the kernel is desired, call alternative version @see EvaluateKids2
  169. * @param[in] size gives the domain size, in metres
  170. * @param[in] level gives the current level of the octree grid, call with 0 initially
  171. * @param[in] cpos is the centre position of the parent cuboid
  172. */
  173. void EvaluateKids( const Vector3r& size, const int& level, const Vector3r& cpos,
  174. const Complex& parentVal );
  175. #ifdef LEMMAUSEVTK
  176. /**
  177. * Same functionality as @see EvaluateKids, but includes generation of a VTK
  178. * HyperOctree, which is useful for visualization.
  179. */
  180. void EvaluateKids2( const Vector3r& size, const int& level, const Vector3r& cpos,
  181. const Complex& parentVal, vtkHyperOctree* octree, vtkHyperOctreeCursor* curse );
  182. void GetPosition( vtkHyperOctreeCursor* Cursor, Real* p );
  183. #endif
  184. // ==================== DATA MEMBERS =========================
  185. int ilay;
  186. int nleaves;
  187. int minLevel=4;
  188. int maxLevel=8;
  189. Real VOLSUM;
  190. Real tol=1e-11;
  191. Real Taup = .020; // Sec
  192. Complex SUM;
  193. Vector3r Size;
  194. Vector3r Origin;
  195. std::shared_ptr< LayeredEarthEM > SigmaModel = nullptr;
  196. std::shared_ptr< FieldPoints > cpoints;
  197. std::map< std::string , std::shared_ptr< PolygonalWireAntenna > > TxRx;
  198. std::map< std::string , std::shared_ptr< EMEarth1D > > EMEarths;
  199. #ifdef LEMMAUSEVTK
  200. std::map< int, Complex > LeafDict;
  201. std::map< int, int > LeafDictIdx;
  202. std::map< int, Real > LeafDictErr;
  203. #endif
  204. /** ASCII string representation of the class name */
  205. static constexpr auto CName = "Coupling";
  206. }; // ----- end of class Coupling -----
  207. } // ----- end of namespace Lemma ----
  208. /* vim: set tabstop=4 expandtab */
  209. /* vim: set filetype=cpp */
  210. #endif // ----- #ifndef COUPLING_INC -----