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
28char des_equipot_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_equipot.C,v 1.5 2014/10/13 08:53:22 j_novak Exp $" ;
29
30/*
31 * $Id: des_equipot.C,v 1.5 2014/10/13 08:53:22 j_novak Exp $
32 * $Log: des_equipot.C,v $
33 * Revision 1.5 2014/10/13 08:53:22 j_novak
34 * Lorene classes and functions now belong to the namespace Lorene.
35 *
36 * Revision 1.4 2014/10/06 15:16:05 j_novak
37 * Modified #include directives to use c++ syntax.
38 *
39 * Revision 1.3 2008/08/19 06:42:00 j_novak
40 * Minor modifications to avoid warnings with gcc 4.3. Most of them concern
41 * cast-type operations, and constant strings that must be defined as const char*
42 *
43 * Revision 1.2 2002/10/16 14:36:57 j_novak
44 * Reorganization of #include instructions of standard C++, in order to
45 * use experimental version 3 of gcc.
46 *
47 * Revision 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon
48 * LORENE
49 *
50 * Revision 1.2 1999/12/23 16:15:19 eric
51 * Ajout des arguments newgraph, nxpage, nypage et device.
52 *
53 * Revision 1.1 1999/12/09 16:38:24 eric
54 * Initial revision
55 *
56 *
57 * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_equipot.C,v 1.5 2014/10/13 08:53:22 j_novak Exp $
58 *
59 */
60
61
62// C++ headers:
63#include"headcpp.h"
64
65// C headers:
66#include <cmath>
67
68// PGPLOT headers:
69#include <cpgplot.h>
70
71namespace Lorene {
72//******************************************************************************
73
74void des_equipot(float* uutab, int nx, int ny, float xmin, float xmax,
75 float ymin, float ymax, int ncour, const char* nomx, const char* nomy,
76 const char* title, const char* device, int newgraph, int nxpage,
77 int nypage) {
78
79 // Search for the extremal values of the field :
80 // -------------------------------------------
81
82 float uumin = uutab[0] ;
83 float uumax = uutab[0] ;
84 for (int i=1; i<nx*ny; i++) {
85 uumin = (uutab[i] < uumin) ? uutab[i] : uumin ;
86 uumax = (uutab[i] > uumax) ? uutab[i] : uumax ;
87 }
88
89 cout << " " << title << " : min, max : " << uumin << " " << uumax
90 << endl ;
91
92 // Values of equipotentials
93 // -------------------------
94
95 float* isopot = new float [ncour] ;
96 float hh = (uumax-uumin) / float(ncour) ;
97 for (int i=0; i<ncour; i++) {
98 isopot[i] = uumin + hh * float(i) ;
99 }
100
101 // Array defining the grid for pgcont_
102 // -----------------------------------
103 float hx = (xmax - xmin)/float(nx-1) ;
104 float hy = (ymax - ymin)/float(ny-1) ;
105
106 float tr[6] ;
107 tr[0] = xmin - hx ;
108 tr[1] = hx ;
109 tr[2] = 0 ;
110 tr[3] = ymin - hy ;
111 tr[4] = 0 ;
112 tr[5] = hy ;
113
114 // Graphics display
115 // ----------------
116
117 if ( (newgraph == 1) || (newgraph == 3) ) {
118
119 if (device == 0x0) device = "?" ;
120
121 int ier = cpgbeg(0, device, nxpage, nypage) ;
122 if (ier != 1) {
123 cout << "des_equipot: problem in opening PGPLOT display !" << endl ;
124 }
125
126 }
127
128 // Taille des caracteres:
129 float size = float(1.3) ;
130 cpgsch(size) ;
131
132 // Epaisseur des traits:
133 int lepais = 1 ;
134 cpgslw(lepais) ;
135
136 // Fonte axes: caracteres romains:
137 cpgscf(2) ;
138
139 // Cadre de la figure
140 cpgenv(xmin, xmax, ymin, ymax, 1, 0 ) ;
141 cpglab(nomx,nomy,title) ;
142
143 // On n'effectue le dessin que si la dynamique est suffisante
144
145 float dynamique = float(fabs(uumax - uumin)) ;
146
147 if (dynamique > 1.e-14) {
148
149 cpgcont(uutab, nx, ny, 1, nx, 1, ny, isopot, ncour, tr) ;
150
151 }
152
153 // Closing the graphical output
154 // ----------------------------
155
156 if ( (newgraph == 2) || (newgraph == 3) ) {
157 cpgend() ;
158 }
159
160
161 delete [] isopot ;
162
163}
164}
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=0x0, int newgraph=3, int nxpage=1, int nypage=1)
Basic routine for drawing isocontours.
Lorene prototypes.
Definition app_hor.h:64