des_vect.C

00001 /*
00002  * Basic routine for plotting a vector field.
00003  *
00004  */
00005 
00006 /*
00007  *   Copyright (c) 2000-2001 Eric Gourgoulhon
00008  *
00009  *   This file is part of LORENE.
00010  *
00011  *   LORENE is free software; you can redistribute it and/or modify
00012  *   it under the terms of the GNU General Public License as published by
00013  *   the Free Software Foundation; either version 2 of the License, or
00014  *   (at your option) any later version.
00015  *
00016  *   LORENE is distributed in the hope that it will be useful,
00017  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *   GNU General Public License for more details.
00020  *
00021  *   You should have received a copy of the GNU General Public License
00022  *   along with LORENE; if not, write to the Free Software
00023  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024  *
00025  */
00026 
00027 
00028 char des_vect_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_vect.C,v 1.3 2008/08/19 06:42:00 j_novak Exp $" ;
00029 
00030 /*
00031  * $Id: des_vect.C,v 1.3 2008/08/19 06:42:00 j_novak Exp $
00032  * $Log: des_vect.C,v $
00033  * Revision 1.3  2008/08/19 06:42:00  j_novak
00034  * Minor modifications to avoid warnings with gcc 4.3. Most of them concern
00035  * cast-type operations, and constant strings that must be defined as const char*
00036  *
00037  * Revision 1.2  2002/10/16 14:36:58  j_novak
00038  * Reorganization of #include instructions of standard C++, in order to
00039  * use experimental version 3 of gcc.
00040  *
00041  * Revision 1.1.1.1  2001/11/20 15:19:29  e_gourgoulhon
00042  * LORENE
00043  *
00044  * Revision 2.0  2000/03/01  16:12:02  eric
00045  * *** empty log message ***
00046  *
00047  *
00048  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_vect.C,v 1.3 2008/08/19 06:42:00 j_novak Exp $
00049  *
00050  */
00051 
00052 
00053 
00054 // C++ headers:
00055 #include"headcpp.h"
00056 
00057 // C headers:
00058 #include <math.h>
00059 
00060 // PGPLOT headers:
00061 #include <cpgplot.h>
00062 
00063 //******************************************************************************
00064 
00065 void des_vect(float* vvx, float* vvy, int nx, int ny, float xmin, float xmax, 
00066          float ymin, float ymax, double scale,  double sizefl, 
00067          const char* nomx, const char* nomy, const char* title, const char* device, 
00068          int newgraph, int nxpage, int nypage) {
00069          
00070 
00071     
00072     // Array defining the grid for pgvect_
00073     // -----------------------------------
00074     float hx = (xmax - xmin)/float(nx-1) ; 
00075     float hy = (ymax - ymin)/float(ny-1) ; 
00076 
00077     float tr[6] ;
00078     tr[0] = xmin - hx ;
00079     tr[1] = hx ;
00080     tr[2] = 0 ;
00081     tr[3] = ymin - hy ; 
00082     tr[4] = 0 ;
00083     tr[5] = hy ;
00084      
00085 
00086     // Determination de la taille des fleches representant les vecteurs:
00087     // -----------------------------------------------------------------
00088 
00089     if (scale < 0) {            // si scale >= 0, on garde la valeur de 
00090                     //  scale donnee en argument
00091     double norme_max = 0 ; 
00092     for(int ix = 0; ix < nx; ix++) {
00093         for(int iy = 0; iy < ny; iy++) {
00094         double xxx = sqrt(  vvx[iy*nx+ix]*vvx[iy*nx+ix] +
00095                     vvy[iy*nx+ix]*vvy[iy*nx+ix]  ) ; 
00096         norme_max = (xxx > norme_max) ? xxx : norme_max ; 
00097         }
00098     }
00099     
00100     if (norme_max < 1.e-14) {
00101         scale = 1 ; 
00102     }
00103     else{
00104         double pas_max = (hx > hy) ? hx : hy ;     
00105         scale = fabs(scale) * pas_max / norme_max ; 
00106     }
00107     cout << "des_vect: norme_max = " << norme_max << endl ; 
00108     cout << "des_vect: scale = " << scale << endl ; 
00109     }
00110 
00111 
00112     // Graphics display
00113     // ----------------
00114 
00115     if ( (newgraph == 1) || (newgraph == 3) ) {
00116 
00117     if (device == 0x0) device = "?" ; 
00118    
00119     int ier = cpgbeg(0, device, nxpage, nypage) ;
00120     if (ier != 1) {
00121     cout << "des_vect: problem in opening PGPLOT display !" << endl ;
00122     }
00123 
00124     }
00125 
00126     // Taille des caracteres:
00127     float size = float(1.3) ;
00128     cpgsch(size) ;
00129     
00130     // Epaisseur des traits:
00131     int lepais = 1 ; 
00132     cpgslw(lepais) ;
00133     
00134     // Fonte axes: caracteres romains:
00135     cpgscf(2) ;
00136     
00137     // Cadre de la figure
00138     cpgenv(xmin, xmax, ymin, ymax, 1, 0 ) ; 
00139     cpglab(nomx,nomy,title) ;
00140 
00141 
00142 
00143     float sizefl1 = float(sizefl) ; 
00144     cpgsch(sizefl1) ;    // controle la taille des extremites des fleches 
00145 
00146     float blank = 0 ; 
00147     float scale1 = float(scale) ; 
00148     int nc = 1 ; 
00149     
00150     cpgvect(vvx, vvy, nx, ny, 1, nx, 1, ny, scale1, nc, tr, blank) ;   
00151 
00152     cpgsch(size) ;  // restauration 
00153 
00154 
00155     
00156     // Closing the graphical output
00157     // ----------------------------
00158 
00159     if ( (newgraph == 2) || (newgraph == 3) ) {    
00160     cpgend() ; 
00161     }
00162     
00163     
00164 }

Generated on Tue Feb 7 01:35:16 2012 for LORENE by  doxygen 1.4.6