20 #include "pism/util/petscwrappers/Viewer.hh"
22 #include <petscdraw.h>
24 #include "pism/util/error_handling.hh"
29 Viewer::Viewer(MPI_Comm com,
const std::string &title,
unsigned int target_size,
30 double Lx,
double Ly) {
36 ierr = PetscViewerDrawOpen(com, NULL, title.c_str(),
37 PETSC_DECIDE, PETSC_DECIDE, X, Y, &
m_value);
38 PISM_CHK(ierr,
"PetscViewerDrawOpen");
43 ierr = PetscViewerDrawGetDraw(
m_value, 0, &draw);
44 PISM_CHK(ierr,
"PetscViewerDrawGetDraw");
46 ierr = PetscDrawSetTitle(draw, title.c_str());
51 PetscErrorCode ierr = PetscViewerCreate(com, &
m_value);
65 PetscErrorCode ierr = PetscViewerDestroy(&
m_value); CHKERRCONTINUE(ierr);
69 void Viewer::compute_size(
unsigned int target_size,
double Lx,
double Ly,
unsigned int &X,
unsigned int &Y) {
71 assert(Lx > 0 && Ly > 0);
74 const double yTOx = Ly / Lx;
77 Y = (
unsigned int) ((
double)target_size * yTOx);
80 X = (
unsigned int) ((
double)target_size / yTOx);
84 if (X > 2 * target_size) {
85 Y = (
unsigned int) ((
double)(Y) * (2.0 * (
double)target_size / (double)(X)));
87 }
else if (Y > 2 * target_size) {
88 X = (
unsigned int) ((
double)(X) * (2.0 * (
double)target_size / (double)(Y)));
void compute_size(unsigned int target_size, double Lx, double Ly, unsigned int &X, unsigned int &Y)
#define PISM_CHK(errcode, name)