strot_dirac_diff_faitomeg.C

00001 /*
00002  * Functions Star_rot_Dirac_diff::fait_omega_field
00003  *       Star_rot_Dirac_diff::fait_prim_field
00004  *
00005  *    (see file star_rot_dirac_diff.h for documentation).
00006  *
00007  */
00008 
00009 /*
00010  *   Copyright (c) 2005 Motoyuki Saijo
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 strot_dirac_diff_faitomeg_C[] = "$Header: /cvsroot/Lorene/C++/Source/Star/strot_dirac_diff_faitomeg.C,v 1.1 2005/08/13 19:48:50 m_saijo Exp $" ;
00032 
00033 /*
00034  * $Header: /cvsroot/Lorene/C++/Source/Star/strot_dirac_diff_faitomeg.C,v 1.1 2005/08/13 19:48:50 m_saijo Exp $
00035  *
00036  */
00037 
00038 
00039 // Headers Lorene
00040 #include "star_rot_dirac_diff.h"
00041 #include "utilitaires.h"
00042 #include "param.h"
00043 
00044 double strot_dirac_diff_fzero(double omeg, const Param& par) ;
00045 
00046 
00047             //-----------------------------------//
00048             //      fait_omega_field         //
00049             //-----------------------------------//
00050 
00051 void Star_rot_Dirac_diff::fait_omega_field(double omeg_min, double omeg_max,
00052                    double precis, int nitermax) {
00053 
00054     const Mg3d& mg = *(mp.get_mg()) ; 
00055     int nz = mg.get_nzone() ; 
00056     int nzm1 = nz - 1 ; 
00057 
00058     Scalar brst2 = gamma.cov()(3,3) ;
00059     brst2.annule(nzm1, nzm1) ; 
00060             brst2.mult_rsint() ;
00061             brst2.mult_rsint() ;
00062     Scalar nnn2 = qqq * qqq / psi4 ; 
00063     Scalar betp = beta(3) ;
00064            betp.div_rsint() ;
00065 
00066     Param par ;
00067     par.add_scalar(nnn2, 0) ;
00068     par.add_scalar(brst2, 1) ;
00069     par.add_scalar(betp, 2) ;
00070 
00071     int l, k, j, i ;
00072     par.add_int(l, 0) ;
00073     par.add_int(k, 1) ;
00074     par.add_int(j, 2) ;
00075     par.add_int(i, 3) ;
00076 
00077     par.add_star(*this) ;
00078 
00079     // Loop on the grid points
00080     // -----------------------
00081 
00082     int niter ;
00083     
00084     bool prev_zero = (omega_field.get_etat() == ETATZERO) ;
00085     
00086     omega_field.allocate_all() ;
00087 
00088     // cout << "Star_rot_Dirac_diff::fait_omega_field: niter : " << '\n' ; 
00089     for (l=0; l<nzet+1; l++) {
00090         Tbl& tom = omega_field.set_domain(l) ;
00091     for (k=0; k<mg.get_np(l); k++) {
00092         for (j=0; j<mg.get_nt(l); j++) {
00093         for (i=0; i<mg.get_nr(l); i++) {
00094 
00095             double& omeg =  tom.set(k, j, i) ; 
00096 
00097             double omeg_min1, omeg_max1 ; 
00098             if ( prev_zero || omeg == double(0)) {
00099             omeg_min1 = omeg_min ; 
00100             omeg_max1 = omeg_max ; 
00101             } 
00102             else{
00103             omeg_min1 = 0.8 * omeg ; 
00104             omeg_max1 = 1.2 * omeg ; 
00105             } 
00106         
00107             omeg = zerosec(strot_dirac_diff_fzero, par, omeg_min1,
00108                    omeg_max1, precis, nitermax, niter) ;
00109             
00110             // cout << "  " << niter ; 
00111 
00112         }
00113         }
00114     }
00115     // cout << '\n' ; 
00116     }
00117 
00118     // omega_field is set to 0 far from the star:
00119     // ---------------------------------------------------
00120     for (l=nzet+1; l<nz; l++) {
00121     omega_field.set_domain(l) = 0 ;
00122     }
00123 
00124     omega_field.std_spectral_base() ;
00125     
00126     // Min and Max of Omega
00127     // --------------------
00128     
00129     omega_min = min( omega_field.domain(0) ) ; 
00130     for (l=1; l<nzet; l++) {
00131     double xx = min( omega_field.domain(l) ) ; 
00132     omega_min = (xx < omega_min) ? xx : omega_min ; 
00133     }
00134     
00135     omega_max = max( max( omega_field ) ) ;     
00136     
00137     // Update of prim_field
00138     // --------------------
00139     fait_prim_field() ; 
00140     
00141 }
00142 
00143             //----------------------------------------//
00144             //      strot_dirac_diff_fzero        //
00145             //----------------------------------------//
00146 
00147 double strot_dirac_diff_fzero(double omeg, const Param& par) {
00148 
00149     const Scalar& nnn2 =  par.get_scalar(0) ;
00150     const Scalar& brst2 = par.get_scalar(1) ;
00151         const Scalar& betp =  par.get_scalar(2) ;
00152         int l = par.get_int(0) ;
00153         int k = par.get_int(1) ;
00154     int j = par.get_int(2) ;
00155     int i = par.get_int(3) ;
00156     
00157     const Star_rot_Dirac_diff* star =
00158       dynamic_cast<const Star_rot_Dirac_diff*>(&par.get_star()) ;
00159         
00160         double fom = star->funct_omega(omeg) ;
00161         double omnp = omeg + betp.val_grid_point(l, k, j, i) ;
00162         
00163         return fom - brst2.val_grid_point(l, k, j, i) * omnp /
00164                ( nnn2.val_grid_point(l, k, j, i) - 
00165                  brst2.val_grid_point(l, k, j, i) * omnp * omnp ) ;
00166 
00167 }
00168 
00169 
00170             //-----------------------------------//
00171             //      fait_prim_field          //
00172             //-----------------------------------//
00173 
00174 
00175 void Star_rot_Dirac_diff::fait_prim_field() {
00176    
00177     const Mg3d& mg = *(mp.get_mg()) ; 
00178     int nz = mg.get_nzone() ; 
00179 
00180     // Loop on the grid points in the vicinity of the star
00181     // ---------------------------------------------------
00182 
00183     prim_field.allocate_all() ;
00184 
00185     for (int l=0; l<nzet+1; l++) {
00186         Tbl& tprim = prim_field.set_domain(l) ;
00187     for (int k=0; k<mg.get_np(l); k++) {
00188         for (int j=0; j<mg.get_nt(l); j++) {
00189         for (int i=0; i<mg.get_nr(l); i++) {
00190         
00191             tprim.set(k, j, i) = 
00192                 primfrot( omega_field.val_grid_point(l, k, j, i), 
00193                                       par_frot ) ; 
00194             
00195         }
00196         }
00197     }
00198     }
00199 
00200     // prim_field is set to 0 far from the star:
00201     // -----------------------------------------
00202     for (int l=nzet+1; l<nz; l++) {
00203     prim_field.set_domain(l) = 0 ;
00204     }
00205 
00206     prim_field.std_spectral_base() ;
00207     
00208     
00209 }

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