helmholtz_plus_mat.C

00001 /*
00002  *   Copyright (c) 1999-2001 Philippe Grandclement
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 helmholtz_plus_mat_C[] = "$$" ;
00024 
00025 /*
00026  * $Id: helmholtz_plus_mat.C,v 1.4 2007/05/06 10:48:12 p_grandclement Exp $
00027  * $Log: helmholtz_plus_mat.C,v $
00028  * Revision 1.4  2007/05/06 10:48:12  p_grandclement
00029  * Modification of a few operators for the vorton project
00030  *
00031  * Revision 1.3  2004/01/15 09:15:37  p_grandclement
00032  * Modification and addition of the Helmholtz operators
00033  *
00034  * Revision 1.2  2003/12/11 15:57:26  p_grandclement
00035  * include stdlib.h encore ...
00036  *
00037  * Revision 1.1  2003/12/11 14:48:49  p_grandclement
00038  * Addition of ALL (and that is a lot !) the files needed for the general elliptic solver ... UNDER DEVELOPEMENT...
00039  *
00040  * 
00041  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/PDE/helmholtz_plus_mat.C,v 1.4 2007/05/06 10:48:12 p_grandclement Exp $
00042  *
00043  */
00044 #include <stdlib.h>
00045 
00046 #include "matrice.h"
00047 #include "type_parite.h"
00048 #include "proto.h"
00049 
00050                      //-----------------------------------
00051                      // Routine pour les cas non prevus -- 
00052                      //-----------------------------------
00053 
00054 Matrice _helmholtz_plus_mat_pas_prevu(int, int, double, double, double) {
00055   cout << "Helmholtz plus : base not implemented..." << endl ;
00056   abort() ;
00057   exit(-1) ;
00058   Matrice res(1, 1) ;
00059   return res;
00060 }
00061 
00062 
00063 
00064                     //-------------------------
00065                     //--   CAS R_CHEBP    -----
00066            //--------------------------
00067             
00068 
00069 Matrice _helmholtz_plus_mat_r_chebp (int n, int lq, double alpha, double, 
00070                      double masse) {
00071   assert (masse > 0) ;
00072  
00073   Matrice dd(n, n) ;
00074   dd.set_etat_qcq() ;
00075   Matrice xd(n, n) ;
00076   xd.set_etat_qcq() ;
00077   Matrice xx(n, n) ;
00078   xx.set_etat_qcq() ;
00079   Matrice sx2(n, n) ;
00080   sx2.set_etat_qcq() ;
00081 
00082   double* vect  = new double[n] ;
00083   
00084   for (int i=0 ; i<n ; i++) {
00085     for (int j=0 ; j<n ; j++)
00086       vect[j] = 0 ;
00087     vect[i] = 1 ;
00088     d2sdx2_1d (n, &vect, R_CHEBP) ;
00089     for (int j=0 ; j<n ; j++)
00090       dd.set(j, i) = vect[j] ; 
00091   }
00092   
00093   for (int i=0 ; i<n ; i++) {
00094     for (int j=0 ; j<n ; j++)
00095       vect[j] = 0 ;
00096     vect[i] = 1 ;
00097     sxdsdx_1d (n, &vect, R_CHEBP) ;
00098     for (int j=0 ; j<n ; j++)
00099       xd.set(j, i) = vect[j] ;  
00100   }
00101    
00102   for (int i=0 ; i<n ; i++) {
00103     for (int j=0 ; j<n ; j++)
00104       vect[j] = 0 ;
00105     vect[i] = 1 ;
00106     sx2_1d (n, &vect, R_CHEBP) ;
00107     for (int j=0 ; j<n ; j++)
00108       sx2.set(j, i) = vect[j] ;  
00109   }
00110 
00111   for (int i=0 ; i<n ; i++) {
00112     for (int j=0 ; j<n ; j++)
00113       xx.set(i,j) = 0 ;
00114     xx.set(i, i) = 1 ;  
00115   }
00116   
00117   delete [] vect ;
00118     
00119   Matrice res(n, n) ;
00120   res = dd+2*xd-lq*(lq+1)*sx2+masse*masse*alpha*alpha*xx ;
00121   
00122   return res ;
00123 }
00124     
00125 
00126                     //-------------------------
00127             //--   CAS R_CHEB   -----
00128             //------------------------
00129 
00130 Matrice _helmholtz_plus_mat_r_cheb (int n, int lq, double alpha, double beta, 
00131                      double masse) {
00132 
00133   
00134 
00135   assert (masse > 0) ;
00136  
00137   double echelle = beta / alpha ;
00138   
00139   Matrice dd(n, n) ;
00140   dd.set_etat_qcq() ;
00141   Matrice xd(n, n) ;
00142   xd.set_etat_qcq() ;
00143   Matrice xx(n, n) ;
00144   xx.set_etat_qcq() ;
00145 
00146   double* vect = new double[n] ;
00147   
00148   for (int i=0 ; i<n ; i++) {
00149     for (int j=0 ; j<n ; j++)
00150       vect[j] = 0 ;
00151     vect[i] = 1 ;
00152     d2sdx2_1d (n, &vect, R_CHEB) ;  // appel dans le cas fin
00153     vect[i] += masse*masse*alpha*alpha ;
00154     for (int j=0 ; j<n ; j++)
00155       dd.set(j, i) = vect[j]*echelle*echelle ;
00156   }
00157   
00158   for (int i=0 ; i<n ; i++) {
00159     for (int j=0 ; j<n ; j++)
00160       vect[j] = 0 ;
00161     vect[i] = 1 ;
00162     d2sdx2_1d (n, &vect, R_CHEB) ;  // appel dans le cas fin
00163     vect[i] += masse*masse*alpha*alpha ;
00164     multx_1d (n, &vect, R_CHEB) ;
00165     for (int j=0 ; j<n ; j++)
00166       dd.set(j, i) += 2*echelle*vect[j] ;
00167   }
00168   
00169   for (int i=0 ; i<n ; i++) {
00170     for (int j=0 ; j<n ; j++)
00171       vect[j] = 0 ;
00172     vect[i] = 1 ;
00173     d2sdx2_1d (n, &vect, R_CHEB) ;  // appel dans le cas fin
00174     vect[i] += masse*masse*alpha*alpha ;
00175     multx_1d (n, &vect, R_CHEB) ;
00176     multx_1d (n, &vect, R_CHEB) ;
00177     for (int j=0 ; j<n ; j++)
00178       dd.set(j, i) += vect[j] ;
00179   }
00180   
00181   for (int i=0 ; i<n ; i++) {
00182     for (int j=0 ; j<n ; j++)
00183     vect[j] = 0 ;
00184     vect[i] = 1 ;
00185     sxdsdx_1d (n, &vect, R_CHEB) ;
00186     for (int j=0 ; j<n ; j++)
00187       xd.set(j, i) = vect[j]*echelle ;
00188   }
00189   
00190   for (int i=0 ; i<n ; i++) {
00191     for (int j=0 ; j<n ; j++)
00192       vect[j] = 0 ;
00193     vect[i] = 1 ;
00194     sxdsdx_1d (n, &vect, R_CHEB) ;
00195     multx_1d (n, &vect, R_CHEB) ;
00196     for (int j=0 ; j<n ; j++)
00197       xd.set(j, i) += vect[j] ;
00198   }
00199 
00200   for (int i=0 ; i<n ; i++) {
00201       for (int j=0 ; j<n ; j++)
00202     vect[j] = 0 ;
00203       vect[i] = 1 ;
00204       sx2_1d (n, &vect, R_CHEB) ;
00205       for (int j=0 ; j<n ; j++)
00206     xx.set(j, i) = vect[j] ;
00207     }
00208 
00209   delete [] vect ;
00210   
00211   Matrice res(n, n) ;
00212   res = dd+2*xd - lq*(lq+1)*xx;  
00213 
00214   return res ;
00215 }
00216 
00217     
00218                 //--------------------------
00219         //- La routine a appeler  ---
00220             //----------------------------
00221 
00222 Matrice helmholtz_plus_mat(int n, int lq, double alpha, double beta, double masse, 
00223                 int base_r)
00224 {
00225   
00226   // Routines de derivation
00227   static Matrice (*helmholtz_plus_mat[MAX_BASE])(int, int, double, double, double);
00228   static int nap = 0 ;
00229   
00230   // Premier appel
00231   if (nap==0) {
00232     nap = 1 ;
00233     for (int i=0 ; i<MAX_BASE ; i++) {
00234       helmholtz_plus_mat[i] = _helmholtz_plus_mat_pas_prevu ;
00235     }
00236     // Les routines existantes
00237     helmholtz_plus_mat[R_CHEB >> TRA_R] = _helmholtz_plus_mat_r_cheb ;
00238     helmholtz_plus_mat[R_CHEBP >> TRA_R] = _helmholtz_plus_mat_r_chebp ;
00239   }
00240   
00241   Matrice res(helmholtz_plus_mat[base_r](n, lq, alpha, beta, masse)) ;
00242   return res ;
00243 }
00244 

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