valeur_equipot_out.C

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

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