00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 char regularisation_C[] = "$Header: /cvsroot/Lorene/C++/Source/Isol_hor/regularisation.C,v 1.10 2008/08/19 06:42:00 j_novak Exp $" ;
00025
00026
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
00066
00067
00068
00069
00070
00071
00072
00073 #include <stdlib.h>
00074 #include <math.h>
00075
00076
00077 #include "isol_hor.h"
00078 #include "nbr_spx.h"
00079 #include "tensor.h"
00080
00081 double Isol_hor::regularisation (const Vector& shift_auto_temp,
00082 const Vector& shift_comp_temp, double om) {
00083
00084 Vector shift_auto(shift_auto_temp) ;
00085 shift_auto.change_triad(shift_auto.get_mp().get_bvect_cart()) ;
00086 Vector shift_comp(shift_comp_temp) ;
00087 shift_comp.change_triad(shift_comp.get_mp().get_bvect_cart()) ;
00088 Vector shift_old (shift_auto) ;
00089
00090 double orientation = shift_auto.get_mp().get_rot_phi() ;
00091 assert ((orientation==0) || (orientation == M_PI)) ;
00092 double orientation_autre = shift_comp.get_mp().get_rot_phi() ;
00093 assert ((orientation_autre==0) || (orientation_autre == M_PI)) ;
00094
00095 int alignes = (orientation == orientation_autre) ? 1 : -1 ;
00096
00097 int np = shift_auto.get_mp().get_mg()->get_np(1) ;
00098 int nt = shift_auto.get_mp().get_mg()->get_nt(1) ;
00099 int nr = shift_auto.get_mp().get_mg()->get_nr(1) ;
00100
00101
00102 Vector shift_tot (shift_auto.get_mp(), CON, *shift_auto.get_triad()) ;
00103 shift_tot.set(1).import(alignes*shift_comp(1)) ;
00104 shift_tot.set(2).import(alignes*shift_comp(2)) ;
00105 shift_tot.set(3).import(shift_comp(3)) ;
00106
00107 shift_tot = shift_tot + shift_auto ;
00108
00109 double indic = (orientation == 0) ? 1 : -1 ;
00110
00111 Vector tbi (shift_tot) ;
00112 if (om != 0) {
00113 for (int i=1 ; i<=3 ; i++) {
00114 tbi.set(i).set_spectral_va().coef_i() ;
00115 tbi.set(i).set_spectral_va().set_etat_c_qcq() ;
00116 }
00117
00118 tbi.set(1) = *shift_tot(1).get_spectral_va().c - indic *om * shift_tot.get_mp().ya ;
00119 tbi.set(2) = *shift_tot(2).get_spectral_va().c + indic *om * shift_tot.get_mp().xa ;
00120 tbi.std_spectral_base() ;
00121 tbi.set(1).annule_domain(nz-1) ;
00122 tbi.set(2).annule_domain(nz-1) ;
00123 }
00124
00125 Vector derive_r (shift_auto.get_mp(), CON, *shift_auto.get_triad()) ;
00126 for (int i=1 ; i<=3 ; i++)
00127 derive_r.set(i) = tbi(i).dsdr() ;
00128
00129
00130
00131
00132 Valeur val_hor (shift_auto.get_mp().get_mg()) ;
00133 Valeur fonction_radiale (shift_auto.get_mp().get_mg()) ;
00134 Scalar enleve (shift_auto.get_mp()) ;
00135
00136 double erreur = 0 ;
00137 for (int comp=1 ; comp<=3 ; comp++) {
00138 val_hor.annule_hard() ;
00139 for (int k=0 ; k<np ; k++)
00140 for (int j=0 ; j<nt ; j++)
00141 for (int i=0 ; i<nr ; i++)
00142 val_hor.set(1, k, j, i) = derive_r(comp).
00143 val_grid_point(1, k, j, 0) ;
00144
00145 double r_0 = shift_auto.get_mp().val_r (1, -1, 0, 0) ;
00146 double r_1 = shift_auto.get_mp().val_r (1, 1, 0, 0) ;
00147
00148 fonction_radiale = pow(r_1-shift_auto.get_mp().r, 3.)*
00149 (shift_auto.get_mp().r-r_0)/pow(r_1-r_0, 3.) ;
00150 fonction_radiale.annule(0) ;
00151 fonction_radiale.annule(2, nz-1) ;
00152
00153 enleve = fonction_radiale * val_hor ;
00154 enleve.set_spectral_va().set_base (shift_auto(comp).
00155 get_spectral_va().get_base()) ;
00156
00157 if (norme(enleve)(1) != 0)
00158 shift_auto.set(comp) = shift_auto(comp) - enleve ;
00159 if (norme(shift_auto(comp))(1) > 1e-5) {
00160 Tbl diff (diffrelmax (shift_auto(comp), shift_old(comp))) ;
00161 if (erreur < diff(1))
00162 erreur = diff(1) ;
00163 }
00164 }
00165
00166 shift_auto.change_triad(shift_auto.get_mp().get_bvect_spher()) ;
00167
00168 double ttime = the_time[jtime] ;
00169 beta_auto_evol.update(shift_auto, jtime, ttime) ;
00170
00171 return erreur ;
00172 }
00173
00174
00175
00176 double Isol_hor::regularise_one () {
00177
00178 Vector shift (beta()) ;
00179
00180 shift.change_triad(mp.get_bvect_cart()) ;
00181
00182 Vector tbi (shift) ;
00183
00184 for (int i=1 ; i<=3 ; i++) {
00185 tbi.set(i).set_spectral_va().coef_i() ;
00186 tbi.set(i).set_spectral_va().set_etat_c_qcq() ;
00187 }
00188
00189 for (int i=1 ; i<=3 ; i++)
00190 shift(i).get_spectral_va().coef_i() ;
00191
00192 tbi.set(1) = *shift(1).get_spectral_va().c - omega*mp.y - boost_x ;
00193 tbi.set(2) = *shift(2).get_spectral_va().c + omega*mp.x ;
00194 if (shift(3).get_etat() != ETATZERO)
00195 tbi.set(3) = *shift(3).get_spectral_va().c - boost_z ;
00196 else
00197 tbi.set(3) = 0. ;
00198 tbi.std_spectral_base() ;
00199
00200
00201 tbi.set(1).annule_domain(mp.get_mg()->get_nzone()-1) ;
00202 tbi.set(2).annule_domain(mp.get_mg()->get_nzone()-1) ;
00203
00204 Vector derive_r (mp, CON, mp.get_bvect_cart()) ;
00205 derive_r.set_etat_qcq() ;
00206 for (int i=1 ; i<=3 ; i++)
00207 derive_r.set(i) = tbi(i).dsdr() ;
00208
00209 Valeur val_hor (mp.get_mg()) ;
00210 Valeur fonction_radiale (mp.get_mg()) ;
00211 Scalar enleve (mp) ;
00212
00213 double erreur = 0 ;
00214 int np = mp.get_mg()->get_np(1) ;
00215 int nt = mp.get_mg()->get_nt(1) ;
00216 int nr = mp.get_mg()->get_nr(1) ;
00217
00218 double r_0 = mp.val_r(1, -1, 0, 0) ;
00219 double r_1 = mp.val_r(1, 1, 0, 0) ;
00220
00221 for (int comp=1 ; comp<=3 ; comp++) {
00222 val_hor.annule_hard() ;
00223 for (int k=0 ; k<np ; k++)
00224 for (int j=0 ; j<nt ; j++)
00225 for (int i=0 ; i<nr ; i++)
00226 val_hor.set(1, k, j, i) = derive_r(comp).val_grid_point(1, k, j, 0) ;
00227
00228 fonction_radiale = pow(r_1-mp.r, 3.)* (mp.r-r_0)/pow(r_1-r_0, 3.) ;
00229 fonction_radiale.annule(0) ;
00230 fonction_radiale.annule(2, nz-1) ;
00231
00232 enleve = fonction_radiale*val_hor ;
00233 enleve.set_spectral_va().base = shift(comp).get_spectral_va().base ;
00234
00235 Scalar copie (shift(comp)) ;
00236 shift.set(comp) = shift(comp)-enleve ;
00237 shift.std_spectral_base() ;
00238
00239 assert (shift(comp).check_dzpuis(0)) ;
00240
00241
00242 Tbl norm (norme(shift(comp))) ;
00243 if (norm(1) > 1e-5) {
00244 Tbl diff (diffrelmax (copie, shift(comp))) ;
00245 if (erreur<diff(1))
00246 erreur = diff(1) ;
00247 }
00248 }
00249
00250 shift.change_triad(mp.get_bvect_spher()) ;
00251 beta_evol.update(shift, jtime, the_time[jtime]) ;
00252
00253 return erreur ;
00254 }