From 99c2e7db0607fc294df8d4e7fbaff9e9c7e8dc7e Mon Sep 17 00:00:00 2001 From: hinder Date: Wed, 9 Oct 2013 17:55:48 +0000 Subject: utils.cc: Treat all integration methods uniformly All tests pass git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinAnalysis/Multipole/trunk@93 4f5cb9a8-4dd8-4c2d-9bbd-173fa4467843 --- src/utils.cc | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/utils.cc b/src/utils.cc index afd4278..dc2f879 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -345,24 +345,9 @@ void Multipole_Integrate(int array_size, int nthetap, iu = Multipole_Index(0,1,ntheta); CCTK_REAL dph = ph[iu] - ph[il]; - if (CCTK_Equals(integration_method, "midpoint")) - { - CCTK_REAL tempr = 0.0; - CCTK_REAL tempi = 0.0; - - for (int i=0; i < array_size; i++) { - // the below calculations take the integral of conj(array1)*array2 - tempr += ( array1r[i]*array2r[i] + array1i[i]*array2i[i] ) - *sin(th[i])*dth*dph; - tempi += ( array1r[i]*array2i[i] - array1i[i]*array2r[i] ) - *sin(th[i])*dth*dph; - - *outre = tempr; - *outim = tempi; - } - } - else if (CCTK_Equals(integration_method, "Simpson") || - CCTK_Equals(integration_method, "DriscollHealy")) + if (CCTK_Equals(integration_method, "Simpson") || + CCTK_Equals(integration_method, "DriscollHealy") || + CCTK_Equals(integration_method, "midpoint")) { static CCTK_REAL *fr = 0; static CCTK_REAL *fi = 0; @@ -376,6 +361,7 @@ void Multipole_Integrate(int array_size, int nthetap, allocated_memory = true; } + // the below calculations take the integral of conj(array1)*array2*sin(th) for (int i = 0; i < array_size; i++) { fr[i] = (array1r[i] * array2r[i] + @@ -384,7 +370,12 @@ void Multipole_Integrate(int array_size, int nthetap, array1i[i] * array2r[i] ) * sin(th[i]); } - if (CCTK_Equals(integration_method, "Simpson")) + if (CCTK_Equals(integration_method, "midpoint")) + { + *outre = Midpoint2DIntegral(fr, ntheta, nphi, dth, dph); + *outim = Midpoint2DIntegral(fi, ntheta, nphi, dth, dph); + } + else if (CCTK_Equals(integration_method, "Simpson")) { if (nphi % 2 != 0 || ntheta % 2 != 0) { -- cgit v1.2.3