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 vector_change_triad_C[] = "$Header: /cvsroot/Lorene/C++/Source/Tensor/vector_change_triad.C,v 1.7 2010/01/26 16:47:10 e_gourgoulhon 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 #include <assert.h>
00064
00065
00066 #include "tensor.h"
00067
00068 void Vector::change_triad(const Base_vect& new_triad) {
00069
00070 assert(triad != 0x0) ;
00071
00072 const Base_vect_cart* nbvc = dynamic_cast<const Base_vect_cart*>(&new_triad) ;
00073 #ifndef NDEBUG
00074 const Base_vect_spher* nbvs
00075 = dynamic_cast<const Base_vect_spher*>(&new_triad) ;
00076 #endif
00077
00078 assert((nbvc != 0x0) || (nbvs != 0x0)) ;
00079
00080 const Base_vect_cart* bvc = dynamic_cast<const Base_vect_cart*>(triad) ;
00081 const Base_vect_spher* bvs = dynamic_cast<const Base_vect_spher*>(triad) ;
00082
00083 assert((bvc != 0x0) || (bvs != 0x0)) ;
00084
00085
00086
00087
00088 if (nbvc != 0x0) {
00089 assert(nbvs == 0x0) ;
00090
00091
00092
00093
00094 if (bvc != 0x0) {
00095 assert(bvs == 0x0) ;
00096
00097 int ind = nbvc->get_align() * (bvc->get_align()) ;
00098
00099 switch (ind) {
00100
00101 case 1 : {
00102
00103 break ;
00104 }
00105
00106 case - 1 : {
00107 Vector copie (*this) ;
00108
00109 set(1) = - copie(1) ;
00110 set(2) = - copie(2) ;
00111
00112 break ;
00113 }
00114
00115 case 0 : {
00116
00117 cout <<
00118 "Vector::change_basis : general value of rot_phi "
00119 << " not contemplated yet, sorry !" << endl ;
00120 abort() ;
00121 break ;
00122 }
00123
00124 default : {
00125 cout <<
00126 "Vector::change_basis : unexpected value of ind !" << endl ;
00127 cout << " ind = " << ind << endl ;
00128 abort() ;
00129 break ;
00130 }
00131 }
00132
00133 }
00134
00135
00136
00137
00138
00139 if (bvs != 0x0) {
00140
00141 assert(bvc == 0x0) ;
00142
00143
00144
00145 assert( *nbvc == mp->get_bvect_cart() ) ;
00146 assert( *bvs == mp->get_bvect_spher() ) ;
00147 #ifndef NDEBUG
00148 int nz = mp->get_mg()->get_nzone() ;
00149 for (int i=0; i<nz; i++) {
00150
00151 assert( mp->get_mg()->get_nt(i) >= 5) ;
00152 }
00153 #endif
00154 Scalar res1(*mp) ;
00155 Scalar res2(*mp) ;
00156
00157 mp->comp_x_from_spherical(*cmp[0], *cmp[1], *cmp[2], res1) ;
00158 mp->comp_y_from_spherical(*cmp[0], *cmp[1], *cmp[2], res2) ;
00159 mp->comp_z_from_spherical(*cmp[0], *cmp[1], set(3)) ;
00160
00161 set(1) = res1 ;
00162 set(2) = res2 ;
00163
00164 }
00165 }
00166
00167
00168
00169
00170 else {
00171
00172 assert(nbvc == 0x0) ;
00173
00174
00175
00176
00177 if (bvc != 0x0) {
00178 assert(bvs == 0x0) ;
00179
00180
00181
00182 assert( *nbvs == mp->get_bvect_spher() ) ;
00183 assert( *bvc == mp->get_bvect_cart() ) ;
00184 #ifndef NDEBUG
00185 int nz = mp->get_mg()->get_nzone() ;
00186 for (int i=0; i<nz; i++) {
00187
00188 assert( mp->get_mg()->get_nt(i) >= 5) ;
00189 }
00190 #endif
00191 Scalar res1(*mp) ;
00192 Scalar res2(*mp) ;
00193
00194 mp->comp_r_from_cartesian(*cmp[0], *cmp[1], *cmp[2], res1) ;
00195 mp->comp_t_from_cartesian(*cmp[0], *cmp[1], *cmp[2], res2) ;
00196 mp->comp_p_from_cartesian(*cmp[0], *cmp[1], set(3)) ;
00197
00198 set(1) = res1 ;
00199 set(2) = res2 ;
00200 }
00201
00202
00203
00204
00205
00206 if (bvs != 0x0) {
00207
00208 assert(bvc == 0x0) ;
00209
00210 cout << "Vector::change_triad : case not treated yet !" << endl ;
00211 abort() ;
00212 }
00213
00214 }
00215
00216 triad = &new_triad ;
00217
00218 }