LORENE
grille_val.h
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 {
94 class Grille_val {
96  friend class Tbl_val ;
97 
98  // Data :
99  // -----
100  protected:
104  int nfantome ;
109  int type_t ;
114  int type_p ;
115 
117  double *zrmin;
118 
120  double *zrmax ;
121 
122  public:
124  Tbl *zr;
126  Tbl *zri ;
127 
128  // Constructors - Destructor
129  // -------------------------
130  protected:
132  Tbl* fait_grille1D(const double rmin, const double rmax, const int n) ;
133 
135  Grille_val(const double, const double, const int n1,
136  const int fantome = 2) ;
137 
139  Grille_val(const double, const double, const int n2, const int n1,
140  const int itype_t, const int fantome = 2) ;
141 
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 
149  Grille_val(const Grille_val& ) ;
150 
152  Grille_val(FILE* ) ;
153 
155  virtual ~Grille_val() ;
156 
157  // Mutators / assignment
158  // ---------------------
159  public:
160 
162  void operator=(const Grille_val&) ;
163 
164  // Accessors
165  // ---------
166  public:
168  int get_fantome() const {
169  return nfantome ;
170  } ;
171 
173  int get_type_t() const {
174  return type_t ;
175  } ;
176 
178  int get_type_p() const {
179  return type_p ;
180  } ;
181 
183  int get_ndim() const {
184  return dim.ndim ;
185  } ;
186 
188  int get_dim(const int i) const {
189  assert ( (i>=0) && (i<dim.ndim) ) ;
190  return dim.dim[i] ;
191  } ;
192 
194  const Dim_tbl* get_dim_tbl() const {
195  return &dim ;
196  } ;
197 
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 
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:
219  virtual void sauve(FILE *) const ;
220 
222  friend ostream& operator<<(ostream& , const Grille_val& ) ;
223 
224  protected:
226  virtual ostream& operator>>(ostream& ) const ;
227 
228  // Interpolation
229  // -------------
230  public:
240  virtual bool compatible(const Map* mp, const int lmax, const int lmin=0)
241  const = 0 ;
242 
253  Tbl interpol1(const Tbl& rdep, const Tbl& rarr, const Tbl& fdep,
254  int flag, const int type_inter) const ;
255 
265  virtual Tbl interpol2(const Tbl& fdep, const Tbl& rarr,
266  const Tbl& tetarr, const int type_inter) const = 0 ;
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 
287  virtual bool contenue_dans(const Map& mp, const int lmax, const int lmin=0)
288  const = 0 ;
289 
290  protected:
298  void somme_spectrale1(const Scalar& meudon, double* t, int taille) const ;
299 
301  virtual void somme_spectrale2(const Scalar& meudon, double* t, int taille) const = 0 ;
302 
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 
325 class Gval_cart : public Grille_val {
327  friend class Tbl_val ;
328 
329  // Data :
330  // -----
331  protected:
333  double *xmin ;
335  double *xmax ;
337  double *ymin ;
339  double *ymax ;
340 
341  public:
343  Tbl *x ;
345  Tbl *xi ;
347  Tbl *y ;
349  Tbl *yi ;
350 
351  // Constructors - Destructor
352  // -------------------------
353 
361  Gval_cart(const double izmin, const double izmax, const int n1,
362  const int fantome = 2) ;
363 
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 
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 
408  Gval_cart(const Gval_cart& ) ;
409 
411  Gval_cart(FILE* ) ;
412 
414  virtual ~Gval_cart() ;
415 
416  // Mutators / assignment
417  // ---------------------
418  public:
419 
421  void operator=(const Gval_cart&) ;
422 
423  // Accessors
424  // ---------
425  public:
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 
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 
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 
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 
463  double get_xmin() const {
464  return *xmin ;
465  } ;
466 
468  double get_xmax() const {
469  return *xmax ;
470  } ;
471 
473  double get_ymin() const {
474  return *ymin ;
475  } ;
476 
478  double get_ymax() const {
479  return *ymax ;
480  } ;
481 
482  // Outputs
483  // -------
484  public:
486  virtual void sauve(FILE *) const ;
487 
488  protected:
490  virtual ostream& operator>>(ostream& ) const ;
491 
492  // Interpolation
493  // -------------
494  public:
504  virtual bool compatible(const Map* mp, const int lmax, const int lmin=0)
505  const ;
506 
517  virtual Tbl interpol2(const Tbl& fdep, const Tbl& rarr,
518  const Tbl& tetarr, const int type_inter) const ;
519 
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 ;
538  virtual Tbl interpol3(const Tbl& fdep, const Tbl& rarr,
539  const Tbl& tetarr, const Tbl& phiarr,
540  const int type_inter) const ;
546  virtual bool contenue_dans(const Map& mp, const int lmax, const int lmin=0)
547  const ;
548 
549  protected:
557  virtual void somme_spectrale2(const Scalar& meudon, double* t, int taille) const ;
558 
560  virtual void somme_spectrale3(const Scalar& meudon, double* t, int taille) const ;
561 };
562 
563  //------------------------------------//
564  // class Gval_spher //
565  //------------------------------------//
566 
579 class Gval_spher : public Grille_val {
581  friend class Tbl_val ;
582 
583  // Data :
584  // -----
585  public:
587  Tbl *tet ;
591  Tbl *phi ;
594 
595  // Constructors - Destructor
596  // -------------------------
597 
605  Gval_spher(const double irmin, const double irmax, const int nr,
606  const int fantome = 2) ;
607 
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 
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 
639  Gval_spher(const Gval_spher& ) ;
640 
642  Gval_spher(FILE* ) ;
643 
645  virtual ~Gval_spher() ;
646 
647  // Mutators / assignment
648  // ---------------------
649  public:
650 
652  void operator=(const Gval_spher&) ;
653 
654  // Accessors
655  // ---------
656  public:
657 
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 
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 
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 
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:
698  virtual void sauve(FILE *) const ;
699 
700  protected:
702  virtual ostream& operator>>(ostream& ) const ;
703 
704  // Interpolation
705  // -------------
706  public:
716  virtual bool compatible(const Map* mp, const int lmax, const int lmin=0)
717  const ;
718 
729  virtual Tbl interpol2(const Tbl& fdep, const Tbl& rarr, const Tbl& tetarr,
730  const int type_inter) const ;
743  virtual Tbl interpol3(const Tbl& fdep, const Tbl& rarr, const Tbl& tetarr,
744  const Tbl& phiarr, const int type_inter) const ;
745 
751  virtual bool contenue_dans(const Map& mp, const int lmax, const int lmin=0)
752  const ;
753 
754  protected:
762  virtual void somme_spectrale2(const Scalar& meudon, double* t, int taille) const ;
763 
765  double* somme_spectrale2ri(const Scalar& meudon) const ;
766 
768  double* somme_spectrale2ti(const Scalar& meudon) const ;
769 
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 
virtual void sauve(FILE *) const
Save in a file.
Definition: grille_val.C:227
virtual bool contenue_dans(const Map &mp, const int lmax, const int lmin=0) const =0
Checks if Grille_val is contained inside the spectral grid/mapping within the domains [lmin...
Tbl * xi
Arrays containing the values of coordinate x on the interfaces.
Definition: grille_val.h:345
double * xmax
Higher boundary for x dimension.
Definition: grille_val.h:335
int get_fantome() const
Returns the number of hidden cells.
Definition: grille_val.h:168
virtual void somme_spectrale2(const Scalar &meudon, double *t, int taille) const
Makes the sommation of the spectral basis functions to know the values of the function described by t...
Tbl * zri
Arrays containing the values of coordinate z (or r) on the interfaces.
Definition: grille_val.h:126
virtual Tbl interpol2(const Tbl &fdep, const Tbl &rarr, const Tbl &tetarr, const int type_inter) const
Performs 2D interpolation.
int get_ndim() const
Returns the number of dimensions.
Definition: grille_val.h:183
virtual bool compatible(const Map *mp, const int lmax, const int lmin=0) const
Checks if the spectral grid and mapping are compatible with the Grille_val caracteristics for the int...
Lorene prototypes.
Definition: app_hor.h:67
double get_zri(const int i) const
Read-only of a particular value of the coordinate z (or r ) at the interfaces.
Definition: grille_val.h:207
double get_xi(const int i) const
Read-only of a particular value of the coordinate x at the interfaces.
Definition: grille_val.h:445
Tbl * y
Arrays containing the values of coordinate y on the nodes.
Definition: grille_val.h:347
int get_type_t() const
Returns the type of symmetry in .
Definition: grille_val.h:173
Tensor field of valence 0 (or component of a tensorial field).
Definition: scalar.h:393
Base class for coordinate mappings.
Definition: map.h:688
double * somme_spectrale2ri(const Scalar &meudon) const
Same as before but at radial grid interfaces.
Tbl * tet
Arrays containing the values of coordinate on the nodes.
Definition: grille_val.h:587
double * zrmax
Higher boundary for z (or r ) direction.
Definition: grille_val.h:120
double get_xmin() const
Returns the lower boundary for x.
Definition: grille_val.h:463
Tbl * phii
Arrays containing the values of coordinate on the interfaces.
Definition: grille_val.h:593
double get_teti(const int i) const
Read-only of a particular value of coordinate at the interfaces.
Definition: grille_val.h:677
double * zrmin
Lower boundary for z (or r ) direction.
Definition: grille_val.h:117
void operator=(const Gval_spher &)
Assignment to another Gval_spher.
Definition: grille_val.C:641
virtual Tbl interpol3(const Tbl &fdep, const Tbl &rarr, const Tbl &tetarr, const Tbl &phiarr, const int type_inter) const =0
Performs 3D interpolation.
double * ymax
Higher boundary for y dimension.
Definition: grille_val.h:339
int type_t
Type of symmetry in :
Definition: grille_val.h:109
virtual bool contenue_dans(const Map &mp, const int lmax, const int lmin=0) const
Checks if Gval_cart is contained inside the spectral grid/mapping within the domains [lmin...
Base class for Godunov-type grids.
Definition: grille_val.h:94
double * xmin
Lower boundary for x dimension.
Definition: grille_val.h:333
virtual void sauve(FILE *) const
Save in a file.
Definition: grille_val.C:692
friend ostream & operator<<(ostream &, const Grille_val &)
Display.
Definition: grille_val.C:246
const Dim_tbl * get_dim_tbl() const
Returns the Dim_tbl associated with the grid.
Definition: grille_val.h:194
Tbl * yi
Arrays containing the values of coordinate y on the interfaces.
Definition: grille_val.h:349
double * ymin
Lower boundary for y dimension.
Definition: grille_val.h:337
virtual ostream & operator>>(ostream &) const
Operator >> (virtual function called by the operator <<).
Definition: grille_val.C:712
virtual ostream & operator>>(ostream &) const
Operator >> (virtual function called by the operator <<).
Definition: grille_val.C:453
double get_ymin() const
Returns the lower boundary for y.
Definition: grille_val.h:473
Tbl * x
Arrays containing the values of coordinate x on the nodes.
Definition: grille_val.h:343
double get_yi(const int i) const
Read-only of a particular value of the coordinate y at the interfaces.
Definition: grille_val.h:454
Tbl * fait_grille1D(const double rmin, const double rmax, const int n)
Auxilliary function used to allocate memory and construct 1D grid.
Definition: grille_val.C:78
double get_phi(const int i) const
Read-only of a particular value of the coordinate at the nodes.
Definition: grille_val.h:668
Grille_val(const double, const double, const int n1, const int fantome=2)
Standard 1D constructor (the size is to be given without hidden cells)
Definition: grille_val.C:90
Tbl * teti
Arrays containing the values of coordinate on the interfaces.
Definition: grille_val.h:589
double get_x(const int i) const
Read-only of a particular value of the coordinate x at the nodes.
Definition: grille_val.h:427
double * t
The array of double.
Definition: tbl.h:176
virtual void sauve(FILE *) const
Save in a file.
Definition: grille_val.C:430
virtual void somme_spectrale2(const Scalar &meudon, double *t, int taille) const =0
Same as before but for the 2D case.
Tbl * zr
Arrays containing the values of coordinate z (or r) on the nodes.
Definition: grille_val.h:124
virtual void somme_spectrale3(const Scalar &meudon, double *t, int taille) const
Same as before but for the 3D case.
double * somme_spectrale2ti(const Scalar &meudon) const
Same as before but at angular grid interfaces.
Finite-difference array intended to store field values.
Definition: tbl_val.h:97
double get_phii(const int i) const
Read-only of a particular value of coordinate at the interfaces.
Definition: grille_val.h:686
virtual Tbl interpol2(const Tbl &fdep, const Tbl &rarr, const Tbl &tetarr, const int type_inter) const
Performs 2D interpolation.
virtual ~Gval_spher()
Destructor.
Definition: grille_val.C:627
virtual void somme_spectrale2(const Scalar &meudon, double *t, int taille) const
Makes the sommation of the spectral basis functions to know the values of the function described by t...
double get_y(const int i) const
Read-only of a particular value of the coordinate y at the nodes.
Definition: grille_val.h:436
double get_tet(const int i) const
Read-only of a particular value of the coordinate at the nodes.
Definition: grille_val.h:659
virtual Tbl interpol2(const Tbl &fdep, const Tbl &rarr, const Tbl &tetarr, const int type_inter) const =0
Performs 2D interpolation.
double get_zr(const int i) const
Read-only of a particular value of the coordinate z (or r ) at the nodes.
Definition: grille_val.h:199
void operator=(const Grille_val &)
Assignment to another Grille_val.
Definition: grille_val.C:202
Tbl * phi
Arrays containing the values of coordinate on the nodes.
Definition: grille_val.h:591
virtual Tbl interpol3(const Tbl &fdep, const Tbl &rarr, const Tbl &tetarr, const Tbl &phiarr, const int type_inter) const
Performs 3D interpolation.
int ndim
Number of dimensions of the Tbl: can be 1, 2 or 3.
Definition: dim_tbl.h:101
int nfantome
The number of hidden cells (same on each side)
Definition: grille_val.h:104
Storage of array dimensions.
Definition: dim_tbl.h:99
Bases of the spectral expansions.
Definition: base_val.h:325
virtual bool compatible(const Map *mp, const int lmax, const int lmin=0) const
Checks if the spectral grid and mapping are compatible with the Grille_val caracteristics for the int...
virtual bool compatible(const Map *mp, const int lmax, const int lmin=0) const =0
Checks if the spectral grid and mapping are compatible with the Grille_val caracteristics for the int...
int get_dim(const int i) const
Returns the size (without hidden cells)
Definition: grille_val.h:188
Class for spherical Godunov-type grids.
Definition: grille_val.h:579
double get_ymax() const
Returns the higher boundary for x.
Definition: grille_val.h:478
Class for cartesian Godunov-type grids.
Definition: grille_val.h:325
Dim_tbl dim
The dimensions of the grid.
Definition: grille_val.h:102
virtual bool contenue_dans(const Map &mp, const int lmax, const int lmin=0) const
Checks if Gval_spher is contained inside the spectral grid/mapping within the domains [lmin...
Gval_spher(const double irmin, const double irmax, const int nr, const int fantome=2)
Standard 1D constructor.
Definition: grille_val.C:535
virtual void somme_spectrale3(const Scalar &meudon, double *t, int taille) const =0
Same as before but for the 3D case.
Gval_cart(const double izmin, const double izmax, const int n1, const int fantome=2)
Standard 1D constructor.
Definition: grille_val.C:282
Tbl interpol2c(const Tbl &xdep, const Tbl &zdep, const Tbl &fdep, const Tbl &rarr, const Tbl &tetarr, const int type_inter) const
Same as before, but the coordinates of source points are passed explicitly (xdep, zdep)...
virtual ~Grille_val()
Destructor.
Definition: grille_val.C:184
Basic array class.
Definition: tbl.h:164
void operator=(const Gval_cart &)
Assignment to another Gval_cart.
Definition: grille_val.C:411
Tbl interpol1(const Tbl &rdep, const Tbl &rarr, const Tbl &fdep, int flag, const int type_inter) const
Performs 1D interpolation.
virtual void somme_spectrale3(const Scalar &meudon, double *t, int taille) const
Same as before but for the 3D case.
virtual ~Gval_cart()
Destructor.
Definition: grille_val.C:393
int type_p
Type of symmetry in :
Definition: grille_val.h:114
virtual ostream & operator>>(ostream &) const
Operator >> (virtual function called by the operator <<).
Definition: grille_val.C:251
int * dim
Array of dimensions (size: ndim).
Definition: dim_tbl.h:102
void somme_spectrale1(const Scalar &meudon, double *t, int taille) const
Makes the sommation of the spectral basis functions to know the values of the function described by t...
double get_xmax() const
Returns the higher boundary for x.
Definition: grille_val.h:468
virtual Tbl interpol3(const Tbl &fdep, const Tbl &rarr, const Tbl &tetarr, const Tbl &phiarr, const int type_inter) const
Performs 3D interpolation.
int get_type_p() const
Returns the type of symmetry in .
Definition: grille_val.h:178