LORENE
grille3d.C
1 /*
2  * Methods of class Grille3d and derived classes
3  *
4  */
5 
6 /*
7  * Copyright (c) 1999-2000 Jean-Alain Marck
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: grille3d.C,v 1.11 2016/12/05 16:17:55 j_novak Exp $
33  * $Log: grille3d.C,v $
34  * Revision 1.11 2016/12/05 16:17:55 j_novak
35  * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
36  *
37  * Revision 1.10 2014/10/13 08:52:59 j_novak
38  * Lorene classes and functions now belong to the namespace Lorene.
39  *
40  * Revision 1.9 2013/06/07 14:44:33 j_novak
41  * Coefficient computation for even Legendre basis.
42  *
43  * Revision 1.8 2013/06/06 15:31:32 j_novak
44  * Functions to compute Legendre coefficients (not fully tested yet).
45  *
46  * Revision 1.7 2013/06/05 15:00:26 j_novak
47  * Suppression of all classes derived from Grille3d. Now Grille3d is no
48  * longer an abstract class. r-samplings are only one of RARE, FIN or
49  * UNSURR (FINJAC has been removed). Instead, Mg3d possesses a new member
50  * colloc_r[nzone] defining the type of collocation points (spectral
51  * bases) in each domain.
52  *
53  * Revision 1.6 2008/08/27 08:47:38 jl_cornou
54  * Added R_JACO02 case
55  *
56  * Revision 1.5 2008/01/09 14:04:03 j_novak
57  * Initialization of xx
58  *
59  * Revision 1.4 2008/01/08 13:53:29 j_novak
60  * Special treatment of the case nt=1.
61  *
62  * Revision 1.3 2007/12/11 15:28:13 jl_cornou
63  * Jacobi(0,2) polynomials partially implemented
64  *
65  * Revision 1.2 2002/10/16 14:36:36 j_novak
66  * Reorganization of #include instructions of standard C++, in order to
67  * use experimental version 3 of gcc.
68  *
69  * Revision 1.1.1.1 2001/11/20 15:19:28 e_gourgoulhon
70  * LORENE
71  *
72  * Revision 2.10 2001/05/26 14:50:46 eric
73  * *** empty log message ***
74  *
75  * Revision 2.9 2001/05/26 13:25:59 eric
76  * Ajout du membre g_twice (grille double pour le desaliasing)
77  * Modif de la declaration de g_angu (pointeur mutable)
78  * g_twice et g_angu ne sont calcules que si necessaire (cad si
79  * on appelle la fonction get_twice() ou get_angu()).
80  *
81  * Revision 2.8 2000/03/22 13:38:51 eric
82  * Remplacement des iendl par endl dans <<
83  *
84  * Revision 2.7 1999/10/12 15:04:29 eric
85  * *** empty log message ***
86  *
87  * Revision 2.6 1999/10/12 15:03:30 eric
88  * *** empty log message ***
89  *
90  * Revision 2.5 1999/09/30 14:58:16 eric
91  * Operator!= declare const
92  *
93  * Revision 2.4 1999/09/30 14:12:04 eric
94  * sauve declaree const.
95  *
96  * Revision 2.3 1999/09/30 12:52:52 eric
97  * Depoussierage.
98  * Documentation.
99  *
100  * Revision 2.2 1999/03/01 14:35:21 eric
101  * Modif affichage (operator<<)
102  *
103  *
104  * $Header: /cvsroot/Lorene/C++/Source/Grille3d/grille3d.C,v 1.11 2016/12/05 16:17:55 j_novak Exp $
105  *
106  */
107 
108 
109 // Fichiers include
110 // ----------------
111 #include <cmath>
112 
113 #include "tbl.h"
114 #include "grilles.h"
115 #include "proto.h"
116 
117 
118  //-------------//
119  // Mono-grille //
120  //-------------//
121 
122 // Constructeur
123 //-------------
124 namespace Lorene {
125 Grille3d::Grille3d(int nrs, int nts, int nps, int typer, int typet,
126  int typep, int baser)
127  : nr(nrs), nt(nts), np(nps), type_r(typer), type_t(typet),
128  type_p(typep), base_r(baser)
129 {
130 
131  //Radial part
132  assert(nr > 0) ;
133  x = new double[nr] ;
134  x[0] = 0. ;
135  if (nr > 1) compute_radial_grid() ;
136 
137  //Theta part
138  assert(nt > 0) ;
139  tet = new double[nt] ;
140  double fac_tet = M_PI ;
141  if (type_t == SYM) fac_tet *= 0.5 ;
142  if (nt == 1)
143  fac_tet = 0 ;
144  else
145  fac_tet /= double(nt-1) ;
146  for (int i=0; i<nt; i++)
147  tet[i] = double(i)*fac_tet ;
148  if ( (type_t != SYM) && (type_t != NONSYM) ) {
149  cout << "Grille3d: unknown type in theta!" << endl ;
150  abort() ;
151  }
152 
153  //Phi part
154  assert(np > 0) ;
155  phi = new double[np] ;
156  double fac_phi = M_PI / double(np) ;
157  if (type_p == NONSYM) fac_phi *= 2. ;
158  for (int i=0; i<np; i++)
159  phi[i] = double(i)*fac_phi ;
160  if ( (type_p != SYM) && (type_p != NONSYM) ) {
161  cout << "Grille3d: unknown type in phi!" << endl ;
162  abort() ;
163  }
164 
165 }
166 
167 // Destructeur
168 //------------
170  delete [] x ;
171  delete [] tet ;
172  delete [] phi ;
173 }
174 
176 
177  assert(nr > 1) ;
178  double xx = 0 ;
179 
180  switch (base_r) {
181  case BASE_CHEB :
182  switch (type_r) {
183  case RARE:
184  xx = M_PI/double(2*(nr-1)) ;
185  for (int i=0; i<nr; i++)
186  x[i] = sin(xx*double(i)) ;
187  break ;
188  case FIN: case UNSURR :
189  xx = M_PI/double(nr-1) ;
190  for (int i=0 ; i<nr ; i++)
191  x[i] = -cos(xx*double(i)) ;
192  break ;
193  default:
194  cout << "Grille3d::compute_radial_grid : " << endl ;
195  cout << "Unknown type of sampling for the Chebyshev basis!" << endl ;
196  abort() ;
197  }
198  break ;
199  case BASE_LEG :
200  switch (type_r) {
201  case FIN:
202  legendre_collocation_points(nr, x) ;
203  break ;
204  case RARE: {
205  Tbl full_x(2*nr-1) ;
206  full_x.set_etat_qcq() ;
207  legendre_collocation_points(2*nr - 1, full_x.t) ;
208  for (int i=0; i<nr; i++)
209  x[i] = full_x(i+nr-1) ;
210  break ;
211  }
212  default:
213  cout << "Grille3d::compute_radial_grid : " << endl ;
214  cout << "Unknown type of sampling for the Legendre basis!" << endl ;
215  abort() ;
216  }
217  break ;
218  case BASE_JAC02 : {
219  double* yy = pointsgausslobatto(nr-1);
220  for (int i=0 ; i<nr ; i++) {
221  x[i] = yy[i] ;
222  }
223  delete [] yy ;
224  break ;
225  }
226  default :
227  cout << "Grille3d::compute_radial_grid : " << endl ;
228  cout << "Unknown type of basis!" << endl ;
229  abort() ;
230  break ;
231  }
232 }
233 
234 
235 }
int type_t
Type of sampling in (SYM,NONSYM)
Definition: grilles.h:208
const int nr
Number of points in r ( )
Definition: grilles.h:202
Lorene prototypes.
Definition: app_hor.h:67
virtual ~Grille3d()
Destructor.
Definition: grille3d.C:169
double * phi
Array of values of at the np collocation points.
Definition: grilles.h:219
double * x
Array of values of at the nr collocation points.
Definition: grilles.h:215
Cmp cos(const Cmp &)
Cosine.
Definition: cmp_math.C:97
void compute_radial_grid()
Computes the collocation point coordinates in the radial direction.
Definition: grille3d.C:175
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Definition: tbl.C:364
int type_p
Type of sampling in (SYM,NONSYM)
Definition: grilles.h:209
double * t
The array of double.
Definition: tbl.h:176
double * tet
Array of values of at the nt collocation points.
Definition: grilles.h:217
const int np
Number of points in .
Definition: grilles.h:204
int base_r
Type of radial spectral basis (BASE_CHEB, BASE_LEG, BASE_JAC02 )
Definition: grilles.h:211
int type_r
Type of sampling in r ( ) (RARE,FIN,UNSURR )
Definition: grilles.h:207
Cmp sin(const Cmp &)
Sine.
Definition: cmp_math.C:72
Basic array class.
Definition: tbl.h:164
Grille3d(int n_r, int n_t, int n_p, int typer, int typet, int typep, int baser)
Constructor.
Definition: grille3d.C:125
const int nt
Number of points in .
Definition: grilles.h:203