op_mult_cp.C

00001 /*
00002  * Sets of routines for multiplication by cos(phi)
00003  * (internal use)
00004  *
00005  *  void _mult_cp_XXXX(Tbl * t, int & b)
00006  *  t   pointer on the Tbl containing the spectral coefficients
00007  *  b   spectral base
00008  *
00009  */
00010 
00011 /*
00012  *   Copyright (c) 2000-2001 Eric Gourgoulhon
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 op_mult_cp_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Operators/op_mult_cp.C,v 1.4 2007/12/14 10:19:33 jl_cornou Exp $" ;
00034 
00035 /*
00036  * $Id: op_mult_cp.C,v 1.4 2007/12/14 10:19:33 jl_cornou Exp $
00037  * $Log: op_mult_cp.C,v $
00038  * Revision 1.4  2007/12/14 10:19:33  jl_cornou
00039  * *** empty log message ***
00040  *
00041  * Revision 1.3  2007/10/05 12:37:20  j_novak
00042  * Corrected a few errors in the theta-nonsymmetric case (bases T_COSSIN_C and
00043  * T_COSSIN_S).
00044  *
00045  * Revision 1.2  2004/11/23 15:16:01  m_forot
00046  *
00047  * Added the bases for the cases without any equatorial symmetry
00048  *  (T_COSSIN_C, T_COSSIN_S, T_LEG, R_CHEBPI_P, R_CHEBPI_I).
00049  *
00050  * Revision 1.1.1.1  2001/11/20 15:19:29  e_gourgoulhon
00051  * LORENE
00052  *
00053  * Revision 2.4  2000/11/14  15:11:45  eric
00054  * Traitement du cas np=1
00055  *
00056  * Revision 2.3  2000/09/18  10:14:42  eric
00057  * Ajout des bases P_COSSIN_P et P_COSSIN_I
00058  *
00059  * Revision 2.2  2000/09/12  13:36:11  eric
00060  * Met les bonnes bases meme dans le cas ETATZERO
00061  *
00062  * Revision 2.1  2000/09/12  08:28:47  eric
00063  * Traitement des bases qui dependent de la parite de m
00064  *
00065  * Revision 2.0  2000/09/11  13:53:32  eric
00066  * *** empty log message ***
00067  *
00068  *
00069  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Operators/op_mult_cp.C,v 1.4 2007/12/14 10:19:33 jl_cornou Exp $
00070  *
00071  */
00072 
00073 // Headers Lorene
00074 #include "tbl.h"
00075 
00076         //-----------------------------------
00077         //    Routine for unknown cases
00078         //-----------------------------------
00079 
00080 void _mult_cp_pas_prevu(Tbl* , int& base) {
00081     cout << "mult_cp() is not not implemented for the basis " << base << " !"
00082        << endl ;
00083     abort() ;
00084 }
00085 
00086             //----------------
00087             // basis P_COSSIN
00088             //----------------
00089 
00090 void _mult_cp_p_cossin(Tbl* tb, int& base) {
00091     
00092     assert(tb->get_etat() != ETATNONDEF) ;  // Protection
00093 
00094     // The spectral bases in r and theta which depend on the parity of m 
00095     // are changed
00096     // -----------------------------------------------------------------
00097         
00098     int base_r = base & MSQ_R ; 
00099     int base_t = base & MSQ_T ; 
00100     const int base_p = base & MSQ_P ; 
00101     
00102     switch (base_r) {
00103 
00104     case R_CHEBPIM_P : {
00105         base_r = R_CHEBPIM_I ; 
00106         break ; 
00107     }
00108     
00109     case R_CHEBPIM_I : {
00110         base_r = R_CHEBPIM_P ; 
00111         break ;         
00112     }
00113     case R_CHEBPI_P : {
00114         break ; 
00115     }
00116     
00117     case R_CHEBPI_I : {
00118         break ;         
00119     }  
00120       
00121     
00122     case R_CHEB : {
00123         break ; 
00124     }
00125 
00126     case R_JACO02 : {
00127         break ;
00128     }
00129     
00130     case R_CHEBU : {
00131         break ; 
00132     }
00133     
00134     default : {
00135         cout << "_mult_cp_p_cossin : unknown basis in r !" << endl ; 
00136         cout << "  base_r = " << hex << base_r << endl ; 
00137         abort() ; 
00138     }   
00139     }
00140     
00141     switch (base_t) {
00142 
00143     case T_COSSIN_CP : {
00144         base_t = T_COSSIN_SI ; 
00145         break ; 
00146     }
00147     
00148     case T_COSSIN_SI : {
00149         base_t = T_COSSIN_CP ; 
00150         break ; 
00151     }
00152     
00153     case T_COSSIN_CI : {
00154         base_t = T_COSSIN_SP ; 
00155         break ; 
00156     }
00157     
00158     case T_COSSIN_SP : {
00159         base_t = T_COSSIN_CI ; 
00160         break ; 
00161     }
00162 
00163         case T_COSSIN_S : {
00164         base_t = T_COSSIN_C ; 
00165         break ; 
00166     }  
00167     case T_COSSIN_C : {
00168         base_t = T_COSSIN_S ; 
00169         break ; 
00170     }  
00171     
00172     default : {
00173         cout << "_mult_cp_p_cossin : unknown basis in theta !" << endl ; 
00174         cout << "  base_t = " << hex << base_t << endl ; 
00175         abort() ; 
00176     }   
00177     }
00178     
00179     base = base_r | base_t | base_p ; 
00180     
00181     //----------------------------------
00182     //  Start of computation 
00183     //----------------------------------
00184 
00185     // Nothing to do ? 
00186     if (tb->get_etat() == ETATZERO) {
00187     return ;
00188     }
00189     
00190     assert(tb->get_etat() == ETATQCQ) ; // Protection
00191   
00192     // Number of degrees of freedom
00193     int nr = tb->get_dim(0) ;
00194     int nt = tb->get_dim(1) ;
00195     int np = tb->get_dim(2) - 2 ;
00196     
00197     // Special case np = 1 (axisymmetry)  --> identity
00198     // ---------------------------------
00199     
00200     if (np==1) {
00201     return ; 
00202     }
00203 
00204     assert(np >= 4) ; 
00205     
00206     int ntnr = nt*nr ;
00207     
00208     double* const cf = tb->t ;              // input coefficients
00209     double* const resu = new double[ tb->get_taille() ] ;   // final result
00210     double* co = resu ;     // initial position 
00211         
00212     // Case k=0 (m=0)
00213     // --------------
00214     
00215     int q = 2 * ntnr ; 
00216     for (int i=0; i<ntnr; i++) {
00217     co[i] = 0.5 * cf[q + i] ; 
00218     }
00219     co += ntnr ; 
00220     
00221     // Case k = 1 
00222     // ----------
00223     
00224     for (int i=0; i<ntnr; i++) {
00225     co[i] = 0 ; 
00226     }
00227     co += ntnr ; 
00228     
00229     // Case k = 2 
00230     // ----------
00231     
00232     q = 4*ntnr ; 
00233     for (int i=0; i<ntnr; i++) {
00234     co[i] = cf[i] + 0.5 * cf[q+i] ; 
00235     }
00236     co += ntnr ; 
00237     
00238     if (np==4) {
00239 
00240     // Case k = 3   for np=4
00241     // ----------
00242     
00243     for (int i=0; i<ntnr; i++) {
00244         co[i] = 0 ; 
00245     }
00246     co += ntnr ; 
00247     }
00248     else {
00249 
00250     // Case k = 3   for np>4
00251     // ----------
00252     
00253     q = 5*ntnr ; 
00254     for (int i=0; i<ntnr; i++) {
00255         co[i] = 0.5 * cf[q+i] ; 
00256     }
00257     co += ntnr ; 
00258 
00259     // Cases 4 <= k <= np-2
00260     // --------------------
00261     
00262     for (int k=4; k<np-1; k++) {
00263         int q1 = (k-2)*ntnr ;
00264         int q2 = (k+2)*ntnr ; 
00265         for (int i=0; i<ntnr; i++) {
00266         co[i] = 0.5 * ( cf[q1+i] + cf[q2+i] ) ; 
00267         }
00268         co += ntnr ; 
00269     }
00270     
00271     // Case k = np - 1   for np>4
00272     // ---------------
00273     
00274     q = (np-3)*ntnr ; 
00275     for (int i=0; i<ntnr; i++) {
00276         co[i] = 0.5 * cf[q+i] ; 
00277     }
00278     co += ntnr ; 
00279     
00280     }  // End of case np > 4
00281     
00282     
00283     // Case k = np
00284     // -----------
00285     
00286     q = (np-2)*ntnr ; 
00287     for (int i=0; i<ntnr; i++) {
00288     co[i] = 0.5 * cf[q+i] ; 
00289     }
00290     co += ntnr ; 
00291     
00292     // Case k = np+1
00293     // -------------
00294 
00295     for (int i=0; i<ntnr; i++) {
00296     co[i] = 0 ; 
00297     }
00298     
00299     //## verif : 
00300     co += ntnr ;
00301     assert( co == resu + (np+2)*ntnr ) ; 
00302     
00303     
00304     // The result is set to tb :
00305     // ----------------------- 
00306     delete [] tb->t ;
00307     tb->t = resu ;
00308     
00309     return ; 
00310 }
00311 
00312 
00313             //-----------------
00314             // basis P_COSSIN_P
00315             //-----------------
00316 
00317 void _mult_cp_p_cossin_p(Tbl* tb, int& base) {
00318     
00319     assert(tb->get_etat() != ETATNONDEF) ;  // Protection
00320 
00321     // New spectral bases
00322     // ------------------        
00323     int base_r = base & MSQ_R ; 
00324     int base_t = base & MSQ_T ; 
00325     base = base_r | base_t | P_COSSIN_I ; 
00326     
00327     //----------------------------------
00328     //  Start of computation 
00329     //----------------------------------
00330 
00331     // Nothing to do ? 
00332     if (tb->get_etat() == ETATZERO) {
00333     return ;
00334     }
00335     
00336     assert(tb->get_etat() == ETATQCQ) ; // Protection
00337   
00338     // Number of degrees of freedom
00339     int nr = tb->get_dim(0) ;
00340     int nt = tb->get_dim(1) ;
00341     int np = tb->get_dim(2) - 2 ;
00342     
00343     // Special case np = 1 (axisymmetry)  --> identity
00344     // ---------------------------------
00345     
00346     if (np==1) {
00347     return ; 
00348     }
00349 
00350     assert(np >= 4) ; 
00351     
00352     int ntnr = nt*nr ;
00353     
00354     double* const cf = tb->t ;              // input coefficients
00355     double* const resu = new double[ tb->get_taille() ] ;   // final result
00356     double* co = resu ;     // initial position 
00357         
00358     // Case k=0 
00359     // --------
00360     
00361     int q = 2 * ntnr ; 
00362     for (int i=0; i<ntnr; i++) {
00363     co[i] = cf[i] + 0.5 * cf[q + i] ; 
00364     }
00365     co += ntnr ; 
00366     
00367     // Case k = 1 
00368     // ----------
00369     
00370     for (int i=0; i<ntnr; i++) {
00371     co[i] = 0 ; 
00372     }
00373     co += ntnr ; 
00374     
00375     // Case k = 2 
00376     // ----------
00377     
00378     q = 3*ntnr ; 
00379     for (int i=0; i<ntnr; i++) {
00380     co[i] = 0.5 * cf[q+i] ; 
00381     }
00382     co += ntnr ; 
00383     
00384 
00385     // Cases 3 <= k <= np-1
00386     // --------------------
00387 
00388     for (int k=3; k<np; k++) {
00389     int q1 = (k-1)*ntnr ;
00390     int q2 = (k+1)*ntnr ; 
00391     for (int i=0; i<ntnr; i++) {
00392         co[i] = 0.5 * ( cf[q1+i] + cf[q2+i] ) ; 
00393     }
00394     co += ntnr ; 
00395     }
00396     
00397     // Case k = np
00398     // -----------
00399     
00400     q = (np-1)*ntnr ; 
00401     for (int i=0; i<ntnr; i++) {
00402     co[i] = 0.5 * cf[q+i] ; 
00403     }
00404     co += ntnr ; 
00405     
00406     // Case k = np+1
00407     // -------------
00408 
00409     for (int i=0; i<ntnr; i++) {
00410     co[i] = 0 ; 
00411     }
00412     
00413     //## verif : 
00414     co += ntnr ;
00415     assert( co == resu + (np+2)*ntnr ) ; 
00416     
00417     // The result is set to tb :
00418     // ----------------------- 
00419     delete [] tb->t ;
00420     tb->t = resu ;
00421         
00422     return ; 
00423 }
00424 
00425 
00426 
00427             //-----------------
00428             // basis P_COSSIN_I
00429             //-----------------
00430 
00431 void _mult_cp_p_cossin_i(Tbl* tb, int& base) {
00432     
00433     assert(tb->get_etat() != ETATNONDEF) ;  // Protection
00434 
00435     // New spectral bases
00436     // ------------------        
00437     int base_r = base & MSQ_R ; 
00438     int base_t = base & MSQ_T ; 
00439     base = base_r | base_t | P_COSSIN_P ; 
00440     
00441     //----------------------------------
00442     //  Start of computation 
00443     //----------------------------------
00444 
00445     // Nothing to do ? 
00446     if (tb->get_etat() == ETATZERO) {
00447     return ;
00448     }
00449     
00450     assert(tb->get_etat() == ETATQCQ) ; // Protection
00451   
00452     // Number of degrees of freedom
00453     int nr = tb->get_dim(0) ;
00454     int nt = tb->get_dim(1) ;
00455     int np = tb->get_dim(2) - 2 ;
00456     
00457     // Special case np = 1 (axisymmetry)  --> identity
00458     // ---------------------------------
00459     
00460     if (np==1) {
00461     return ; 
00462     }
00463 
00464     assert(np >= 4) ; 
00465     
00466     int ntnr = nt*nr ;
00467     
00468     double* const cf = tb->t ;              // input coefficients
00469     double* const resu = new double[ tb->get_taille() ] ;   // final result
00470     double* co = resu ;     // initial position 
00471         
00472     // Case k=0 
00473     // --------
00474     
00475     for (int i=0; i<ntnr; i++) {
00476     co[i] = 0.5 * cf[i] ; 
00477     }
00478     co += ntnr ; 
00479     
00480     // Case k = 1 
00481     // ----------
00482     
00483     for (int i=0; i<ntnr; i++) {
00484     co[i] = 0 ; 
00485     }
00486     co += ntnr ; 
00487     
00488     // Case k = 2 
00489     // ----------
00490     
00491     int q = 3*ntnr ; 
00492     for (int i=0; i<ntnr; i++) {
00493     co[i] = 0.5 * ( cf[i] + cf[q+i] ) ; 
00494     }
00495     co += ntnr ; 
00496     
00497     // Cases 3 <= k <= np-1
00498     // --------------------
00499 
00500     for (int k=3; k<np; k++) {
00501     int q1 = (k-1)*ntnr ;
00502     int q2 = (k+1)*ntnr ; 
00503     for (int i=0; i<ntnr; i++) {
00504         co[i] = 0.5 * ( cf[q1+i] + cf[q2+i] ) ; 
00505     }
00506     co += ntnr ; 
00507     }
00508     
00509     // Case k = np
00510     // -----------
00511     
00512     q = (np-1)*ntnr ; 
00513     for (int i=0; i<ntnr; i++) {
00514     co[i] = 0.5 * cf[q+i] ; 
00515     }
00516     co += ntnr ; 
00517     
00518     // Case k = np+1
00519     // -------------
00520 
00521     for (int i=0; i<ntnr; i++) {
00522     co[i] = 0 ; 
00523     }
00524     
00525     //## verif : 
00526     co += ntnr ;
00527     assert( co == resu + (np+2)*ntnr ) ; 
00528     
00529     // The result is set to tb :
00530     // ----------------------- 
00531     delete [] tb->t ;
00532     tb->t = resu ;
00533     
00534     return ; 
00535 }
00536 
00537 
00538 
00539 
00540 
00541 
00542 
00543 
00544 
00545 
00546 
00547 
00548 
00549 
00550 
00551 
00552 
00553             

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