op_d2sdphi2.C

00001 /*
00002  *   Copyright (c) 1999-2000 Jean-Alain Marck
00003  *   Copyright (c) 1999-2001 Eric Gourgoulhon
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 op_d2sdphi2_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Operators/op_d2sdphi2.C,v 1.2 2006/03/10 12:45:38 j_novak Exp $" ;
00025 
00026 /*
00027  * Ensemble des routines de base de derivation seconde par rapport a Phi
00028  * (Utilisation interne)
00029  * 
00030  *  void _d2sdphi2_XXXX(Tbl * t, int & b)
00031  *  t   pointeur sur le Tbl d'entree-sortie
00032  *  b   base spectrale
00033  * 
00034  */
00035 
00036 /*
00037  * $Id: op_d2sdphi2.C,v 1.2 2006/03/10 12:45:38 j_novak Exp $
00038  * $Log: op_d2sdphi2.C,v $
00039  * Revision 1.2  2006/03/10 12:45:38  j_novak
00040  * Use of C++-style cast.
00041  *
00042  * Revision 1.1.1.1  2001/11/20 15:19:29  e_gourgoulhon
00043  * LORENE
00044  *
00045  * Revision 2.4  2000/10/04  10:14:52  eric
00046  * Ajout d' abort() dans le cas non prevu.
00047  * ./
00048  *
00049  * Revision 2.3  2000/02/24  16:40:19  eric
00050  * Initialisation a zero du tableau xo avant le calcul.
00051  *
00052  * Revision 2.2  1999/11/15  16:37:33  eric
00053  * Tbl::dim est desormais un Dim_tbl et non plus un Dim_tbl*.
00054  *
00055  * Revision 2.1  1999/03/01  15:05:37  eric
00056  * *** empty log message ***
00057  *
00058  * Revision 2.0  1999/02/23  11:40:34  hyc
00059  * *** empty log message ***
00060  *
00061  *
00062  *
00063  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Operators/op_d2sdphi2.C,v 1.2 2006/03/10 12:45:38 j_novak Exp $
00064  *
00065  */
00066 
00067 // Headers Lorene
00068 #include "tbl.h"
00069 
00070 // Routine pour les cas non prevus
00071 //--------------------------------
00072 void _d2sdphi2_pas_prevu(Tbl* , int & b) {
00073     cout << "Unknown phi basis in Mtbl_cf::d2sdp2() !" << endl ;
00074     cout << " basis: " << hex << b << endl ;
00075     abort() ; 
00076 }
00077 
00078 // cas P_COSSIN
00079 //-------------
00080 void _d2sdphi2_p_cossin(Tbl* tb, int & )
00081 {
00082 
00083     // Peut-etre rien a faire ?
00084     if (tb->get_etat() == ETATZERO) {
00085     return ;
00086     }
00087     
00088     // Protection
00089     assert(tb->get_etat() == ETATQCQ) ;
00090     
00091     // Pour le confort
00092     int nr = (tb->dim).dim[0] ;     // Nombre
00093     int nt = (tb->dim).dim[1] ;     //   de points
00094     int np = (tb->dim).dim[2] ;     //      physiques REELS
00095     np = np - 2 ;           // Nombre de points physiques
00096     
00097     // Variables statiques
00098     static double* cx = 0 ;
00099     static int np_pre =0 ;
00100 
00101     // Test sur np pour initialisation eventuelle
00102     if (np > np_pre) {
00103     np_pre = np ;
00104     cx = reinterpret_cast<double*>(realloc(cx, (np+2) * sizeof(double))) ;
00105     for (int i=0 ; i<np+2 ; i++) {
00106         cx[i] = - (i/2) * (i/2) ;
00107     }
00108     }
00109 
00110     // pt. sur le tableau de double resultat
00111     double* xo = new double[(tb->dim).taille] ;
00112     
00113     // Initialisation a zero :
00114     for (int i=0; i<(tb->dim).taille; i++) {
00115     xo[i] = 0 ; 
00116     }
00117     
00118     // On y va...
00119     double* xi = tb->t ;
00120     double* xci = xi ;  // Pointeurs
00121     double* xco = xo ;  //  courants
00122     
00123     // k = 0
00124     for (int j=0 ; j<nt ; j++) {
00125         for (int i=0 ; i<nr ; i++ ) {
00126         *xco = cx[0] * (*xci) ;
00127         xci++ ;
00128         xco++ ;
00129         }   // Fin de la boucle sur r
00130     }   // Fin de la boucle sur theta
00131 
00132     // k = 1
00133     xci += nr*nt ;
00134     xco += nr*nt ;
00135     
00136     // k >= 2
00137     for (int k=2 ; k<np+1 ; k++) {
00138     for (int j=0 ; j<nt ; j++) {
00139         for (int i=0 ; i<nr ; i++ ) {
00140         *xco = cx[k] * (*xci) ;
00141         xci++ ;
00142         xco++ ;
00143         }   // Fin de la boucle sur r
00144     }   // Fin de la boucle sur theta
00145     }   // Fin de la boucle sur phi
00146 
00147     // On remet les choses la ou il faut
00148     delete [] tb->t ;
00149     tb->t = xo ;
00150     
00151     // base de developpement
00152     // inchangee
00153 }
00154 

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