LORENE
valeur_mult_sp.C
1 /*
2  * Methods for multiplication by sin(phi) for classes
3  * - Valeur
4  * - Mtbl_cf
5  */
6 
7 /*
8  * Copyright (c) 1999-2001 Eric Gourgoulhon
9  *
10  * This file is part of LORENE.
11  *
12  * LORENE is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
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 /*
32  * $Id: valeur_mult_sp.C,v 1.5 2016/12/05 16:18:21 j_novak Exp $
33  * $Log: valeur_mult_sp.C,v $
34  * Revision 1.5 2016/12/05 16:18:21 j_novak
35  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
36  *
37  * Revision 1.4 2014/10/13 08:53:50 j_novak
38  * Lorene classes and functions now belong to the namespace Lorene.
39  *
40  * Revision 1.3 2014/10/06 15:13:23 j_novak
41  * Modified #include directives to use c++ syntax.
42  *
43  * Revision 1.2 2012/01/17 15:08:32 j_penner
44  * using MAX_BASE_2 for the phi coordinate
45  *
46  * Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon
47  * LORENE
48  *
49  * Revision 2.2 2000/09/18 10:15:20 eric
50  * Ajout des bases P_COSSIN_P et P_COSSIN_I
51  *
52  * Revision 2.1 2000/09/11 15:04:04 eric
53  * *** empty log message ***
54  *
55  * Revision 2.0 2000/09/11 13:54:00 eric
56  * *** empty log message ***
57  *
58  *
59  * $Header: /cvsroot/Lorene/C++/Source/Valeur/valeur_mult_sp.C,v 1.5 2016/12/05 16:18:21 j_novak Exp $
60  *
61  */
62 
63 // Headers C
64 #include <cassert>
65 
66 // Headers Lorene
67 #include "mtbl_cf.h"
68 #include "valeur.h"
69 
70 // Local prototypes
71 namespace Lorene {
72 void _mult_sp_pas_prevu(Tbl*, int&) ;
73 void _mult_sp_p_cossin(Tbl*, int&) ;
74 void _mult_sp_p_cossin_p(Tbl*, int&) ;
75 void _mult_sp_p_cossin_i(Tbl*, int&) ;
76 
77 // Version membre d'un Valeur
78 // --------------------------
79 
80 const Valeur& Valeur::mult_sp() const {
81 
82  // Protection
83  assert(etat != ETATNONDEF) ;
84 
85  // Peut-etre rien a faire ?
86  if (p_mult_sp != 0x0) {
87  return *p_mult_sp ;
88  }
89 
90  // ... si, il faut bosser
91 
92  p_mult_sp = new Valeur(mg) ;
93 
94  if (etat == ETATZERO) {
96  }
97  else {
98  assert(etat == ETATQCQ) ;
100  Mtbl_cf* cfp = p_mult_sp->c_cf ; // Pointeur sur le Mtbl_cf qui vient d'etre
101  // cree par le set_etat_cf_qcq()
102 
103  // Initialisation de *cfp : recopie des coef. de la fonction
104  if (c_cf == 0x0) {
105  coef() ;
106  }
107  *cfp = *c_cf ;
108 
109  cfp->mult_sp() ; // calcul
110 
111  p_mult_sp->base = cfp->base ; // On remonte la base de sortie au niveau Valeur
112  }
113 
114  // Termine
115  return *p_mult_sp ;
116 }
117 
118 
119 
120 // Version membre d'un Mtbl_cf
121 // ---------------------------
122 
124 
125 // Routines de derivation
126 static void (*_mult_sp[MAX_BASE_2])(Tbl *, int &) ;
127 static int nap = 0 ;
128 
129  // Premier appel
130  if (nap==0) {
131  nap = 1 ;
132  for (int i=0 ; i<MAX_BASE_2 ; i++) {
133  _mult_sp[i] = _mult_sp_pas_prevu ;
134  }
135  // Les routines existantes
136  _mult_sp[P_COSSIN >> TRA_P] = _mult_sp_p_cossin ;
137  _mult_sp[P_COSSIN_P >> TRA_P] = _mult_sp_p_cossin_p ;
138  _mult_sp[P_COSSIN_I >> TRA_P] = _mult_sp_p_cossin_i ;
139  }
140 
141  // Debut de la routine
142 
143  // Protection
144  assert(etat == ETATQCQ) ;
145 
146  // Boucle sur les zones
147  for (int l=0 ; l<nzone ; l++) {
148  int base_p = (base.b[l] & MSQ_P) >> TRA_P ;
149  assert(t[l] != 0x0) ;
150  _mult_sp[base_p](t[l], base.b[l]) ;
151  }
152 }
153 }
#define MAX_BASE_2
Smaller maximum bases used for phi (and higher dimensions for now)
Definition: type_parite.h:146
Mtbl_cf * c_cf
Coefficients of the spectral expansion of the function.
Definition: valeur.h:312
#define P_COSSIN
dev. standart
Definition: type_parite.h:245
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
#define TRA_P
Translation en Phi, used for a bitwise shift (in hex)
Definition: type_parite.h:162
const Valeur & mult_sp() const
Returns applied to *this.
void set_etat_zero()
Sets the logical state to ETATZERO (zero).
Definition: valeur.C:692
Lorene prototypes.
Definition: app_hor.h:67
#define MSQ_P
Extraction de l&#39;info sur Phi.
Definition: type_parite.h:156
Values and coefficients of a (real-value) function.
Definition: valeur.h:297
const Mg3d * mg
Multi-grid Mgd3 on which this is defined.
Definition: valeur.h:302
int etat
Logical state (ETATNONDEF , ETATQCQ or ETATZERO ).
Definition: mtbl_cf.h:206
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
Valeur(const Mg3d &mgrid)
Constructor.
Definition: valeur.C:203
int nzone
Number of domains (zones)
Definition: mtbl_cf.h:204
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
#define P_COSSIN_I
dev. sur Phi = 2*phi, freq. impaires
Definition: type_parite.h:249
Basic array class.
Definition: tbl.h:164
#define P_COSSIN_P
dev. sur Phi = 2*phi, freq. paires
Definition: type_parite.h:247
Valeur * p_mult_sp
Pointer on .
Definition: valeur.h:337
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