84 #include "grille_val.h" 85 #include "proto_f77.h" 96 if (taille != taille_in) {
97 cout <<
"Gval_spher::somme_spectral2():\n" ;
98 cout <<
"grid size incompatible with array size... exiting!" << endl ;
105 for (
int i=0; i<
nfantome; i++) resu[i] = 0 ;
110 for (
int i=nrv; i<taille; i++) resu[i] = 0 ;
118 int taille = nxv2*nzv2 ;
119 if (taille != taille_in) {
120 cout <<
"Gval_spher::somme_spectral2():\n" ;
121 cout <<
"grid size incompatible with array size... exiting!" << endl ;
126 double xi0, rr, theta ;
130 for (
int iz=0; iz<nzv2; iz++) {
135 for (
int ix=
nfantome; ix<nxv; ix++) {
140 double xx2 = (
x->
t[ix])*(
x->
t[ix]) ;
141 for (
int iz=
nfantome; iz<nzv; iz++) {
143 theta = (rr != 0. ?
acos((
zr->
t[iz])/rr) : 0) ;
144 mp.
val_lx(rr, theta, phi, l, xi0) ;
148 for (
int iz=nzv; iz<nzv2; iz++) {
153 for (
int ix=nxv; ix<nxv2; ix++) {
154 for (
int iz=0; iz<nzv2; iz++) {
168 int taille = nyv2*nxv2*nzv2 ;
169 if (taille != taille_in) {
170 cout <<
"Gval_spher::somme_spectral2():\n" ;
171 cout <<
"grid size incompatible with array size... exiting!" << endl ;
176 double xi0, rr, theta, phi ;
179 for (
int ix=0; ix<nxv2; ix++) {
180 for (
int iz=0; iz<nzv2; iz++){
186 for (
int iy=
nfantome; iy<nyv; iy++) {
187 double yy =
x->
t[iy] ;
190 for (
int iz=0; iz<nzv2; iz++) {
195 for (
int ix=
nfantome; ix<nxv; ix++) {
200 double xx =
x->
t[ix] ;
202 for (
int iz=
nfantome; iz<nzv; iz++) {
203 rr =
sqrt((
zr->
t[iz])*(
zr->
t[iz]) + xx2 + yy2) ;
204 theta = (rr != 0. ?
acos((
zr->
t[iz])/rr) : 0. );
205 phi = (rr != 0. ? atan2(yy, xx) : 0. ) ;
206 mp.
val_lx(rr, theta, phi, l, xi0) ;
210 for (
int iz=nzv; iz<nzv2; iz++) {
215 for (
int ix=nxv; ix<nxv2; ix++) {
216 for (
int iz=0; iz<nzv2; iz++) {
222 for (
int iy=nyv; iy<nyv2; iy++) {
223 for (
int ix=0; ix<nxv2; ix++) {
224 for (
int iz=0; iz<nzv2; iz++){
239 int taille = ntv2*nrv2 ;
240 if (taille != taille_in) {
241 cout <<
"Gval_spher::somme_spectral2():\n" ;
242 cout <<
"grid size incompatible with array size... exiting!" << endl ;
247 double xi, rr, theta ;
251 for (
int ir=0; ir<nrv2; ir++) {
256 for (
int it=
nfantome; it<ntv; it++) {
262 for (
int ir=
nfantome; ir<nrv; ir++) {
264 mp.
val_lx(rr, theta, phi0, l, xi) ;
268 for (
int ir=nrv; ir<nrv2; ir++) {
273 for (
int it=ntv; it<ntv2; it++) {
274 for (
int ir=0; ir<nrv2; ir++) {
286 int taille = ntv2*nrv2 ;
288 double* resu =
new double[taille] ;
290 double xi, rr, theta ;
294 for (
int ir=0; ir<nrv2; ir++) {
299 for (
int it=
nfantome; it<ntv; it++) {
305 for (
int ir=
nfantome; ir<nrv; ir++) {
307 mp.
val_lx(rr, theta, phi0, l, xi) ;
311 for (
int ir=nrv; ir<nrv2; ir++) {
316 for (
int it=ntv; it<ntv2; it++) {
317 for (
int ir=0; ir<nrv2; ir++) {
330 int taille = ntv2*nrv2 ;
332 double* resu =
new double[taille] ;
334 double xi, rr, theta ;
338 for (
int ir=0; ir<nrv2; ir++) {
343 for (
int it=
nfantome; it<ntv; it++) {
348 theta =
teti->
t[it] ;
349 for (
int ir=
nfantome; ir<nrv; ir++) {
351 mp.
val_lx(rr, theta, phi0, l, xi) ;
355 for (
int ir=nrv; ir<nrv2; ir++) {
360 for (
int it=ntv; it<ntv2; it++) {
361 for (
int ir=0; ir<nrv2; ir++) {
371 assert(meudon.
get_etat() == ETATQCQ) ;
384 int taille = npv2*ntv2*nrv2 ;
385 if (taille != taille_in) {
386 cout <<
"Gval_spher::somme_spectral3():\n" ;
387 cout <<
"grid size incompatible with array size... exiting!" << endl ;
392 const Map_af* mpaff =
dynamic_cast<const Map_af*
>(&mp) ;
393 assert(mpaff != 0x0) ;
400 for (
int lz=1; lz<nz; lz++) {
401 assert (ntm == mg->
get_nt(lz)) ;
402 assert (npm == mg->
get_np(lz)) ;
408 double* alpha =
new double[nrv0*(npm+2)*ntm] ;
409 double* p_coef = alpha ;
410 double* chebnri = 0x0 ;
413 double* p_func = chebnri ;
415 double** coefm =
new double*[nz] ;
416 for (
int lz=0; lz<nz; lz++) {
417 assert((mtbcf.
t[lz])->get_etat() != ETATNONDEF) ;
418 coefm[lz] = (mtbcf.
t[lz])->t ;
419 if (coefm[lz] == 0x0) {
420 int sizem = mg->
get_nr(lz)*ntm*(npm+2) ;
421 coefm[lz] =
new double[sizem] ;
422 double* pcf = coefm[lz] ;
423 for (
int i=0; i<sizem; i++)
430 for (
int irv=0; irv<nrv0; irv++) {
432 double* tbcf = coefm[lz] ;
433 int nrm = mg->
get_nr(lz) ;
434 for (
int mpm=0; mpm<npm+2; mpm++) {
435 for (
int ltm=0; ltm<ntm; ltm++) {
437 for (
int irm=0; irm<nrm; irm++) {
438 *p_coef += (*tbcf)*(*p_func) ;
448 for (
int lz=0; lz<nz; lz++) {
449 if ((mtbcf.
t[lz])->t == 0x0)
delete [] coefm[lz] ;
455 double* beta =
new double[ntv0*nrv0*(npm+2)] ;
457 double* tetlj = 0x0 ;
460 double* p_interm = alpha ;
464 for (
int jtv=0; jtv<ntv0; jtv++) {
465 for (
int irv=0; irv<nrv0; irv++) {
466 for (
int mpm=0; mpm<npm+2; mpm++) {
468 for (
int ltm=0; ltm<ntm; ltm++) {
469 *p_coef += (*p_interm) * (*p_func) ;
475 p_func -= (npm+2)*ntm ;
478 p_func += (npm+2)*ntm ;
489 double* expmk = 0x0 ;
494 for (
int it=0; it<ntv2; it++) {
495 for (
int ir=0; ir<nrv2; ir++){
501 for (
int ip=
nfantome; ip<npv; ip++) {
503 for (
int ir=0; ir<nrv2; ir++) {
508 for (
int it=
nfantome; it<ntv; it++) {
513 for (
int ir=
nfantome; ir<nrv; ir++) {
515 for (
int mpm=0; mpm<npm+2; mpm++) {
516 *p_coef += (*p_interm) * (*p_func) ;
523 for (
int ir=nrv; ir<nrv2; ir++) {
528 for (
int it=ntv; it<ntv2; it++) {
529 for (
int ir=0; ir<nrv2; ir++) {
537 for (
int ip=npv; ip<npv2; ip++) {
538 for (
int it=0; it<ntv2; it++) {
539 for (
int ir=0; ir<nrv2; ir++){
550 void Gval_spher::initialize_spectral_r(
const Map& mp,
const Base_val& base,
551 int*& idom,
double*& chebnri)
const {
558 assert (idom == 0x0) ;
559 idom =
new int[nrv0] ;
560 double* xi =
new double[nrv0] ;
563 for (
int i=0; i<nrv0; i++) {
565 nrmax += mg->
get_nr(idom[i]) ;
568 assert (chebnri == 0x0) ;
569 chebnri =
new double[(npm+2)*ntm*nrmax] ;
570 double* p_out = chebnri ;
571 for (
int irv=0; irv<nrv0; irv++) {
572 bool nucleus = (mg->
get_type_r(idom[irv]) == RARE) ;
573 int nmax = (nucleus ? 2*mg->
get_nr(idom[irv]) + 1
574 : mg->
get_nr(idom[irv])) ;
575 double* cheb =
new double[nmax] ;
578 for (
int ir=2; ir<nmax; ir++) {
579 cheb[ir] = 2*xi[irv]*cheb[ir-1] - cheb[ir-2] ;
584 for (
int ip=0; ip<npm+2; ip++) {
585 for (
int it=0; it<ntm; it++) {
616 par = 1 - ((ip/2) % 2) ;
621 cout <<
"Gval_spher::initialize_spectral_r : " <<
'\n' 622 <<
"Unexpected radial base !" <<
'\n' 623 <<
"Base : " << base_r << endl ;
629 for (
int ir=0; ir<mg->
get_nr(idom[irv]); ir++) {
630 *p_out = cheb[fact*ir+par] ;
644 void Gval_spher::initialize_spectral_theta(
const Map& mp,
const Base_val& base,
645 double*& tetlj)
const {
648 const Mg3d* mg = mp.get_mg() ;
650 int ntm = mg->get_nt(0) ;
651 int base_t = base.get_base_t(0) ;
653 assert (tetlj == 0x0) ;
654 tetlj =
new double[(npm+2)*ntv0*ntm] ;
655 double* p_out = tetlj ;
657 for (
int jtv=0; jtv<ntv0; jtv++) {
659 for (
int mpm=0; mpm < npm+2; mpm++) {
660 for (
int ltm=0; ltm<ntm; ltm++) {
663 *p_out =
cos(ltm*teta) ;
667 *p_out =
sin(ltm*teta) ;
671 *p_out =
cos(2*ltm*teta) ;
675 *p_out =
cos((2*ltm+1)*teta) ;
679 *p_out =
sin(2*ltm*teta) ;
683 *p_out =
sin((2*ltm+1)*teta) ;
687 *p_out = ( ((mpm/2) % 2 == 0) ?
cos(2*ltm*teta)
688 :
sin((2*ltm+1)*teta)) ;
692 *p_out = ( ((mpm/2) % 2 == 0) ?
cos((2*ltm+1)*teta)
697 *p_out = ( ((mpm/2) % 2 == 0) ?
sin(2*ltm*teta)
698 :
cos((2*ltm+1)*teta)) ;
702 *p_out = ( ((mpm/2) % 2 == 0) ?
sin((2*ltm+1)*teta)
707 *p_out = ( ((mpm/2) % 2 == 0) ?
cos(ltm*teta)
712 *p_out = ( ((mpm/2) % 2 == 0) ?
sin(ltm*teta)
717 cout <<
"Gval_spher::initialize_spectral_theta : " <<
'\n' 718 <<
"Unexpected theta base !" <<
'\n' 719 <<
"Base : " << base_t << endl ;
738 void Gval_spher::initialize_spectral_phi(
const Map& mp,
const Base_val& base,
739 double*& expmk)
const {
742 const Mg3d* mg = mp.get_mg() ;
743 int npm = mg->get_np(0) ;
744 int base_p = base.get_base_p(0) ;
746 assert (expmk == 0x0) ;
747 expmk =
new double[(npm+2)*npv0] ;
748 double* p_out = expmk ;
750 for (
int kpv=0; kpv<npv0; kpv++) {
752 for (
int mpm=0; mpm < npm+2; mpm++) {
756 *p_out = ( (mpm%2 == 0) ?
cos(m*fi) :
sin(m*fi) ) ;
761 *p_out = ( (mpm%2 == 0) ?
cos(2*m*fi) :
sin(2*m*fi) ) ;
766 *p_out = ( (mpm%2 == 0) ?
cos((2*m+1)*fi) :
sin((2*m+1)*fi) ) ;
770 cout <<
"Gval_spher::initialize_spectral_phi : " <<
'\n' 771 <<
"Unexpected phi base !" <<
'\n' 772 <<
"Base : " << base_p << endl ;
Mtbl_cf * c_cf
Coefficients of the spectral expansion of the function.
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.
#define P_COSSIN
dev. standart
int get_np(int l) const
Returns the number of points in the azimuthal direction ( ) in domain no. l.
void coef() const
Computes the coeffcients of *this.
Cmp sqrt(const Cmp &)
Square root.
#define R_CHEBPI_I
Cheb. pair-impair suivant l impair pour l=0.
const Mg3d * get_mg() const
Gives the Mg3d on which the mapping is defined.
Tensor field of valence 0 (or component of a tensorial field).
Base class for coordinate mappings.
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.
#define T_COS
dev. cos seulement
#define T_COSSIN_SP
sin pair-cos impair alternes, sin pour m=0
int get_etat() const
Returns the logical state ETATNONDEF (undefined), ETATZERO (null) or ETATQCQ (ordinary).
Cmp cos(const Cmp &)
Cosine.
#define T_SIN
dev. sin seulement
int get_base_r(int l) const
Returns the expansion basis for r ( ) functions in the domain of index l (e.g.
#define T_COS_I
dev. cos seulement, harmoniques impaires
#define R_CHEBI
base de Cheb. impaire (rare) seulement
double val_point(int l, double x, double theta, double phi) const
Computes the value of the field represented by *this at an arbitrary point, by means of the spectral ...
#define R_CHEBP
base de Cheb. paire (rare) seulement
Tbl * x
Arrays containing the values of coordinate x on the nodes.
#define T_COS_P
dev. cos seulement, harmoniques paires
#define T_COSSIN_C
dev. cos-sin alternes, cos pour m=0
Tbl * teti
Arrays containing the values of coordinate on the interfaces.
double * t
The array of double.
#define T_SIN_P
dev. sin seulement, harmoniques paires
Tbl * zr
Arrays containing the values of coordinate z (or r) on the nodes.
virtual void somme_spectrale3(const Scalar &meudon, double *t, int taille) const
Same as before but for the 3D case.
int get_nzone() const
Returns the number of domains.
double val_point_jk(int l, double x, int j, int k) const
Computes the value of the field represented by *this at an arbitrary point in , but collocation point...
double * somme_spectrale2ti(const Scalar &meudon) const
Same as before but at angular grid interfaces.
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...
#define T_COSSIN_SI
sin impair-cos pair alternes, sin pour m=0
#define R_CHEBPIM_I
Cheb. pair-impair suivant m, impair pour m=0.
#define R_CHEBPIM_P
Cheb. pair-impair suivant m, pair pour m=0.
Tbl * phi
Arrays containing the values of coordinate on the nodes.
int ndim
Number of dimensions of the Tbl: can be 1, 2 or 3.
int nfantome
The number of hidden cells (same on each side)
int get_nr(int l) const
Returns the number of points in the radial direction ( ) in domain no. l.
Bases of the spectral expansions.
#define R_CHEBPI_P
Cheb. pair-impair suivant l pair pour l=0.
Dim_tbl dim
The dimensions of the grid.
Cmp acos(const Cmp &)
Arccosine.
#define T_COSSIN_CI
cos impair-sin pair alternes, cos pour m=0
Coefficients storage for the multi-domain spectral method.
Cmp sin(const Cmp &)
Sine.
#define P_COSSIN_I
dev. sur Phi = 2*phi, freq. impaires
int get_nt(int l) const
Returns the number of points in the co-latitude direction ( ) in domain no. l.
#define P_COSSIN_P
dev. sur Phi = 2*phi, freq. paires
int get_type_r(int l) const
Returns the type of sampling in the radial direction in domain no.
#define T_COSSIN_CP
cos pair-sin impair alternes, cos pour m=0
const Map & get_mp() const
Returns the mapping.
#define T_SIN_I
dev. sin seulement, harmoniques impaires
virtual void somme_spectrale3(const Scalar &meudon, double *t, int taille) const
Same as before but for the 3D case.
Tbl ** t
Array (size nzone ) of pointers on the Tbl 's which contain the spectral coefficients in each domain...
const Valeur & get_spectral_va() const
Returns va (read only version)
int * dim
Array of dimensions (size: ndim).
#define T_COSSIN_S
dev. cos-sin alternes, sin pour m=0
virtual void val_lx(double rr, double theta, double pphi, int &l, double &xi) const =0
Computes the domain index l and the value of corresponding to a point given by its physical coordina...
const Base_val & get_base() const
Return the bases for spectral expansions (member base )
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...