LORENE
mtbl.h
1/*
2 * Definition of Lorene class Mtbl
3 *
4 */
5
6/*
7 * Copyright (c) 1999-2000 Jean-Alain Marck
8 * Copyright (c) 1999-2001 Eric Gourgoulhon
9 *
10 * This file is part of LORENE.
11 *
12 * LORENE is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * LORENE is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with LORENE; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 */
27
28
29#ifndef __MTBL_H_
30#define __MTBL_H_
31
32/*
33 * $Id: mtbl.h,v 1.7 2014/10/13 08:52:36 j_novak Exp $
34 * $Log: mtbl.h,v $
35 * Revision 1.7 2014/10/13 08:52:36 j_novak
36 * Lorene classes and functions now belong to the namespace Lorene.
37 *
38 * Revision 1.6 2012/01/17 10:22:13 j_penner
39 * function added: Heaviside
40 *
41 * Revision 1.5 2004/03/22 13:12:42 j_novak
42 * Modification of comments to use doxygen instead of doc++
43 *
44 * Revision 1.4 2003/11/06 14:43:37 e_gourgoulhon
45 * Gave a name to const arguments in certain method prototypes (e.g.
46 * constructors) to correct a bug of DOC++.
47 *
48 * Revision 1.3 2002/09/13 09:17:33 j_novak
49 * Modif. commentaires
50 *
51 * Revision 1.2 2002/06/17 14:05:17 j_novak
52 * friend functions are now also declared outside the class definition
53 *
54 * Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon
55 * LORENE
56 *
57 * Revision 2.9 2000/08/16 10:29:45 eric
58 * Suppression du membre dzpuis.
59 *
60 * Revision 2.8 2000/08/04 11:40:58 eric
61 * Ajout de l'operateur (int l) et de la fonction set(int l) pour l'acces
62 * individuel aux Tbl.
63 *
64 * Revision 2.7 1999/12/02 17:55:07 phil
65 * *** empty log message ***
66 *
67 * Revision 2.6 1999/10/29 15:05:43 eric
68 * Suppression des fonctions membres min() et max():
69 * elles deviennent des fonctions externes.
70 * Ajout de fonctions mathematiques (abs, norme, etc...).
71 *
72 * Revision 2.5 1999/10/18 15:06:25 eric
73 * La fonction membre annule() est rebaptisee annule_hard().
74 * Introduction de la fonction membre annule(int, int).
75 *
76 * Revision 2.4 1999/10/01 10:35:58 eric
77 * Amelioration des commentaires.
78 *
79 * Revision 2.3 1999/10/01 10:08:25 eric
80 * Depoussierage
81 * Documentation.
82 *
83 * Revision 2.2 1999/03/02 18:54:50 eric
84 * Ajout de la fonction affiche_seuil.
85 *
86 * Revision 2.1 1999/02/22 15:23:49 hyc
87 * *** empty log message ***
88 *
89 *
90 * Revision 2.0 1999/01/15 09:10:39 hyc
91 * *** empty log message ***
92 *
93 *
94 * $Header: /cvsroot/Lorene/C++/Include/mtbl.h,v 1.7 2014/10/13 08:52:36 j_novak Exp $
95 *
96 */
97
98
99// Headers Lorene
100#include "tbl.h"
101#include "grilles.h"
102
103namespace Lorene {
104class Coord ;
105
118class Mtbl {
119
120 // Data :
121 // -----
122 private:
124 const Mg3d* mg ;
126 int nzone ;
128 int etat ;
129
130 public:
132 Tbl** t;
133
134 // Constructors - Destructor
135 // -------------------------
136
137 public:
139 explicit Mtbl(const Mg3d& mgrid) ;
141 explicit Mtbl(const Mg3d* p_mgrid) ;
143 Mtbl(const Mg3d&, FILE* ) ;
145 Mtbl(const Coord& c) ;
147 Mtbl(const Mtbl& a) ;
149 ~Mtbl() ;
150
151 // Assignement
152 // -----------
153 public:
155 void operator=(const Mtbl& ) ;
157 void operator=(double ) ;
159 void operator=(int ) ;
160
161 // Memory management
162 // -----------------
163 private:
167 void del_t() ;
168
169 public:
170
175 void set_etat_nondef() ;
176
181 void set_etat_zero() ;
182
189 void set_etat_qcq() ;
190
199 void annule_hard() ;
200
211 void annule(int l_min, int l_max) ;
212
213
214 // Access to individual elements
215 // -----------------------------
216 public:
221 Tbl& set(int l) {
222 assert(l < nzone) ;
223 assert(etat == ETATQCQ) ;
224 return *(t[l]) ;
225 };
226
227
232 const Tbl& operator()(int l) const {
233 assert(l < nzone) ;
234 assert(etat == ETATQCQ) ;
235 return *(t[l]) ;
236 };
237
245 double& set(int l, int k, int j, int i) {
246 assert(l < nzone) ;
247 assert(etat == ETATQCQ) ;
248 return (t[l])->set(k, j, i) ;
249 };
250
251
259 double operator()(int l, int k, int j, int i) const {
260 assert(etat != ETATNONDEF) ;
261 assert(l < nzone) ;
262 if (etat == ETATZERO) {
263 double zero = 0. ;
264 return zero ;
265 }
266 else return (*t[l])(k, j, i) ;
267 };
268
269
270 // Extraction of information
271 // -------------------------
272 public:
274 const Mg3d* get_mg() const { return mg ; };
275
277 int get_etat() const { return etat ; };
278
280 int get_nzone() const { return nzone ; } ;
281
282 // Outputs
283 // -------
284 public:
286 void sauve(FILE *) const ;
287
294 void affiche_seuil(ostream& ostr, int precision = 4,
295 double threshold = 1.e-7) const ;
297 friend ostream& operator<<(ostream& , const Mtbl & ) ;
298
299 // Member arithmetics
300 // ------------------
301 public:
303 void operator+=(const Mtbl & ) ;
305 void operator+=(double ) ;
307 void operator-=(const Mtbl & ) ;
309 void operator-=(double ) ;
311 void operator*=(const Mtbl & ) ;
313 void operator*=(double ) ;
315 void operator/=(const Mtbl & ) ;
317 void operator/=(double ) ;
318
319} ;
320ostream& operator<<(ostream& , const Mtbl & ) ;
321
329Mtbl operator+(const Mtbl& ) ;
331Mtbl operator-(const Mtbl& ) ;
333Mtbl operator+(const Mtbl&, const Mtbl& ) ;
335Mtbl operator+(const Mtbl&, double ) ;
337Mtbl operator+(double , const Mtbl& ) ;
339Mtbl operator+(const Mtbl&, int ) ;
341Mtbl operator+(int, const Mtbl& ) ;
343Mtbl operator-(const Mtbl&, const Mtbl& ) ;
345Mtbl operator-(const Mtbl&, double ) ;
347Mtbl operator-(double, const Mtbl& ) ;
349Mtbl operator-(const Mtbl&, int ) ;
351Mtbl operator-(int, const Mtbl& ) ;
353Mtbl operator*(const Mtbl&, const Mtbl& ) ;
355Mtbl operator*(const Mtbl&, double ) ;
357Mtbl operator*(double, const Mtbl& ) ;
359Mtbl operator*(const Mtbl&, int ) ;
361Mtbl operator*(int, const Mtbl& ) ;
363Mtbl operator/(const Mtbl&, const Mtbl& ) ;
365Mtbl operator/(const Mtbl&, double ) ;
367Mtbl operator/(double, const Mtbl& ) ;
369Mtbl operator/(const Mtbl&, int ) ;
371Mtbl operator/(int, const Mtbl& ) ;
372
374Mtbl sin(const Mtbl& ) ;
376Mtbl cos(const Mtbl& ) ;
378Mtbl tan(const Mtbl& ) ;
380Mtbl asin(const Mtbl& ) ;
382Mtbl acos(const Mtbl& ) ;
384Mtbl atan(const Mtbl& ) ;
386Mtbl exp(const Mtbl& ) ;
388Mtbl Heaviside(const Mtbl& ) ;
390Mtbl log(const Mtbl& ) ;
392Mtbl log(const Mtbl& ) ;
394Mtbl log10(const Mtbl& ) ;
396Mtbl sqrt(const Mtbl& ) ;
398Mtbl racine_cubique (const Mtbl&) ;
400Mtbl pow(const Mtbl& , int ) ;
402Mtbl pow(const Mtbl& , double ) ;
404Mtbl abs(const Mtbl& ) ;
405
410double totalmax(const Mtbl& ) ;
411
416double totalmin(const Mtbl& ) ;
417
423Tbl max(const Mtbl& ) ;
424
430Tbl min(const Mtbl& ) ;
431
437Tbl norme(const Mtbl& ) ;
438
447Tbl diffrel(const Mtbl& a, const Mtbl& b) ;
448
457Tbl diffrelmax(const Mtbl& a, const Mtbl& b) ;
458
462}
463#endif
Active physical coordinates and mapping derivatives.
Definition coord.h:90
Multi-domain grid.
Definition grilles.h:273
Multi-domain array.
Definition mtbl.h:118
void sauve(FILE *) const
Save in a file.
Definition mtbl.C:209
friend ostream & operator<<(ostream &, const Mtbl &)
Display.
Definition mtbl.C:365
void annule(int l_min, int l_max)
Sets the Mtbl to zero in some domains.
Definition mtbl.C:329
double operator()(int l, int k, int j, int i) const
Read-only of a particular element.
Definition mtbl.h:259
const Mg3d * get_mg() const
Gives the Mg3d on which the Mtbl is defined.
Definition mtbl.h:274
double & set(int l, int k, int j, int i)
Read/write of a particular element.
Definition mtbl.h:245
Tbl & set(int l)
Read/write of the Tbl in a given domain.
Definition mtbl.h:221
~Mtbl()
Destructor.
Definition mtbl.C:156
int get_etat() const
Gives the logical state.
Definition mtbl.h:277
void del_t()
Logical destructor: dellocates the memory occupied by the Tbl array t .
Definition mtbl.C:277
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
void operator/=(const Mtbl &)
/= Mtbl
const Mg3d * mg
Pointer on the multi-grid Mgd3 on which this is defined.
Definition mtbl.h:124
void operator+=(const Mtbl &)
+= Mtbl
Tbl ** t
Array (size nzone ) of pointers on the Tbl 's.
Definition mtbl.h:132
void operator=(const Mtbl &)
Assignement to another Mtbl.
Definition mtbl.C:224
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Definition mtbl.C:299
void set_etat_nondef()
Sets the logical state to ETATNONDEF (undefined).
Definition mtbl.C:293
int nzone
Number of domains (zones)
Definition mtbl.h:126
void set_etat_zero()
Sets the logical state to ETATZERO (zero).
Definition mtbl.C:287
int get_nzone() const
Gives the number of zones (domains)
Definition mtbl.h:280
void operator*=(const Mtbl &)
*= Mtbl
const Tbl & operator()(int l) const
Read-only of the Tbl in a given domain.
Definition mtbl.h:232
int etat
Logical state (ETATNONDEF , ETATQCQ or ETATZERO ).
Definition mtbl.h:128
void annule_hard()
Sets the Mtbl to zero in a hard way.
Definition mtbl.C:312
void operator-=(const Mtbl &)
-= Mtbl
Basic array class.
Definition tbl.h:161
Base_val operator*(const Base_val &, const Base_val &)
This operator is used when calling multiplication or division of Valeur .
Cmp operator-(const Cmp &)
- Cmp
Definition cmp_arithm.C:108
Cmp atan(const Cmp &)
Arctangent.
Definition cmp_math.C:195
Cmp sqrt(const Cmp &)
Square root.
Definition cmp_math.C:220
Cmp log10(const Cmp &)
Basis 10 logarithm.
Definition cmp_math.C:322
Cmp operator/(const Cmp &, const Cmp &)
Cmp / Cmp.
Definition cmp_arithm.C:457
Cmp exp(const Cmp &)
Exponential.
Definition cmp_math.C:270
Cmp sin(const Cmp &)
Sine.
Definition cmp_math.C:69
Tbl diffrel(const Cmp &a, const Cmp &b)
Relative difference between two Cmp (norme version).
Definition cmp_math.C:504
Tbl norme(const Cmp &)
Sums of the absolute values of all the values of the Cmp in each domain.
Definition cmp_math.C:481
Cmp acos(const Cmp &)
Arccosine.
Definition cmp_math.C:169
Cmp asin(const Cmp &)
Arcsine.
Definition cmp_math.C:144
Cmp racine_cubique(const Cmp &)
Cube root.
Definition cmp_math.C:245
Tbl min(const Cmp &)
Minimum values of a Cmp in each domain.
Definition cmp_math.C:458
Tbl max(const Cmp &)
Maximum values of a Cmp in each domain.
Definition cmp_math.C:435
Cmp pow(const Cmp &, int)
Power .
Definition cmp_math.C:348
Cmp cos(const Cmp &)
Cosine.
Definition cmp_math.C:94
Cmp abs(const Cmp &)
Absolute value.
Definition cmp_math.C:410
Tbl diffrelmax(const Cmp &a, const Cmp &b)
Relative difference between two Cmp (max version).
Definition cmp_math.C:539
Cmp operator+(const Cmp &)
Definition cmp_arithm.C:104
Cmp tan(const Cmp &)
Tangent.
Definition cmp_math.C:120
Cmp log(const Cmp &)
Neperian logarithm.
Definition cmp_math.C:296
Mtbl Heaviside(const Mtbl &)
Heaviside function.
Definition mtbl_math.C:317
double totalmin(const Mtbl &)
Minimum value of the Mtbl elements in all domain.
Definition mtbl_math.C:522
double totalmax(const Mtbl &)
Maximum value of the Mtbl elements in all domains.
Definition mtbl_math.C:494
Lorene prototypes.
Definition app_hor.h:64