sym_tensor_decomp.C

00001 /*
00002  *  Methods transverse( ) and longit_pot( ) of class Sym_tensor
00003  *
00004  *    (see file sym_tensor.h for documentation).
00005  *
00006  */
00007 
00008 /*
00009  *   Copyright (c) 2003-2004  Eric Gourgoulhon & 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_decomp_C[] = "$Header: /cvsroot/Lorene/C++/Source/Tensor/sym_tensor_decomp.C,v 1.13 2008/12/05 08:45:12 j_novak Exp $" ;
00029 
00030 /*
00031  * $Id: sym_tensor_decomp.C,v 1.13 2008/12/05 08:45:12 j_novak Exp $
00032  * $Log: sym_tensor_decomp.C,v $
00033  * Revision 1.13  2008/12/05 08:45:12  j_novak
00034  * Modified dzpuis treatment.
00035  *
00036  * Revision 1.12  2008/12/03 10:20:00  j_novak
00037  * Modified output.
00038  *
00039  * Revision 1.11  2004/06/17 06:56:42  e_gourgoulhon
00040  * Simplified code for method transverse (use of Vector::ope_killing).
00041  * Slight modif. of output in method longit_pot.
00042  *
00043  * Revision 1.10  2004/06/14 20:45:41  e_gourgoulhon
00044  * Added argument method_poisson to methods longit_pot and transverse.
00045  *
00046  * Revision 1.9  2004/05/25 15:05:57  f_limousin
00047  * Add parameters in argument of the functions transverse, longit_pot
00048  * for the case of Map_et.
00049  *
00050  * Revision 1.8  2004/03/30 14:01:19  j_novak
00051  * Copy constructors and operator= now copy the "derived" members.
00052  *
00053  * Revision 1.7  2004/03/30 08:01:16  j_novak
00054  * Better treatment of dzpuis in mutators.
00055  *
00056  * Revision 1.6  2004/03/29 16:13:07  j_novak
00057  * New methods set_longit_trans and set_tt_trace .
00058  *
00059  * Revision 1.5  2004/02/09 12:56:27  e_gourgoulhon
00060  * Method longit_pot: added test of the vector Poisson equation.
00061  *
00062  * Revision 1.4  2004/02/02 09:18:11  e_gourgoulhon
00063  * Method longit_pot: treatment of case divergence dzpuis = 5.
00064  *
00065  * Revision 1.3  2003/12/10 10:17:54  e_gourgoulhon
00066  * First operational version.
00067  *
00068  * Revision 1.2  2003/11/27 16:01:47  e_gourgoulhon
00069  * First implmentation.
00070  *
00071  * Revision 1.1  2003/11/26 21:57:03  e_gourgoulhon
00072  * First version; not ready yet.
00073  *
00074  *
00075  * $Header: /cvsroot/Lorene/C++/Source/Tensor/sym_tensor_decomp.C,v 1.13 2008/12/05 08:45:12 j_novak Exp $
00076  *
00077  */
00078 
00079 
00080 // Lorene headers
00081 #include "metric.h"
00082 #include "param.h"
00083 
00084 void Sym_tensor::set_longit_trans(const Vector& v_pot, 
00085                   const Sym_tensor_trans& ht ) {
00086 
00087   assert ( v_pot.get_index_type(0) == CON ) ;
00088 
00089   const Metric& metre = ht.get_met_div() ;
00090 
00091   *this = ht + v_pot.ope_killing(metre) ; // this has dzpuis = 2, if v_pot not 0
00092   if ((*this)(1,1).get_dzpuis() == 2) 
00093       dec_dzpuis(2) ; // which is decreased so to add *this to a flat metric
00094 
00095   del_deriv() ;
00096 
00097   set_dependance(metre) ;
00098   int jp = get_place_met(metre) ;
00099   assert ((jp>=0) && (jp<N_MET_MAX)) ;
00100 
00101   p_transverse[jp] = new Sym_tensor_trans(ht) ;
00102   p_longit_pot[jp] = new Vector( v_pot ) ;
00103   
00104 }
00105 
00106 const Sym_tensor_trans& Sym_tensor::transverse(const Metric& metre, Param* par,
00107             int method_poisson) const {
00108 
00109     set_dependance(metre) ;
00110     int jp = get_place_met(metre) ;
00111     assert ((jp>=0) && (jp<N_MET_MAX)) ;
00112 
00113     if (p_transverse[jp] == 0x0) { // a new computation is necessary
00114 
00115         assert( (type_indice(0) == CON) && (type_indice(1) == CON) ) ; 
00116 
00117         for (int ic=0; ic<n_comp; ic++) {
00118             assert(cmp[ic]->check_dzpuis(4)) ;  // dzpuis=4 is assumed
00119         }
00120 
00121         const Vector& ww = longit_pot(metre, par, method_poisson) ;     
00122 
00123         Sym_tensor lww = ww.ope_killing(metre) ;  // D^i W^j + D^j W^i        
00124         
00125         lww.inc_dzpuis(2) ;                     
00126         
00127         p_transverse[jp] = new Sym_tensor_trans(*mp, *triad, metre) ;
00128         
00129         *(p_transverse[jp]) = *this - lww ; 
00130 
00131     }
00132 
00133     return *p_transverse[jp] ;
00134     
00135 
00136 }
00137 
00138 
00139 const Vector& Sym_tensor::longit_pot(const Metric& metre, Param* par,
00140     int method_poisson) const {
00141 
00142     set_dependance(metre) ;
00143     int jp = get_place_met(metre) ;
00144     assert ((jp>=0) && (jp<N_MET_MAX)) ;
00145 
00146     if (p_longit_pot[jp] == 0x0) {  // a new computation is necessary
00147         
00148         const Metric_flat* metf = dynamic_cast<const Metric_flat*>(&metre) ; 
00149         if (metf == 0x0) {
00150             cout << "Sym_tensor::longit_pot : the case of a non flat metric"
00151              << endl <<"  is not treated yet !" << endl ; 
00152             abort() ; 
00153         }
00154         
00155         Vector hhh = divergence(metre) ; 
00156 
00157 
00158         // If dpzuis is 5, it should be decreased to 4 for the Poisson equation:
00159         bool dzp5 = false ; 
00160         for (int i=1; i<=3; i++) {
00161             dzp5 = dzp5 || hhh(i).check_dzpuis(5) ;
00162         }
00163         if (dzp5) hhh.dec_dzpuis() ; 
00164                 
00165     if (dynamic_cast<const Map_af*>(mp) != 0x0) 
00166         p_longit_pot[jp] = new Vector( hhh.poisson(double(1), 
00167                                                        method_poisson) ) ; 
00168         else
00169         p_longit_pot[jp] = new Vector( hhh.poisson(double(1), *par, 
00170                                                        method_poisson) ) ; 
00171 
00172 
00173         // Test of resolution of the vector Poisson equation:
00174         const Vector& ww = *(p_longit_pot[jp]) ; 
00175 
00176         hhh.dec_dzpuis() ; 
00177 
00178         Vector lapw = ww.derive_con(metre).divergence(metre) 
00179                         + (ww.divergence(metre)).derive_con(metre) ;
00180 #ifndef NDEBUG
00181         cout << "## Sym_tensor::longit_pot : test of Poisson : \n" ;
00182         cout << 
00183         "  Max absolute error in each domain on the vector Poisson equation:\n" ;   
00184         maxabs(lapw - hhh) ; 
00185 
00186     int nz = mp->get_mg()->get_nzone() ;        // total number of domains
00187         
00188     cout << "  Relative error in each domain on the vector Poisson equation:\n" ;
00189     for (int i=1; i<=3; i++){
00190         cout << "   Comp. " << i << " :  " ;
00191         for (int l=0; l<nz; l++){
00192         cout << diffrel(lapw(i),hhh(i) )(l) << " " ;
00193         }
00194         cout << endl ;
00195     }
00196     cout << endl ;
00197 #endif
00198     }
00199 
00200     return *p_longit_pot[jp] ;
00201     
00202 
00203 }
00204 
00205 

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