Lemma is an Electromagnetics API
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.

sintransintegrationkernel.cpp 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* This file is part of Lemma, a geophysical modelling and inversion API */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. /**
  6. @file
  7. @author Trevor Irons
  8. @date 02/08/2011
  9. @version $Id: sintransintegrationkernel.cpp 87 2013-09-05 22:44:05Z tirons $
  10. **/
  11. #include "sintransintegrationkernel.h"
  12. namespace Lemma {
  13. // ==================== FRIENDS =======================
  14. // std::ostream &operator<<(std::ostream &stream,
  15. // const DigitalFilterSinTrans &ob) {
  16. // stream << *(DigitalFilterIntegrator<Real>*)(&ob);
  17. // return stream;
  18. // }
  19. // ==================== LIFECYCLE =======================
  20. SinTransIntegrationKernel::
  21. SinTransIntegrationKernel(const std::string& name) :
  22. IntegrationKernel<Real>(name) {
  23. }
  24. SinTransIntegrationKernel::~SinTransIntegrationKernel() {}
  25. SinTransIntegrationKernel* SinTransIntegrationKernel::New() {
  26. SinTransIntegrationKernel* Obj =
  27. new SinTransIntegrationKernel("SinTransIntegrationKernel");
  28. Obj->AttachTo(Obj);
  29. return Obj;
  30. }
  31. void SinTransIntegrationKernel::Delete() {
  32. this->DetachFrom(this);
  33. }
  34. void SinTransIntegrationKernel::Release() {
  35. delete this;
  36. }
  37. // ==================== OPERATIONS =======================
  38. void SinTransIntegrationKernel::SetA(const Real& Ain) {
  39. A = Ain;
  40. }
  41. void SinTransIntegrationKernel::SetIntegral(const int& i) {
  42. Integral = i;
  43. }
  44. Real SinTransIntegrationKernel::GetAnalytical (const Real& B) {
  45. Real SQPI = std::sqrt(PI);
  46. switch (Integral) {
  47. case 1:
  48. return SQPI*B*std::exp(-B*B/(4.*A*A))/(4.*A*A*A);
  49. break;
  50. case 2:
  51. return (PI/2.)*std::exp(-A*B);
  52. break;
  53. case 3:
  54. return B/(A*A+B*B);
  55. break;
  56. default:
  57. std::cerr << "Test integral is not allowed\n";
  58. exit(EXIT_FAILURE);
  59. }
  60. }
  61. Real SinTransIntegrationKernel::Argument(const Real&x, const int& iRelated) {
  62. // 1 DEXP(-A*A*G*G) SQPI*DEXP(-B*B/(4.*A*A))/(2.*A), WHERE
  63. // SQPI="SQUARE ROOT OF PI"
  64. // 2 1/(A*A+G*G) (PI/2)*DEXP(-A*B)/A
  65. // 3 DEXP(-A*G) A/(A*A+B*B)
  66. switch (Integral) {
  67. case 1:
  68. return x*std::exp( -A*A*x*x );
  69. case 2:
  70. return x/(A*A+x*x);
  71. case 3:
  72. return std::exp(-A*x);
  73. default:
  74. std::cerr << "Test integral is not allowed\n";
  75. exit(EXIT_FAILURE);
  76. }
  77. }
  78. int SinTransIntegrationKernel::GetNumRel( ) {
  79. return 1;
  80. }
  81. } // ----- end of Lemma name -----