20 #include "headcpp.hpp"
22 #include "spheric.hpp"
24 #include "tensor_impl.hpp"
37 double fact_t, fact_r, fact_rt ;
44 assert (baset==COS_EVEN) ;
45 for (
int j=0 ; j<2 ; j++) {
48 assert ((baser==CHEB_ODD) || (baser==LEG_ODD)) ;
51 so.
cf->
set(pos_cf) += values(conte) ;
61 assert (baset==COS_EVEN) ;
65 assert ((baser==CHEB_ODD) || (baser==LEG_ODD)) ;
69 pos_gal_r.
set(0) = 0 ;
72 fact_r = - (2*i+1) * pow(-1, i) ;
76 for (
int t=0 ; t<i ; t++)
77 fact_r *= -
double(2*t+3)/double(2*t+2) ;
81 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain_cart" << endl ;
84 so.
cf->
set(pos_cf) += values(conte) ;
85 so.
cf->
set(pos_gal_r) += fact_r*values(conte) ;
97 int mquant = (k%2==0) ?
int(k/2) : int((k-1)/2) ;
102 assert (baset=COS_EVEN) ;
106 assert ((baser==CHEB_ODD) || (baser==LEG_ODD)) ;
110 pos_gal_r.
set(0) = 0 ;
112 pos_gal_t.
set(1) = 0 ;
113 pos_gal_rt = pos_cf ;
114 pos_gal_rt.
set(0) = 0 ;
115 pos_gal_rt.
set(1) = 0 ;
118 fact_r = -pow(-1, i)*(2*i+1) ;
120 fact_rt = pow(-1, i)*(2*i+1) ;
124 for (
int t=0 ; t<i ; t++)
125 l0 *= -
double(2*t+3)/double(2*t+2) ;
132 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain_cart" << endl ;
136 so.
cf->
set(pos_cf) += values(conte) ;
137 so.
cf->
set(pos_gal_r) += fact_r*values(conte) ;
138 so.
cf->
set(pos_gal_t) += fact_t*values(conte) ;
139 so.
cf->
set(pos_gal_rt) += fact_rt*values(conte) ;
146 assert (baset=SIN_ODD) ;
150 assert ((baser==CHEB_EVEN) || (baser==LEG_EVEN)) ;
154 pos_gal_r.
set(0) = 0 ;
157 fact_r = - pow(-1, i) ;
161 for (
int t=0 ; t<i ; t++)
162 fact_r *= -
double(2*t+1)/double(2*t+2) ;
166 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain_vr" << endl ;
170 so.
cf->
set(pos_cf) += values(conte) ;
171 so.
cf->
set(pos_gal_r) += fact_r*values(conte) ;
190 double fact_t, fact_r, fact_rt ;
197 assert (baset==SIN_EVEN) ;
201 assert ((baser==CHEB_ODD) || (baser==LEG_ODD)) ;
205 pos_gal_r.
set(0) = 0 ;
208 fact_r = - (2*i+1) * pow(-1, i) ;
212 for (
int t=0 ; t<i ; t++)
213 fact_r *= -
double(2*t+3)/double(2*t+2) ;
217 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain_vt" << endl ;
220 so.
cf->
set(pos_cf) += values(conte) ;
221 so.
cf->
set(pos_gal_r) += fact_r*values(conte) ;
233 assert (baset==COS_ODD) ;
236 assert ((baser==CHEB_EVEN) || (baser==LEG_EVEN)) ;
239 so.
cf->
set(pos_cf) += values(conte) ;
249 assert (baset=COS_ODD) ;
253 assert ((baser==CHEB_EVEN) || (baser==LEG_EVEN)) ;
257 pos_gal_r.
set(0) = 0 ;
260 fact_r = - pow(-1, i) ;
264 for (
int t=0 ; t<i ; t++)
265 fact_r *= -
double(2*t+1)/double(2*t+2) ;
269 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain_vt" << endl ;
273 so.
cf->
set(pos_cf) += values(conte) ;
274 so.
cf->
set(pos_gal_r) += fact_r*values(conte) ;
286 assert (baset==COS_ODD) ;
289 assert ((baser==CHEB_EVEN) || (baser==LEG_EVEN)) ;
292 so.
cf->
set(pos_cf) += values(conte) ;
302 assert (baset=COS_ODD) ;
306 assert ((baser==CHEB_EVEN) || (baser==LEG_EVEN)) ;
310 pos_gal_r.
set(0) = 0 ;
313 fact_r = - pow(-1, i) ;
317 for (
int t=0 ; t<i ; t++)
318 fact_r *= -
double(2*t+1)/double(2*t+2) ;
322 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain_vt" << endl ;
326 so.
cf->
set(pos_cf) += values(conte) ;
327 so.
cf->
set(pos_gal_r) += fact_r*values(conte) ;
338 int mquant = (k%2==0) ?
int(k/2) : int((k-1)/2) ;
343 assert (baset=SIN_EVEN) ;
347 assert ((baser==CHEB_ODD) || (baser==LEG_ODD)) ;
351 pos_gal_r.
set(0) = 0 ;
354 fact_r = - (2*i+1) * pow(-1, i) ;
358 for (
int t=0 ; t<i ; t++)
359 fact_r *= -
double(2*t+3)/double(2*t+2) ;
363 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain_vt" << endl ;
366 so.
cf->
set(pos_cf) += values(conte) ;
367 so.
cf->
set(pos_gal_r) += fact_r*values(conte) ;
374 assert (baset=COS_ODD) ;
378 assert ((baser==CHEB_EVEN) || (baser==LEG_EVEN)) ;
382 pos_gal_r.
set(0) = 0 ;
384 pos_gal_t.
set(1) = 0 ;
385 pos_gal_rt = pos_cf ;
386 pos_gal_rt.
set(0) = 0 ;
387 pos_gal_rt.
set(1) = 0 ;
390 fact_r = -pow(-1, i) ;
392 fact_rt = pow(-1, i) ;
396 for (
int t=0 ; t<i ; t++)
397 l0 *= -
double(2*t+1)/double(2*t+2) ;
404 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain_vt" << endl ;
407 so.
cf->
set(pos_cf) += values(conte) ;
408 so.
cf->
set(pos_gal_r) += fact_r*values(conte) ;
409 so.
cf->
set(pos_gal_t) += fact_t*values(conte) ;
410 so.
cf->
set(pos_gal_rt) += fact_rt*values(conte) ;
429 double fact_t, fact_r, fact_rt ;
435 assert (baset==SIN_ODD) ;
438 assert ((baser==CHEB_ODD) || (baser==LEG_ODD)) ;
441 so.
cf->
set(pos_cf) += values(conte) ;
450 assert (baset=SIN_ODD) ;
454 assert ((baser==CHEB_ODD) || (baser==LEG_ODD)) ;
458 pos_gal_r.
set(0) = 0 ;
461 fact_r = - (2*i+1) * pow(-1, i) ;
465 for (
int t=0 ; t<i ; t++)
466 fact_r *= -
double(2*t+3)/double(2*t+2) ;
470 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain_vp" << endl ;
473 so.
cf->
set(pos_cf) += values(conte) ;
474 so.
cf->
set(pos_gal_r) += fact_r*values(conte) ;
486 assert (baset==COS_EVEN) ;
489 assert ((baser==CHEB_EVEN) || (baser==LEG_EVEN)) ;
492 so.
cf->
set(pos_cf) += values(conte) ;
502 assert (baset=COS_EVEN) ;
506 assert ((baser==CHEB_EVEN) || (baser==LEG_EVEN)) ;
510 pos_gal_r.
set(0) = 0 ;
513 fact_r = - pow(-1, i) ;
517 for (
int t=0 ; t<i ; t++)
518 fact_r *= -
double(2*t+1)/double(2*t+2) ;
522 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain_vp" << endl ;
526 so.
cf->
set(pos_cf) += values(conte) ;
527 so.
cf->
set(pos_gal_r) += fact_r*values(conte) ;
539 assert (baset==COS_EVEN) ;
542 assert ((baser==CHEB_EVEN) || (baser==LEG_EVEN)) ;
545 so.
cf->
set(pos_cf) += values(conte) ;
555 assert (baset=COS_EVEN) ;
559 assert ((baser==CHEB_EVEN) || (baser==LEG_EVEN)) ;
563 pos_gal_r.
set(0) = 0 ;
566 fact_r = - pow(-1, i) ;
570 for (
int t=0 ; t<i ; t++)
571 fact_r *= -
double(2*t+1)/double(2*t+2) ;
575 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain_vp" << endl ;
579 so.
cf->
set(pos_cf) += values(conte) ;
580 so.
cf->
set(pos_gal_r) += fact_r*values(conte) ;
590 assert (baset==SIN_ODD) ;
593 assert ((baser==CHEB_ODD) || (baser==LEG_ODD)) ;
596 so.
cf->
set(pos_cf) += values(conte) ;
606 assert (baset=SIN_ODD) ;
610 assert ((baser==CHEB_ODD) || (baser==LEG_ODD)) ;
614 pos_gal_r.
set(0) = 0 ;
617 fact_r = - (2*i+1) * pow(-1, i) ;
621 for (
int t=0 ; t<i ; t++)
622 fact_r *= -
double(2*t+3)/double(2*t+2) ;
626 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain_vp" << endl ;
629 so.
cf->
set(pos_cf) += values(conte) ;
630 so.
cf->
set(pos_gal_r) += fact_r*values(conte) ;
641 assert (baset==SIN_ODD) ;
644 assert ((baser==CHEB_ODD) || (baser==LEG_ODD)) ;
647 so.
cf->
set(pos_cf) += values(conte) ;
657 assert (baset=SIN_ODD) ;
661 assert ((baser==CHEB_ODD) || (baser==LEG_ODD)) ;
665 pos_gal_r.
set(0) = 0 ;
668 fact_r = - (2*i+1) * pow(-1, i) ;
672 for (
int t=0 ; t<i ; t++)
673 fact_r *= -
double(2*t+3)/double(2*t+2) ;
677 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain_vp" << endl ;
680 so.
cf->
set(pos_cf) += values(conte) ;
681 so.
cf->
set(pos_gal_r) += fact_r*values(conte) ;
691 int mquant = (k%2==0) ?
int(k/2) : int((k-1)/2) ;
696 assert (baset=SIN_ODD) ;
700 assert ((baser==CHEB_ODD) || (baser==LEG_ODD)) ;
704 pos_gal_r.
set(0) = 0 ;
707 fact_r = - (2*i+1) * pow(-1, i) ;
711 for (
int t=0 ; t<i ; t++)
712 fact_r *= -
double(2*t+3)/double(2*t+2) ;
716 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain_vp" << endl ;
719 so.
cf->
set(pos_cf) += values(conte) ;
720 so.
cf->
set(pos_gal_r) += fact_r*values(conte) ;
727 assert (baset=COS_EVEN) ;
731 assert ((baser==CHEB_EVEN) || (baser==LEG_EVEN)) ;
735 pos_gal_r.
set(0) = 0 ;
737 pos_gal_t.
set(1) = 0 ;
738 pos_gal_rt = pos_cf ;
739 pos_gal_rt.
set(0) = 0 ;
740 pos_gal_rt.
set(1) = 0 ;
743 fact_r = -pow(-1, i) ;
745 fact_rt = pow(-1, i) ;
749 for (
int t=0 ; t<i ; t++)
750 l0 *= -
double(2*t+1)/double(2*t+2) ;
757 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain_vp" << endl ;
760 so.
cf->
set(pos_cf) += values(conte) ;
761 so.
cf->
set(pos_gal_r) += fact_r*values(conte) ;
762 so.
cf->
set(pos_gal_t) += fact_t*values(conte) ;
763 so.
cf->
set(pos_gal_rt) += fact_rt*values(conte) ;
773 int kmin = 2*mlim+2 ;
784 double fact_t, fact_r, fact_rt ;
802 if ((k<kmin) && (lquant<=llim)) {
803 so.
cf->
set(pos_cf) += values(conte) ;
810 pos_gal_r.
set(0) = 0 ;
813 fact_r = - pow(-1, i) ;
817 for (
int t=0 ; t<i ; t++)
818 fact_r *= -
double(2*t+1)/double(2*t+2) ;
822 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain" << endl ;
826 so.
cf->
set(pos_cf) += values(conte) ;
827 so.
cf->
set(pos_gal_r) += fact_r*values(conte) ;
831 else if ((j!=0) && (i!=0)) {
834 pos_gal_r.
set(0) = 0 ;
836 pos_gal_t.
set(1) = 0 ;
837 pos_gal_rt = pos_cf ;
838 pos_gal_rt.
set(0) = 0 ;
839 pos_gal_rt.
set(1) = 0 ;
842 fact_r = -pow(-1, i) ;
844 fact_rt = pow(-1, i) ;
848 for (
int t=0 ; t<i ; t++)
849 l0 *= -
double(2*t+1)/double(2*t+2) ;
856 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain" << endl ;
859 so.
cf->
set(pos_cf) += values(conte) ;
860 so.
cf->
set(pos_gal_r) += fact_r*values(conte) ;
861 so.
cf->
set(pos_gal_t) += fact_t*values(conte) ;
862 so.
cf->
set(pos_gal_rt) += fact_rt*values(conte) ;
869 if ((k<kmin) && (lquant<=llim+1)) {
870 so.
cf->
set(pos_cf) += values(conte) ;
874 if ((k<kmin) && (i!=0)) {
876 pos_gal_r.
set(0) = 0 ;
879 fact_r = - (2*i+1) * pow(-1, i) ;
883 for (
int t=0 ; t<i ; t++)
884 fact_r *= -
double(2*t+3)/double(2*t+2) ;
888 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain" << endl ;
891 so.
cf->
set(pos_cf) += values(conte) ;
892 so.
cf->
set(pos_gal_r) += fact_r*values(conte) ;
895 else if ((j!=0) && (i!=0)) {
898 pos_gal_r.
set(0) = 0 ;
900 pos_gal_t.
set(1) = 0 ;
901 pos_gal_rt = pos_cf ;
902 pos_gal_rt.
set(0) = 0 ;
903 pos_gal_rt.
set(1) = 0 ;
906 fact_r = -pow(-1, i)*(2*i+1) ;
908 fact_rt = pow(-1, i)*(2*i+1) ;
912 for (
int t=0 ; t<i ; t++)
913 l0 *= -
double(2*t+3)/double(2*t+2) ;
920 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain" << endl ;
923 so.
cf->
set(pos_cf) += values(conte) ;
924 so.
cf->
set(pos_gal_r) += fact_r*values(conte) ;
925 so.
cf->
set(pos_gal_t) += fact_t*values(conte) ;
926 so.
cf->
set(pos_gal_rt) += fact_rt*values(conte) ;
935 if ((k<kmin+2) && (lquant<=llim)) {
936 so.
cf->
set(pos_cf) += values(conte) ;
940 if ((k<kmin+2) && (i!=0)) {
943 pos_gal_r.
set(0) = 0 ;
946 fact_r = - pow(-1, i) ;
950 for (
int t=0 ; t<i ; t++)
951 fact_r *= -
double(2*t+1)/double(2*t+2) ;
955 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain" << endl ;
958 so.
cf->
set(pos_cf) += values(conte) ;
959 so.
cf->
set(pos_gal_r) += fact_r*values(conte) ;
964 if ((j!=1) && (i!=0)) {
967 pos_gal_r.
set(0) = 0 ;
969 pos_gal_t.
set(1) = 1 ;
970 pos_gal_rt = pos_cf ;
971 pos_gal_rt.
set(0) = 0 ;
972 pos_gal_rt.
set(1) = 1 ;
975 fact_r = -pow(-1, i) ;
977 fact_rt = pow(-1, i)*j ;
981 for (
int t=0 ; t<i ; t++)
982 l0 *= -
double(2*t+1)/double(2*t+2) ;
989 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain" << endl ;
992 so.
cf->
set(pos_cf) += values(conte) ;
993 so.
cf->
set(pos_gal_r) += fact_r*values(conte) ;
994 so.
cf->
set(pos_gal_t) += fact_t*values(conte) ;
995 so.
cf->
set(pos_gal_rt) += fact_rt*values(conte) ;
1004 if ((k<kmin+2) && (lquant<=llim+1)) {
1005 so.
cf->
set(pos_cf) += values(conte) ;
1009 if ((k<kmin+2) && (i!=0)) {
1010 pos_gal_r = pos_cf ;
1011 pos_gal_r.
set(0) = 0 ;
1014 fact_r = - (2*i+1) * pow(-1, i) ;
1018 for (
int t=0 ; t<i ; t++)
1019 fact_r *= -
double(2*t+3)/double(2*t+2) ;
1023 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain" << endl ;
1026 so.
cf->
set(pos_cf) += values(conte) ;
1027 so.
cf->
set(pos_gal_r) += fact_r*values(conte) ;
1030 else if ((j!=0) && (i!=0)) {
1032 pos_gal_r = pos_cf ;
1033 pos_gal_r.
set(0) = 0 ;
1034 pos_gal_t = pos_cf ;
1035 pos_gal_t.
set(1) = 0 ;
1036 pos_gal_rt = pos_cf ;
1037 pos_gal_rt.
set(0) = 0 ;
1038 pos_gal_rt.
set(1) = 0 ;
1041 fact_r = -pow(-1, i)*(2*i+1) ;
1043 fact_rt = pow(-1, i)*(2*i+1)*(2*j+1) ;
1047 for (
int t=0 ; t<i ; t++)
1048 l0 *= -
double(2*t+3)/double(2*t+2) ;
1051 fact_rt = l0*(2*j+1) ;
1055 cerr <<
"Strange base in Domain_nucleus::affecte_tau_val_domain" << endl ;
1058 so.
cf->
set(pos_cf) += values(conte) ;
1059 so.
cf->
set(pos_gal_r) += fact_r*values(conte) ;
1060 so.
cf->
set(pos_gal_t) += fact_t*values(conte) ;
1061 so.
cf->
set(pos_gal_rt) += fact_rt*values(conte) ;
1068 cerr <<
"Unknow theta basis in Domain_nucleus::affecte_tau_val_domain" << endl ;
1087 bool found = false ;
1103 cerr <<
"Unknown type of vector Domain_nucleus::affecte_tau" << endl ;
1109 bool found = false ;
1134 cerr <<
"Unknown type of 2-tensor Domain_nucleus::affecte_tau" << endl ;
1140 cerr <<
"Valence " << val <<
" not implemented in Domain_nucleus::affecte_tau" << endl ;
reference set(const Index &pos)
Read/write of an element.
Bases_container bases_1d
Arrays containing the various basis of decomposition.
int get_basis(int nd) const
Read only the basis in a given domain.
virtual void affecte_tau(Tensor &, int, const Array< double > &, int &) const
Affects some coefficients to a Tensor.
void affecte_tau_val_domain_vp(Val_domain &so, const Array< double > &cf, int &pos_cf) const
Affects some coefficients to a Val_domain.
void affecte_tau_val_domain_vt(Val_domain &so, const Array< double > &cf, int &pos_cf) const
Affects some coefficients to a Val_domain.
void affecte_tau_val_domain_vr(Val_domain &so, const Array< double > &cf, int &pos_cf) const
Affects some coefficients to a Val_domain.
void affecte_tau_val_domain(Val_domain &so, int mlim, int llim, const Array< double > &cf, int &pos_cf) const
Affects some coefficients to a Val_domain.
Dim_array nbr_coefs
Number of coefficients.
Class that gives the position inside a multi-dimensional Array.
int & set(int i)
Read/write of the position in a given dimension.
Val_domain & set_domain(int)
Read/write of a particular Val_domain.
const Domain * get_domain(int i) const
returns a pointer on the domain.
Scalar & set(const Array< int > &ind)
Returns the value of a component (read/write version).
const Base_tensor & get_basis() const
Returns the vectorial basis (triad) on which the components are defined.
int get_n_comp() const
Returns the number of stored components.
int get_valence() const
Returns the valence.
const Space & get_space() const
Returns the Space.
Class for storing the basis of decompositions of a field and its values on both the configuration and...
void allocate_coef()
Allocates the values in the coefficient space and destroys the values in the configuration space.
Array< double > * cf
Pointer on the Array of the values in the coefficients space.
const Base_spectral & get_base() const
Returns the basis of decomposition.