cmp_manip.C

00001 /*
00002  *   Copyright (c) 2000-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 cmp_manip_C[] = "$Header: /cvsroot/Lorene/C++/Source/Cmp/cmp_manip.C,v 1.4 2008/08/19 06:41:59 j_novak Exp $" ;
00024 
00025 /*
00026  * $Id: cmp_manip.C,v 1.4 2008/08/19 06:41:59 j_novak Exp $
00027  * $Log: cmp_manip.C,v $
00028  * Revision 1.4  2008/08/19 06:41:59  j_novak
00029  * Minor modifications to avoid warnings with gcc 4.3. Most of them concern
00030  * cast-type operations, and constant strings that must be defined as const char*
00031  *
00032  * Revision 1.3  2003/10/23 09:41:27  p_grandclement
00033  * small modif of set_val_hor (one can work at the origin now)
00034  *
00035  * Revision 1.2  2003/10/03 15:58:44  j_novak
00036  * Cleaning of some headers
00037  *
00038  * Revision 1.1.1.1  2001/11/20 15:19:27  e_gourgoulhon
00039  * LORENE
00040  *
00041  * Revision 2.2  2001/05/25  09:29:58  phil
00042  * ajout de filtre_phi
00043  *
00044  * Revision 2.1  2001/02/12  18:08:51  phil
00045  * ajout de fixe_decroissance
00046  *
00047  * Revision 2.0  2000/10/19  09:23:37  phil
00048  * *** empty log message ***
00049  *
00050  *
00051  * $Header: /cvsroot/Lorene/C++/Source/Cmp/cmp_manip.C,v 1.4 2008/08/19 06:41:59 j_novak Exp $
00052  *
00053  */
00054 
00055 //standard
00056 #include <stdlib.h>
00057 #include <math.h>
00058 
00059 // Lorene
00060 #include "cmp.h"
00061 #include "proto.h"
00062 
00063 /*
00064  * Annule les n derniers coefficients en r dans la derniere zone
00065  */
00066  
00067 void Cmp::filtre (int n) {
00068     
00069     assert (etat != ETATNONDEF) ;
00070     if (etat == ETATZERO)
00071     return ;
00072     
00073     int nz = mp->get_mg()->get_nzone() ;
00074     int np = mp->get_mg()->get_np(nz-1) ;
00075     int nt = mp->get_mg()->get_nt(nz-1) ;
00076     int nr = mp->get_mg()->get_nr(nz-1) ;
00077     
00078     del_deriv() ;
00079     
00080     va.coef() ;
00081     va.set_etat_cf_qcq() ;
00082     
00083     for (int k=0 ; k<np+1 ; k++)
00084     if (k!=1)
00085         for (int j=0 ; j<nt ; j++)
00086         for (int i=nr-1 ; i>nr-1-n ; i--)
00087             va.c_cf->set(nz-1, k, j, i) = 0 ;
00088 }
00089 
00090 /*
00091  * Annule les n derniers coefficients en phi dans zone nz
00092  */
00093  
00094 void Cmp::filtre_phi (int n, int nz) {
00095     assert (etat != ETATNONDEF) ;
00096     if (etat == ETATZERO)
00097     return ;
00098     
00099     del_deriv() ;
00100     
00101     va.coef() ;
00102     va.set_etat_cf_qcq() ;
00103     int np = mp->get_mg()->get_np(nz) ;
00104     int nt = mp->get_mg()->get_nt(nz) ;
00105     int nr = mp->get_mg()->get_nr(nz) ;
00106     
00107     for (int k=np+1-n ; k<np+1 ; k++)
00108     for (int j=0 ; j<nt ; j++)
00109         for (int i=0 ; i<nr ; i++)
00110         va.c_cf->set(nz, k, j, i) = 0 ;
00111 }
00112 
00113 /*
00114  * Fixe la valeur a l'infini (si la derniere zone est compactifiee) 
00115  * d'un Cmp a val
00116  * Utile quand on a affaire a des nan0x10000000
00117  */
00118 
00119 void Cmp::set_val_inf (double val) {
00120     
00121     assert (etat != ETATNONDEF) ;
00122     if (etat == ETATZERO) {
00123     if (val == 0)
00124         return ;
00125     else
00126         annule_hard() ;
00127     }
00128     del_deriv() ;
00129     
00130     int nz = mp->get_mg()->get_nzone() ;
00131     
00132     // On verifie la compactification
00133     assert (mp->get_mg()->get_type_r(nz-1) == UNSURR) ;
00134     
00135     int nr = mp->get_mg()->get_nr(nz-1) ;
00136     int nt = mp->get_mg()->get_nt(nz-1) ;
00137     int np = mp->get_mg()->get_np(nz-1) ;
00138     
00139     va.coef_i() ;
00140     va.set_etat_c_qcq() ;
00141     
00142     for (int k=0 ; k<np ; k++)
00143     for (int j=0 ; j<nt ; j++)
00144         va.set(nz-1, k, j, nr-1) = val ;
00145 }
00146 
00147 /*
00148  * Fixe la valeur d'un Cmp a val, sur la frontiere interne de la coquille zone.
00149  * Utile quand on a affaire a des nan0x10000000
00150  */
00151 
00152 void Cmp::set_val_hor (double val, int zone) {
00153     
00154     assert (etat != ETATNONDEF) ;
00155     if (etat == ETATZERO) {
00156     if (val == 0)
00157         return ;
00158     else
00159         annule_hard() ;
00160     }
00161     assert (zone < mp->get_mg()->get_nzone()) ;
00162     del_deriv() ;
00163     
00164     int nt = mp->get_mg()->get_nt(zone) ;
00165     int np = mp->get_mg()->get_np(zone) ;
00166     
00167     va.coef_i() ;
00168     va.set_etat_c_qcq() ;
00169     
00170     for (int k=0 ; k<np ; k++)
00171     for (int j=0 ; j<nt ; j++)
00172         va.set(zone, k, j, 0) = val ;
00173 }
00174 
00175 /*
00176  * Permet de fixer la decroissance du cmp a l infini en viurant les 
00177  * termes en 1/r^n
00178  */
00179 void Cmp::fixe_decroissance (int puis) {
00180     
00181     if (puis<dzpuis)
00182     return ;
00183     else {
00184     
00185     int nbre = puis-dzpuis ;
00186     
00187     // le confort avant tout ! (c'est bien le confort ...)
00188     int nz = mp->get_mg()->get_nzone() ;
00189     int np = mp->get_mg()->get_np(nz-1) ;
00190     int nt = mp->get_mg()->get_nt(nz-1) ;
00191     int nr = mp->get_mg()->get_nr(nz-1) ;
00192     
00193     const Map_af* map  = dynamic_cast<const Map_af*>(mp) ;
00194     if (map == 0x0) {
00195         cout << "Le mapping doit etre affine" << endl ;
00196         abort() ;
00197     }
00198     
00199     double alpha = map->get_alpha()[nz-1] ;
00200     
00201     Cmp courant (*this) ;
00202     
00203     va.coef() ;
00204     va.set_etat_cf_qcq() ;
00205     
00206     for (int conte=0 ; conte<nbre ; conte++) {
00207         
00208         int base_r = courant.va.base.get_base_r(nz-1) ;
00209         
00210         courant.va.coef() ;
00211         
00212         // On calcul les coefficients de 1/r^conte
00213         double* coloc = new double [nr] ;
00214         int * deg = new int[3] ;
00215         deg[0] = 1 ; 
00216         deg[1] = 1 ;
00217         deg[2] = nr ;
00218             
00219         for (int i=0 ; i<nr ; i++)
00220         coloc[i] =pow(alpha, double(conte))*
00221             pow(-1-cos(M_PI*i/(nr-1)), double(conte)) ;
00222             
00223         cfrcheb(deg, deg, coloc, deg, coloc) ;
00224         
00225         for (int k=0 ; k<np+1 ; k++)
00226         if (k != 1)
00227         for (int j=0 ; j<nt ; j++) {
00228             
00229             // On doit determiner le coefficient du truc courant :
00230             double* coef = new double [nr] ;
00231             double* auxi = new double[1] ;
00232             for (int i=0 ; i<nr ; i++)
00233             coef[i] = (*courant.va.c_cf)(nz-1, k, j, i) ;
00234             switch (base_r) {
00235             case R_CHEBU :
00236             som_r_chebu (coef, nr, 1, 1, 1, auxi) ;
00237             break ;
00238             default :
00239             som_r_pas_prevu (coef, nr, 1, 1, 1, auxi) ;
00240             break ;
00241             }
00242             
00243             // On modifie le cmp courant :
00244             courant.va.coef() ;
00245             courant.va.set_etat_cf_qcq() ;
00246             courant.va.c_cf->set(nz-1, k, j, 0) -= *auxi ;  
00247             
00248             for (int i=0 ; i<nr ; i++)
00249                 this->va.c_cf->set(nz-1, k, j, i) -= *auxi * coloc[i] ;
00250 
00251               
00252             delete [] coef ;
00253             delete [] auxi ;
00254         }
00255         delete [] coloc ;
00256         delete [] deg ;
00257         
00258         courant.mult_r_zec() ;
00259     }
00260     }
00261 }

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