2: #include <petscvec.h> /*I "petscvec.h" I*/
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) {
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: }