Debian Codegraph @

C++/Include/grille_val.h

raw symbols SCIP
1 /*
2 * Definition of Lorene class Grille_val, Gval_cart and Gval_spher
3 *
4 */
5
6 /*
7 * Copyright (c) 2001 Jerome Novak
8 *
9 * This file is part of LORENE.
10 *
11 * LORENE is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * LORENE is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with LORENE; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 */
26
27
28 #ifndef __GRILLE_VAL_H_
29 #define __GRILLE_VAL_H_
30
31 /*
32 * $Id: grille_val.h,v 1.11 2014/10/13 08:52:35 j_novak Exp $
33 * $Log: grille_val.h,v $
34 * Revision 1.11 2014/10/13 08:52:35 j_novak
35 * Lorene classes and functions now belong to the namespace Lorene.
36 *
37 * Revision 1.10 2014/10/06 15:09:39 j_novak
38 * Modified #include directives to use c++ syntax.
39 *
40 * Revision 1.9 2008/02/18 13:53:37 j_novak
41 * Removal of special indentation instructions.
42 *
43 * Revision 1.8 2007/11/02 16:49:12 j_novak
44 * Suppression of intermediate array for spectral summation.
45 *
46 * Revision 1.7 2005/06/22 09:09:38 lm_lin
47 *
48 * Grid wedding: convert from the old C++ object "Cmp" to "Scalar".
49 *
50 * Revision 1.6 2004/05/07 12:32:12 j_novak
51 * New summation from spectral to FD grid. Much faster!
52 *
53 * Revision 1.5 2004/03/22 13:12:41 j_novak
54 * Modification of comments to use doxygen instead of doc++
55 *
56 * Revision 1.4 2002/11/13 11:22:57 j_novak
57 * Version "provisoire" de l'interpolation (sommation depuis la grille
58 * spectrale) aux interfaces de la grille de Valence.
59 *
60 * Revision 1.3 2002/10/16 14:36:29 j_novak
61 * Reorganization of #include instructions of standard C++, in order to
62 * use experimental version 3 of gcc.
63 *
64 * Revision 1.2 2002/06/17 14:05:16 j_novak
65 * friend functions are now also declared outside the class definition
66 *
67 * Revision 1.1 2001/11/22 13:38:09 j_novak
68 * added Include files for Valencia objects: tbl_val.h and grille_val.h
69 *
70 *
71 * $Header: /cvsroot/Lorene/C++/Include/grille_val.h,v 1.11 2014/10/13 08:52:35 j_novak Exp $
72 *
73 */
74
75
76 #include <cassert>
77 #include <cmath>
78 #include "tensor.h"
79
80 namespace Lorene {
81 /**
82 * Base class for Godunov-type grids. \ingroup (mdm)
83 *
84 * Takes into account hidden cells and interfaces between cells,
85 * in 1,2 or 3D.
86 * The derived classes stand for spherical and cartesian grids.
87 * this base class settles quantities for 1D grid, which is minimal
88 * and independent from the geometry (cartesian or spherical).
89 * Therefore, the coordinates \e z and \e r are identified.
90 *
91 * This is an abstract class (cannot be instanciated).
92 *
93 **/
94 class Grille_val {
95 /// Arrays defined on Godunov-type grids.
96 friend class Tbl_val ;
97
98 // Data :
99 // -----
100 protected:
101 /// The dimensions of the grid.
102 Dim_tbl dim ;
103 /// The number of hidden cells (same on each side)
104 int nfantome ;
105 /**
106 * Type of symmetry in \f$\theta\f$:\li \c SYM -> \f$\theta \to -\theta\f$
107 * \li \c NONSYM no symmetry
108 */
109 int type_t ;
110 /**
111 * Type of symmetry in \f$\phi\f$: \li \c SYM -> \f$(x,y) \to (-x,-y)\f$
112 * \li \c NONSYM no symmetry
113 */
114 int type_p ;
115
116 /// Lower boundary for \e z (or \e r ) direction
117 double *zrmin;
118
119 /// Higher boundary for \e z (or \e r ) direction
120 double *zrmax ;
121
122 public:
123 /// Arrays containing the values of coordinate \e z (or \e r) on the nodes
124 Tbl *zr;
125 /// Arrays containing the values of coordinate \e z (or \e r) on the interfaces
126 Tbl *zri ;
127
128 // Constructors - Destructor
129 // -------------------------
130 protected:
131 /// Auxilliary function used to allocate memory and construct 1D grid
132 Tbl* fait_grille1D(const double rmin, const double rmax, const int n) ;
133
134 /// Standard 1D constructor (the size is to be given without hidden cells)
135 Grille_val(const double, const double, const int n1,
136 const int fantome = 2) ;
137
138 /// Standard 2D constructor (the sizes are to be given without hidden cells)
139 Grille_val(const double, const double, const int n2, const int n1,
140 const int itype_t, const int fantome = 2) ;
141
142 /// Standard 3D constructor (the sizes are to be given without hidden cells)
143 Grille_val(const double, const double, const int n3, const int n2, const
144 int n1, const int itype_t, const int itype_p, const int
145 fantome = 2);
146
147
148 /// Copy constructor
149 Grille_val(const Grille_val& ) ;
150
151 /// Constructor from a file (see \c sauve(FILE*) )
152 Grille_val(FILE* ) ;
153
154 /// Destructor
155 virtual ~Grille_val() ;
156
157 // Mutators / assignment
158 // ---------------------
159 public:
160
161 /// Assignment to another Grille_val
162 void operator=(const Grille_val&) ;
163
164 // Accessors
165 // ---------
166 public:
167 /// Returns the number of hidden cells
168 int get_fantome() const {
169 return nfantome ;
170 } ;
171
172 /// Returns the type of symmetry in \f$\theta\f$
173 int get_type_t() const {
174 return type_t ;
175 } ;
176
177 /// Returns the type of symmetry in \f$\phi\f$
178 int get_type_p() const {
179 return type_p ;
180 } ;
181
182 /// Returns the number of dimensions
183 int get_ndim() const {
184 return dim.ndim ;
185 } ;
186
187 /// Returns the size (without hidden cells)
188 int get_dim(const int i) const {
189 assert ( (i>=0) && (i<dim.ndim) ) ;
190 return dim.dim[i] ;
191 } ;
192
193 /// Returns the \c Dim_tbl associated with the grid.
194 const Dim_tbl* get_dim_tbl() const {
195 return &dim ;
196 } ;
197
198 /// Read-only of a particular value of the coordinate \e z (or \e r ) at the nodes
199 double get_zr(const int i) const {
200 assert (i>= -nfantome) ;
201 assert (i<dim.dim[0]+nfantome) ;
202
203 return zr->t[i+nfantome] ;
204 } ;
205
206 /// Read-only of a particular value of the coordinate \e z (or \e r ) at the interfaces
207 double get_zri(const int i) const {
208 assert (i>= -nfantome) ;
209 assert (i<dim.dim[0]+nfantome+1) ;
210
211 return zri->t[i+nfantome] ;
212 } ;
213
214
215 // Outputs
216 // -------
217 public:
218 /// Save in a file
219 virtual void sauve(FILE *) const ;
220
221 /// Display
222 friend ostream& operator<<(ostream& , const Grille_val& ) ;
223
224 protected:
225 /// Operator >> (virtual function called by the operator <<).
226 virtual ostream& operator>>(ostream& ) const ;
227
228 // Interpolation
229 // -------------
230 public:
231 /**
232 * Checks if the spectral grid and mapping are compatible with the
233 * \c Grille_val caracteristics for the interpolation to be done.
234 * It checks wether the spectral grid is included in the Godunov one,
235 * if the numbers of dimensions are the same (1,2 or 3D), and if the
236 * spectral collocation points in \f$\theta\f$ and \f$\phi\f$ are well
237 * defined across all the domains (see the documentation of \c
238 * Tbl_val ).
239 **/
240 virtual bool compatible(const Map* mp, const int lmax, const int lmin=0)
241 const = 0 ;
242
243 /**
244 * Performs 1D interpolation.
245 * @param rdep [input] the coordinates \e r of the source points
246 * @param rarr [input] the coordinates \e r of the destination points
247 * @param fdep [input] values of the function at the source points
248 * @param flag [input] = 1 used for \c INSMTS -- ought to disappear
249 * @param type_inter [input] type of interpolation (see \c Tbl_val )
250 * @return \c Tbl 1D of the same size as rarr, containing the values
251 * of the function at destination points
252 **/
253 Tbl interpol1(const Tbl& rdep, const Tbl& rarr, const Tbl& fdep,
254 int flag, const int type_inter) const ;
255
256 /**
257 * Performs 2D interpolation.
258 * @param fdep [input] values of the function at the source points
259 * @param rarr [input] the coordinates \e r of the destination points
260 * @param tetarr [input] the coordinates \f$\theta\f$ of the destination points
261 * @param type_inter [input] type of interpolation (see \c Tbl_val )
262 * @return Tbl 2D size1:that of rarr, size2: that of tetarr,
263 * containing the values of the function at destination points.
264 **/
265 virtual Tbl interpol2(const Tbl& fdep, const Tbl& rarr,
266 const Tbl& tetarr, const int type_inter) const = 0 ;
267 /**
268 * Performs 3D interpolation.
269 * @param fdep [input] values of the function at the source points
270 * @param rarr [input] the coordinates \e r of the destination points
271 * @param tetarr [input] the coordinates \f$\theta\f$ of the destination points
272 * @param phiarr [input] the coordinates \f$\phi\f$ of the destination points
273 * @param type_inter [input] type of interpolation (see \c Tbl_val )
274 * @return Tbl 3D size1:that of rarr, size2: that of tetarr,
275 * size3: that of phiarr, containing the values of the function at
276 * destination points.
277 **/
278 virtual Tbl interpol3(const Tbl& fdep, const Tbl& rarr,
279 const Tbl& tetarr, const Tbl& phiarr,
280 const int type_inter) const = 0 ;
281
282 /**
283 * Checks if \c Grille_val is contained inside the spectral grid/mapping
284 * within the domains [lmin, lmax[, if the numbers of dimensions are
285 * the same (1,2 or 3D), and if the symmetries are compatible.
286 **/
287 virtual bool contenue_dans(const Map& mp, const int lmax, const int lmin=0)
288 const = 0 ;
289
290 protected:
291 /**
292 * Makes the sommation of the spectral basis functions to know
293 * the values of the function described by the \c Scalar meudon
294 * at the points of the 1D Godunov grid \c this .
295 * The result is an array \c t of size \c taille of all the values of
296 * the function at \c this grid points.
297 */
298 void somme_spectrale1(const Scalar& meudon, double* t, int taille) const ;
299
300 /// Same as before but for the 2D case
301 virtual void somme_spectrale2(const Scalar& meudon, double* t, int taille) const = 0 ;
302
303 /// Same as before but for the 3D case
304 virtual void somme_spectrale3(const Scalar& meudon, double* t, int taille) const = 0 ;
305
306 };
307 ostream& operator<<(ostream& , const Grille_val& ) ;
308
309
310 //------------------------------------//
311 // class Gval_cart //
312 //------------------------------------//
313
314 /**
315 * Class for cartesian Godunov-type grids.\ingroup (mdm)
316 *
317 * Can be used for 1D (only z-coordinate), 2D (x and z) or 3D (y,x and z)
318 * grids. The coordinates of the nodes are stored in \c Tbl 's zr
319 * (derived from \c Grille_val ),x and y.
320 * The coordinates of the interfaces are stored in \c Tbl 's zri
321 * (derived from \c Grille_val ),xi and yi.
322 * The standard constructors only allow for equally-spaced nodes.
323 *
324 **/
325 class Gval_cart : public Grille_val {
326 /// Arrays defined on Godunov-type grids.
327 friend class Tbl_val ;
328
329 // Data :
330 // -----
331 protected:
332 /// Lower boundary for \e x dimension
333 double *xmin ;
334 /// Higher boundary for \e x dimension
335 double *xmax ;
336 /// Lower boundary for \e y dimension
337 double *ymin ;
338 /// Higher boundary for \e y dimension
339 double *ymax ;
340
341 public:
342 /// Arrays containing the values of coordinate \e x on the nodes
343 Tbl *x ;
344 /// Arrays containing the values of coordinate \e x on the interfaces
345 Tbl *xi ;
346 /// Arrays containing the values of coordinate \e y on the nodes
347 Tbl *y ;
348 /// Arrays containing the values of coordinate \e y on the interfaces
349 Tbl *yi ;
350
351 // Constructors - Destructor
352 // -------------------------
353
354 /**
355 * Standard 1D constructor.
356 * @param izmin [input] lower \e z boundary
357 * @param izmax [input] higher \e z boundary
358 * @param n1 [input] the number of cells (without the hidden ones)
359 * @param fantome [input] the number of hidden cells on each side
360 */
361 Gval_cart(const double izmin, const double izmax, const int n1,
362 const int fantome = 2) ;
363
364 /**
365 * Standard 2D constructor.
366 * @param ixmin [input] lower \e x boundary
367 * @param ixmax [input] higher \e x boundary
368 * @param izmin [input] lower \e z boundary
369 * @param izmax [input] higher \e z boundary
370 * @param nx [input] the number of cells in \e x direction
371 * (without the hidden ones)
372 * @param nz [input] the number of cells in \e z direction
373 * (without the hidden ones)
374 * @param type_t [input] the type of symmetry in \f$\theta\f$ (SYM, NONSYM,
375 * see base class documentation)
376 * @param fantome [input] the number of hidden cells on each side
377 */
378 Gval_cart(const double ixmin, const double ixmax, const double izmin,
379 const double izmax, const int nx, const int nz, const int type_t,
380 const int fantome = 2) ;
381
382 /**
383 * Standard 3D constructor.
384 * @param iymin [input] lower \e y boundary
385 * @param iymax [input] higher \e y boundary
386 * @param ixmin [input] lower \e x boundary
387 * @param ixmax [input] higher \e x boundary
388 * @param izmin [input] lower \e z boundary
389 * @param izmax [input] higher \e z boundary
390 * @param ny [input] the number of cells in \e y direction
391 * (without the hidden ones)
392 * @param nx [input] the number of cells in \e x direction
393 * (without the hidden ones)
394 * @param nz [input] the number of cells in \e z direction
395 * (without the hidden ones)
396 * @param type_t [input] the type of symmetry in \f$\theta\f$ (SYM, NONSYM,
397 * see base class documentation)
398 * @param type_p [input] the type of symmetry in \f$\phi\f$ (SYM, NONSYM,
399 * see base class documentation)
400 * @param fantome [input] the number of hidden cells on each side
401 */
402 Gval_cart(const double iymin, const double iymax, const double ixmin,
403 const double ixmax, const double izmin, const double izmax,
404 const int ny, const int nx, const int nz, const int itype_t,
405 const int itype_p, const int fantome = 2);
406
407 /// Copy constructor
408 Gval_cart(const Gval_cart& ) ;
409
410 /// Constructor from a file (see \c sauve(FILE*) )
411 Gval_cart(FILE* ) ;
412
413 /// Destructor
414 virtual ~Gval_cart() ;
415
416 // Mutators / assignment
417 // ---------------------
418 public:
419
420 /// Assignment to another Gval_cart
421 void operator=(const Gval_cart&) ;
422
423 // Accessors
424 // ---------
425 public:
426 /// Read-only of a particular value of the coordinate \e x at the nodes
427 double get_x(const int i) const {
428 assert (i>= -nfantome) ;
429 assert (i<dim.dim[1]+nfantome) ;
430 assert (dim.ndim >= 2) ;
431
432 return (*x)(i+nfantome) ;
433 } ;
434
435 /// Read-only of a particular value of the coordinate \e y at the nodes
436 double get_y(const int i) const {
437 assert (i>= -nfantome) ;
438 assert (i<dim.dim[2]+nfantome) ;
439 assert (dim.ndim == 3) ;
440
441 return (*y)(i+nfantome) ;
442 } ;
443
444 /// Read-only of a particular value of the coordinate \e x at the interfaces
445 double get_xi(const int i) const {
446 assert (i>= -nfantome) ;
447 assert (i<dim.dim[1]+nfantome+1) ;
448 assert (dim.ndim >= 2) ;
449
450 return (*xi)(i+nfantome) ;
451 } ;
452
453 /// Read-only of a particular value of the coordinate \e y at the interfaces
454 double get_yi(const int i) const {
455 assert (i>= -nfantome) ;
456 assert (i<dim.dim[2]+nfantome+1) ;
457 assert (dim.ndim == 3) ;
458
459 return (*yi)(i+nfantome) ;
460 } ;
461
462 /// Returns the lower boundary for x
463 double get_xmin() const {
464 return *xmin ;
465 } ;
466
467 /// Returns the higher boundary for x
468 double get_xmax() const {
469 return *xmax ;
470 } ;
471
472 /// Returns the lower boundary for y
473 double get_ymin() const {
474 return *ymin ;
475 } ;
476
477 /// Returns the higher boundary for x
478 double get_ymax() const {
479 return *ymax ;
480 } ;
481
482 // Outputs
483 // -------
484 public:
485 /// Save in a file
486 virtual void sauve(FILE *) const ;
487
488 protected:
489 /// Operator >> (virtual function called by the operator <<).
490 virtual ostream& operator>>(ostream& ) const ;
491
492 // Interpolation
493 // -------------
494 public:
495 /**
496 * Checks if the spectral grid and mapping are compatible with the
497 * \c Grille_val caracteristics for the interpolation to be done.
498 *
499 * It checks wether the spectral grid is included in the Godunov one,
500 * if the numbers of dimensions are the same (1,2 or 3D), and if the
501 * spectral collocation points in \f$\theta\f$ and \f$\phi\f$ are well
502 * defined across all the domains (see the documentation of \c Tbl_val .
503 **/
504 virtual bool compatible(const Map* mp, const int lmax, const int lmin=0)
505 const ;
506
507 /**
508 * Performs 2D interpolation.
509 * @param fdep [input] values of the function at the source points,
510 * defined as the nodes of the Godunov grid
511 * @param rarr [input] the coordinates \e r of the destination points
512 * @param tetarr [input] the coordinates \f$\theta\f$ of the destination points
513 * @param type_inter [input] type of interpolation (see \c Tbl_val )
514 * @return Tbl 2D size1:that of rarr, size2: that of tetarr,
515 * containing the values of the function at destination points.
516 **/
517 virtual Tbl interpol2(const Tbl& fdep, const Tbl& rarr,
518 const Tbl& tetarr, const int type_inter) const ;
519
520 /**
521 * Same as before, but the coordinates of source points are passed
522 * explicitly (xdep, zdep).
523 */
524 Tbl interpol2c(const Tbl& xdep, const Tbl& zdep, const Tbl& fdep,
525 const Tbl& rarr, const Tbl& tetarr,
526 const int type_inter) const ;
527 /**
528 * Performs 3D interpolation.
529 * @param fdep [input] values of the function at the source points
530 * @param rarr [input] the coordinates \e r of the destination points
531 * @param tetarr [input] the coordinates \f$\theta\f$ of the destination points
532 * @param phiarr [input] the coordinates \f$\phi\f$ of the destination points
533 * @param type_inter [input] type of interpolation (see \c Tbl_val )
534 * @return Tbl 3D size1:that of rarr, size2: that of tetarr,
535 * size3: that of phiarr, containing the values of the function at
536 * destination points.
537 **/
538 virtual Tbl interpol3(const Tbl& fdep, const Tbl& rarr,
539 const Tbl& tetarr, const Tbl& phiarr,
540 const int type_inter) const ;
541 /**
542 * Checks if \c Gval_cart is contained inside the spectral grid/mapping
543 * within the domains [lmin, lmax[, if the numbers of dimensions are
544 * the same (1,2 or 3D), and if the symmetries are compatible.
545 **/
546 virtual bool contenue_dans(const Map& mp, const int lmax, const int lmin=0)
547 const ;
548
549 protected:
550 /**
551 * Makes the sommation of the spectral basis functions to know
552 * the values of the function described by the \c Scalar meudon
553 * at the points of the 2D Godunov grid \c this .
554 * The result is an array \c t of size \c taille of all the values
555 * of the function at \c this grid points.
556 */
557 virtual void somme_spectrale2(const Scalar& meudon, double* t, int taille) const ;
558
559 /// Same as before but for the 3D case
560 virtual void somme_spectrale3(const Scalar& meudon, double* t, int taille) const ;
561 };
562
563 //------------------------------------//
564 // class Gval_spher //
565 //------------------------------------//
566
567 /**
568 * Class for spherical Godunov-type grids.\ingroup (mdm)
569 *
570 * Can be used for 1D (only r-coordinate), 2D (\f$\theta\f$ and \e r )
571 * or 3D (\f$\phi\f$, \f$\theta\f$ and \e r )
572 * grids. The coordinates of the nodes are stored in \c Tbl 's zr
573 * (derived from \c Grille_val ),tet and phi.
574 * The coordinates of the interfaces are stored in \c Tbl 's zri
575 * (derived from \c Grille_val ),teti and phii.
576 * The standard constructors only allow for equally-spaced nodes.
577 *
578 **/
579 class Gval_spher : public Grille_val {
580 /// Arrays defined on Godunov-type grids.
581 friend class Tbl_val ;
582
583 // Data :
584 // -----
585 public:
586 /// Arrays containing the values of coordinate \f$\theta\f$ on the nodes
587 Tbl *tet ;
588 /// Arrays containing the values of coordinate \f$\theta\f$ on the interfaces
589 Tbl *teti ;
590 /// Arrays containing the values of coordinate \f$\phi\f$ on the nodes
591 Tbl *phi ;
592 /// Arrays containing the values of coordinate \f$\phi\f$ on the interfaces
593 Tbl *phii ;
594
595 // Constructors - Destructor
596 // -------------------------
597
598 /**
599 * Standard 1D constructor.
600 * @param irmin [input] lower \e r boundary
601 * @param irmax [input] higher \e r boundary
602 * @param nr [input] the number of cells (without the hidden ones)
603 * @param fantome [input] the number of hidden cells on each side
604 */
605 Gval_spher(const double irmin, const double irmax, const int nr,
606 const int fantome = 2) ;
607
608 /**
609 * Standard 2D constructor.
610 * @param irmin [input] lower \e r boundary
611 * @param irmax [input] higher \e r boundary
612 * @param nt [input] the number of cells in \f$\theta\f$ (without hidden ones)
613 * @param nr [input] the number of cells in r(without the hidden ones)
614 * @param type_t [input] the type of symmetry in \f$\theta\f$ (SYM, NONSYM,
615 * see base class documentation)
616 * @param fantome [input] the number of hidden cells on each side
617 */
618 Gval_spher(const double irmin, const double irmax, const int nt, const
619 int nr, const int type_t, const int fantome = 2) ;
620
621 /**
622 * Standard 3D constructor.
623 * @param irmin [input] lower \e r boundary
624 * @param irmax [input] higher \e r boundary
625 * @param np [input] the number of cells in \f$\phi\f$ (without the hidden ones)
626 * @param nt [input] the number of cells in \f$\theta\f$ (without hidden ones)
627 * @param nr [input] the number of cells in r(without the hidden ones)
628 * @param type_t [input] the type of symmetry in \f$\theta\f$ (SYM, NONSYM,
629 * see base class documentation)
630 * @param type_p [input] the type of symmetry in \f$\phi\f$ (SYM, NONSYM,
631 * see base class documentation)
632 * @param fantome [input] the number of hidden cells on each side
633 */
634 Gval_spher(const double irmin, const double irmax, const int np, const
635 int nt, const int nr, const int itype_t, const int itype_p,
636 const int fantome = 2);
637
638 /// Copy constructor
639 Gval_spher(const Gval_spher& ) ;
640
641 /// Constructor from a file (see \c sauve(FILE*) )
642 Gval_spher(FILE* ) ;
643
644 /// Destructor
645 virtual ~Gval_spher() ;
646
647 // Mutators / assignment
648 // ---------------------
649 public:
650
651 /// Assignment to another Gval_spher
652 void operator=(const Gval_spher&) ;
653
654 // Accessors
655 // ---------
656 public:
657
658 /// Read-only of a particular value of the coordinate \f$\theta\f$ at the nodes
659 double get_tet(const int i) const {
660 assert (i>= -nfantome) ;
661 assert (dim.ndim >= 2) ;
662 assert (i<dim.dim[1]+nfantome) ;
663
664 return tet->t[i+nfantome] ;
665 } ;
666
667 /// Read-only of a particular value of the coordinate \f$\phi\f$ at the nodes
668 double get_phi(const int i) const {
669 assert (i>= -nfantome) ;
670 assert (dim.ndim == 3) ;
671 assert (i<dim.dim[2]+nfantome) ;
672
673 return phi->t[i+nfantome] ;
674 } ;
675
676 /// Read-only of a particular value of coordinate \f$\theta\f$ at the interfaces
677 double get_teti(const int i) const {
678 assert (i>= -nfantome) ;
679 assert (dim.ndim >= 2) ;
680 assert (i<dim.dim[1]+nfantome+1) ;
681
682 return teti->t[i+nfantome] ;
683 } ;
684
685 /// Read-only of a particular value of coordinate \f$\phi\f$ at the interfaces
686 double get_phii(const int i) const {
687 assert (i>= -nfantome) ;
688 assert (dim.ndim == 3) ;
689 assert (i<dim.dim[2]+nfantome+1) ;
690
691 return phii->t[i+nfantome] ;
692 } ;
693
694 // Outputs
695 // -------
696 public:
697 /// Save in a file
698 virtual void sauve(FILE *) const ;
699
700 protected:
701 /// Operator >> (virtual function called by the operator <<).
702 virtual ostream& operator>>(ostream& ) const ;
703
704 // Interpolation
705 // -------------
706 public:
707 /**
708 * Checks if the spectral grid and mapping are compatible with the
709 * \c Grille_val caracteristics for the interpolation to be done.
710 *
711 * It checks wether the spectral grid is included in the Godunov one,
712 * if the numbers of dimensions are the same (1,2 or 3D), and if the
713 * spectral collocation points in \f$\theta\f$ and \f$\phi\f$ are well
714 * defined across all the domains (see the documentation of \c Tbl_val .
715 **/
716 virtual bool compatible(const Map* mp, const int lmax, const int lmin=0)
717 const ;
718
719 /**
720 * Performs 2D interpolation.
721 * @param fdep [input] values of the function at the source points,
722 * defined as the nodes of the Godunov grid
723 * @param rarr [input] the coordinates \e r of the destination points
724 * @param tetarr [input] the coordinates \f$\theta\f$ of the destination points
725 * @param type_inter [input] type of interpolation (see \c Tbl_val )
726 * @return Tbl 2D size1:that of rarr, size2: that of tetarr,
727 * containing the values of the function at destination points.
728 **/
729 virtual Tbl interpol2(const Tbl& fdep, const Tbl& rarr, const Tbl& tetarr,
730 const int type_inter) const ;
731 /**
732 * Performs 3D interpolation.
733 * @param fdep [input] values of the function at the source points
734 * defined as the nodes of the Godunov grid \c this
735 * @param rarr [input] the coordinates \e r of the destination points
736 * @param tetarr [input] the coordinates \f$\theta\f$ of the destination points
737 * @param phiarr [input] the coordinates \f$\phi\f$ of the destination points
738 * @param type_inter [input] type of interpolation (see \c Tbl_val )
739 * @return Tbl 3D size1:that of rarr, size2: that of tetarr,
740 * size3: that of phiarr, containing the values of the function at
741 * destination points.
742 **/
743 virtual Tbl interpol3(const Tbl& fdep, const Tbl& rarr, const Tbl& tetarr,
744 const Tbl& phiarr, const int type_inter) const ;
745
746 /**
747 * Checks if \c Gval_spher is contained inside the spectral grid/mapping
748 * within the domains [lmin, lmax[, if the numbers of dimensions are
749 * the same (1,2 or 3D), and if the symmetries are compatible.
750 **/
751 virtual bool contenue_dans(const Map& mp, const int lmax, const int lmin=0)
752 const ;
753
754 protected:
755 /**
756 * Makes the sommation of the spectral basis functions to know
757 * the values of the function described by the \c Scalar meudon
758 * at the points of the 2D Godunov grid \c this .
759 * The result is an array \c t of size \c taille of all the values
760 * of the function at \c this grid points.
761 */
762 virtual void somme_spectrale2(const Scalar& meudon, double* t, int taille) const ;
763
764 /// Same as before but at radial grid interfaces
765 double* somme_spectrale2ri(const Scalar& meudon) const ;
766
767 /// Same as before but at angular grid interfaces
768 double* somme_spectrale2ti(const Scalar& meudon) const ;
769
770 /// Same as before but for the 3D case
771 virtual void somme_spectrale3(const Scalar& meudon, double* t, int taille) const ;
772
773 void initialize_spectral_r(const Map& mp, const Base_val& base, int*& idom,
774 double*& chebnri) const ;
775 void initialize_spectral_theta(const Map& mp, const Base_val& base,
776 double*& tetlj) const ;
777 void initialize_spectral_phi(const Map& mp, const Base_val& base,
778 double*& expmk) const ;
779
780 };
781
782 }
783 #endif
784
785