2: #include <petsc-private/vecimpl.h> /*I "petscvec.h" I*/ 3: #include <petscdraw.h> 7: /*@ 8: VecContourScale - Prepares a vector of values to be plotted using 9: the PetscDrawTriangle() contour plotter. 11: Collective on Vec 13: Input Parameters: 14: + v - the vector of values 15: . vmin - minimum value (for lowest color) 16: - vmax - maximum value (for highest color) 18: Level: intermediate 20: .seealso: PetscDrawTensorContour(),PetscDrawTensorContourPatch() 22: @*/ 23: PetscErrorCode VecContourScale(Vec v,PetscReal vmin,PetscReal vmax) 24: { 25: PetscScalar *values; 27: PetscInt n,i; 28: PetscReal scale; 33: if (PetscAbsReal(vmax - vmin) < 1.e-50) scale = 1.0; 34: else scale = (245.0 - PETSC_DRAW_BASIC_COLORS)/(vmax - vmin); 36: VecGetLocalSize(v,&n); 37: VecGetArray(v,&values); 38: for (i=0; i<n; i++) values[i] = (PetscReal)PETSC_DRAW_BASIC_COLORS + scale*(values[i] - vmin); 39: VecRestoreArray(v,&values); 40: return(0); 41: }