val_solp.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_solp_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/PDE/val_solp.C,v 1.4 2008/02/18 13:53:45 j_novak Exp $" ;
00024 
00025 /*
00026  * $Id: val_solp.C,v 1.4 2008/02/18 13:53:45 j_novak Exp $
00027  * $Log: val_solp.C,v $
00028  * Revision 1.4  2008/02/18 13:53:45  j_novak
00029  * Removal of special indentation instructions.
00030  *
00031  * Revision 1.3  2004/08/24 09:14:44  p_grandclement
00032  * Addition of some new operators, like Poisson in 2d... It now requieres the
00033  * GSL library to work.
00034  *
00035  * Also, the way a variable change is stored by a Param_elliptic is changed and
00036  * no longer uses Change_var but rather 2 Scalars. The codes using that feature
00037  * will requiere some modification. (It should concern only the ones about monopoles)
00038  *
00039  * Revision 1.2  2003/12/11 15:37:09  p_grandclement
00040  * sqrt(2) ----> sqrt(double(2))
00041  *
00042  * Revision 1.1  2003/12/11 14:48:49  p_grandclement
00043  * Addition of ALL (and that is a lot !) the files needed for the general elliptic solver ... UNDER DEVELOPEMENT...
00044  *
00045  * 
00046  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/PDE/val_solp.C,v 1.4 2008/02/18 13:53:45 j_novak Exp $
00047  *
00048  */
00049 
00050 //fichiers includes
00051 #include <stdio.h>
00052 #include <stdlib.h>
00053 #include <math.h>
00054 
00055 #include "proto.h"
00056 #include "matrice.h"
00057 #include "type_parite.h"
00058 
00059 
00060         //------------------------------------
00061         // Routine pour les cas non prevus --
00062         //------------------------------------
00063 Tbl _val_solp_pas_prevu (const Tbl&, double) {
00064 
00065     cout << " Base_r unknown in val_solp."<< endl ;
00066     abort() ;
00067     exit(-1) ;
00068     Tbl res(1) ;
00069     return res;
00070 }
00071     
00072     
00073         //-------------------
00074            //--  R_CHEB   ------
00075           //-------------------
00076 
00077 Tbl _val_solp_r_cheb (const Tbl& sp, double alpha) {
00078   
00079   int nr = sp.get_dim(0) ;
00080   Tbl res(4) ;
00081   res.annule_hard() ;
00082   
00083   // Solution en + 1 
00084   for (int i=0 ; i<nr ; i++)
00085     res.set(0) += sp(i) ;
00086 
00087   // Solution en -1 :
00088   for (int i=0 ; i<nr ; i++)
00089     if (i%2 == 0)
00090       res.set(1) += sp(i) ;
00091     else
00092       res.set(1) -= sp(i) ;
00093 
00094   // Derivee en +1 :
00095   for (int i=0 ; i<nr ; i++)
00096     res.set(2) += sp(i)*i*i/alpha ;
00097 
00098   // Derivee en -1 :
00099   for (int i=0 ; i<nr ; i++)
00100     if (i%2 == 0)
00101       res.set(3) -= sp(i)*i*i/alpha ;
00102     else
00103       res.set(3) += sp(i)*i*i/alpha ;
00104 
00105   res /= sqrt(double(2)) ;
00106   return res ;
00107 }   
00108     
00109         //-------------------
00110            //--  R_CHEBP  ------
00111           //-------------------
00112 
00113 Tbl _val_solp_r_chebp (const Tbl& sp, double alpha) {
00114   
00115   int nr = sp.get_dim(0) ;
00116   Tbl res(4) ;
00117   res.annule_hard() ;
00118   
00119   // Solution en +1 :
00120   for (int i=0 ; i<nr ; i++)
00121     res.set(0) += sp(i) ;
00122 
00123   // Solution en 0 (a priori pas trop utilise)
00124   for (int i=0 ; i<nr ; i++)
00125     if (i%2==0)
00126       res.set(1) += sp(i) ;
00127     else
00128       res.set(1) -= sp(i) ;
00129   
00130   // Derivee en +1 :
00131   for (int i=0 ; i<nr ; i++) 
00132     res.set(2) += sp(i)*(2*i)*(2*i)/alpha ;
00133 
00134   // Derivee en 0
00135   res.set(3) = 0 ;
00136 
00137   res /= sqrt(double(2)) ;
00138   return res ;
00139 }
00140     
00141     
00142             //-------------------
00143            //--  R_CHEBI   -----
00144           //-------------------
00145     
00146 Tbl _val_solp_r_chebi (const Tbl& sp, double alpha) {
00147      
00148   int nr = sp.get_dim(0) ;
00149   Tbl res(4) ;
00150   res.annule_hard() ;
00151   
00152   // Solution en +1 :
00153   for (int i=0 ; i<nr ; i++)
00154     res.set(0) += sp(i) ;
00155 
00156   // Solution en 0 :
00157   res.set(1) = 0 ;
00158 
00159   // Derivee en +1 :
00160   for (int i=0 ; i<nr ; i++) 
00161     res.set(2) += sp(i)*(2*i+1)*(2*i+1)/alpha ;
00162   
00163   // Derivee en 0 :
00164   for (int i=0 ; i<nr ; i++)
00165     if (i%2==0)
00166       res.set(3) += (2*i+1)*sp(i) ;
00167     else
00168       res.set(3) -= (2*i+1)*sp(i) ;
00169 
00170   res /= sqrt(double(2)) ;
00171   return res ;   
00172 }
00173     
00174     
00175     
00176             //-------------------
00177            //--  R_CHEBU   -----
00178           //-------------------
00179     
00180 Tbl _val_solp_r_chebu (const Tbl& sp, double alpha) {
00181  
00182   int nr = sp.get_dim(0) ;
00183   Tbl res(4) ;
00184   res.annule_hard() ;
00185 
00186   // Solution en + 1 
00187   for (int i=0 ; i<nr ; i++)
00188     res.set(0) += sp(i) ;
00189 
00190   // Solution en -1 :
00191   for (int i=0 ; i<nr ; i++)
00192     if (i%2==0)
00193       res.set(1) += sp(i) ;
00194     else
00195       res.set(1) -= sp(i) ;
00196 
00197   // Derivee en +1 c'est zero ca !
00198 
00199   // Derivee en -1 :
00200   for (int i=0 ; i<nr ; i++)
00201     if (i%2==0)
00202       res.set(3) += 4.*alpha*i*i*sp(i) ;
00203     else
00204       res.set(3) -= 4.*alpha*i*i*sp(i) ;
00205  
00206   res /= sqrt(double(2)) ;
00207   return res ;
00208 }
00209     
00210     
00211     
00212     
00213             //-------------------
00214            //--  Fonction   ----
00215           //-------------------
00216           
00217           
00218 Tbl val_solp (const Tbl& sp, double alpha, int base_r) {
00219 
00220         // Routines de derivation
00221     static Tbl (*val_solp[MAX_BASE])(const Tbl&, double) ;
00222     static int nap = 0 ;
00223     
00224     // Premier appel
00225     if (nap==0) {
00226       nap = 1 ;
00227       for (int i=0 ; i<MAX_BASE ; i++) {
00228     val_solp[i] = _val_solp_pas_prevu ;
00229       }
00230       // Les routines existantes
00231       val_solp[R_CHEB >> TRA_R] = _val_solp_r_cheb ;
00232       val_solp[R_CHEBU >> TRA_R] = _val_solp_r_chebu ;
00233       val_solp[R_CHEBP >> TRA_R] = _val_solp_r_chebp ;
00234       val_solp[R_CHEBI >> TRA_R] = _val_solp_r_chebi ;
00235     }
00236     
00237     Tbl res(val_solp[base_r](sp, alpha)) ;
00238     return res ;
00239 }

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