scalar_r_manip.C

00001 /*
00002  *  Member functions of the class Scalar for various r manipulations
00003  *
00004  *    See file scalar.h for documentation. 
00005  */
00006 
00007 /*
00008  *   Copyright (c) 2003-2004 Eric Gourgoulhon & Jerome Novak
00009  *
00010  *   Copyright (c) 1999-2001 Eric Gourgoulhon  (for a preceding Cmp version)
00011  *   Copyright (c) 1999-2001 Philippe Grandclement  (for a preceding Cmp version)
00012  *   Copyright (c) 2001 Jerome Novak (for a preceding Cmp version)
00013  *
00014  *   This file is part of LORENE.
00015  *
00016  *   LORENE is free software; you can redistribute it and/or modify
00017  *   it under the terms of the GNU General Public License as published by
00018  *   the Free Software Foundation; either version 2 of the License, or
00019  *   (at your option) any later version.
00020  *
00021  *   LORENE is distributed in the hope that it will be useful,
00022  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024  *   GNU General Public License for more details.
00025  *
00026  *   You should have received a copy of the GNU General Public License
00027  *   along with LORENE; if not, write to the Free Software
00028  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00029  *
00030  */
00031 
00032 
00033 char scalar_r_manip_C[] = "$Header: /cvsroot/Lorene/C++/Source/Tensor/Scalar/scalar_r_manip.C,v 1.22 2005/05/25 16:11:05 j_novak Exp $" ;
00034 
00035 /*
00036  * $Id: scalar_r_manip.C,v 1.22 2005/05/25 16:11:05 j_novak Exp $
00037  * $Log: scalar_r_manip.C,v $
00038  * Revision 1.22  2005/05/25 16:11:05  j_novak
00039  * Better handling of the case with no compactified domain.
00040  *
00041  * Revision 1.21  2005/05/18 11:45:46  j_novak
00042  * Added del_deriv() calls at the end of inc/dec_dzpuis.
00043  *
00044  * Revision 1.20  2004/10/11 15:09:04  j_novak
00045  * The radial manipulation functions take Scalar as arguments, instead of Cmp.
00046  * Added a conversion operator from Scalar to Cmp.
00047  * The Cmp radial manipulation function make conversion to Scalar, call to the
00048  * Map_radial version with a Scalar argument and back.
00049  *
00050  * Revision 1.19  2004/10/08 13:34:37  j_novak
00051  * Scalar::div_r() does not need to pass through Cmp version anymore.
00052  *
00053  * Revision 1.18  2004/05/12 14:22:12  f_limousin
00054  * Treated the case ETATZERO in dec_dzpuis and inc_dzpuis (-> return).
00055  *
00056  * Revision 1.17  2004/01/29 09:31:44  j_novak
00057  * Better treatment of ETATUN
00058  *
00059  * Revision 1.16  2004/01/28 10:34:27  j_novak
00060  * Corrected some errors.
00061  *
00062  * Revision 1.15  2004/01/27 15:10:02  j_novak
00063  * New methods Scalar::div_r_dzpuis(int) and Scalar_mult_r_dzpuis(int)
00064  * which replace div_r_inc*. Tried to clean the dzpuis handling.
00065  * WARNING: no testing at this point!!
00066  *
00067  * Revision 1.14  2004/01/22 16:11:30  e_gourgoulhon
00068  * Added (provisory method) div_r_inc1().
00069  * Case inc = 3 treated in inc_dzpuis.
00070  *
00071  * Revision 1.13  2003/11/04 23:02:21  e_gourgoulhon
00072  * -- Method dec_dzpuis(int decrem) : the case decrem = 1 is now treated.
00073  * -- Method div_tant() is now defined in file scalar_th_manip.C.
00074  *
00075  * Revision 1.12  2003/11/03 22:36:37  e_gourgoulhon
00076  *  Method dec_dzpuis: changed the name of argument dec --> decrem
00077  *  (in order not to shadow some globally defined dec).
00078  *
00079  * Revision 1.11  2003/11/03 10:25:05  e_gourgoulhon
00080  * Scalar::dec_dzpuis(int dec)  : treated the case dec = 0
00081  * Scalar::inc_dzpuis(int inc)  : treated the case inc = 0
00082  *
00083  * Revision 1.10  2003/10/29 11:02:13  e_gourgoulhon
00084  * Functions dec_dzpuis and inc_dzpuis have now an integer argument to
00085  * specify by which amount dzpuis is to be increased.
00086  * Accordingly methods dec2_dzpuis and inc2_dzpuis have been suppressed
00087  *
00088  * Revision 1.9  2003/10/16 15:29:08  e_gourgoulhon
00089  * Name of method div_r_ced() changed to div_r_inc2().
00090  * Name of method div_rsint_ced() changed to div_rsint_inc2().
00091  *
00092  * Revision 1.8  2003/10/15 10:44:21  e_gourgoulhon
00093  * Added new method div_tant.
00094  *
00095  * Revision 1.7  2003/10/13 20:50:16  e_gourgoulhon
00096  * Replaced "va.base" by "va.get_base()".
00097  *
00098  * Revision 1.6  2003/10/10 15:57:29  j_novak
00099  * Added the state one (ETATUN) to the class Scalar
00100  *
00101  * Revision 1.5  2003/10/08 14:24:10  j_novak
00102  * replaced mult_r_zec with mult_r_ced
00103  *
00104  * Revision 1.4  2003/10/08 12:26:03  j_novak
00105  * Second part of the bug (sorry!)
00106  *
00107  * Revision 1.3  2003/10/08 12:19:12  j_novak
00108  * Bug corrected, thanks to purify
00109  *
00110  * Revision 1.2  2003/10/05 21:16:41  e_gourgoulhon
00111  * Added methods div_r_ced() and div_rsint_ced().
00112  *
00113  * Revision 1.1  2003/09/25 09:12:01  e_gourgoulhon
00114  * First version (uses Cmp as intermediate variable).
00115  *
00116  *
00117  * $Header: /cvsroot/Lorene/C++/Source/Tensor/Scalar/scalar_r_manip.C,v 1.22 2005/05/25 16:11:05 j_novak Exp $
00118  *
00119  */
00120 
00121 #include "tensor.h" 
00122 #include "cmp.h" 
00123 
00124 
00125             //-------------------//
00126             //   div_r       //
00127             //-------------------//
00128 
00129 void Scalar::div_r() {
00130     
00131   mp->div_r(*this) ;   // Call of the appropriate routine of the mapping
00132     
00133   del_deriv() ;   // Delete the derived members
00134 
00135 }
00136 
00137 
00138             //---------------------//
00139             //    div_r_dzpuis     //
00140             //---------------------//
00141 
00142 
00143 void Scalar::div_r_dzpuis(int ced_mult_r) {
00144     
00145   assert (etat != ETATNONDEF) ;
00146 
00147   Base_val lbase = va.base ;
00148  
00149   if (etat != ETATZERO) {
00150     
00151     assert((etat == ETATQCQ) || (etat == ETATUN)) ;
00152     
00153     set_etat_qcq() ;
00154 
00155     int nzm1 = mp->get_mg()->get_nzone() - 1 ; // index of the CED
00156     bool ced = mp->get_mg()->get_type_r(nzm1) == UNSURR ;
00157     
00158     // Copy of the CED part of *this into uu_ext 
00159     Scalar uu_ext(*mp) ;
00160     if (ced) {
00161     uu_ext.allocate_all() ;
00162     uu_ext.annule(0,nzm1-1) ; // zero in all domains but the CED
00163     uu_ext.set_domain(nzm1) = domain(nzm1) ; 
00164     uu_ext.set_spectral_base(va.get_base()) ; 
00165 
00166     // Division by r in all domains but the CED
00167     annule(nzm1, nzm1) ;    // zero in the CED
00168     }
00169     div_r() ; 
00170     
00171     if (ced) { // Add the CED part
00172     set_domain(nzm1) = uu_ext.domain(nzm1) ; 
00173     dzpuis += 1 ; 
00174     }
00175   }
00176     
00177   int diff_dzpuis = ced_mult_r - dzpuis ;
00178   (diff_dzpuis >= 0) ? inc_dzpuis(diff_dzpuis) : dec_dzpuis(-diff_dzpuis) ;
00179   
00180   lbase.sx() ;
00181   set_spectral_base(lbase) ;
00182 
00183   del_deriv() ;   // Delete the derived members
00184     
00185   return ;
00186 }
00187 
00188             //---------------------------//
00189             //      div_r_ced        //
00190             //---------------------------//
00191 
00192 void Scalar::div_r_ced() {
00193 
00194   mp->div_r_zec(*this) ;   // Call of the appropriate routine of the mapping
00195     
00196   del_deriv() ;   // Delete the derived members
00197 
00198 }
00199 
00200             //---------------------------//
00201             //      mult_r       //
00202             //---------------------------//
00203 
00204 void Scalar::mult_r() {
00205     
00206   mp->mult_r(*this) ;   // Call of the appropriate routine of the mapping
00207     
00208   del_deriv() ;   // Delete the derived members
00209     
00210 }
00211 
00212             //---------------------//
00213             //    mult_r_dzpuis    //
00214             //---------------------//
00215 
00216 
00217 void Scalar::mult_r_dzpuis(int ced_mult_r) {
00218     
00219   assert (etat != ETATNONDEF) ;
00220 
00221   Base_val lbase = va.base ;
00222 
00223   if (etat != ETATZERO) {
00224     
00225     assert((etat == ETATQCQ) || (etat == ETATUN)) ;
00226     
00227     set_etat_qcq() ;
00228     
00229     int nzm1 = mp->get_mg()->get_nzone() - 1 ; // index of the CED
00230     bool ced = mp->get_mg()->get_type_r(nzm1) == UNSURR ;
00231     Scalar uu_ext(*mp) ; 
00232     
00233     if (ced) {// Copy of the CED part of *this into uu_ext 
00234     uu_ext.allocate_all() ;
00235     uu_ext.annule(0,nzm1-1) ; // zero in all domains but the CED
00236     uu_ext.set_domain(nzm1) = domain(nzm1) ; 
00237     uu_ext.set_spectral_base(va.get_base()) ; 
00238     
00239     // Division by r in all domains but the CED
00240     annule(nzm1, nzm1) ;    // zero in the CED
00241     }
00242     mult_r() ; 
00243     
00244     if (ced) {// Add the CED part
00245     set_domain(nzm1) = uu_ext.domain(nzm1) ; 
00246     dzpuis -= 1 ; 
00247     }
00248   }
00249     
00250   int diff_dzpuis = ced_mult_r - dzpuis ;
00251   (diff_dzpuis >= 0) ? inc_dzpuis(diff_dzpuis) : dec_dzpuis(-diff_dzpuis) ;
00252   
00253   lbase.mult_x() ;
00254   set_spectral_base(lbase) ;
00255 
00256   del_deriv() ;   // Delete the derived members
00257     
00258   return ;
00259 }
00260 
00261             //---------------------------//
00262             //      mult_r_ced       //
00263             //---------------------------//
00264 
00265 void Scalar::mult_r_ced() {
00266     
00267   mp->mult_r_zec(*this) ;   // Call of the appropriate routine of the mapping
00268     
00269   del_deriv() ;   // Delete the derived members
00270 
00271 }
00272 
00273             //---------------------------//
00274             //      mult_rsint       //
00275             //---------------------------//
00276 
00277 void Scalar::mult_rsint() {
00278     
00279   mp->mult_rsint(*this) ; // Call of the appropriate routine of the mapping 
00280     
00281   del_deriv() ;   // Delete the derived members
00282 
00283 }
00284 
00285             //-------------------------//
00286             //    mult_rsint_dzpuis    //
00287             //-------------------------//
00288 
00289 
00290 void Scalar::mult_rsint_dzpuis(int ced_mult_r) {
00291     
00292   assert (etat != ETATNONDEF) ;
00293 
00294   Base_val lbase = va.base ;
00295   int nzm1 = mp->get_mg()->get_nzone() - 1 ; // index of the CED
00296   bool ced = mp->get_mg()->get_type_r(nzm1) == UNSURR ;
00297 
00298   if (etat != ETATZERO) {
00299 
00300     assert((etat == ETATQCQ) || (etat == ETATUN)) ;
00301     
00302     set_etat_qcq() ;
00303     Scalar uu_ext(*mp) ; 
00304         
00305     if (ced) {// Copy of the CED part of *this into uu_ext and multiplication by r
00306     uu_ext.allocate_all() ;
00307     uu_ext.annule(0,nzm1-1) ; // zero in all domains but the CED
00308     uu_ext.set_domain(nzm1) = domain(nzm1) ; 
00309     uu_ext.set_spectral_base(va.get_base()) ; 
00310     int dzpuis_ext = dzpuis - 1 ;
00311     uu_ext.set_dzpuis(dzpuis_ext) ;
00312     int diff_dzpuis = ced_mult_r - dzpuis_ext ;
00313     (diff_dzpuis >= 0) ? uu_ext.inc_dzpuis(diff_dzpuis) 
00314         : uu_ext.dec_dzpuis(-diff_dzpuis) ;
00315 
00316     // Multiplication by sin(theta) in the CED :
00317     // what follows does not apply if the mapping is not radial:
00318     assert( dynamic_cast<const Map_radial*>(mp) != 0x0 ) ; 
00319     uu_ext.mult_sint() ;
00320     
00321     // Multiplication by r sin(theta) in all domains but the CED
00322     annule(nzm1, nzm1) ;    // zero in the CED
00323     }
00324     mult_rsint() ; 
00325     
00326     if (ced) // Add the CED part
00327     set_domain(nzm1) = uu_ext.domain(nzm1) ; 
00328   }
00329   
00330   if (ced) dzpuis = ced_mult_r ;
00331  
00332   lbase.mult_x() ;
00333   lbase.mult_sint() ; 
00334   set_spectral_base(lbase) ;
00335 
00336   del_deriv() ;   // Delete the derived members
00337 
00338 }
00339 
00340             //---------------------------//
00341             //      div_rsint        //
00342             //---------------------------//
00343 
00344 void Scalar::div_rsint() {
00345 
00346   mp->div_rsint(*this) ;   // Call of the appropriate routine of the mapping
00347     
00348   del_deriv() ;   // Delete the derived members
00349 
00350 }
00351 
00352 
00353             //-------------------------//
00354             //     div_rsint_dzpuis    //
00355             //-------------------------//
00356 
00357 
00358 void Scalar::div_rsint_dzpuis(int ced_mult_r) {
00359     
00360   assert (etat != ETATNONDEF) ;
00361 
00362   Base_val lbase = va.base ;
00363   int nzm1 = mp->get_mg()->get_nzone() - 1 ; // index of the CED
00364   bool ced = mp->get_mg()->get_type_r(nzm1) == UNSURR ;
00365 
00366   if (etat != ETATZERO) {
00367 
00368     assert((etat == ETATQCQ) || (etat == ETATUN)) ;
00369     
00370     set_etat_qcq() ;
00371     Scalar uu_ext(*mp) ; 
00372     
00373     if (ced) {// Copy of the CED part of *this into uu_ext and multiplication by r
00374     uu_ext.allocate_all() ;
00375     uu_ext.annule(0,nzm1-1) ; // zero in all domains but the CED
00376     uu_ext.set_domain(nzm1) = domain(nzm1) ; 
00377     uu_ext.set_spectral_base(va.get_base()) ; 
00378     int dzpuis_ext = dzpuis + 1 ;
00379     uu_ext.set_dzpuis(dzpuis_ext) ;
00380     int diff_dzpuis = ced_mult_r - dzpuis_ext ;
00381     (diff_dzpuis >= 0) ? uu_ext.inc_dzpuis(diff_dzpuis) 
00382         : uu_ext.dec_dzpuis(-diff_dzpuis) ;
00383     
00384     // Division by sin(theta) in the CED :
00385     // what follows does not apply if the mapping is not radial:
00386     assert( dynamic_cast<const Map_radial*>(mp) != 0x0 ) ; 
00387     uu_ext.div_sint() ;
00388 
00389     // Division by r sin(theta) in all domains but the CED
00390     annule(nzm1, nzm1) ;    // zero in the CED
00391     }
00392     div_rsint() ; 
00393     
00394     if (ced) // Add the CED part
00395     set_domain(nzm1) = uu_ext.domain(nzm1) ; 
00396     
00397   }
00398   if (ced) 
00399       dzpuis = ced_mult_r ;
00400     
00401   lbase.sx() ;
00402   lbase.ssint() ;
00403   set_spectral_base(lbase) ;
00404 
00405   del_deriv() ;   // Delete the derived members
00406 
00407 }
00408 
00409 
00410             //-----------------------//
00411             //      dec_dzpuis       //
00412             //-----------------------//
00413 
00414 void Scalar::dec_dzpuis(int decrem) {
00415     
00416     if (decrem == 0) return ; 
00417     
00418     if (etat == ETATZERO) {
00419 //##        dzpuis -= decrem ;   // a voir...
00420         return ; 
00421     }
00422 
00423     switch (decrem) {
00424     
00425         case 0 : { 
00426             break ; 
00427         }
00428 
00429         case 1 : { 
00430             mp->dec_dzpuis(*this) ;   
00431             break ; 
00432         }
00433 
00434         case 2 : {
00435             mp->dec2_dzpuis(*this) ;  
00436             break ; 
00437         }
00438         
00439         case 3 : {
00440             mp->dec2_dzpuis(*this) ;  
00441         mp->dec_dzpuis(*this) ;   
00442             break ; 
00443         }
00444         
00445         case 4 : {
00446             mp->dec2_dzpuis(*this) ;  
00447             mp->dec2_dzpuis(*this) ;  
00448             break ; 
00449         }
00450         
00451         default : {
00452             cout << "Scalar::dec_dzpuis : unexpected value of decrem !"
00453                 << endl << "  decrem = " << decrem << endl ; 
00454             abort() ;
00455             break ; 
00456         }
00457     }
00458     del_deriv() ;
00459     
00460 }
00461 
00462             //-----------------------//
00463             //      inc_dzpuis       //
00464             //-----------------------//
00465 
00466 void Scalar::inc_dzpuis(int inc) {
00467     
00468     if (inc == 0) return ; 
00469 
00470     if (etat == ETATZERO) {
00471 //##        dzpuis += inc ;   // a voir ...
00472         return ; 
00473     }
00474 
00475     switch (inc) {
00476     
00477         case 0 : { 
00478             break ; 
00479         }
00480 
00481         case 1 : { 
00482             mp->inc_dzpuis(*this) ;   
00483                 break ; 
00484         }
00485 
00486         case 2 : {
00487                 mp->inc2_dzpuis(*this) ;  
00488             break ; 
00489         }
00490         
00491         case 3 : {
00492             mp->inc_dzpuis(*this) ;   
00493                 mp->inc2_dzpuis(*this) ;  
00494             break ; 
00495         }
00496         
00497         case 4 : {
00498                 mp->inc2_dzpuis(*this) ;  
00499                 mp->inc2_dzpuis(*this) ;  
00500             break ; 
00501         }
00502         
00503         default : {
00504             cout << "Scalar::inc_dzpuis : unexpected value of inc !"
00505                 << endl << "  inc = " << inc << endl ; 
00506             abort() ;
00507             break ; 
00508         }
00509     }
00510     del_deriv() ;
00511     
00512 }
00513 
00514 
00515 

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