00001 /* 00002 * Copyright (c) 1999-2001 Eric Gourgoulhon 00003 * 00004 * This file is part of LORENE. 00005 * 00006 * LORENE is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * LORENE is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with LORENE; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 * 00020 */ 00021 00022 00023 char chb_leg_cossinc_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/chb_leg_cossinc.C,v 1.2 2005/02/18 13:14:10 j_novak Exp $" ; 00024 00025 /* 00026 * Calcule les coefficients du developpement (suivant theta) 00027 * en cos(j*theta) [m pair] / sin(j*theta) [m impair] 00028 * a partir des coefficients du developpement en fonctions 00029 * associees de Legendre P_l^m(cos(theta)) 00030 * pour une une fonction 3-D symetrique par rapport au plan equatorial 00031 * z = 0. 00032 * 00033 * Entree: 00034 * ------- 00035 * const int* deg : tableau du nombre effectif de degres de liberte dans chacune 00036 * des 3 dimensions: 00037 * deg[0] = np : nombre de points de collocation en phi 00038 * deg[1] = nt : nombre de points de collocation en theta 00039 * deg[2] = nr : nombre de points de collocation en r 00040 * 00041 * const double* cfi : tableau des coefficients a_l du develop. en fonctions de 00042 * Legendre associees P_n^m: 00043 * 00044 * pour m pair: f(theta) = 00045 * som_{l=m}^{nt-1} a_l P_{l}^m( cos(theta) ) 00046 * 00047 * pour m impair: f(theta) = 00048 * som_{l=m}^{nt-1} a_l P_{l}^m( cos(theta) ) 00049 * 00050 * ou P_n^m(x) represente la fonction de Legendre associee 00051 * de degre n et d'ordre m normalisee de facon a ce que 00052 * 00053 * int_0^pi [ P_n^m(cos(theta)) ]^2 sin(theta) dtheta = 1 00054 * 00055 * L'espace memoire correspondant au pointeur cfi doit etre 00056 * nr*nt*(np+2) et doit avoir ete alloue avant 00057 * l'appel a la routine. 00058 * Le coefficient a_l (0 <= l <= nt-1) doit etre stoke dans le 00059 * tableau cfi comme suit 00060 * a_l = cfi[ nr*nt* k + i + nr* l ] 00061 * ou k et i sont les indices correspondant a phi et r 00062 * respectivement: m = k/2. 00063 * NB: pour m pair et l < m, a_l = 0 00064 * pour m impair et l < m, a_l = 0 00065 00066 00067 00068 * 00069 * Sortie: 00070 * ------- 00071 * double* cfo : tableau des coefficients c_j du develop. en cos/sin definis 00072 * comme suit (a r et phi fixes) : 00073 * 00074 * pour m pair: f(theta) = som_{j=0}^{nt-1} c_j cos( j theta ) 00075 * 00076 * pour m impair: f(theta) = som_{j=0}^{nt-2} c_j sin( j theta ) 00077 * 00078 * L'espace memoire correspondant au pointeur cfo doit etre 00079 * nr*nt*(np+2) et doit avoir ete alloue avant 00080 * l'appel a la routine. 00081 * Le coefficient c_j (0 <= j <= nt-1) est stoke dans le 00082 * tableau cfo comme suit 00083 * c_j = cfo[ nr*nt* k + i + nr* j ] 00084 * ou k et i sont les indices correspondant a 00085 * phi et r respectivement: m = k/2. 00086 * Pour m impair, c_0 = c_{nt-1} = 0. 00087 00088 * 00089 * NB: 00090 * --- 00091 * Il n'est pas possible d'avoir le pointeur cfo egal a cfi. 00092 */ 00093 00094 /* 00095 * $Id: chb_leg_cossinc.C,v 1.2 2005/02/18 13:14:10 j_novak Exp $ 00096 * $Log: chb_leg_cossinc.C,v $ 00097 * Revision 1.2 2005/02/18 13:14:10 j_novak 00098 * Changing of malloc/free to new/delete + suppression of some unused variables 00099 * (trying to avoid compilation warnings). 00100 * 00101 * Revision 1.1 2004/11/23 15:13:50 m_forot 00102 * Added the bases for the cases without any equatorial symmetry 00103 * (T_COSSIN_C, T_COSSIN_S, T_LEG, R_CHEBPI_P, R_CHEBPI_I). 00104 * 00105 * 00106 * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/chb_leg_cossinc.C,v 1.2 2005/02/18 13:14:10 j_novak Exp $ 00107 * 00108 */ 00109 00110 00111 // headers du C 00112 #include <assert.h> 00113 #include <stdlib.h> 00114 00115 // Prototypage 00116 #include "headcpp.h" 00117 #include "proto.h" 00118 00119 //****************************************************************************** 00120 00121 void chb_leg_cossinc(const int* deg , const double* cfi, double* cfo) { 00122 00123 int ip, k2, l, j, i, m ; 00124 00125 // Nombres de degres de liberte en phi et theta : 00126 int np = deg[0] ; 00127 int nt = deg[1] ; 00128 int nr = deg[2] ; 00129 00130 assert(np < 4*nt) ; 00131 00132 // Tableau de travail 00133 double* som = new double[nr] ; 00134 00135 // Recherche de la matrice de passage Legendre --> cos/sin 00136 double* bb = mat_leg_cossinc(np, nt) ; 00137 00138 // Increment en m pour la matrice bb : 00139 int mbb = nt * nt ; 00140 00141 //## Test 00142 // double* bbt = bb ; 00143 // cout << "chb_leg_cossinc: matrice de passage : " << endl ; 00144 // for ( m=0; m < np/2+1 ; m++) { 00145 // cout << "---------------------------------------" << endl ; 00146 // cout << " m = " << m << endl ; 00147 // cout << " " << endl ; 00148 // 00149 // for (j=0; j<nt; j++) { 00150 // cout << " j = " << j << " : " ; 00151 // for (l=m/2; l<nt; l++) { 00152 // cout << bbt[nt*j + l] << " " ; 00153 // } 00154 // cout << endl ; 00155 // } 00156 // arrete() ; 00157 // bbt += mbb ; // pointeur sur la nouvelle matrice de passage 00158 // } 00159 //## 00160 00161 // Pointeurs de travail : 00162 double* resu = cfo ; 00163 const double* cc = cfi ; 00164 00165 // Increment en phi : 00166 int ntnr = nt * nr ; 00167 00168 // Indice courant en phi : 00169 int k = 0 ; 00170 00171 // Ordre des harmoniques du developpement de Fourier en phi : 00172 m = 0 ; 00173 00174 // -------------- 00175 // Boucle sur phi : k = 4*ip 4*ip+1 4*ip+2 4*ip+3 00176 // -------------- m = 2*ip 2*ip 2*ip+1 2*ip+1 00177 // k2 = 0 1 0 1 00178 00179 for (ip=0; ip < np/4 + 1 ; ip++) { 00180 00181 //-------------------------------- 00182 // Partie m pair 00183 //-------------------------------- 00184 00185 00186 for (k2=0; k2 < 2; k2++) { // k2=0 : cos(m phi) ; k2=1 : sin(m phi) 00187 00188 if ( (k == 1) || (k == np+1) ) { // On met les coef de sin(0 phi) 00189 // et sin( np/2 phi) a zero 00190 for (j=0; j<nt; j++) { 00191 for (i=0; i<nr; i++) { 00192 *resu = 0 ; 00193 resu++ ; 00194 } 00195 } 00196 } 00197 else { 00198 00199 // Boucle sur l'indice j du developpement en cos(j theta) 00200 00201 for (j=0; j<nt; j++) { 00202 00203 // ... produit matriciel (parallelise sur r) 00204 for (i=0; i<nr; i++) { 00205 som[i] = 0 ; 00206 } 00207 00208 for (l=m; l<nt; l++) { 00209 00210 double bmjl = bb[nt*j + l] ; 00211 for (i=0; i<nr; i++) { 00212 som[i] += bmjl * cc[nr*l + i] ; 00213 } 00214 } 00215 00216 for (i=0; i<nr; i++) { 00217 *resu = som[i] ; 00218 resu++ ; 00219 } 00220 00221 } // fin de la boucle sur j 00222 00223 } // fin du cas k != 1 00224 00225 // On passe au phi suivant : 00226 cc = cc + ntnr ; 00227 k++ ; 00228 00229 } // fin de la boucle sur k2 00230 00231 // On passe a l'harmonique en phi suivante : 00232 m++ ; 00233 bb += mbb ; // pointeur sur la nouvelle matrice de passage 00234 00235 //-------------------------------- 00236 // Partie m impair 00237 //-------------------------------- 00238 00239 for (k2=0; k2 < 2; k2++) { // k2=0 : cos(m phi) ; k2=1 : sin(m phi) 00240 00241 if ( k == np+1 ) { // On met les coef de 00242 // sin( np/2 phi) a zero 00243 for (j=0; j<nt; j++) { 00244 for (i=0; i<nr; i++) { 00245 *resu = 0 ; 00246 resu++ ; 00247 } 00248 } 00249 } 00250 00251 if (k < np+1) { 00252 00253 // Boucle sur l'indice j du developpement en sin( j theta) 00254 00255 for (j=0; j<nt-1; j++) { 00256 00257 // ... produit matriciel (parallelise sur r) 00258 for (i=0; i<nr; i++) { 00259 som[i] = 0 ; 00260 } 00261 00262 for (l=m; l<nt-1; l++) { 00263 double bmjl = bb[nt*j + l] ; 00264 for (i=0; i<nr; i++) { 00265 som[i] += bmjl * cc[nr*l + i] ; 00266 } 00267 } 00268 00269 for (i=0; i<nr; i++) { 00270 *resu = som[i] ; 00271 resu++ ; 00272 } 00273 00274 } // fin de la boucle sur j 00275 00276 // Dernier coef en j=nt-1 mis a zero pour le cas m impair : 00277 for (i=0; i<nr; i++) { 00278 *resu = 0 ; 00279 resu++ ; 00280 } 00281 00282 // On passe au phi suivant : 00283 cc = cc + ntnr ; 00284 k++ ; 00285 00286 } // fin du cas k < np+1 00287 00288 } // fin de la boucle sur k2 00289 00290 00291 // On passe a l'harmonique en phi suivante : 00292 m++ ; 00293 bb += mbb ; // pointeur sur la nouvelle matrice de passage 00294 00295 } // fin de la boucle (ip) sur phi 00296 00297 // Mise a zero des coefficients de sin( np/2 phi ) (k=np+1) 00298 00299 //## verif : 00300 // assert(resu == cfo + (np+2)*ntnr) ; 00301 00302 // Menage 00303 delete [] som ; 00304 00305 }
1.4.6