Surface NMR forward modelling
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

Coupling.h 8.9KB

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