val_solh.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 val_solh_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/PDE/val_solh.C,v 1.3 2008/02/18 13:53:45 j_novak Exp $" ;
00024 
00025 /*
00026  * $Id: val_solh.C,v 1.3 2008/02/18 13:53:45 j_novak Exp $
00027  * $Log: val_solh.C,v $
00028  * Revision 1.3  2008/02/18 13:53:45  j_novak
00029  * Removal of special indentation instructions.
00030  *
00031  * Revision 1.2  2003/12/11 15:37:09  p_grandclement
00032  * sqrt(2) ----> sqrt(double(2))
00033  *
00034  * Revision 1.1  2003/12/11 14:48:49  p_grandclement
00035  * Addition of ALL (and that is a lot !) the files needed for the general elliptic solver ... UNDER DEVELOPEMENT...
00036  *
00037  * 
00038  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/PDE/val_solh.C,v 1.3 2008/02/18 13:53:45 j_novak Exp $
00039  *
00040  */
00041 
00042 //fichiers includes
00043 #include <stdio.h>
00044 #include <stdlib.h>
00045 #include <math.h>
00046 
00047 #include "proto.h"
00048 #include "matrice.h"
00049 #include "type_parite.h"
00050 
00051 
00052         //------------------------------------
00053         // Routine pour les cas non prevus --
00054         //------------------------------------
00055 Tbl _val_solh_pas_prevu (int, double, double) {
00056 
00057     cout << " Solution homogene pas prevue ..... : "<< endl ;
00058     abort() ;
00059     exit(-1) ;
00060     Tbl res(1) ;
00061     return res;
00062 }
00063     
00064     
00065         //-------------------
00066            //--  R_CHEB   ------
00067           //-------------------
00068 
00069 Tbl _val_solh_r_cheb (int l, double alpha, double beta) {
00070   
00071   double echelle = beta/alpha ;
00072 
00073   Tbl res(2, 4) ;
00074   res.set_etat_qcq() ;
00075   
00076   // Solution 1 : (x+echelle)^l
00077   res.set(0,0) = pow(1.+echelle, l) ;
00078   res.set(0,1) = pow(-1.+echelle, l) ;
00079   res.set(0,2) = pow(1.+echelle, l-1)*l/alpha ;
00080   res.set(0,3) = pow(-1.+echelle, l-1)*l/alpha ;
00081   
00082   // Solution 2 : 1./(x+echelle)^(l+1)
00083   res.set(1,0) = 1./pow(1.+echelle, l+1) ;
00084   res.set(1,1) = 1./pow(-1.+echelle, l+1) ;
00085   res.set(1,2) = -1./pow(1.+echelle, l+2)*(l+1)/alpha ;
00086   res.set(1,3) = -1./pow(-1.+echelle, l+2)*(l+1)/alpha ;
00087 
00088   res /= sqrt(double(2)) ;
00089   return res ;
00090 }   
00091     
00092         //-------------------
00093            //--  R_CHEBP  ------
00094           //-------------------
00095 
00096 Tbl _val_solh_r_chebp (int l, double alpha, double) {
00097   
00098   Tbl res(4) ;
00099   res.set_etat_qcq() ;
00100   
00101   // Solution : x^l
00102   res.set(0) = 1. ;
00103   res.set(1) = (l==0) ? 1. : 0. ;
00104   res.set(2) = 1./alpha*l ;
00105   res.set(3) = (l==1) ? 1 : 0 ;
00106   
00107   res /= sqrt(double(2)) ;
00108   return res ;
00109 }
00110     
00111     
00112             //-------------------
00113            //--  R_CHEBI   -----
00114           //-------------------
00115     
00116 Tbl _val_solh_r_chebi (int l, double alpha, double) {
00117         
00118   Tbl res(4) ;
00119   res.set_etat_qcq() ;
00120   
00121   // Solution : x^l
00122   res.set(0) = 1. ;
00123   res.set(1) = (l==0) ? 1. : 0 ;
00124   res.set(2) = 1./alpha*l ;
00125   res.set(3) = (l==1) ? 1 : 0. ;
00126   
00127   res /= sqrt(double(2)) ;
00128   return res ;
00129 }
00130     
00131     
00132     
00133             //-------------------
00134            //--  R_CHEBU   -----
00135           //-------------------
00136     
00137 Tbl _val_solh_r_chebu (int l, double alpha, double) {
00138    
00139   Tbl res(4) ;
00140   res.set_etat_qcq() ;
00141   
00142   // Solution : 1/(x-1)^(l+1)
00143   res.set(0) = 0 ; 
00144   res.set(1) = pow(-2., l+1)/sqrt(double(2)) ; 
00145   res.set(2) = 0. ; 
00146   res.set(3) = -alpha*(l+1)*pow(-2., l+2)/sqrt(double(2)) ;        
00147 
00148   return res ;
00149 }
00150     
00151     
00152     
00153     
00154             //-------------------
00155            //--  Fonction   ----
00156           //-------------------
00157           
00158           
00159 Tbl val_solh(int l, double alpha, double beta, int base_r) {
00160 
00161         // Routines de derivation
00162     static Tbl (*val_solh[MAX_BASE])(int, double, double) ;
00163     static int nap = 0 ;
00164 
00165         // Premier appel
00166     if (nap==0) {
00167     nap = 1 ;
00168     for (int i=0 ; i<MAX_BASE ; i++) {
00169         val_solh[i] = _val_solh_pas_prevu ;
00170     }
00171         // Les routines existantes
00172     val_solh[R_CHEB >> TRA_R] = _val_solh_r_cheb ;
00173     val_solh[R_CHEBU >> TRA_R] = _val_solh_r_chebu ;
00174     val_solh[R_CHEBP >> TRA_R] = _val_solh_r_chebp ;
00175     val_solh[R_CHEBI >> TRA_R] = _val_solh_r_chebi ;
00176     }
00177     
00178     Tbl res(val_solh[base_r](l, alpha, beta)) ;
00179     return res ;
00180 }

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