LORENE
base_val_name_theta.C
1 /*
2  * Method Base_val::name_theta
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_theta.C,v 1.11 2023/06/28 10:04:32 j_novak Exp $
32  * $Log: base_val_name_theta.C,v $
33  * Revision 1.11 2023/06/28 10:04:32 j_novak
34  * Use of C++ strings and flows instead of C types.
35  *
36  * Revision 1.10 2016/12/05 16:17:44 j_novak
37  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
38  *
39  * Revision 1.9 2014/10/13 08:52:39 j_novak
40  * Lorene classes and functions now belong to the namespace Lorene.
41  *
42  * Revision 1.8 2014/10/06 15:12:57 j_novak
43  * Modified #include directives to use c++ syntax.
44  *
45  * Revision 1.7 2009/10/23 12:55:16 j_novak
46  * New base T_LEG_MI
47  *
48  * Revision 1.6 2009/10/08 16:20:13 j_novak
49  * Addition of new bases T_COS and T_SIN.
50  *
51  * Revision 1.5 2004/12/17 13:35:01 m_forot
52  * Add the case T_LEG
53  *
54  * Revision 1.4 2004/11/23 15:08:01 m_forot
55  * Added the bases for the cases without any equatorial symmetry
56  * (T_COSSIN_C, T_COSSIN_S, T_LEG, R_CHEBPI_P, R_CHEBPI_I).
57  *
58  * Revision 1.3 2004/10/04 13:40:38 j_novak
59  * Added the T_COS base case.
60  *
61  * Revision 1.2 2004/08/24 09:14:41 p_grandclement
62  * Addition of some new operators, like Poisson in 2d... It now requieres the
63  * GSL library to work.
64  *
65  * Also, the way a variable change is stored by a Param_elliptic is changed and
66  * no longer uses Change_var but rather 2 Scalars. The codes using that feature
67  * will requiere some modification. (It should concern only the ones about monopoles)
68  *
69  * Revision 1.1 2003/10/19 19:49:40 e_gourgoulhon
70  * First version
71  *
72  *
73  *
74  * $Header: /cvsroot/Lorene/C++/Source/Base_val/base_val_name_theta.C,v 1.11 2023/06/28 10:04:32 j_novak Exp $
75  *
76  */
77 
78 // C headers
79 #include <cstring>
80 #include <cstdlib>
81 
82 // Header C++
83 #include <sstream>
84 
85 // Lorene headers
86 #include "type_parite.h"
87 #include "base_val.h"
88 
89 // Local prototypes
90 namespace Lorene {
91  void basename_t_unknown(int, int, string&) ;
92  void basename_t_cos(int, int, string&) ;
93  void basename_t_sin(int, int, string&) ;
94  void basename_t_cos_p(int, int, string&) ;
95  void basename_t_sin_p(int, int, string&) ;
96  void basename_t_cos_i(int, int, string&) ;
97  void basename_t_sin_i(int, int, string&) ;
98  void basename_t_cossin_cp(int, int, string&) ;
99  void basename_t_cossin_sp(int, int, string&) ;
100  void basename_t_cossin_c(int, int, string&) ;
101  void basename_t_cossin_s(int, int, string&) ;
102  void basename_t_cossin_ci(int, int, string&) ;
103  void basename_t_cossin_si(int, int, string&) ;
104  void basename_t_leg_p(int, int, string&) ;
105  void basename_t_leg(int, int, string&) ;
106  void basename_t_leg_mp(int, int, string&) ;
107  void basename_t_leg_mi(int, int, string&) ;
108  void basename_t_leg_pp(int, int, string&) ;
109  void basename_t_leg_i(int, int, string&) ;
110  void basename_t_leg_ip(int, int, string&) ;
111  void basename_t_leg_pi(int, int, string&) ;
112  void basename_t_leg_ii(int, int, string&) ;
113  void basename_t_cl_cos_p(int, int, string&) ;
114  void basename_t_cl_sin_p(int, int, string&) ;
115  void basename_t_cl_cos_i(int, int, string&) ;
116  void basename_t_cl_sin_i(int, int, string&) ;
117 
118 
119  //----------------------------//
120  // Base_val method //
121  //----------------------------//
122 
123  void Base_val::name_theta(int l, int k, int j, string& name) const {
124 
125  // Array of actual base name functions
126  static void(*vbasename_t[MAX_BASE])(int, int, string&) ;
127 
128  static bool first_call = true ;
129 
130  // Initializations at first call
131  // -----------------------------
132  if ( first_call ) {
133 
134  first_call = false ;
135 
136  for (int i=0 ; i<MAX_BASE ; i++) {
137  vbasename_t[i] = basename_t_unknown ;
138  }
139 
140  vbasename_t[T_COS >> TRA_T] = basename_t_cos ;
141  vbasename_t[T_SIN >> TRA_T] = basename_t_sin ;
142  vbasename_t[T_COS_P >> TRA_T] = basename_t_cos_p ;
143  vbasename_t[T_SIN_P >> TRA_T] = basename_t_sin_p ;
144  vbasename_t[T_COS_I >> TRA_T] = basename_t_cos_i ;
145  vbasename_t[T_SIN_I >> TRA_T] = basename_t_sin_i ;
146  vbasename_t[T_COSSIN_CP >> TRA_T] = basename_t_cossin_cp ;
147  vbasename_t[T_COSSIN_SP >> TRA_T] = basename_t_cossin_sp ;
148  vbasename_t[T_COSSIN_CI >> TRA_T] = basename_t_cossin_ci ;
149  vbasename_t[T_COSSIN_SI >> TRA_T] = basename_t_cossin_si ;
150  vbasename_t[T_COSSIN_C >> TRA_T] = basename_t_cossin_c ;
151  vbasename_t[T_COSSIN_S >> TRA_T] = basename_t_cossin_s ;
152  vbasename_t[T_LEG_P >> TRA_T] = basename_t_leg_p ;
153  vbasename_t[T_LEG_MP >> TRA_T] = basename_t_leg_mp ;
154  vbasename_t[T_LEG_MI >> TRA_T] = basename_t_leg_mi ;
155  vbasename_t[T_LEG >> TRA_T] = basename_t_leg ;
156  vbasename_t[T_LEG_PP >> TRA_T] = basename_t_leg_pp ;
157  vbasename_t[T_LEG_I >> TRA_T] = basename_t_leg_i ;
158  vbasename_t[T_LEG_IP >> TRA_T] = basename_t_leg_ip ;
159  vbasename_t[T_LEG_PI >> TRA_T] = basename_t_leg_pi ;
160  vbasename_t[T_LEG_II >> TRA_T] = basename_t_leg_ii ;
161  vbasename_t[T_CL_COS_P >> TRA_T] = basename_t_cl_cos_p ;
162  vbasename_t[T_CL_SIN_P >> TRA_T] = basename_t_cl_sin_p ;
163  vbasename_t[T_CL_COS_I >> TRA_T] = basename_t_cl_cos_i ;
164  vbasename_t[T_CL_SIN_I >> TRA_T] = basename_t_cl_sin_i ;
165 
166  }
167 
168  // Call to the function adapted to the basis in domain l
169  //------------------------------------------------------
170 
171  assert( (l>=0) && (l<nzone) ) ;
172 
173  int base_t = ( b[l] & MSQ_T ) >> TRA_T ;
174 
175  vbasename_t[base_t](k, j, name) ;
176 
177  }
178 
179 
180  //-------------------------------//
181  // individual basis functions //
182  //-------------------------------//
183 
184  void basename_t_unknown(int, int, string&) {
185  cout << "Base_val::name_theta : unknwon basis !" << endl ;
186  abort() ;
187  }
188 
189 
190  void basename_t_cos(int , int j, string& name) {
191 
192  assert( j>=0 ) ;
193 
194  ostringstream ostr ;
195  ostr << "cos" << j << 't' << flush ;
196  name = ostr.str() ;
197  }
198 
199  void basename_t_sin(int , int j, string& name) {
200 
201  assert( j>=0 ) ;
202 
203  ostringstream ostr ;
204  ostr << "sin" << j << 't' << flush ;
205  name = ostr.str() ;
206  }
207 
208 
209  void basename_t_cos_p(int , int j, string& name) {
210 
211  assert( j>=0 ) ;
212 
213  ostringstream ostr ;
214  ostr << "cos" << 2*j << 't' << flush ;
215  name = ostr.str() ;
216  }
217 
218 
219  void basename_t_sin_p(int , int j, string& name) {
220 
221  assert( j>=0 ) ;
222 
223  if (j == 0) {
224  name = "unused" ;
225  return ;
226  }
227 
228  ostringstream ostr ;
229  ostr << "sin" << 2*j << 't' << flush ;
230  name = ostr.str() ;
231  }
232 
233  void basename_t_cl_cos_p(int , int j, string& name) {
234 
235  assert( j>=0 ) ;
236 
237  ostringstream ostr ;
238  ostr << "cl_cos" << 2*j << 't' << flush ;
239  name = ostr.str() ;
240  }
241 
242  void basename_t_cl_sin_p(int , int j, string& name) {
243 
244  assert( j>=0 ) ;
245 
246  ostringstream ostr ;
247  ostr << "cl_sin" << 2*j << 't' << flush ;
248  name = ostr.str() ;
249  }
250 
251  void basename_t_cos_i(int , int j, string& name) {
252 
253  assert( j>=0 ) ;
254 
255  ostringstream ostr ;
256  ostr << "cos" << (2*j + 1) << 't' << flush ;
257  name = ostr.str() ;
258  }
259 
260  void basename_t_cl_cos_i(int , int j, string& name) {
261 
262  assert( j>=0 ) ;
263 
264  ostringstream ostr ;
265  ostr << "cl_cos" << (2*j + 1) << 't' << flush ;
266  name = ostr.str() ;
267  }
268 
269  void basename_t_sin_i(int , int j, string& name) {
270 
271  assert( j>=0 ) ;
272 
273  ostringstream ostr ;
274  ostr << "sin" << (2*j + 1) << 't' << flush ;
275  name = ostr.str() ;
276  }
277 
278  void basename_t_cl_sin_i(int , int j, string& name) {
279 
280  assert( j>=0 ) ;
281 
282  ostringstream ostr ;
283  ostr << "cl_sin" << (2*j + 1) << 't' << flush ;
284  name = ostr.str() ;
285  }
286 
287 
288  void basename_t_cossin_cp(int k, int j, string& name) {
289 
290  assert( k>=0 ) ;
291  assert( j>=0 ) ;
292 
293  ostringstream ostr ;
294  int m = k / 2 ;
295  int xt ;
296  if (m%2 == 0) {
297  ostr << "cos" ;
298  xt = 2*j ;
299  }
300  else {
301  ostr << "sin" ;
302  xt = 2*j + 1 ;
303  }
304  ostr << xt << 't' << flush ;
305  name = ostr.str() ;
306  }
307 
308 
309  void basename_t_cossin_sp(int k, int j, string& name) {
310 
311  assert( k>=0 ) ;
312  assert( j>=0 ) ;
313 
314  ostringstream ostr ;
315  int m = k / 2 ;
316  int xt ;
317  if (m%2 == 0) {
318  if (j == 0) {
319  name = "unused" ;
320  return ;
321  }
322  else {
323  ostr << "sin" ;
324  xt = 2*j ;
325  }
326  }
327  else {
328  ostr << "cos" ;
329  xt = 2*j + 1 ;
330  }
331  ostr << xt << 't' << flush ;
332  name = ostr.str() ;
333  }
334 
335  void basename_t_cossin_c(int k, int j, string& name) {
336 
337  assert( k>=0 ) ;
338  assert( j>=0 ) ;
339 
340  ostringstream ostr ;
341  int m = k / 2 ;
342  int xt ;
343  if (m%2 == 0) {
344  ostr << "cos" ;
345  xt = j ;
346  }
347  else {
348  if (j == 0) {
349  name = "unused" ;
350  return ;
351  } else {
352  ostr << "sin" ;
353  xt = j ;
354  }
355  }
356  ostr << xt << 't' << flush ;
357  name = ostr.str() ;
358  }
359 
360 
361  void basename_t_cossin_s(int k, int j, string& name) {
362 
363  assert( k>=0 ) ;
364  assert( j>=0 ) ;
365 
366  ostringstream ostr ;
367  int m = k / 2 ;
368  int xt ;
369  if (m%2 == 0) {
370  if (j == 0) {
371  name = "unused" ;
372  return ;
373  }
374  else {
375  ostr << "sin" ;
376  xt = j ;
377  }
378  }
379  else {
380  ostr << "cos" ;
381  xt = j ;
382  }
383  ostr << xt << 't' << flush ;
384  name = ostr.str() ;
385  }
386 
387 
388  void basename_t_cossin_ci(int k, int j, string& name) {
389 
390  assert( k>=0 ) ;
391  assert( j>=0 ) ;
392 
393  ostringstream ostr ;
394  int m = k / 2 ;
395  int xt ;
396  if (m%2 == 0) {
397  ostr << "cos" ;
398  xt = 2*j + 1;
399  }
400  else {
401  if (j == 0) {
402  name = "unused" ;
403  return ;
404  }
405  else {
406  ostr << "sin" ;
407  xt = 2*j ;
408  }
409  }
410  ostr << xt << 't' << flush ;
411  name = ostr.str() ;
412  }
413 
414 
415  void basename_t_cossin_si(int k, int j, string& name) {
416 
417  assert( k>=0 ) ;
418  assert( j>=0 ) ;
419 
420  ostringstream ostr ;
421  int m = k / 2 ;
422  int xt ;
423  if (m%2 == 0) {
424  ostr << "sin" ;
425  xt = 2*j + 1;
426  }
427  else {
428  ostr << "cos" ;
429  xt = 2*j ;
430  }
431  ostr << xt << 't' << flush ;
432  name = ostr.str() ;
433  }
434 
435  void basename_t_leg(int k, int j, string& name) {
436 
437  assert( k>=0 ) ;
438  assert( j>=0 ) ;
439 
440  int m = k / 2 ;
441 
442  if (j < m/2) {
443  name = "unused" ;
444  return ;
445  }
446 
447  ostringstream ostr ;
448  ostr << "P_" << j << '^' << m << flush ;
449  name = ostr.str() ;
450  }
451 
452  void basename_t_leg_mp(int k, int j, string& name) {
453 
454  assert( k>=0 ) ;
455  assert( j>=0 ) ;
456 
457  int m = 2 * (k / 2) ;
458 
459  if (j < m/2) {
460  name = "unused" ;
461  return ;
462  }
463  ostringstream ostr ;
464  ostr << "P_" << j << '^' << m << flush ;
465  name = ostr.str() ;
466  }
467 
468  void basename_t_leg_mi(int k, int j, string& name) {
469 
470  assert( k>=0 ) ;
471  assert( j>=0 ) ;
472 
473  int m = 2 * ((k-1) / 2) + 1 ;
474 
475  if (j < m/2) {
476  name = "unused" ;
477  return ;
478  }
479 
480  ostringstream ostr ;
481  ostr << "P_" << j << '^' << m << flush ;
482  name = ostr.str() ;
483  }
484 
485  void basename_t_leg_p(int k, int j, string& name) {
486 
487  assert( k>=0 ) ;
488  assert( j>=0 ) ;
489 
490  int m = k / 2 ;
491 
492  if (j < m/2) {
493  name = "unused" ;
494  return ;
495  }
496 
497  int xt = (m%2 == 0) ? 2*j : 2*j + 1 ;
498  ostringstream ostr ;
499  ostr << "P_" << xt << '^' << m << flush ;
500  name = ostr.str() ;
501  }
502 
503 
504  void basename_t_leg_pp(int k, int j, string& name) {
505 
506  assert( k>=0 ) ;
507  assert( j>=0 ) ;
508 
509  int m = 2 * (k / 2) ;
510 
511  if (j < m/2) {
512  name = "unused" ;
513  return ;
514  }
515 
516  ostringstream ostr ;
517  ostr << "P_" << 2*j << '^' << m << flush ;
518  name = ostr.str() ;
519  }
520 
521 
522  void basename_t_leg_i(int k, int j, string& name) {
523 
524  assert( k>=0 ) ;
525  assert( j>=0 ) ;
526 
527  int m = k / 2 ;
528 
529  if (j < m/2 + m%2) {
530  name = "unused" ;
531  return ;
532  }
533 
534  int xt = (m%2 == 0) ? 2*j + 1 : 2*j ;
535  ostringstream ostr ;
536  ostr << "P_" << xt << '^' << m << flush ;
537  name = ostr.str() ;
538  }
539 
540 
541  void basename_t_leg_ip(int k, int j, string& name) {
542 
543  assert( k>=0 ) ;
544  assert( j>=0 ) ;
545 
546  int m = 2 * (k / 2) ;
547 
548  if (j < m/2) {
549  name = "unused" ;
550  return ;
551  }
552 
553  ostringstream ostr ;
554  ostr << "P_" << (2*j + 1) << '^' << m << flush ;
555  name = ostr.str() ;
556  }
557 
558 
559  void basename_t_leg_pi(int k, int j, string& name) {
560 
561  assert( k>=0 ) ;
562  assert( j>=0 ) ;
563 
564  int m = 2 * ((k-1) / 2) + 1 ;
565 
566  if (j < m/2) {
567  name = "unused" ;
568  return ;
569  }
570 
571  ostringstream ostr ;
572  ostr << "P_" << (2*j + 1) << '^' << m << flush ;
573  name = ostr.str() ;
574  }
575 
576 
577  void basename_t_leg_ii(int k, int j, string& name) {
578 
579  assert( k>=0 ) ;
580  assert( j>=0 ) ;
581 
582  int m = 2 * ((k-1) / 2) + 1 ;
583 
584  if (j < m/2 + 1) {
585  name = "unused" ;
586  return ;
587  }
588 
589  ostringstream ostr ;
590  ostr << "P_" << 2*j << '^' << m << flush ;
591  name = ostr.str() ;
592 
593  }
594 
595 
596 }
#define T_LEG
fct. de Legendre associees
Definition: type_parite.h:236
#define T_LEG_MP
fct. de Legendre associees avec m pair
Definition: type_parite.h:238
#define T_LEG_PI
fct. de Legendre associees paires avec m impair
Definition: type_parite.h:224
#define T_LEG_MI
fct. de Legendre associees avec m impair
Definition: type_parite.h:240
Lorene prototypes.
Definition: app_hor.h:67
#define TRA_T
Translation en Theta, used for a bitwise shift (in hex)
Definition: type_parite.h:160
#define T_COS
dev. cos seulement
Definition: type_parite.h:196
#define T_COSSIN_SP
sin pair-cos impair alternes, sin pour m=0
Definition: type_parite.h:210
void name_theta(int l, int k, int j, string &basename) const
Name of the basis function in .
int nzone
Number of domains (zones)
Definition: base_val.h:330
#define T_SIN
dev. sin seulement
Definition: type_parite.h:198
#define T_CL_COS_P
CL of even cosines.
Definition: type_parite.h:228
#define T_LEG_I
fct. de Legendre associees impaires
Definition: type_parite.h:220
#define T_COS_I
dev. cos seulement, harmoniques impaires
Definition: type_parite.h:204
#define T_CL_SIN_P
CL of even sines.
Definition: type_parite.h:230
#define T_COS_P
dev. cos seulement, harmoniques paires
Definition: type_parite.h:200
#define T_CL_SIN_I
CL of odd sines.
Definition: type_parite.h:234
#define MSQ_T
Extraction de l&#39;info sur Theta.
Definition: type_parite.h:154
#define T_COSSIN_C
dev. cos-sin alternes, cos pour m=0
Definition: type_parite.h:192
int * b
Array (size: nzone ) of the spectral basis in each domain.
Definition: base_val.h:334
#define T_SIN_P
dev. sin seulement, harmoniques paires
Definition: type_parite.h:202
#define T_COSSIN_SI
sin impair-cos pair alternes, sin pour m=0
Definition: type_parite.h:214
#define T_LEG_IP
fct. de Legendre associees impaires avec m pair
Definition: type_parite.h:222
#define T_LEG_P
fct. de Legendre associees paires
Definition: type_parite.h:216
#define T_COSSIN_CI
cos impair-sin pair alternes, cos pour m=0
Definition: type_parite.h:212
#define T_LEG_II
fct. de Legendre associees impaires avec m impair
Definition: type_parite.h:226
#define T_CL_COS_I
CL of odd cosines.
Definition: type_parite.h:232
#define T_COSSIN_CP
cos pair-sin impair alternes, cos pour m=0
Definition: type_parite.h:208
#define MAX_BASE
Nombre max. de bases differentes.
Definition: type_parite.h:144
#define T_SIN_I
dev. sin seulement, harmoniques impaires
Definition: type_parite.h:206
#define T_LEG_PP
fct. de Legendre associees paires avec m pair
Definition: type_parite.h:218
#define T_COSSIN_S
dev. cos-sin alternes, sin pour m=0
Definition: type_parite.h:194