1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
|
/*
* Basic routine for plotting a vector field.
*
*/
/*
* Copyright (c) 2000-2001 Eric Gourgoulhon
*
* This file is part of LORENE.
*
* LORENE is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* LORENE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LORENE; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
char des_vect_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_vect.C,v 1.5 2014/10/13 08:53:23 j_novak Exp $" ;
/*
* $Id: des_vect.C,v 1.5 2014/10/13 08:53:23 j_novak Exp $
* $Log: des_vect.C,v $
* Revision 1.5 2014/10/13 08:53:23 j_novak
* Lorene classes and functions now belong to the namespace Lorene.
*
* Revision 1.4 2014/10/06 15:16:05 j_novak
* Modified #include directives to use c++ syntax.
*
* Revision 1.3 2008/08/19 06:42:00 j_novak
* Minor modifications to avoid warnings with gcc 4.3. Most of them concern
* cast-type operations, and constant strings that must be defined as const char*
*
* Revision 1.2 2002/10/16 14:36:58 j_novak
* Reorganization of #include instructions of standard C++, in order to
* use experimental version 3 of gcc.
*
* Revision 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon
* LORENE
*
* Revision 2.0 2000/03/01 16:12:02 eric
* *** empty log message ***
*
*
* $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_vect.C,v 1.5 2014/10/13 08:53:23 j_novak Exp $
*
*/
// C++ headers:
#include"headcpp.h"
// C headers:
#include <cmath>
// PGPLOT headers:
#include <cpgplot.h>
namespace Lorene {
//******************************************************************************
void des_vect(float* vvx, float* vvy, int nx, int ny, float xmin, float xmax,
float ymin, float ymax, double scale, double sizefl,
const char* nomx, const char* nomy, const char* title, const char* device,
int newgraph, int nxpage, int nypage) {
// Array defining the grid for pgvect_
// -----------------------------------
float hx = (xmax - xmin)/float(nx-1) ;
float hy = (ymax - ymin)/float(ny-1) ;
float tr[6] ;
tr[0] = xmin - hx ;
tr[1] = hx ;
tr[2] = 0 ;
tr[3] = ymin - hy ;
tr[4] = 0 ;
tr[5] = hy ;
// Determination de la taille des fleches representant les vecteurs:
// -----------------------------------------------------------------
if (scale < 0) { // si scale >= 0, on garde la valeur de
// scale donnee en argument
double norme_max = 0 ;
for(int ix = 0; ix < nx; ix++) {
for(int iy = 0; iy < ny; iy++) {
double xxx = sqrt( vvx[iy*nx+ix]*vvx[iy*nx+ix] +
vvy[iy*nx+ix]*vvy[iy*nx+ix] ) ;
norme_max = (xxx > norme_max) ? xxx : norme_max ;
}
}
if (norme_max < 1.e-14) {
scale = 1 ;
}
else{
double pas_max = (hx > hy) ? hx : hy ;
scale = fabs(scale) * pas_max / norme_max ;
}
cout << "des_vect: norme_max = " << norme_max << endl ;
cout << "des_vect: scale = " << scale << endl ;
}
// Graphics display
// ----------------
if ( (newgraph == 1) || (newgraph == 3) ) {
if (device == 0x0) device = "?" ;
int ier = cpgbeg(0, device, nxpage, nypage) ;
if (ier != 1) {
cout << "des_vect: problem in opening PGPLOT display !" << endl ;
}
}
// Taille des caracteres:
float size = float(1.3) ;
cpgsch(size) ;
// Epaisseur des traits:
int lepais = 1 ;
cpgslw(lepais) ;
// Fonte axes: caracteres romains:
cpgscf(2) ;
// Cadre de la figure
cpgenv(xmin, xmax, ymin, ymax, 1, 0 ) ;
cpglab(nomx,nomy,title) ;
float sizefl1 = float(sizefl) ;
cpgsch(sizefl1) ; // controle la taille des extremites des fleches
float blank = 0 ;
float scale1 = float(scale) ;
int nc = 1 ;
cpgvect(vvx, vvy, nx, ny, 1, nx, 1, ny, scale1, nc, tr, blank) ;
cpgsch(size) ; // restauration
// Closing the graphical output
// ----------------------------
if ( (newgraph == 2) || (newgraph == 3) ) {
cpgend() ;
}
}
}
|