Lemma is an Electromagnetics API
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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 02/12/2014 10:20:18 AM
  11. * @version $Id$
  12. * @author Trevor Irons (ti)
  13. * @email Trevor.Irons@lemmasoftware.org
  14. * @copyright Copyright (c) 2014, Trevor Irons
  15. */
  16. #ifndef QWEKEY_INC
  17. #define QWEKEY_INC
  18. #include "HankelTransform.h"
  19. #include <Eigen/Eigenvalues>
  20. #ifdef HAVE_BOOST_SPECIAL_FUNCTIONS
  21. #include "boost/math/special_functions.hpp"
  22. #include "boost/math/special_functions/bessel.hpp"
  23. #endif
  24. namespace Lemma {
  25. /** breakpoint to use in division of domain, based on zeros of bessel function or
  26. regular nPi spacing.
  27. */
  28. enum sZeroType{J0, J1, NPI};
  29. /**
  30. \brief Port of Key's quadrature with extrapolation Hankel transform algorithm.
  31. \details Details of the algorithm can be found in Key2011. This code is a port
  32. of the published algorithm, which contains the following notice:
  33. %------------------------------------------------------------------%
  34. % Copyright (c) 2012 by the Society of Exploration Geophysicists. %
  35. % For more information, go to http://software.seg.org/2012/0003 . %
  36. % You must read and accept usage terms at: %
  37. % http://software.seg.org/disclaimer.txt before use. %
  38. %------------------------------------------------------------------%
  39. */
  40. class QWEKey : public HankelTransform {
  41. friend std::ostream &operator<<(std::ostream &stream, const QWEKey &ob);
  42. public:
  43. // ==================== LIFECYCLE =======================
  44. /** Default locked constructor, use NewSP */
  45. QWEKey ( const ctor_key& );
  46. /** DeSerializing locked constructor, use DeSerialize */
  47. QWEKey ( const YAML::Node& node, const ctor_key& );
  48. /** Default destructor */
  49. ~QWEKey ();
  50. /**
  51. * Factory method for generating objects.
  52. * @return std::shared_ptr< QWEKey >
  53. */
  54. static std::shared_ptr<QWEKey> NewSP();
  55. /** YAML Serializing method
  56. */
  57. YAML::Node Serialize() const;
  58. /**
  59. * Constructs an object from a YAML::Node.
  60. */
  61. static std::shared_ptr< QWEKey > DeSerialize(const YAML::Node& node);
  62. // ==================== OPERATORS =======================
  63. void TestPrivate(const int& N);
  64. // ==================== OPERATIONS =======================
  65. Complex Zgauss(const int &ikk, const EMMODE &imode,
  66. const int &itype, const Real &rho,
  67. const Real &wavef, KernelEM1DBase* Kernel);
  68. /// Computes related kernels, if applicable, otherwise this is
  69. /// just a dummy function.
  70. void ComputeRelated(const Real& rho, std::shared_ptr<KernelEM1DBase> Kernel);
  71. void ComputeRelated(const Real& rho, std::vector< std::shared_ptr<KernelEM1DBase> > KernelVec);
  72. void ComputeRelated(const Real& rho, std::shared_ptr<KernelEM1DManager> KernelManager);
  73. // ==================== ACCESS =======================
  74. // ==================== INQUIRY =======================
  75. /** Returns the name of the underlying class, similiar to Python's type */
  76. virtual std::string GetName() const ;
  77. protected:
  78. // ==================== LIFECYCLE =======================
  79. /** Calculates Gauss quadrature weights of order N on the interval -1,1
  80. Algorithm from p 129 in:
  81. Trefethen, L. N., 2000, Spectral methods in MATLAB: Society for
  82. Industrial and Applied Mathematics (SIAM), volume 10 of Software,
  83. Environments, and Tools.
  84. */
  85. void GaussQuadWeights(const int& N);
  86. /** Returns the quadrature intervals and Bessel function weights used for the
  87. QWE method.
  88. */
  89. void BesselWeights( const sZeroType& sType);
  90. /** Computes an infinite integral using the partial sum of quadrature terms
  91. accelerated by sequence extrapolation using the Shanks transformation
  92. implemented with Wynn's epsilon algorithm.
  93. */
  94. void QWE(const Real& rho);
  95. /** Calls the underlying kernel functions evaluated as necessary
  96. */
  97. void getEyKernel(const int& i, const int& idx, const Real& rho);
  98. private:
  99. // ==================== DATA MEMBERS =========================
  100. /** Relative tolerance, default is 1e-6 */
  101. Real RelTol;
  102. /** Absolute tolerance, default is 1e-24 */
  103. Real AbsTol;
  104. /** Quadrature order, higher is more accurate but more expensive. Eefault is 9 */
  105. int nQuad;
  106. /** in QWE partial integrals before Shanks recurive algorithm. Defaults to 1 */
  107. int nDelay;
  108. /** Maximum number of intervals to integrate over . Defaults to 40 */
  109. int nIntervalsMax;
  110. /** Weighing of gaussian quadrature points */
  111. VectorXr GaussWeights;
  112. /** Abscissa locations of quadrature points */
  113. VectorXr GaussAbscissa;
  114. /** Breakpoints for dividing up the global integral */
  115. VectorXr xInt;
  116. /** All quadrature points between all breakpoints */
  117. VectorXr Bx;
  118. /** J0 weights */
  119. VectorXr BJ0;
  120. /** J1 weights */
  121. VectorXr BJ1;
  122. /** array of lambda arguments */
  123. VectorXr Lambda;
  124. /** array of lambda arguments */
  125. VectorXr Intervals;
  126. MatrixXcr TS;
  127. VectorXi Tn;
  128. MatrixXcr Textrap;
  129. MatrixXr TrelErr;
  130. MatrixXr TabsErr;
  131. /** Container to hold bessel arguments */
  132. Eigen::Matrix<Complex, Eigen::Dynamic, Eigen::Dynamic > Zwork;
  133. /** Container to hold bessel arguments */
  134. Eigen::Matrix<Complex, Eigen::Dynamic, Eigen::Dynamic > Zans;
  135. /** Manager for related kernels to evaluate */
  136. std::shared_ptr<KernelEM1DManager> KernelManager;
  137. /** ASCII string representation of the class name */
  138. static constexpr auto CName = "QWEKey";
  139. }; // ----- end of class QWEKey -----
  140. } // ----- end of Lemma name -----
  141. #endif // ----- #ifndef QWEKEY_INC -----