des_coupe_vector.C

00001 /*
00002  *   Copyright (c) 2005 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_vector_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_coupe_vector.C,v 1.2 2008/08/19 06:42:00 j_novak Exp $" ;
00024 
00025 /*
00026  * $Id: des_coupe_vector.C,v 1.2 2008/08/19 06:42:00 j_novak Exp $
00027  * $Log: des_coupe_vector.C,v $
00028  * Revision 1.2  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.1  2005/03/24 22:01:07  e_gourgoulhon
00033  * Plot of a vector field represented by a Vector.
00034  *
00035  *
00036  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_coupe_vector.C,v 1.2 2008/08/19 06:42:00 j_novak Exp $
00037  *
00038  */
00039 
00040 
00041 // Header C
00042 #include <math.h>
00043 
00044 // Header Lorene
00045 #include "tensor.h"
00046 #include "graphique.h"
00047 #include "param.h"
00048 #include "utilitaires.h"
00049 #include "unites.h"
00050 
00051 //******************************************************************************
00052 
00053 void des_coupe_vect_x(const Vector& vv, double x0, double scale, double sizefl,
00054               int nzdes, const char* title, const Scalar* defsurf, double zoom, 
00055               bool draw_bound, int ny, int nz) {
00056              
00057     const Map& mp = vv.get_mp() ; 
00058 
00059     double a1 = mp.val_r(nzdes-1, 1., M_PI/2., 0.) ;         
00060     double a2 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI/2.) ;        
00061     double a3 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI) ;       
00062     double ray = mp.val_r(nzdes-1, 1., 0., 0.) ; 
00063     
00064     ray = ( a1 > ray ) ? a1 : ray ; 
00065     ray = ( a2 > ray ) ? a2 : ray ; 
00066     ray = ( a3 > ray ) ? a3 : ray ; 
00067              
00068     ray *= zoom ; 
00069     
00070     double y_min = mp.get_ori_y() - ray ; 
00071     double y_max = mp.get_ori_y() + ray ; 
00072     double z_min = mp.get_ori_z() - ray ; 
00073     double z_max = mp.get_ori_z() + ray ; 
00074 
00075     des_coupe_vect_x(vv, x0, scale, sizefl, y_min, y_max, z_min, z_max, title, 
00076             defsurf, draw_bound, ny, nz) ;
00077 
00078 }
00079 
00080 
00081 
00082 //******************************************************************************
00083 
00084 void des_coupe_vect_x(const Vector& vv, double x0, double scale, double
00085               sizefl, double y_min, double y_max, double z_min, 
00086               double z_max, const char* title, const Scalar* defsurf, 
00087               bool draw_bound, int ny, int nz) {
00088 
00089   using namespace Unites ;
00090     
00091     const Map& mp = vv.get_mp() ; 
00092 
00093     if ( vv.get_triad()->identify() != mp.get_bvect_cart().identify() ) {
00094     cout << 
00095     "des_coupe_vect_x: the vector must be given in Cartesian components !" 
00096     << endl ;
00097     abort() ; 
00098     }
00099 
00100     
00101     // Plot of the vector field
00102     // ------------------------
00103        
00104     float* vvy = new float[ny*nz] ; 
00105     float* vvz = new float[ny*nz] ; 
00106     
00107     double hy = (y_max - y_min) / double(ny-1) ; 
00108     double hza = (z_max - z_min) / double(nz-1) ; 
00109     
00110     for (int j=0; j<nz; j++) {
00111     
00112     double z = z_min + hza * j ; 
00113     
00114     for (int i=0; i<ny; i++) {
00115     
00116         double y = y_min + hy * i ; 
00117 
00118         // Computation of (r,theta,phi) :       
00119         double r, theta, phi ; 
00120         mp.convert_absolute(x0, y, z, r, theta, phi) ; 
00121     
00122         vvy[ny*j+i] = float(vv(2).val_point(r, theta, phi)) ; 
00123         vvz[ny*j+i] = float(vv(3).val_point(r, theta, phi)) ; 
00124         
00125     }
00126     }
00127     
00128     float ymin1 = float(y_min / km) ;
00129     float ymax1 = float(y_max / km) ;
00130     float zmin1 = float(z_min / km) ;
00131     float zmax1 = float(z_max / km) ;
00132     
00133     const char* nomy = "y [km]" ; 
00134     const char* nomz = "z [km]" ; 
00135     
00136     if (title == 0x0) {
00137     title = "" ;
00138     }
00139     
00140     const char* device = 0x0 ; 
00141     int newgraph = ( (defsurf != 0x0) || draw_bound ) ? 1 : 3 ; 
00142     
00143     des_vect(vvy, vvz, ny, nz, ymin1, ymax1, zmin1, zmax1,
00144          scale,  sizefl, nomy, nomz, title, device, newgraph) ; 
00145          
00146          
00147     delete [] vvy ;     
00148     delete [] vvz ;     
00149     
00150     // Plot of the surface
00151     // -------------------
00152     
00153     if (defsurf != 0x0) {
00154 
00155     assert( &(defsurf->get_mp()) == &mp ) ; 
00156 
00157     newgraph = draw_bound ? 0 : 2 ;  
00158     
00159     des_surface_x(*defsurf, x0, device, newgraph) ; 
00160     
00161     }  // End of the surface drawing
00162     
00163 
00164     // Plot of the domains outer boundaries
00165     // ------------------------------------
00166     
00167     if (draw_bound) {
00168 
00169     int ndom = mp.get_mg()->get_nzone() ;  // total number of domains
00170     
00171     for (int l=0; l<ndom-1; l++) {  // loop on the domains (except the
00172                     //  last one)
00173 
00174         newgraph = (l == ndom-2) ? 2 : 0 ; 
00175     
00176         des_domaine_x(mp, l, x0, device, newgraph) ; 
00177     }
00178     }
00179 
00180         
00181 } 
00182 
00183 
00184 
00185 //******************************************************************************
00186 
00187 void des_coupe_vect_y(const Vector& vv, double y0, double scale, double sizefl,
00188               int nzdes, const char* title, const Scalar* defsurf, double zoom, 
00189               bool draw_bound, int nx, int nz) {
00190              
00191     const Map& mp = vv.get_mp() ; 
00192 
00193     double a1 = mp.val_r(nzdes-1, 1., M_PI/2., 0.) ;         
00194     double a2 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI/2.) ;        
00195     double a3 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI) ;       
00196     double ray = mp.val_r(nzdes-1, 1., 0., 0.) ; 
00197     
00198     ray = ( a1 > ray ) ? a1 : ray ; 
00199     ray = ( a2 > ray ) ? a2 : ray ; 
00200     ray = ( a3 > ray ) ? a3 : ray ; 
00201              
00202     ray *= zoom ; 
00203     
00204     double x_min = mp.get_ori_x() - ray ; 
00205     double x_max = mp.get_ori_x() + ray ; 
00206     double z_min = mp.get_ori_z() - ray ; 
00207     double z_max = mp.get_ori_z() + ray ; 
00208 
00209 
00210     des_coupe_vect_y(vv, y0, scale, sizefl, x_min, x_max, z_min, z_max, title, 
00211             defsurf, draw_bound, nx, nz) ;
00212 
00213 }
00214 
00215 
00216 
00217 //******************************************************************************
00218 
00219 void des_coupe_vect_y(const Vector& vv, double y0, double scale, double
00220               sizefl, double x_min, double x_max, double z_min, 
00221               double z_max, const char* title, const Scalar* defsurf, 
00222               bool draw_bound, int nx, int nz) {
00223         
00224   using namespace Unites ;
00225     
00226     const Map& mp = vv.get_mp() ; 
00227 
00228     if ( vv.get_triad()->identify() != mp.get_bvect_cart().identify() ) {
00229     cout << 
00230     "des_coupe_vect_y: the vector must be given in Cartesian components !" 
00231     << endl ;
00232     abort() ; 
00233     }
00234 
00235     
00236     // Plot of the vector field
00237     // ------------------------
00238        
00239     float* vvx = new float[nx*nz] ; 
00240     float* vvz = new float[nx*nz] ; 
00241     
00242     double hx = (x_max - x_min) / double(nx-1) ; 
00243     double hza = (z_max - z_min) / double(nz-1) ; 
00244     
00245     for (int j=0; j<nz; j++) {
00246     
00247     double z = z_min + hza * j ; 
00248     
00249     for (int i=0; i<nx; i++) {
00250     
00251         double x = x_min + hx * i ; 
00252         
00253         // Computation of (r,theta,phi) :       
00254         double r, theta, phi ; 
00255         mp.convert_absolute(x, y0, z, r, theta, phi) ; 
00256     
00257         vvx[nx*j+i] = float(vv(1).val_point(r, theta, phi)) ; 
00258         vvz[nx*j+i] = float(vv(3).val_point(r, theta, phi)) ; 
00259         
00260     }
00261     }
00262     
00263     float xmin1 = float(x_min / km) ;
00264     float xmax1 = float(x_max / km) ;
00265     float zmin1 = float(z_min / km) ;
00266     float zmax1 = float(z_max / km) ;
00267     
00268     const char* nomx = "x [km]" ; 
00269     const char* nomz = "z [km]" ; 
00270     
00271     if (title == 0x0) {
00272     title = "" ;
00273     }
00274     
00275 
00276     const char* device = 0x0 ; 
00277     int newgraph = ( (defsurf != 0x0) || draw_bound ) ? 1 : 3 ; 
00278 
00279     des_vect(vvx, vvz, nx, nz, xmin1, xmax1, zmin1, zmax1,
00280          scale,  sizefl, nomx, nomz, title, device, newgraph) ; 
00281          
00282          
00283     delete [] vvx ;     
00284     delete [] vvz ;     
00285     
00286     // Plot of the surface
00287     // -------------------
00288     
00289     if (defsurf != 0x0) {
00290 
00291     assert( &(defsurf->get_mp()) == &mp ) ; 
00292 
00293     newgraph = draw_bound ? 0 : 2 ;  
00294     
00295     des_surface_y(*defsurf, y0, device, newgraph) ; 
00296     
00297     }  // End of the surface drawing
00298 
00299 
00300     // Plot of the domains outer boundaries
00301     // ------------------------------------
00302     
00303     if (draw_bound) {
00304 
00305     int ndom = mp.get_mg()->get_nzone() ;  // total number of domains
00306     
00307     for (int l=0; l<ndom-1; l++) {  // loop on the domains (except the
00308                     //  last one)
00309 
00310         newgraph = (l == ndom-2) ? 2 : 0 ; 
00311     
00312         des_domaine_y(mp, l, y0, device, newgraph) ; 
00313     }
00314     }
00315 
00316     
00317 } 
00318 
00319 
00320 //******************************************************************************
00321 
00322 void des_coupe_vect_z(const Vector& vv, double z0, double scale, double sizefl,
00323               int nzdes, const char* title, const Scalar* defsurf, double zoom, 
00324               bool draw_bound, int nx, int ny) {
00325              
00326     const Map& mp = vv.get_mp() ; 
00327 
00328     double a1 = mp.val_r(nzdes-1, 1., M_PI/2., 0.) ;         
00329     double a2 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI/2.) ;        
00330     double a3 = mp.val_r(nzdes-1, 1., M_PI/2., M_PI) ;       
00331     double ray = mp.val_r(nzdes-1, 1., 0., 0.) ; 
00332     
00333     ray = ( a1 > ray ) ? a1 : ray ; 
00334     ray = ( a2 > ray ) ? a2 : ray ; 
00335     ray = ( a3 > ray ) ? a3 : ray ; 
00336              
00337     ray *= zoom ; 
00338     
00339     double x_min = mp.get_ori_x() - ray ; 
00340     double x_max = mp.get_ori_x() + ray ; 
00341     double y_min = mp.get_ori_y() - ray ; 
00342     double y_max = mp.get_ori_y() + ray ; 
00343 
00344     des_coupe_vect_z(vv, z0, scale, sizefl, x_min, x_max, y_min, y_max, title, 
00345             defsurf, draw_bound, nx, ny) ;
00346 
00347 }
00348 
00349 
00350 
00351 //******************************************************************************
00352 
00353 void des_coupe_vect_z(const Vector& vv, double z0, double scale, double
00354               sizefl, double x_min, double x_max, double y_min, 
00355               double y_max, const char* title, const Scalar* defsurf, 
00356               bool draw_bound, int nx, int ny) {
00357         
00358   using namespace Unites ;
00359     
00360     const Map& mp = vv.get_mp() ; 
00361 
00362     if ( vv.get_triad()->identify() != mp.get_bvect_cart().identify() ) {
00363     cout << 
00364     "des_coupe_vect_y: the vector must be given in Cartesian components !" 
00365     << endl ;
00366     abort() ; 
00367     }
00368 
00369     
00370     // Plot of the vector field
00371     // ------------------------
00372        
00373     float* vvx = new float[nx*ny] ; 
00374     float* vvy = new float[nx*ny] ; 
00375     
00376     double hy = (y_max - y_min) / double(ny-1) ; 
00377     double hx = (x_max - x_min) / double(nx-1) ; 
00378 
00379     for (int j=0; j<ny; j++) {
00380     
00381     double y = y_min + hy * j ; 
00382     
00383     for (int i=0; i<nx; i++) {
00384     
00385         double x = x_min + hx * i ; 
00386         
00387         // Computation of (r,theta,phi) :       
00388         double r, theta, phi ; 
00389         mp.convert_absolute(x, y, z0, r, theta, phi) ; 
00390     
00391         vvx[nx*j+i] = float(vv(1).val_point(r, theta, phi)) ; 
00392         vvy[nx*j+i] = float(vv(2).val_point(r, theta, phi)) ; 
00393         
00394     }
00395     }
00396     
00397     float ymin1 = float(y_min / km) ;
00398     float ymax1 = float(y_max / km) ;
00399     float xmin1 = float(x_min / km) ;
00400     float xmax1 = float(x_max / km) ;
00401     
00402     const char* nomy = "y [km]" ; 
00403     const char* nomx = "x [km]" ; 
00404     
00405     if (title == 0x0) {
00406     title = "" ;
00407     }
00408     
00409     const char* device = 0x0 ; 
00410     int newgraph = ( (defsurf != 0x0) || draw_bound ) ? 1 : 3 ; 
00411     
00412     des_vect(vvx, vvy, nx, ny, xmin1, xmax1, ymin1, ymax1,
00413          scale,  sizefl, nomx, nomy, title, device, newgraph) ; 
00414          
00415          
00416     delete [] vvx ;     
00417     delete [] vvy ;     
00418     
00419     // Plot of the surface
00420     // -------------------
00421     
00422     if (defsurf != 0x0) {
00423 
00424     assert( &(defsurf->get_mp()) == &mp ) ; 
00425 
00426     newgraph = draw_bound ? 0 : 2 ;  
00427     
00428     des_surface_z(*defsurf, z0, device, newgraph) ; 
00429     
00430     }  // End of the surface drawing
00431 
00432     // Plot of the domains outer boundaries
00433     // ------------------------------------
00434     
00435     if (draw_bound) {
00436 
00437     int ndom = mp.get_mg()->get_nzone() ;  // total number of domains
00438     
00439     for (int l=0; l<ndom-1; l++) {  // loop on the domains (except the
00440                     //  last one)
00441 
00442         newgraph = (l == ndom-2) ? 2 : 0 ; 
00443     
00444         des_domaine_z(mp, l, z0, device, newgraph) ; 
00445     }
00446     }
00447     
00448 } 

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