1: /*$Id: cmesh.c,v 1.75 2001/09/07 20:08:55 bsmith Exp $*/
3: #include petscvec.h
6: /*@
7: VecContourScale - Prepares a vector of values to be plotted using
8: the PetscDrawTriangle() contour plotter.
10: Collective on Vec
12: Input Parameters:
13: + v - the vector of values
14: . vmin - minimum value (for lowest color)
15: - vmax - maximum value (for highest color)
17: Level: intermediate
19: .seealso: PetscDrawTensorContour(),PetscDrawTensorContourPatch()
21: @*/
22: int VecContourScale(Vec v,PetscReal vmin,PetscReal vmax)
23: {
24: PetscScalar *values;
25: int ierr,n,i;
26: PetscReal scale;
31: if (PetscAbsReal(vmax - vmin) < 1.e-50) {
32: scale = 1.0;
33: } else {
34: scale = (245.0 - PETSC_DRAW_BASIC_COLORS)/(vmax - vmin);
35: }
37: VecGetLocalSize(v,&n);
38: VecGetArray(v,&values);
39: for (i=0; i<n; i++) {
40: values[i] = (PetscReal)PETSC_DRAW_BASIC_COLORS + scale*(values[i] - vmin);
41: }
42: VecRestoreArray(v,&values);
44: return(0);
45: }