grille_val.h

00001 /*
00002  *  Definition of Lorene class Grille_val, Gval_cart and Gval_spher
00003  *
00004  */
00005 
00006 /*
00007  *   Copyright (c) 2001 Jerome Novak
00008  *
00009  *   This file is part of LORENE.
00010  *
00011  *   LORENE is free software; you can redistribute it and/or modify
00012  *   it under the terms of the GNU General Public License as published by
00013  *   the Free Software Foundation; either version 2 of the License, or
00014  *   (at your option) any later version.
00015  *
00016  *   LORENE is distributed in the hope that it will be useful,
00017  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *   GNU General Public License for more details.
00020  *
00021  *   You should have received a copy of the GNU General Public License
00022  *   along with LORENE; if not, write to the Free Software
00023  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024  *
00025  */
00026 
00027 
00028 #ifndef __GRILLE_VAL_H_
00029 #define __GRILLE_VAL_H_
00030 
00031 /*
00032  * $Id: grille_val.h,v 1.9 2008/02/18 13:53:37 j_novak Exp $
00033  * $Log: grille_val.h,v $
00034  * Revision 1.9  2008/02/18 13:53:37  j_novak
00035  * Removal of special indentation instructions.
00036  *
00037  * Revision 1.8  2007/11/02 16:49:12  j_novak
00038  * Suppression of intermediate array for spectral summation.
00039  *
00040  * Revision 1.7  2005/06/22 09:09:38  lm_lin
00041  *
00042  * Grid wedding: convert from the old C++ object "Cmp" to "Scalar".
00043  *
00044  * Revision 1.6  2004/05/07 12:32:12  j_novak
00045  * New summation from spectral to FD grid. Much faster!
00046  *
00047  * Revision 1.5  2004/03/22 13:12:41  j_novak
00048  * Modification of comments to use doxygen instead of doc++
00049  *
00050  * Revision 1.4  2002/11/13 11:22:57  j_novak
00051  * Version "provisoire" de l'interpolation (sommation depuis la grille
00052  * spectrale) aux interfaces de la grille de Valence.
00053  *
00054  * Revision 1.3  2002/10/16 14:36:29  j_novak
00055  * Reorganization of #include instructions of standard C++, in order to
00056  * use experimental version 3 of gcc.
00057  *
00058  * Revision 1.2  2002/06/17 14:05:16  j_novak
00059  * friend functions are now also declared outside the class definition
00060  *
00061  * Revision 1.1  2001/11/22 13:38:09  j_novak
00062  * added Include files for Valencia objects: tbl_val.h and grille_val.h
00063  *
00064  *
00065  * $Header: /cvsroot/Lorene/C++/Include/grille_val.h,v 1.9 2008/02/18 13:53:37 j_novak Exp $
00066  *
00067  */
00068 
00069 
00070 #include <assert.h>
00071 #include <math.h>
00072 #include "tensor.h"
00073 
00087 class Grille_val {
00089   friend class Tbl_val ;
00090   
00091   // Data : 
00092   // -----
00093  protected:
00095   Dim_tbl dim ;
00097   int nfantome ;
00102   int type_t ;
00107   int type_p ;
00108 
00110   double *zrmin;
00111 
00113   double *zrmax ;
00114   
00115  public:
00117   Tbl *zr;
00119   Tbl *zri ;
00120 
00121   // Constructors - Destructor
00122   // -------------------------
00123  protected: 
00125   Tbl* fait_grille1D(const double rmin, const double rmax, const int n) ;
00126 
00128   Grille_val(const double, const double, const int n1,
00129          const int fantome = 2) ; 
00130   
00132   Grille_val(const double, const double, const int n2, const int n1, 
00133          const int itype_t, const int fantome = 2) ; 
00134 
00136   Grille_val(const double, const double, const int n3, const int n2, const
00137          int n1, const int itype_t, const int itype_p, const int
00138          fantome = 2); 
00139   
00140 
00142   Grille_val(const Grille_val& ) ;      
00143   
00145   Grille_val(FILE* ) ;          
00146   
00148   virtual ~Grille_val() ;           
00149   
00150   // Mutators / assignment
00151   // ---------------------
00152  public:
00153 
00155   void operator=(const Grille_val&) ;   
00156   
00157   // Accessors
00158   // ---------
00159  public:
00161   int get_fantome() const {
00162     return nfantome ;
00163   } ;
00164   
00166   int get_type_t() const {
00167     return type_t ;
00168   } ;
00169   
00171   int get_type_p() const {
00172     return type_p ;
00173   } ;
00174   
00176   int get_ndim() const {
00177     return dim.ndim ;
00178   } ;
00179   
00181   int get_dim(const int i) const {
00182     assert ( (i>=0) && (i<dim.ndim) ) ;
00183     return dim.dim[i] ;
00184   } ;
00185   
00187   const Dim_tbl* get_dim_tbl() const {
00188     return &dim ;
00189   } ;
00190 
00192   double get_zr(const int i) const {
00193     assert (i>= -nfantome) ;
00194     assert (i<dim.dim[0]+nfantome) ;
00195     
00196     return zr->t[i+nfantome] ;
00197   } ;
00198   
00200   double get_zri(const int i) const {
00201     assert (i>= -nfantome) ;
00202     assert (i<dim.dim[0]+nfantome+1) ;
00203     
00204     return zri->t[i+nfantome] ;
00205   } ;
00206   
00207   
00208   // Outputs
00209   // -------
00210  public:
00212   virtual void sauve(FILE *) const ;        
00213   
00215   friend ostream& operator<<(ostream& , const Grille_val& ) ;   
00216 
00217  protected:
00219   virtual ostream& operator>>(ostream& ) const ;    
00220   
00221   // Interpolation
00222   // -------------
00223  public:
00233   virtual bool compatible(const Map* mp, const int lmax, const int lmin=0) 
00234     const = 0 ;
00235 
00246   Tbl interpol1(const Tbl& rdep, const Tbl& rarr, const Tbl& fdep, 
00247            int flag, const int type_inter) const ;
00248 
00258   virtual Tbl interpol2(const Tbl& fdep, const Tbl& rarr, 
00259                const Tbl& tetarr, const int type_inter) const = 0 ;
00271   virtual Tbl interpol3(const Tbl& fdep, const Tbl& rarr, 
00272                const Tbl& tetarr, const Tbl& phiarr, 
00273                const int type_inter) const = 0 ;
00274 
00280   virtual bool contenue_dans(const Map& mp, const int lmax, const int lmin=0) 
00281     const = 0 ;
00282 
00283  protected:
00291   void somme_spectrale1(const Scalar& meudon, double* t, int taille) const ;
00292 
00294   virtual void somme_spectrale2(const Scalar& meudon, double* t, int taille) const = 0 ;
00295 
00297   virtual void somme_spectrale3(const Scalar& meudon, double* t, int taille) const = 0 ;
00298   
00299 };
00300 ostream& operator<<(ostream& , const Grille_val& ) ;    
00301 
00302 
00303             //------------------------------------//
00304             //      class Gval_cart       //
00305             //------------------------------------//
00306 
00318 class Gval_cart : public Grille_val {
00320   friend class Tbl_val ;
00321 
00322   // Data : 
00323   // -----
00324  protected:
00326   double *xmin ;
00328   double *xmax ;
00330   double *ymin ;
00332   double *ymax ;
00333   
00334  public:
00336   Tbl *x ;
00338   Tbl *xi ;
00340   Tbl *y ; 
00342   Tbl *yi ;
00343 
00344   // Constructors - Destructor
00345   // -------------------------
00346 
00354   Gval_cart(const double izmin, const double izmax, const int n1,
00355         const int fantome = 2) ; 
00356   
00371   Gval_cart(const double ixmin, const double ixmax, const double izmin, 
00372         const double izmax, const int nx, const int nz, const int type_t, 
00373         const int fantome = 2) ; 
00374 
00395   Gval_cart(const double iymin, const double iymax, const double ixmin, 
00396         const double ixmax, const double izmin, const double izmax, 
00397         const int ny, const int nx, const int nz, const int itype_t, 
00398         const int itype_p, const int fantome = 2); 
00399   
00401   Gval_cart(const Gval_cart& ) ;        
00402   
00404   Gval_cart(FILE* ) ;           
00405   
00407   virtual ~Gval_cart() ;            
00408   
00409   // Mutators / assignment
00410   // ---------------------
00411  public:
00412 
00414   void operator=(const Gval_cart&) ;    
00415   
00416   // Accessors
00417   // ---------
00418  public:
00420   double get_x(const int i) const {
00421     assert (i>= -nfantome) ;
00422     assert (i<dim.dim[1]+nfantome) ;
00423     assert (dim.ndim >= 2) ;
00424     
00425     return (*x)(i+nfantome) ;
00426   } ;
00427   
00429   double get_y(const int i) const {
00430     assert (i>= -nfantome) ;
00431     assert (i<dim.dim[2]+nfantome) ;
00432     assert (dim.ndim == 3) ;
00433     
00434     return (*y)(i+nfantome) ;
00435   } ;
00436   
00438   double get_xi(const int i) const {
00439     assert (i>= -nfantome) ;
00440     assert (i<dim.dim[1]+nfantome+1) ;
00441     assert (dim.ndim >= 2) ;
00442     
00443     return (*xi)(i+nfantome) ;
00444   } ;
00445   
00447   double get_yi(const int i) const {
00448     assert (i>= -nfantome) ;
00449     assert (i<dim.dim[2]+nfantome+1) ;
00450     assert (dim.ndim == 3) ;
00451     
00452     return (*yi)(i+nfantome) ;
00453   } ;   
00454   
00456   double get_xmin() const {
00457     return *xmin ;
00458   } ;
00459   
00461   double get_xmax() const {
00462     return *xmax ;
00463   } ;
00464   
00466   double get_ymin() const {
00467     return *ymin ;
00468   } ;
00469 
00471   double get_ymax() const {
00472     return *ymax ;
00473   } ;
00474   
00475   // Outputs
00476   // -------
00477  public:
00479   virtual void sauve(FILE *) const ;        
00480   
00481  protected:
00483   virtual ostream& operator>>(ostream& ) const ;    
00484   
00485   // Interpolation
00486   // -------------
00487  public:
00497   virtual bool compatible(const Map* mp, const int lmax, const int lmin=0) 
00498     const ;
00499 
00510   virtual Tbl interpol2(const Tbl& fdep, const Tbl& rarr, 
00511                const Tbl& tetarr, const int type_inter) const ;
00512 
00517   Tbl interpol2c(const Tbl& xdep, const Tbl& zdep, const Tbl& fdep, 
00518         const Tbl& rarr, const Tbl& tetarr, 
00519         const int type_inter) const ;
00531   virtual Tbl interpol3(const Tbl& fdep, const Tbl& rarr, 
00532                const Tbl& tetarr, const Tbl& phiarr, 
00533                const int type_inter) const ;
00539   virtual bool contenue_dans(const Map& mp, const int lmax, const int lmin=0) 
00540     const ;
00541 
00542  protected:
00550   virtual void somme_spectrale2(const Scalar& meudon, double* t, int taille) const  ;
00551 
00553   virtual void somme_spectrale3(const Scalar& meudon, double* t, int taille) const  ;
00554 };
00555 
00556             //------------------------------------//
00557             //      class Gval_spher          //
00558             //------------------------------------//
00559 
00572 class Gval_spher : public Grille_val {
00574   friend class Tbl_val ;
00575   
00576   // Data : 
00577   // -----
00578  public:
00580   Tbl *tet ;
00582   Tbl *teti ;
00584   Tbl *phi ;
00586   Tbl *phii ;
00587 
00588   // Constructors - Destructor
00589   // -------------------------
00590 
00598   Gval_spher(const double irmin, const double irmax, const int nr,
00599          const int fantome = 2) ; 
00600   
00611   Gval_spher(const double irmin, const double irmax, const int nt, const 
00612          int nr, const int type_t, const int fantome = 2) ; 
00613 
00627   Gval_spher(const double irmin, const double irmax, const int np, const 
00628          int nt, const int nr, const int itype_t, const int itype_p, 
00629          const int fantome = 2); 
00630   
00632   Gval_spher(const Gval_spher& ) ;      
00633   
00635   Gval_spher(FILE* ) ;          
00636   
00638   virtual ~Gval_spher() ;           
00639   
00640   // Mutators / assignment
00641   // ---------------------
00642  public:
00643 
00645   void operator=(const Gval_spher&) ;   
00646   
00647   // Accessors
00648   // ---------
00649  public:
00650 
00652   double get_tet(const int i) const {
00653     assert (i>= -nfantome) ;
00654     assert (dim.ndim >= 2) ;
00655     assert (i<dim.dim[1]+nfantome) ;
00656     
00657     return tet->t[i+nfantome] ;
00658   } ;
00659   
00661   double get_phi(const int i) const {
00662     assert (i>= -nfantome) ;
00663     assert (dim.ndim == 3) ;
00664     assert (i<dim.dim[2]+nfantome) ;
00665     
00666     return phi->t[i+nfantome] ;
00667   } ;
00668   
00670   double get_teti(const int i) const {
00671     assert (i>= -nfantome) ;
00672     assert (dim.ndim >= 2) ;
00673     assert (i<dim.dim[1]+nfantome+1) ;
00674     
00675     return teti->t[i+nfantome] ;
00676   } ;
00677   
00679   double get_phii(const int i) const {
00680     assert (i>= -nfantome) ;
00681     assert (dim.ndim == 3) ;
00682     assert (i<dim.dim[2]+nfantome+1) ;
00683     
00684     return phii->t[i+nfantome] ;
00685   } ;   
00686   
00687   // Outputs
00688   // -------
00689  public:
00691   virtual void sauve(FILE *) const ;        
00692   
00693  protected:
00695   virtual ostream& operator>>(ostream& ) const ;    
00696   
00697   // Interpolation
00698   // -------------
00699  public:
00709   virtual bool compatible(const Map* mp, const int lmax, const int lmin=0) 
00710     const ;
00711 
00722   virtual Tbl interpol2(const Tbl& fdep, const Tbl& rarr, const Tbl& tetarr, 
00723                const int type_inter) const ;
00736  virtual Tbl interpol3(const Tbl& fdep, const Tbl& rarr, const Tbl& tetarr, 
00737                const Tbl& phiarr, const int type_inter) const ;
00738 
00744  virtual bool contenue_dans(const Map& mp, const int lmax, const int lmin=0) 
00745     const ;
00746 
00747  protected:
00755   virtual void somme_spectrale2(const Scalar& meudon, double* t, int taille) const  ;
00756 
00758   double* somme_spectrale2ri(const Scalar& meudon) const ;
00759 
00761   double* somme_spectrale2ti(const Scalar& meudon) const ;
00762 
00764   virtual void somme_spectrale3(const Scalar& meudon, double* t, int taille) const  ;
00765 
00766   void initialize_spectral_r(const Map& mp, const Base_val& base, int*& idom, 
00767                  double*& chebnri) const ;
00768   void initialize_spectral_theta(const Map& mp, const Base_val& base, 
00769                  double*& tetlj) const ;
00770   void initialize_spectral_phi(const Map& mp, const Base_val& base,
00771                    double*& expmk) const ;
00772 
00773  };
00774 
00775 #endif
00776 
00777 

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