et_bin_equil_regu.C

00001 /*
00002  *  Method of class Etoile_bin to compute an equilibrium configuration
00003  *  by regularizing source.
00004  *
00005  *  (see file etoile.h for documentation).
00006  *
00007  */
00008 
00009 /*
00010  *   Copyright (c) 2000-2001 Eric Gourgoulhon
00011  *   Copyright (c) 2000-2001 Keisuke Taniguchi
00012  *
00013  *   This file is part of LORENE.
00014  *
00015  *   LORENE is free software; you can redistribute it and/or modify
00016  *   it under the terms of the GNU General Public License as published by
00017  *   the Free Software Foundation; either version 2 of the License, or
00018  *   (at your option) any later version.
00019  *
00020  *   LORENE is distributed in the hope that it will be useful,
00021  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00022  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023  *   GNU General Public License for more details.
00024  *
00025  *   You should have received a copy of the GNU General Public License
00026  *   along with LORENE; if not, write to the Free Software
00027  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00028  *
00029  */
00030 
00031 
00032 char et_bin_equil_regu_C[] = "$Header: /cvsroot/Lorene/C++/Source/Etoile/et_bin_equil_regu.C,v 1.6 2009/06/15 09:26:57 k_taniguchi Exp $" ;
00033 
00034 /*
00035  * $Id: et_bin_equil_regu.C,v 1.6 2009/06/15 09:26:57 k_taniguchi Exp $
00036  * $Log: et_bin_equil_regu.C,v $
00037  * Revision 1.6  2009/06/15 09:26:57  k_taniguchi
00038  * Improved the rescaling of the domains.
00039  *
00040  * Revision 1.5  2004/03/25 10:29:03  j_novak
00041  * All LORENE's units are now defined in the namespace Unites (in file unites.h).
00042  *
00043  * Revision 1.4  2003/09/01 06:48:08  k_taniguchi
00044  * Change of the domain which should be resized.
00045  *
00046  * Revision 1.3  2003/08/31 05:35:38  k_taniguchi
00047  * Addition of the specification of the domain
00048  *  which is resized.
00049  *
00050  * Revision 1.2  2002/12/11 12:51:26  k_taniguchi
00051  * Change the multiplication "*" to "%"
00052  *   and flat_scalar_prod to flat_scalar_prod_desal.
00053  *
00054  * Revision 1.1.1.1  2001/11/20 15:19:28  e_gourgoulhon
00055  * LORENE
00056  *
00057  * Revision 2.17  2001/08/07  09:49:00  keisuke
00058  * Change of the method to set the longest radius of a star
00059  *  on the first domain.
00060  * Addition of a new argument in Etoile_bin::equil_regular : Tbl fact.
00061  *
00062  * Revision 2.16  2001/06/22  08:54:53  keisuke
00063  * Set the inner values of the second domain of ent
00064  *   by using the outer ones of the first domain.
00065  *
00066  * Revision 2.15  2001/05/17  12:22:26  keisuke
00067  * Change of the method to calculate chi from setting position in map
00068  *  to val_point.
00069  *
00070  * Revision 2.14  2001/02/07  09:47:28  eric
00071  * unsgam1 est desormais donne par Eos::der_nbar_ent (cas newtonien)
00072  *   ou Eos::der_ener_ent (cas relativiste).
00073  *
00074  * Revision 2.13  2001/01/16  17:02:32  keisuke
00075  * *** empty log message ***
00076  *
00077  * Revision 2.12  2001/01/16  16:58:08  keisuke
00078  * Change the method to set the values on the surface.
00079  *
00080  * Revision 2.11  2001/01/10  16:45:34  keisuke
00081  * Set the inner values of the second domain of logn_auto
00082  *   by using the outer ones of the first domain.
00083  *
00084  * Revision 2.10  2000/12/20  10:33:14  eric
00085  * Changement important : nz_search = nzet ---> nz_search = nzet + 1
00086  *
00087  * Revision 2.9  2000/10/25  14:01:03  keisuke
00088  * Modif de Map_et::adapt: on y rentre desormais avec nz_search
00089  *  (dans le cas present nz_search = nzet).
00090  *
00091  * Revision 2.8  2000/10/06  15:29:01  keisuke
00092  * Change poisson_vect into poisson_vect_regu.
00093  *
00094  * Revision 2.7  2000/09/25  15:01:10  keisuke
00095  * Suppress "int" from the declaration of k_div.
00096  *
00097  * Revision 2.6  2000/09/22  15:51:39  keisuke
00098  * d_logn_auto est desormais calcule en dehors (dans update_metric).
00099  *
00100  * Revision 2.5  2000/09/13  09:50:33  keisuke
00101  * Minor change on change_triad.
00102  *
00103  * Revision 2.4  2000/09/08  15:57:31  keisuke
00104  * Change the basis of d_logn_auto_div from the spherical coordinate
00105  *  to the Cartesian one with respect to ref_triad.
00106  *
00107  * Revision 2.3  2000/09/07  15:47:19  keisuke
00108  * Minor change.
00109  *
00110  * Revision 2.2  2000/09/07  15:43:41  keisuke
00111  * Add a new argument in poisson_regular and suppress logn_auto_total.
00112  *
00113  * Revision 2.1  2000/08/29  14:01:43  keisuke
00114  * Modify the arguments of poisson_regular.
00115  *
00116  * Revision 2.0  2000/08/29  11:39:02  eric
00117  * Version provisoire.
00118  *
00119  *
00120  * $Header: /cvsroot/Lorene/C++/Source/Etoile/et_bin_equil_regu.C,v 1.6 2009/06/15 09:26:57 k_taniguchi Exp $
00121  *
00122  */
00123 
00124 // Headers C
00125 #include <math.h>
00126 
00127 // Headers Lorene
00128 #include "etoile.h"
00129 #include "param.h"
00130 #include "eos.h"
00131 #include "utilitaires.h"
00132 #include "unites.h"     
00133 
00134 //********************************************************************
00135 
00136 void Etoile_bin::equil_regular(double ent_c, int mermax, int mermax_poisson, 
00137                    double relax_poisson, int mermax_potvit, 
00138                    double relax_potvit, double thres_adapt,
00139                    const Tbl& fact_resize, Tbl& diff) {
00140 
00141     // Fundamental constants and units
00142     // -------------------------------
00143   using namespace Unites ;
00144 
00145     // Initializations
00146     // ---------------
00147 
00148     k_div = 2 ;  // Regularity parameter for poisson_regular
00149 
00150     const Mg3d* mg = mp.get_mg() ;
00151     int nz = mg->get_nzone() ;      // total number of domains
00152 
00153     // The following is required to initialize mp_prev as a Map_et:
00154     Map_et& mp_et = dynamic_cast<Map_et&>(mp) ;
00155 
00156     // Domain and radial indices of points at the surface of the star:
00157     int l_b = nzet - 1 ; 
00158     int i_b = mg->get_nr(l_b) - 1 ; 
00159     int k_b ;
00160     int j_b ; 
00161 
00162     // Value of the enthalpy defining the surface of the star
00163     double ent_b = 0 ;
00164 
00165     // Error indicators
00166     // ----------------
00167 
00168     double& diff_ent = diff.set(0) ;
00169     double& diff_vel_pot = diff.set(1) ;
00170     double& diff_logn = diff.set(2) ;
00171     double& diff_beta = diff.set(3) ;
00172     double& diff_shift_x = diff.set(4) ;
00173     double& diff_shift_y = diff.set(5) ;
00174     double& diff_shift_z = diff.set(6) ;
00175 
00176     // Parameters for the function Map_et::adapt
00177     // -----------------------------------------
00178 
00179     Param par_adapt ;
00180     int nitermax = 100 ;
00181     int niter ;
00182     int adapt_flag = 1 ;    //  1 = performs the full computation, 
00183                 //  0 = performs only the rescaling by 
00184                 //      the factor alpha_r
00185     //##    int nz_search = nzet + 1 ;  // Number of domains for searching the enthalpy
00186     int nz_search = nzet ;  // Number of domains for searching the enthalpy
00187                 //  isosurfaces
00188 
00189     double precis_secant = 1.e-14 ;
00190     double alpha_r ;
00191     double reg_map = 1. ; // 1 = regular mapping, 0 = contracting mapping
00192 
00193     Tbl ent_limit(nz) ;
00194 
00195     par_adapt.add_int(nitermax, 0) ; // maximum number of iterations to 
00196                      // locate zeros by the secant method
00197     par_adapt.add_int(nzet, 1) ;    // number of domains where the adjustment
00198                     // to the isosurfaces of ent is to be
00199                     // performed
00200     par_adapt.add_int(nz_search, 2) ;   // number of domains to search for
00201                     // the enthalpy isosurface
00202     par_adapt.add_int(adapt_flag, 3) ; //  1 = performs the full computation, 
00203                        //  0 = performs only the rescaling by 
00204                        //      the factor alpha_r
00205     par_adapt.add_int(j_b, 4) ; //  theta index of the collocation point 
00206                     //  (theta_*, phi_*)
00207     par_adapt.add_int(k_b, 5) ; //  theta index of the collocation point 
00208                     //  (theta_*, phi_*)
00209     par_adapt.add_int_mod(niter, 0) ;  //  number of iterations actually
00210                                        //  used in the secant method
00211     par_adapt.add_double(precis_secant, 0) ; // required absolute precision in
00212                          // the determination of zeros by
00213                          // the secant method
00214     par_adapt.add_double(reg_map, 1)    ;  // 1. = regular mapping,
00215                                            // 0 = contracting mapping
00216     par_adapt.add_double(alpha_r, 2) ;      // factor by which all the radial 
00217                         // distances will be multiplied 
00218     par_adapt.add_tbl(ent_limit, 0) ;   // array of values of the field ent 
00219                         // to define the isosurfaces.
00220 
00221     // Parameters for the function Map_et::poisson_regular for logn_auto
00222     // -----------------------------------------------------------------
00223 
00224     double precis_poisson = 1.e-16 ;     
00225 
00226     Param par_poisson1 ; 
00227 
00228     par_poisson1.add_int(mermax_poisson,  0) ;  // maximum number of iterations
00229     par_poisson1.add_double(relax_poisson,  0) ; // relaxation parameter
00230     par_poisson1.add_double(precis_poisson, 1) ; // required precision
00231     par_poisson1.add_int_mod(niter, 0) ;  //  number of iterations actually
00232                                           //  used 
00233     par_poisson1.add_cmp_mod( ssjm1_logn ) ;
00234 
00235     // Parameters for the function Map_et::poisson for beta_auto
00236     // ---------------------------------------------------------
00237 
00238     Param par_poisson2 ;
00239 
00240     par_poisson2.add_int(mermax_poisson,  0) ;  // maximum number of iterations
00241     par_poisson2.add_double(relax_poisson,  0) ; // relaxation parameter
00242     par_poisson2.add_double(precis_poisson, 1) ; // required precision
00243     par_poisson2.add_int_mod(niter, 0) ;  //  number of iterations actually
00244                                           //  used 
00245     par_poisson2.add_cmp_mod( ssjm1_beta ) ;
00246 
00247     // Parameters for the function Tenseur::poisson_vect_regu
00248     // ------------------------------------------------------
00249 
00250     Param par_poisson_vect ;
00251 
00252     par_poisson_vect.add_int(mermax_poisson,  0) ;  // maximum number of
00253                                                     // iterations
00254     par_poisson_vect.add_double(relax_poisson,  0) ; // relaxation parameter
00255     par_poisson_vect.add_double(precis_poisson, 1) ; // required precision
00256     par_poisson_vect.add_cmp_mod( ssjm1_khi ) ;
00257     par_poisson_vect.add_tenseur_mod( ssjm1_wshift ) ;
00258     par_poisson_vect.add_int_mod(niter, 0) ;
00259 
00260        
00261     // External potential
00262     // ------------------
00263 
00264     Tenseur pot_ext = logn_comp + pot_centri + loggam ;
00265 //##
00266 //  des_coupe_z(pot_ext(), 0., 1, "pot_ext", &(ent()) ) ;
00267 //##
00268 
00269     Tenseur ent_jm1 = ent ; // Enthalpy at previous step
00270 
00271     Tenseur source(mp) ;    // source term in the equation for logn_auto
00272                 // and beta_auto
00273 
00274     Tenseur source_shift(mp, 1, CON, ref_triad) ;  // source term in the
00275                                                    // equation for shift_auto
00276 
00277     Cmp source_regu(mp) ;
00278     Cmp source_div(mp) ;
00279 
00280     //=========================================================================
00281     //          Start of iteration
00282     //=========================================================================
00283 
00284     for(int mer=0 ; mer<mermax ; mer++ ) {
00285 
00286     cout << "-----------------------------------------------" << endl ;
00287     cout << "step: " << mer << endl ;
00288     cout << "diff_ent = " << diff_ent << endl ;
00289 
00290     //-----------------------------------------------------
00291     // Resolution of the elliptic equation for the velocity
00292     // scalar potential
00293     //-----------------------------------------------------
00294 
00295     if (irrotational) {
00296 
00297         diff_vel_pot = velocity_potential(mermax_potvit, precis_poisson, 
00298                           relax_potvit) ; 
00299 
00300     }
00301 
00302     //-----------------------------------------------------
00303     // Computation of the new radial scale
00304     //-----------------------------------------------------
00305 
00306     // alpha_r (r = alpha_r r') is determined so that the enthalpy
00307     // takes the requested value ent_b at the stellar surface
00308 
00309     // Values at the center of the star:
00310     double logn_auto_c  = logn_auto()(0, 0, 0, 0) ; 
00311     double pot_ext_c  = pot_ext()(0, 0, 0, 0) ; 
00312 
00313     // Search for the reference point (theta_*, phi_*) [notation of
00314     //  Bonazzola, Gourgoulhon & Marck PRD 58, 104020 (1998)]
00315     //  at the surface of the star
00316     // ------------------------------------------------------------
00317     double alpha_r2 = 0 ; 
00318     for (int k=0; k<mg->get_np(l_b); k++) {
00319         for (int j=0; j<mg->get_nt(l_b); j++) {
00320         
00321         double pot_ext_b  = pot_ext()(l_b, k, j, i_b) ; 
00322         double logn_auto_b  = logn_auto()(l_b, k, j, i_b) ; 
00323 
00324         double alpha_r2_jk = ( ent_c - ent_b + pot_ext_c - pot_ext_b) / 
00325                 ( logn_auto_b - logn_auto_c ) ;
00326         
00327 //      cout << "k, j, alpha_r2_jk : " << k << "  " << j << "  " 
00328 //           << alpha_r2_jk << endl ; 
00329           
00330         if (alpha_r2_jk > alpha_r2) {
00331             alpha_r2 = alpha_r2_jk ; 
00332             k_b = k ; 
00333             j_b = j ; 
00334         }
00335 
00336         }
00337     }
00338     
00339     alpha_r = sqrt(alpha_r2) ;
00340         
00341     cout << "k_b, j_b, alpha_r: " << k_b << "  " << j_b << "  " 
00342          <<  alpha_r << endl ;
00343 
00344     // New value of logn_auto
00345     // ----------------------
00346 
00347     logn_auto = alpha_r2 * logn_auto ;
00348     logn_auto_regu = alpha_r2 * logn_auto_regu ;
00349     logn_auto_c  = logn_auto()(0, 0, 0, 0) ;
00350 
00351 
00352     //------------------------------------------------------------
00353     // Change the values of the inner points of the second domain
00354     // by those of the outer points of the first domain
00355     //------------------------------------------------------------
00356 
00357     (logn_auto().va).smooth(nzet, (logn_auto.set()).va) ;
00358 
00359 
00360     //--------------------
00361     // First integral   --> enthalpy in all space
00362     //--------------------
00363 
00364     ent = (ent_c + logn_auto_c + pot_ext_c) - logn_auto - pot_ext ;
00365 
00366     (ent().va).smooth(nzet, (ent.set()).va) ;
00367 
00368     //----------------------------------------------------
00369     // Adaptation of the mapping to the new enthalpy field
00370     //----------------------------------------------------
00371 
00372     // Shall the adaptation be performed (cusp) ?
00373     // ------------------------------------------
00374 
00375     double dent_eq = ent().dsdr().val_point(ray_eq(),M_PI/2.,0.) ;
00376     double dent_pole = ent().dsdr().val_point(ray_pole(),0.,0.) ;
00377     double rap_dent = fabs( dent_eq / dent_pole ) ;
00378     cout << "| dH/dr_eq / dH/dr_pole | = " << rap_dent << endl ;
00379 
00380     if ( rap_dent < thres_adapt ) {
00381         adapt_flag = 0 ;    // No adaptation of the mapping
00382         cout << "******* FROZEN MAPPING  *********" << endl ;
00383     }
00384     else{
00385         adapt_flag = 1 ;    // The adaptation of the mapping is to be
00386                 //  performed
00387     }
00388 
00389 
00390     ent_limit.set_etat_qcq() ;
00391     for (int l=0; l<nzet; l++) {    // loop on domains inside the star
00392         ent_limit.set(l) = ent()(l, k_b, j_b, i_b) ;
00393     }
00394     ent_limit.set(nzet-1) = ent_b  ;
00395 
00396     Map_et mp_prev = mp_et ;
00397 
00398 //##
00399 //  des_coupe_z(ent(), 0., 1, "ent before adapt", &(ent()) ) ;
00400 //##
00401 
00402     mp.adapt(ent(), par_adapt) ;
00403 
00404     // Readjustment of the external boundary of domain l=nzet
00405     // to keep a fixed ratio with respect to star's surface
00406     
00407     double rr_in_1 = mp.val_r(nzet, -1., M_PI/2., 0.) ;
00408 
00409     // Resizes the outer boundary of the shell including the comp. NS
00410     double rr_out_nm2 = mp.val_r(nz-2, 1., M_PI/2., 0.) ;
00411 
00412     mp.resize(nz-2, rr_in_1/rr_out_nm2 * fact_resize(1)) ;
00413 
00414     // Resizes the inner boundary of the shell including the comp. NS
00415     double rr_out_nm3 = mp.val_r(nz-3, 1., M_PI/2., 0.) ;
00416 
00417     mp.resize(nz-3, rr_in_1/rr_out_nm3 * fact_resize(0)) ;
00418 
00419     if (nz > nzet+3) {
00420 
00421         // Resize of the domain from 1(nzet) to N-4
00422         double rr_out_nm3_new = mp.val_r(nz-3, 1., M_PI/2., 0.) ;
00423 
00424         for (int i=nzet-1; i<nz-4; i++) {
00425 
00426             double rr_out_i = mp.val_r(i, 1., M_PI/2., 0.) ;
00427 
00428         double rr_mid = rr_out_i
00429           + (rr_out_nm3_new - rr_out_i) / double(nz - 3 - i) ;
00430 
00431         double rr_2timesi = 2. * rr_out_i ;
00432 
00433         if (rr_2timesi < rr_mid) {
00434 
00435             double rr_out_ip1 = mp.val_r(i+1, 1., M_PI/2., 0.) ;
00436 
00437             mp.resize(i+1, rr_2timesi / rr_out_ip1) ;
00438 
00439         }
00440         else {
00441 
00442             double rr_out_ip1 = mp.val_r(i+1, 1., M_PI/2., 0.) ;
00443 
00444             mp.resize(i+1, rr_mid / rr_out_ip1) ;
00445 
00446         }  // End of else
00447 
00448         }  // End of i loop
00449 
00450     }  // End of (nz > nzet+3) loop
00451 
00452 //##
00453 //  des_coupe_z(ent(), 0., 1, "ent after adapt", &(ent()) ) ;
00454 //##
00455     //----------------------------------------------------
00456     // Computation of the enthalpy at the new grid points
00457     //----------------------------------------------------
00458 
00459     mp_prev.homothetie(alpha_r) ;
00460 
00461     mp.reevaluate_symy(&mp_prev, nzet+1, ent.set()) ;
00462 
00463 //  des_coupe_z(ent(), 0., 1, "ent after reevaluate", &(ent()) ) ;
00464 
00465     double ent_s_max = -1 ; 
00466     int k_s_max = -1 ; 
00467     int j_s_max = -1 ; 
00468     for (int k=0; k<mg->get_np(l_b); k++) {
00469         for (int j=0; j<mg->get_nt(l_b); j++) {
00470         double xx = fabs( ent()(l_b, k, j, i_b) ) ;
00471         if (xx > ent_s_max) {
00472             ent_s_max = xx ; 
00473             k_s_max = k ; 
00474             j_s_max = j ; 
00475         }
00476         }
00477     }
00478     cout << "Max. abs(enthalpy) at the boundary between domains nzet-1"
00479          << " and nzet : " << endl ; 
00480     cout << "   " << ent_s_max << " reached for k = " << k_s_max <<
00481         " and j = " << j_s_max << endl ; 
00482 
00483     //----------------------------------------------------
00484     // Equation of state
00485     //----------------------------------------------------
00486 
00487     equation_of_state() ;   // computes new values for nbar (n), ener (e)
00488                 // and press (p) from the new ent (H)
00489 
00490     //---------------------------------------------------------
00491     // Matter source terms in the gravitational field equations
00492     //---------------------------------------------------------
00493 
00494     hydro_euler() ;     // computes new values for ener_euler (E),
00495                 // s_euler (S) and u_euler (U^i)
00496 
00497     //--------------------------------------------------------
00498     // Poisson equation for logn_auto (nu_auto)
00499     //--------------------------------------------------------
00500 
00501     // Source
00502     // ------
00503 
00504     double unsgam1 ;    // effective power of H in the source 
00505                 // close to the surface
00506 
00507     if (relativistic) {
00508         source = qpig * a_car % (ener_euler + s_euler)
00509             + akcar_auto + akcar_comp
00510             - flat_scalar_prod_desal(d_logn_auto,
00511                        d_beta_auto + d_beta_comp) ;
00512                        
00513         // 1/(gam-1) = dln(e)/dln(H) close to the surface : 
00514         unsgam1 = eos.der_ener_ent_p(ent_b + 1e-10*(ent_c-ent_b)) ; 
00515     
00516     }
00517     else {
00518         source = qpig * nbar ;
00519         
00520         // 1/(gam-1) = dln(n)/dln(H) close to the surface : 
00521         unsgam1 = eos.der_nbar_ent_p(ent_b + 1e-10*(ent_c-ent_b)) ; 
00522     }
00523 
00524     source.set_std_base() ;
00525 
00526     // Resolution of the Poisson equation
00527     // ----------------------------------
00528 
00529     logn_auto_regu.set_etat_qcq() ;
00530     logn_auto_div.set_etat_qcq() ;
00531     d_logn_auto_div.set_etat_qcq() ;
00532 
00533     source_regu.std_base_scal() ;
00534     source_div.std_base_scal() ;
00535 
00536     source().poisson_regular(k_div, nzet, unsgam1, par_poisson1,
00537                  logn_auto.set(), logn_auto_regu.set(),
00538                  logn_auto_div.set(),
00539                  d_logn_auto_div,
00540                  source_regu, source_div) ;
00541 
00542     // Check: has the Poisson equation been correctly solved ?
00543     // -----------------------------------------------------
00544 
00545     Tbl tdiff_logn = diffrel(logn_auto().laplacien(), source()) ;
00546     cout <<
00547     "Relative error in the resolution of the equation for logn_auto : "
00548     << endl ;
00549     for (int l=0; l<nz; l++) {
00550         cout << tdiff_logn(l) << "  " ;
00551     }
00552     cout << endl ;
00553     diff_logn = max(abs(tdiff_logn)) ;
00554 
00555 
00556     if (relativistic) {
00557 
00558         //--------------------------------------------------------
00559         // Poisson equation for beta_auto
00560         //--------------------------------------------------------
00561 
00562         // Source
00563         // ------
00564 
00565         source = qpig * a_car % s_euler
00566             + .75 * ( akcar_auto + akcar_comp )
00567             - .5 * flat_scalar_prod_desal(d_logn_auto,
00568                         d_logn_auto + d_logn_comp)
00569             - .5 * flat_scalar_prod_desal(d_beta_auto,
00570                         d_beta_auto + d_beta_comp) ;
00571 
00572         source.set_std_base() ;
00573 
00574         // Resolution of the Poisson equation
00575         // ----------------------------------
00576 
00577         source().poisson(par_poisson2, beta_auto.set()) ;
00578 
00579 
00580         // Check: has the Poisson equation been correctly solved ?
00581         // -----------------------------------------------------
00582 
00583         Tbl tdiff_beta = diffrel(beta_auto().laplacien(), source()) ;
00584         cout <<
00585         "Relative error in the resolution of the equation for beta_auto : "
00586         << endl ;
00587         for (int l=0; l<nz; l++) {
00588         cout << tdiff_beta(l) << "  " ;
00589         }
00590         cout << endl ;
00591         diff_beta = max(abs(tdiff_beta)) ;
00592 
00593         //--------------------------------------------------------
00594         // Vector Poisson equation for shift_auto
00595         //--------------------------------------------------------
00596 
00597         // Source
00598         // ------
00599 
00600         Tenseur vtmp =  6. * ( d_beta_auto + d_beta_comp )
00601                -8. * ( d_logn_auto + d_logn_comp ) ;
00602 
00603         source_shift = (-4.*qpig) * nnn % a_car % (ener_euler + press)
00604                             % u_euler
00605                + nnn % flat_scalar_prod_desal(tkij_auto, vtmp) ;
00606 
00607         source_shift.set_std_base() ;
00608 
00609         // Resolution of the Poisson equation
00610         // ----------------------------------
00611 
00612         // Filter for the source of shift vector
00613 
00614         for (int i=0; i<3; i++) {
00615 
00616           if (source_shift(i).get_etat() != ETATZERO)
00617         source_shift.set(i).filtre(4) ;
00618 
00619         }
00620 
00621         // For Tenseur::poisson_vect_regu,
00622         // the triad must be the mapping triad,
00623         // not the reference one:
00624 
00625         source_shift.change_triad( mp.get_bvect_cart() ) ;
00626 
00627         for (int i=0; i<3; i++) {
00628         if(source_shift(i).dz_nonzero()) {
00629             assert( source_shift(i).get_dzpuis() == 4 ) ;
00630         }
00631         else{
00632             (source_shift.set(i)).set_dzpuis(4) ;
00633         }
00634         }
00635 
00636         //##
00637         // source_shift.dec2_dzpuis() ;    // dzpuis 4 -> 2
00638 
00639         double lambda_shift = double(1) / double(3) ;
00640 
00641         source_shift.poisson_vect_regu(k_div, nzet, unsgam1,
00642                        lambda_shift, par_poisson_vect,
00643                        shift_auto, w_shift, khi_shift) ;  
00644 
00645 
00646         // Check: has the equation for shift_auto been correctly solved ?
00647         // --------------------------------------------------------------
00648 
00649         // Divergence of shift_auto :
00650         Tenseur divn = contract(shift_auto.gradient(), 0, 1) ;
00651         divn.dec2_dzpuis() ;    // dzpuis 2 -> 0
00652 
00653         // Grad(div) :
00654         Tenseur graddivn = divn.gradient() ;
00655         graddivn.inc2_dzpuis() ;    // dzpuis 2 -> 4
00656 
00657         // Full operator :
00658         Tenseur lap_shift(mp, 1, CON, mp.get_bvect_cart() ) ;
00659         lap_shift.set_etat_qcq() ;
00660         for (int i=0; i<3; i++) {
00661         lap_shift.set(i) = shift_auto(i).laplacien()
00662                     + lambda_shift * graddivn(i) ;
00663         }
00664 
00665         Tbl tdiff_shift_x = diffrel(lap_shift(0), source_shift(0)) ;
00666         Tbl tdiff_shift_y = diffrel(lap_shift(1), source_shift(1)) ;
00667         Tbl tdiff_shift_z = diffrel(lap_shift(2), source_shift(2)) ;
00668 
00669         cout <<
00670           "Relative error in the resolution of the equation "
00671           "for shift_auto : "
00672          << endl ;
00673         cout << "x component : " ;
00674         for (int l=0; l<nz; l++) {
00675         cout << tdiff_shift_x(l) << "  " ;
00676         }
00677         cout << endl ;
00678         cout << "y component : " ;
00679         for (int l=0; l<nz; l++) {
00680         cout << tdiff_shift_y(l) << "  " ;
00681         }
00682         cout << endl ;
00683         cout << "z component : " ;
00684         for (int l=0; l<nz; l++) {
00685         cout << tdiff_shift_z(l) << "  " ;
00686         }
00687         cout << endl ;
00688 
00689         diff_shift_x = max(abs(tdiff_shift_x)) ;
00690         diff_shift_y = max(abs(tdiff_shift_y)) ;
00691         diff_shift_z = max(abs(tdiff_shift_z)) ;
00692 
00693         // Final result
00694         // ------------
00695         // The output of Tenseur::poisson_vect is on the mapping triad,
00696         // it should therefore be transformed to components on the
00697         // reference triad :
00698 
00699         shift_auto.change_triad( ref_triad ) ;
00700 
00701 
00702     }   // End of relativistic equations
00703 
00704 
00705     //-------------------------------------------------
00706     //  Relative change in enthalpy
00707     //-------------------------------------------------
00708 
00709     Tbl diff_ent_tbl = diffrel( ent(), ent_jm1() ) ;
00710     diff_ent = diff_ent_tbl(0) ;
00711     for (int l=1; l<nzet; l++) {
00712         diff_ent += diff_ent_tbl(l) ;
00713     }
00714     diff_ent /= nzet ;
00715 
00716     ent_jm1 = ent ;
00717 
00718 
00719     } // End of main loop
00720     
00721     //=========================================================================
00722     //          End of iteration
00723     //=========================================================================
00724 
00725 
00726 }

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