Actual source code: cmesh.c

  1: /*$Id: cmesh.c,v 1.75 2001/09/07 20:08:55 bsmith Exp $*/

 3:  #include petscvec.h


  6: #undef __FUNCT__  
  8: /*@
  9:     VecContourScale - Prepares a vector of values to be plotted using 
 10:     the PetscDrawTriangle() contour plotter.

 12:     Collective on Vec

 14:     Input Parameters:
 15: +   v - the vector of values
 16: .   vmin - minimum value (for lowest color)
 17: -   vmax - maximum value (for highest color)

 19:    Level: intermediate

 21: .seealso: PetscDrawTensorContour(),PetscDrawTensorContourPatch()

 23: @*/
 24: int VecContourScale(Vec v,PetscReal vmin,PetscReal vmax)
 25: {
 26:   PetscScalar *values;
 27:   int         ierr,n,i;
 28:   PetscReal   scale;


 33:   if (PetscAbsReal(vmax - vmin) < 1.e-50) {
 34:      scale = 1.0;
 35:   } else {
 36:     scale = (245.0 - PETSC_DRAW_BASIC_COLORS)/(vmax - vmin);
 37:   }

 39:   VecGetLocalSize(v,&n);
 40:   VecGetArray(v,&values);
 41:   for (i=0; i<n; i++) {
 42:     values[i] = (PetscReal)PETSC_DRAW_BASIC_COLORS + scale*(values[i] - vmin);
 43:   }
 44:   VecRestoreArray(v,&values);

 46:   return(0);
 47: }