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