sym_tensor_trans_aux.C

00001 /*
00002  *  Manipulation of auxiliary potentials for Sym_tensor_trans objects.
00003  *
00004  *    (see file sym_tensor.h for documentation).
00005  *
00006  */
00007 
00008 /*
00009  *   Copyright (c) 2005-2006  Jerome Novak
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 version 2
00015  *   as published by the Free Software Foundation.
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 char sym_tensor_trans_aux_C[] = "$Header: /cvsroot/Lorene/C++/Source/Tensor/sym_tensor_trans_aux.C,v 1.19 2010/10/11 10:23:03 j_novak Exp $" ;
00029 
00030 /*
00031  * $Id: sym_tensor_trans_aux.C,v 1.19 2010/10/11 10:23:03 j_novak Exp $
00032  * $Log: sym_tensor_trans_aux.C,v $
00033  * Revision 1.19  2010/10/11 10:23:03  j_novak
00034  * Removed methods Sym_tensor_trans::solve_hrr() and Sym_tensor_trans::set_WX_det_one(), as they are no longer relevant.
00035  *
00036  * Revision 1.18  2008/12/05 08:46:19  j_novak
00037  * New method Sym_tensor_trans_aux::set_tt_part_det_one.
00038  *
00039  * Revision 1.17  2007/04/27 13:52:55  j_novak
00040  * In method Sym_tensor_trans::set_AtBtt_det_one(), the member p_tt (the TT-part)
00041  * is updated.
00042  *
00043  * Revision 1.16  2007/03/20 12:20:56  j_novak
00044  * In Sym_tensor_trans::set_AtBtt_det_one(), the trace is stored in the resulting
00045  * object.
00046  *
00047  * Revision 1.15  2006/10/24 13:03:19  j_novak
00048  * New methods for the solution of the tensor wave equation. Perhaps, first
00049  * operational version...
00050  *
00051  * Revision 1.14  2006/09/15 08:48:01  j_novak
00052  * Suppression of some messages in the optimized version.
00053  *
00054  * Revision 1.13  2006/08/31 12:13:22  j_novak
00055  * Added an argument of type Param to Sym_tensor_trans::sol_Dirac_A().
00056  *
00057  * Revision 1.12  2006/06/26 09:28:13  j_novak
00058  * Added a forgotten initialisation in set_AtB_trace_zero().
00059  *
00060  * Revision 1.11  2006/06/20 12:07:15  j_novak
00061  * Improved execution speed for sol_Dirac_tildeB...
00062  *
00063  * Revision 1.10  2006/06/14 10:04:21  j_novak
00064  * New methods sol_Dirac_l01, set_AtB_det_one and set_AtB_trace_zero.
00065  *
00066  * Revision 1.9  2006/01/17 15:50:53  j_novak
00067  * Slight re-arrangment of the det=1 formula.
00068  *
00069  * Revision 1.8  2005/11/28 14:45:17  j_novak
00070  * Improved solution of the Poisson tensor equation in the case of a transverse
00071  * tensor.
00072  *
00073  * Revision 1.7  2005/09/16 13:34:44  j_novak
00074  * Back to dzpuis 1 for the source for mu. eta is computed the same way as hrr.
00075  *
00076  * Revision 1.6  2005/09/08 16:00:23  j_novak
00077  * Change of dzpuis for source for mu (temporary?).
00078  *
00079  * Revision 1.5  2005/09/07 16:47:43  j_novak
00080  * Removed method Sym_tensor_trans::T_from_det_one
00081  * Modified Sym_tensor::set_auxiliary, so that it takes eta/r and mu/r as
00082  * arguments.
00083  * Modified Sym_tensor_trans::set_hrr_mu.
00084  * Added new protected method Sym_tensor_trans::solve_hrr
00085  *
00086  * Revision 1.4  2005/04/08 08:22:04  j_novak
00087  * New methods set_hrr_mu_det_one() and set_WX_det_one(). Not tested yet...
00088  *
00089  * Revision 1.3  2005/04/07 07:56:22  j_novak
00090  * Better handling of dzpuis (first try).
00091  *
00092  * Revision 1.2  2005/04/06 15:49:46  j_novak
00093  * Error corrected.
00094  *
00095  * Revision 1.1  2005/04/06 15:43:59  j_novak
00096  * New method Sym_tensor_trans::T_from_det_one(...).
00097  *
00098  *
00099  * $Header: /cvsroot/Lorene/C++/Source/Tensor/sym_tensor_trans_aux.C,v 1.19 2010/10/11 10:23:03 j_novak Exp $
00100  *
00101  */
00102 
00103 // C headers
00104 #include <assert.h>
00105 
00106 // Lorene headers
00107 #include "metric.h"
00108 #include "param.h"
00109 
00110 void Sym_tensor_trans::set_hrr_mu_det_one(const Scalar& hrr, const Scalar& mu_in,
00111                       double precis, int it_max ) {
00112 
00113     // All this has a meaning only for spherical components:
00114     assert(dynamic_cast<const Base_vect_spher*>(triad) != 0x0) ; 
00115     assert(hrr.check_dzpuis(0)) ;
00116     assert(mu_in.check_dzpuis(0)) ;
00117     assert(&mu_in != p_mu) ;
00118     assert( (precis > 0.) && (it_max > 0) ) ;
00119 
00120     Sym_tensor_tt tens_tt(*mp, *triad, *met_div) ;
00121     tens_tt.set_rr_mu(hrr, mu_in) ;
00122     tens_tt.inc_dzpuis(2) ;
00123     trace_from_det_one(tens_tt, precis, it_max) ;
00124     dec_dzpuis(2) ;
00125 
00126     return ;
00127 
00128 }
00129 
00130 void Sym_tensor_trans::set_AtBtt_det_one(const Scalar& a_in, const Scalar& tbtt_in,
00131                      const Scalar* h_prev, Param* par_bc, 
00132                      Param* par_mat, double precis, 
00133                      int it_max ) {
00134     // All this has a meaning only for spherical components:
00135     assert(dynamic_cast<const Base_vect_spher*>(triad) != 0x0) ; 
00136     assert(a_in.check_dzpuis(2)) ;
00137     assert(tbtt_in.check_dzpuis(2)) ;
00138     assert(&a_in != p_aaa) ;
00139     assert(&tbtt_in != p_tilde_b) ;
00140     assert( (precis > 0.) && (it_max > 0) ) ;
00141 
00142     //Computation of mu and X from A
00143     //-------------------------------
00144     Scalar mu_over_r(*mp) ;
00145     Scalar x_new(*mp) ;
00146     sol_Dirac_A(a_in, mu_over_r, x_new, par_bc) ;
00147 
00148     // Preparation for the iteration
00149     //------------------------------
00150     Scalar h_old(*mp) ;
00151     if (h_prev != 0x0) 
00152     h_old = *h_prev ;
00153     else 
00154     h_old.set_etat_zero() ;
00155     double lambda = 1. ;
00156     Scalar zero(*mp) ;
00157     zero.set_etat_zero() ;
00158 
00159     Scalar hrr_tt(*mp) ;
00160     Scalar eta_sr_tt(*mp) ;
00161     Scalar w_tt(*mp) ;
00162     sol_Dirac_tilde_B(tbtt_in, zero, hrr_tt, eta_sr_tt, w_tt, par_bc, par_mat) ;
00163     Sym_tensor_tt hijtt(*mp, *triad, *met_div) ;
00164     hijtt.set_auxiliary(hrr_tt, eta_sr_tt, mu_over_r, w_tt, x_new, zero) ;
00165 
00166     Scalar hrr_new(*mp) ;
00167     Scalar eta_over_r(*mp) ;
00168     Scalar w_new(*mp) ;
00169 
00170     for (int it=0; it<=it_max; it++) {
00171     Scalar tilde_B = get_tilde_B_from_TT_trace(zero, h_old) ;
00172     sol_Dirac_tilde_B(tilde_B, h_old, hrr_new, eta_over_r, w_new, 0x0, par_mat) ;
00173     
00174     set_auxiliary(hrr_new+hrr_tt, eta_over_r+eta_sr_tt, mu_over_r, 
00175               w_new+w_tt, x_new, h_old - hrr_new-hrr_tt) ;
00176 
00177     const Sym_tensor_trans& hij = *this ;
00178     Scalar h_new = (1 + hij(1,1))*( hij(2,3)*hij(2,3) - hij(2,2)*hij(3,3) )
00179         + hij(1,2)*hij(1,2)*(1 + hij(3,3)) 
00180         + hij(1,3)*hij(1,3)*(1 + hij(2,2)) 
00181         - hij(1,1)*(hij(2,2) + hij(3,3)) - 2*hij(1,2)*hij(1,3)*hij(2,3) ;
00182     h_new.set_spectral_base(hrr_tt.get_spectral_base()) ;
00183 
00184     double diff = max(max(abs(h_new - h_old))) ;
00185 #ifndef NDEBUG
00186         cout << "Sym_tensor_trans::set_AtB_det_one : " 
00187          << "iteration : " << it << " convergence on h: " 
00188          << diff << endl ; 
00189 #endif
00190         if (diff < precis) {
00191         set_auxiliary(hrr_new+hrr_tt, eta_over_r+eta_sr_tt, mu_over_r, 
00192               w_new+w_tt, x_new, h_old - hrr_new-hrr_tt) ;
00193         if (p_aaa != 0x0) delete p_aaa ;
00194         p_aaa = new Scalar(a_in) ;
00195         if (p_tilde_b != 0x0) delete p_tilde_b ;
00196         p_tilde_b = new Scalar(tilde_B + tbtt_in) ;
00197         if (p_trace != 0x0) delete p_trace ;
00198         p_trace = new Scalar(h_old) ;
00199         if (p_tt != 0x0) delete p_tt ;
00200         p_tt = new Sym_tensor_tt(hijtt) ;
00201         p_tt->inc_dzpuis(2) ;
00202         break ;
00203     }
00204         else {
00205         h_old = lambda*h_new +(1-lambda)*h_old ;
00206     }
00207 
00208         if (it == it_max) {
00209             cout << "Sym_tensor_trans:::set_AtBtt_det_one : convergence not reached \n" ;
00210             cout << "  for the required accuracy (" << precis << ") ! " 
00211          << endl ;
00212             abort() ;
00213     }
00214     }
00215     return ;
00216 
00217 }
00218 
00219 void Sym_tensor_trans::set_tt_part_det_one(const Sym_tensor_tt& hijtt, const 
00220                        Scalar* h_prev, Param* par_mat, 
00221                        double precis, int it_max ) {
00222     // All this has a meaning only for spherical components:
00223     assert(dynamic_cast<const Base_vect_spher*>(triad) != 0x0) ; 
00224     assert( (precis > 0.) && (it_max > 0) ) ;
00225 
00226     Scalar mu_over_r = hijtt.mu() ;
00227     mu_over_r.div_r() ;
00228     const Scalar& x_new = hijtt.xxx() ;
00229 
00230     // Preparation for the iteration
00231     //------------------------------
00232     Scalar h_old(*mp) ;
00233     if (h_prev != 0x0) 
00234     h_old = *h_prev ;
00235     else 
00236     h_old.set_etat_zero() ;
00237     double lambda = 1. ;
00238     Scalar zero(*mp) ;
00239     zero.set_etat_zero() ;
00240 
00241     const Scalar& hrr_tt = hijtt( 1, 1 ) ;
00242     Scalar eta_sr_tt = hijtt.eta() ;
00243     eta_sr_tt.div_r() ;
00244     const Scalar w_tt = hijtt.www() ;
00245 
00246     Scalar hrr_new(*mp) ;
00247     Scalar eta_over_r(*mp) ;
00248     Scalar w_new(*mp) ;
00249 
00250     for (int it=0; it<=it_max; it++) {
00251     Scalar tilde_B = get_tilde_B_from_TT_trace(zero, h_old) ;
00252     sol_Dirac_tilde_B(tilde_B, h_old, hrr_new, eta_over_r, w_new, 0x0, par_mat) ;
00253     
00254     set_auxiliary(hrr_new+hrr_tt, eta_over_r+eta_sr_tt, mu_over_r, 
00255               w_new+w_tt, x_new, h_old - hrr_new-hrr_tt) ;
00256 
00257     const Sym_tensor_trans& hij = *this ;
00258     Scalar h_new = (1 + hij(1,1))*( hij(2,3)*hij(2,3) - hij(2,2)*hij(3,3) )
00259         + hij(1,2)*hij(1,2)*(1 + hij(3,3)) 
00260         + hij(1,3)*hij(1,3)*(1 + hij(2,2)) 
00261         - hij(1,1)*(hij(2,2) + hij(3,3)) - 2*hij(1,2)*hij(1,3)*hij(2,3) ;
00262     h_new.set_spectral_base(hrr_tt.get_spectral_base()) ;
00263 
00264     double diff = max(max(abs(h_new - h_old))) ;
00265 #ifndef NDEBUG
00266         cout << "Sym_tensor_trans::set_tt_part_det_one : " 
00267          << "iteration : " << it << " convergence on h: " 
00268          << diff << endl ; 
00269 #endif
00270         if (diff < precis) {
00271         set_auxiliary(hrr_new+hrr_tt, eta_over_r+eta_sr_tt, mu_over_r, 
00272               w_new+w_tt, x_new, h_old - hrr_new-hrr_tt) ;
00273         if (p_trace != 0x0) delete p_trace ;
00274         p_trace = new Scalar(h_old) ;
00275         if (p_tt != 0x0) delete p_tt ;
00276         p_tt = new Sym_tensor_tt(hijtt) ;
00277         p_tt->inc_dzpuis(2) ;
00278         break ;
00279     }
00280         else {
00281         h_old = lambda*h_new +(1-lambda)*h_old ;
00282     }
00283 
00284         if (it == it_max) {
00285             cout << "Sym_tensor_trans:::set_AtBtt_det_one : convergence not reached \n" ;
00286             cout << "  for the required accuracy (" << precis << ") ! " 
00287          << endl ;
00288             abort() ;
00289     }
00290     }
00291     return ;
00292 
00293 }
00294 
00295 void Sym_tensor_trans::set_AtB_trace(const Scalar& a_in, const Scalar& tb_in,
00296                      const Scalar& hh, Param* par_bc, Param* par_mat) {
00297 
00298     // All this has a meaning only for spherical components:
00299     assert(dynamic_cast<const Base_vect_spher*>(triad) != 0x0) ; 
00300     assert(a_in.check_dzpuis(2)) ;
00301     assert(tb_in.check_dzpuis(2)) ;
00302     assert(hh.check_dzpuis(0)) ;
00303     assert(&a_in != p_aaa) ;
00304     assert(&tb_in != p_tilde_b) ;
00305 
00306     //Computation of mu and X from A
00307     //-------------------------------
00308     Scalar mu_over_r(*mp) ;
00309     Scalar x_new(*mp) ;
00310     sol_Dirac_A(a_in, mu_over_r, x_new, par_bc) ;
00311 
00312     // Computation of the other potentials
00313     //------------------------------------
00314     Scalar hrr_new(*mp) ;
00315     Scalar eta_over_r(*mp) ;
00316     Scalar w_new(*mp) ;
00317 
00318     sol_Dirac_tilde_B(tb_in, hh, hrr_new, eta_over_r, w_new, par_bc, par_mat) ;
00319 
00320     set_auxiliary(hrr_new, eta_over_r, mu_over_r, w_new, x_new, hh - hrr_new) ;
00321     if (p_aaa != 0x0) delete p_aaa ;
00322     p_aaa = new Scalar(a_in) ;
00323     if (p_tilde_b != 0x0) delete p_tilde_b ;
00324     p_tilde_b = new Scalar(tb_in) ;
00325 
00326     return ;
00327 
00328 }

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