des_domaine.C

00001 /*
00002  *  Basic routines for drawing the boundaries between domains.
00003  */
00004 
00005 /*
00006  *   Copyright (c) 1999-2001 Eric Gourgoulhon
00007  *
00008  *   This file is part of LORENE.
00009  *
00010  *   LORENE is free software; you can redistribute it and/or modify
00011  *   it under the terms of the GNU General Public License as published by
00012  *   the Free Software Foundation; either version 2 of the License, or
00013  *   (at your option) any later version.
00014  *
00015  *   LORENE is distributed in the hope that it will be useful,
00016  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *   GNU General Public License for more details.
00019  *
00020  *   You should have received a copy of the GNU General Public License
00021  *   along with LORENE; if not, write to the Free Software
00022  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *
00024  */
00025 
00026 
00027 char des_domaine_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_domaine.C,v 1.4 2008/08/19 06:42:00 j_novak Exp $" ;
00028 
00029 /*
00030  * $Id: des_domaine.C,v 1.4 2008/08/19 06:42:00 j_novak Exp $
00031  * $Log: des_domaine.C,v $
00032  * Revision 1.4  2008/08/19 06:42:00  j_novak
00033  * Minor modifications to avoid warnings with gcc 4.3. Most of them concern
00034  * cast-type operations, and constant strings that must be defined as const char*
00035  *
00036  * Revision 1.3  2005/03/24 14:33:03  e_gourgoulhon
00037  * Ponderation of precis by rhomax-rhomax (to draw domains with
00038  *   large r).
00039  *
00040  * Revision 1.2  2004/03/25 10:29:25  j_novak
00041  * All LORENE's units are now defined in the namespace Unites (in file unites.h).
00042  *
00043  * Revision 1.1.1.1  2001/11/20 15:19:29  e_gourgoulhon
00044  * LORENE
00045  *
00046  * Revision 1.4  2001/02/28  09:45:02  eric
00047  * Correction erreur affichage "des_domaine_y" dans des_domaine_z.
00048  *
00049  * Revision 1.3  2000/02/11  16:53:50  eric
00050  * Utilisation des coordonnees cartesiennes abolues (X,Y,Z) et non plus
00051  * des coordonnees relatives (x,y,z).
00052  *
00053  * Revision 1.2  1999/12/27  12:20:59  eric
00054  * *** empty log message ***
00055  *
00056  * Revision 1.1  1999/12/27  12:19:03  eric
00057  * Initial revision
00058  *
00059  *
00060  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Graphics/des_domaine.C,v 1.4 2008/08/19 06:42:00 j_novak Exp $
00061  *
00062  */
00063 
00064 // C headers:
00065 #include <math.h>
00066 
00067 // PGPLOT headers:
00068 #include <cpgplot.h>
00069 
00070 // Lorene headers
00071 #include "map.h"
00072 #include "param.h"
00073 #include "utilitaires.h"
00074 #include "unites.h"
00075 
00076 // Local prototypes
00077 double fonc_des_domaine_x(double, const Param&) ; 
00078 double fonc_des_domaine_y(double, const Param&) ; 
00079 double fonc_des_domaine_z(double, const Param&) ; 
00080 
00081 //******************************************************************************
00082  
00083 void des_domaine_x(const Map& mp, int l0, double x0, const char* device, int newgraph, 
00084            double y_min, double y_max, double z_min, double z_max, 
00085            const char* nomy, const char* nomz, const char* title, int nxpage, int nypage)
00086 {
00087   using namespace Unites ;
00088 
00089     double khi ;
00090     
00091     Param parzerosec ;
00092     parzerosec.add_int(l0, 0) ;     
00093     parzerosec.add_double_mod(x0, 0) ;  
00094     parzerosec.add_double_mod(khi, 1) ;     
00095     parzerosec.add_map(mp, 0) ;     
00096 
00097     double rhomin = 0 ; 
00098     double rhomax = 2 * 
00099             mp.val_r(mp.get_mg()->get_nzone() - 1, -1., 0., 0.) ;  
00100     double precis = 1.e-14 * (rhomax - rhomin) ; 
00101     int nitermax = 100 ; 
00102     int niter ; 
00103     
00104     const int np = 101 ; 
00105     float yg[np] ; 
00106     float zg[np] ; 
00107 
00108     double hkhi = 2 * M_PI / (np-1) ; 
00109     
00110     bool coupe_surface = true ; 
00111     
00112     for (int i=0; i< np; i++) {
00113 
00114     khi = hkhi * i ; 
00115     
00116     // Search for the interval [rhomin0, rhomax0] which contains 
00117     //  the first zero of des_surf:
00118     
00119     double rhomin0 ;
00120     double rhomax0 ;
00121 
00122     if ( zero_premier(fonc_des_domaine_x, parzerosec, rhomin, rhomax, 100, 
00123              rhomin0, rhomax0) == false ) {
00124         cout << 
00125    "des_domaine_x : WARNING : no crossing with the domain boundary"
00126         << endl ; 
00127         cout << "  has been found for khi = " << khi << " !" << endl ; 
00128 
00129         coupe_surface = false ; 
00130         break ; 
00131 
00132     }
00133         
00134              
00135     // Search for the zero in the interval [rhomin0, rhomax0] :
00136     
00137     double rho = zerosec(fonc_des_domaine_x, parzerosec, rhomin0, rhomax0, 
00138                  precis, nitermax, niter) ;
00139                    
00140     yg[i] = float(( rho * cos(khi) + mp.get_ori_y() ) / km) ;
00141     zg[i] = float(( rho * sin(khi) + mp.get_ori_z() ) / km) ;
00142 
00143     }
00144     
00145     // Graphics display
00146     // ----------------
00147 
00148     if ( (newgraph == 1) || (newgraph == 3) ) {
00149 
00150     if (device == 0x0) device = "?" ; 
00151    
00152     int ier = cpgbeg(0, device, nxpage, nypage) ;
00153     if (ier != 1) {
00154     cout << "des_domaine_x: problem in opening PGPLOT display !" << endl ;
00155     } 
00156     
00157     // Taille des caracteres:
00158     float size = float(1.3) ;
00159     cpgsch(size) ;
00160     
00161     // Epaisseur des traits:
00162     int lepais = 1 ; 
00163     cpgslw(lepais) ;
00164     
00165     cpgscf(2) ; // Fonte axes: caracteres romains
00166     
00167     float ymin1 = float(y_min / km) ;
00168     float ymax1 = float(y_max / km) ;
00169     float zmin1 = float(z_min / km) ;
00170     float zmax1 = float(z_max / km) ;
00171     
00172     cpgenv(ymin1, ymax1, zmin1, zmax1, 1, 0 ) ; 
00173 
00174     if (nomy == 0x0) nomy = "y [km]" ;
00175     if (nomz == 0x0) nomz = "z [km]" ; 
00176     if (title == 0x0) title = " " ; 
00177     cpglab(nomy,nomz,title) ;
00178 
00179     }
00180 
00181     if (coupe_surface) {
00182     cpgsls(3) ;     // lignes en trait mixte
00183     cpgsci(3) ;     // couleur verte
00184     cpgline(np, yg, zg) ;
00185     cpgsls(1) ;     // retour aux lignes en trait plein
00186     cpgsci(1) ;     // couleur noire
00187     }
00188     
00189     
00190     // Closing graphic display
00191     // -----------------------
00192 
00193     if ( (newgraph == 2) || (newgraph == 3) ) {    
00194     cpgend() ; 
00195     }
00196 
00197 }
00198 
00199 
00200 //******************************************************************************
00201 
00202 void des_domaine_y(const Map& mp, int l0, double y0, const char* device, int newgraph, 
00203            double x_min, double x_max, double z_min, double z_max, 
00204            const char* nomx, const char* nomz, const char* title, int nxpage, int nypage)
00205 {
00206   using namespace Unites ;
00207 
00208     double khi ;
00209     
00210     Param parzerosec ;
00211     parzerosec.add_int(l0, 0) ;     
00212     parzerosec.add_double_mod(y0, 0) ;  
00213     parzerosec.add_double_mod(khi, 1) ;     
00214     parzerosec.add_map(mp, 0) ;     
00215 
00216     double rhomin = 0 ; 
00217     double rhomax = 2 * 
00218             mp.val_r(mp.get_mg()->get_nzone() - 1, -1., 0., 0.) ;  
00219     double precis = 1.e-14 * (rhomax - rhomin) ; 
00220     int nitermax = 100 ; 
00221     int niter ; 
00222     
00223     const int np = 101 ; 
00224     float xg[np] ; 
00225     float zg[np] ; 
00226 
00227     double hkhi = 2 * M_PI / (np-1) ; 
00228     
00229     bool coupe_surface = true ; 
00230     
00231     for (int i=0; i< np; i++) {
00232 
00233     khi = hkhi * i ; 
00234     
00235     // Search for the interval [rhomin0, rhomax0] which contains 
00236     //  the first zero of des_surf:
00237     
00238     double rhomin0 ;
00239     double rhomax0 ;
00240 
00241     if ( zero_premier(fonc_des_domaine_y, parzerosec, rhomin, rhomax, 100, 
00242              rhomin0, rhomax0) == false ) {
00243         cout << 
00244    "des_domaine_y : WARNING : no crossing with the domain boundary"
00245         << endl ; 
00246         cout << "  has been found for khi = " << khi << " !" << endl ; 
00247 
00248         coupe_surface = false ; 
00249         break ; 
00250 
00251     }
00252         
00253              
00254     // Search for the zero in the interval [rhomin0, rhomax0] :
00255     
00256     double rho = zerosec(fonc_des_domaine_y, parzerosec, rhomin0, rhomax0, 
00257                  precis, nitermax, niter) ;
00258                    
00259     xg[i] = float(( rho * cos(khi) + mp.get_ori_x() ) / km) ;
00260     zg[i] = float(( rho * sin(khi) + mp.get_ori_z() ) / km) ;
00261 
00262     }
00263     
00264     // Graphics display
00265     // ----------------
00266 
00267     if ( (newgraph == 1) || (newgraph == 3) ) {
00268 
00269     if (device == 0x0) device = "?" ; 
00270    
00271     int ier = cpgbeg(0, device, nxpage, nypage) ;
00272     if (ier != 1) {
00273     cout << "des_domaine_y: problem in opening PGPLOT display !" << endl ;
00274     } 
00275     
00276     // Taille des caracteres:
00277     float size = float(1.3) ;
00278     cpgsch(size) ;
00279     
00280     // Epaisseur des traits:
00281     int lepais = 1 ; 
00282     cpgslw(lepais) ;
00283     
00284     cpgscf(2) ; // Fonte axes: caracteres romains
00285     
00286     float xmin1 = float(x_min / km) ;
00287     float xmax1 = float(x_max / km) ;
00288     float zmin1 = float(z_min / km) ;
00289     float zmax1 = float(z_max / km) ;
00290     
00291     cpgenv(xmin1, xmax1, zmin1, zmax1, 1, 0 ) ; 
00292 
00293     if (nomx == 0x0) nomx = "x [km]" ;
00294     if (nomz == 0x0) nomz = "z [km]" ; 
00295     if (title == 0x0) title = " " ; 
00296     cpglab(nomx,nomz,title) ;
00297 
00298     }
00299 
00300     if (coupe_surface) {
00301     cpgsls(3) ;     // lignes en trait mixte
00302     cpgsci(3) ;     // couleur verte
00303     cpgline(np, xg, zg) ;
00304     cpgsls(1) ;     // retour aux lignes en trait plein
00305     cpgsci(1) ;     // couleur noire
00306     }
00307     
00308     
00309     // Closing graphic display
00310     // -----------------------
00311 
00312     if ( (newgraph == 2) || (newgraph == 3) ) {    
00313     cpgend() ; 
00314     }
00315 
00316 }
00317 
00318 //******************************************************************************
00319 
00320 void des_domaine_z(const Map& mp, int l0, double z0, const char* device, int newgraph, 
00321            double x_min, double x_max, double y_min, double y_max, 
00322            const char* nomx, const char* nomy, const char* title, int nxpage, int nypage)
00323 {
00324   using namespace Unites ;
00325 
00326     double khi ;
00327     
00328     Param parzerosec ;
00329     parzerosec.add_int(l0, 0) ;     
00330     parzerosec.add_double_mod(z0, 0) ;  
00331     parzerosec.add_double_mod(khi, 1) ;     
00332     parzerosec.add_map(mp, 0) ;     
00333 
00334     double rhomin = 0 ; 
00335     double rhomax = 2 * 
00336             mp.val_r(mp.get_mg()->get_nzone() - 1, -1., 0., 0.) ;  
00337     double precis = 1.e-14 * (rhomax - rhomin) ; 
00338     int nitermax = 100 ; 
00339     int niter ; 
00340     
00341     const int np = 101 ; 
00342     float xg[np] ; 
00343     float yg[np] ; 
00344 
00345     double hkhi = 2 * M_PI / (np-1) ; 
00346     
00347     bool coupe_surface = true ; 
00348     
00349     for (int i=0; i< np; i++) {
00350 
00351     khi = hkhi * i ; 
00352     
00353     // Search for the interval [rhomin0, rhomax0] which contains 
00354     //  the first zero of des_surf:
00355     
00356     double rhomin0 ;
00357     double rhomax0 ;
00358 
00359     if ( zero_premier(fonc_des_domaine_z, parzerosec, rhomin, rhomax, 100, 
00360              rhomin0, rhomax0) == false ) {
00361         cout << 
00362    "des_domaine_z : WARNING : no crossing with the domain boundary"
00363         << endl ; 
00364         cout << "  has been found for khi = " << khi << " !" << endl ; 
00365 
00366         coupe_surface = false ; 
00367         break ; 
00368 
00369     }
00370         
00371              
00372     // Search for the zero in the interval [rhomin0, rhomax0] :
00373     
00374     double rho = zerosec(fonc_des_domaine_z, parzerosec, rhomin0, rhomax0, 
00375                  precis, nitermax, niter) ;
00376                    
00377     xg[i] = float(( rho * cos(khi) + mp.get_ori_x() ) / km) ;
00378     yg[i] = float(( rho * sin(khi) + mp.get_ori_y() ) / km) ;
00379 
00380     }
00381     
00382     // Graphics display
00383     // ----------------
00384 
00385     if ( (newgraph == 1) || (newgraph == 3) ) {
00386 
00387     if (device == 0x0) device = "?" ; 
00388    
00389     int ier = cpgbeg(0, device, nxpage, nypage) ;
00390     if (ier != 1) {
00391     cout << "des_domaine_z: problem in opening PGPLOT display !" << endl ;
00392     } 
00393     
00394     // Taille des caracteres:
00395     float size = float(1.3) ;
00396     cpgsch(size) ;
00397     
00398     // Epaisseur des traits:
00399     int lepais = 1 ; 
00400     cpgslw(lepais) ;
00401     
00402     cpgscf(2) ; // Fonte axes: caracteres romains
00403     
00404     float xmin1 = float(x_min / km) ;
00405     float xmax1 = float(x_max / km) ;
00406     float ymin1 = float(y_min / km) ;
00407     float ymax1 = float(y_max / km) ;
00408     
00409     cpgenv(xmin1, xmax1, ymin1, ymax1, 1, 0 ) ; 
00410 
00411     if (nomx == 0x0) nomx = "x [km]" ;
00412     if (nomy == 0x0) nomy = "y [km]" ; 
00413     if (title == 0x0) title = " " ; 
00414     cpglab(nomx,nomy,title) ;
00415 
00416     }
00417 
00418     if (coupe_surface) {
00419     cpgsls(3) ;     // lignes en trait mixte
00420     cpgsci(3) ;     // couleur verte
00421     cpgline(np, xg, yg) ;
00422     cpgsls(1) ;     // retour aux lignes en trait plein
00423     cpgsci(1) ;     // couleur noire
00424     }
00425     
00426     
00427     // Closing graphic display
00428     // -----------------------
00429 
00430     if ( (newgraph == 2) || (newgraph == 3) ) {    
00431     cpgend() ; 
00432     }
00433 
00434 }
00435 
00436 
00437 
00438 
00439 //*****************************************************************************
00440 
00441 double fonc_des_domaine_x(double vrho, const Param& par) {
00442     
00443     int l = par.get_int(0) ; 
00444     double x = par.get_double_mod(0) ; 
00445     double khi = par.get_double_mod(1) ; 
00446     const Map& mp = par.get_map(0) ; 
00447     
00448     // Absolute Cartesian coordinates: 
00449     double y = vrho * cos(khi) + mp.get_ori_y() ; 
00450     double z = vrho * sin(khi) + mp.get_ori_z() ; 
00451 
00452     // Spherical coordinates of the mapping:
00453     double r, theta, phi ; 
00454     mp.convert_absolute(x, y, z, r, theta, phi) ;
00455     
00456     return  r - mp.val_r(l, 1., theta, phi) ; 
00457     
00458 }
00459 
00460 //*****************************************************************************
00461 
00462 double fonc_des_domaine_y(double vrho, const Param& par) {
00463     
00464     int l = par.get_int(0) ; 
00465     double y = par.get_double_mod(0) ; 
00466     double khi = par.get_double_mod(1) ; 
00467     const Map& mp = par.get_map(0) ; 
00468     
00469     // Absolute Cartesian coordinates: 
00470     double x = vrho * cos(khi) + mp.get_ori_x() ; 
00471     double z = vrho * sin(khi) + mp.get_ori_z() ; 
00472 
00473     // Spherical coordinates of the mapping:
00474     double r, theta, phi ; 
00475     mp.convert_absolute(x, y, z, r, theta, phi) ;
00476     
00477     return  r - mp.val_r(l, 1., theta, phi) ; 
00478     
00479 }
00480 
00481 //*****************************************************************************
00482 
00483 double fonc_des_domaine_z(double vrho, const Param& par) {
00484     
00485     int l = par.get_int(0) ; 
00486     double z = par.get_double_mod(0) ; 
00487     double khi = par.get_double_mod(1) ; 
00488     const Map& mp = par.get_map(0) ; 
00489     
00490     // Absolute Cartesian coordinates: 
00491     double x = vrho * cos(khi) + mp.get_ori_x() ; 
00492     double y = vrho * sin(khi) + mp.get_ori_y() ; 
00493 
00494     // Spherical coordinates of the mapping:
00495     double r, theta, phi ; 
00496     mp.convert_absolute(x, y, z, r, theta, phi) ;
00497     
00498     return  r - mp.val_r(l, 1., theta, phi) ; 
00499     
00500 }
00501 

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