integrationformulasummed.h

Go to the documentation of this file.
00001 #ifndef __IntegrationFormulaSummed_h
00002 #define __IntegrationFormulaSummed_h
00003 
00004 #include  "integrationformula.h"
00005 
00006 /*------------------------------------------------------------*/
00007 
00008 namespace Gascoigne
00009 {
00010 
00011 template<class INT>
00012 class IntegrationFormulaSummed1d : public IntegrationFormula1d
00013 {
00014  protected:
00015 
00016   INT I;
00017 
00018  public:
00019 
00020   IntegrationFormulaSummed1d(int n) : IntegrationFormula1d(), I()
00021     {
00022       int    N = static_cast<int>(pow(2.,n));
00023 
00024       IntegrationFormula1d::ReInit(N*I.n());
00025 
00026       int nn = static_cast<int>(pow(2.,n));
00027       double d2 = pow(0.5,n);
00028 
00029       for(int i=0;i<N;i++)
00030         {
00031           int ix = i%nn;
00032           double dx = 1.*ix;
00033 
00034           for(int ii=0;ii<I.n();ii++)
00035             {
00036               int index = i*I.n()+ii;
00037               w(index) = d2 * I.w(ii);
00038 
00039               double x = I.c(ii).x();
00040 
00041               x += dx;
00042               x *= d2;
00043 
00044               c(index).x() = x;
00045             }
00046         }
00047     }
00048 };
00049 
00050 /*------------------------------------------------------------*/
00051 
00052 template<class INT>
00053 class IntegrationFormulaSummed2d : public IntegrationFormula2d
00054 {
00055  protected:
00056 
00057   INT I;
00058 
00059  public:
00060 
00061   IntegrationFormulaSummed2d(int n=4) : IntegrationFormula2d(), I()
00062     {
00063       int    N = static_cast<int>(pow(4.,n));
00064 
00065       IntegrationFormula2d::ReInit(N*I.n());
00066 
00067       int nn = static_cast<int>(pow(2.,n));
00068       double d2 = pow(0.5,n);
00069       double d4 = pow(0.25,n);
00070 
00071       for(int i=0;i<N;i++)
00072         {
00073           int ix = i%nn;
00074           int iy = i/nn;
00075 
00076           double dx = 1.*ix;
00077           double dy = 1.*iy;
00078 
00079           for(int ii=0;ii<I.n();ii++)
00080             {
00081               int index = i*I.n()+ii;
00082               w(index) = d4 * I.w(ii);
00083 
00084               double x = I.c(ii).x();
00085               double y = I.c(ii).y();
00086 
00087               x += dx;
00088               y += dy;
00089 
00090               x *= d2;
00091               y *= d2;
00092 
00093               c(index).x() = x;
00094               c(index).y() = y;
00095             }
00096         }
00097     }
00098 };
00099 
00100 /*------------------------------------------------------------*/
00101 
00102 template<class INT>
00103 class IntegrationFormulaSummed3d : public IntegrationFormula3d
00104 {
00105  protected:
00106 
00107   INT I;
00108 
00109  public:
00110 
00111   IntegrationFormulaSummed3d(int n=2) : IntegrationFormula3d(), I()
00112     {
00113       int    N = static_cast<int>(pow(8.,n));
00114 
00115       IntegrationFormula3d::ReInit(N*I.n());
00116 
00117       int nn = static_cast<int>(pow(2.,n));
00118       double d2 = pow(0.5,n);
00119       double d8 = pow(0.125,n);
00120 
00121       for(int i=0;i<N;i++)
00122         {
00123           int ix = i%nn;
00124           int j = (i-ix)/nn;
00125 
00126           int iy = j%nn;
00127           int iz = j/nn;
00128 
00129           double dx = 1.*ix;
00130           double dy = 1.*iy;
00131           double dz = 1.*iz;
00132 
00133           for(int ii=0;ii<I.n();ii++)
00134             {
00135               int index = i*I.n()+ii;
00136               w(index) = d8 * I.w(ii);
00137 
00138               double x = I.c(ii).x();
00139               double y = I.c(ii).y();
00140               double z = I.c(ii).z();
00141 
00142               x += dx;
00143               y += dy;
00144               z += dz;
00145 
00146               x *= d2;
00147               y *= d2;
00148               z *= d2;
00149 
00150               c(index).x() = x;
00151               c(index).y() = y;
00152               c(index).z() = z;
00153             }
00154         }
00155     }
00156 };
00157 
00158 }
00159 
00160 #endif

Generated on Thu Sep 14 10:34:35 2006 for Gascoigne by  doxygen 1.4.7