solh_helmholtz_minus.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 solh_helmholtz_minusC[] = "$Header $" ;
00024 
00025 /*
00026  * $Id: solh_helmholtz_minus.C,v 1.7 2008/07/10 11:20:33 p_grandclement Exp $
00027  * $Log: solh_helmholtz_minus.C,v $
00028  * Revision 1.7  2008/07/10 11:20:33  p_grandclement
00029  * mistake fixed in solh_helmholtz_minus
00030  *
00031  * Revision 1.6  2008/07/08 11:45:28  p_grandclement
00032  * Add helmholtz_minus in the nucleus
00033  *
00034  * Revision 1.5  2008/02/18 13:53:43  j_novak
00035  * Removal of special indentation instructions.
00036  *
00037  * Revision 1.4  2004/08/24 10:11:12  p_grandclement
00038  * Correction of the includes of gsl
00039  *
00040  * Revision 1.3  2004/08/24 09:14:44  p_grandclement
00041  * Addition of some new operators, like Poisson in 2d... It now requieres the
00042  * GSL library to work.
00043  *
00044  * Also, the way a variable change is stored by a Param_elliptic is changed and
00045  * no longer uses Change_var but rather 2 Scalars. The codes using that feature
00046  * will requiere some modification. (It should concern only the ones about monopoles)
00047  *
00048  * Revision 1.2  2004/01/15 09:15:37  p_grandclement
00049  * Modification and addition of the Helmholtz operators
00050  *
00051  * Revision 1.1  2003/12/11 14:48:49  p_grandclement
00052  * Addition of ALL (and that is a lot !) the files needed for the general elliptic solver ... UNDER DEVELOPEMENT...
00053  *
00054  * 
00055  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/PDE/solh_helmholtz_minus.C,v 1.7 2008/07/10 11:20:33 p_grandclement Exp $
00056  *
00057  */
00058 
00059 //fichiers includes
00060 #include <stdio.h>
00061 #include <stdlib.h>
00062 #include <math.h>
00063 #include <gsl/gsl_sf_bessel.h>
00064 
00065 #include "proto.h"
00066 #include "matrice.h"
00067 #include "type_parite.h"
00068 
00069 
00070                 //------------------------------------
00071         // Routine pour les cas non prevus --
00072         //------------------------------------
00073 Tbl _solh_helmholtz_minus_pas_prevu (int, int, double, double, double) {
00074 
00075   cout << "Homogeneous solution not implemented in hemlholtz_minus : "<< endl ;
00076   abort() ;
00077   exit(-1) ;
00078   Tbl res(1) ;
00079   return res;
00080 }
00081     
00082 
00083     
00084         //-------------------
00085            //--  R_CHEB   ------
00086           //-------------------
00087 
00088 Tbl _solh_helmholtz_minus_r_cheb (int n, int lq, double alpha, double beta, 
00089                   double masse) {
00090   
00091   assert (masse > 0) ;
00092   
00093   Tbl res(2,n) ;
00094   res.set_etat_qcq() ;
00095   double* coloc = new double[n] ;
00096     
00097   int * deg = new int[3] ;
00098   deg[0] = 1 ; 
00099   deg[1] = 1 ;
00100   deg[2] = n ;
00101   
00102   // First SH
00103   for (int i=0 ; i<n ; i++){
00104     double air = alpha*(-cos(M_PI*i/(n-1))) + beta ;
00105     coloc[i] = gsl_sf_bessel_il_scaled (lq, masse*air)/exp(-masse*air) ;
00106   }
00107 
00108   cfrcheb(deg, deg, coloc, deg, coloc) ;
00109   for (int i=0 ; i<n ;i++)
00110     res.set(0,i) = coloc[i] ;
00111 
00112   // Second SH
00113   for (int i=0 ; i<n ; i++){
00114     double air = alpha*(-cos(M_PI*i/(n-1))) + beta ;
00115     coloc[i] = gsl_sf_bessel_kl_scaled (lq, masse*air) / exp(masse*air) ;
00116   }
00117   
00118   cfrcheb(deg, deg, coloc, deg, coloc) ;
00119   for (int i=0 ; i<n ;i++)
00120     res.set(1,i) = coloc[i] ;
00121 
00122   delete [] deg ;
00123   delete [] coloc ;
00124   return res ;
00125 }
00126         //-------------------
00127            //--  R_CHEBP   ------
00128           //-------------------
00129 
00130 Tbl _solh_helmholtz_minus_r_chebp (int n, int lq, double alpha, double, 
00131                   double masse) {
00132   
00133   assert (masse > 0) ;
00134   
00135   Tbl res(n) ;
00136   res.set_etat_qcq() ;
00137   double* coloc = new double[n] ;
00138     
00139   int * deg = new int[3] ;
00140   deg[0] = 1 ; 
00141   deg[1] = 1 ;
00142   deg[2] = n ;
00143   
00144   // First SH
00145   for (int i=0 ; i<n ; i++){
00146     double air = alpha*(sin(M_PI*i/2./(n-1))) ;
00147     coloc[i] = gsl_sf_bessel_il_scaled (lq, masse*air)/exp(-masse*air) ;
00148   }
00149 
00150   cfrchebp(deg, deg, coloc, deg, coloc) ;
00151   for (int i=0 ; i<n ;i++)
00152     res.set(i) = coloc[i] ;
00153 
00154   delete [] deg ;
00155   delete [] coloc ;
00156   return res ;
00157 }
00158         //-------------------
00159            //--  R_CHEBI   ------
00160           //-------------------
00161 
00162 Tbl _solh_helmholtz_minus_r_chebi (int n, int lq, double alpha, double, 
00163                   double masse) {
00164   
00165   assert (masse > 0) ;
00166   
00167   Tbl res(n) ;
00168   res.set_etat_qcq() ;
00169   double* coloc = new double[n] ;
00170     
00171   int * deg = new int[3] ;
00172   deg[0] = 1 ; 
00173   deg[1] = 1 ;
00174   deg[2] = n ;
00175   
00176   // First SH
00177   for (int i=0 ; i<n ; i++){
00178     double air = alpha*(sin(M_PI*i/2./(n-1))) ;
00179     coloc[i] = gsl_sf_bessel_il_scaled (lq, masse*air)/exp(-masse*air) ;
00180   }
00181 
00182   cfrchebi(deg, deg, coloc, deg, coloc) ;
00183   for (int i=0 ; i<n ;i++)
00184     res.set(i) = coloc[i] ;
00185 
00186   delete [] deg ;
00187   delete [] coloc ;
00188   return res ;
00189 }
00190 
00191         //-------------------
00192            //--  R_CHEBU  ------
00193           //-------------------
00194 
00195 Tbl _solh_helmholtz_minus_r_chebu (int n, int lq, 
00196                    double alpha, double, double masse) {
00197   
00198   assert (masse > 0) ;
00199   
00200   Tbl res(n) ;
00201   res.set_etat_qcq() ;
00202   double* coloc = new double[n] ;
00203     
00204   int * deg = new int[3] ;
00205   deg[0] = 1 ; 
00206   deg[1] = 1 ;
00207   deg[2] = n ;
00208   
00209   for (int i=0 ; i<n-1 ; i++){
00210     double air = 1./(alpha*(-1-cos(M_PI*i/(n-1)))) ;
00211     coloc[i] = gsl_sf_bessel_kl_scaled (lq, masse*air) / exp(masse*air) ;
00212   }
00213   coloc[n-1] = 0 ;
00214   
00215   cfrcheb(deg, deg, coloc, deg, coloc) ;
00216   for (int i=0 ; i<n ;i++)
00217     res.set(i) = coloc[i] ;
00218 
00219   delete [] deg ;
00220   delete [] coloc ;
00221   return res ;
00222 }
00223 
00224 
00225             //-------------------
00226            //--  Fonction   ----
00227           //-------------------
00228           
00229           
00230 Tbl solh_helmholtz_minus (int n, int lq, double alpha, double beta, 
00231               double masse, int base_r) {
00232 
00233   // Routines de derivation
00234   static Tbl (*solh_helmholtz_minus[MAX_BASE])(int, int, double, double, double) ;
00235   static int nap = 0 ;
00236   
00237   // Premier appel
00238   if (nap==0) {
00239     nap = 1 ;
00240     for (int i=0 ; i<MAX_BASE ; i++) {
00241       solh_helmholtz_minus[i] = _solh_helmholtz_minus_pas_prevu ;
00242     }
00243     // Les routines existantes
00244     solh_helmholtz_minus[R_CHEB >> TRA_R] = _solh_helmholtz_minus_r_cheb ;
00245     solh_helmholtz_minus[R_CHEBU >> TRA_R] = _solh_helmholtz_minus_r_chebu ;
00246     solh_helmholtz_minus[R_CHEBP >> TRA_R] = _solh_helmholtz_minus_r_chebp ;
00247     solh_helmholtz_minus[R_CHEBI >> TRA_R] = _solh_helmholtz_minus_r_chebi ;
00248   }
00249     
00250   Tbl res(solh_helmholtz_minus[base_r](n, lq, alpha, beta, masse)) ;
00251   return res ;
00252 }

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