LORENE
des_equipot.C
1 /*
2  * Basic routine for drawing isocontours.
3  *
4  */
5 
6 /*
7  * Copyright (c) 1999-2001 Eric Gourgoulhon
8  *
9  * This file is part of LORENE.
10  *
11  * LORENE is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * LORENE is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with LORENE; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24  *
25  */
26 
27 
28 
29 
30 /*
31  * $Id: des_equipot.C,v 1.6 2016/12/05 16:18:06 j_novak Exp $
32  * $Log: des_equipot.C,v $
33  * Revision 1.6 2016/12/05 16:18:06 j_novak
34  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
35  *
36  * Revision 1.5 2014/10/13 08:53:22 j_novak
37  * Lorene classes and functions now belong to the namespace Lorene.
38  *
39  * Revision 1.4 2014/10/06 15:16:05 j_novak
40  * Modified #include directives to use c++ syntax.
41  *
42  * Revision 1.3 2008/08/19 06:42:00 j_novak
43  * Minor modifications to avoid warnings with gcc 4.3. Most of them concern
44  * cast-type operations, and constant strings that must be defined as const char*
45  *
46  * Revision 1.2 2002/10/16 14:36:57 j_novak
47  * Reorganization of #include instructions of standard C++, in order to
48  * use experimental version 3 of gcc.
49  *
50  * Revision 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon
51  * LORENE
52  *
53  * Revision 1.2 1999/12/23 16:15:19 eric
54  * Ajout des arguments newgraph, nxpage, nypage et device.
55  *
56  * Revision 1.1 1999/12/09 16:38:24 eric
57  * Initial revision
58  *
59  *
60  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_equipot.C,v 1.6 2016/12/05 16:18:06 j_novak Exp $
61  *
62  */
63 
64 
65 // C++ headers:
66 #include"headcpp.h"
67 
68 // C headers:
69 #include <cmath>
70 
71 // PGPLOT headers:
72 #include <cpgplot.h>
73 
74 namespace Lorene {
75 //******************************************************************************
76 
77 void des_equipot(float* uutab, int nx, int ny, float xmin, float xmax,
78  float ymin, float ymax, int ncour, const char* nomx, const char* nomy,
79  const char* title, const char* device, int newgraph, int nxpage,
80  int nypage) {
81 
82  // Search for the extremal values of the field :
83  // -------------------------------------------
84 
85  float uumin = uutab[0] ;
86  float uumax = uutab[0] ;
87  for (int i=1; i<nx*ny; i++) {
88  uumin = (uutab[i] < uumin) ? uutab[i] : uumin ;
89  uumax = (uutab[i] > uumax) ? uutab[i] : uumax ;
90  }
91 
92  cout << " " << title << " : min, max : " << uumin << " " << uumax
93  << endl ;
94 
95  // Values of equipotentials
96  // -------------------------
97 
98  float* isopot = new float [ncour] ;
99  float hh = (uumax-uumin) / float(ncour) ;
100  for (int i=0; i<ncour; i++) {
101  isopot[i] = uumin + hh * float(i) ;
102  }
103 
104  // Array defining the grid for pgcont_
105  // -----------------------------------
106  float hx = (xmax - xmin)/float(nx-1) ;
107  float hy = (ymax - ymin)/float(ny-1) ;
108 
109  float tr[6] ;
110  tr[0] = xmin - hx ;
111  tr[1] = hx ;
112  tr[2] = 0 ;
113  tr[3] = ymin - hy ;
114  tr[4] = 0 ;
115  tr[5] = hy ;
116 
117  // Graphics display
118  // ----------------
119 
120  if ( (newgraph == 1) || (newgraph == 3) ) {
121 
122  if (device == 0x0) device = "?" ;
123 
124  int ier = cpgbeg(0, device, nxpage, nypage) ;
125  if (ier != 1) {
126  cout << "des_equipot: problem in opening PGPLOT display !" << endl ;
127  }
128 
129  }
130 
131  // Taille des caracteres:
132  float size = float(1.3) ;
133  cpgsch(size) ;
134 
135  // Epaisseur des traits:
136  int lepais = 1 ;
137  cpgslw(lepais) ;
138 
139  // Fonte axes: caracteres romains:
140  cpgscf(2) ;
141 
142  // Cadre de la figure
143  cpgenv(xmin, xmax, ymin, ymax, 1, 0 ) ;
144  cpglab(nomx,nomy,title) ;
145 
146  // On n'effectue le dessin que si la dynamique est suffisante
147 
148  float dynamique = float(fabs(uumax - uumin)) ;
149 
150  if (dynamique > 1.e-14) {
151 
152  cpgcont(uutab, nx, ny, 1, nx, 1, ny, isopot, ncour, tr) ;
153 
154  }
155 
156  // Closing the graphical output
157  // ----------------------------
158 
159  if ( (newgraph == 2) || (newgraph == 3) ) {
160  cpgend() ;
161  }
162 
163 
164  delete [] isopot ;
165 
166 }
167 }
Lorene prototypes.
Definition: app_hor.h:67
void des_equipot(float *uutab, int nx, int ny, float xmin, float xmax, float ymin, float ymax, int ncour, const char *nomx, const char *nomy, const char *title, const char *device, int newgraph, int nxpage, int nypage)
Basic routine for drawing isocontours.
Definition: des_equipot.C:77