des_equipot.C

00001 /*
00002  * Basic routine for drawing isocontours.
00003  *
00004  */
00005 
00006 /*
00007  *   Copyright (c) 1999-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_equipot_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_equipot.C,v 1.3 2008/08/19 06:42:00 j_novak Exp $" ;
00029 
00030 /*
00031  * $Id: des_equipot.C,v 1.3 2008/08/19 06:42:00 j_novak Exp $
00032  * $Log: des_equipot.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:57  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 1.2  1999/12/23  16:15:19  eric
00045  * Ajout des arguments newgraph, nxpage, nypage et device.
00046  *
00047  * Revision 1.1  1999/12/09  16:38:24  eric
00048  * Initial revision
00049  *
00050  *
00051  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_equipot.C,v 1.3 2008/08/19 06:42:00 j_novak Exp $
00052  *
00053  */
00054 
00055 
00056 // C++ headers:
00057 #include"headcpp.h"
00058 
00059 // C headers:
00060 #include <math.h>
00061 
00062 // PGPLOT headers:
00063 #include <cpgplot.h>
00064 
00065 //******************************************************************************
00066 
00067 void des_equipot(float* uutab, int nx, int ny, float xmin, float xmax, 
00068          float ymin, float ymax, int ncour, const char* nomx, const char* nomy, 
00069          const char* title, const char* device, int newgraph, int nxpage, 
00070          int nypage) {
00071          
00072     // Search for the extremal values of the field : 
00073     // -------------------------------------------
00074 
00075     float uumin = uutab[0] ;
00076     float uumax = uutab[0] ;
00077     for (int i=1; i<nx*ny; i++) {
00078     uumin = (uutab[i] < uumin) ? uutab[i] : uumin ;
00079     uumax = (uutab[i] > uumax) ? uutab[i] : uumax ; 
00080     }
00081 
00082     cout << "  " << title << " : min, max : " << uumin << "   " << uumax 
00083          << endl ; 
00084 
00085     // Values of equipotentials
00086     // -------------------------
00087  
00088     float* isopot = new float [ncour] ;
00089     float hh = (uumax-uumin) / float(ncour) ; 
00090     for (int i=0; i<ncour; i++) {
00091     isopot[i] = uumin + hh * float(i) ;
00092     }
00093     
00094     // Array defining the grid for pgcont_
00095     // -----------------------------------
00096     float hx = (xmax - xmin)/float(nx-1) ; 
00097     float hy = (ymax - ymin)/float(ny-1) ; 
00098 
00099     float tr[6] ;
00100     tr[0] = xmin - hx ;
00101     tr[1] = hx ;
00102     tr[2] = 0 ;
00103     tr[3] = ymin - hy ; 
00104     tr[4] = 0 ;
00105     tr[5] = hy ;
00106      
00107     // Graphics display
00108     // ----------------
00109 
00110     if ( (newgraph == 1) || (newgraph == 3) ) {
00111 
00112     if (device == 0x0) device = "?" ; 
00113    
00114     int ier = cpgbeg(0, device, nxpage, nypage) ;
00115     if (ier != 1) {
00116     cout << "des_equipot: problem in opening PGPLOT display !" << endl ;
00117     }
00118 
00119     }
00120 
00121     // Taille des caracteres:
00122     float size = float(1.3) ;
00123     cpgsch(size) ;
00124     
00125     // Epaisseur des traits:
00126     int lepais = 1 ; 
00127     cpgslw(lepais) ;
00128     
00129     // Fonte axes: caracteres romains:
00130     cpgscf(2) ;
00131     
00132     // Cadre de la figure
00133     cpgenv(xmin, xmax, ymin, ymax, 1, 0 ) ; 
00134     cpglab(nomx,nomy,title) ;
00135 
00136     // On n'effectue le dessin que si la dynamique est suffisante
00137     
00138     float dynamique = float(fabs(uumax - uumin)) ; 
00139 
00140     if (dynamique > 1.e-14) {
00141     
00142     cpgcont(uutab, nx, ny, 1, nx, 1, ny, isopot, ncour, tr) ;
00143     
00144     }
00145     
00146     // Closing the graphical output
00147     // ----------------------------
00148 
00149     if ( (newgraph == 2) || (newgraph == 3) ) {    
00150     cpgend() ; 
00151     }
00152     
00153     
00154     delete [] isopot ; 
00155 
00156 }

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