[Dune] printvector changes output format

Bernd Flemisch bernd at iws.uni-stuttgart.de
Wed Jan 31 12:30:44 CET 2007


Dear Dune-Users,

the printvector routine in istl/io.hh may change the output format in a
way which is not desired. For example, assigning the value 1e-7 to a
double, and printing it via std::cout << gives the exact value. But
after the printvector has been carried out, printing it gives 0.000000.
This may be quite misleading. See the following example:

#ifdef HAVE_CONFIG_H
# include "config.h"    
#endif
#include<dune/istl/io.hh>

int main(int argc, char** argv)
{
  try{
    typedef Dune::FieldVector<double,1> R1;
    Dune::BlockVector<R1> press(1);
    double vec[3];

    double small = 1e-7;

    std::cout << std::endl << "before printvector: small = " << small <<
std::endl << std::endl;

    printvector(std::cout,vec,"pressure","row",11,1);

    std::cout << std::endl << "after printvector: small = " << small <<
std::endl << std::endl;

    std::cout << "forced format: small = " << std::scientific << small
<< std::endl << std::endl;

    return 0;
  }
  catch (Dune::Exception &e){
    std::cerr << "Dune reported error: " << e << std::endl;
  }
  catch (...){
    std::cerr << "Unknown exception thrown!" << std::endl;
  }
}

Best wishes
Bernd

-- 
_____________________________________________________________________

Bernd Flemisch                               phone: +49 711 685 69162
IWS, Universität Stuttgart                   fax:   +49 711 685 60430
Pfaffenwaldring 61                  email: bernd at iws.uni-stuttgart.de
D-70569 Stuttgart                       url: www.iws.uni-stuttgart.de
_____________________________________________________________________





More information about the Dune mailing list