LORENE
valeur_sx2.C
1/*
2 * Computation of 1/x^2
3 *
4 * for:
5 * - Valeur
6 * - Mtbl_cf
7 */
8
9/*
10 * Copyright (c) 1999-2000 Jean-Alain Marck
11 * Copyright (c) 1999-2001 Eric Gourgoulhon
12 * Copyright (c) 1999-2001 Philippe Grandclement
13 *
14 * This file is part of LORENE.
15 *
16 * LORENE is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * LORENE is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with LORENE; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 *
30 */
31
32
33char valeur_sx2_C[] = "$Header: /cvsroot/Lorene/C++/Source/Valeur/valeur_sx2.C,v 1.5 2015/03/05 08:49:33 j_novak Exp $" ;
34
35/*
36 * $Id: valeur_sx2.C,v 1.5 2015/03/05 08:49:33 j_novak Exp $
37 * $Log: valeur_sx2.C,v $
38 * Revision 1.5 2015/03/05 08:49:33 j_novak
39 * Implemented operators with Legendre bases.
40 *
41 * Revision 1.4 2014/10/13 08:53:51 j_novak
42 * Lorene classes and functions now belong to the namespace Lorene.
43 *
44 * Revision 1.3 2014/10/06 15:13:24 j_novak
45 * Modified #include directives to use c++ syntax.
46 *
47 * Revision 1.2 2004/11/23 15:17:20 m_forot
48 * Added the bases for the cases without any equatorial symmetry
49 * (T_COSSIN_C, T_COSSIN_S, T_LEG, R_CHEBPI_P, R_CHEBPI_I).
50 *
51 * Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon
52 * LORENE
53 *
54 * Revision 2.8 1999/11/30 12:46:01 eric
55 * Valeur::base est desormais du type Base_val et non plus Base_val*.
56 *
57 * Revision 2.7 1999/11/23 16:19:22 eric
58 * Reorganisation du calcul dans le cas ETATZERO.
59 *
60 * Revision 2.6 1999/11/19 09:32:02 eric
61 * La valeur de retour est desormais const Valeur &.
62 *
63 * Revision 2.5 1999/10/28 08:00:57 eric
64 * Modif commentaires.
65 *
66 * Revision 2.4 1999/10/18 13:43:07 eric
67 * Suppression de l'argument base dans les routines de derivation des mtbl_cf.
68 *
69 * Revision 2.3 1999/04/28 10:10:59 phil
70 * *** empty log message ***
71 *
72 * Revision 2.2 1999/04/26 17:15:57 phil
73 * *** empty log message ***
74 *
75 * Revision 2.1 1999/04/26 17:14:20 phil
76 * *** empty log message ***
77 *
78 * Revision 2.0 1999/04/26 17:13:09 phil
79 * *** empty log message ***
80 *
81 * Revision 2.0 1999/04/26 14:59:31 phil
82 * *** empty log message ***
83 *
84 *
85 * $Header: /cvsroot/Lorene/C++/Source/Valeur/valeur_sx2.C,v 1.5 2015/03/05 08:49:33 j_novak Exp $
86 *
87 */
88
89
90// Headers C
91#include <cassert>
92
93// Headers Lorene
94#include "mtbl_cf.h"
95#include "valeur.h"
96
97// Local prototypes:
98namespace Lorene {
99void _sx2_pas_prevu(Tbl *, int &) ;
100void _sx2_r_chebu(Tbl *, int &) ;
101void _sx2_r_chebp(Tbl *, int &) ;
102void _sx2_r_chebi(Tbl *, int &) ;
103void _sx2_r_chebpim_p(Tbl *, int &) ;
104void _sx2_r_chebpim_i(Tbl *, int &) ;
105void _sx2_identite (Tbl *, int &) ;
106void _sx2_r_chebpi_p(Tbl *, int &) ;
107void _sx2_r_chebpi_i(Tbl *, int &) ;
108void _sx2_r_legp(Tbl *, int &) ;
109void _sx2_r_legi(Tbl *, int &) ;
110
111// Version membre d'un Valeur
112// --------------------------
113
114const Valeur& Valeur::sx2() const {
115
116 // Protection
117 assert(etat != ETATNONDEF) ;
118
119 // Peut-etre rien a faire ?
120 if (p_sx2 != 0x0) {
121 return *p_sx2 ;
122 }
123
124 // ... si, il faut bosser
125
126 p_sx2 = new Valeur(mg) ;
127
128 if (etat == ETATZERO) {
129 p_sx2->set_etat_zero() ;
130 }
131 else {
132 assert(etat == ETATQCQ) ;
134 Mtbl_cf* cfp = p_sx2->c_cf ; // Pointeur sur le Mtbl_cf qui vient d'etre
135 // cree par le set_etat_cf_qcq()
136
137 // Initialisation de *cfp : recopie des coef. de la fonction
138 if (c_cf == 0x0) {
139 coef() ;
140 }
141 *cfp = *c_cf ;
142
143 cfp->sx2() ; // calcul
144
145 p_sx2->base = cfp->base ; // On remonte la base de sortie au niveau Valeur
146 }
147
148 // Termine
149 return *p_sx2 ;
150}
151
152
153
154// Version membre d'un Mtbl_cf
155// ---------------------------
156\
158
159// Routines de derivation
160static void (*_sx2[MAX_BASE])(Tbl *, int &) ;
161static int nap = 0 ;
162
163 // Premier appel
164 if (nap==0) {
165 nap = 1 ;
166 for (int i=0 ; i<MAX_BASE ; i++) {
167 _sx2[i] = _sx2_pas_prevu ;
168 }
169 // Les routines existantes
170 _sx2[R_CHEB >> TRA_R] = _sx2_identite ;
171 _sx2[R_CHEBU >> TRA_R] = _sx2_r_chebu ;
172 _sx2[R_CHEBP >> TRA_R] = _sx2_r_chebp ;
173 _sx2[R_CHEBI >> TRA_R] = _sx2_r_chebi ;
174 _sx2[R_CHEBPIM_P >> TRA_R] = _sx2_r_chebpim_p ;
175 _sx2[R_CHEBPIM_I >> TRA_R] = _sx2_r_chebpim_i ;
176 _sx2[R_CHEBPI_P >> TRA_R] = _sx2_r_chebpi_p ;
177 _sx2[R_CHEBPI_I >> TRA_R] = _sx2_r_chebpi_i ;
178 _sx2[R_LEG >> TRA_R] = _sx2_identite ;
179 _sx2[R_LEGP >> TRA_R] = _sx2_r_legp ;
180 _sx2[R_LEGI >> TRA_R] = _sx2_r_legi ;
181 }
182
183 //- Debut de la routine -
184
185 // Protection
186 assert(etat == ETATQCQ) ;
187
188 // Boucle sur les zones
189 for (int l=0 ; l<nzone ; l++) {
190 int base_r = (base.b[l] & MSQ_R) >> TRA_R ;
191 assert(t[l] != 0x0) ;
192 _sx2[base_r](t[l], base.b[l]) ;
193 }
194}
195}
int * b
Array (size: nzone ) of the spectral basis in each domain.
Definition base_val.h:331
Time evolution with partial storage (*** under development ***).
Definition evolution.h:371
Coefficients storage for the multi-domain spectral method.
Definition mtbl_cf.h:186
Base_val base
Bases of the spectral expansions.
Definition mtbl_cf.h:200
void sx2()
(r -sampling = RARE ) \ Id (r sampling = FIN ) \ (r -sampling = UNSURR )
Definition valeur_sx2.C:157
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
int nzone
Number of domains (zones)
Definition mtbl_cf.h:194
Basic array class.
Definition tbl.h:161
Values and coefficients of a (real-value) function.
Definition valeur.h:287
const Valeur & sx2() const
Returns (r -sampling = RARE ) \ Id (r sampling = FIN ) \ (r -sampling = UNSURR )
Definition valeur_sx2.C:114
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:712
Valeur * p_sx2
Pointer on .
Definition valeur.h:313
void set_etat_zero()
Sets the logical state to ETATZERO (zero).
Definition valeur.C:689
const Mg3d * mg
Multi-grid Mgd3 on which this is defined.
Definition valeur.h:292
Mtbl_cf * c_cf
Coefficients of the spectral expansion of the function.
Definition valeur.h:302
void coef() const
Computes the coeffcients of *this.
Base_val base
Bases on which the spectral expansion is performed.
Definition valeur.h:305
int etat
Logical state (ETATNONDEF , ETATQCQ or ETATZERO ).
Definition valeur.h:295
#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_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:64