158 #include "type_parite.h" 159 #include "utilitaires.h" 172 Mg3d::Mg3d(
int nz,
int nbr[],
int typr[],
int nbt[],
int typt,
int nbp[],
173 int typp,
int* base_r)
174 : nzone(nz), type_t(typt), type_p(typp)
180 bool cheb = (base_r == 0x0) ;
181 for (
int i=0 ; i<nz ; i++) {
183 colloc_r[i] = cheb ? BASE_CHEB : base_r[i] ;
190 for (
int i=0 ; i<nz ; i++) {
200 for (
int i=0; i<nz; i++) {
218 Mg3d::Mg3d(
int nz,
int nbr,
int nbt,
int nbp,
int typt,
int typp,
219 bool compact,
bool leg)
228 colloc_r[0] = leg ? BASE_LEG : BASE_CHEB ;
229 for (
int l=1; l<nz-1; l++) {
231 colloc_r[l] = leg ? BASE_LEG : BASE_CHEB ;
240 colloc_r[nz-1] = leg ? BASE_LEG : BASE_CHEB ;
248 for (
int l=0 ; l<nz ; l++) {
258 for (
int i=0; i<nz; i++) {
276 Mg3d::Mg3d(
int nz,
int nbr,
int nbt,
int nbp,
int typt,
int typp)
284 for (
int l=0; l<nz; l++) {
293 for (
int l=0 ; l<nz ; l++) {
303 for (
int i=0; i<nz; i++) {
328 ifstream parfile(filename.c_str()) ;
330 string message =
"Unable to open file " ;
331 message += filename ;
332 throw ios_base::failure(message);
335 string tmp_str =
"Definition of the Mg3d" ;
337 string mesg =
"No data found to contruct an object Mg3d in " ;
339 throw invalid_argument(mesg) ;
343 parfile.ignore(1000,
'\n') ;
347 parfile >>
nzone ; parfile.ignore(1000,
'\n') ;
352 if ( tmp_str.compare(
"SYM") == 0) {
355 else if ( tmp_str.compare(
"NONSYM") == 0)
361 invalid_argument(
"Mg3d::Mg3d(string): incorrect value for theta symmetry") ;
362 parfile.ignore(1000,
'\n') ;
365 if ( tmp_str.compare(
"SYM") == 0)
369 else if ( tmp_str.compare(
"NONSYM") == 0)
375 invalid_argument(
"Mg3d::Mg3d(string): incorrect value for phi symmetry") ;
376 parfile.ignore(1000,
'\n') ;
378 int nbp ; parfile >> nbp ; parfile.ignore(1000,
'\n') ;
379 int nbt ; parfile >> nbt ; parfile.ignore(1000,
'\n') ;
388 for (
int i=0; i<
nzone; i++) {
389 parfile >>
nr[i] >> tmp_str ;
391 if ( tmp_str.compare(
"nucleus") == 0)
395 else if ( tmp_str.compare(
"shell") == 0)
399 else if ( tmp_str.compare(
"ced") == 0)
405 invalid_argument(
"Mg3d::Mg3d(string): incorrect value for the type of domain") ;
406 parfile.ignore(1000,
'\n') ;
413 parfile >> legendre ;
414 for (
int i=0; i<
nzone; i++)
415 colloc_r[i] = (legendre ? BASE_LEG : BASE_CHEB) ;
422 for (
int i=0; i<
nzone; i++) {
464 for (
int i=0; i<
nzone; i++) {
465 if (!read_base)
colloc_r[i] = BASE_CHEB ;
489 for (
int i=0 ; i<
nzone ; i++) {
512 for (
int l=0; l<
nzone; l++)
514 cout <<
"Mg3d::sauve(FILE*, bool) : " << endl ;
515 cout <<
"The multi-grid is not with Chebyshev basis!!" << endl ;
516 cout <<
"Consider setting the 'save_base' flaf to 'true'!!" 528 ostream& operator<<(ostream& o,
const Mg3d& g) {
530 tr[FIN] =
"FIN" ; tr[RARE] =
"RARE" ; tr[UNSURR] =
"UNSURR" ;
531 const char* tang[2] ;
532 tang[NONSYM] =
"NONSYM" ; tang[SYM] =
"SYM" ;
533 const char* tbase[3] ;
534 tbase[BASE_CHEB] =
"Chebyshev" ; tbase[BASE_LEG] =
"Legendre" ;
535 tbase[BASE_JAC02] =
"Jacobi(0,2)" ;
536 o <<
"Number of domains: " << g.
nzone << endl ;
537 for (
int i=0 ; i< g.
nzone ; i++) {
538 o <<
" Domain #" << i <<
": " 539 <<
"nr = " << g.
nr[i] <<
", " << tr[g.
type_r[i]] <<
"; " 540 <<
"nt = " << g.
nt[i] <<
", " << tang[g.
type_t] <<
"; " 541 <<
"np = " << g.
np[i] <<
", " << tang[g.
type_p] <<
"; " 542 <<
"Collocation points type : " << tbase[g.
colloc_r[i]] << endl ;
553 for (
int i=0 ; i<
nzone ; i++) {
554 if (
nr[i] != titi.
nr[i])
return true ;
555 if (
nt[i] != titi.
nt[i])
return true ;
556 if (
np[i] != titi.
np[i])
return true ;
608 int* nbr_angu =
new int[
nzone] ;
609 for (
int i=0 ; i<
nzone ; i++) {
628 int* nbr_angu =
new int(1) ;
629 int* nbt_angu =
new int(
nt[0]) ;
630 int* nbp_angu =
new int(
np[0]) ;
631 int* type_r_angu =
new int(FIN) ;
653 int* nbr_radial =
new int[
nzone] ;
654 for (
int i=0 ; i<
nzone ; i++) {
659 delete [] nbr_radial ;
674 int* nbr =
new int[
nzone] ;
675 int* nbt =
new int[
nzone] ;
676 int* nbp =
new int[
nzone] ;
678 for (
int l=0; l<
nzone; l++) {
683 nbr[l] = 2*
nr[l] - 1 ;
690 nbt[l] = 2*
nt[l] - 1 ;
722 int* nbr =
new int[
nzone] ;
724 for (
int l=0; l<
nzone; l++) {
728 nbr[l] = (3*
nr[l])/2 ;
750 int* nbt =
new int[
nzone] ;
751 int* nbp =
new int[
nzone] ;
753 for (
int l=0; l<
nzone; l++) {
757 int nt_bis = (3*(
nt[l]))/2;
758 if (nt_bis % 2 == 0) nt_bis += 1 ;
788 int* nbt =
new int[
nzone] ;
789 int* nbp =
new int[
nzone] ;
791 for (
int l=0; l<
nzone; l++) {
823 for (
int i=0; i<
nzone; i++) {
824 if (mgi.
get_nr(i) !=
nr[i]) resu =
false ;
825 if (mgi.
get_np(i) !=
np[i]) resu =
false ;
826 if (mgi.
get_nt(i) !=
nt[i]) resu =
false ;
void set_deriv_0x0() const
Sets to 0x0 all the pointers on derived quantities (g_radial , g_angu, g_twice, ...
int get_type_p() const
Returns the type of sampling in the direction: SYM : : symmetry with respect to the transformatio...
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 ...
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...
int get_np(int l) const
Returns the number of points in the azimuthal direction ( ) in domain no. l.
int type_p
Type of sampling in (SYM, NONSYM)
Mg3d * g_plus_half
Pointer on the grid which has 50% more points in r dimension (for desaliasing).
int * np
Array (size: nzone) of nb. of points in .
Mg3d * g_angu_1dom
Pointer on the associated angular grid with only one domain.
const Mg3d * get_twice() const
Returns the pointer on the grid which has twice the number of points in each dimension (for desaliasi...
void del_deriv() const
Deletes all the derived quantities (g_radial , g_angu, g_twice, ...)
int get_type_t() const
Returns the type of sampling in the direction: SYM : : symmetry with respect to the equatorial pl...
const Mg3d * get_radial() const
Returns the pointer on the associated radial grid.
bool operator==(const Mg3d &) const
Comparison operator (egality)
int type_t
Type of sampling in (SYM, NONSYM)
int get_colloc_r(int l) const
Returns the type of collocation points used in domain no.
Mg3d * g_plus_half_angu
Pointer on the grid which has 50% more points in and dimension (for desaliasing).
void sauve(FILE *fd, bool save_base=false) const
Saves into a file.
const Mg3d * get_angu() const
Returns the pointer on the associated angular grid.
bool search_file(ifstream &infile, const string &pattern)
A function that searches for a pattern in a file and places the file stream after the found pattern...
int nzone
Number of domains (zones)
Mg3d * g_angu
Pointer on the associated angular grid.
int get_nzone() const
Returns the number of domains.
int fwrite_be(const int *aa, int size, int nb, FILE *fich)
Writes integer(s) into a binary file according to the big endian convention.
Mg3d * g_twice
Pointer on the grid which has twice the number of points in each dimension (for desaliasing).
Mg3d * g_radial
Pointer on the associated radial grid.
const Mg3d * plus_half() const
Returns the pointer on the grid which has 50% more points in r dimension (for desaliasing).
Grille3d ** g
Array (size: nzone) of pointers on the Grille3d's.
int * type_r
Array (size: nzone) of type of sampling in r ( ) (RARE,FIN, UNSURR)
int fread_be(int *aa, int size, int nb, FILE *fich)
Reads integer(s) from a binary file according to the big endian convention.
int get_nr(int l) const
Returns the number of points in the radial direction ( ) in domain no. l.
int * colloc_r
Array (size: nzone) of type of collocation points in r ( ) and related decompoisition bases (BASE_CHE...
const Mg3d * plus_half_angu() const
Returns the pointer on the grid which has 50% more points in and dimension (for desaliasing)...
void arrete(int a=0)
Setting a stop point in a code.
int get_nt(int l) const
Returns the number of points in the co-latitude direction ( ) in domain no. l.
bool operator!=(const Mg3d &) const
Operator !=.
int get_type_r(int l) const
Returns the type of sampling in the radial direction in domain no.
Mg3d(int nz, int nbr[], int typr[], int nbt[], int typt, int nbp[], int typp, int *base_r=0x0)
General constructor.
int * nt
Array (size: nzone) of nb. of points in .
const Mg3d * get_angu_1dom() const
Returns the pointer on the associated mono-domain angular grid.
3D grid class in one domain.
int * nr
Array (size: nzone) of nb. of points in r ( )