00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 char tensor_change_triad_C[] = "$Header: /cvsroot/Lorene/C++/Source/Tensor/tensor_change_triad.C,v 1.7 2005/09/15 15:51:26 j_novak Exp $" ;
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 #include <assert.h>
00066
00067
00068 #include "tensor.h"
00069
00070 void Tensor::change_triad(const Base_vect& new_triad) {
00071
00072 assert (valence == 2) ;
00073 assert(triad != 0x0) ;
00074
00075 const Base_vect_cart* nbvc = dynamic_cast<const Base_vect_cart*>(&new_triad) ;
00076 #ifndef NDEBUG
00077 const Base_vect_spher* nbvs
00078 = dynamic_cast<const Base_vect_spher*>(&new_triad) ;
00079 #endif
00080
00081 assert((nbvc != 0x0) || (nbvs != 0x0)) ;
00082
00083 const Base_vect_cart* bvc = dynamic_cast<const Base_vect_cart*>(triad) ;
00084 const Base_vect_spher* bvs = dynamic_cast<const Base_vect_spher*>(triad) ;
00085
00086 assert((bvc != 0x0) || (bvs != 0x0)) ;
00087
00088
00089
00090
00091 if (nbvc != 0x0) {
00092 assert(nbvs == 0x0) ;
00093
00094
00095
00096
00097 if (bvc != 0x0) {
00098 assert(bvs == 0x0) ;
00099
00100 int ind = nbvc->get_align() * (bvc->get_align()) ;
00101
00102 switch (ind) {
00103
00104 case 1 : {
00105
00106
00107 break ;
00108 }
00109
00110 case - 1 : {
00111
00112
00113 Tensor copie (*this) ;
00114
00115 set(1, 3) = - copie(1, 3) ;
00116 set(2, 3) = - copie(2, 3) ;
00117 set(3, 1) = - copie(3, 1) ;
00118 set(3, 2) = - copie(3, 2) ;
00119
00120 break ;
00121 }
00122 case 0 : {
00123
00124 cout <<
00125 "Tensor::change_basis : general value of rot_phi "
00126 << " not contemplated yet, sorry !" << endl ;
00127 abort() ;
00128 break ;
00129 }
00130
00131 default : {
00132 cout <<
00133 "Tensor::change_basis : unexpected value of ind !" << endl ;
00134 cout << " ind = " << ind << endl ;
00135 abort() ;
00136 break ;
00137 }
00138 }
00139
00140 }
00141
00142
00143
00144
00145
00146 if (bvs != 0x0) {
00147
00148 assert(bvc == 0x0) ;
00149
00150
00151
00152 assert( *nbvc == mp->get_bvect_cart() ) ;
00153 assert( *bvs == mp->get_bvect_spher() ) ;
00154
00155
00156 assert( ( (type_indice(0)==COV) && (type_indice(1)==COV) ) ||
00157 ( (type_indice(0)==CON) && (type_indice(1)==CON) ) ) ;
00158 #ifndef NDEBUG
00159 int nz = mp->get_mg()->get_nzone() ;
00160 for (int i=0; i<nz; i++) {
00161 assert( mp->get_mg()->get_np(i) >= 4) ;
00162 assert( mp->get_mg()->get_nt(i) >= 5) ;
00163 }
00164 #endif
00165
00166
00167 Tensor tmp(*mp, 2, COV, *triad) ;
00168 for (int i=1; i<=3; i++) {
00169 mp->comp_x_from_spherical(operator()(1,i), operator()(2,i),
00170 operator()(3,i), tmp.set(1,i)) ;
00171 mp->comp_y_from_spherical(operator()(1,i), operator()(2,i),
00172 operator()(3,i), tmp.set(2,i)) ;
00173 mp->comp_z_from_spherical(operator()(1,i), operator()(2,i), tmp.set(3,i) ) ;
00174 }
00175 for (int i=1; i<=3; i++) {
00176 mp->comp_x_from_spherical(tmp(i,1), tmp(i,2), tmp(i,3), set(i,1)) ;
00177 mp->comp_y_from_spherical(tmp(i,1), tmp(i,2), tmp(i,3), set(i,2)) ;
00178 mp->comp_z_from_spherical(tmp(i,1), tmp(i,2), set(i,3)) ;
00179 }
00180
00181 }
00182 }
00183
00184
00185
00186
00187 else {
00188
00189 assert(nbvc == 0x0) ;
00190
00191
00192
00193
00194 if (bvc != 0x0) {
00195 assert(bvs == 0x0) ;
00196
00197
00198
00199 assert( *nbvs == mp->get_bvect_spher() ) ;
00200 assert( *bvc == mp->get_bvect_cart() ) ;
00201
00202
00203 assert( ( (type_indice(0)==COV) && (type_indice(1)==COV) ) ||
00204 ( (type_indice(0)==CON) && (type_indice(1)==CON) ) ) ;
00205 #ifndef NDEBUG
00206 int nz = mp->get_mg()->get_nzone() ;
00207 for (int i=0; i<nz; i++) {
00208 assert( mp->get_mg()->get_np(i) >= 4) ;
00209 assert( mp->get_mg()->get_nt(i) >= 5) ;
00210 }
00211 #endif
00212
00213
00214 Tensor tmp(*mp, 2, COV, *triad) ;
00215 for (int i=1; i<=3; i++) {
00216 mp->comp_r_from_cartesian(operator()(1,i), operator()(2,i),
00217 operator()(3,i), tmp.set(1,i)) ;
00218 mp->comp_t_from_cartesian(operator()(1,i), operator()(2,i),
00219 operator()(3,i), tmp.set(2,i)) ;
00220 mp->comp_p_from_cartesian(operator()(1,i), operator()(2,i), tmp.set(3,i)) ;
00221 }
00222 for (int i=1; i<=3; i++) {
00223 mp->comp_r_from_cartesian(tmp(i,1), tmp(i,2), tmp(i,3), set(i,1)) ;
00224 mp->comp_t_from_cartesian(tmp(i,1), tmp(i,2), tmp(i,3), set(i,2)) ;
00225 mp->comp_p_from_cartesian(tmp(i,1), tmp(i,2), set(i,3)) ;
00226 }
00227 }
00228
00229
00230
00231
00232
00233 if (bvs != 0x0) {
00234
00235 assert(bvc == 0x0) ;
00236
00237 cout << "Tensor::change_triad : case not treated yet !" << endl ;
00238 abort() ;
00239 }
00240
00241 }
00242
00243 triad = &new_triad ;
00244
00245 }