LORENE
valeur_dsdx.C
1 /*
2  * Computation of d/dx
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  *
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 char valeur_dsdx_C[] = "$Header: /cvsroot/Lorene/C++/Source/Valeur/valeur_dsdx.C,v 1.6 2014/10/13 08:53:49 j_novak Exp $" ;
33 
34 /*
35  * $Id: valeur_dsdx.C,v 1.6 2014/10/13 08:53:49 j_novak Exp $
36  * $Log: valeur_dsdx.C,v $
37  * Revision 1.6 2014/10/13 08:53:49 j_novak
38  * Lorene classes and functions now belong to the namespace Lorene.
39  *
40  * Revision 1.5 2014/10/06 15:13:23 j_novak
41  * Modified #include directives to use c++ syntax.
42  *
43  * Revision 1.4 2013/06/14 15:54:07 j_novak
44  * Inclusion of Legendre bases.
45  *
46  * Revision 1.3 2007/12/14 10:19:35 jl_cornou
47  * *** empty log message ***
48  *
49  * Revision 1.2 2004/11/23 15:17:19 m_forot
50  * Added the bases for the cases without any equatorial symmetry
51  * (T_COSSIN_C, T_COSSIN_S, T_LEG, R_CHEBPI_P, R_CHEBPI_I).
52  *
53  * Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon
54  * LORENE
55  *
56  * Revision 2.7 1999/11/30 12:44:13 eric
57  * Valeur::base est desormais du type Base_val et non plus Base_val*.
58  *
59  * Revision 2.6 1999/11/23 16:17:06 eric
60  * Reorganisation du calcul dans le cas ETATZERO.
61  *
62  * Revision 2.5 1999/11/19 09:31:06 eric
63  * La valeur de retour est desormais const Valeur &.
64  *
65  * Revision 2.4 1999/10/28 08:00:20 eric
66  * Modif commentaires.
67  *
68  * Revision 2.3 1999/10/18 13:41:46 eric
69  * Suppression de l'argument base dans les routines de derivation des mtbl_cf.
70  *
71  * Revision 2.2 1999/04/09 14:03:58 phil
72  * Correction erreur base dans Valeur Valeur::dsdx.
73  *
74  * Revision 2.1 1999/03/01 14:56:40 eric
75  * *** empty log message ***
76  *
77  * Revision 2.0 1999/02/22 15:39:13 hyc
78  * *** empty log message ***
79  *
80  *
81  * $Header: /cvsroot/Lorene/C++/Source/Valeur/valeur_dsdx.C,v 1.6 2014/10/13 08:53:49 j_novak Exp $
82  *
83  */
84 
85 // Headers C
86 #include <cassert>
87 
88 // Headers Lorene
89 #include "mtbl_cf.h"
90 #include "valeur.h"
91 
92 // Prototypage temporaire
93 namespace Lorene {
94 void _dsdx_pas_prevu(Tbl *, int &) ;
95 void _dsdx_r_cheb(Tbl *, int &) ;
96 void _dsdx_r_chebu(Tbl *, int &) ;
97 void _dsdx_r_chebp(Tbl *, int &) ;
98 void _dsdx_r_chebi(Tbl *, int &) ;
99 void _dsdx_r_chebpim_p(Tbl *, int &) ;
100 void _dsdx_r_chebpim_i(Tbl *, int &) ;
101 void _dsdx_r_chebpi_p(Tbl *, int &) ;
102 void _dsdx_r_chebpi_i(Tbl *, int &) ;
103 void _dsdx_r_leg(Tbl *, int &) ;
104 void _dsdx_r_legp(Tbl *, int &) ;
105 void _dsdx_r_legi(Tbl *, int &) ;
106 void _dsdx_r_jaco02(Tbl *, int &) ;
107 
108 // Version membre d'un Valeur
109 // --------------------------
110 
111 const Valeur& Valeur::dsdx() const {
112 
113  // Protection
114  assert(etat != ETATNONDEF) ;
115 
116  // Peut-etre rien a faire ?
117  if (p_dsdx != 0x0) {
118  return *p_dsdx ;
119  }
120 
121  // ... si, il faut bosser
122 
123  p_dsdx = new Valeur(mg) ;
124 
125  if (etat == ETATZERO) {
126  p_dsdx->set_etat_zero() ;
127  }
128  else {
129  assert(etat == ETATQCQ) ;
131  Mtbl_cf* cfp = p_dsdx->c_cf ; // Pointeur sur le Mtbl_cf qui vient d'etre
132  // cree par le set_etat_cf_qcq()
133 
134  // Initialisation de *cfp : recopie des coef. de la fonction
135  if (c_cf == 0x0) {
136  coef() ;
137  }
138  *cfp = *c_cf ;
139 
140  cfp->dsdx() ; // calcul
141 
142  p_dsdx->base = cfp->base ; // On remonte la base de sortie au niveau Valeur
143  }
144 
145  // Termine
146  return *p_dsdx ;
147 }
148 
149 
150 // Version membre d'un Mtbl_cf
151 // ---------------------------
152 
154 
155 // Routines de derivation
156 static void (*_dsdx[MAX_BASE])(Tbl *, int &) ;
157 static int nap = 0 ;
158 
159  // Premier appel
160  if (nap==0) {
161  nap = 1 ;
162  for (int i=0 ; i<MAX_BASE ; i++) {
163  _dsdx[i] = _dsdx_pas_prevu ;
164  }
165  // Les routines existantes
166  _dsdx[R_CHEB >> TRA_R] = _dsdx_r_cheb ;
167  _dsdx[R_CHEBU >> TRA_R] = _dsdx_r_chebu ;
168  _dsdx[R_CHEBP >> TRA_R] = _dsdx_r_chebp ;
169  _dsdx[R_CHEBI >> TRA_R] = _dsdx_r_chebi ;
170  _dsdx[R_CHEBPIM_P >> TRA_R] = _dsdx_r_chebpim_p ;
171  _dsdx[R_CHEBPIM_I >> TRA_R] = _dsdx_r_chebpim_i ;
172  _dsdx[R_CHEBPI_P >> TRA_R] = _dsdx_r_chebpi_p ;
173  _dsdx[R_CHEBPI_I >> TRA_R] = _dsdx_r_chebpi_i ;
174  _dsdx[R_LEG >> TRA_R] = _dsdx_r_leg ;
175  _dsdx[R_LEGP >> TRA_R] = _dsdx_r_legp ;
176  _dsdx[R_LEGI >> TRA_R] = _dsdx_r_legi ;
177  _dsdx[R_JACO02 >> TRA_R] = _dsdx_r_jaco02 ;
178  }
179 
180  //- Debut de la routine -
181 
182  // Protection
183  assert(etat == ETATQCQ) ;
184 
185  // Boucle sur les zones
186  for (int l=0 ; l<nzone ; l++) {
187  int base_r = (base.b[l] & MSQ_R) >> TRA_R ;
188  assert(t[l] != 0x0) ;
189  _dsdx[base_r](t[l], base.b[l]) ;
190  }
191 }
192 }
Mtbl_cf * c_cf
Coefficients of the spectral expansion of the function.
Definition: valeur.h:302
const Valeur & dsdx() const
Returns of *this.
Definition: valeur_dsdx.C:111
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
void coef() const
Computes the coeffcients of *this.
Definition: valeur_coef.C:148
void set_etat_zero()
Sets the logical state to ETATZERO (zero).
Definition: valeur.C:689
#define R_CHEBPI_I
Cheb. pair-impair suivant l impair pour l=0.
Definition: type_parite.h:174
Lorene prototypes.
Definition: app_hor.h:64
Values and coefficients of a (real-value) function.
Definition: valeur.h:287
#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
#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
const Mg3d * mg
Multi-grid Mgd3 on which this is defined.
Definition: valeur.h:292
#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
Valeur * p_dsdx
Pointer on .
Definition: valeur.h:310
Base_val base
Bases on which the spectral expansion is performed.
Definition: valeur.h:305
int * b
Array (size: nzone ) of the spectral basis in each domain.
Definition: base_val.h:331
#define MSQ_R
Extraction de l&#39;info sur R.
Definition: type_parite.h:152
Valeur(const Mg3d &mgrid)
Constructor.
Definition: valeur.C:200
#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
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
int etat
Logical state (ETATNONDEF , ETATQCQ or ETATZERO ).
Definition: valeur.h:295
Basic array class.
Definition: tbl.h:161
#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