int main int  argc,
char **  argv
 

Main function operates in several steps: First, the options file as provided to optionsCreate is parsed. From this, we get the number of sources and target points (numSrc, numTrg), the kernel type (kt - see kernel3d.hpp and kernel3d.cpp), etc. Random locations are generated for source and target locations. Random sources densities are allocated based on the degrees of freedom of the specified kernel, and target value space is allocated as well. Then, space for the fmm is allocated and variables are set. Fmm is then this run and checked/clocked.

1. allocate random data

numSrc = Number of source points

numTrg = Number of target points

Declare kernel as knl of type kt and coefficients temp

Allocate random data for source positions (srcPos) and target positions (trgPos)

srcDOF = source degree of freedom. See kernel3d.hpp

trgDOF = target degree of freedom. See kernel3d.hpp

srcDen = source density values of size sDOF*numSrc

2. allocate fmm

3. run fmm

4. check

Definition at line 57 of file tt.cpp.

References optionsCreate().

00058 {
00059   srand48( (long)time(NULL) );  //srand48( 0 );
00060   iA(argc==2);
00061   map<string,string> optionsMap;
00062   optionsCreate(argv[1], optionsMap);
00063   
00065   map<string,string>::iterator mapIdx;
00066   mapIdx = optionsMap.find("-numSrc"); assert(mapIdx!=optionsMap.end());
00068   int numSrc;  { istringstream ss((*mapIdx).second);  ss >> numSrc; }
00069   mapIdx = optionsMap.find("-numTrg"); assert(mapIdx!=optionsMap.end());
00071   int numTrg;  { istringstream ss((*mapIdx).second);  ss >> numTrg; }
00072   mapIdx = optionsMap.find("-kt"); assert(mapIdx!=optionsMap.end());
00073   /* ht = Kernel Type.  See kernel3d.hpp */
00074   int kernelType;  { istringstream ss((*mapIdx).second);  ss>>kernelType; }
00075     
00076   vector<double> tmp(2);         tmp[0] = 1;     tmp[1] = 0.25; //coefs in the kernel, work for all examples
00078   Kernel3d knl(kernelType, tmp);
00079 
00081   DblNumMat srcPos(3, numSrc);
00082   for(int i=0; i<numSrc; i++) {
00083          srcPos(0,i) = (2.0*drand48()-1.0);
00084          srcPos(1,i) = (2.0*drand48()-1.0);
00085          srcPos(2,i) = (2.0*drand48()-1.0);
00086   }
00087   DblNumMat trgPos(3, numTrg);
00088   for(int i=0; i<numTrg; i++) {
00089          trgPos(0,i) = (2.0*drand48()-1.0);
00090          trgPos(1,i) = (2.0*drand48()-1.0);
00091          trgPos(2,i) = (2.0*drand48()-1.0);
00092   }
00093 
00095   int srcDOF = knl.srcDOF();
00097   int trgDOF = knl.trgDOF();
00099   DblNumVec srcDen(srcDOF * numSrc);
00100   for(int i=0; i<numSrc; i++) {
00101          for(int d=0; d<srcDOF; d++)
00102                 srcDen(d + i*srcDOF) = drand48(); //(2.0*drand48()-1.0);
00103   }
00104   /* trgVal = target values of size trgDOF *numTrg */
00105   DblNumVec trgVal(trgDOF * numTrg);
00106   
00108   clock_t clockZero, clockOne;
00109   
00110   FMM3d* fmm = new FMM3d("fmm3d_");
00111   fmm->srcPos()=&srcPos;  fmm->srcNor()=&srcPos;
00112   fmm->trgPos()=&trgPos;
00113   fmm->center() = Point3(0,0,0); // CENTER OF THE TOPLEVEL BOX
00114   fmm->rootLevel() = 0;         // 2^(-rootlvl) is the RADIUS OF THE TOPLEVEL BOX
00115   fmm->knl() = knl;
00116   
00117   clockZero = clock();
00118   iC( fmm->setup(optionsMap) );
00119   clockOne = clock();  cout<<"fmm setup used "<<double(clockOne-clockZero)/CLOCKS_PER_SEC<<"secs "<<endl;
00120   
00122   for(int i=0; i<3; i++) {
00123          clockZero = clock();
00124          iC( fmm->evaluate(srcDen, trgVal) );
00125          clockOne = clock();  cout<<"fmm eval used "<<double(clockOne-clockZero)/CLOCKS_PER_SEC<<"secs "<<endl;
00126   }
00127   
00129   clockZero = clock();
00130   double relativeError;
00131   iC( fmm->check(srcDen, trgVal, 20, relativeError) );
00132   cout << "relative error: " << relativeError << endl;
00133   clockOne = clock();  cout<<"fmm check used "<<double(clockOne-clockZero)/CLOCKS_PER_SEC<<"sec "<<endl;
00134   
00135   delete fmm;
00136   
00137   return 0;
00138 }


Generated on Sun Dec 4 19:24:40 2005 for fmm3d by  doxygen 1.4.5