et_rot_diff_faitomeg.C

00001 /*
00002  * Functions Et_rot_diff::fait_omega_field
00003  *       Et_rot_diff::fait_prim_field
00004  *
00005  *    (see file et_rot_diff.h for documentation).
00006  *
00007  */
00008 
00009 /*
00010  *   Copyright (c) 2001 Eric Gourgoulhon
00011  *
00012  *   This file is part of LORENE.
00013  *
00014  *   LORENE is free software; you can redistribute it and/or modify
00015  *   it under the terms of the GNU General Public License as published by
00016  *   the Free Software Foundation; either version 2 of the License, or
00017  *   (at your option) any later version.
00018  *
00019  *   LORENE is distributed in the hope that it will be useful,
00020  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022  *   GNU General Public License for more details.
00023  *
00024  *   You should have received a copy of the GNU General Public License
00025  *   along with LORENE; if not, write to the Free Software
00026  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00027  *
00028  */
00029 
00030 
00031 char et_rot_diff_faitomeg_C[] = "$Header: /cvsroot/Lorene/C++/Source/Etoile/et_rot_diff_faitomeg.C,v 1.2 2003/05/14 20:07:00 e_gourgoulhon Exp $" ;
00032 
00033 /*
00034  * $Id: et_rot_diff_faitomeg.C,v 1.2 2003/05/14 20:07:00 e_gourgoulhon Exp $
00035  * $Log: et_rot_diff_faitomeg.C,v $
00036  * Revision 1.2  2003/05/14 20:07:00  e_gourgoulhon
00037  * Suppressed the outputs (cout)
00038  *
00039  * Revision 1.1.1.1  2001/11/20 15:19:28  e_gourgoulhon
00040  * LORENE
00041  *
00042  * Revision 1.3  2001/10/25  09:43:18  eric
00043  * omega_min est determine dans l'etoile seulement (l<nzet).
00044  *
00045  * Revision 1.2  2001/10/25  09:21:29  eric
00046  * Recherche de Omega dans un intervalle de 20% autour de la valeur precedente.
00047  *
00048  * Revision 1.1  2001/10/19  08:18:23  eric
00049  * Initial revision
00050  *
00051  *
00052  * $Header: /cvsroot/Lorene/C++/Source/Etoile/et_rot_diff_faitomeg.C,v 1.2 2003/05/14 20:07:00 e_gourgoulhon Exp $
00053  *
00054  */
00055 
00056 
00057 // Headers Lorene
00058 #include "et_rot_diff.h"
00059 #include "utilitaires.h"
00060 #include "param.h"
00061 
00062 double et_rot_diff_fzero(double omeg, const Param& par) ;
00063 
00064 
00065             //-----------------------------------//
00066             //      fait_omega_field         //
00067             //-----------------------------------//
00068 
00069 void Et_rot_diff::fait_omega_field(double omeg_min, double omeg_max,
00070                    double precis, int nitermax) {
00071     
00072     const Mg3d& mg = *(mp.get_mg()) ; 
00073     int nz = mg.get_nzone() ; 
00074     int nzm1 = nz - 1 ; 
00075 
00076     // Computation of B^2 r^2 sin^2(theta):
00077     // -----------------------------------
00078     
00079     Cmp brst2 = bbb() ;
00080     brst2.annule(nzm1) ; 
00081     brst2.std_base_scal() ;
00082     brst2.mult_rsint() ;        //  Multiplication by r sin(theta)
00083     brst2 = brst2*brst2 ;
00084     
00085     Cmp nnn2 = nnn() * nnn() ; 
00086 
00087     Param par ; 
00088     par.add_cmp(nnn2, 0) ; 
00089     par.add_cmp(brst2, 1) ; 
00090     par.add_cmp(nphi(), 2) ;
00091 
00092     int l, k, j, i ;
00093     par.add_int(l, 0) ;
00094     par.add_int(k, 1) ;
00095     par.add_int(j, 2) ;
00096     par.add_int(i, 3) ;
00097 
00098     par.add_etoile(*this) ;
00099 
00100     // Loop on the grid points
00101     // -----------------------
00102 
00103     int niter ;
00104     
00105     bool prev_zero = (omega_field.get_etat() == ETATZERO) ;
00106     
00107     omega_field.allocate_all() ;
00108 
00109     // cout << "Et_rot_diff::fait_omega_field: niter : " << endl ; 
00110     for (l=0; l<nzet+1; l++) {
00111         Tbl& tom = omega_field.set().set(l) ;
00112     for (k=0; k<mg.get_np(l); k++) {
00113         for (j=0; j<mg.get_nt(l); j++) {
00114         for (i=0; i<mg.get_nr(l); i++) {
00115 
00116             double& omeg =  tom.set(k, j, i) ; 
00117 
00118             double omeg_min1, omeg_max1 ; 
00119             if ( prev_zero || omeg == double(0)) {
00120             omeg_min1 = omeg_min ; 
00121             omeg_max1 = omeg_max ; 
00122             } 
00123             else{
00124             omeg_min1 = 0.8 * omeg ; 
00125             omeg_max1 = 1.2 * omeg ; 
00126             } 
00127         
00128             omeg = zerosec(et_rot_diff_fzero, par, omeg_min1,
00129                    omeg_max1, precis, nitermax, niter) ;
00130             
00131             // cout << "  " << niter ; 
00132 
00133         }
00134         }
00135     }
00136     // cout << endl ; 
00137     }
00138 
00139     // omega_field is set to 0 far from the star:
00140     // ---------------------------------------------------
00141     for (l=nzet+1; l<nz; l++) {
00142     omega_field.set().set(l) = 0 ;
00143     }
00144 
00145     omega_field.set_std_base() ;
00146     
00147     // Min and Max of Omega
00148     // --------------------
00149     
00150     omega_min = min( omega_field()(0) ) ; 
00151     for (l=1; l<nzet; l++) {
00152     double xx = min( omega_field()(l) ) ; 
00153     omega_min = (xx < omega_min) ? xx : omega_min ; 
00154     }
00155     
00156     omega_max = max( max( omega_field() ) ) ;     
00157     
00158     // Update of prim_field
00159     // --------------------
00160     fait_prim_field() ; 
00161     
00162 }
00163 
00164             //-----------------------------------//
00165             //      et_rot_diff_fzero        //
00166             //-----------------------------------//
00167 
00168 double et_rot_diff_fzero(double omeg, const Param& par) {
00169 
00170     const Cmp& nnn2 =  par.get_cmp(0) ;
00171     const Cmp& brst2 = par.get_cmp(1) ;
00172         const Cmp& nphi =  par.get_cmp(2) ;
00173         int l = par.get_int(0) ;
00174         int k = par.get_int(1) ;
00175     int j = par.get_int(2) ;
00176     int i = par.get_int(3) ;
00177     
00178     const Et_rot_diff* et =
00179         dynamic_cast<const Et_rot_diff*>(&par.get_etoile()) ;
00180         
00181         double fom = et->funct_omega(omeg) ;
00182         double omnp = omeg - nphi(l, k, j, i) ;
00183         
00184         return fom - brst2(l, k, j, i) * omnp /
00185                ( nnn2(l, k, j, i) - brst2(l, k, j, i) * omnp*omnp ) ;
00186 
00187 }
00188 
00189 
00190             //-----------------------------------//
00191             //      fait_prim_field          //
00192             //-----------------------------------//
00193 
00194 
00195 void Et_rot_diff::fait_prim_field() {
00196    
00197     const Mg3d& mg = *(mp.get_mg()) ; 
00198     int nz = mg.get_nzone() ; 
00199 
00200     // Loop on the grid points in the vicinity of the star
00201     // ---------------------------------------------------
00202 
00203     prim_field.allocate_all() ;
00204 
00205     for (int l=0; l<nzet+1; l++) {
00206         Tbl& tprim = prim_field.set().set(l) ;
00207     for (int k=0; k<mg.get_np(l); k++) {
00208         for (int j=0; j<mg.get_nt(l); j++) {
00209         for (int i=0; i<mg.get_nr(l); i++) {
00210         
00211             tprim.set(k, j, i) = 
00212                 primfrot( omega_field()(l, k, j, i), par_frot ) ; 
00213             
00214         }
00215         }
00216     }
00217     }
00218 
00219     // prim_field is set to 0 far from the star:
00220     // -----------------------------------------
00221     for (int l=nzet+1; l<nz; l++) {
00222     prim_field.set().set(l) = 0 ;
00223     }
00224 
00225     prim_field.set_std_base() ;
00226     
00227     
00228 }

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