valeur_equipot.C

00001 /*
00002  * Method of the class Valeur to compute an equipotential surface.
00003  *
00004  * (see file valeur.h for the documentation).
00005  */
00006 
00007 /*
00008  *   Copyright (c) 1999-2001 Eric Gourgoulhon
00009  *
00010  *   This file is part of LORENE.
00011  *
00012  *   LORENE is free software; you can redistribute it and/or modify
00013  *   it under the terms of the GNU General Public License as published by
00014  *   the Free Software Foundation; either version 2 of the License, or
00015  *   (at your option) any later version.
00016  *
00017  *   LORENE is distributed in the hope that it will be useful,
00018  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  *   GNU General Public License for more details.
00021  *
00022  *   You should have received a copy of the GNU General Public License
00023  *   along with LORENE; if not, write to the Free Software
00024  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025  *
00026  */
00027 
00028 
00029 char valeur_equipot_C[] = "$Header: /cvsroot/Lorene/C++/Source/Valeur/valeur_equipot.C,v 1.3 2003/12/19 15:05:56 j_novak Exp $" ;
00030 
00031 /*
00032  * $Id: valeur_equipot.C,v 1.3 2003/12/19 15:05:56 j_novak Exp $
00033  * $Log: valeur_equipot.C,v $
00034  * Revision 1.3  2003/12/19 15:05:56  j_novak
00035  * Added some initializations
00036  *
00037  * Revision 1.2  2002/10/16 14:37:15  j_novak
00038  * Reorganization of #include instructions of standard C++, in order to
00039  * use experimental version 3 of gcc.
00040  *
00041  * Revision 1.1.1.1  2001/11/20 15:19:27  e_gourgoulhon
00042  * LORENE
00043  *
00044  * Revision 1.3  2000/01/28  17:06:37  eric
00045  * Changement du cas l2<nz_search-1.
00046  *
00047  * Revision 1.2  2000/01/03  15:07:50  eric
00048  * *** empty log message ***
00049  *
00050  * Revision 1.1  1999/12/29  13:12:08  eric
00051  * Initial revision
00052  *
00053  *
00054  * $Header: /cvsroot/Lorene/C++/Source/Valeur/valeur_equipot.C,v 1.3 2003/12/19 15:05:56 j_novak Exp $
00055  *
00056  */
00057 
00058 // Headers C
00059 #include <stdlib.h>
00060 #include <math.h>
00061 
00062 // Headers Lorene
00063 #include "valeur.h"
00064 #include "itbl.h"
00065 #include "param.h"
00066 #include "nbr_spx.h"
00067 #include "utilitaires.h"
00068 
00069 // Local prototypes
00070 double valeur_equipot_fonc(double, const Param&) ;
00071 
00072 //****************************************************************************
00073  
00074 void Valeur::equipot(double uu0, int nz_search, double precis, int nitermax,
00075              int& niter, Itbl& l_iso, Tbl& xi_iso) const {
00076 
00077     
00078     int nz = mg->get_nzone() ; 
00079     int nt = mg->get_nt(0) ; 
00080     int np = mg->get_np(0) ; 
00081     
00082     // Protections 
00083     // -----------
00084     assert(etat == ETATQCQ) ; 
00085     assert(nz_search > 0) ; 
00086     assert(nz_search <= nz) ; 
00087     for (int l=1; l<nz_search; l++) {
00088     assert( mg->get_nt(l) == nt ) ; 
00089     assert( mg->get_np(l) == np ) ; 
00090     }
00091     
00092     coef() ;    // the spectral coefficients are required
00093     
00094     l_iso.set_etat_qcq() ; 
00095     xi_iso.set_etat_qcq() ; 
00096 
00097     Param parf ;
00098     int j, k, l2 ; 
00099     parf.add_int_mod(j, 0) ; 
00100     parf.add_int_mod(k, 1) ; 
00101     parf.add_int_mod(l2, 2) ; 
00102     parf.add_double(uu0) ; 
00103     parf.add_mtbl_cf(*c_cf) ; 
00104     
00105     
00106     // Loop of phi and theta
00107     // ---------------------
00108     
00109     niter = 0 ; 
00110     
00111     for (k=0; k<np; k++) {
00112 
00113         for (j=0; j<nt; j++) {
00114 
00115 
00116 // 1. Recherche du point de collocation en r (l2,i2) egal a ou situe 
00117 //    immediatement avant r_iso(phi,theta)
00118 
00119     int i2 = 0;
00120     l2 = nz ;
00121     for (int l=nz_search-1; l>= 0; l--) {   // On part de la zone la plus extreme
00122         int nr = mg->get_nr(l) ;
00123     
00124         for (int i=nr-1; i >= 0; i--) {
00125         double uux = (*this)(l, k, j, i) ;
00126         if ( ( (uux > uu0) || ( fabs(uux-uu0) < 1.e-14 ) ) &&
00127             (uux != __infinity) ) {
00128             l2 = l ;        // on a trouve le point 
00129             i2 = i ;        //
00130             break ;
00131         }
00132         }
00133 
00134         if (l2 == l) break ;
00135     }   // fin de la boucle sur les zones
00136 
00137     if (l2==nz) {
00138         cout << "Valeur::equipot: the point uu >= uu0 has not been found" << endl ;
00139         cout << " for the phi index " << k << endl ;
00140         cout << " and the theta index " << j <<  endl ;
00141         cout << " uu0 = " << uu0 << endl ;
00142         abort () ;
00143     }       
00144 
00145 // 2. Point suivant (l2,i3) 
00146     int i3 = 0 ;
00147     if (i2 < mg->get_nr(l2) -1) { // on reste dans la meme zone
00148         i3 = i2 + 1 ;
00149     }
00150     else {
00151          if (l2<nz_search-1) { // on change de zone
00152 
00153         double uux = (*this)(l2, k, j, i2) ;
00154         if ( ( fabs(uux-uu0) < 1.e-14 ) ) {
00155             // it is OK
00156                 cout << 
00157             "Valeur::equipot: WARNING : fabs(uux-uu0) < 1.e-14" << endl ;
00158             l_iso.set(k, j) = l2 ;
00159             xi_iso.set(k, j) = (mg->get_grille3d(l2))->x[i2] ;
00160         }
00161         else{
00162                 cout << "Valeur::equipot: PROBLEM !!!" << endl ;
00163             cout << " k,  j : " << k << " " << j << endl ;
00164             cout << " uu0 : " << uu0 << endl ;
00165             abort () ;
00166         } 
00167          }
00168          else { // on est a l'extremite de la grille
00169         l_iso.set(k, j) = nz_search-1 ;
00170         xi_iso.set(k, j) = (mg->get_grille3d(l2))->x[i2] ;
00171         continue ;  // on passe au theta suivant
00172          }
00173     }
00174 
00175     l_iso.set(k, j) = l2 ;
00176 
00177     double x2 = (mg->get_grille3d(l2))->x[i2] ;
00178     double x3 = (mg->get_grille3d(l2))->x[i3] ;
00179 
00180     double y2 = (*this)(l2, k, j, i2) - uu0 ;
00181 
00182 // 3. Recherche de x0 
00183     
00184     int niter0 = 0 ;
00185     if (fabs(y2) < 1.e-14) {
00186         xi_iso.set(k, j) = x2 ;
00187     }
00188     else {
00189         xi_iso.set(k, j) = zerosec(valeur_equipot_fonc, parf, x2, x3, precis, 
00190                         nitermax, niter0 ) ;
00191     }
00192     
00193     niter = ( niter0 > niter ) ? niter0 : niter ;
00194     
00195     }      // fin de la boucle sur theta
00196     }      // fin de la boucle sur phi
00197         
00198 }
00199     
00200   
00201         
00202 //****************************************************************************
00203  
00204 double valeur_equipot_fonc(double xi, const Param& par) {
00205     
00206     int j = par.get_int_mod(0) ; 
00207     int k = par.get_int_mod(1) ; 
00208     int l = par.get_int_mod(2) ;
00209     double uu0 = par.get_double() ; 
00210     const Mtbl_cf& cuu = par.get_mtbl_cf() ; 
00211     
00212     return cuu.val_point_jk(l, xi, j, k) - uu0 ;     
00213 }
00214 

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