LORENE
mtbl_cf_display.C
1 /*
2  * Method Mtbl_cf::display
3  *
4  * (see file mtbl_cf.h for documentation).
5  *
6  */
7 
8 /*
9  * Copyright (c) 2003 Eric Gourgoulhon
10  *
11  * This file is part of LORENE.
12  *
13  * LORENE is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License version 2
15  * as published by the Free Software Foundation.
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 
30 /*
31  * $Id: mtbl_cf_display.C,v 1.5 2023/06/28 10:04:32 j_novak Exp $
32  * $Log: mtbl_cf_display.C,v $
33  * Revision 1.5 2023/06/28 10:04:32 j_novak
34  * Use of C++ strings and flows instead of C types.
35  *
36  * Revision 1.4 2016/12/05 16:17:59 j_novak
37  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
38  *
39  * Revision 1.3 2014/10/13 08:53:08 j_novak
40  * Lorene classes and functions now belong to the namespace Lorene.
41  *
42  * Revision 1.2 2014/10/06 15:13:15 j_novak
43  * Modified #include directives to use c++ syntax.
44  *
45  * Revision 1.1 2003/10/19 19:51:58 e_gourgoulhon
46  * First version
47  *
48  *
49  *
50  * $Header: /cvsroot/Lorene/C++/Source/Mtbl_cf/mtbl_cf_display.C,v 1.5 2023/06/28 10:04:32 j_novak Exp $
51  *
52  */
53 
54 // C headers
55 #include <cstdlib>
56 #include <cmath>
57 
58 // Lorene headers
59 #include "mtbl_cf.h"
60 
61 namespace Lorene {
62  void Mtbl_cf::display(double thres, int precis, ostream& ost) const {
63 
64  ost << "Spectral expansion (Mtbl_cf, threshold for display = "
65  << thres << ")" << endl ;
66  ost << base << endl ;
67 
68  if (etat == ETATNONDEF) {
69  ost << " state: UNDEFINED" << endl ;
70  return ;
71  }
72 
73  if (etat == ETATZERO) {
74  ost << " state: ZERO" << endl ;
75  return ;
76  }
77 
78  ost.precision(precis);
79  ost.setf(ios::showpoint);
80  assert(etat == ETATQCQ) ;
81  string namep ;
82  string namet ;
83  string namer ;
84 
85  for (int l=0; l<nzone; l++) {
86 
87  int nr = mg->get_nr(l) ;
88  int nt = mg->get_nt(l) ;
89  int np = mg->get_np(l) ;
90 
91  ost << " --------- Domain no. " << l << " ------- nr x nt x np = "
92  << nr << " x " << nt << " x " << np << " ------" << endl ;
93  const Tbl& tcf = *(t[l]) ;
94  if (tcf.get_etat() == ETATZERO) {
95  ost << "*** identically ZERO ***" << endl << endl ;
96  continue ;
97  }
98  if (tcf.get_etat() == ETATNONDEF) {
99  ost << "*** UNDEFINED ***" << endl << endl ;
100  continue ;
101  }
102  assert( tcf.get_etat() == ETATQCQ ) ;
103 
104  for (int k=0; k<=np; k++) {
105  base.name_phi(l, k, namep) ;
106  if (namep[0] == 'u') continue ; // unused phi coefficient
107 
108  for (int j=0; j<nt; j++) {
109 
110  bool test_display = false ;
111  for (int i=0; i<nr; i++) {
112  if (fabs( tcf(k, j, i) ) >= thres) test_display = true ;
113  }
114 
115  base.name_theta(l, k, j, namet) ;
116 
117  test_display = test_display && ( namet[0] != 'u' ) ;
118 
119  if (test_display) {
120  ost << "# " << namep << " " << namet << " :" ;
121  for (int i=0; i<nr; i++) {
122  double cx = tcf(k, j, i) ;
123  if (fabs( cx ) >= thres) {
124  base.name_r(l, k, j, i, namer) ;
125  if (namer[0] == 'u') continue ; // unused r coefficient
126  if ( (i>0) && (cx >= 0.) ) {
127  ost << " +" << setw(precis) << cx
128  << " " << namer ;
129  }
130  else {
131  ost << " " << setw(precis) << cx
132  << " " << namer ;
133  }
134  }
135  }
136  ost << endl ;
137  }
138 
139  } // end of theta loop (index j)
140 
141  } // end of phi loop (index k)
142 
143  ost << endl ;
144 
145  } // end of loop on the domains (index l)
146 
147  }
148 }
int get_np(int l) const
Returns the number of points in the azimuthal direction ( ) in domain no. l.
Definition: grilles.h:479
Lorene prototypes.
Definition: app_hor.h:67
void display(double threshold=1.e-7, int precision=4, ostream &ostr=cout) const
Prints the coefficients whose values are greater than a given threshold, as well as the corresponding...
const Mg3d * mg
Pointer on the multi-grid Mgd3 on which this is defined.
Definition: mtbl_cf.h:202
int get_etat() const
Gives the logical state.
Definition: tbl.h:414
void name_theta(int l, int k, int j, string &basename) const
Name of the basis function in .
int etat
Logical state (ETATNONDEF , ETATQCQ or ETATZERO ).
Definition: mtbl_cf.h:206
void name_r(int l, int k, int j, int i, string &basename) const
Name of the basis function in r ( )
int nzone
Number of domains (zones)
Definition: mtbl_cf.h:204
void name_phi(int l, int k, string &basename) const
Name of the basis function in .
int get_nr(int l) const
Returns the number of points in the radial direction ( ) in domain no. l.
Definition: grilles.h:469
Base_val base
Bases of the spectral expansions.
Definition: mtbl_cf.h:210
Basic array class.
Definition: tbl.h:164
int get_nt(int l) const
Returns the number of points in the co-latitude direction ( ) in domain no. l.
Definition: grilles.h:474
Tbl ** t
Array (size nzone ) of pointers on the Tbl &#39;s which contain the spectral coefficients in each domain...
Definition: mtbl_cf.h:215