ExaFMM 1
Fast-multipole Method for exascale systems
|
00001 /* 00002 Copyright (C) 2011 by Rio Yokota, Simon Layton, Lorena Barba 00003 00004 Permission is hereby granted, free of charge, to any person obtaining a copy 00005 of this software and associated documentation files (the "Software"), to deal 00006 in the Software without restriction, including without limitation the rights 00007 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00008 copies of the Software, and to permit persons to whom the Software is 00009 furnished to do so, subject to the following conditions: 00010 00011 The above copyright notice and this permission notice shall be included in 00012 all copies or substantial portions of the Software. 00013 00014 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00015 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00016 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00017 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00018 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00019 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00020 THE SOFTWARE. 00021 */ 00022 #include "evaluator.h" 00023 00024 int main() { 00025 const int numBodies = 100; 00026 IMAGES = 0; 00027 THETA = 1 / sqrtf(4); 00028 Bodies ibodies(numBodies); 00029 Bodies ibodies2(numBodies); 00030 Bodies jbodies(numBodies); 00031 Cells icells; 00032 Cells jcells; 00033 Evaluator<Laplace> FMM; 00034 FMM.initialize(); 00035 FMM.preCalculation(); 00036 00037 for( int it=0; it!=10; ++it ) { 00038 real dist = (1 << it) / 2; 00039 for( B_iter B=ibodies.begin(); B!=ibodies.end(); ++B ) { 00040 for( int d=0; d!=3; ++d ) { 00041 B->X[d] = -drand48() - dist; 00042 } 00043 } 00044 for( B_iter B=jbodies.begin(); B!=jbodies.end(); ++B ) { 00045 for( int d=0; d!=3; ++d ) { 00046 B->X[d] = drand48(); 00047 } 00048 } 00049 FMM.initSource(jbodies); 00050 bool IeqJ = false; 00051 FMM.initTarget(ibodies,IeqJ); 00052 00053 Cell cell; 00054 cell.NDLEAF = numBodies; 00055 cell.LEAF = jbodies.begin(); 00056 cell.X = 0.5; 00057 cell.M = 0; 00058 cell.ICELL = 8; 00059 cell.NCHILD = 0; 00060 cell.PARENT = 1; 00061 jcells.push_back(cell); 00062 FMM.evalP2M(jcells); 00063 cell.X = 1; 00064 cell.M = 0; 00065 cell.ICELL = 0; 00066 cell.NCHILD = 1; 00067 cell.CHILD = 0; 00068 jcells.push_back(cell); 00069 FMM.evalM2M(jcells,jcells); 00070 jcells.erase(jcells.begin()); 00071 cell.X = -1 - dist; 00072 cell.M = 1; 00073 cell.L = 0; 00074 cell.ICELL = 0; 00075 icells.push_back(cell); 00076 FMM.addM2L(jcells.begin()); 00077 FMM.evalM2L(icells); 00078 cell.NDLEAF = numBodies; 00079 cell.LEAF = ibodies.begin(); 00080 cell.X = -0.5 - dist; 00081 cell.L = 0; 00082 cell.ICELL = 1; 00083 cell.NCHILD = 0; 00084 cell.PARENT = 1; 00085 icells.insert(icells.begin(),cell); 00086 FMM.evalL2L(icells); 00087 icells.pop_back(); 00088 FMM.evalL2P(icells); 00089 00090 ibodies2 = ibodies; 00091 FMM.initTarget(ibodies2,IeqJ); 00092 FMM.evalP2P(ibodies2,jbodies); 00093 00094 real diff1 = 0, norm1 = 0, diff2 = 0, norm2 = 0; 00095 FMM.evalError(ibodies,ibodies2,diff1,norm1,diff2,norm2); 00096 std::cout << "Distance : " << dist << std::endl; 00097 FMM.printError(diff1,norm1,diff2,norm2); 00098 00099 FMM.initTarget(ibodies); 00100 FMM.addM2P(jcells.begin()); 00101 FMM.evalM2P(icells); 00102 icells.clear(); 00103 jcells.clear(); 00104 diff1 = norm1 = diff2 = norm2 = 0; 00105 FMM.evalError(ibodies,ibodies2,diff1,norm1,diff2,norm2); 00106 FMM.printError(diff1,norm1,diff2,norm2); 00107 } 00108 FMM.postCalculation(); 00109 FMM.finalize(); 00110 }