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
28char mtbl_cf_display_C[] = "$Header: /cvsroot/Lorene/C++/Source/Mtbl_cf/mtbl_cf_display.C,v 1.3 2014/10/13 08:53:08 j_novak Exp $" ;
29
30/*
31 * $Id: mtbl_cf_display.C,v 1.3 2014/10/13 08:53:08 j_novak Exp $
32 * $Log: mtbl_cf_display.C,v $
33 * Revision 1.3 2014/10/13 08:53:08 j_novak
34 * Lorene classes and functions now belong to the namespace Lorene.
35 *
36 * Revision 1.2 2014/10/06 15:13:15 j_novak
37 * Modified #include directives to use c++ syntax.
38 *
39 * Revision 1.1 2003/10/19 19:51:58 e_gourgoulhon
40 * First version
41 *
42 *
43 *
44 * $Header: /cvsroot/Lorene/C++/Source/Mtbl_cf/mtbl_cf_display.C,v 1.3 2014/10/13 08:53:08 j_novak Exp $
45 *
46 */
47
48// C headers
49#include <cstdlib>
50#include <cmath>
51
52// Lorene headers
53#include "mtbl_cf.h"
54
55namespace Lorene {
56void Mtbl_cf::display(double thres, int precis, ostream& ost) const {
57
58 ost << "Spectral expansion (Mtbl_cf, threshold for display = "
59 << thres << ")" << endl ;
60 ost << base << endl ;
61
62 if (etat == ETATNONDEF) {
63 ost << " state: UNDEFINED" << endl ;
64 return ;
65 }
66
67 if (etat == ETATZERO) {
68 ost << " state: ZERO" << endl ;
69 return ;
70 }
71
72 ost.precision(precis);
73 ost.setf(ios::showpoint);
74 assert(etat == ETATQCQ) ;
75 char namep[12] ;
76 char namet[12] ;
77 char namer[12] ;
78
79 for (int l=0; l<nzone; l++) {
80
81 int nr = mg->get_nr(l) ;
82 int nt = mg->get_nt(l) ;
83 int np = mg->get_np(l) ;
84
85 ost << " --------- Domain no. " << l << " ------- nr x nt x np = "
86 << nr << " x " << nt << " x " << np << " ------" << endl ;
87 const Tbl& tcf = *(t[l]) ;
88 if (tcf.get_etat() == ETATZERO) {
89 ost << "*** identically ZERO ***" << endl << endl ;
90 continue ;
91 }
92 if (tcf.get_etat() == ETATNONDEF) {
93 ost << "*** UNDEFINED ***" << endl << endl ;
94 continue ;
95 }
96 assert( tcf.get_etat() == ETATQCQ ) ;
97
98 for (int k=0; k<=np; k++) {
99 base.name_phi(l, k, namep) ;
100 if (namep[0] == 'u') continue ; // unused phi coefficient
101
102 for (int j=0; j<nt; j++) {
103
104 bool test_display = false ;
105 for (int i=0; i<nr; i++) {
106 if (fabs( tcf(k, j, i) ) >= thres) test_display = true ;
107 }
108
109 base.name_theta(l, k, j, namet) ;
110
111 test_display = test_display && ( namet[0] != 'u' ) ;
112
113 if (test_display) {
114 ost << "# " << namep << " " << namet << " :" ;
115 for (int i=0; i<nr; i++) {
116 double cx = tcf(k, j, i) ;
117 if (fabs( cx ) >= thres) {
118 base.name_r(l, k, j, i, namer) ;
119 if (namer[0] == 'u') continue ; // unused r coefficient
120 if ( (i>0) && (cx >= 0.) ) {
121 ost << " +" << setw(precis) << cx
122 << " " << namer ;
123 }
124 else {
125 ost << " " << setw(precis) << cx
126 << " " << namer ;
127 }
128 }
129 }
130 ost << endl ;
131 }
132
133 } // end of theta loop (index j)
134
135 } // end of phi loop (index k)
136
137 ost << endl ;
138
139 } // end of loop on the domains (index l)
140
141}
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156}
void name_r(int l, int k, int j, int i, char *basename) const
Name of the basis function in r ( )
void name_phi(int l, int k, char *basename) const
Name of the basis function in .
void name_theta(int l, int k, int j, char *basename) const
Name of the basis function in .
int get_np(int l) const
Returns the number of points in the azimuthal direction ( ) in domain no. l.
Definition grilles.h:462
int get_nt(int l) const
Returns the number of points in the co-latitude direction ( ) in domain no. l.
Definition grilles.h:457
int get_nr(int l) const
Returns the number of points in the radial direction ( ) in domain no. l.
Definition grilles.h:452
Base_val base
Bases of the spectral expansions.
Definition mtbl_cf.h:200
const Mg3d * mg
Pointer on the multi-grid Mgd3 on which this is defined.
Definition mtbl_cf.h:192
int etat
Logical state (ETATNONDEF , ETATQCQ or ETATZERO ).
Definition mtbl_cf.h:196
Tbl ** t
Array (size nzone ) of pointers on the Tbl 's which contain the spectral coefficients in each domain.
Definition mtbl_cf.h:205
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...
int nzone
Number of domains (zones)
Definition mtbl_cf.h:194
Basic array class.
Definition tbl.h:161
int get_etat() const
Gives the logical state.
Definition tbl.h:394
Lorene prototypes.
Definition app_hor.h:64