LORENE
grilles.h
1 /*
2  * Definition of Lorene classes Grille3d and Mg3d
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 #ifndef __GRILLES_H_
30 #define __GRILLES_H_
31 
32 /*
33  * $Id: grilles.h,v 1.25 2023/05/24 09:48:50 g_servignat Exp $
34  * $Log: grilles.h,v $
35  * Revision 1.25 2023/05/24 09:48:50 g_servignat
36  * Added plus_half grid in angular direction for dealiasing
37  *
38  * Revision 1.24 2018/12/05 15:03:20 j_novak
39  * New Mg3d constructor from a formatted file.
40  *
41  * Revision 1.23 2014/10/13 08:52:35 j_novak
42  * Lorene classes and functions now belong to the namespace Lorene.
43  *
44  * Revision 1.22 2014/10/06 15:09:39 j_novak
45  * Modified #include directives to use c++ syntax.
46  *
47  * Revision 1.21 2013/06/05 15:00:26 j_novak
48  * Suppression of all classes derived from Grille3d. Now Grille3d is no
49  * longer an abstract class. r-samplings are only one of RARE, FIN or
50  * UNSURR (FINJAC has been removed). Instead, Mg3d possesses a new member
51  * colloc_r[nzone] defining the type of collocation points (spectral
52  * bases) in each domain.
53  *
54  * Revision 1.20 2013/01/11 15:44:53 j_novak
55  * Addition of Legendre bases (part 2).
56  *
57  * Revision 1.19 2012/01/17 10:10:15 j_penner
58  * added a constructor in which the nucleus and outer domain are both of type FIN
59  *
60  * Revision 1.18 2008/10/29 08:17:51 jl_cornou
61  * Standard spectral bases for pseudo vectors added
62  *
63  * Revision 1.17 2008/02/18 13:53:37 j_novak
64  * Removal of special indentation instructions.
65  *
66  * Revision 1.16 2007/12/11 15:28:05 jl_cornou
67  * Jacobi(0,2) polynomials partially implemented
68  *
69  * Revision 1.15 2006/05/17 13:17:02 j_novak
70  * New member g_angu_1dom, the one-domain angular grid associated with the
71  * current grid.
72  *
73  * Revision 1.14 2005/10/25 08:56:34 p_grandclement
74  * addition of std_spectral_base in the case of odd functions near the origin
75  *
76  * Revision 1.13 2005/10/07 08:47:20 j_novak
77  * Addition of the pointer g_non_axi on a grid, with at least 5 points in the
78  * theta direction and 4 in the phi one (for tensor rotations).
79  *
80  * Revision 1.12 2005/03/25 14:54:04 e_gourgoulhon
81  * Corrected documentation.
82  *
83  * Revision 1.11 2004/07/06 13:36:27 j_novak
84  * Added methods for desaliased product (operator |) only in r direction.
85  *
86  * Revision 1.10 2004/06/22 08:49:56 p_grandclement
87  * Addition of everything needed for using the logarithmic mapping
88  *
89  * Revision 1.9 2004/03/22 13:12:41 j_novak
90  * Modification of comments to use doxygen instead of doc++
91  *
92  * Revision 1.8 2003/06/20 14:16:57 f_limousin
93  * Add the operator== to compare two Mg3d
94  *
95  * Revision 1.7 2003/06/18 08:45:26 j_novak
96  * In class Mg3d: added the member get_radial, returning only a radial grid
97  * For dAlembert solver: the way the coefficients of the operator are defined has been changed.
98  *
99  * Revision 1.6 2002/10/16 14:36:29 j_novak
100  * Reorganization of #include instructions of standard C++, in order to
101  * use experimental version 3 of gcc.
102  *
103  * Revision 1.5 2002/08/13 08:02:45 j_novak
104  * Handling of spherical vector/tensor components added in the classes
105  * Mg3d and Tenseur. Minor corrections for the class Metconf.
106  *
107  * Revision 1.4 2002/06/17 14:05:16 j_novak
108  * friend functions are now also declared outside the class definition
109  *
110  * Revision 1.3 2001/12/12 09:23:46 e_gourgoulhon
111  * Parameter compact added to the simplified constructor of class Mg3d
112  *
113  * Revision 1.2 2001/12/11 06:47:42 e_gourgoulhon
114  * Simplified constructor for class Mg3d
115  *
116  * Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon
117  * LORENE
118  *
119  * Revision 2.10 2001/06/13 14:23:40 eric
120  * Les fonctions Mg3d::del_deriv() et Mg3d::set_deriv_0x0() ne sont plus
121  * virtuelles puisque Mg3d n'a aucune classe derivee.
122  *
123  * Revision 2.9 2001/05/26 13:24:49 eric
124  * Ajout du membre g_twice (grille double pour le desaliasing)
125  * Modif de la declaration de g_angu (pointeur mutable)
126  * g_twice et g_angu ne sont calcules que si necessaire (cad si
127  * on appelle la fonction get_twice() ou get_angu()).
128  *
129  * Revision 2.8 1999/11/16 14:15:57 eric
130  * Ajout de la fonction Mg3d::get_angu().
131  *
132  * Revision 2.7 1999/10/12 14:54:11 eric
133  * Ajout du membre Base_val std_base_scal() const.
134  *
135  * Revision 2.6 1999/10/01 10:35:42 eric
136  * Amelioration des commentaires.
137  *
138  * Revision 2.5 1999/09/30 14:58:00 eric
139  * Operator!= declare const/
140  *
141  * Revision 2.4 1999/09/30 14:11:43 eric
142  * sauve et std_base_vect_cart declarees const.
143  *
144  * Revision 2.3 1999/09/30 12:52:38 eric
145  * Depoussierage.
146  * Documentation.
147  *
148  * Revision 2.2 1999/09/24 14:23:24 eric
149  * Declaration de methodes const.
150  *
151  * Revision 2.1 1999/09/14 15:24:04 phil
152  * ajout de std_base_vect_cart
153  *
154  * Revision 2.0 1999/02/15 10:41:51 hyc
155  * *** empty log message ***
156  *
157  * Revision 2.1 1999/02/15 09:59:50 hyc
158  * *** empty log message ***
159  *
160  * Revision 2.0 1998/12/01 14:28:00 hyc
161  * Version 2
162  *
163  *
164  * $Header: /cvsroot/Lorene/C++/Include/grilles.h,v 1.25 2023/05/24 09:48:50 g_servignat Exp $
165  *
166  */
167 
168 // Classes utilisees
169 
170 // Fichiers includes
171 #include <cassert>
172 #include <cstdio>
173 #include <cstdlib>
174 #include "headcpp.h"
175 
176 #include "type_parite.h"
177 
178 namespace Lorene {
179 class Base_val ;
180 
181  //-------------//
182  // Mono-grille //
183  //-------------//
184 
185 // Classe de base
200 class Grille3d {
201  protected:
202  const int nr ;
203  const int nt ;
204  const int np ;
205 
207  int type_r ;
208  int type_t ;
209  int type_p ;
210  int base_r ;
212 
213  public:
215  double* x ;
217  double* tet ;
219  double* phi ;
220 
222  Grille3d(int n_r, int n_t, int n_p, int typer, int typet,
223  int typep, int baser) ;
224 
226  Grille3d(const Grille3d& ) ;
227 
229  void operator=(const Grille3d& ) ;
230 
231  public:
232  virtual ~Grille3d() ;
233 
234  public:
236  int get_nr() const {return nr ;} ;
238  int get_nt() const {return nt ;} ;
240  int get_np() const {return np ;} ;
241 
243  int get_type_r() const {return type_r ;} ;
245  int get_type_t() const {return type_t ;} ;
247  int get_type_p() const {return type_p ;} ;
249  int get_base_r() const {return base_r ;} ;
250 
251  protected:
253  void compute_radial_grid() ;
254 };
255 
256 
257 
258  //---------------//
259  // Multi-grilles //
260  //---------------//
261 
279 class Mg3d {
280 
281  // Data
282  // ----
283  protected:
284  int nzone ;
285 
286  int* nr ;
287  int* nt ;
288  int* np ;
289 
293  int* type_r ;
294 
296  int type_t ;
297 
299  int type_p ;
300 
305  int* colloc_r ;
306 
308  Grille3d** g ;
309 
310  mutable Mg3d* g_angu ;
311  mutable Mg3d* g_angu_1dom ;
313  mutable Mg3d* g_radial ;
314 
318  mutable Mg3d* g_twice ;
319 
323  mutable Mg3d* g_plus_half ;
324 
328  mutable Mg3d* g_plus_half_angu ;
329 
334  mutable Mg3d* g_non_axi ;
335 
336  // Constructors - Destructor
337  // -------------------------
338 
339  public:
340 
357  Mg3d(int nz, int nbr[], int typr[], int nbt[], int typt, int nbp[],
358  int typp, int* base_r = 0x0) ;
359 
398  Mg3d(int nz, int nbr, int nbt, int nbp, int typt, int typp,
399  bool compact, bool legendre=false) ;
400 
426  Mg3d(int nz, int nbr, int nbt, int nbp, int typt, int typp) ;
427 
428 
432  explicit Mg3d(const string& filename) ;
433 
439  Mg3d(FILE* fd, bool read_base=false) ;
440 
441  public:
446  Mg3d(const Mg3d& ) ;
447 
448  public:
449 
450  ~Mg3d() ;
451 
452  // Assignement
453  // -----------
454  private:
459  void operator=(const Mg3d& ) ;
460 
461  // Extraction of information
462  // -------------------------
463  public:
465  int get_nzone() const {
466  return nzone ;
467  } ;
469  int get_nr(int l) const {
470  assert(l>=0 && l<nzone) ;
471  return nr[l] ;
472  } ;
474  int get_nt(int l) const {
475  assert(l>=0 && l<nzone) ;
476  return nt[l] ;
477  } ;
479  int get_np(int l) const {
480  assert(l>=0 && l<nzone) ;
481  return np[l] ;
482  } ;
483 
491  int get_type_r(int l) const {
492  assert(l>=0 && l<nzone) ;
493  return type_r[l] ;
494  } ;
495 
502  int get_type_t() const {
503  return type_t ;
504  } ;
505 
512  int get_type_p() const {
513  return type_p ;
514  } ;
515 
517  const Grille3d* get_grille3d(int l) const {
518  assert(l>=0 && l<nzone) ;
519  return g[l] ;
520  } ;
521 
528  int get_colloc_r(int l) const {
529  assert(l>=0 && l<nzone) ;
530  return colloc_r[l] ;
531  }
532 
534  const Mg3d* get_angu() const ;
535 
539  const Mg3d* get_angu_1dom() const ;
540 
542  const Mg3d* get_radial() const ;
543 
547  const Mg3d* get_twice() const ;
548 
552  const Mg3d* plus_half() const ;
553 
557  const Mg3d* plus_half_angu() const ;
558 
563  const Mg3d* get_non_axi() const ;
564 
566  bool operator==(const Mg3d& ) const ;
567 
568 
569 
570  // Outputs
571  // -------
572  public:
580  void sauve(FILE* fd, bool save_base=false) const ;
581 
582  friend ostream& operator<<(ostream& , const Mg3d & ) ;
583 
584  // Management of derived quantities
585  // --------------------------------
586  protected:
590  void del_deriv() const ;
591 
595  void set_deriv_0x0() const ;
596 
597 
598  // Miscellaneous
599  // -------------
600  public:
601  bool operator!=(const Mg3d & ) const ;
602 
604  Base_val std_base_scal() const ;
605 
607  Base_val std_base_scal_odd() const ;
608 
612  Base_val** std_base_vect_cart() const ;
613 
617  Base_val** std_base_vect_spher() const ;
618 
622  Base_val** pseudo_base_vect_cart() const ;
623 
627  Base_val** pseudo_base_vect_spher() const ;
628 
629 };
630 ostream& operator<<(ostream& , const Mg3d & ) ;
631 
632 
633 //======================================
634 // One domain standard bases definitions
635 //======================================
636 int std_base_scal_1z(int type_r, int type_t, int type_p) ;
637 int std_base_scal_odd_1z(int type_r, int type_t, int type_p) ;
638 int leg_base_scal_1z(int type_r, int type_t, int type_p) ;
639 int leg_base_scal_odd_1z(int type_r, int type_t, int type_p) ;
640 int jac02_base_scal_1z(int type_r, int type_t, int type_p) ;
641 int jac02_base_scal_odd_1z(int type_r, int type_t, int type_p) ;
642 
643 }
644 #endif
void set_deriv_0x0() const
Sets to 0x0 all the pointers on derived quantities (g_radial , g_angu, g_twice, ...
Definition: mg3d.C:588
int get_type_p() const
Returns the type of sampling in the direction: SYM : : symmetry with respect to the transformatio...
Definition: grilles.h:512
const Mg3d * get_non_axi() const
Returns the pointer on the grid which has at least 4 points in the direction and at least 5 in the ...
Definition: mg3d.C:784
Base_val ** std_base_vect_cart() const
Returns the standard spectral bases for the Cartesian components of a vector.
const Grille3d * get_grille3d(int l) const
Returns a pointer on the 3D mono-grid for domain no. l.
Definition: grilles.h:517
Mg3d * g_non_axi
Pointer on the grid which has at least 4 points in the direction and at least 5 in the direction (f...
Definition: grilles.h:334
int get_np() const
Returns np.
Definition: grilles.h:240
int get_type_r() const
Returns type_r.
Definition: grilles.h:243
int get_np(int l) const
Returns the number of points in the azimuthal direction ( ) in domain no. l.
Definition: grilles.h:479
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
int type_p
Type of sampling in (SYM, NONSYM)
Definition: grilles.h:299
Lorene prototypes.
Definition: app_hor.h:67
Mg3d * g_plus_half
Pointer on the grid which has 50% more points in r dimension (for desaliasing).
Definition: grilles.h:323
virtual ~Grille3d()
Destructor.
Definition: grille3d.C:169
int * np
Array (size: nzone) of nb. of points in .
Definition: grilles.h:288
double * phi
Array of values of at the np collocation points.
Definition: grilles.h:219
Mg3d * g_angu_1dom
Pointer on the associated angular grid with only one domain.
Definition: grilles.h:312
const Mg3d * get_twice() const
Returns the pointer on the grid which has twice the number of points in each dimension (for desaliasi...
Definition: mg3d.C:670
void del_deriv() const
Deletes all the derived quantities (g_radial , g_angu, g_twice, ...)
Definition: mg3d.C:574
void operator=(const Grille3d &)
Assignement operator.
int get_type_t() const
Returns the type of sampling in the direction: SYM : : symmetry with respect to the equatorial pl...
Definition: grilles.h:502
const Mg3d * get_radial() const
Returns the pointer on the associated radial grid.
Definition: mg3d.C:649
bool operator==(const Mg3d &) const
Comparison operator (egality)
Definition: mg3d.C:815
double * x
Array of values of at the nr collocation points.
Definition: grilles.h:215
int get_type_t() const
Returns type_t.
Definition: grilles.h:245
int type_t
Type of sampling in (SYM, NONSYM)
Definition: grilles.h:296
Base_val ** pseudo_base_vect_cart() const
Returns the standard spectral bases for the Cartesian components of a pseudo-vector.
void compute_radial_grid()
Computes the collocation point coordinates in the radial direction.
Definition: grille3d.C:175
int get_colloc_r(int l) const
Returns the type of collocation points used in domain no.
Definition: grilles.h:528
Base_val ** pseudo_base_vect_spher() const
Returns the standard spectral bases for the spherical components of a pseudo-vector.
Base_val std_base_scal_odd() const
Returns the standard odd spectral bases for a scalar.
~Mg3d()
Destructor.
Definition: mg3d.C:480
Mg3d * g_plus_half_angu
Pointer on the grid which has 50% more points in and dimension (for desaliasing).
Definition: grilles.h:328
void sauve(FILE *fd, bool save_base=false) const
Saves into a file.
Definition: mg3d.C:500
const Mg3d * get_angu() const
Returns the pointer on the associated angular grid.
Definition: mg3d.C:604
int type_p
Type of sampling in (SYM,NONSYM)
Definition: grilles.h:209
double * tet
Array of values of at the nt collocation points.
Definition: grilles.h:217
int nzone
Number of domains (zones)
Definition: grilles.h:284
Mg3d * g_angu
Pointer on the associated angular grid.
Definition: grilles.h:310
Base_val ** std_base_vect_spher() const
Returns the standard spectral bases for the spherical components of a vector.
const int np
Number of points in .
Definition: grilles.h:204
int get_nzone() const
Returns the number of domains.
Definition: grilles.h:465
int base_r
Type of radial spectral basis (BASE_CHEB, BASE_LEG, BASE_JAC02 )
Definition: grilles.h:211
int get_base_r() const
Returns base_r.
Definition: grilles.h:249
Mg3d * g_twice
Pointer on the grid which has twice the number of points in each dimension (for desaliasing).
Definition: grilles.h:318
Mg3d * g_radial
Pointer on the associated radial grid.
Definition: grilles.h:313
const Mg3d * plus_half() const
Returns the pointer on the grid which has 50% more points in r dimension (for desaliasing).
Definition: mg3d.C:718
Grille3d ** g
Array (size: nzone) of pointers on the Grille3d&#39;s.
Definition: grilles.h:308
int * type_r
Array (size: nzone) of type of sampling in r ( ) (RARE,FIN, UNSURR)
Definition: grilles.h:293
int get_nr(int l) const
Returns the number of points in the radial direction ( ) in domain no. l.
Definition: grilles.h:469
int * colloc_r
Array (size: nzone) of type of collocation points in r ( ) and related decompoisition bases (BASE_CHE...
Definition: grilles.h:305
Multi-domain grid.
Definition: grilles.h:279
Bases of the spectral expansions.
Definition: base_val.h:325
Base_val std_base_scal() const
Returns the standard spectral bases for a scalar.
int get_type_p() const
Returns type_p.
Definition: grilles.h:247
const Mg3d * plus_half_angu() const
Returns the pointer on the grid which has 50% more points in and dimension (for desaliasing)...
Definition: mg3d.C:746
friend ostream & operator<<(ostream &, const Mg3d &)
Display.
Definition: mg3d.C:528
int get_nr() const
Returns nr.
Definition: grilles.h:236
int type_r
Type of sampling in r ( ) (RARE,FIN,UNSURR )
Definition: grilles.h:207
int get_nt() const
Returns nt.
Definition: grilles.h:238
int get_nt(int l) const
Returns the number of points in the co-latitude direction ( ) in domain no. l.
Definition: grilles.h:474
bool operator!=(const Mg3d &) const
Operator !=.
Definition: mg3d.C:549
int get_type_r(int l) const
Returns the type of sampling in the radial direction in domain no.
Definition: grilles.h:491
Mg3d(int nz, int nbr[], int typr[], int nbt[], int typt, int nbp[], int typp, int *base_r=0x0)
General constructor.
Definition: mg3d.C:172
int * nt
Array (size: nzone) of nb. of points in .
Definition: grilles.h:287
const Mg3d * get_angu_1dom() const
Returns the pointer on the associated mono-domain angular grid.
Definition: mg3d.C:625
Grille3d(int n_r, int n_t, int n_p, int typer, int typet, int typep, int baser)
Constructor.
Definition: grille3d.C:125
void operator=(const Mg3d &)
Assignement operator (private and not implemented to make Mg3d a non-copyable class) ...
3D grid class in one domain.
Definition: grilles.h:200
const int nt
Number of points in .
Definition: grilles.h:203
int * nr
Array (size: nzone) of nb. of points in r ( )
Definition: grilles.h:286