comb_lin_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 comb_lin_helmholtz_minusC[] = "$Header $" ;
00024 
00025 /*
00026  * $Id: comb_lin_helmholtz_minus.C,v 1.5 2008/07/08 11:45:28 p_grandclement Exp $
00027  * $Log: comb_lin_helmholtz_minus.C,v $
00028  * Revision 1.5  2008/07/08 11:45:28  p_grandclement
00029  * Add helmholtz_minus in the nucleus
00030  *
00031  * Revision 1.4  2008/02/18 13:53:42  j_novak
00032  * Removal of special indentation instructions.
00033  *
00034  * Revision 1.3  2004/08/24 09:14:44  p_grandclement
00035  * Addition of some new operators, like Poisson in 2d... It now requieres the
00036  * GSL library to work.
00037  *
00038  * Also, the way a variable change is stored by a Param_elliptic is changed and
00039  * no longer uses Change_var but rather 2 Scalars. The codes using that feature
00040  * will requiere some modification. (It should concern only the ones about monopoles)
00041  *
00042  * Revision 1.2  2004/01/15 09:15:37  p_grandclement
00043  * Modification and addition of the Helmholtz operators
00044  *
00045  * Revision 1.1  2003/12/11 14:48:49  p_grandclement
00046  * Addition of ALL (and that is a lot !) the files needed for the general elliptic solver ... UNDER DEVELOPEMENT...
00047  *
00048  * 
00049  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/PDE/comb_lin_helmholtz_minus.C,v 1.5 2008/07/08 11:45:28 p_grandclement Exp $
00050  *
00051  */
00052 
00053 //fichiers includes
00054 #include <stdio.h>
00055 #include <stdlib.h>
00056 #include <math.h>
00057 
00058 #include "matrice.h"
00059 #include "type_parite.h"
00060 #include "proto.h"
00061 
00062 
00063 // Version Matrice --> Matrice
00064 Matrice _cl_helmholtz_minus_pas_prevu (const Matrice& so) {
00065   cout << "CL Helmholtz minus not implemented" << endl ;
00066     abort() ;
00067     exit(-1) ;
00068     return so;
00069 }
00070 
00071 
00072 
00073         //-------------------
00074            //--  R_CHEB   ------
00075           //-------------------
00076 
00077 Matrice _cl_helmholtz_minus_r_cheb (const Matrice& source) {
00078 
00079   int n = source.get_dim(0) ;
00080   assert (n==source.get_dim(1)) ;
00081    
00082   Matrice barre(source) ;
00083   int dirac = 1 ;
00084   for (int i=0 ; i<n-2 ; i++) {
00085     for (int j=0 ; j<n ; j++)
00086       barre.set(i, j) = ((1+dirac)*source(i, j)-source(i+2, j))
00087     /(i+1) ;
00088     if (i==0) dirac = 0 ;
00089   }
00090   
00091   Matrice res(barre) ;
00092   for (int i=0 ; i<n-4 ; i++)
00093     for (int j=0 ; j<n ; j++)
00094       res.set(i, j) = barre(i, j)-barre(i+2, j) ;
00095   
00096   return res ;
00097 } 
00098  
00099 
00100                //-------------------
00101            //--  R_CHEBU  ------
00102           //-------------------
00103 
00104 Matrice _cl_helmholtz_minus_r_chebu (const Matrice& source) {
00105   
00106   int n = source.get_dim(0) ;
00107   assert (n==source.get_dim(1)) ;
00108 
00109   Matrice barre(source) ;
00110   int dirac = 1 ;
00111   for (int i=0 ; i<n-2 ; i++) {
00112     for (int j=0 ; j<n ; j++)
00113       barre.set(i, j) = ((1+dirac)*source(i, j)-source(i+2, j)) ;
00114     if (i==0) dirac = 0 ;
00115   }
00116   
00117   Matrice tilde(barre) ;
00118   for (int i=0 ; i<n-4 ; i++)
00119     for (int j=0 ; j<n ; j++)
00120       tilde.set(i, j) = (barre(i, j)-barre(i+2, j)) ;
00121   
00122   Matrice hat(tilde) ;
00123   for (int i=0 ; i<n-4 ; i++)
00124     for (int j=0 ; j<n ; j++)
00125       hat.set(i, j) = (tilde(i, j)+tilde(i+1, j)) ;
00126   
00127   Matrice res(hat) ;
00128   for (int i=0 ; i<n-4 ; i++)
00129     for (int j=0 ; j<n ; j++)
00130       res.set(i, j) = hat(i, j)-hat(i+1, j) ;
00131   
00132   return res ;
00133 } 
00134   
00135         //-------------------
00136            //--  R_CHEBP   -----
00137           //-------------------
00138 
00139 
00140 Matrice _cl_helmholtz_minus_r_chebp (const Matrice &source) {
00141     int n = source.get_dim(0) ;
00142   assert (n==source.get_dim(1)) ;
00143 
00144   Matrice barre(source) ;
00145   
00146     int dirac = 1 ;
00147     for (int i=0 ; i<n-2 ; i++) {
00148     for (int j=0 ; j<n ; j++)
00149         barre.set(i, j) = (1+dirac)*source(i, j)-source(i+2, j) ;
00150     if (i==0) dirac = 0 ;
00151     }
00152 
00153     Matrice tilde(barre) ;
00154     for (int i=0 ; i<n-4 ; i++)
00155     for (int j=0 ; j<n ; j++)
00156         tilde.set(i, j) = barre(i, j)-barre(i+2, j) ;
00157 
00158     Matrice res(tilde) ;
00159     for (int i=0 ; i<n-4 ; i++)
00160     for (int j=0 ; j<n ; j++)
00161         res.set(i, j) = tilde(i, j)-tilde(i+1, j) ;
00162     return res ;
00163 }
00164 
00165         //-------------------
00166            //--  R_CHEBI   -----
00167           //-------------------
00168 
00169 
00170 Matrice _cl_helmholtz_minus_r_chebi (const Matrice &source) {
00171      int n = source.get_dim(0) ;
00172   assert (n==source.get_dim(1)) ;
00173 
00174  Matrice barre(source) ;
00175    
00176     for (int i=0 ; i<n-2 ; i++)
00177     for (int j=0 ; j<n ; j++)
00178         barre.set(i, j) = source(i, j)-source(i+2, j) ;
00179 
00180     Matrice tilde(barre) ;
00181     for (int i=0 ; i<n-4 ; i++)
00182     for (int j=0 ; j<n ; j++)
00183         tilde.set(i, j) = barre(i, j)-barre(i+2, j) ;    
00184 
00185     Matrice res(tilde) ;
00186     for (int i=0 ; i<n-4 ; i++)
00187     for (int j=0 ; j<n ; j++)
00188         res.set(i, j) = tilde(i, j)-tilde(i+1, j) ;
00189     return res ;
00190 }
00191 
00192                 //-------------------------
00193            //- La routine a appeler ---
00194           //---------------------------
00195 
00196 Matrice cl_helmholtz_minus (const Matrice &source, int base_r) {
00197     
00198         // Routines de derivation
00199     static Matrice (*cl_helmholtz_minus[MAX_BASE]) (const Matrice &) ;
00200     static int nap = 0 ;
00201     
00202     // Premier appel
00203     if (nap==0) {
00204       nap = 1 ;
00205       for (int i=0 ; i<MAX_BASE ; i++) {
00206     cl_helmholtz_minus[i] = _cl_helmholtz_minus_pas_prevu ;
00207     }
00208       // Les routines existantes
00209       cl_helmholtz_minus[R_CHEB >> TRA_R] = _cl_helmholtz_minus_r_cheb ;
00210       cl_helmholtz_minus[R_CHEBU >> TRA_R] = _cl_helmholtz_minus_r_chebu ;
00211       cl_helmholtz_minus[R_CHEBP >> TRA_R] = _cl_helmholtz_minus_r_chebp ;
00212       cl_helmholtz_minus[R_CHEBI >> TRA_R] = _cl_helmholtz_minus_r_chebi ;
00213     }
00214     
00215     Matrice res(cl_helmholtz_minus[base_r](source)) ;
00216     return res ;
00217 }
00218 
00219 
00220 //************************ TBL Versions *************************************
00221 
00222 
00223 
00224 
00225 Tbl _cl_helmholtz_minus_pas_prevu (const Tbl &so) {
00226 
00227   cout << "Linear combination for Helmholtz minus not implemented..." << endl ;
00228   abort() ;
00229   exit(-1) ;
00230   return so;
00231 }
00232 
00233                //-------------------
00234            //--  R_CHEB  -------
00235           //--------------------
00236 Tbl _cl_helmholtz_minus_r_cheb (const Tbl& source) {
00237   
00238   int n = source.get_dim(0) ;
00239   
00240   Tbl barre(source) ;
00241   int dirac = 1 ;
00242   for (int i=0 ; i<n-2 ; i++) {
00243     barre.set(i) = ((1+dirac)*source(i)-source(i+2))
00244       /(i+1) ;
00245     if (i==0) dirac = 0 ;
00246   }
00247   
00248   Tbl res(barre) ;
00249   for (int i=0 ; i<n-4 ; i++)
00250     res.set(i) = barre(i)-barre(i+2) ;
00251 
00252   return res ;
00253 }
00254             
00255 
00256                 //------------------
00257            //--  R_CHEBU -------
00258           //--------------------
00259 
00260 Tbl _cl_helmholtz_minus_r_chebu (const Tbl& source) {
00261 
00262   int n = source.get_dim(0) ;
00263   
00264   Tbl barre(source) ;
00265   int dirac = 1 ;
00266   for (int i=0 ; i<n-2 ; i++) {
00267     barre.set(i) = ((1+dirac)*source(i)-source(i+2)) ;
00268     if (i==0) dirac = 0 ;
00269   }
00270   
00271   Tbl tilde(barre) ;
00272   for (int i=0 ; i<n-4 ; i++)
00273     tilde.set(i) = (barre(i)-barre(i+2)) ;
00274 
00275   Tbl hat(tilde) ;
00276   for (int i=0 ; i<n-4 ; i++)
00277     hat.set(i) = (tilde(i)+tilde(i+1)) ;
00278 
00279   Tbl res(hat) ;
00280   for (int i=0 ; i<n-4 ; i++)
00281     res.set(i) = hat(i)-hat(i+1) ;
00282 
00283   return res ;
00284 }
00285   
00286         //-------------------
00287            //--  R_CHEBP   -----
00288           //-------------------
00289 
00290 
00291 Tbl _cl_helmholtz_minus_r_chebp (const Tbl &source) {
00292    int n = source.get_dim(0) ;
00293    Tbl barre(source) ;
00294   
00295     int dirac = 1 ;
00296     for (int i=0 ; i<n-2 ; i++) {
00297         barre.set(i) = (1+dirac)*source(i)-source(i+2) ;
00298     if (i==0) dirac = 0 ;
00299     }
00300 
00301     Tbl tilde(barre) ;
00302     for (int i=0 ; i<n-4 ; i++)
00303         tilde.set(i) = barre(i)-barre(i+2) ;
00304 
00305     Tbl res(tilde) ;
00306     for (int i=0 ; i<n-4 ; i++)
00307         res.set(i) = tilde(i)-tilde(i+1) ;
00308     return res ;
00309 }
00310 
00311         //-------------------
00312            //--  R_CHEBI   -----
00313           //-------------------
00314 
00315 
00316 Tbl _cl_helmholtz_minus_r_chebi (const Tbl &source) {
00317     int n = source.get_dim(0) ;
00318   Tbl barre(source) ;
00319    
00320     for (int i=0 ; i<n-2 ; i++)
00321         barre.set(i) = source(i)-source(i+2) ;
00322 
00323     Tbl tilde(barre) ;
00324     for (int i=0 ; i<n-4 ; i++)
00325         tilde.set(i) = barre(i)-barre(i+2) ;    
00326 
00327     Tbl res(tilde) ;
00328     for (int i=0 ; i<n-4 ; i++)
00329         res.set(i) = tilde(i)-tilde(i+1) ;
00330     return res ;
00331 }
00332         //----------------------------
00333            //- Routine a appeler        ---
00334           //------------------------------
00335 
00336 Tbl cl_helmholtz_minus (const Tbl &source, int base_r) {
00337     
00338   // Routines de derivation
00339   static Tbl (*cl_helmholtz_minus[MAX_BASE])(const Tbl &) ;
00340   static int nap = 0 ;
00341   
00342   // Premier appel
00343   if (nap==0) {
00344     nap = 1 ;
00345     for (int i=0 ; i<MAX_BASE ; i++) {
00346       cl_helmholtz_minus[i] = _cl_helmholtz_minus_pas_prevu ;
00347     }
00348     // Les routines existantes
00349     cl_helmholtz_minus[R_CHEB >> TRA_R] = _cl_helmholtz_minus_r_cheb ;
00350     cl_helmholtz_minus[R_CHEBU >> TRA_R] = _cl_helmholtz_minus_r_chebu ; 
00351     cl_helmholtz_minus[R_CHEBP >> TRA_R] = _cl_helmholtz_minus_r_chebp ;
00352     cl_helmholtz_minus[R_CHEBI >> TRA_R] = _cl_helmholtz_minus_r_chebi ;
00353   }
00354     
00355     Tbl res(cl_helmholtz_minus[base_r](source)) ;
00356     return res ;
00357 }

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