LORENE
base_val_name_r.C
1 /*
2  * Method Base_val::name_r
3  *
4  * (see file base_val.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: base_val_name_r.C,v 1.8 2023/06/28 10:04:32 j_novak Exp $
32  * $Log: base_val_name_r.C,v $
33  * Revision 1.8 2023/06/28 10:04:32 j_novak
34  * Use of C++ strings and flows instead of C types.
35  *
36  * Revision 1.7 2016/12/05 16:17:44 j_novak
37  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
38  *
39  * Revision 1.6 2014/10/13 08:52:39 j_novak
40  * Lorene classes and functions now belong to the namespace Lorene.
41  *
42  * Revision 1.5 2014/10/06 15:12:57 j_novak
43  * Modified #include directives to use c++ syntax.
44  *
45  * Revision 1.4 2013/01/11 08:20:11 j_novak
46  * New radial spectral bases with Legendre polynomials (R_LEG, R_LEGP, R_LEGI).
47  *
48  * Revision 1.3 2007/12/11 15:28:09 jl_cornou
49  * Jacobi(0,2) polynomials partially implemented
50  *
51  * Revision 1.2 2004/11/23 15:08:01 m_forot
52  * Added the bases for the cases without any equatorial symmetry
53  * (T_COSSIN_C, T_COSSIN_S, T_LEG, R_CHEBPI_P, R_CHEBPI_I).
54  *
55  * Revision 1.1 2003/10/19 19:49:40 e_gourgoulhon
56  * First version
57  *
58  *
59  *
60  * $Header: /cvsroot/Lorene/C++/Source/Base_val/base_val_name_r.C,v 1.8 2023/06/28 10:04:32 j_novak Exp $
61  *
62  */
63 
64 // C headers
65 #include <cstring>
66 #include <cstdlib>
67 
68 // Header C++
69 #include <sstream>
70 
71 // Lorene headers
72 #include "base_val.h"
73 
74 // Local prototypes
75 namespace Lorene {
76  void basename_r_unknown(int, int, int, string&) ;
77  void basename_r_cheb(int, int, int, string&) ;
78  void basename_r_chebp(int, int, int, string&) ;
79  void basename_r_chebi(int, int, int, string&) ;
80  void basename_r_chebpim_p(int, int, int, string&) ;
81  void basename_r_chebpim_i(int, int, int, string&) ;
82  void basename_r_chebpi_p(int, int, int, string&) ;
83  void basename_r_chebpi_i(int, int, int, string&) ;
84  void basename_r_leg(int, int, int, string&) ;
85  void basename_r_legp(int, int, int, string&) ;
86  void basename_r_legi(int, int, int, string&) ;
87  void basename_r_jaco02(int, int, int, string&) ;
88 
89  //----------------------------//
90  // Base_val method //
91  //----------------------------//
92 
93  void Base_val::name_r(int l, int k, int j, int i, string& name) const {
94 
95  // Array of actual base name functions
96  static void(*vbasename_r[MAX_BASE])(int, int, int, string&) ;
97 
98  static bool first_call = true ;
99 
100  // Initializations at first call
101  // -----------------------------
102  if ( first_call ) {
103 
104  first_call = false ;
105 
106  for (int ib=0 ; ib<MAX_BASE ; ib++) {
107  vbasename_r[ib] = basename_r_unknown ;
108  }
109 
110  vbasename_r[R_CHEB >> TRA_R] = basename_r_cheb ;
111  vbasename_r[R_CHEBP >> TRA_R] = basename_r_chebp ;
112  vbasename_r[R_CHEBI >> TRA_R] = basename_r_chebi ;
113  vbasename_r[R_CHEBPIM_P >> TRA_R] = basename_r_chebpim_p ;
114  vbasename_r[R_CHEBPIM_I >> TRA_R] = basename_r_chebpim_i ;
115  vbasename_r[R_CHEBU >> TRA_R] = basename_r_cheb ;
116  vbasename_r[R_CHEBPI_P >> TRA_R] = basename_r_chebpi_p ;
117  vbasename_r[R_CHEBPI_I >> TRA_R] = basename_r_chebpi_i ;
118  vbasename_r[R_LEG >> TRA_R] = basename_r_leg ;
119  vbasename_r[R_LEGP >> TRA_R] = basename_r_legp ;
120  vbasename_r[R_LEGI >> TRA_R] = basename_r_legi ;
121  vbasename_r[R_JACO02 >> TRA_R] = basename_r_jaco02 ;
122  }
123 
124  // Call to the function adapted to the basis in domain l
125  //------------------------------------------------------
126 
127  assert( (l>=0) && (l<nzone) ) ;
128 
129  int base_r = ( b[l] & MSQ_R ) >> TRA_R ;
130 
131  vbasename_r[base_r](k, j, i, name) ;
132 
133  }
134 
135 
136  //-------------------------------//
137  // individual basis functions //
138  //-------------------------------//
139 
140  void basename_r_unknown(int, int, int, string&) {
141  cout << "Base_val::name_r : unknwon basis !" << endl ;
142  abort() ;
143  }
144 
145 
146  void basename_r_cheb(int, int, int i, string& name) {
147 
148  assert( i>=0 ) ;
149 
150  ostringstream ostr ;
151  ostr << 'T' << i << flush ;
152  name = ostr.str() ;
153  }
154 
155 
156  void basename_r_chebp(int, int, int i, string& name) {
157 
158  assert( i>=0 ) ;
159 
160  ostringstream ostr ;
161  ostr << 'T' << 2*i << flush ;
162  name = ostr.str() ;
163  }
164 
165 
166  void basename_r_chebi(int, int, int i, string& name) {
167 
168  assert( i>=0 ) ;
169 
170  ostringstream ostr ;
171  ostr << 'T' << (2*i+1) << flush ;
172  name = ostr.str() ;
173  }
174 
175 
176  void basename_r_chebpim_p(int k, int, int i, string& name) {
177 
178  assert( k>=0 ) ;
179  assert( i>=0 ) ;
180 
181  int m = k / 2 ;
182  int xr = (m%2 == 0) ? 2*i : 2*i + 1 ;
183 
184  ostringstream ostr ;
185  ostr << 'T' << xr << flush ;
186  name = ostr.str() ;
187  }
188 
189 
190  void basename_r_chebpim_i(int k, int, int i, string& name) {
191 
192  assert( k>=0 ) ;
193  assert( i>=0 ) ;
194 
195  int m = k / 2 ;
196  int xr = (m%2 == 0) ? 2*i + 1 : 2*i ;
197 
198  ostringstream ostr ;
199  ostr << 'T' << xr << flush ;
200  name = ostr.str() ;
201  }
202 
203  void basename_r_chebpi_p(int , int j, int i, string& name) {
204 
205  assert( j>=0 ) ;
206  assert( i>=0 ) ;
207 
208  int xr = (j%2 == 0) ? 2*i : 2*i + 1 ;
209 
210  ostringstream ostr ;
211  ostr << 'T' << xr << flush ;
212  name = ostr.str() ;
213  }
214 
215 
216  void basename_r_chebpi_i(int , int j, int i, string& name) {
217 
218  assert( j>=0 ) ;
219  assert( i>=0 ) ;
220 
221  int xr = (j%2 == 0) ? 2*i + 1 : 2*i ;
222 
223  ostringstream ostr ;
224  ostr << 'T' << xr << flush ;
225  name = ostr.str() ;
226  }
227 
228  void basename_r_leg(int, int, int i, string& name) {
229 
230  assert( i>=0 ) ;
231 
232  ostringstream ostr ;
233  ostr << 'P' << i << flush ;
234  name = ostr.str() ;
235  }
236 
237 
238  void basename_r_legp(int, int, int i, string& name) {
239 
240  assert( i>=0 ) ;
241 
242  ostringstream ostr ;
243  ostr << 'P' << 2*i << flush ;
244  name = ostr.str() ;
245  }
246 
247 
248  void basename_r_legi(int, int, int i, string& name) {
249 
250  assert( i>=0 ) ;
251 
252  ostringstream ostr ;
253  ostr << 'T' << (2*i + 1) << flush ;
254  name = ostr.str() ;
255  }
256 
257  void basename_r_jaco02(int, int, int i, string& name) {
258 
259  assert( i>=0 ) ;
260 
261  ostringstream ostr ;
262  ostr << 'J' << i << flush ;
263  name = ostr.str() ;
264  }
265 
266 }
#define R_CHEBPI_I
Cheb. pair-impair suivant l impair pour l=0.
Definition: type_parite.h:174
Lorene prototypes.
Definition: app_hor.h:67
#define R_LEGP
base de Legendre paire (rare) seulement
Definition: type_parite.h:184
#define R_LEGI
base de Legendre impaire (rare) seulement
Definition: type_parite.h:186
int nzone
Number of domains (zones)
Definition: base_val.h:330
#define R_JACO02
base de Jacobi(0,2) ordinaire (finjac)
Definition: type_parite.h:188
#define TRA_R
Translation en R, used for a bitwise shift (in hex)
Definition: type_parite.h:158
#define R_CHEBI
base de Cheb. impaire (rare) seulement
Definition: type_parite.h:170
#define R_CHEBP
base de Cheb. paire (rare) seulement
Definition: type_parite.h:168
int * b
Array (size: nzone ) of the spectral basis in each domain.
Definition: base_val.h:334
#define MSQ_R
Extraction de l&#39;info sur R.
Definition: type_parite.h:152
void name_r(int l, int k, int j, int i, string &basename) const
Name of the basis function in r ( )
#define R_CHEBPIM_I
Cheb. pair-impair suivant m, impair pour m=0.
Definition: type_parite.h:178
#define R_CHEBPIM_P
Cheb. pair-impair suivant m, pair pour m=0.
Definition: type_parite.h:176
#define R_CHEBPI_P
Cheb. pair-impair suivant l pair pour l=0.
Definition: type_parite.h:172
#define R_CHEBU
base de Chebychev ordinaire (fin), dev. en 1/r
Definition: type_parite.h:180
#define MAX_BASE
Nombre max. de bases differentes.
Definition: type_parite.h:144
#define R_LEG
base de Legendre ordinaire (fin)
Definition: type_parite.h:182
#define R_CHEB
base de Chebychev ordinaire (fin)
Definition: type_parite.h:166