LORENE
op_mult_xp1.C
1 /*
2  * Copyright (c) 1999-2001 Jerome Novak
3  *
4  * This file is part of LORENE.
5  *
6  * LORENE is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * LORENE is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with LORENE; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  */
21 
22 
23 
24 
25 /*
26  * $Id: op_mult_xp1.C,v 1.5 2021/11/24 13:12:17 g_servignat Exp $
27  * $Log: op_mult_xp1.C,v $
28  * Revision 1.5 2021/11/24 13:12:17 g_servignat
29  * Addition of new method mult_xm1_shell(int) to multiply by (\xi +1) in a given shell.
30  *
31  * Revision 1.4 2016/12/05 16:18:08 j_novak
32  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
33  *
34  * Revision 1.3 2014/10/13 08:53:26 j_novak
35  * Lorene classes and functions now belong to the namespace Lorene.
36  *
37  * Revision 1.2 2008/08/19 06:42:00 j_novak
38  * Minor modifications to avoid warnings with gcc 4.3. Most of them concern
39  * cast-type operations, and constant strings that must be defined as const char*
40  *
41  * Revision 1.1 2007/12/11 15:42:23 jl_cornou
42  * Premiere version des fonctions liees aux polynomes de Jacobi(0,2)
43  *
44  * Revision 1.2 2004/11/23 15:16:01 m_forot
45  *
46  * Added the bases for the cases without any equatorial symmetry
47  * (T_COSSIN_C, T_COSSIN_S, T_LEG, R_CHEBPI_P, R_CHEBPI_I).
48  *
49  * Revision 1.1.1.1 2001/11/20 15:19:29 e_gourgoulhon
50  * LORENE
51  *
52  * Revision 1.3 2000/09/07 12:49:53 phil
53  * *** empty log message ***
54  *
55  * Revision 1.2 2000/02/24 16:42:18 eric
56  * Initialisation a zero du tableau xo avant le calcul.
57  *
58  * Revision 1.1 1999/11/16 13:37:41 novak
59  * Initial revision
60  *
61  *
62  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/Operators/op_mult_xp1.C,v 1.5 2021/11/24 13:12:17 g_servignat Exp $
63  *
64  */
65 
66 /*
67  * Ensemble des routines de base de multiplication par x+1
68  * (Utilisation interne)
69  *
70  * void _mult_x_XXXX(Tbl * t, int & b)
71  * t pointeur sur le Tbl d'entree-sortie
72  * b base spectrale
73  *
74  */
75 
76  // Fichier includes
77 #include "tbl.h"
78 #include "type_parite.h"
79 
80 // Prototypage
81 #include "proto.h"
82 
83 
84  //-----------------------------------
85  // Routine pour les cas non prevus --
86  //-----------------------------------
87 
88 namespace Lorene {
89 void _mult_xp1_pas_prevu(Tbl * tb, int& base) {
90  cout << "mult_xp1 pas prevu..." << endl ;
91  cout << "Tbl: " << tb << " base: " << base << endl ;
92  abort () ;
93  exit(-1) ;
94 }
95 
96  //-------------
97  // Identite ---
98  //-------------
99 
100 void _mult_xp1_identite(Tbl* , int& ) {
101  return ;
102 }
103 
104  //---------------
105  //-- cas CHEB ---
106  //---------------
107 
108 void _mult_xp1_cheb(Tbl *tb, int& )
109 {
110 
111  // Peut-etre rien a faire ?
112  if (tb->get_etat() == ETATZERO) {
113  return ;
114  }
115 
116  // Pour le confort
117  int nr = (tb->dim).dim[0] ; // Nombre
118  int nt = (tb->dim).dim[1] ; // de points
119  int np = (tb->dim).dim[2] ; // physiques REELS
120  np = np - 2 ; // Nombre de points physiques
121 
122  int ntnr = nt*nr ;
123 
124  double* trav = new double[nr] ;
125 
126  int k, j, i ;
127  for (k=0 ; k<np+1 ; k++) {
128  if (k==1) continue ; // On ne traite pas le coefficient de sin(0*phi)
129  for (j=0 ; j<nt ; j++) {
130 
131  double* cf = tb->t + k*ntnr + j*nr ;
132 
133  mult_xp1_1d_cheb(nr, cf, trav) ; // multiplication par (x+1)
134 
135  for (i=0; i<nr; i++) {
136  cf[i] = trav[i] ;
137  }
138 
139  } // Fin de la boucle sur theta
140  } // Fin de la boucle sur phi
141 
142  delete [] trav ;
143 
144  // base de developpement
145  // inchangee
146 }
147 
148  //---------------
149  // cas R_JACO02 -
150  //---------------
151 
152 void _mult_xp1_r_jaco02(Tbl* tb, int& )
153  {
154  // Peut-etre rien a faire ?
155  if (tb->get_etat() == ETATZERO) {
156  return ;
157  }
158 
159  // Pour le confort
160  int nr = (tb->dim).dim[0] ; // Nombre
161  int nt = (tb->dim).dim[1] ; // de points
162  int np = (tb->dim).dim[2] ; // physiques REELS
163  np = np - 2 ; // Nombre de points physiques
164 
165  // pt. sur le tableau de double resultat
166  double* xo = new double [tb->get_taille()];
167 
168  // Initialisation a zero :
169  for (int i=0; i<tb->get_taille(); i++) {
170  xo[i] = 0 ;
171  }
172 
173  // On y va...
174  double* xi = tb->t ;
175  double* xci = xi ; // Pointeurs
176  double* xco = xo ; // courants
177 
178  int borne_phi = np + 1 ;
179  if (np == 1) {
180  borne_phi = 1 ;
181  }
182 
183  for (int k=0 ; k< borne_phi ; k++)
184  if (k==1) {
185  xci += nr*nt ;
186  xco += nr*nt ;
187  }
188  else {
189  for (int j=0 ; j<nt ; j++) {
190 
191  xco[0] = 1.5*xci[0] + 0.3*xci[1] ;
192  for (int i = 1 ; i < nr-1 ; i++) {
193  xco[i] = i*(i+2)/double((i+1)*(2*i+1))*xci[i-1] + (i*i+3*i+3)/double((i+1)*(i+2))*xci[i] + (i+1)*(i+3)/double((i+2)*(2*i+5))*xci[i+1] ;
194  }
195  xco[nr-1] = (nr*nr-1)/double((nr)*(2*nr-1))*xci[nr-2] + (1+1/double((nr)*(nr+1)))*xci[nr-1] ;
196 
197  xci += nr ;
198  xco += nr ;
199  } // Fin de la boucle sur theta
200  } // Fin de la boucle sur phi
201 
202  // On remet les choses la ou il faut
203  delete [] tb->t ;
204  tb->t = xo ;
205 
206  // base de developpement
207  // inchangee
208 
209 }
210 }
Lorene prototypes.
Definition: app_hor.h:67