LORENE
valeur_scost.C
1 /*
2  * Computation of 1/(cos theta)
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_scost.C,v 1.6 2016/12/05 16:18:21 j_novak Exp $
36  * $Log: valeur_scost.C,v $
37  * Revision 1.6 2016/12/05 16:18:21 j_novak
38  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
39  *
40  * Revision 1.5 2014/10/13 08:53:51 j_novak
41  * Lorene classes and functions now belong to the namespace Lorene.
42  *
43  * Revision 1.4 2014/10/06 15:13:24 j_novak
44  * Modified #include directives to use c++ syntax.
45  *
46  * Revision 1.3 2009/10/10 18:28:11 j_novak
47  * New bases T_COS and T_SIN.
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 1.5 1999/11/30 12:45:27 eric
57  * Valeur::base est desormais du type Base_val et non plus Base_val*.
58  *
59  * Revision 1.4 1999/11/24 09:34:46 eric
60  * Modif commentaires.
61  *
62  * Revision 1.3 1999/11/23 16:18:13 eric
63  * Reorganisation du calcul dans le cas ETATZERO.
64  *
65  * Revision 1.2 1999/11/19 09:31:31 eric
66  * La valeur de retour est desormais const Valeur &.
67  *
68  * Revision 1.1 1999/11/16 13:37:50 novak
69  * Initial revision
70  *
71  *
72  * $Header: /cvsroot/Lorene/C++/Source/Valeur/valeur_scost.C,v 1.6 2016/12/05 16:18:21 j_novak Exp $
73  *
74  */
75 
76 // Headers C
77 #include <cassert>
78 
79 // Headers Lorene
80 #include "mtbl_cf.h"
81 #include "valeur.h"
82 
83 // Local prototypes
84 namespace Lorene {
85 void _scost_pas_prevu (Tbl*, int&) ;
86 void _scost_t_cos (Tbl*, int&) ;
87 void _scost_t_sin (Tbl*, int&) ;
88 void _scost_t_sin_p (Tbl*, int&) ;
89 void _scost_t_sin_i (Tbl*, int&) ;
90 void _scost_t_cos_i (Tbl*, int&) ;
91 void _scost_t_cos_p (Tbl*, int&) ;
92 void _scost_t_cossin_si (Tbl*, int&) ;
93 void _scost_t_cossin_ci (Tbl*, int&) ;
94 void _scost_t_cossin_cp (Tbl*, int&) ;
95 void _scost_t_cossin_sp (Tbl*, int&) ;
96 void _scost_t_cossin_c (Tbl*, int&) ;
97 void _scost_t_cossin_s (Tbl*, int&) ;
98 
99 // Version membre d'un Valeur
100 // --------------------------
101 
102 const Valeur& Valeur::scost() const {
103 
104  // Protection
105  assert(etat != ETATNONDEF) ;
106 
107  // Peut-etre rien a faire ?
108  if (p_scost != 0x0) {
109  return *p_scost ;
110  }
111 
112  // ... si, il faut bosser
113 
114  p_scost = new Valeur(mg) ;
115 
116  if (etat == ETATZERO) {
117  p_scost->set_etat_zero() ;
118  }
119  else {
120  assert(etat == ETATQCQ) ;
122  Mtbl_cf* cfp = p_scost->c_cf ; // Pointeur sur le Mtbl_cf qui vient d'etre
123  // cree par le set_etat_cf_qcq()
124 
125  // Initialisation de *cfp : recopie des coef. de la fonction
126  if (c_cf == 0x0) {
127  coef() ;
128  }
129  *cfp = *c_cf ;
130 
131  cfp->scost() ; // calcul
132 
133  p_scost->base = cfp->base ; // On remonte la base de sortie au niveau Valeur
134  }
135 
136  // Termine
137  return *p_scost ;
138 }
139 
140 
141 
142 // Version membre d'un Mtbl_cf
143 // ---------------------------
144 
146 
147 // Routines de derivation
148 static void (*_scost[MAX_BASE])(Tbl *, int &) ;
149 static int nap = 0 ;
150 
151  // Premier appel
152  if (nap==0) {
153  nap = 1 ;
154  for (int i=0 ; i<MAX_BASE ; i++) {
155  _scost[i] = _scost_pas_prevu ;
156  }
157  // Les routines existantes
158  _scost[T_COS >> TRA_T] = _scost_t_cos ;
159  _scost[T_SIN >> TRA_T] = _scost_t_sin ;
160  _scost[T_COS_P >> TRA_T] = _scost_t_cos_p ;
161  _scost[T_COS_I >> TRA_T] = _scost_t_cos_i ;
162  _scost[T_SIN_P >> TRA_T] = _scost_t_sin_p ;
163  _scost[T_SIN_I >> TRA_T] = _scost_t_sin_i ;
164  _scost[T_COSSIN_SI >> TRA_T] = _scost_t_cossin_si ;
165  _scost[T_COSSIN_CI >> TRA_T] = _scost_t_cossin_ci ;
166  _scost[T_COSSIN_CP >> TRA_T] = _scost_t_cossin_cp ;
167  _scost[T_COSSIN_SP >> TRA_T] = _scost_t_cossin_sp ;
168  _scost[T_COSSIN_C >> TRA_T] = _scost_t_cossin_c ;
169  _scost[T_COSSIN_S >> TRA_T] = _scost_t_cossin_s ;
170  }
171 
172  // Debut de la routine
173 
174  // Protection
175  assert(etat == ETATQCQ) ;
176 
177  // Boucle sur les zones
178  int base_t ;
179  for (int l=0 ; l<nzone ; l++) {
180  base_t = (base.b[l] & MSQ_T) >> TRA_T ;
181  assert(t[l] != 0x0) ;
182  _scost[base_t](t[l], base.b[l]) ;
183  }
184 }
185 }
Mtbl_cf * c_cf
Coefficients of the spectral expansion of the function.
Definition: valeur.h:312
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
void coef() const
Computes the coeffcients of *this.
Definition: valeur_coef.C:151
void set_etat_zero()
Sets the logical state to ETATZERO (zero).
Definition: valeur.C:692
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
Valeur * p_scost
Pointer on .
Definition: valeur.h:329
#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
Values and coefficients of a (real-value) function.
Definition: valeur.h:297
#define T_SIN
dev. sin seulement
Definition: type_parite.h:198
const Mg3d * mg
Multi-grid Mgd3 on which this is defined.
Definition: valeur.h:302
#define T_COS_I
dev. cos seulement, harmoniques impaires
Definition: type_parite.h:204
const Valeur & scost() const
Returns of *this.
Definition: valeur_scost.C:102
int etat
Logical state (ETATNONDEF , ETATQCQ or ETATZERO ).
Definition: mtbl_cf.h:206
#define T_COS_P
dev. cos seulement, harmoniques paires
Definition: type_parite.h:200
#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
Base_val base
Bases on which the spectral expansion is performed.
Definition: valeur.h:315
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
Valeur(const Mg3d &mgrid)
Constructor.
Definition: valeur.C:203
#define T_COSSIN_SI
sin impair-cos pair alternes, sin pour m=0
Definition: type_parite.h:214
int nzone
Number of domains (zones)
Definition: mtbl_cf.h:204
#define T_COSSIN_CI
cos impair-sin pair alternes, cos pour m=0
Definition: type_parite.h:212
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
int etat
Logical state (ETATNONDEF , ETATQCQ or ETATZERO ).
Definition: valeur.h:305
Basic array class.
Definition: tbl.h:164
#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
Tbl ** t
Array (size nzone ) of pointers on the Tbl &#39;s which contain the spectral coefficients in each domain...
Definition: mtbl_cf.h:215
#define T_COSSIN_S
dev. cos-sin alternes, sin pour m=0
Definition: type_parite.h:194