Commits

Rio Yokota committed 4d787ce

Integrating exafmm2d.

Comments (0)

Files changed (3)

   PetscFunctionBegin;
   PetscValidHeaderSpecific(iga,IGA_CLASSID,2);
   if (iga) fmm->iga = iga;
+  FMM_Init(0);
   PetscFunctionReturn(0);
 }
 
   IGA iga = fmm->iga;
   PetscInt ni = fmm->ni;
   PetscInt nb = fmm->nb;
-  //PetscInt *ip1 = fmm->ip1;
   PetscReal *xi  = fmm->xi;
   PetscReal *yi  = fmm->yi;
   PetscReal *ri  = fmm->ri;
-  //PetscReal *xb  = fmm->xb;
-  //PetscReal *yb  = fmm->yb;
   PetscReal *ub  = fmm->ub;
   PetscReal *xm  = fmm->xm;
   PetscReal *ym  = fmm->ym;
   nb = ic; // this is ok, but we should improve memory allocation
   assert( nb == ic );
 
-  nbodyG(nb,xm,ym,rhs,ni,xi,yi,ri,0.0);
-  nbodyGn(nb,xm,ym,rhs,nb,xm,ym,um,dxe,dye,re,eps);
+  FMM(nb,xm,ym,rhs,ni,xi,yi,ri);
+  //nbodyGn(nb,xm,ym,rhs,nb,xm,ym,um,dxe,dye,re,eps);
 
   for (i=0; i<nb; i++) {
     VecSetValue(f,i,rhs[i],INSERT_VALUES);
   for (i=0; i<ni; i++) {
     ui[i] = 0;
   }
-  nbodyG(ni,xi,yi,ui,ni,xi,yi,ri,eps);
-  nbodyG(ni,xi,yi,ui,nb,xm,ym,un,0.0);
-  nbodyGn(ni,xi,yi,ui,nb,xm,ym,um,dxe,dye,re,eps);
+  FMM(ni,xi,yi,ui,ni,xi,yi,ri);
+  FMM(ni,xi,yi,ui,nb,xm,ym,un);
+  //nbodyGn(ni,xi,yi,ui,nb,xm,ym,um,dxe,dye,re,eps);
 
   ic = 0;
   for (i=info.xs+1; i<info.xs+info.xm-1; i++) {
     }
   }
 
-  /* ic = 0; */
-  /* j = 0; */
-  /* for (i=info.xs; i<info.xs+info.xm-1; i++,ic++) { // Bottom points                                                                                           */
-  /*   Y[j][i] = ub[ic]; */
-  /* } */
-  /* i = info.xs+info.xm-1; */
-  /* for (j=info.ys; j<info.ys+info.ym-1; j++,ic++) { // Right points                                                                                            */
-  /*   Y[j][i] = ub[ic];                                                                                                                                     */
-  /* } */
-  /* j = info.ys+info.ym-1; */
-  /* for (i=info.xs+info.xm-1; i>info.xs; i--,ic++) { // Top points                                                                                              */
-  /*   Y[j][i] = ub[ic];                                                                                                                                     */
-  /* } */
-  /* i = 0; */
-  /* for (j=info.ys+info.ym-1; j>info.ys; j--,ic++) { // Left points                                                                                             */
-  /*   Y[j][i] = ub[ic];                                                                                                                                     */
-  /* } */
+#if 0
+  ic = 0;
+  j = 0;
+  for (i=info.xs; i<info.xs+info.xm-1; i++,ic++) { // Bottom points
+    Y[j][i] = ub[ic];
+  }
+  i = info.xs+info.xm-1;
+  for (j=info.ys; j<info.ys+info.ym-1; j++,ic++) { // Right points
+    Y[j][i] = ub[ic];
+  }
+  j = info.ys+info.ym-1;
+  for (i=info.xs+info.xm-1; i>info.xs; i--,ic++) { // Top points
+    Y[j][i] = ub[ic];
+  }
+  i = 0;
+  for (j=info.ys+info.ym-1; j>info.ys; j--,ic++) { // Left points
+    Y[j][i] = ub[ic];
+  }
+#endif
 
   ierr = DMDAVecRestoreArray(da,x,&X);CHKERRQ(ierr);
   ierr = DMDAVecRestoreArray(da,y,&Y);CHKERRQ(ierr);
   ierr = VecDestroy(&(fmm->u));CHKERRQ(ierr);
   ierr = VecDestroy(&(fmm->f));CHKERRQ(ierr);
   ierr = MatDestroy(&(fmm->G));CHKERRQ(ierr);
-  ierr = PetscFree(fmm->ip1);CHKERRQ(ierr);
   ierr = PetscFree3(fmm->xi,fmm->yi,fmm->ri);CHKERRQ(ierr);
   ierr = PetscFree3(fmm->xb,fmm->yb,fmm->ub);CHKERRQ(ierr);
   ierr = PetscFree3(fmm->xm,fmm->ym,fmm->um);CHKERRQ(ierr);
 
 PETSC_EXTERN PetscErrorCode PCFMMSetIGA(PC pc,IGA iga);
 
+extern "C" void FMM_Init(int verbose);
+extern "C" void FMM(int ni, double * xi, double * yi, double * vi,
+  	            int nj, double * xj, double * yj, double * vj);
 #endif
 all: ${TARGETS}
 
 Poisson2D: Poisson2D.o fmm.o
-	${CLINKER} $^ -o $@ ${PETIGA_LIB}
+	${CLINKER} $^ -o $@ ${PETIGA_LIB} -L../../exafmm2d/wrappers -lfmm -ltbb
 	${RM} -f $<
-	./Poisson2D -ksp_monitor -ksp_norm_type UNPRECONDITIONED -draw_pause 1
+	mpirun -np 1 ./Poisson2D -ksp_monitor -ksp_norm_type UNPRECONDITIONED -draw_pause 1
 
 clean::
 	-@${RM} ${TARGETS}