comb_lin_helmholtz_plus.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_plusC[] = "$Header $" ;
00024 
00025 /*
00026  * $Id: comb_lin_helmholtz_plus.C,v 1.3 2008/02/18 13:53:43 j_novak Exp $
00027  * $Log: comb_lin_helmholtz_plus.C,v $
00028  * Revision 1.3  2008/02/18 13:53:43  j_novak
00029  * Removal of special indentation instructions.
00030  *
00031  * Revision 1.2  2004/01/15 09:15:37  p_grandclement
00032  * Modification and addition of the Helmholtz operators
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/comb_lin_helmholtz_plus.C,v 1.3 2008/02/18 13:53:43 j_novak Exp $
00039  *
00040  */
00041 
00042 //fichiers includes
00043 #include <stdio.h>
00044 #include <stdlib.h>
00045 #include <math.h>
00046 
00047 #include "matrice.h"
00048 #include "type_parite.h"
00049 #include "proto.h"
00050 
00051 
00052 // Version Matrice --> Matrice
00053 Matrice _cl_helmholtz_plus_pas_prevu (const Matrice& so) {
00054   cout << "CL Helmholtz plus not implemented" << endl ;
00055     abort() ;
00056     exit(-1) ;
00057     return so;
00058 }
00059 
00060 
00061         //-------------------
00062            //--  R_CHEBP   -----
00063           //-------------------
00064 
00065 
00066 Matrice _cl_helmholtz_plus_r_chebp (const Matrice &source) {
00067     
00068   int n = source.get_dim(0) ;
00069   assert (n == source.get_dim(1)) ;
00070  
00071   Matrice barre(source) ;
00072   
00073   int dirac = 1 ;
00074   for (int i=0 ; i<n-2 ; i++) {
00075     for (int j=0 ; j<n ; j++)
00076       barre.set(i, j) = (1+dirac)*source(i, j)-source(i+2, j) ;
00077     if (i==0) dirac = 0 ;
00078   }
00079   
00080   Matrice tilde(barre) ;
00081   for (int i=0 ; i<n-4 ; i++)
00082     for (int j=0 ; j<n ; j++)
00083       tilde.set(i, j) = barre(i, j)-barre(i+2, j) ;
00084   
00085   Matrice res(tilde) ;
00086   for (int i=0 ; i<n-4 ; i++)
00087     for (int j=0 ; j<n ; j++)
00088       res.set(i, j) = tilde(i, j)-tilde(i+1, j) ;
00089     
00090   return res ;
00091 }
00092                
00093 
00094                 //-------------------
00095            //--  R_CHEB   ------
00096           //-------------------
00097 
00098 Matrice _cl_helmholtz_plus_r_cheb (const Matrice& source) {
00099 
00100  
00101   int n = source.get_dim(0) ;
00102   assert (n==source.get_dim(1)) ;
00103 
00104   Matrice barre(source) ;
00105   int dirac = 1 ;
00106   for (int i=0 ; i<n-2 ; i++) {
00107     for (int j=0 ; j<n ; j++)
00108       barre.set(i, j) = ((1+dirac)*source(i, j)-source(i+2, j))
00109     /(i+1) ;
00110     if (i==0) dirac = 0 ;
00111   }
00112   
00113   Matrice res(barre) ;
00114   for (int i=0 ; i<n-4 ; i++)
00115     for (int j=0 ; j<n ; j++)
00116       res.set(i, j) = barre(i, j)-barre(i+2, j) ;
00117 
00118   return res ;
00119 } 
00120 
00121 
00122                 //-------------------------
00123            //- La routine a appeler ---
00124           //---------------------------
00125 
00126 Matrice cl_helmholtz_plus (const Matrice &source, int base_r) {
00127     
00128         // Routines de derivation
00129     static Matrice (*cl_helmholtz_plus[MAX_BASE]) (const Matrice &) ;
00130     static int nap = 0 ;
00131     
00132     // Premier appel
00133     if (nap==0) {
00134       nap = 1 ;
00135       for (int i=0 ; i<MAX_BASE ; i++) {
00136     cl_helmholtz_plus[i] = _cl_helmholtz_plus_pas_prevu ;
00137     }
00138       // Les routines existantes
00139       cl_helmholtz_plus[R_CHEB >> TRA_R] = _cl_helmholtz_plus_r_cheb ;
00140       cl_helmholtz_plus[R_CHEBP >> TRA_R] = _cl_helmholtz_plus_r_chebp ;
00141     }
00142     
00143     Matrice res(cl_helmholtz_plus[base_r](source)) ;
00144     return res ;
00145 }
00146 
00147 
00148 //************************ TBL Versions *************************************
00149 
00150 
00151 
00152 
00153 Tbl _cl_helmholtz_plus_pas_prevu (const Tbl &so) {
00154 
00155   cout << "Linear combination for Helmholtz plus not implemented..." << endl ;
00156   abort() ;
00157   exit(-1) ;
00158   return so;
00159 }
00160 
00161               
00162                //-------------------
00163            //--  R_CHEBP  -------
00164           //--------------------
00165 Tbl _cl_helmholtz_plus_r_chebp (const Tbl& source) {
00166   
00167   int n = source.get_dim(0) ;
00168   
00169   Tbl barre(source) ;
00170   int dirac = 1 ;
00171   for (int i=0 ; i<n-2 ; i++) {
00172     barre.set(i) = (1+dirac)*source(i)-source(i+2) ;
00173     if (i==0) dirac = 0 ;
00174   }
00175      
00176   Tbl tilde(barre) ;
00177   for (int i=0 ; i<n-4 ; i++)
00178     tilde.set(i) = barre(i)-barre(i+2) ;
00179      
00180   Tbl res(tilde) ;
00181   for (int i=0 ; i<n-4 ; i++)
00182     res.set(i) = tilde(i)-tilde(i+1) ;
00183 
00184   return res ;
00185 }
00186                
00187                 //-------------------
00188            //--  R_CHEB  -------
00189           //--------------------
00190 Tbl _cl_helmholtz_plus_r_cheb (const Tbl& source) {
00191   
00192   int n = source.get_dim(0) ;
00193 
00194   Tbl barre(source) ;
00195   int dirac = 1 ;
00196   for (int i=0 ; i<n-2 ; i++) {
00197     barre.set(i) = ((1+dirac)*source(i)-source(i+2))
00198       /(i+1) ;
00199     if (i==0) dirac = 0 ;
00200   }
00201   
00202   Tbl res(barre) ;
00203   for (int i=0 ; i<n-4 ; i++)
00204     res.set(i) = barre(i)-barre(i+2) ;
00205 
00206   return res ;
00207 }
00208         //----------------------------
00209            //- Routine a appeler        ---
00210           //------------------------------
00211 
00212 Tbl cl_helmholtz_plus (const Tbl &source, int base_r) {
00213     
00214   // Routines de derivation
00215   static Tbl (*cl_helmholtz_plus[MAX_BASE])(const Tbl &) ;
00216   static int nap = 0 ;
00217   
00218   // Premier appel
00219   if (nap==0) {
00220     nap = 1 ;
00221     for (int i=0 ; i<MAX_BASE ; i++) {
00222       cl_helmholtz_plus[i] = _cl_helmholtz_plus_pas_prevu ;
00223     }
00224     // Les routines existantes
00225     cl_helmholtz_plus[R_CHEB >> TRA_R] = _cl_helmholtz_plus_r_cheb ;
00226     cl_helmholtz_plus[R_CHEBP >> TRA_R] = _cl_helmholtz_plus_r_chebp ;
00227   }
00228     
00229     Tbl res(cl_helmholtz_plus[base_r](source)) ;
00230     return res ;
00231 }

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