Example #1
0
  /// Main worker function (entry method).
  /// In this simple example, an element performs the following:
  /// 1. Create a bunch of boxes from this element.  These are all
  ///    in the x-y plane and all parallel to the y-axis.
  /// 2. Stretch the first box over into next object.
  ///    With this, the first box on elment 'e' will overlap with the first
  ///    and second box on element 'e+1'
  /// 3. Send these objects to be collided. Results go to the collide manager
  ///    group with which this chunk (element) was registered at construction. 
  ///    This is done by invoking the method 'contribute' on the local branch
  ///    of the collide manager group, passing it the chunk (element) number,
  ///    the number of boxes created by this element, the actual boxes, and
  ///    the array of priority flags.
  ///
  /// Setting priority=NULL here will use the default setting which is
  /// priority=thisIndex.  In other words, objects created in the same
  /// chunk (i.e. by the same element) will not collide with each other.
  ///
  /// \see CollideBoxesPrio defined in collidecharm.{h,C}
  ///
  void DoIt(void)
  {
    CkPrintf("Contributing to reduction %d, element %04d\n", nTimes, thisIndex);

    // Create a bunch of boxes from this element.

    ////CkVector3d o(-6.8, 7.9, 8.0);
    CkVector3d o( 0,   0,   0);
    CkVector3d x( 4,   0,   0);
    CkVector3d y( 0,   0.3, 0);
    CkVector3d boxSize(0.2, 0.2, 0.2);
    ////int nBoxes = 1000;
    int nBoxes = 10;
    bbox3d *box = new bbox3d[nBoxes];
    for (int i=0; i<nBoxes; i++) {
      CkVector3d c(o + x*thisIndex + y*i);
      CkVector3d c2(c + boxSize);
      // Create a box with corners 'c' and 'c2'
      box[i].empty();
      box[i].add(c); box[i].add(c2);
      
#ifdef RADU_DBG
      // Write box information
      rSeg1d x_dim = box[i].axis(0);
      rSeg1d y_dim = box[i].axis(1);
      rSeg1d z_dim = box[i].axis(2);
      CkPrintf("%d:%d   (%g, %g, %g) - (%g, %g, %g)\n",
               thisIndex, i,
               x_dim.getMin(), y_dim.getMin(), z_dim.getMin(),
               x_dim.getMax(), y_dim.getMax(), z_dim.getMax());
#endif
    } 
    
    // Stretch the first box over into next object.
    box[0].add(o + x*(thisIndex+1.5) + y*2);

#ifdef RADU_DBG	
    // Stretched box[0]
    rSeg1d x_dim = box[0].axis(0);
    rSeg1d y_dim = box[0].axis(1);
    rSeg1d z_dim = box[0].axis(2);
    CkPrintf(">>> %d:0   (%g, %g, %g) - (%g, %g, %g)\n",
             thisIndex,
             x_dim.getMin(), y_dim.getMin(), z_dim.getMin(),
             x_dim.getMax(), y_dim.getMax(), z_dim.getMax());
#endif
    
    // Send these objects to be collided.
    CollideBoxesPrio(collide, thisIndex, nBoxes, box, NULL);
    
    delete[] box;
    nTimes++;
  }
Example #2
0
  void DoIt(void)
  {
	CkPrintf("Contributing to reduction %d, element %04d\n",nTimes,thisIndex);
	CkVector3d o(-6.8,7.9,8.0), x(4.0,0,0), y(0,0.3,0);
	CkVector3d boxSize(0.2,0.2,0.2);
	int nBoxes=1000;
	bbox3d *box=new bbox3d[nBoxes];
	for (int i=0;i<nBoxes;i++) {
		CkVector3d c(o+x*thisIndex+y*i);
		CkVector3d c2(c+boxSize);
		box[i].empty();
		box[i].add(c); box[i].add(c2);
	} 
	// first box stretches over into next object:
	box[0].add(o+x*(thisIndex+1.5)+y*2);
	
	CollideBoxesPrio(collide,thisIndex,nBoxes,box,NULL);
	
	delete[] box;
	nTimes++;
  }