ope_poisson_pseudo_1d_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_poisson_pseudo_1d_solh_C[] = "$Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_poisson_pseudo_1d/ope_poisson_pseudo_1d_solh.C,v 1.1 2004/08/24 09:14:48 p_grandclement Exp $" ;
00022 
00023 /*
00024  * $Id: ope_poisson_pseudo_1d_solh.C,v 1.1 2004/08/24 09:14:48 p_grandclement Exp $
00025  * $Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_poisson_pseudo_1d/ope_poisson_pseudo_1d_solh.C,v 1.1 2004/08/24 09:14:48 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         //------------------------------------
00036         // Routine pour les cas non prevus --
00037         //------------------------------------
00038 Tbl _solh_poisson_pseudo_1d_pas_prevu (int, int,double, double, Tbl&) {
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_poisson_pseudo_1d_r_cheb (int n, int l, double alpha, double beta, 
00052                     Tbl& val_lim) {
00053                 
00054 
00055   double echelle = beta / alpha ;
00056   int expo_un = l ;
00057   int expo_deux = -l+1 ;
00058 
00059   val_lim.set(0,0) = pow(echelle-1, double(expo_un)) ;
00060   val_lim.set(0,1) = double(expo_un) * pow(echelle-1, double(expo_un-1))/alpha ;
00061   val_lim.set(0,2) = pow(echelle+1, double(expo_un)) ;
00062   val_lim.set(0,3) = double(expo_un) * pow(echelle+1, double(expo_un-1))/alpha ;
00063     
00064     
00065   val_lim.set(1,0) = pow(echelle-1, double(expo_deux)) ;
00066   val_lim.set(1,1) = double(expo_deux) * pow(echelle-1, double(expo_deux-1))/alpha ;
00067   val_lim.set(1,2) = pow(echelle+1, double(expo_deux)) ;
00068   val_lim.set(1,3) = double(expo_deux) * pow(echelle+1, double(expo_deux-1))/alpha ;
00069   
00070  
00071   Tbl res(2, n) ;
00072   res.set_etat_qcq() ;
00073   double* coloc = new double[n] ;
00074   
00075   int * deg = new int[3] ;
00076   deg[0] = 1 ; 
00077   deg[1] = 1 ;
00078   deg[2] = n ;
00079   
00080   //Construction de la premiere solution homogene :
00081   
00082   for (int i=0 ; i<n ; i++)
00083     coloc[i] = pow(echelle-cos(M_PI*i/(n-1)), double(expo_un)) ;
00084     
00085   cfrcheb(deg, deg, coloc, deg, coloc) ;
00086   for (int i=0 ; i<n ;i++)
00087     res.set(0, i) = coloc[i] ;
00088   
00089   // construction de la seconde solution homogene :
00090   for (int i=0 ; i<n ; i++)
00091     coloc[i] = pow(echelle-cos(M_PI*i/(n-1)), double(expo_deux)) ;
00092   
00093   cfrcheb(deg, deg, coloc, deg, coloc) ;
00094   for (int i=0 ; i<n ;i++)
00095     res.set(1, i) = coloc[i] ;  
00096   
00097   
00098   delete [] coloc ;
00099   delete [] deg ;
00100    
00101   return res ;
00102 }
00103     
00104     
00105         //-------------------
00106            //--  R_CHEBP  ------
00107           //-------------------
00108 
00109 Tbl _solh_poisson_pseudo_1d_r_chebp (int n, int l, double alpha, 
00110                   double, Tbl& val_lim) {
00111   
00112 
00113   val_lim.set(0,0) = (l!=0) ? 1 : 0 ;
00114   val_lim.set(0,1) = (l!=1) ? 0 : 1 ;
00115   val_lim.set(0,2) = 1. ;
00116   val_lim.set(0,3) = double(l)/alpha ;
00117 
00118 
00119   assert (div(l, 2).rem ==0) ;
00120   
00121   Tbl res(n) ;
00122   res.set_etat_qcq() ;
00123   double* coloc = new double[n] ;
00124   
00125   int * deg = new int[3] ;
00126   deg[0] = 1 ; 
00127   deg[1] = 1 ;
00128   deg[2] = n ;
00129   
00130   for (int i=0 ; i<n ; i++)
00131     coloc[i] = pow(sin(M_PI*i/2/(n-1)), double(l)) ;
00132 
00133   cfrchebp(deg, deg, coloc, deg, coloc) ;
00134   for (int i=0 ; i<n ;i++)
00135     res.set(i) = coloc[i] ;
00136   
00137   delete [] coloc ;
00138   delete [] deg ;
00139    
00140   return res ;
00141 }   
00142     
00143             //-------------------
00144            //--  R_CHEBI   -----
00145           //-------------------
00146     
00147 Tbl _solh_poisson_pseudo_1d_r_chebi (int n, int l, 
00148                      double alpha, double, Tbl& val_lim) {
00149 
00150   val_lim.set(0,0) = 0 ;
00151   val_lim.set(0,1) = (l!=1) ? 0 : 1 ;
00152   val_lim.set(0,2) = 1. ;
00153   val_lim.set(0,3) = double(l)/alpha ;
00154 
00155  
00156     
00157   assert (div(l, 2).rem == 1)  ;
00158 
00159   Tbl res(n) ;
00160   res.set_etat_qcq() ;
00161   double* coloc = new double[n] ;
00162     
00163   int * deg = new int[3] ;
00164   deg[0] = 1 ; 
00165   deg[1] = 1 ;
00166   deg[2] = n ;
00167     
00168   for (int i=0 ; i<n ; i++)
00169     coloc[i] = pow(sin(M_PI*i/2/(n-1)), double(l)) ;
00170     
00171   cfrchebi(deg, deg, coloc, deg, coloc) ;
00172   for (int i=0 ; i<n ;i++)
00173     res.set(i) = coloc[i] ;
00174     
00175   delete [] coloc ;
00176   delete [] deg ;
00177    
00178   return res ;
00179 }
00180     
00181 
00182 Tbl Ope_poisson_pseudo_1d::get_solh () const {
00183 
00184   // Routines de derivation
00185   static Tbl (*solh_poisson_pseudo_1d[MAX_BASE]) (int, int, double, double, Tbl&) ;
00186   static int nap = 0 ;
00187   
00188   // Premier appel
00189   if (nap==0) {
00190     nap = 1 ;
00191     for (int i=0 ; i<MAX_BASE ; i++) {
00192       solh_poisson_pseudo_1d[i] = _solh_poisson_pseudo_1d_pas_prevu ;
00193     }
00194     // Les routines existantes
00195     solh_poisson_pseudo_1d[R_CHEB >> TRA_R] = _solh_poisson_pseudo_1d_r_cheb ;
00196     solh_poisson_pseudo_1d[R_CHEBP >> TRA_R] = _solh_poisson_pseudo_1d_r_chebp ;
00197     solh_poisson_pseudo_1d[R_CHEBI >> TRA_R] = _solh_poisson_pseudo_1d_r_chebi ;
00198   }
00199   
00200   Tbl val_lim (2,4) ;
00201   val_lim.set_etat_qcq() ;
00202   Tbl res(solh_poisson_pseudo_1d[base_r](nr,l_quant, alpha, beta, val_lim)) ;
00203 
00204   s_one_minus  = val_lim(0,0) ;
00205   ds_one_minus = val_lim(0,1) ;
00206   s_one_plus   = val_lim(0,2) ;
00207   ds_one_plus  = val_lim(0,3) ;
00208 
00209   s_two_minus  = val_lim(1,0) ;
00210   ds_two_minus = val_lim(1,1) ;
00211   s_two_plus   = val_lim(1,2) ;
00212   ds_two_plus  = val_lim(1,3) ;
00213 
00214   return res ;
00215 }

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