LORENE
op_d2sdphi2.C
1 /*
2  * Copyright (c) 1999-2000 Jean-Alain Marck
3  * Copyright (c) 1999-2001 Eric Gourgoulhon
4  *
5  * This file is part of LORENE.
6  *
7  * LORENE is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * LORENE is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with LORENE; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  *
21  */
22 
23 
24 char op_d2sdphi2_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Operators/op_d2sdphi2.C,v 1.3 2014/10/13 08:53:24 j_novak Exp $" ;
25 
26 /*
27  * Ensemble des routines de base de derivation seconde par rapport a Phi
28  * (Utilisation interne)
29  *
30  * void _d2sdphi2_XXXX(Tbl * t, int & b)
31  * t pointeur sur le Tbl d'entree-sortie
32  * b base spectrale
33  *
34  */
35 
36 /*
37  * $Id: op_d2sdphi2.C,v 1.3 2014/10/13 08:53:24 j_novak Exp $
38  * $Log: op_d2sdphi2.C,v $
39  * Revision 1.3 2014/10/13 08:53:24 j_novak
40  * Lorene classes and functions now belong to the namespace Lorene.
41  *
42  * Revision 1.2 2006/03/10 12:45:38 j_novak
43  * Use of C++-style cast.
44  *
45  * Revision 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon
46  * LORENE
47  *
48  * Revision 2.4 2000/10/04 10:14:52 eric
49  * Ajout d' abort() dans le cas non prevu.
50  * ./
51  *
52  * Revision 2.3 2000/02/24 16:40:19 eric
53  * Initialisation a zero du tableau xo avant le calcul.
54  *
55  * Revision 2.2 1999/11/15 16:37:33 eric
56  * Tbl::dim est desormais un Dim_tbl et non plus un Dim_tbl*.
57  *
58  * Revision 2.1 1999/03/01 15:05:37 eric
59  * *** empty log message ***
60  *
61  * Revision 2.0 1999/02/23 11:40:34 hyc
62  * *** empty log message ***
63  *
64  *
65  *
66  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Operators/op_d2sdphi2.C,v 1.3 2014/10/13 08:53:24 j_novak Exp $
67  *
68  */
69 
70 // Headers Lorene
71 #include "tbl.h"
72 
73 // Routine pour les cas non prevus
74 //--------------------------------
75 namespace Lorene {
76 void _d2sdphi2_pas_prevu(Tbl* , int & b) {
77  cout << "Unknown phi basis in Mtbl_cf::d2sdp2() !" << endl ;
78  cout << " basis: " << hex << b << endl ;
79  abort() ;
80 }
81 
82 // cas P_COSSIN
83 //-------------
84 void _d2sdphi2_p_cossin(Tbl* tb, int & )
85 {
86 
87  // Peut-etre rien a faire ?
88  if (tb->get_etat() == ETATZERO) {
89  return ;
90  }
91 
92  // Protection
93  assert(tb->get_etat() == ETATQCQ) ;
94 
95  // Pour le confort
96  int nr = (tb->dim).dim[0] ; // Nombre
97  int nt = (tb->dim).dim[1] ; // de points
98  int np = (tb->dim).dim[2] ; // physiques REELS
99  np = np - 2 ; // Nombre de points physiques
100 
101  // Variables statiques
102  static double* cx = 0 ;
103  static int np_pre =0 ;
104 
105  // Test sur np pour initialisation eventuelle
106  if (np > np_pre) {
107  np_pre = np ;
108  cx = reinterpret_cast<double*>(realloc(cx, (np+2) * sizeof(double))) ;
109  for (int i=0 ; i<np+2 ; i++) {
110  cx[i] = - (i/2) * (i/2) ;
111  }
112  }
113 
114  // pt. sur le tableau de double resultat
115  double* xo = new double[(tb->dim).taille] ;
116 
117  // Initialisation a zero :
118  for (int i=0; i<(tb->dim).taille; i++) {
119  xo[i] = 0 ;
120  }
121 
122  // On y va...
123  double* xi = tb->t ;
124  double* xci = xi ; // Pointeurs
125  double* xco = xo ; // courants
126 
127  // k = 0
128  for (int j=0 ; j<nt ; j++) {
129  for (int i=0 ; i<nr ; i++ ) {
130  *xco = cx[0] * (*xci) ;
131  xci++ ;
132  xco++ ;
133  } // Fin de la boucle sur r
134  } // Fin de la boucle sur theta
135 
136  // k = 1
137  xci += nr*nt ;
138  xco += nr*nt ;
139 
140  // k >= 2
141  for (int k=2 ; k<np+1 ; k++) {
142  for (int j=0 ; j<nt ; j++) {
143  for (int i=0 ; i<nr ; i++ ) {
144  *xco = cx[k] * (*xci) ;
145  xci++ ;
146  xco++ ;
147  } // Fin de la boucle sur r
148  } // Fin de la boucle sur theta
149  } // Fin de la boucle sur phi
150 
151  // On remet les choses la ou il faut
152  delete [] tb->t ;
153  tb->t = xo ;
154 
155  // base de developpement
156  // inchangee
157 }
158 
159 }
Lorene prototypes.
Definition: app_hor.h:64