示例#1
0
/*
 * Zoltan_Oct_global_insert(region)
 *
 * try to insert the region into any of the local-rooted subtrees
 *
 * return the octant pointer if successful, or NULL if region's
 * centroid does not lie within the local octree.  This could
 * be due to centroid not lying within any local root, or also
 * if some local root's subtree is off-processor.
 *
 * During insertion, refinement may be performed.
 * In that case, the returned octant is an ancestor
 * of the octant to which the region is attached.
 *
 */
static pOctant Zoltan_Oct_global_insert(ZZ *zz, pRegion region) 
{
  pOctant oct;                            /* octree octant */
  OCT_Global_Info *OCT_info = (OCT_Global_Info *)(zz->LB.Data_Structure);

  oct = NULL;
  /* find the octant which the object lies in */
  oct=Zoltan_Oct_global_find(OCT_info,region->Coord);
  /* if octant is found, try to insert the region */
  if (oct)
    if (!Zoltan_Oct_subtree_insert(zz, oct, region)) {  /* inserting region */
      fprintf(stderr,"OCT Zoltan_Oct_global_insert: insertion failed\n");
      abort();
    }

  return(oct);
}
示例#2
0
/*
 * void Zoltan_Oct_insert_orphan(pRegion region)
 *
 * Insert orphan regions migrated from off processors, or to insert
 * regions that lie on the boundary.
 */
static int Zoltan_Oct_insert_orphan(ZZ *zz, Region reg) {
  pRList  RootList;                /* list of all local roots */
  pOctant RootOct;
  int rflag;                       /* flag to indicate region fits in octant */
  int i, j;                        /* index counters */
  double upper,                    /* upper bounds of the octant */
         lower;                    /* lower bounds of the octant */
  OCT_Global_Info *OCT_info = (OCT_Global_Info *)(zz->LB.Data_Structure);
  char *yo = "Zoltan_Oct_insert_orphan";
  int ierr = ZOLTAN_OK;

  if (OCT_info->OCT_dimension == 2)
    i = 2;                                           /* ignore z coordinates */
  else
    i = 3;

  rflag = 0;
  RootList = Zoltan_Oct_POct_localroots(OCT_info);               /* get a list all local roots */
  while((RootOct = RL_nextRootOctant(&RootList))) {
    rflag = 1;
    for (j=0; j<i; j++) {
      lower = RootOct->min[j];
      upper = RootOct->max[j];
      if (reg.Coord[j]<lower || reg.Coord[j]>upper) {
	/* if region coord lie outside bounds, then cannot fit */
	rflag = 0;
	break;
      }
    }
    if(rflag == 1) { 
      /* region fits inside octant */
      /* found a place to insert region */
      Zoltan_Oct_subtree_insert(zz, RootOct, &reg);
      return ierr;
    }
  }
  ierr = ZOLTAN_WARN;
  ZOLTAN_TRACE_DETAIL(zz, yo, "could not insert region");
  
  fprintf(stderr,"%s failed to insert %f %f %f on proc %d\n",yo, reg.Coord[0], reg.Coord[1], reg.Coord[2], zz->Proc);

  RootList = Zoltan_Oct_POct_localroots(OCT_info); 
  RL_printRootOctants(RootList);
  return ierr;
}