00001
00008 #include <stdio.h>
00009 #include <stdlib.h>
00010 #include "transfer.h"
00011 #include "charm.h"
00012
00013 int main(int argc,char *argv[]) {
00014 if (argc<2) {printf("Usage: test_transfer <src .noboite file> <dest .noboite file>\n"); exit(1);}
00015 TetMesh srcMesh, destMesh;
00016 readNoboite(fopen(argv[1],"r"),srcMesh);
00017 printf("Source "); printSize(srcMesh);
00018 readNoboite(fopen(argv[2],"r"),destMesh);
00019 printf("Destination "); printSize(destMesh);
00020
00021
00022 int s,nSrc=srcMesh.getTets();
00023 double *src=new double[nSrc];
00024 double totalSrc=0;
00025 for (s=0;s<nSrc;s++) {
00026 double v=0.1*s;
00027 src[s]=v;
00028 totalSrc+=v*srcMesh.getTetVolume(s);
00029 }
00030 int d,nDest=destMesh.getTets();
00031 double *dest=new double[nDest];
00032 for (d=0;d<nDest;d++) dest[d]=-1;
00033
00034 transferCells(1,src,srcMesh,dest,destMesh);
00035
00036 double totalDest=0;
00037 for (d=0;d<nDest;d++)
00038 totalDest+=dest[d]*destMesh.getTetVolume(d);
00039 double err=totalSrc-totalDest;
00040 if (fabs(err)>1.0e-10) CkAbort("Total data transferred doesn't match!");
00041
00042 printf("Transfer successful: total error %.3g\n",err);
00043
00044 return 0;
00045 }