// How to control precision in VecView ? // // ~> g++ -o vecViewPrecision.exe vecViewPrecision.cpp -lpetsc -lm // ~> mpirun -n 5 vecViewPrecision.exe #include #include "petsc.h" int main(int argc,char **argv) { PetscInitialize(&argc, &argv, NULL, NULL); int size = 0; MPI_Comm_size(MPI_COMM_WORLD, &size); int rank = 0; MPI_Comm_rank(MPI_COMM_WORLD, &rank); Vec v; VecCreateMPI(PETSC_COMM_WORLD, 2, 2*size, &v); double value = 1.23456789; double coef = (rank%2 == 0) ? 1.e-6 : 1.e+6; // Big/small values VecSetValue(v, 2*rank+0, rank*value*coef, INSERT_VALUES); VecSetValue(v, 2*rank+1, -rank/value/coef, INSERT_VALUES); VecAssemblyBegin(v); VecAssemblyEnd(v); VecView(v, PETSC_VIEWER_STDOUT_WORLD); PetscFinalize(); return 0; }