Esempio n. 1
0
File: partition.c Progetto: rolk/ug
INT NS_DIM_PREFIX CheckPartitioning (MULTIGRID *theMG)
{
  INT i,_restrict_;
  ELEMENT *theElement;
  ELEMENT *theFather;
  GRID    *theGrid;

  _restrict_ = 0;

  /* reset used flags */
  for (i=TOPLEVEL(theMG); i>0; i--)
  {
    theGrid = GRID_ON_LEVEL(theMG,i);
    for (theElement=FIRSTELEMENT(theGrid); theElement!=NULL;
         theElement=SUCCE(theElement))
    {
      if (LEAFELEM(theElement))
      {
        theFather = theElement;
        while (EMASTER(theFather) && ECLASS(theFather)!=RED_CLASS
               && LEVEL(theFather)>0)
        {
          theFather = EFATHER(theFather);
        }

        /* if element with red element class does not exist */
        /* or is ghost -> partitioning must be restricted   */
        if (!EMASTER(theFather))
        {
          UserWriteF(PFMT "elem=" EID_FMTX  " cannot be refined\n",
                     me,EID_PRTX(theFather));
          _restrict_ = 1;
          continue;
        }
        if (COARSEN(theFather))
        {
          /* level 0 elements cannot be coarsened */
          if (LEVEL(theFather)<=1) continue;
          if (!EMASTER(EFATHER(theFather)))
          {
            UserWriteF(PFMT "elem=" EID_FMTX " cannot be coarsened\n",
                       me,EID_PRTX(theFather));
            _restrict_ = 1;
          }
        }
      }
    }
  }

  _restrict_ = UG_GlobalMaxINT(_restrict_);
  if (me==master && _restrict_==1)
  {
    UserWriteF("CheckPartitioning(): partitioning is not valid for refinement\n");
    UserWriteF("                     cleaning up ...\n");
  }

  return(_restrict_);
}
Esempio n. 2
0
void PrintTIME( double time, char *text )
{
#ifdef ModelP
	int maxpe = -1;
	double maxt = time;
	maxt = UG_GlobalMaxDOUBLE( (DOUBLE)time );

	if( maxt == time )
		maxpe = me;

	maxpe = UG_GlobalMaxINT( (INT)maxpe );

	if( me == 0 )
		printf(PFMT" PrintTIME %s %g maxt %g mpe %d\n",me, text, time, maxt, maxpe );
#else
	printf("  0: PrintTIME %s mt %g mpe 0\n",me, text, time );
#endif
	return;
}
Esempio n. 3
0
File: bullet.c Progetto: rolk/ug
INT NS_DIM_PREFIX BulletOpen(PICTURE *picture, DOUBLE factor)
{
  HEAP *heap;
  ZTYP *z;
  PIXEL *p;
  INT i, err;

  /* remember picture data */
  OutputDevice = PIC_OUTPUTDEV(picture);
  XShift = (DOUBLE)PIC_GLL(picture)[0];
  YShift = (DOUBLE)PIC_GUR(picture)[1];
  Width  = PIC_GUR(picture)[0] - PIC_GLL(picture)[0] + 1;
  Height = PIC_GLL(picture)[1] - PIC_GUR(picture)[1] + 1;

  zOffsetFactor = factor;

  /* check output device */
  if (OutputDevice->PlotPixelBuffer == NULL)
    return BULLET_CANT;

  /* allocate buffers */
  NbPixels = Width*Height;
  if (BulletDim == 3)
    Length = NbPixels * (sizeof(PIXEL)+sizeof(ZTYP));
  else
    Length = NbPixels * sizeof(PIXEL);

  heap = GetCurrentMultigrid()->theHeap;
  MarkTmpMem(heap, &MarkKey);
  err =  ((ZBuffer = GetTmpMem(heap, Length, MarkKey)) == NULL);
#ifdef ModelP
  err = UG_GlobalMaxINT(err);
#endif
  if (err) {
    ReleaseTmpMem(heap, MarkKey);
    return BULLET_NOMEM;
  }
#ifdef ModelP
  err = ((ABuffer = GetTmpMem(heap, Length, MarkKey)) == NULL);
  if (UG_GlobalMaxINT(err)) {
    ReleaseTmpMem(heap, MarkKey);
    return BULLET_NOMEM;
  }
#endif
  if (BulletDim == 3)
  {
    /* init z buffer */
    z = (ZTYP *)ZBuffer;
    for (i = 0; i < NbPixels; i++)
      *z++ = FAR_AWAY;

    PBuffer = z;
  }
  else
    PBuffer = ZBuffer;

  /* init pixel buffer */
  p = (PIXEL *)PBuffer;
  for (i = 0; i < NbPixels; i++) {
    p->cindex = OutputDevice->white;
    p->intensity = 255;
    p++;
  }

  return BULLET_OK;
}