mtbl.h
/*
* Definition of Lorene class Mtbl
*
*/
/*
* Copyright (c) 1999-2000 Jean-Alain Marck
* Copyright (c) 1999-2001 Eric Gourgoulhon
*
* 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 as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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 __MTBL_H_
#define __MTBL_H_
/*
* $Id: mtbl.h,v 1.7 2014/10/13 08:52:36 j_novak Exp $
* $Log: mtbl.h,v $
* Revision 1.7 2014/10/13 08:52:36 j_novak
* Lorene classes and functions now belong to the namespace Lorene.
*
* Revision 1.6 2012/01/17 10:22:13 j_penner
* function added: Heaviside
*
* Revision 1.5 2004/03/22 13:12:42 j_novak
* Modification of comments to use doxygen instead of doc++
*
* Revision 1.4 2003/11/06 14:43:37 e_gourgoulhon
* Gave a name to const arguments in certain method prototypes (e.g.
* constructors) to correct a bug of DOC++.
*
* Revision 1.3 2002/09/13 09:17:33 j_novak
* Modif. commentaires
*
* Revision 1.2 2002/06/17 14:05:17 j_novak
* friend functions are now also declared outside the class definition
*
* Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon
* LORENE
*
* Revision 2.9 2000/08/16 10:29:45 eric
* Suppression du membre dzpuis.
*
* Revision 2.8 2000/08/04 11:40:58 eric
* Ajout de l'operateur (int l) et de la fonction set(int l) pour l'acces
* individuel aux Tbl.
*
* Revision 2.7 1999/12/02 17:55:07 phil
* *** empty log message ***
*
* Revision 2.6 1999/10/29 15:05:43 eric
* Suppression des fonctions membres min() et max():
* elles deviennent des fonctions externes.
* Ajout de fonctions mathematiques (abs, norme, etc...).
*
* Revision 2.5 1999/10/18 15:06:25 eric
* La fonction membre annule() est rebaptisee annule_hard().
* Introduction de la fonction membre annule(int, int).
*
* Revision 2.4 1999/10/01 10:35:58 eric
* Amelioration des commentaires.
*
* Revision 2.3 1999/10/01 10:08:25 eric
* Depoussierage
* Documentation.
*
* Revision 2.2 1999/03/02 18:54:50 eric
* Ajout de la fonction affiche_seuil.
*
* Revision 2.1 1999/02/22 15:23:49 hyc
* *** empty log message ***
*
*
* Revision 2.0 1999/01/15 09:10:39 hyc
* *** empty log message ***
*
*
* $Header: /cvsroot/Lorene/C++/Include/mtbl.h,v 1.7 2014/10/13 08:52:36 j_novak Exp $
*
*/
// Headers Lorene
#include "tbl.h"
#include "grilles.h"
namespace Lorene {
class Coord ;
class Mtbl {
// Data :
// -----
private:
const Mg3d* mg ;
int nzone ;
int etat ;
public:
Tbl** t;
// Constructors - Destructor
// -------------------------
public:
explicit Mtbl(const Mg3d& mgrid) ;
explicit Mtbl(const Mg3d* p_mgrid) ;
Mtbl(const Mg3d&, FILE* ) ;
Mtbl(const Coord& c) ;
Mtbl(const Mtbl& a) ;
~Mtbl() ;
// Assignement
// -----------
public:
void operator=(const Mtbl& ) ;
void operator=(double ) ;
void operator=(int ) ;
// Memory management
// -----------------
private:
void del_t() ;
public:
void set_etat_nondef() ;
void set_etat_zero() ;
void set_etat_qcq() ;
void annule_hard() ;
void annule(int l_min, int l_max) ;
// Access to individual elements
// -----------------------------
public:
Tbl& set(int l) {
assert(l < nzone) ;
assert(etat == ETATQCQ) ;
return *(t[l]) ;
};
const Tbl& operator()(int l) const {
assert(l < nzone) ;
assert(etat == ETATQCQ) ;
return *(t[l]) ;
};
double& set(int l, int k, int j, int i) {
assert(l < nzone) ;
assert(etat == ETATQCQ) ;
return (t[l])->set(k, j, i) ;
};
double operator()(int l, int k, int j, int i) const {
assert(etat != ETATNONDEF) ;
assert(l < nzone) ;
if (etat == ETATZERO) {
double zero = 0. ;
return zero ;
}
else return (*t[l])(k, j, i) ;
};
// Extraction of information
// -------------------------
public:
const Mg3d* get_mg() const { return mg ; };
int get_etat() const { return etat ; };
int get_nzone() const { return nzone ; } ;
// Outputs
// -------
public:
void sauve(FILE *) const ;
void affiche_seuil(ostream& ostr, int precision = 4,
double threshold = 1.e-7) const ;
friend ostream& operator<<(ostream& , const Mtbl & ) ;
// Member arithmetics
// ------------------
public:
void operator+=(const Mtbl & ) ;
void operator+=(double ) ;
void operator-=(const Mtbl & ) ;
void operator-=(double ) ;
void operator*=(const Mtbl & ) ;
void operator*=(double ) ;
void operator/=(const Mtbl & ) ;
void operator/=(double ) ;
} ;
ostream& operator<<(ostream& , const Mtbl & ) ;
Mtbl operator+(const Mtbl& ) ;
Mtbl operator-(const Mtbl& ) ;
Mtbl operator+(const Mtbl&, const Mtbl& ) ;
Mtbl operator+(const Mtbl&, double ) ;
Mtbl operator+(double , const Mtbl& ) ;
Mtbl operator+(const Mtbl&, int ) ;
Mtbl operator+(int, const Mtbl& ) ;
Mtbl operator-(const Mtbl&, const Mtbl& ) ;
Mtbl operator-(const Mtbl&, double ) ;
Mtbl operator-(double, const Mtbl& ) ;
Mtbl operator-(const Mtbl&, int ) ;
Mtbl operator-(int, const Mtbl& ) ;
Mtbl operator*(const Mtbl&, const Mtbl& ) ;
Mtbl operator*(const Mtbl&, double ) ;
Mtbl operator*(double, const Mtbl& ) ;
Mtbl operator*(const Mtbl&, int ) ;
Mtbl operator*(int, const Mtbl& ) ;
Mtbl operator/(const Mtbl&, const Mtbl& ) ;
Mtbl operator/(const Mtbl&, double ) ;
Mtbl operator/(double, const Mtbl& ) ;
Mtbl operator/(const Mtbl&, int ) ;
Mtbl operator/(int, const Mtbl& ) ;
Mtbl sin(const Mtbl& ) ;
Mtbl cos(const Mtbl& ) ;
Mtbl tan(const Mtbl& ) ;
Mtbl asin(const Mtbl& ) ;
Mtbl acos(const Mtbl& ) ;
Mtbl atan(const Mtbl& ) ;
Mtbl exp(const Mtbl& ) ;
Mtbl Heaviside(const Mtbl& ) ;
Mtbl log(const Mtbl& ) ;
Mtbl log(const Mtbl& ) ;
Mtbl log10(const Mtbl& ) ;
Mtbl sqrt(const Mtbl& ) ;
Mtbl racine_cubique (const Mtbl&) ;
Mtbl pow(const Mtbl& , int ) ;
Mtbl pow(const Mtbl& , double ) ;
Mtbl abs(const Mtbl& ) ;
double totalmax(const Mtbl& ) ;
double totalmin(const Mtbl& ) ;
Tbl max(const Mtbl& ) ;
Tbl min(const Mtbl& ) ;
Tbl norme(const Mtbl& ) ;
Tbl diffrel(const Mtbl& a, const Mtbl& b) ;
Tbl diffrelmax(const Mtbl& a, const Mtbl& b) ;
}
#endif
Lorene::Coord
Active physical coordinates and mapping derivatives.
Definition coord.h:90
Lorene::Mg3d
Multi-domain grid.
Definition grilles.h:273
Lorene::Mtbl
Multi-domain array.
Definition mtbl.h:118
Lorene::Mtbl::sauve
void sauve(FILE *) const
Save in a file.
Definition mtbl.C:209
Lorene::Mtbl::annule
void annule(int l_min, int l_max)
Sets the Mtbl to zero in some domains.
Definition mtbl.C:329
Lorene::Mtbl::operator()
double operator()(int l, int k, int j, int i) const
Read-only of a particular element.
Definition mtbl.h:259
Lorene::Mtbl::get_mg
const Mg3d * get_mg() const
Gives the Mg3d on which the Mtbl is defined.
Definition mtbl.h:274
Lorene::Mtbl::set
double & set(int l, int k, int j, int i)
Read/write of a particular element.
Definition mtbl.h:245
Lorene::Mtbl::operator<<
friend ostream & operator<<(ostream &, const Mtbl &)
Display.
Definition mtbl.C:365
Lorene::Mtbl::set
Tbl & set(int l)
Read/write of the Tbl in a given domain.
Definition mtbl.h:221
Lorene::Mtbl::~Mtbl
~Mtbl()
Destructor.
Definition mtbl.C:156
Lorene::Mtbl::get_etat
int get_etat() const
Gives the logical state.
Definition mtbl.h:277
Lorene::Mtbl::del_t
void del_t()
Logical destructor: dellocates the memory occupied by the Tbl array t .
Definition mtbl.C:277
Lorene::Mtbl::affiche_seuil
void affiche_seuil(ostream &ostr, int precision=4, double threshold=1.e-7) const
Prints only the values greater than a given threshold.
Definition mtbl.C:393
Lorene::Mtbl::Mtbl
Mtbl(const Mg3d &mgrid)
Constructor.
Definition mtbl.C:124
Lorene::Mtbl::operator/=
void operator/=(const Mtbl &)
/= Mtbl
Lorene::Mtbl::mg
const Mg3d * mg
Pointer on the multi-grid Mgd3 on which this is defined.
Definition mtbl.h:124
Lorene::Mtbl::operator+=
void operator+=(const Mtbl &)
+= Mtbl
Definition mtbl_arithm.C:513
Lorene::Mtbl::t
Tbl ** t
Array (size nzone ) of pointers on the Tbl 's.
Definition mtbl.h:132
Lorene::Mtbl::operator=
void operator=(const Mtbl &)
Assignement to another Mtbl.
Definition mtbl.C:224
Lorene::Mtbl::set_etat_qcq
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Definition mtbl.C:299
Lorene::Mtbl::set_etat_nondef
void set_etat_nondef()
Sets the logical state to ETATNONDEF (undefined).
Definition mtbl.C:293
Lorene::Mtbl::nzone
int nzone
Number of domains (zones).
Definition mtbl.h:126
Lorene::Mtbl::set_etat_zero
void set_etat_zero()
Sets the logical state to ETATZERO (zero).
Definition mtbl.C:287
Lorene::Mtbl::get_nzone
int get_nzone() const
Gives the number of zones (domains).
Definition mtbl.h:280
Lorene::Mtbl::operator*=
void operator*=(const Mtbl &)
*= Mtbl
Definition mtbl_arithm.C:557
Lorene::Mtbl::operator()
const Tbl & operator()(int l) const
Read-only of the Tbl in a given domain.
Definition mtbl.h:232
Lorene::Mtbl::etat
int etat
Logical state (ETATNONDEF , ETATQCQ or ETATZERO ).
Definition mtbl.h:128
Lorene::Mtbl::annule_hard
void annule_hard()
Sets the Mtbl to zero in a hard way.
Definition mtbl.C:312
Lorene::Mtbl::operator-=
void operator-=(const Mtbl &)
-= Mtbl
Definition mtbl_arithm.C:535
Lorene::Tbl
Basic array class.
Definition tbl.h:161
Lorene::operator*
Base_val operator*(const Base_val &, const Base_val &)
This operator is used when calling multiplication or division of Valeur .
Definition base_val_mult.C:102
Lorene::operator-
Cmp operator-(const Cmp &)
- Cmp
Definition cmp_arithm.C:108
Lorene::atan
Cmp atan(const Cmp &)
Arctangent.
Definition cmp_math.C:195
Lorene::sqrt
Cmp sqrt(const Cmp &)
Square root.
Definition cmp_math.C:220
Lorene::log10
Cmp log10(const Cmp &)
Basis 10 logarithm.
Definition cmp_math.C:322
Lorene::operator/
Cmp operator/(const Cmp &, const Cmp &)
Cmp / Cmp.
Definition cmp_arithm.C:457
Lorene::exp
Cmp exp(const Cmp &)
Exponential.
Definition cmp_math.C:270
Lorene::sin
Cmp sin(const Cmp &)
Sine.
Definition cmp_math.C:69
Lorene::diffrel
Tbl diffrel(const Cmp &a, const Cmp &b)
Relative difference between two Cmp (norme version).
Definition cmp_math.C:504
Lorene::norme
Tbl norme(const Cmp &)
Sums of the absolute values of all the values of the Cmp in each domain.
Definition cmp_math.C:481
Lorene::acos
Cmp acos(const Cmp &)
Arccosine.
Definition cmp_math.C:169
Lorene::asin
Cmp asin(const Cmp &)
Arcsine.
Definition cmp_math.C:144
Lorene::racine_cubique
Cmp racine_cubique(const Cmp &)
Cube root.
Definition cmp_math.C:245
Lorene::min
Tbl min(const Cmp &)
Minimum values of a Cmp in each domain.
Definition cmp_math.C:458
Lorene::max
Tbl max(const Cmp &)
Maximum values of a Cmp in each domain.
Definition cmp_math.C:435
Lorene::pow
Cmp pow(const Cmp &, int)
Power .
Definition cmp_math.C:348
Lorene::cos
Cmp cos(const Cmp &)
Cosine.
Definition cmp_math.C:94
Lorene::abs
Cmp abs(const Cmp &)
Absolute value.
Definition cmp_math.C:410
Lorene::diffrelmax
Tbl diffrelmax(const Cmp &a, const Cmp &b)
Relative difference between two Cmp (max version).
Definition cmp_math.C:539
Lorene::operator+
Cmp operator+(const Cmp &)
Definition cmp_arithm.C:104
Lorene::tan
Cmp tan(const Cmp &)
Tangent.
Definition cmp_math.C:120
Lorene::log
Cmp log(const Cmp &)
Neperian logarithm.
Definition cmp_math.C:296
Lorene::Heaviside
Mtbl Heaviside(const Mtbl &)
Heaviside function.
Definition mtbl_math.C:317
Lorene::totalmin
double totalmin(const Mtbl &)
Minimum value of the Mtbl elements in all domain.
Definition mtbl_math.C:522
Lorene::totalmax
double totalmax(const Mtbl &)
Maximum value of the Mtbl elements in all domains.
Definition mtbl_math.C:494
Lorene
Lorene prototypes.
Definition app_hor.h:64