get_operateur.C

00001 /*
00002  *   Copyright (c) 2000-2001 Jerome Novak
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 get_operateur_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/PDE/get_operateur.C,v 1.7 2008/08/27 08:51:15 jl_cornou Exp $" ;
00024 
00025 /*
00026  * $Id: get_operateur.C,v 1.7 2008/08/27 08:51:15 jl_cornou Exp $
00027  * $Log: get_operateur.C,v $
00028  * Revision 1.7  2008/08/27 08:51:15  jl_cornou
00029  * Added Jacobi(0,2) polynomials
00030  *
00031  * Revision 1.6  2005/01/27 10:19:43  j_novak
00032  * Now using Diff operators to build the matrices.
00033  *
00034  * Revision 1.5  2003/06/18 08:45:27  j_novak
00035  * In class Mg3d: added the member get_radial, returning only a radial grid
00036  * For dAlembert solver: the way the coefficients of the operator are defined has been changed.
00037  *
00038  * Revision 1.4  2002/01/03 15:30:28  j_novak
00039  * Some comments modified.
00040  *
00041  * Revision 1.3  2002/01/03 13:18:41  j_novak
00042  * Optimization: the members set(i,j) and operator(i,j) of class Matrice are
00043  * now defined inline. Matrice is a friend class of Tbl.
00044  *
00045  * Revision 1.2  2002/01/02 14:07:57  j_novak
00046  * Dalembert equation is now solved in the shells. However, the number of
00047  * points in theta and phi must be the same in each domain. The solver is not
00048  * completely tested (beta version!).
00049  *
00050  * Revision 1.1.1.1  2001/11/20 15:19:28  e_gourgoulhon
00051  * LORENE
00052  *
00053  * Revision 1.3  2001/10/29  10:55:28  novak
00054  * Error fixed for r^2 d^2/dr^2 operator
00055  *
00056  * Revision 1.2  2000/12/18 13:33:46  novak
00057  * *** empty log message ***
00058  *
00059  * Revision 1.1  2000/12/04 16:36:50  novak
00060  * Initial revision
00061  *
00062  *
00063  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/PDE/get_operateur.C,v 1.7 2008/08/27 08:51:15 jl_cornou Exp $
00064  *
00065  */
00066 
00067 // Header C : 
00068 #include <math.h>
00069 
00070 // Headers Lorene :
00071 #include "param.h"
00072 #include "base_val.h"
00073 #include "diff.h"
00074 #include "proto.h"
00075 
00076 /*************************************************************************
00077  *
00078  * Routine used by sol_dalembert, to compute the matrix of the operator
00079  * to be solved. The coefficients (Ci) are stored in par.get_tbl_mod(1->9)
00080  * The time-step is par.get_double(0). Other inputs are:
00081  * l: spherical harmonic number
00082  * alpha, beta: coefficients of the affine mapping (see map.h)
00083  * Outputs are: type_dal : type of the operator (see type_parite.h)
00084  *              operateur: matrix of the operator
00085  * 
00086  * The operator reads: 
00087  * 
00088  *  Indentity - 0.5*dt^2 [ (C1 + C3r^2) d^2/dr^2 + (C6/r + C5r) d/dr
00089  *                         (C9/r^2 + C7) Id ] 
00090  * 
00091  *************************************************************************/
00092 
00093 
00094 
00095         //-----------------------------------
00096         // Routine pour les cas non prevus --
00097         //-----------------------------------
00098 
00099 void _get_operateur_dal_pas_prevu(const Param& , const int&, int& , Matrice& )
00100 {
00101     cout << "get_operateur_dal pas prevu..." << endl ;
00102     abort() ;
00103     exit(-1) ;
00104 }
00105 
00106 
00107 void _get_operateur_dal_r_cheb(const Param& par, const int& lz, 
00108 int& type_dal, Matrice& operateur)
00109 {
00110   int nr = operateur.get_dim(0) ;
00111   assert (nr == operateur.get_dim(1)) ;
00112   assert (par.get_n_double() > 0) ;
00113   assert (par.get_n_tbl_mod() > 0) ;
00114   assert ((par.get_tbl_mod()).get_dim(1) == 12 ) ;
00115   assert ((par.get_tbl_mod()).get_ndim() ==2 ) ;
00116 
00117   double dt = par.get_double(0) ;
00118   dt *= 0.5*dt ;
00119 
00120   // Copies the global coefficients to a local Tbl 
00121     Tbl coeff(10) ;
00122     coeff.set_etat_qcq() ;
00123     coeff.set(1) = (par.get_tbl_mod())(1,lz) ;
00124     coeff.set(2) = (par.get_tbl_mod())(2,lz) ;
00125     coeff.set(3) = (par.get_tbl_mod())(3,lz) ;
00126     coeff.set(4) = (par.get_tbl_mod())(4,lz) ;
00127     coeff.set(5) = (par.get_tbl_mod())(5,lz) ;
00128     coeff.set(6) = (par.get_tbl_mod())(6,lz) ;
00129     coeff.set(7) = (par.get_tbl_mod())(7,lz) ;
00130     coeff.set(8) = (par.get_tbl_mod())(8,lz) ;
00131     coeff.set(9) = (par.get_tbl_mod())(9,lz) ;
00132     double R1 = (par.get_tbl_mod())(10,lz) ;
00133     double R2 = (par.get_tbl_mod())(11,lz) ;
00134 
00135     double a00 = 0. ; double a01 = 0. ; double  a02 = 0. ; 
00136     double a10 = 0. ; double a11 = 0. ; double  a12 = 0. ; 
00137     double a13 = 0. ; double a20 = 0. ; double  a21 = 0. ; 
00138     double a22 = 0. ; double a23 = 0. ; double  a24 = 0. ; 
00139 
00140     bool dege = (fabs(coeff(9)) < 1.e-10) ;
00141      switch (dege) {
00142      case true:
00143       a00 = R1 - dt*(coeff(7)*R1 + coeff(8)) ;
00144       a01 = R2 - dt*R2*coeff(7) ;
00145       a02 = 0 ;
00146       a10 = -dt*(R1*coeff(4) + R1*R1*coeff(5) + coeff(6))/R2 ;
00147       a11 = -dt*(coeff(4) + 2*R1*coeff(5)) ;
00148       a12 = -dt*R2*coeff(5) ;
00149       a13 = 0 ;
00150       a20 = -dt*R1/(R2*R2)*(coeff(1) + R1*coeff(2) + R1*R1*coeff(3)) ;
00151       a21 = -dt/R2*(coeff(1) + 2*R1*coeff(2) + 3*R1*R1*coeff(3)) ;
00152       a22 = -dt*(coeff(2) + 3*R1*coeff(3)) ;
00153       a23 = -dt*R2*coeff(3) ;
00154       a24 = 0 ;
00155       type_dal = ((0.1*(fabs(a20)+fabs(a21)+fabs(a22)+fabs(a23))*nr*nr*nr 
00156            < 1.) ? O2DEGE_SMALL : O2DEGE_LARGE ) ;
00157        break ;
00158      case false:
00159       a00 = R1*R1 - dt*(coeff(7)*R1*R1 + coeff(8)*R1 + coeff(9)) ;
00160       a01 = 2*R1*R2 - dt*(2*R1*R2*coeff(7) + R2*coeff(8)) ;
00161       a02 = R2*R2*(1 - dt*coeff(7)) ;
00162       a10 = -dt*R1/R2*(R1*coeff(4) + R1*R1*coeff(5) + coeff(6)) ;
00163       a11 = -dt*(2*R1*coeff(4) + 3*R1*R1*coeff(5) + coeff(6)) ;
00164       a12 = -dt*(R2*coeff(4) + 3*R1*R2*coeff(5)) ;
00165       a13 = -dt*R2*R2*coeff(5) ;
00166       a20 = -dt*(R1*R1)/(R2*R2)*(coeff(1) + R1*coeff(2) + R1*R1*coeff(3)) ;
00167       a21 = -dt*R1/R2*(2*coeff(1) + 3*R1*coeff(2) + 4*R1*R1*coeff(3)) ;
00168       a22 = -dt*(coeff(1) + 3*R1*coeff(2) + 6*R1*R1*coeff(3)) ;
00169       a23 = -dt*(R2*coeff(2) + 4*R1*R2*coeff(3)) ;
00170       a24 = -dt*R2*R2*coeff(3) ;
00171        type_dal = ((0.1*(fabs(a20)+fabs(a21)+fabs(a22)+fabs(a23)+fabs(a24))
00172            *nr*nr*nr < 1.) ? O2NOND_SMALL : O2NOND_LARGE ) ;
00173        break ;
00174      }
00175     if (fabs(a00)<1.e-15) a00 = 0 ;
00176     if (fabs(a01)<1.e-15) a01 = 0 ;
00177     if (fabs(a02)<1.e-15) a02 = 0 ;
00178     if (fabs(a10)<1.e-15) a10 = 0 ;
00179     if (fabs(a11)<1.e-15) a11 = 0 ;
00180     if (fabs(a12)<1.e-15) a12 = 0 ;
00181     if (fabs(a13)<1.e-15) a13 = 0 ;
00182     if (fabs(a20)<1.e-15) a20 = 0 ;
00183     if (fabs(a21)<1.e-15) a21 = 0 ;
00184     if (fabs(a22)<1.e-15) a22 = 0 ;
00185     if (fabs(a23)<1.e-15) a23 = 0 ;
00186     if (fabs(a24)<1.e-15) a24 = 0 ;
00187 
00188     
00189 
00190     Diff_id id(R_CHEB, nr) ;
00191     if (fabs(a00)>1.e-15) {
00192     operateur = a00*id ;
00193     }
00194     else{
00195     operateur.set_etat_qcq() ;
00196     for (int i=0; i<nr; i++) 
00197         for (int j=0; j<nr; j++)
00198         operateur.set(i,j) = 0. ;
00199     }
00200     Diff_mx op01(R_CHEB, nr) ; const Matrice& m01 = op01.get_matrice() ;
00201     Diff_mx2 op02(R_CHEB, nr) ; const Matrice& m02 = op02.get_matrice() ;
00202     Diff_dsdx op10(R_CHEB, nr) ; const Matrice& m10 = op10.get_matrice() ;
00203     Diff_xdsdx op11(R_CHEB, nr) ; const Matrice& m11 = op11.get_matrice() ;
00204     Diff_x2dsdx op12(R_CHEB, nr) ; const Matrice& m12 = op12.get_matrice() ;
00205     Diff_x3dsdx op13(R_CHEB, nr) ; const Matrice& m13 = op13.get_matrice() ;
00206     Diff_dsdx2 op20(R_CHEB, nr) ; const Matrice& m20 = op20.get_matrice() ;
00207     Diff_xdsdx2 op21(R_CHEB, nr) ; const Matrice& m21 = op21.get_matrice() ;
00208     Diff_x2dsdx2 op22(R_CHEB, nr) ; const Matrice& m22 = op22.get_matrice() ;
00209     Diff_x3dsdx2 op23(R_CHEB, nr) ; const Matrice& m23 = op23.get_matrice() ;
00210     Diff_x4dsdx2 op24(R_CHEB, nr) ; const Matrice& m24 = op24.get_matrice() ;
00211 
00212     for (int i=0; i<nr; i++) {
00213     int jmin = (i>3 ? i-3 : 0) ; 
00214     int jmax = (i<nr-9 ? i+10 : nr) ;
00215     for (int j=jmin ; j<jmax; j++) 
00216         operateur.set(i,j) += a01*m01(i,j) + a02*m02(i,j) 
00217         + a10*m10(i,j) + a11*m11(i,j) + a12*m12(i,j) 
00218         + a13*m13(i,j) + a20*m20(i,j) + a21*m21(i,j)
00219         + a22*m22(i,j) + a23*m23(i,j) + a24*m24(i,j) ;
00220     
00221     }
00222 }
00223 
00224 void _get_operateur_dal_r_chebp(const Param& par, const int& lzone, 
00225                 int& type_dal, Matrice& operateur)
00226 {
00227   assert(lzone == 0) ; // Nucleus!
00228   int nr = operateur.get_dim(0) ;
00229   assert (nr == operateur.get_dim(1)) ;
00230   assert (par.get_n_double() > 0) ;
00231   assert (par.get_n_tbl_mod() > 0) ;
00232   assert ((par.get_tbl_mod()).get_dim(1) == 12 ) ;
00233   assert ((par.get_tbl_mod()).get_ndim() ==2 ) ;
00234 
00235   double dt = par.get_double(0) ;
00236   dt *= 0.5*dt ;
00237 
00238   // Copies the global coefficients to a local Tbl and adds the -l(l+1) term
00239   Tbl coeff(7) ;
00240   coeff.set_etat_qcq() ;
00241   coeff.set(1) = (par.get_tbl_mod())(1,lzone) ;
00242   if (fabs(coeff(1))<1.e-15) coeff.set(1) = 0 ;
00243   coeff.set(2) = (par.get_tbl_mod())(3,lzone) ;
00244   if (fabs(coeff(2))<1.e-15) coeff.set(2) = 0 ;
00245   coeff.set(3) = (par.get_tbl_mod())(6,lzone) ;
00246   if (fabs(coeff(3))<1.e-15) coeff.set(3) = 0 ;
00247   coeff.set(4) = (par.get_tbl_mod())(5,lzone) ;
00248   if (fabs(coeff(4))<1.e-15) coeff.set(4) = 0 ;
00249   coeff.set(5) = (par.get_tbl_mod())(9,lzone) ;
00250   if (fabs(coeff(5))<1.e-15) coeff.set(5) = 0 ;
00251   coeff.set(6) = (par.get_tbl_mod())(7,lzone) ;
00252   if (fabs(coeff(6))<1.e-15) coeff.set(6) = 0 ;
00253   double alpha2 = (par.get_tbl_mod())(11,lzone)*(par.get_tbl_mod())(11,lzone) ;
00254 
00255   //***********************************************************************
00256   //                Definition of the type of operator
00257   // For each type and a fixed time-step, if the number of points (nr) is too
00258   // large, the round-off error makes the matrix ill-conditioned. So one has
00259   // to pass the last line of the matrix to the first place (see dal_inverse).
00260   // The linear combinations to put the matrix into a banded form also depend
00261   // on the type of operator.
00262   //***********************************************************************
00263 
00264   if (fabs(coeff(1)) + fabs(coeff(2)) + fabs(coeff(5)) < 1.e-30) {
00265     // First order operator
00266     if (dt < 0.1/(fabs(coeff(3)) + fabs(coeff(4))*nr))
00267       type_dal = ORDRE1_SMALL ;
00268     else type_dal = ORDRE1_LARGE ;
00269   }
00270   else {
00271     // Second order degenerate (no 1/r^2 term)
00272     if (fabs(coeff(5)) < 1.e-24) {
00273       if (dt < 1./(fabs(coeff(1)) + fabs(coeff(2)) + fabs(coeff(3))*nr
00274            +fabs(coeff(4)))/nr/nr) type_dal = O2DEGE_SMALL ;
00275       else type_dal = O2DEGE_LARGE ;
00276     }
00277     else {
00278       // Second order non-degenerate (most general case)
00279       if (dt < 1./((fabs(coeff(1)) + fabs(coeff(2)) + fabs(coeff(3))*nr
00280             + fabs(coeff(4)) + fabs(coeff(5)))*nr*nr))
00281     type_dal = O2NOND_SMALL ;
00282       else type_dal = O2NOND_LARGE ;
00283     }
00284   }
00285 
00286   coeff.set(1) *= dt/alpha2 ;
00287   coeff.set(2) *= dt ;
00288   coeff.set(3) *= dt/alpha2 ;
00289   coeff.set(4) *= dt ;
00290   coeff.set(5) *= dt/alpha2 ;
00291   coeff.set(6) *= dt ;
00292 
00293   Diff_id id(R_CHEBP, nr) ;
00294   if (fabs(1-coeff(6))>1.e-15) {
00295       operateur = (1-coeff(6))*id ;
00296   }
00297   else{
00298       operateur.set_etat_qcq() ;
00299       for (int i=0; i<nr; i++) 
00300       for (int j=0; j<nr; j++)
00301           operateur.set(i,j) = 0. ;
00302   }
00303   Diff_sx2 op02(R_CHEBP, nr) ; const Matrice& m02 = op02.get_matrice() ;
00304   Diff_xdsdx op11(R_CHEBP, nr) ; const Matrice& m11 = op11.get_matrice() ;
00305   Diff_sxdsdx op12(R_CHEBP, nr) ; const Matrice& m12 = op12.get_matrice() ;
00306   Diff_dsdx2 op20(R_CHEBP, nr) ; const Matrice& m20 = op20.get_matrice() ;
00307   Diff_x2dsdx2 op22(R_CHEBP, nr) ; const Matrice& m22 = op22.get_matrice() ;
00308 
00309     for (int i=0; i<nr; i++) {
00310     int jmin = (i>3 ? i-3 : 0) ; 
00311     int jmax = (i<nr-9 ? i+10 : nr) ;
00312     for (int j=jmin ; j<jmax; j++) 
00313         operateur.set(i,j) -= coeff(1)*m20(i,j) + coeff(2)*m22(i,j)
00314         + coeff(3)*m12(i,j) + coeff(4)*m11(i,j) + coeff(5)*m02(i,j) ;
00315     }
00316 
00317 
00318 }
00319 
00320 
00321 void _get_operateur_dal_r_chebi(const Param& par, const int& lzone,
00322                 int& type_dal, Matrice& operateur)
00323 {
00324   assert(lzone == 0) ; // Nucleus!
00325   int nr = operateur.get_dim(0) ;
00326   assert (nr == operateur.get_dim(1)) ;
00327   assert (par.get_n_double() > 0) ;
00328   assert (par.get_n_tbl_mod() > 0) ;
00329   assert ((par.get_tbl_mod()).get_dim(1) == 12 ) ;
00330   assert ((par.get_tbl_mod()).get_ndim() == 2 ) ;
00331 
00332   double dt = par.get_double(0) ;
00333   dt *= 0.5*dt ;
00334 
00335   // Copies the global coefficients to a local Tbl and adds the -l(l+1) term
00336   Tbl coeff(7) ;
00337   coeff.set_etat_qcq() ;
00338   coeff.set(1) = (par.get_tbl_mod())(1,lzone) ;
00339   if (fabs(coeff(1))<1.e-15) coeff.set(1) = 0 ;
00340   coeff.set(2) = (par.get_tbl_mod())(3,lzone) ;
00341   if (fabs(coeff(2))<1.e-15) coeff.set(2) = 0 ;
00342   coeff.set(3) = (par.get_tbl_mod())(6,lzone) ;
00343   if (fabs(coeff(3))<1.e-15) coeff.set(3) = 0 ;
00344   coeff.set(4) = (par.get_tbl_mod())(5,lzone) ;
00345   if (fabs(coeff(4))<1.e-15) coeff.set(4) = 0 ;
00346   coeff.set(5) = (par.get_tbl_mod())(9,lzone) ;
00347   if (fabs(coeff(5))<1.e-15) coeff.set(5) = 0 ;
00348   coeff.set(6) = (par.get_tbl_mod())(7,lzone) ;
00349   if (fabs(coeff(6))<1.e-15) coeff.set(6) = 0 ;
00350   double alpha2 = (par.get_tbl_mod())(11,lzone)*(par.get_tbl_mod())(11,lzone) ;
00351 
00352   //***********************************************************************
00353   //                Definition of the type of operator
00354   // For each type and a fixed time-step, if the number of points (nr) is too
00355   // large, the round-off error makes the matrix ill-conditioned. So one has
00356   // to pass the last line of the matrix to the first place (see dal_inverse).
00357   // The linear combinations to put the matrix into a banded form also depend
00358   // on the type of operator.
00359   //***********************************************************************
00360 
00361   if (fabs(coeff(1)) + fabs(coeff(2)) + fabs(coeff(3)) + 
00362       fabs(coeff(5)) < 1.e-30) {
00363     // First order operator
00364     if (dt < 0.1/(fabs(coeff(4))*nr))
00365       type_dal = ORDRE1_SMALL ;
00366     else type_dal = ORDRE1_LARGE ;
00367   }
00368   else {
00369     if (fabs(coeff(5)+coeff(3)) < 1.e-6) {
00370     // Second order degenerate (no 1/r^2 term)
00371       if (dt < 1./(fabs(coeff(1)) + fabs(coeff(2)) + fabs(coeff(3))*nr
00372            +fabs(coeff(4)))/nr/nr) type_dal = O2DEGE_SMALL ;
00373       else type_dal = O2DEGE_LARGE ;
00374     }
00375     else {
00376       // Second order non-degenerate (most general case)
00377       if (dt < 1./((fabs(coeff(1)) + fabs(coeff(2)) + fabs(coeff(3))*nr
00378             + fabs(coeff(4)) + fabs(coeff(5)))*nr*nr))
00379     type_dal = O2NOND_SMALL ;
00380       else type_dal = O2NOND_LARGE ;
00381     }
00382   }
00383 
00384   coeff.set(1) *= dt/alpha2 ;
00385   coeff.set(2) *= dt ;
00386   coeff.set(3) *= dt/alpha2 ;
00387   coeff.set(4) *= dt ;
00388   coeff.set(5) *= dt/alpha2 ;
00389   coeff.set(6) *= dt ;
00390 
00391   Diff_id id(R_CHEBP, nr) ;
00392   if (fabs(1-coeff(6))>1.e-15) {
00393       operateur = (1-coeff(6))*id ;
00394   }
00395   else{
00396       operateur.set_etat_qcq() ;
00397       for (int i=0; i<nr; i++) 
00398       for (int j=0; j<nr; j++)
00399           operateur.set(i,j) = 0. ;
00400   }
00401   Diff_sx2 op02(R_CHEBI, nr) ; const Matrice& m02 = op02.get_matrice() ;
00402   Diff_xdsdx op11(R_CHEBI, nr) ; const Matrice& m11 = op11.get_matrice() ;
00403   Diff_sxdsdx op12(R_CHEBI, nr) ; const Matrice& m12 = op12.get_matrice() ;
00404   Diff_dsdx2 op20(R_CHEBI, nr) ; const Matrice& m20 = op20.get_matrice() ;
00405   Diff_x2dsdx2 op22(R_CHEBI, nr) ; const Matrice& m22 = op22.get_matrice() ;
00406 
00407     for (int i=0; i<nr; i++) {
00408     int jmin = (i>3 ? i-3 : 0) ; 
00409     int jmax = (i<nr-9 ? i+10 : nr) ;
00410     for (int j=jmin ; j<jmax; j++) 
00411         operateur.set(i,j) -= coeff(1)*m20(i,j) + coeff(2)*m22(i,j)
00412         + coeff(3)*m12(i,j) + coeff(4)*m11(i,j) + coeff(5)*m02(i,j) ;
00413     }
00414 
00415 }
00416 
00417 
00418 
00419 void _get_operateur_dal_r_jaco02(const Param& par, const int& lz, 
00420 int& type_dal, Matrice& operateur)
00421 {
00422   int nr = operateur.get_dim(0) ;
00423   assert (nr == operateur.get_dim(1)) ;
00424   assert (par.get_n_double() > 0) ;
00425   assert (par.get_n_tbl_mod() > 0) ;
00426   assert ((par.get_tbl_mod()).get_dim(1) == 12 ) ;
00427   assert ((par.get_tbl_mod()).get_ndim() ==2 ) ;
00428 
00429   double dt = par.get_double(0) ;
00430   dt *= 0.5*dt ;
00431 
00432   // Copies the global coefficients to a local Tbl 
00433     Tbl coeff(10) ;
00434     coeff.set_etat_qcq() ;
00435     coeff.set(1) = (par.get_tbl_mod())(1,lz) ;
00436     coeff.set(2) = (par.get_tbl_mod())(2,lz) ;
00437     coeff.set(3) = (par.get_tbl_mod())(3,lz) ;
00438     coeff.set(4) = (par.get_tbl_mod())(4,lz) ;
00439     coeff.set(5) = (par.get_tbl_mod())(5,lz) ;
00440     coeff.set(6) = (par.get_tbl_mod())(6,lz) ;
00441     coeff.set(7) = (par.get_tbl_mod())(7,lz) ;
00442     coeff.set(8) = (par.get_tbl_mod())(8,lz) ;
00443     coeff.set(9) = (par.get_tbl_mod())(9,lz) ;
00444     double R1 = (par.get_tbl_mod())(10,lz) ;
00445     double R2 = (par.get_tbl_mod())(11,lz) ;
00446 
00447     double a00 = 0. ; double a01 = 0. ; double  a02 = 0. ; 
00448     double a10 = 0. ; double a11 = 0. ; double  a12 = 0. ; 
00449     double a13 = 0. ; double a20 = 0. ; double  a21 = 0. ; 
00450     double a22 = 0. ; double a23 = 0. ; double  a24 = 0. ; 
00451 
00452     bool dege = (fabs(coeff(9)) < 1.e-10) ;
00453      switch (dege) {
00454      case true:
00455       a00 = R1 - dt*(coeff(7)*R1 + coeff(8)) ;
00456       a01 = R2 - dt*R2*coeff(7) ;
00457       a02 = 0 ;
00458       a10 = -dt*(R1*coeff(4) + R1*R1*coeff(5) + coeff(6))/R2 ;
00459       a11 = -dt*(coeff(4) + 2*R1*coeff(5)) ;
00460       a12 = -dt*R2*coeff(5) ;
00461       a13 = 0 ;
00462       a20 = -dt*R1/(R2*R2)*(coeff(1) + R1*coeff(2) + R1*R1*coeff(3)) ;
00463       a21 = -dt/R2*(coeff(1) + 2*R1*coeff(2) + 3*R1*R1*coeff(3)) ;
00464       a22 = -dt*(coeff(2) + 3*R1*coeff(3)) ;
00465       a23 = -dt*R2*coeff(3) ;
00466       a24 = 0 ;
00467       type_dal = ((0.1*(fabs(a20)+fabs(a21)+fabs(a22)+fabs(a23))*nr*nr*nr 
00468            < 1.) ? O2DEGE_SMALL : O2DEGE_LARGE ) ;
00469        break ;
00470      case false:
00471       a00 = R1*R1 - dt*(coeff(7)*R1*R1 + coeff(8)*R1 + coeff(9)) ;
00472       a01 = 2*R1*R2 - dt*(2*R1*R2*coeff(7) + R2*coeff(8)) ;
00473       a02 = R2*R2*(1 - dt*coeff(7)) ;
00474       a10 = -dt*R1/R2*(R1*coeff(4) + R1*R1*coeff(5) + coeff(6)) ;
00475       a11 = -dt*(2*R1*coeff(4) + 3*R1*R1*coeff(5) + coeff(6)) ;
00476       a12 = -dt*(R2*coeff(4) + 3*R1*R2*coeff(5)) ;
00477       a13 = -dt*R2*R2*coeff(5) ;
00478       a20 = -dt*(R1*R1)/(R2*R2)*(coeff(1) + R1*coeff(2) + R1*R1*coeff(3)) ;
00479       a21 = -dt*R1/R2*(2*coeff(1) + 3*R1*coeff(2) + 4*R1*R1*coeff(3)) ;
00480       a22 = -dt*(coeff(1) + 3*R1*coeff(2) + 6*R1*R1*coeff(3)) ;
00481       a23 = -dt*(R2*coeff(2) + 4*R1*R2*coeff(3)) ;
00482       a24 = -dt*R2*R2*coeff(3) ;
00483        type_dal = ((0.1*(fabs(a20)+fabs(a21)+fabs(a22)+fabs(a23)+fabs(a24))
00484            *nr*nr*nr < 1.) ? O2NOND_SMALL : O2NOND_LARGE ) ;
00485        break ;
00486      }
00487     if (fabs(a00)<1.e-15) a00 = 0 ;
00488     if (fabs(a01)<1.e-15) a01 = 0 ;
00489     if (fabs(a02)<1.e-15) a02 = 0 ;
00490     if (fabs(a10)<1.e-15) a10 = 0 ;
00491     if (fabs(a11)<1.e-15) a11 = 0 ;
00492     if (fabs(a12)<1.e-15) a12 = 0 ;
00493     if (fabs(a13)<1.e-15) a13 = 0 ;
00494     if (fabs(a20)<1.e-15) a20 = 0 ;
00495     if (fabs(a21)<1.e-15) a21 = 0 ;
00496     if (fabs(a22)<1.e-15) a22 = 0 ;
00497     if (fabs(a23)<1.e-15) a23 = 0 ;
00498     if (fabs(a24)<1.e-15) a24 = 0 ;
00499 
00500     
00501 
00502     Diff_id id(R_JACO02, nr) ;
00503     if (fabs(a00)>1.e-15) {
00504     operateur = a00*id ;
00505     }
00506     else{
00507     operateur.set_etat_qcq() ;
00508     for (int i=0; i<nr; i++) 
00509         for (int j=0; j<nr; j++)
00510         operateur.set(i,j) = 0. ;
00511     }
00512     Diff_mx op01(R_JACO02, nr) ; const Matrice& m01 = op01.get_matrice() ;
00513     Diff_mx2 op02(R_JACO02, nr) ; const Matrice& m02 = op02.get_matrice() ;
00514     Diff_dsdx op10(R_JACO02, nr) ; const Matrice& m10 = op10.get_matrice() ;
00515     Diff_xdsdx op11(R_JACO02, nr) ; const Matrice& m11 = op11.get_matrice() ;
00516     Diff_x2dsdx op12(R_JACO02, nr) ; const Matrice& m12 = op12.get_matrice() ;
00517     Diff_x3dsdx op13(R_JACO02, nr) ; const Matrice& m13 = op13.get_matrice() ;
00518     Diff_dsdx2 op20(R_JACO02, nr) ; const Matrice& m20 = op20.get_matrice() ;
00519     Diff_xdsdx2 op21(R_JACO02, nr) ; const Matrice& m21 = op21.get_matrice() ;
00520     Diff_x2dsdx2 op22(R_JACO02, nr) ; const Matrice& m22 = op22.get_matrice() ;
00521     Diff_x3dsdx2 op23(R_JACO02, nr) ; const Matrice& m23 = op23.get_matrice() ;
00522     Diff_x4dsdx2 op24(R_JACO02, nr) ; const Matrice& m24 = op24.get_matrice() ;
00523 
00524     for (int i=0; i<nr; i++) {
00525     int jmin = (i>3 ? i-3 : 0) ; 
00526     int jmax = (i<nr-9 ? i+10 : nr) ;
00527     for (int j=jmin ; j<jmax; j++) 
00528         operateur.set(i,j) += a01*m01(i,j) + a02*m02(i,j) 
00529         + a10*m10(i,j) + a11*m11(i,j) + a12*m12(i,j) 
00530         + a13*m13(i,j) + a20*m20(i,j) + a21*m21(i,j)
00531         + a22*m22(i,j) + a23*m23(i,j) + a24*m24(i,j) ;
00532     
00533     }
00534 }
00535 
00536 
00537 
00538 
00539          //--------------------------
00540         //- La routine a appeler  ---
00541            //----------------------------
00542 void get_operateur_dal(const Param& par, const int& lzone,
00543                const int& base_r, int& type_dal, Matrice& operateur)
00544 {
00545 
00546         // Routines de derivation
00547   static void (*get_operateur_dal[MAX_BASE])(const Param&,
00548                          const int&, int&, Matrice&) ;
00549   static int nap = 0 ;
00550   
00551   // Premier appel
00552   if (nap==0) {
00553     nap = 1 ;
00554     for (int i=0 ; i<MAX_BASE ; i++) 
00555       get_operateur_dal[i] = _get_operateur_dal_pas_prevu ;
00556     
00557     // Les routines existantes
00558     get_operateur_dal[R_CHEB >> TRA_R] = _get_operateur_dal_r_cheb ;
00559     get_operateur_dal[R_CHEBP >> TRA_R] = _get_operateur_dal_r_chebp ;
00560     get_operateur_dal[R_CHEBI >> TRA_R] = _get_operateur_dal_r_chebi ;
00561     get_operateur_dal[R_JACO02 >> TRA_R] = _get_operateur_dal_r_jaco02 ;
00562   }
00563   
00564   get_operateur_dal[base_r](par, lzone, type_dal, operateur) ;
00565 }

Generated on Tue Feb 9 01:35:14 2010 for LORENE by  doxygen 1.4.6