LORENE
base_val_name_phi.C
1/*
2 * Method Base_val::name_phi
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_phi.C,v 1.6 2023/06/28 10:04:32 j_novak Exp $
32 * $Log: base_val_name_phi.C,v $
33 * Revision 1.6 2023/06/28 10:04:32 j_novak
34 * Use of C++ strings and flows instead of C types.
35 *
36 * Revision 1.5 2016/12/05 16:17:44 j_novak
37 * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
38 *
39 * Revision 1.4 2014/10/13 08:52:39 j_novak
40 * Lorene classes and functions now belong to the namespace Lorene.
41 *
42 * Revision 1.3 2014/10/06 15:12:57 j_novak
43 * Modified #include directives to use c++ syntax.
44 *
45 * Revision 1.2 2012/01/17 14:44:27 j_penner
46 * Modified phi variables to only use 16 integers in arrays
47 *
48 * Revision 1.1 2003/10/19 19:49:40 e_gourgoulhon
49 * First version
50 *
51 *
52 *
53 * $Header: /cvsroot/Lorene/C++/Source/Base_val/base_val_name_phi.C,v 1.6 2023/06/28 10:04:32 j_novak Exp $
54 *
55 */
56
57// C headers
58#include <cstring>
59#include <cstdlib>
60
61// Header C++
62#include <sstream>
63
64// Lorene headers
65#include "base_val.h"
66
67// Local prototypes
68namespace Lorene {
69void basename_p_unknown(int, string&) ;
70void basename_p_cossin(int, string&) ;
71void basename_p_cossin_p(int, string&) ;
72void basename_p_cossin_i(int, string&) ;
73
74 //----------------------------//
75 // Base_val method //
76 //----------------------------//
77
78void Base_val::name_phi(int l, int k, string& name) const {
79
80 // Array of actual base name functions
81 static void(*vbasename_p[MAX_BASE_2])(int, string&) ;
82
83 static bool first_call = true ;
84
85 // Initializations at first call
86 // -----------------------------
87 if ( first_call ) {
88
89 first_call = false ;
90
91 for (int i=0 ; i<MAX_BASE_2 ; i++) {
92 vbasename_p[i] = basename_p_unknown ;
93 }
94
95 vbasename_p[P_COSSIN >> TRA_P] = basename_p_cossin ;
96 vbasename_p[P_COSSIN_P >> TRA_P] = basename_p_cossin_p ;
97 vbasename_p[P_COSSIN_I >> TRA_P] = basename_p_cossin_i ;
98
99 }
100
101 // Call to the function adapted to the basis in domain l
102 //------------------------------------------------------
103
104 assert( (l>=0) && (l<nzone) ) ;
105
106 int base_p = ( b[l] & MSQ_P ) >> TRA_P ;
107
108 vbasename_p[base_p](k, name) ;
109
110}
111
112
113 //-------------------------------//
114 // individual basis functions //
115 //-------------------------------//
116
117void basename_p_unknown(int, string&) {
118 cout << "Base_val::name_phi : unknwon basis !" << endl ;
119 abort() ;
120}
121
122
123void basename_p_cossin(int k, string& name) {
124
125 assert( k>=0 ) ;
126
127 ostringstream ostr ;
128
129 if (k%2 == 0) {
130 ostr << "cos" ;
131 }
132 else {
133 if (k == 1) {
134 name = "unused" ;
135 return ;
136 }
137 else {
138 ostr << "sin" ;
139 }
140 }
141
142 int m = k / 2 ;
143
144 ostr << m << 'p' << flush ;
145 name = ostr.str() ;
146}
147
148
149
150void basename_p_cossin_p(int k, string& name) {
151
152 assert( k>=0 ) ;
153
154 ostringstream ostr ;
155 if (k%2 == 0) {
156 ostr << "cos" ;
157 }
158 else {
159 if (k == 1) {
160 name = "unused" ;
161 return ;
162 }
163 else {
164 ostr << "sin" ;
165 }
166 }
167
168 int m = 2 * (k / 2) ;
169
170 ostr << m << 'p' << flush ;
171 name = ostr.str() ;
172}
173
174
175void basename_p_cossin_i(int k, string& name) {
176
177 assert( k>=0 ) ;
178
179 ostringstream ostr ;
180 if (k == 0) {
181 name = "cos1p" ;
182 return ;
183 }
184
185 if (k%2 == 0) {
186 ostr << "sin" ;
187 }
188 else {
189 if (k == 1) {
190 name = "unused" ;
191 return ;
192 }
193 else {
194 ostr << "cos" ;
195 }
196 }
197
198 int m = 2 * ((k-1) / 2) + 1 ;
199 ostr << m << 'p' << flush ;
200 name = ostr.str() ;
201
202}
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218}
void name_phi(int l, int k, string &basename) const
Name of the basis function in .
int * b
Array (size: nzone ) of the spectral basis in each domain.
Definition base_val.h:334
int nzone
Number of domains (zones).
Definition base_val.h:330
#define MAX_BASE_2
Smaller maximum bases used for phi (and higher dimensions for now).
#define P_COSSIN_P
dev. sur Phi = 2*phi, freq. paires
#define P_COSSIN
dev. standart
#define P_COSSIN_I
dev. sur Phi = 2*phi, freq. impaires
#define MSQ_P
Extraction de l'info sur Phi.
#define TRA_P
Translation en Phi, used for a bitwise shift (in hex).
Lorene prototypes.
Definition app_hor.h:67