ope_helmholtz_minus_2d_solh.C

00001 /*
00002  *   Copyright (c) 2004 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_solh_C[] = "$Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_helmholtz_minus_2d/ope_helmholtz_minus_2d_solh.C,v 1.2 2004/08/24 10:11:13 p_grandclement Exp $" ;
00022 
00023 /*
00024  * $Id: ope_helmholtz_minus_2d_solh.C,v 1.2 2004/08/24 10:11:13 p_grandclement Exp $
00025  * $Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_helmholtz_minus_2d/ope_helmholtz_minus_2d_solh.C,v 1.2 2004/08/24 10:11:13 p_grandclement Exp $
00026  *
00027  */
00028 #include <math.h>
00029 #include <stdlib.h>
00030 #include <gsl/gsl_sf_bessel.h>
00031 
00032 #include "proto.h"
00033 #include "ope_elementary.h"
00034 
00035         //------------------------------------
00036         // Routine pour les cas non prevus --
00037         //------------------------------------
00038 Tbl _solh_helmholtz_minus_2d_pas_prevu (int, int, double, double, double) {
00039 
00040     cout << " Solution homogene pas prevue ..... : "<< endl ;
00041     exit(-1) ;
00042     Tbl res(1) ;
00043     return res;
00044 }
00045     
00046     
00047         //-------------------
00048            //--  R_CHEB   ------
00049           //-------------------
00050 
00051 Tbl _solh_helmholtz_minus_2d_r_cheb (int n, int l, double masse, double alpha, double beta) {
00052                 
00053 
00054   double echelle = beta / alpha ;
00055 
00056   Tbl res(2, n) ;
00057   res.set_etat_qcq() ;
00058   double* coloc = new double[n] ;
00059   
00060   int * deg = new int[3] ;
00061   deg[0] = 1 ; 
00062   deg[1] = 1 ;
00063   deg[2] = n ;
00064   
00065   //Construction de la premiere solution homogene :
00066   for (int i=0 ; i<n ; i++)
00067     coloc[i] = gsl_sf_bessel_In (l, masse*alpha*(echelle-cos(M_PI*i/(n-1)))) ;
00068     
00069   cfrcheb(deg, deg, coloc, deg, coloc) ;
00070   for (int i=0 ; i<n ;i++)
00071     res.set(0, i) = coloc[i] ;
00072     
00073   // construction de la seconde solution homogene :
00074   for (int i=0 ; i<n ; i++) 
00075     coloc[i] = gsl_sf_bessel_Kn (l, masse*alpha*(echelle-cos(M_PI*i/(n-1)))) ;
00076 
00077   cfrcheb(deg, deg, coloc, deg, coloc) ;
00078   for (int i=0 ; i<n ;i++)
00079     res.set(1, i) = coloc[i] ;  
00080         
00081   delete [] coloc ;
00082   delete [] deg ;
00083    
00084   return res ;
00085 }   
00086 
00087             //-------------------
00088            //--  R_CHEBU   -----
00089           //-------------------
00090     
00091 Tbl _solh_helmholtz_minus_2d_r_chebu (int n, int l, double masse, 
00092                       double alpha, double) {
00093     
00094  
00095     Tbl res(n) ;
00096     res.set_etat_qcq() ;
00097     double* coloc = new double[n] ;
00098     
00099     int * deg = new int[3] ;
00100     deg[0] = 1 ; 
00101     deg[1] = 1 ;
00102     deg[2] = n ;
00103     
00104     for (int i=0 ; i<n-1 ; i++)
00105       coloc[i] = gsl_sf_bessel_Kn (l, masse/alpha/(-1-cos(M_PI*i/(n-1)))) ;
00106     coloc[n-1] = 0 ;
00107 
00108     cfrcheb(deg, deg, coloc, deg, coloc) ;
00109     for (int i=0 ; i<n ;i++)
00110       res.set(i) = coloc[i] ;
00111      
00112     delete [] coloc ;
00113     delete [] deg ;
00114     
00115     return res ;
00116 }
00117 
00118 
00119 Tbl Ope_helmholtz_minus_2d::get_solh () const {
00120 
00121   // Routines de derivation
00122   static Tbl (*solh_helmholtz_minus_2d[MAX_BASE]) (int, int, double, double, double) ;
00123   static int nap = 0 ;
00124   
00125   // Premier appel
00126   if (nap==0) {
00127     nap = 1 ;
00128     for (int i=0 ; i<MAX_BASE ; i++) {
00129       solh_helmholtz_minus_2d[i] = _solh_helmholtz_minus_2d_pas_prevu ;
00130     }
00131     // Les routines existantes
00132     solh_helmholtz_minus_2d[R_CHEB >> TRA_R] = _solh_helmholtz_minus_2d_r_cheb ;
00133     solh_helmholtz_minus_2d[R_CHEBU >> TRA_R] = _solh_helmholtz_minus_2d_r_chebu ;
00134   }
00135   
00136   Tbl res(solh_helmholtz_minus_2d[base_r](nr,l_quant, masse, alpha, beta)) ;
00137 
00138   // Un peu tricky...
00139   
00140   if (res.get_ndim() == 1) {
00141     Tbl val_lim (val_solp (res, alpha, base_r)) ;
00142     val_lim *= sqrt(double(2)) ;
00143 
00144     s_one_plus   = val_lim(0) ;
00145     s_one_minus  = val_lim(1) ; 
00146     ds_one_plus  = val_lim(2) ;
00147     ds_one_minus = val_lim(3) ;
00148 
00149   }
00150   else {
00151     Tbl auxi (nr) ;
00152     auxi.set_etat_qcq() ;
00153     for (int i=0 ; i<nr ; i++)
00154       auxi.set(i) = res(0,i) ;
00155 
00156     Tbl val_one  (val_solp (auxi, alpha, base_r)) ; 
00157     val_one *= sqrt(double(2)) ;
00158 
00159     s_one_plus   = val_one(0) ;
00160     s_one_minus  = val_one(1) ; 
00161     ds_one_plus  = val_one(2) ;
00162     ds_one_minus = val_one(3) ;
00163 
00164     for (int i=0 ; i<nr ; i++)
00165       auxi.set(i) = res(1,i) ;
00166 
00167     Tbl val_two  (val_solp (auxi, alpha, base_r)) ;
00168     val_two *= sqrt(double(2)) ;
00169 
00170     s_two_plus   = val_two(0) ;
00171     s_two_minus  = val_two(1) ; 
00172     ds_two_plus  = val_two(2) ;
00173     ds_two_minus = val_two(3) ;   
00174 
00175   }
00176   
00177   return res ;
00178 }

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