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 
103 namespace Lorene {
104 class Coord ;
105 
118 class 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 } ;
320 ostream& operator<<(ostream& , const Mtbl & ) ;
321 
328 Mtbl operator+(const Mtbl& ) ;
331 Mtbl operator-(const Mtbl& ) ;
333 Mtbl operator+(const Mtbl&, const Mtbl& ) ;
335 Mtbl operator+(const Mtbl&, double ) ;
337 Mtbl operator+(double , const Mtbl& ) ;
339 Mtbl operator+(const Mtbl&, int ) ;
341 Mtbl operator+(int, const Mtbl& ) ;
343 Mtbl operator-(const Mtbl&, const Mtbl& ) ;
345 Mtbl operator-(const Mtbl&, double ) ;
347 Mtbl operator-(double, const Mtbl& ) ;
349 Mtbl operator-(const Mtbl&, int ) ;
351 Mtbl operator-(int, const Mtbl& ) ;
353 Mtbl operator*(const Mtbl&, const Mtbl& ) ;
355 Mtbl operator*(const Mtbl&, double ) ;
357 Mtbl operator*(double, const Mtbl& ) ;
359 Mtbl operator*(const Mtbl&, int ) ;
361 Mtbl operator*(int, const Mtbl& ) ;
363 Mtbl operator/(const Mtbl&, const Mtbl& ) ;
365 Mtbl operator/(const Mtbl&, double ) ;
367 Mtbl operator/(double, const Mtbl& ) ;
369 Mtbl operator/(const Mtbl&, int ) ;
371 Mtbl operator/(int, const Mtbl& ) ;
372 
374 Mtbl sin(const Mtbl& ) ;
376 Mtbl cos(const Mtbl& ) ;
378 Mtbl tan(const Mtbl& ) ;
380 Mtbl asin(const Mtbl& ) ;
382 Mtbl acos(const Mtbl& ) ;
384 Mtbl atan(const Mtbl& ) ;
386 Mtbl exp(const Mtbl& ) ;
388 Mtbl Heaviside(const Mtbl& ) ;
390 Mtbl log(const Mtbl& ) ;
392 Mtbl log(const Mtbl& ) ;
394 Mtbl log10(const Mtbl& ) ;
396 Mtbl sqrt(const Mtbl& ) ;
398 Mtbl racine_cubique (const Mtbl&) ;
400 Mtbl pow(const Mtbl& , int ) ;
402 Mtbl pow(const Mtbl& , double ) ;
404 Mtbl abs(const Mtbl& ) ;
405 
410 double totalmax(const Mtbl& ) ;
411 
416 double totalmin(const Mtbl& ) ;
417 
423 Tbl max(const Mtbl& ) ;
424 
430 Tbl min(const Mtbl& ) ;
431 
437 Tbl norme(const Mtbl& ) ;
438 
447 Tbl diffrel(const Mtbl& a, const Mtbl& b) ;
448 
457 Tbl diffrelmax(const Mtbl& a, const Mtbl& b) ;
458 
462 }
463 #endif
Cmp log(const Cmp &)
Neperian logarithm.
Definition: cmp_math.C:299
Cmp asin(const Cmp &)
Arcsine.
Definition: cmp_math.C:147
Cmp exp(const Cmp &)
Exponential.
Definition: cmp_math.C:273
Cmp sqrt(const Cmp &)
Square root.
Definition: cmp_math.C:223
void del_t()
Logical destructor: dellocates the memory occupied by the Tbl array t .
Definition: mtbl.C:280
Multi-domain array.
Definition: mtbl.h:118
Lorene prototypes.
Definition: app_hor.h:67
~Mtbl()
Destructor.
Definition: mtbl.C:159
Cmp racine_cubique(const Cmp &)
Cube root.
Definition: cmp_math.C:248
Base_val operator*(const Base_val &, const Base_val &)
This operator is used when calling multiplication or division of Valeur .
void annule(int l_min, int l_max)
Sets the Mtbl to zero in some domains.
Definition: mtbl.C:332
Cmp operator/(const Cmp &, const Cmp &)
Cmp / Cmp.
Definition: cmp_arithm.C:460
Tbl min(const Cmp &)
Minimum values of a Cmp in each domain.
Definition: cmp_math.C:461
Cmp cos(const Cmp &)
Cosine.
Definition: cmp_math.C:97
Tbl diffrel(const Cmp &a, const Cmp &b)
Relative difference between two Cmp (norme version).
Definition: cmp_math.C:507
void operator*=(const Mtbl &)
*= Mtbl
Definition: mtbl_arithm.C:560
int get_etat() const
Gives the logical state.
Definition: mtbl.h:277
Cmp tan(const Cmp &)
Tangent.
Definition: cmp_math.C:123
double operator()(int l, int k, int j, int i) const
Read-only of a particular element.
Definition: mtbl.h:259
void operator+=(const Mtbl &)
+= Mtbl
Definition: mtbl_arithm.C:516
Tbl norme(const Cmp &)
Sums of the absolute values of all the values of the Cmp in each domain.
Definition: cmp_math.C:484
int get_nzone() const
Gives the number of zones (domains)
Definition: mtbl.h:280
void set_etat_zero()
Sets the logical state to ETATZERO (zero).
Definition: mtbl.C:290
Cmp atan(const Cmp &)
Arctangent.
Definition: cmp_math.C:198
Cmp operator+(const Cmp &)
Definition: cmp_arithm.C:107
const Mg3d * mg
Pointer on the multi-grid Mgd3 on which this is defined.
Definition: mtbl.h:124
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:396
Mtbl(const Mg3d &mgrid)
Constructor.
Definition: mtbl.C:127
int etat
Logical state (ETATNONDEF , ETATQCQ or ETATZERO ).
Definition: mtbl.h:128
int nzone
Number of domains (zones)
Definition: mtbl.h:126
Tbl max(const Cmp &)
Maximum values of a Cmp in each domain.
Definition: cmp_math.C:438
double totalmax(const Mtbl &)
Maximum value of the Mtbl elements in all domains.
Definition: mtbl_math.C:497
Cmp pow(const Cmp &, int)
Power .
Definition: cmp_math.C:351
Active physical coordinates and mapping derivatives.
Definition: coord.h:90
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Definition: mtbl.C:302
double totalmin(const Mtbl &)
Minimum value of the Mtbl elements in all domain.
Definition: mtbl_math.C:525
void sauve(FILE *) const
Save in a file.
Definition: mtbl.C:212
void annule_hard()
Sets the Mtbl to zero in a hard way.
Definition: mtbl.C:315
Multi-domain grid.
Definition: grilles.h:279
void operator/=(const Mtbl &)
/= Mtbl
Cmp log10(const Cmp &)
Basis 10 logarithm.
Definition: cmp_math.C:325
Cmp acos(const Cmp &)
Arccosine.
Definition: cmp_math.C:172
Cmp abs(const Cmp &)
Absolute value.
Definition: cmp_math.C:413
const Tbl & operator()(int l) const
Read-only of the Tbl in a given domain.
Definition: mtbl.h:232
Cmp operator-(const Cmp &)
- Cmp
Definition: cmp_arithm.C:111
friend ostream & operator<<(ostream &, const Mtbl &)
Display.
Definition: mtbl.C:368
Cmp sin(const Cmp &)
Sine.
Definition: cmp_math.C:72
Mtbl Heaviside(const Mtbl &)
Heaviside function.
Definition: mtbl_math.C:320
Basic array class.
Definition: tbl.h:164
void operator-=(const Mtbl &)
-= Mtbl
Definition: mtbl_arithm.C:538
Tbl ** t
Array (size nzone ) of pointers on the Tbl &#39;s.
Definition: mtbl.h:132
const Mg3d * get_mg() const
Gives the Mg3d on which the Mtbl is defined.
Definition: mtbl.h:274
void set_etat_nondef()
Sets the logical state to ETATNONDEF (undefined).
Definition: mtbl.C:296
Tbl diffrelmax(const Cmp &a, const Cmp &b)
Relative difference between two Cmp (max version).
Definition: cmp_math.C:542
void operator=(const Mtbl &)
Assignement to another Mtbl.
Definition: mtbl.C:227