des_coupe_bin.C

00001 /*
00002  *   Copyright (c) 2000-2001 Eric Gourgoulhon
00003  *
00004  *   This file is part of LORENE.
00005  *
00006  *   LORENE is free software; you can redistribute it and/or modify
00007  *   it under the terms of the GNU General Public License as published by
00008  *   the Free Software Foundation; either version 2 of the License, or
00009  *   (at your option) any later version.
00010  *
00011  *   LORENE is distributed in the hope that it will be useful,
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *   GNU General Public License for more details.
00015  *
00016  *   You should have received a copy of the GNU General Public License
00017  *   along with LORENE; if not, write to the Free Software
00018  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 
00022 
00023 char des_coupe_bin_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_coupe_bin.C,v 1.4 2008/08/19 06:42:00 j_novak Exp $" ;
00024 
00025 /*
00026  * $Id: des_coupe_bin.C,v 1.4 2008/08/19 06:42:00 j_novak Exp $
00027  * $Log: des_coupe_bin.C,v $
00028  * Revision 1.4  2008/08/19 06:42:00  j_novak
00029  * Minor modifications to avoid warnings with gcc 4.3. Most of them concern
00030  * cast-type operations, and constant strings that must be defined as const char*
00031  *
00032  * Revision 1.3  2004/03/25 10:29:24  j_novak
00033  * All LORENE's units are now defined in the namespace Unites (in file unites.h).
00034  *
00035  * Revision 1.2  2002/09/06 15:18:52  e_gourgoulhon
00036  * Changement du nom de la variable "hz" en "hza"
00037  * pour assurer la compatibilite avec le compilateur xlC_r
00038  * sur IBM Regatta (le preprocesseur de ce compilateur remplace
00039  * "hz" par "100").
00040  *
00041  * Revision 1.1.1.1  2001/11/20 15:19:29  e_gourgoulhon
00042  * LORENE
00043  *
00044  * Revision 2.1  2000/02/11  18:44:28  eric
00045  * Ajout de l'argument draw_bound.
00046  *
00047  * Revision 2.0  2000/02/11  17:47:26  eric
00048  * *** empty log message ***
00049  *
00050  *
00051  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_coupe_bin.C,v 1.4 2008/08/19 06:42:00 j_novak Exp $
00052  *
00053  */
00054 
00055 // Header C
00056 #include <math.h>
00057 
00058 // Header Lorene
00059 #include "cmp.h"
00060 #include "graphique.h"
00061 #include "param.h"
00062 #include "utilitaires.h"
00063 #include "unites.h"
00064 
00065 //******************************************************************************
00066 
00067 void des_coupe_bin_x(const Cmp& uu1, const Cmp& uu2, double x0, double y_min, 
00068          double y_max, double z_min, double z_max, const char* title, 
00069          const Cmp* defsurf1, const Cmp* defsurf2, 
00070          bool draw_bound, int ncour, int ny, int nz) {
00071 
00072   using namespace Unites ;      
00073 
00074     const Map& mp1 = *(uu1.get_mp()) ; 
00075     const Map& mp2 = *(uu2.get_mp()) ; 
00076 
00077     // Plot of isocontours
00078     // -------------------
00079        
00080     float* uutab = new float[ny*nz] ; 
00081     
00082     double hy = (y_max - y_min) / double(ny-1) ; 
00083     double hza = (z_max - z_min) / double(nz-1) ; 
00084     
00085     for (int j=0; j<nz; j++) {
00086     
00087     double z = z_min + hza * j ; 
00088     
00089     for (int i=0; i<ny; i++) {
00090     
00091         double y = y_min + hy * i ; 
00092 
00093         double r, theta, phi ; 
00094 
00095         mp1.convert_absolute(x0, y, z, r, theta, phi) ; 
00096         double uu_1 = uu1.val_point(r, theta, phi) ; 
00097         
00098         mp2.convert_absolute(x0, y, z, r, theta, phi) ; 
00099         double uu_2 = uu2.val_point(r, theta, phi) ; 
00100             
00101         uutab[ny*j+i] = float(uu_1 + uu_2) ; 
00102         
00103     }
00104     }
00105     
00106     float ymin1 = float(y_min / km) ;
00107     float ymax1 = float(y_max / km) ;
00108     float zmin1 = float(z_min / km) ;
00109     float zmax1 = float(z_max / km) ;
00110     
00111     const char* nomy = "y [km]" ; 
00112     const char* nomz = "z [km]" ; 
00113     
00114     if (title == 0x0) {
00115     title = "" ;
00116     }
00117     
00118     const char* device = 0x0 ; 
00119     int newgraph = ( (defsurf1 != 0x0) || (defsurf2 != 0x0) || draw_bound ) ?
00120             1 : 3 ; 
00121     
00122     des_equipot(uutab, ny, nz, ymin1, ymax1, zmin1, zmax1, ncour, nomy, nomz,
00123         title, device, newgraph) ;    
00124 
00125     delete [] uutab ;     
00126     
00127     // Plot of the surfaces
00128     // --------------------
00129     
00130     if (defsurf1 != 0x0) {
00131 
00132     assert(defsurf1->get_mp() == uu1.get_mp()) ; 
00133     newgraph = ( (defsurf2 != 0x0) || draw_bound ) ? 0 : 2 ;  
00134     des_surface_x(*defsurf1, x0, device, newgraph) ; 
00135     }
00136     
00137     if (defsurf2 != 0x0) {
00138 
00139     assert(defsurf2->get_mp() == uu2.get_mp()) ; 
00140     newgraph = draw_bound ? 0 : 2 ;  
00141     des_surface_x(*defsurf2, x0, device, newgraph) ; 
00142     }
00143     
00144 
00145     // Plot of the domains outer boundaries
00146     // ------------------------------------
00147     
00148     if (draw_bound) {
00149 
00150     int ndom1 = mp1.get_mg()->get_nzone() ;  
00151     int ndom2 = mp2.get_mg()->get_nzone() ;  
00152     
00153     for (int l=0; l<ndom1-1; l++) { // loop on the domains (except the
00154                     //  last one)
00155         newgraph = 0 ;  
00156         des_domaine_x(mp1, l, x0, device, newgraph) ; 
00157     }
00158 
00159     for (int l=0; l<ndom2-1; l++) { // loop on the domains (except the
00160                     //  last one)
00161 
00162         newgraph = (l == ndom2-2) ? 2 : 0 ; 
00163     
00164         des_domaine_x(mp2, l, x0, device, newgraph) ; 
00165     }
00166 
00167     }
00168 } 
00169 
00170 
00171 //******************************************************************************
00172 
00173 void des_coupe_bin_y(const Cmp& uu1, const Cmp& uu2, double y0, double x_min, 
00174          double x_max, double z_min, double z_max, const char* title, 
00175          const Cmp* defsurf1, const Cmp* defsurf2, 
00176          bool draw_bound, int ncour, int nx, int nz) {
00177         
00178   using namespace Unites ;      
00179   
00180     const Map& mp1 = *(uu1.get_mp()) ; 
00181     const Map& mp2 = *(uu2.get_mp()) ; 
00182 
00183     // Plot of isocontours
00184     // -------------------
00185               
00186     float* uutab = new float[nx*nz] ; 
00187     
00188     double hx = (x_max - x_min) / double(nx-1) ; 
00189     double hza = (z_max - z_min) / double(nz-1) ; 
00190     
00191 
00192 
00193     for (int j=0; j<nz; j++) {
00194     
00195     double z = z_min + hza * j ; 
00196     
00197     for (int i=0; i<nx; i++) {
00198     
00199         double x = x_min + hx * i ; 
00200         
00201         double r, theta, phi ; 
00202 
00203         mp1.convert_absolute(x, y0, z, r, theta, phi) ; 
00204         double uu_1 = uu1.val_point(r, theta, phi) ; 
00205         
00206         mp2.convert_absolute(x, y0, z, r, theta, phi) ; 
00207         double uu_2 = uu2.val_point(r, theta, phi) ; 
00208                 
00209         uutab[nx*j+i] = float(uu_1 + uu_2) ; 
00210     }
00211     }
00212     
00213     float xmin1 = float(x_min / km) ;
00214     float xmax1 = float(x_max / km) ;
00215     float zmin1 = float(z_min / km) ;
00216     float zmax1 = float(z_max / km) ;
00217     
00218     const char* nomx = "x [km]" ; 
00219     const char* nomz = "z [km]" ; 
00220     
00221     if (title == 0x0) {
00222     title = "" ;
00223     }
00224     
00225 
00226     const char* device = 0x0 ; 
00227     int newgraph = ( (defsurf1 != 0x0) || (defsurf2 != 0x0) || draw_bound ) ?
00228             1 : 3 ; 
00229 
00230     des_equipot(uutab, nx, nz, xmin1, xmax1, zmin1, zmax1, ncour, nomx, nomz,
00231         title, device, newgraph) ;    
00232     
00233     delete [] uutab ; 
00234 
00235     // Plot of the surfaces
00236     // --------------------
00237     
00238     if (defsurf1 != 0x0) {
00239 
00240     assert(defsurf1->get_mp() == uu1.get_mp()) ; 
00241     newgraph = ( (defsurf2 != 0x0) || draw_bound ) ? 0 : 2 ;  
00242     des_surface_y(*defsurf1, y0, device, newgraph) ; 
00243     }
00244     
00245     if (defsurf2 != 0x0) {
00246 
00247     assert(defsurf2->get_mp() == uu2.get_mp()) ; 
00248     newgraph = draw_bound ? 0 : 2 ;  
00249     des_surface_y(*defsurf2, y0, device, newgraph) ; 
00250     }
00251     
00252 
00253     // Plot of the domains outer boundaries
00254     // ------------------------------------
00255     
00256     if (draw_bound) {
00257 
00258     int ndom1 = mp1.get_mg()->get_nzone() ;  
00259     int ndom2 = mp2.get_mg()->get_nzone() ;  
00260     
00261     for (int l=0; l<ndom1-1; l++) { // loop on the domains (except the
00262                     //  last one)
00263         newgraph = 0 ; 
00264             des_domaine_y(mp1, l, y0, device, newgraph) ; 
00265     }
00266 
00267     for (int l=0; l<ndom2-1; l++) { // loop on the domains (except the
00268                     //  last one)
00269 
00270         newgraph = (l == ndom2-2) ? 2 : 0 ; 
00271 
00272         des_domaine_y(mp2, l, y0, device, newgraph) ; 
00273     }
00274 
00275     }
00276 } 
00277 
00278 
00279 //******************************************************************************
00280 
00281 void des_coupe_bin_z(const Cmp& uu1, const Cmp& uu2, double z0, double x_min, 
00282         double x_max, double y_min, double y_max, const char* title, 
00283         const Cmp* defsurf1, const Cmp* defsurf2, 
00284         bool draw_bound, int ncour, int nx, int ny) {
00285         
00286   using namespace Unites ;      
00287   
00288     const Map& mp1 = *(uu1.get_mp()) ; 
00289     const Map& mp2 = *(uu2.get_mp()) ; 
00290 
00291     // Plot of isocontours
00292     // -------------------
00293        
00294     float* uutab = new float[ny*nx] ; 
00295     
00296     double hy = (y_max - y_min) / double(ny-1) ; 
00297     double hx = (x_max - x_min) / double(nx-1) ; 
00298 
00299     for (int j=0; j<ny; j++) {
00300     
00301     double y = y_min + hy * j ; 
00302     
00303     for (int i=0; i<nx; i++) {
00304     
00305         double x = x_min + hx * i ; 
00306         
00307         double r, theta, phi ; 
00308 
00309         mp1.convert_absolute(x, y, z0, r, theta, phi) ; 
00310         double uu_1 = uu1.val_point(r, theta, phi) ; 
00311         
00312         mp2.convert_absolute(x, y, z0, r, theta, phi) ; 
00313         double uu_2 = uu2.val_point(r, theta, phi) ; 
00314         
00315         uutab[nx*j+i] = float(uu_1 + uu_2) ; 
00316     }
00317     }
00318     
00319     float ymin1 = float(y_min / km) ;
00320     float ymax1 = float(y_max / km) ;
00321     float xmin1 = float(x_min / km) ;
00322     float xmax1 = float(x_max / km) ;
00323     
00324     const char* nomy = "y [km]" ; 
00325     const char* nomx = "x [km]" ; 
00326     
00327     if (title == 0x0) {
00328     title = "" ;
00329     }
00330     
00331     const char* device = 0x0 ; 
00332     int newgraph = ( (defsurf1 != 0x0) || (defsurf2 != 0x0) || draw_bound ) ?
00333             1 : 3 ; 
00334     
00335     des_equipot(uutab, nx, ny, xmin1, xmax1, ymin1, ymax1, ncour, nomx, nomy,
00336         title, device, newgraph) ;    
00337 
00338     delete [] uutab ; 
00339     
00340         
00341     // Plot of the surfaces
00342     // --------------------
00343     
00344     if (defsurf1 != 0x0) {
00345 
00346     assert(defsurf1->get_mp() == uu1.get_mp()) ; 
00347     newgraph = ( (defsurf2 != 0x0) || draw_bound ) ? 0 : 2 ;  
00348     des_surface_z(*defsurf1, z0, device, newgraph) ; 
00349     }
00350     
00351     if (defsurf2 != 0x0) {
00352 
00353     assert(defsurf2->get_mp() == uu2.get_mp()) ; 
00354     newgraph = draw_bound ? 0 : 2 ;  
00355     des_surface_z(*defsurf2, z0, device, newgraph) ; 
00356     }
00357     
00358 
00359     // Plot of the domains outer boundaries
00360     // ------------------------------------
00361     
00362     if (draw_bound) {
00363 
00364     int ndom1 = mp1.get_mg()->get_nzone() ;  
00365     int ndom2 = mp2.get_mg()->get_nzone() ;  
00366     
00367     for (int l=0; l<ndom1-1; l++) { // loop on the domains (except the
00368                     //  last one)
00369         newgraph = 0 ; 
00370         des_domaine_z(mp1, l, z0, device, newgraph) ; 
00371     }
00372 
00373     for (int l=0; l<ndom2-1; l++) { // loop on the domains (except the
00374                     //  last one)
00375 
00376         newgraph = (l == ndom2-2) ? 2 : 0 ; 
00377     
00378         des_domaine_z(mp2, l, z0, device, newgraph) ; 
00379     }
00380 
00381     }
00382 } 

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