evolution.h

00001 /*
00002  *  Definition of Lorene template classes Evolution, Evolution_full
00003  *  and Evolution_std
00004  *
00005  */
00006 
00007 /*
00008  *   Copyright (c) 2004  Eric Gourgoulhon & Jerome Novak
00009  *
00010  *   This file is part of LORENE.
00011  *
00012  *   LORENE is free software; you can redistribute it and/or modify
00013  *   it under the terms of the GNU General Public License version 2
00014  *   as published by the Free Software Foundation.
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 __EVOLUTION_H_ 
00029 #define __EVOLUTION_H_ 
00030 
00031 /*
00032  * $Id: evolution.h,v 1.12 2004/11/26 09:28:50 p_grandclement Exp $
00033  * $Log: evolution.h,v $
00034  * Revision 1.12  2004/11/26 09:28:50  p_grandclement
00035  * using in Derived templates are now public
00036  *
00037  * Revision 1.11  2004/11/25 07:53:53  e_gourgoulhon
00038  * Added directives
00039  *        using Evolution<TyT>::...
00040  * to comply with g++ 3.4.
00041  *
00042  * Revision 1.10  2004/05/11 20:11:49  e_gourgoulhon
00043  * Class Evolution:
00044  *  -- suppressed method get_jtop()
00045  *  -- added methods j_min(), j_max() and save().
00046  *
00047  * Revision 1.9  2004/03/26 13:31:08  j_novak
00048  * Definition of the macro UNDEF_STEP for non-defined time-steps.
00049  * Changes in the way the time derivative is calculated.
00050  *
00051  * Revision 1.8  2004/03/26 08:22:12  e_gourgoulhon
00052  * *** Full reorganization of class Evolution ***
00053  * Introduction of the notion of absoluteuniversal time steps,
00054  * stored in the new array 'step'.
00055  * The new function position(int j) makes a correspondence
00056  * between a universal time step j and the position in the
00057  * arrays step, the_time and val.
00058  * Only method update is now virtual.
00059  * Methods operator[], position, is_known, downdate belong to
00060  * the base class.
00061  *
00062  * Revision 1.7  2004/03/24 14:55:46  e_gourgoulhon
00063  * Added method last_value().
00064  *
00065  * Revision 1.6  2004/03/23 14:50:40  e_gourgoulhon
00066  * Added methods is_updated, downdate, get_jlast, get_size,
00067  * as well as constructors without any initial value.
00068  * Formatted documentation for Doxygen.
00069  *
00070  * Revision 1.5  2004/03/06 21:13:13  e_gourgoulhon
00071  * Added time derivation (method time_derive).
00072  *
00073  * Revision 1.4  2004/02/16 17:37:17  j_novak
00074  * Arguments named for doc++.
00075  *
00076  * Revision 1.3  2004/02/16 10:36:03  e_gourgoulhon
00077  * Replaced " = 0x0" by " = 0" in the declaration of pure virtual functions.
00078  *
00079  * Revision 1.2  2004/02/15 21:55:32  e_gourgoulhon
00080  * Introduced derived classes Evolution_full and Evolution_std.
00081  * Evolution is now an abstract base class.
00082  *
00083  * Revision 1.1  2004/02/13 15:53:20  e_gourgoulhon
00084  * New (template) class for time evolution.
00085  *
00086  *
00087  *
00088  *
00089  * $Header: /cvsroot/Lorene/C++/Include/evolution.h,v 1.12 2004/11/26 09:28:50 p_grandclement Exp $
00090  *
00091  */
00092 
00093 #define UNDEF_STEP  -100000
00094 
00095                         //---------------------------//
00096                         //      Class Evolution      //
00097                         //---------------------------//
00098 
00099 
00110 template<typename TyT> class Evolution {
00111 
00112         
00113     // Data:
00114     // -----
00115     
00116     protected: 
00118         int size ; 
00119         
00121         int* step ; 
00122         
00124         double* the_time ; 
00125       
00127         TyT** val ; 
00128         
00132         int pos_jtop ; 
00133       
00134         
00135     // Constructors - Destructor
00136     // -------------------------
00137     protected:
00141         Evolution(const TyT& initial_value, int initial_j, 
00142                   double initial_time, int initial_size) ;          
00143     
00146         Evolution(int initial_size) ;           
00147     
00148         Evolution(const Evolution<TyT>& t_in) ;     
00149 
00150     public: 
00151 
00152     virtual ~Evolution() ;          
00153  
00154     // Mutators 
00155     // --------
00156     public:
00159         virtual void update(const TyT& new_value, int j, 
00160                             double time_j) = 0 ; 
00161         
00164         void downdate(int j) ; 
00165         
00167         virtual void operator=(const Evolution<TyT>& t_in) ;
00168 
00169     
00170     // Accessors
00171     // ---------
00172     protected: 
00176         int position(int j) const ; 
00177         
00178     public:
00180         const TyT& operator[](int j) const ;
00181 
00183         double get_time(int j) const {return the_time[position(j)];} ;
00184         
00186         TyT operator()(double t) const ;
00187 
00189         int get_size() const {return size; } ; 
00190         
00192         int j_min() const ; 
00193 
00195         int j_max() const ; 
00196 
00202         bool is_known(int j) const ; 
00203         
00204         
00205 
00206     // Computational methods
00207     // ---------------------
00220         TyT time_derive(int j, int n = 2) const ; 
00221 
00222     // Outputs
00223     // -------
00224     
00232          void save(const char* filename) const ; 
00233 
00234 };
00235 
00236 
00237                         //---------------------------//
00238                         //   Class Evolution_full    //
00239                         //---------------------------//
00240 
00241 
00254 template<typename TyT> class Evolution_full : public Evolution<TyT> {
00255 
00256    public:
00257     using Evolution<TyT>::size ; 
00258     using Evolution<TyT>::step ; 
00259     using Evolution<TyT>::the_time ; 
00260     using Evolution<TyT>::val ; 
00261     using Evolution<TyT>::pos_jtop ; 
00262     using Evolution<TyT>::downdate ; 
00263     using Evolution<TyT>::position ; 
00264     using Evolution<TyT>::get_time ; 
00265     using Evolution<TyT>::get_size ; 
00266     using Evolution<TyT>::j_min ; 
00267     using Evolution<TyT>::j_max ; 
00268     using Evolution<TyT>::is_known ; 
00269         
00270     // Data:
00271     // -----
00272     
00273     private:
00278          int fact_resize ; 
00279         
00280     // Constructors - Destructor
00281     // -------------------------
00282     public:
00293         Evolution_full(const TyT& initial_value, int initial_j = 0,
00294                        double initial_time = 0., int fact_resize_i = 2) ;           
00295     
00303         Evolution_full(int fact_resize_i = 2) ;         
00304     
00305     
00306         Evolution_full(const Evolution_full<TyT>& t_in) ;  
00307 
00308         virtual ~Evolution_full() ;         
00309  
00310     // Mutators 
00311     // --------
00312     public:
00318         virtual void update(const TyT& new_value, int j, 
00319                             double time_j) ; 
00320         
00322         virtual void operator=(const Evolution_full<TyT>& t_in) ;
00323 
00325         virtual void operator=(const Evolution<TyT>& t_in) ;
00326 
00327     
00328     // Accessors
00329     // ---------
00330 
00331     // Outputs
00332     // -------
00333     
00334     
00335 
00336 };
00337 
00338 
00339                         //---------------------------//
00340                         //   Class Evolution_std     //
00341                         //---------------------------//
00342 
00343 
00355 template<typename TyT> class Evolution_std : public Evolution<TyT> {
00356 
00357    public:
00358     using Evolution<TyT>::size ; 
00359     using Evolution<TyT>::step ; 
00360     using Evolution<TyT>::the_time ; 
00361     using Evolution<TyT>::val ; 
00362     using Evolution<TyT>::pos_jtop ; 
00363     using Evolution<TyT>::downdate ; 
00364     using Evolution<TyT>::position ; 
00365     using Evolution<TyT>::get_time ; 
00366     using Evolution<TyT>::get_size ; 
00367     using Evolution<TyT>::j_min ; 
00368     using Evolution<TyT>::j_max ; 
00369     using Evolution<TyT>::is_known ; 
00370                 
00371     // Constructors - Destructor
00372     // -------------------------
00373     public:
00382         Evolution_std(const TyT& initial_value, int nstored, 
00383                       int initial_j = 0, double initial_time = 0.) ;            
00384     
00390         Evolution_std(int nstored) ;            
00391     
00392     
00393         Evolution_std(const Evolution_std<TyT>& t_in) ; 
00394 
00395         virtual ~Evolution_std() ;          
00396  
00397     // Mutators 
00398     // --------
00404         virtual void update(const TyT& new_value, int j, double time_j) ; 
00405     
00407         virtual void operator=(const Evolution_std<TyT>& t_in) ;
00408 
00410         virtual void operator=(const Evolution<TyT>& t_in) ;
00411 
00412     // Accessors
00413     // ---------
00414 
00415     // Outputs
00416     // -------
00417     
00418     
00419 
00420 };
00421 
00422 
00423 #include "Template/evolution.C"
00424 #include "Template/evolution_full.C"
00425 #include "Template/evolution_std.C"
00426 
00427 #endif
00428 

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