LORENE
valeur_mult_x.C
1/*
2 * Computation of x*Id
3 *
4 * for:
5 * - Valeur
6 * - Mtbl_cf
7 */
8
9/*
10 * Copyright (c) 1999-2001 Jerome Novak
11 * Copyright (c) 1999-2001 Eric Gourgoulhon
12 *
13 * This file is part of LORENE.
14 *
15 * LORENE is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * LORENE is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with LORENE; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 */
30
31
32
33
34/*
35 * $Id: valeur_mult_x.C,v 1.8 2023/05/24 09:52:02 g_servignat Exp $
36 * $Log: valeur_mult_x.C,v $
37 * Revision 1.8 2023/05/24 09:52:02 g_servignat
38 * Added multiplication by \xi in a given shell, and dealiasing product in angular direction only
39 *
40 * Revision 1.7 2016/12/05 16:18:21 j_novak
41 * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
42 *
43 * Revision 1.6 2015/03/05 08:49:33 j_novak
44 * Implemented operators with Legendre bases.
45 *
46 * Revision 1.5 2014/10/13 08:53:50 j_novak
47 * Lorene classes and functions now belong to the namespace Lorene.
48 *
49 * Revision 1.4 2014/10/06 15:13:24 j_novak
50 * Modified #include directives to use c++ syntax.
51 *
52 * Revision 1.3 2008/08/27 08:52:55 jl_cornou
53 * Added Jacobi(0,2) polynomials case
54 *
55 * Revision 1.2 2004/11/23 15:17:19 m_forot
56 * Added the bases for the cases without any equatorial symmetry
57 * (T_COSSIN_C, T_COSSIN_S, T_LEG, R_CHEBPI_P, R_CHEBPI_I).
58 *
59 * Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon
60 * LORENE
61 *
62 * Revision 1.5 1999/11/30 12:45:07 eric
63 * Valeur::base est desormais du type Base_val et non plus Base_val*.
64 *
65 * Revision 1.4 1999/11/24 09:34:16 eric
66 * Modif commentaires.
67 *
68 * Revision 1.3 1999/11/23 16:18:04 eric
69 * Reorganisation du calcul dans le cas ETATZERO.
70 *
71 * Revision 1.2 1999/11/19 09:31:21 eric
72 * La valeur de retour est desormais const Valeur &.
73 *
74 * Revision 1.1 1999/11/16 13:37:24 novak
75 * Initial revision
76 *
77 *
78 * $Header: /cvsroot/Lorene/C++/Source/Valeur/valeur_mult_x.C,v 1.8 2023/05/24 09:52:02 g_servignat Exp $
79 *
80 */
81
82// Headers C
83#include <cassert>
84
85// Headers Lorene
86#include "mtbl_cf.h"
87#include "valeur.h"
88
89// Local prototypes
90namespace Lorene {
91void _mult_x_pas_prevu(Tbl *, int &) ;
92void _mult_x_r_chebp(Tbl *, int &) ;
93void _mult_x_r_chebi(Tbl *, int &) ;
94void _mult_x_r_chebpim_p(Tbl *, int &) ;
95void _mult_x_r_chebpim_i(Tbl *, int &) ;
96void _mult_xm1_cheb(Tbl *, int&) ;
97void _mult_x_identite (Tbl *, int &) ;
98void _mult_x_r_chebpi_p(Tbl *, int &) ;
99void _mult_x_r_chebpi_i(Tbl *, int &) ;
100void _mult_x_r_jaco02(Tbl *, int &) ;
101void _mult_x_r_legp(Tbl *, int &) ;
102void _mult_x_r_legi(Tbl *, int &) ;
103void _mult_x_r_cheb(Tbl *, int &) ;
104
105// Version membre d'un Valeur
106// --------------------------
107
108const Valeur& Valeur::mult_x() const {
109
110 // Protection
111 assert(etat != ETATNONDEF) ;
112
113 // Peut-etre rien a faire ?
114 if (p_mult_x != 0x0) {
115 return *p_mult_x ;
116 }
117
118 // ... si, il faut bosser
119
120 p_mult_x = new Valeur(mg) ;
121
122 if (etat == ETATZERO) {
123 p_mult_x->set_etat_zero() ;
124 }
125 else {
126 assert(etat == ETATQCQ) ;
127 p_mult_x->set_etat_cf_qcq() ;
128 Mtbl_cf* cfp = p_mult_x->c_cf ; // Pointeur sur le Mtbl_cf qui vient d'etre
129 // cree par le set_etat_cf_qcq()
130
131 // Initialisation de *cfp : recopie des coef. de la fonction
132 if (c_cf == 0x0) {
133 coef() ;
134 }
135 *cfp = *c_cf ;
136
137 cfp->mult_x() ; // calcul
138
139 p_mult_x->base = cfp->base ; // On remonte la base de sortie au niveau Valeur
140 }
141
142 // Termine
143 return *p_mult_x ;
144}
145
146
147
148// Version membre d'un Mtbl_cf
149// ---------------------------
150
152
153// Routines de derivation
154static void (*_mult_x[MAX_BASE])(Tbl *, int &) ;
155static int nap = 0 ;
156
157 // Premier appel
158 if (nap==0) {
159 nap = 1 ;
160 for (int i=0 ; i<MAX_BASE ; i++) {
161 _mult_x[i] = _mult_x_pas_prevu ;
162 }
163 // Les routines existantes
164 _mult_x[R_CHEB >> TRA_R] = _mult_x_identite ;
165 _mult_x[R_CHEBU >> TRA_R] = _mult_xm1_cheb ;
166 _mult_x[R_CHEBP >> TRA_R] = _mult_x_r_chebp ;
167 _mult_x[R_CHEBI >> TRA_R] = _mult_x_r_chebi ;
168 _mult_x[R_CHEBPIM_P >> TRA_R] = _mult_x_r_chebpim_p ;
169 _mult_x[R_CHEBPIM_I >> TRA_R] = _mult_x_r_chebpim_i ;
170 _mult_x[R_CHEBPI_P >> TRA_R] = _mult_x_r_chebpi_p ;
171 _mult_x[R_CHEBPI_I >> TRA_R] = _mult_x_r_chebpi_i ;
172 _mult_x[R_JACO02 >> TRA_R] = _mult_x_r_jaco02 ;
173 _mult_x[R_LEG >> TRA_R] = _mult_x_identite ;
174 _mult_x[R_LEGP >> TRA_R] = _mult_x_r_legp ;
175 _mult_x[R_LEGI >> TRA_R] = _mult_x_r_legi ;
176 }
177
178 // Debut de la routine
179
180 // Protection
181 assert(etat == ETATQCQ) ;
182
183 // Boucle sur les zones
184 int base_r ;
185 for (int l=0 ; l<nzone ; l++) {
186 base_r = (base.b[l] & MSQ_R) >> TRA_R ;
187 assert(t[l] != 0x0) ;
188 _mult_x[base_r](t[l], base.b[l]) ;
189 }
190}
191
193
194 // Peut-etre ne rien faire ?
195 if (etat==ETATZERO) {
196 return ;
197 }
198
199 assert(etat==ETATQCQ) ;
200
201 // Calcul des coef.
202 coef() ;
203
204 // La multiplication
205 c_cf->mult_x_shell(lz) ;
207
208 base = c_cf->base ; // On remonte la base de sortie au niveau Valeur
209
210}
211
212/*
213 * Fonction membre de la classe Mtbl_cf pour la multiplication par x
214 * dans une coquille applique a this
215 *
216 */
217
219{
220
221 if (mg->get_type_r(lz) != FIN) {
222 cerr << "Mtbl_cf::mult_xp1_shell() : not called on a shell!" << endl ;
223 abort() ;
224 }
225
226 // Peut-etre ne rien faire ?
227 if (etat==ETATZERO) {
228 return ;
229 }
230
231 assert(etat==ETATQCQ) ;
232
233 _mult_x_r_cheb(t[lz], base.b[lz]) ;
234
235}
236
237}
Coefficients storage for the multi-domain spectral method.
Definition mtbl_cf.h:196
Base_val base
Bases of the spectral expansions.
Definition mtbl_cf.h:210
const Mg3d * mg
Pointer on the multi-grid Mgd3 on which this is defined.
Definition mtbl_cf.h:202
int etat
Logical state (ETATNONDEF , ETATQCQ or ETATZERO ).
Definition mtbl_cf.h:206
Tbl ** t
Array (size nzone ) of pointers on the Tbl 's which contain the spectral coefficients in each domain.
Definition mtbl_cf.h:215
void mult_x()
(r -sampling = RARE ) \ Id (r sampling = FIN ) \ (r -sampling = UNSURR )
void mult_x_shell(int i)
Id (r sampling = RARE, UNSURR ) \ (r -sampling = FIN ).
int nzone
Number of domains (zones).
Definition mtbl_cf.h:204
Basic array class.
Definition tbl.h:161
void set_etat_cf_qcq()
Sets the logical state to ETATQCQ (ordinary state) for values in the configuration space (Mtbl_cf c_c...
Definition valeur.C:715
Valeur * p_mult_x
Pointer on .
Definition valeur.h:324
Valeur(const Mg3d &mgrid)
Constructor.
Definition valeur.C:203
void mult_x_shell(int index)
Applies the following operator to *this : \ Id (r sampling = RARE, UNSURR ) \ (r -sampling = FIN ) \...
const Mg3d * mg
Multi-grid Mgd3 on which this is defined.
Definition valeur.h:302
const Valeur & mult_x() const
Returns (r -sampling = RARE ) \ Id (r sampling = FIN ) \ (r -sampling = UNSURR ).
Mtbl_cf * c_cf
Coefficients of the spectral expansion of the function.
Definition valeur.h:312
void coef() const
Computes the coeffcients of *this.
Base_val base
Bases on which the spectral expansion is performed.
Definition valeur.h:315
int etat
Logical state (ETATNONDEF , ETATQCQ or ETATZERO ).
Definition valeur.h:305
#define R_LEGP
base de Legendre paire (rare) seulement
#define MAX_BASE
Nombre max. de bases differentes.
#define R_CHEBU
base de Chebychev ordinaire (fin), dev. en 1/r
#define R_JACO02
base de Jacobi(0,2) ordinaire (finjac)
#define R_LEGI
base de Legendre impaire (rare) seulement
#define R_CHEBI
base de Cheb. impaire (rare) seulement
#define MSQ_R
Extraction de l'info sur R.
#define R_CHEBPIM_I
Cheb. pair-impair suivant m, impair pour m=0.
#define R_CHEBPI_I
Cheb. pair-impair suivant l impair pour l=0.
#define R_LEG
base de Legendre ordinaire (fin)
#define R_CHEBPIM_P
Cheb. pair-impair suivant m, pair pour m=0.
#define TRA_R
Translation en R, used for a bitwise shift (in hex).
#define R_CHEB
base de Chebychev ordinaire (fin)
#define R_CHEBP
base de Cheb. paire (rare) seulement
#define R_CHEBPI_P
Cheb. pair-impair suivant l pair pour l=0.
Lorene prototypes.
Definition app_hor.h:67