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

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