00001 /* 00002 * Copyright (c) 1999-2001 Eric Gourgoulhon 00003 * 2009 Jerome Novak 00004 * 00005 * This file is part of LORENE. 00006 * 00007 * LORENE is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * LORENE is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with LORENE; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 * 00021 */ 00022 00023 00024 char chb_legmp_cos_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/chb_legmp_cos.C,v 1.1 2009/10/13 13:49:36 j_novak Exp $" ; 00025 00026 /* 00027 * Calcule les coefficients du developpement (suivant theta) 00028 * en cos(j*theta) 00029 * a partir des coefficients du developpement en fonctions 00030 * associees de Legendre P_l^m(cos(theta)) (m pair) 00031 * pour une une fonction 3-D symetrique par le retournement (x, y, z) --> (-x, -y, z). 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 * f(theta) = som_{l=m}^{nt-1} a_l P_l^m( cos(theta) ) 00045 * 00046 * (m pair) 00047 * 00048 * ou P_n^m(x) represente la fonction de Legendre associee 00049 * de degre n et d'ordre m normalisee de facon a ce que 00050 * 00051 * int_0^pi [ P_n^m(cos(theta)) ]^2 sin(theta) dtheta = 1 00052 * 00053 * L'espace memoire correspondant au pointeur cfi doit etre 00054 * nr*nt*(np+2) et doit avoir ete alloue avant 00055 * l'appel a la routine. 00056 * Le coefficient a_l (0 <= l <= nt-1) doit etre stoke dans le 00057 * tableau cfi comme suit 00058 * a_l = cfi[ nr*nt* k + i + nr* l ] 00059 * ou k et i sont les indices correspondant a phi et r 00060 * respectivement: m = 2 (k/2). 00061 * NB: pour l < m, a_l = 0 00062 * 00063 * Sortie: 00064 * ------- 00065 * double* cfo : tableau des coefficients c_j du develop. en cos/sin definis 00066 * comme suit (a r et phi fixes) : 00067 * 00068 * f(theta) = som_{j=0}^{nt-1} c_j cos( j theta ) 00069 * 00070 * L'espace memoire correspondant au pointeur cfo doit etre 00071 * nr*nt*(np+2) et doit avoir ete alloue avant 00072 * l'appel a la routine. 00073 * Le coefficient c_j (0 <= j <= nt-1) est stoke dans le 00074 * tableau cfo comme suit 00075 * c_j = cfo[ nr*nt* k + i + nr* j ] 00076 * ou k et i sont les indices correspondant a 00077 * phi et r respectivement: m = 2 (k/2). 00078 * Pour m impair, c_0 = c_{nt-1} = 0. 00079 * 00080 * 00081 * NB: 00082 * --- 00083 * Il n'est pas possible d'avoir le pointeur cfo egal a cfi. 00084 */ 00085 00086 /* 00087 * $Id: chb_legmp_cos.C,v 1.1 2009/10/13 13:49:36 j_novak Exp $ 00088 * $Log: chb_legmp_cos.C,v $ 00089 * Revision 1.1 2009/10/13 13:49:36 j_novak 00090 * New base T_LEG_MP. 00091 * 00092 * 00093 * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Coef/chb_legmp_cos.C,v 1.1 2009/10/13 13:49:36 j_novak Exp $ 00094 * 00095 */ 00096 00097 00098 00099 // headers du C 00100 #include <stdlib.h> 00101 #include <assert.h> 00102 00103 // Prototypage 00104 #include "headcpp.h" 00105 #include "proto.h" 00106 00107 //****************************************************************************** 00108 00109 void chb_legmp_cos(const int* deg , const double* cfi, double* cfo) { 00110 00111 int k2, l, j, i, m ; 00112 00113 // Nombres de degres de liberte en phi et theta : 00114 int np = deg[0] ; 00115 int nt = deg[1] ; 00116 int nr = deg[2] ; 00117 00118 assert(np < 4*nt) ; 00119 00120 // Tableau de travail 00121 double* som = new double[nr] ; 00122 00123 // Recherche de la matrice de passage Legendre --> cos/sin 00124 double* bb = mat_legmp_cos(np, nt) ; 00125 00126 // Increment en m pour la matrice bb : 00127 int mbb = nt * nt ; 00128 00129 // Pointeurs de travail : 00130 double* resu = cfo ; 00131 const double* cc = cfi ; 00132 00133 // Increment en phi : 00134 int ntnr = nt * nr ; 00135 00136 // Indice courant en phi : 00137 int k = 0 ; 00138 00139 //---------------------------------------------------------------- 00140 // Cas axisymetrique 00141 //---------------------------------------------------------------- 00142 00143 if (np == 1) { 00144 00145 m = 0 ; 00146 00147 // Boucle sur l'indice j du developpement en cos(j theta) 00148 00149 for (j=0; j<nt; j++) { 00150 00151 // ... produit matriciel (parallelise sur r) 00152 for (i=0; i<nr; i++) { 00153 som[i] = 0 ; 00154 } 00155 00156 for (l=m; l<nt; l++) { 00157 00158 double bmjl = bb[nt*j + l] ; 00159 for (i=0; i<nr; i++) { 00160 som[i] += bmjl * cc[nr*l + i] ; 00161 } 00162 } 00163 00164 for (i=0; i<nr; i++) { 00165 *resu = som[i] ; 00166 resu++ ; 00167 } 00168 00169 } // fin de la boucle sur j 00170 00171 // Mise a zero des coefficients k=1 et k=2 : 00172 // --------------------------------------- 00173 00174 for (i=ntnr; i<3*ntnr; i++) { 00175 cfo[i] = 0 ; 00176 } 00177 00178 // On sort 00179 delete [] som ; 00180 return ; 00181 00182 } // fin du cas np=1 00183 00184 00185 //---------------------------------------------------------------- 00186 // Cas 3-D 00187 //---------------------------------------------------------------- 00188 00189 00190 // Boucle sur phi : 00191 00192 for (m=0; m < np + 1 ; m+=2) { 00193 00194 for (k2=0; k2 < 2; k2++) { // k2=0 : cos(m phi) ; k2=1 : sin(m phi) 00195 00196 if ( (k == 1) || (k == np+1) ) { // On met les coef de sin(0 phi) 00197 // et sin( np phi) a zero 00198 for (j=0; j<nt; j++) { 00199 for (i=0; i<nr; i++) { 00200 *resu = 0 ; 00201 resu++ ; 00202 } 00203 } 00204 } 00205 else { 00206 00207 // Boucle sur l'indice j du developpement en cos(2 j theta) 00208 00209 for (j=0; j<nt; j++) { 00210 00211 // ... produit matriciel (parallelise sur r) 00212 for (i=0; i<nr; i++) { 00213 som[i] = 0 ; 00214 } 00215 00216 for (l=m; l<nt; l++) { 00217 00218 double bmjl = bb[nt*j + l] ; 00219 for (i=0; i<nr; i++) { 00220 som[i] += bmjl * cc[nr*l + i] ; 00221 } 00222 } 00223 00224 for (i=0; i<nr; i++) { 00225 *resu = som[i] ; 00226 resu++ ; 00227 } 00228 00229 } // fin de la boucle sur j 00230 00231 } // fin du cas k != 1 00232 00233 // On passe au phi suivant : 00234 cc = cc + ntnr ; 00235 k++ ; 00236 00237 } // fin de la boucle sur k2 00238 00239 // On passe a l'harmonique en phi suivante : 00240 00241 bb += mbb ; // pointeur sur la nouvelle matrice de passage 00242 00243 } // fin de la boucle (m) sur phi 00244 00245 //## verif : 00246 assert(resu == cfo + (np+2)*ntnr) ; 00247 00248 // Menage 00249 delete [] som ; 00250 00251 }
1.4.6