evolution.h
/*
* Definition of Lorene template classes Evolution, Evolution_full
* and Evolution_std
*
*/
/*
* Copyright (c) 2004 Eric Gourgoulhon & Jerome Novak
*
* This file is part of LORENE.
*
* LORENE is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* LORENE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LORENE; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef __EVOLUTION_H_
#define __EVOLUTION_H_
/*
* $Id: evolution.h,v 1.15 2014/10/13 08:52:34 j_novak Exp $
* $Log: evolution.h,v $
* Revision 1.15 2014/10/13 08:52:34 j_novak
* Lorene classes and functions now belong to the namespace Lorene.
*
* Revision 1.14 2014/03/27 16:59:41 j_novak
* Added methods next_position(int) and previous_position(int). Changed (corrected + simplified) the interpolation method.
*
* Revision 1.13 2013/07/19 15:50:24 j_novak
* Implementation of the interpolation function for Evolution, with order=0, 1 or 2.
*
* Revision 1.12 2004/11/26 09:28:50 p_grandclement
* using in Derived templates are now public
*
* Revision 1.11 2004/11/25 07:53:53 e_gourgoulhon
* Added directives
* using Evolution<TyT>::...
* to comply with g++ 3.4.
*
* Revision 1.10 2004/05/11 20:11:49 e_gourgoulhon
* Class Evolution:
* -- suppressed method get_jtop()
* -- added methods j_min(), j_max() and save().
*
* Revision 1.9 2004/03/26 13:31:08 j_novak
* Definition of the macro UNDEF_STEP for non-defined time-steps.
* Changes in the way the time derivative is calculated.
*
* Revision 1.8 2004/03/26 08:22:12 e_gourgoulhon
* *** Full reorganization of class Evolution ***
* Introduction of the notion of absoluteuniversal time steps,
* stored in the new array 'step'.
* The new function position(int j) makes a correspondence
* between a universal time step j and the position in the
* arrays step, the_time and val.
* Only method update is now virtual.
* Methods operator[], position, is_known, downdate belong to
* the base class.
*
* Revision 1.7 2004/03/24 14:55:46 e_gourgoulhon
* Added method last_value().
*
* Revision 1.6 2004/03/23 14:50:40 e_gourgoulhon
* Added methods is_updated, downdate, get_jlast, get_size,
* as well as constructors without any initial value.
* Formatted documentation for Doxygen.
*
* Revision 1.5 2004/03/06 21:13:13 e_gourgoulhon
* Added time derivation (method time_derive).
*
* Revision 1.4 2004/02/16 17:37:17 j_novak
* Arguments named for doc++.
*
* Revision 1.3 2004/02/16 10:36:03 e_gourgoulhon
* Replaced " = 0x0" by " = 0" in the declaration of pure virtual functions.
*
* Revision 1.2 2004/02/15 21:55:32 e_gourgoulhon
* Introduced derived classes Evolution_full and Evolution_std.
* Evolution is now an abstract base class.
*
* Revision 1.1 2004/02/13 15:53:20 e_gourgoulhon
* New (template) class for time evolution.
*
*
*
*
* $Header: /cvsroot/Lorene/C++/Include/evolution.h,v 1.15 2014/10/13 08:52:34 j_novak Exp $
*
*/
#define UNDEF_STEP -100000
//---------------------------//
// Class Evolution //
//---------------------------//
namespace Lorene {
template<typename TyT> class Evolution {
// Data:
// -----
protected:
int size ;
int* step ;
double* the_time ;
TyT** val ;
int pos_jtop ;
// Constructors - Destructor
// -------------------------
protected:
Evolution(const TyT& initial_value, int initial_j,
double initial_time, int initial_size) ;
Evolution(int initial_size) ;
Evolution(const Evolution<TyT>& t_in) ;
public:
virtual ~Evolution() ;
// Mutators
// --------
public:
virtual void update(const TyT& new_value, int j,
double time_j) = 0 ;
void downdate(int j) ;
virtual void operator=(const Evolution<TyT>& t_in) ;
// Accessors
// ---------
protected:
int position(int j) const ;
int next_position(int i) const ;
int previous_position(int i) const ;
public:
const TyT& operator[](int j) const ;
double get_time(int j) const {return the_time[position(j)];} ;
TyT operator()(double t, int order=2) const ;
int get_size() const {return size; } ;
int j_min() const ;
int j_max() const ;
bool is_known(int j) const ;
// Computational methods
// ---------------------
TyT time_derive(int j, int n = 2) const ;
// Outputs
// -------
void save(const char* filename) const ;
};
//---------------------------//
// Class Evolution_full //
//---------------------------//
template<typename TyT> class Evolution_full : public Evolution<TyT> {
public:
using Evolution<TyT>::size ;
using Evolution<TyT>::step ;
using Evolution<TyT>::the_time ;
using Evolution<TyT>::val ;
using Evolution<TyT>::pos_jtop ;
using Evolution<TyT>::downdate ;
using Evolution<TyT>::position ;
using Evolution<TyT>::get_time ;
using Evolution<TyT>::get_size ;
using Evolution<TyT>::j_min ;
using Evolution<TyT>::j_max ;
using Evolution<TyT>::is_known ;
// Data:
// -----
private:
int fact_resize ;
// Constructors - Destructor
// -------------------------
public:
Evolution_full(const TyT& initial_value, int initial_j = 0,
double initial_time = 0., int fact_resize_i = 2) ;
Evolution_full(int fact_resize_i = 2) ;
Evolution_full(const Evolution_full<TyT>& t_in) ;
virtual ~Evolution_full() ;
// Mutators
// --------
public:
virtual void update(const TyT& new_value, int j,
double time_j) ;
virtual void operator=(const Evolution_full<TyT>& t_in) ;
virtual void operator=(const Evolution<TyT>& t_in) ;
// Accessors
// ---------
// Outputs
// -------
};
//---------------------------//
// Class Evolution_std //
//---------------------------//
template<typename TyT> class Evolution_std : public Evolution<TyT> {
public:
using Evolution<TyT>::size ;
using Evolution<TyT>::step ;
using Evolution<TyT>::the_time ;
using Evolution<TyT>::val ;
using Evolution<TyT>::pos_jtop ;
using Evolution<TyT>::downdate ;
using Evolution<TyT>::position ;
using Evolution<TyT>::get_time ;
using Evolution<TyT>::get_size ;
using Evolution<TyT>::j_min ;
using Evolution<TyT>::j_max ;
using Evolution<TyT>::is_known ;
// Constructors - Destructor
// -------------------------
public:
Evolution_std(const TyT& initial_value, int nstored,
int initial_j = 0, double initial_time = 0.) ;
Evolution_std(int nstored) ;
Evolution_std(const Evolution_std<TyT>& t_in) ;
virtual ~Evolution_std() ;
// Mutators
// --------
virtual void update(const TyT& new_value, int j, double time_j) ;
virtual void operator=(const Evolution_std<TyT>& t_in) ;
virtual void operator=(const Evolution<TyT>& t_in) ;
// Accessors
// ---------
// Outputs
// -------
};
}
#include "Template/evolution.C"
#include "Template/evolution_full.C"
#include "Template/evolution_std.C"
#endif
Lorene::Evolution_full::Evolution_full
Evolution_full(const TyT &initial_value, int initial_j=0, double initial_time=0., int fact_resize_i=2)
Constructor from initial value.
Definition evolution_full.C:95
Lorene::Evolution_full::update
virtual void update(const TyT &new_value, int j, double time_j)
Sets a new value at a given time step.
Definition evolution_full.C:176
Lorene::Evolution_full::operator=
virtual void operator=(const Evolution_full< TyT > &t_in)
Assignement to another Evolution_full.
Definition evolution_full.C:132
Lorene::Evolution_full::fact_resize
int fact_resize
Factor by which the size size of the arrays val and the_time are to be multiplied when their limits h...
Definition evolution.h:294
Lorene::Evolution_full::~Evolution_full
virtual ~Evolution_full()
Destructor.
Definition evolution_full.C:123
Lorene::Evolution_std::operator=
virtual void operator=(const Evolution_std< TyT > &t_in)
Assignement to another Evolution_std.
Definition evolution_std.C:129
Lorene::Evolution_std::Evolution_std
Evolution_std(const TyT &initial_value, int nstored, int initial_j=0, double initial_time=0.)
Constructor from initial value.
Definition evolution_std.C:93
Lorene::Evolution_std::~Evolution_std
virtual ~Evolution_std()
Destructor.
Definition evolution_std.C:119
Lorene::Evolution_std::update
virtual void update(const TyT &new_value, int j, double time_j)
Sets a new value at a given time step.
Definition evolution_std.C:171
Lorene::Evolution::get_size
int get_size() const
Returns the member size.
Definition evolution.h:205
Lorene::Evolution::downdate
void downdate(int j)
Suppresses a stored value.
Definition evolution.C:244
Lorene::Evolution::save
void save(const char *filename) const
Saves *this in a formatted file.
Definition evolution.C:589
Lorene::Evolution::Evolution
Evolution(const TyT &initial_value, int initial_j, double initial_time, int initial_size)
Constructor from some initial value.
Definition evolution.C:127
Lorene::Evolution::operator[]
const TyT & operator[](int j) const
Returns the value at time step j.
Definition evolution.C:360
Lorene::Evolution::j_max
int j_max() const
Returns the larger time step j stored in *this.
Definition evolution.C:482
Lorene::Evolution::next_position
int next_position(int i) const
Returns the next valid position (returns -1 if none is found).
Definition evolution.C:302
Lorene::Evolution::time_derive
TyT time_derive(int j, int n=2) const
Computes the time derivative at time step j by means of a n-th order scheme, from the values at steps...
Definition evolution.C:504
Lorene::Evolution::get_time
double get_time(int j) const
Returns the time t at time step j.
Definition evolution.h:199
Lorene::Evolution::val
TyT ** val
Array of pointers onto the values (size = size).
Definition evolution.h:137
Lorene::Evolution::operator()
TyT operator()(double t, int order=2) const
Returns the value at time t, with a scheme of order order.
Definition evolution.C:370
Lorene::Evolution::size
int size
Maximum number of stored time steps.
Definition evolution.h:128
Lorene::Evolution::~Evolution
virtual ~Evolution()
Destructor.
Definition evolution.C:214
Lorene::Evolution::step
int * step
Array of time step indices (size = size).
Definition evolution.h:131
Lorene::Evolution::pos_jtop
int pos_jtop
Position in the arrays step, the_time and val of the most evolved time step.
Definition evolution.h:142
Lorene::Evolution::j_min
int j_min() const
Returns the smaller time step j stored in *this.
Definition evolution.C:463
Lorene::Evolution::the_time
double * the_time
Array of values of t at the various time steps (size = size).
Definition evolution.h:134
Lorene::Evolution::update
virtual void update(const TyT &new_value, int j, double time_j)=0
Sets a new value at a given time step.
Lorene::Evolution::position
int position(int j) const
Gives the position in the arrays step, the_time and val corresponding to the time step j.
Definition evolution.C:273
Lorene::Evolution::is_known
bool is_known(int j) const
Checks whether the value a given time step has been set.
Definition evolution.C:335
Lorene::Evolution::operator=
virtual void operator=(const Evolution< TyT > &t_in)
Assignement.
Definition evolution.C:235
Lorene::Evolution::previous_position
int previous_position(int i) const
Returns the previous valid position (returns -1 if none is found).
Definition evolution.C:318
Lorene
Lorene prototypes.
Definition app_hor.h:64