ope_helmholtz_minus_2d_mat.C

00001 /*
00002  *   Copyright (c) 2003 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 version 2
00008  *   as published by the Free Software Foundation.
00009  *
00010  *   LORENE is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with LORENE; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  *
00019  */
00020 
00021 char ope_helmholtz_minus_2d_mat_C[] = "$Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_helmholtz_minus_2d/ope_helmholtz_minus_2d_mat.C,v 1.1 2004/08/24 09:14:46 p_grandclement Exp $" ;
00022 
00023 /*
00024  * $Id: ope_helmholtz_minus_2d_mat.C,v 1.1 2004/08/24 09:14:46 p_grandclement Exp $
00025  * $Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_helmholtz_minus_2d/ope_helmholtz_minus_2d_mat.C,v 1.1 2004/08/24 09:14:46 p_grandclement Exp $
00026  *
00027  */
00028 #include <math.h>
00029 #include <stdlib.h>
00030 
00031 #include "proto.h"
00032 #include "ope_elementary.h"
00033 
00034         //-----------------------------------
00035         // Routine pour les cas non prevus --
00036         //-----------------------------------
00037 
00038 Matrice _helmholtz_minus_2d_mat_pas_prevu(int, int, double, double, 
00039                       double, int) {
00040     cout << "Operateur pas prevu..." << endl ;
00041     abort() ;
00042     exit(-1) ;
00043     Matrice res(1, 1) ;
00044     return res;
00045 }
00046 
00047 
00048 
00049            //-------------------------
00050            //--   CAS R_CHEBU    -----
00051            //-------------------------
00052 
00053 Matrice _helmholtz_minus_2d_mat_r_chebu_deux(int,int,double, double) ;
00054 
00055 Matrice _helmholtz_minus_2d_mat_r_chebu( int n, int l, double masse, 
00056                      double alpha, double, int puis) {
00057   Matrice res(n-2, n-2) ; 
00058   res.set_etat_qcq() ;
00059   switch (puis) {
00060   case 2 :
00061     res = _helmholtz_minus_2d_mat_r_chebu_deux (n, l, masse, alpha) ;
00062     break ;
00063   default :
00064     abort() ;
00065     exit(-1) ;
00066   }
00067   return res ;
00068 }
00069 
00070     //Cas ou dzpuis = 2
00071 Matrice _helmholtz_minus_2d_mat_r_chebu_deux (int n, int l, double masse, 
00072                           double alpha) {
00073         
00074   Matrice res(n-2, n-2) ;
00075   res.set_etat_qcq() ;
00076   double* vect = new double[n] ;
00077   double* vect_bis = new double[n] ;
00078   double* vect_dd = new double[n] ;
00079   double* vect_d = new double[n] ;
00080   
00081   for (int i=0 ; i<n-2 ; i++) {
00082     for (int j=0 ; j<n ; j++)
00083       vect[j] = 0 ;
00084     vect[i] = 2*i+3 ;
00085     vect[i+1] = -4*i-4 ;
00086     vect[i+2] = 2*i+1 ;
00087 
00088     // Der sec.
00089     for (int j=0 ; j<n ; j++)
00090       vect_bis[j] = vect[j] ;
00091     
00092     d2sdx2_1d (n, &vect_bis, R_CHEBU) ;  // appel dans le cas unsurr
00093     mult2_xm1_1d_cheb (n, vect_bis, vect_dd) ; // multiplication par (x-1)^2
00094     
00095     // Der simple
00096     for (int j=0 ; j<n ; j++)
00097       vect_bis[j] = vect[j] ;
00098 
00099     dsdx_1d (n, &vect_bis, R_CHEBU) ;  // appel dans le cas unsurr
00100     mult_xm1_1d_cheb (n, vect_bis, vect_d) ; // multiplication par (x-1)
00101     
00102     // Mass term
00103     for (int j=0 ; j<n ; j++)
00104       vect_bis[j] = vect[j] ;
00105     sx2_1d (n, &vect_bis, R_CHEBU) ;
00106     
00107     for (int j=0 ; j<n-2 ; j++)
00108       res.set(j,i) = vect_dd[j] + vect_d[j] - l*l*vect[j] - masse*masse/alpha/alpha*vect_bis[j] ; 
00109   }
00110 
00111   delete [] vect ;
00112   delete [] vect_bis ;
00113   delete [] vect_dd ;
00114   delete [] vect_d ;
00115   
00116   return res ;
00117 } 
00118 
00119 
00120            //-------------------------
00121            //--   CAS R_CHEB    -----
00122            //-----------------------
00123             
00124 
00125 Matrice _helmholtz_minus_2d_mat_r_cheb (int n, int l, double masse, 
00126                     double alf, double bet, int) {
00127             
00128   double echelle = bet / alf ;
00129 
00130   Matrice dd(n, n) ;
00131   dd.set_etat_qcq() ;
00132   Matrice xd(n, n) ;
00133   xd.set_etat_qcq() ;
00134   Matrice xx(n, n) ;
00135   xx.set_etat_qcq() ;
00136   
00137   double* vect = new double[n] ;
00138   
00139   for (int i=0 ; i<n ; i++) {
00140     for (int j=0 ; j<n ; j++)
00141       vect[j] = 0 ;
00142     vect[i] = 1 ;
00143     d2sdx2_1d (n, &vect, R_CHEB) ;  // appel dans le cas fin
00144     vect[i] -= masse*masse*alf*alf  ;
00145     for (int j=0 ; j<n ; j++)
00146       dd.set(j, i) = vect[j]*echelle*echelle ;
00147   }
00148   
00149   for (int i=0 ; i<n ; i++) {
00150     for (int j=0 ; j<n ; j++)
00151       vect[j] = 0 ;
00152     vect[i] = 1 ;
00153     d2sdx2_1d (n, &vect, R_CHEB) ;  // appel dans le cas fin
00154     vect[i] -= masse*masse*alf*alf ;
00155     multx_1d (n, &vect, R_CHEB) ;
00156     for (int j=0 ; j< n ; j++)
00157       dd.set(j, i) += 2*echelle*vect[j] ;
00158   }
00159   
00160   for (int i=0 ; i<n ; i++) {
00161     for (int j=0 ; j<n ; j++)
00162       vect[j] = 0 ;
00163     vect[i] = 1 ;
00164     d2sdx2_1d (n, &vect, R_CHEB) ;  // appel dans le cas fin
00165     vect[i] -= masse*masse*alf*alf ;
00166     multx_1d (n, &vect, R_CHEB) ;
00167     multx_1d (n, &vect, R_CHEB) ;
00168     for (int j=0 ; j<n ; j++)
00169       dd.set(j, i) += vect[j] ;
00170   }
00171   
00172   for (int i=0 ; i<n ; i++) {
00173     for (int j=0 ; j<n ; j++)
00174       vect[j] = 0 ;
00175     vect[i] = 1 ;
00176     sxdsdx_1d (n, &vect, R_CHEB) ;
00177     for (int j=0 ; j<n ; j++)
00178       xd.set(j, i) = vect[j]*echelle ;
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     multx_1d (n, &vect, R_CHEB) ;
00187     for (int j=0 ; j<(n>i+1 ? i+1 : n) ; j++)
00188       xd.set(j, i) += vect[j] ;
00189   }
00190   
00191   for (int i=0 ; i<n ; i++) {
00192     for (int j=0 ; j<n ; j++)
00193       vect[j] = 0 ;
00194     vect[i] = 1 ;
00195     sx2_1d (n, &vect, R_CHEB) ;
00196     for (int j=0 ; j<n ; j++)
00197       xx.set(j, i) = vect[j] ;
00198   }
00199   
00200   delete [] vect ;
00201   
00202   Matrice res(n, n) ;
00203   res = dd+xd-l*l*xx ;
00204   
00205   return res ;
00206 } 
00207     
00208 
00209 void Ope_helmholtz_minus_2d::do_ope_mat() const {
00210   if (ope_mat != 0x0) 
00211     delete ope_mat ;
00212 
00213   // Routines de derivation
00214   static Matrice (*helmholtz_minus_2d_mat[MAX_BASE])(int, int, double, 
00215                              double, double, int);
00216   static int nap = 0 ;
00217   
00218   // Premier appel
00219   if (nap==0) {
00220     nap = 1 ;
00221     for (int i=0 ; i<MAX_BASE ; i++) {
00222       helmholtz_minus_2d_mat[i] = _helmholtz_minus_2d_mat_pas_prevu ;
00223     }
00224     // Les routines existantes
00225     helmholtz_minus_2d_mat[R_CHEB >> TRA_R] = _helmholtz_minus_2d_mat_r_cheb ;
00226     helmholtz_minus_2d_mat[R_CHEBU >> TRA_R] = _helmholtz_minus_2d_mat_r_chebu ;
00227   }
00228   ope_mat = new Matrice(helmholtz_minus_2d_mat[base_r](nr, l_quant, masse, 
00229                                alpha, beta, dzpuis)) ;
00230 }

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