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 single_regul_C[] = "$Header: /cvsroot/Lorene/C++/Source/Isol_hor/single_regul.C,v 1.2 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 #include <stdlib.h>
00045 #include <math.h>
00046
00047
00048 #include "isol_hor.h"
00049 #include "nbr_spx.h"
00050 #include "tensor.h"
00051
00052 double Single_hor::regularisation (const Vector& shift_auto_temp,
00053 const Vector& shift_comp_temp, double om) {
00054
00055 Vector shift_auto(shift_auto_temp) ;
00056 shift_auto.change_triad(shift_auto.get_mp().get_bvect_cart()) ;
00057 Vector shift_comp(shift_comp_temp) ;
00058 shift_comp.change_triad(shift_comp.get_mp().get_bvect_cart()) ;
00059 Vector shift_old (shift_auto) ;
00060
00061 double orientation = shift_auto.get_mp().get_rot_phi() ;
00062 assert ((orientation==0) || (orientation == M_PI)) ;
00063 double orientation_autre = shift_comp.get_mp().get_rot_phi() ;
00064 assert ((orientation_autre==0) || (orientation_autre == M_PI)) ;
00065
00066 int alignes = (orientation == orientation_autre) ? 1 : -1 ;
00067
00068 int np = shift_auto.get_mp().get_mg()->get_np(1) ;
00069 int nt = shift_auto.get_mp().get_mg()->get_nt(1) ;
00070 int nr = shift_auto.get_mp().get_mg()->get_nr(1) ;
00071
00072
00073 Vector shift_tot (shift_auto.get_mp(), CON, *shift_auto.get_triad()) ;
00074 shift_tot.set(1).import(alignes*shift_comp(1)) ;
00075 shift_tot.set(2).import(alignes*shift_comp(2)) ;
00076 shift_tot.set(3).import(shift_comp(3)) ;
00077
00078 shift_tot = shift_tot + shift_auto ;
00079
00080 double indic = (orientation == 0) ? 1 : -1 ;
00081
00082 Vector tbi (shift_tot) ;
00083 if (om != 0) {
00084 for (int i=1 ; i<=3 ; i++) {
00085 tbi.set(i).set_spectral_va().coef_i() ;
00086 tbi.set(i).set_spectral_va().set_etat_c_qcq() ;
00087 }
00088
00089 tbi.set(1) = *shift_tot(1).get_spectral_va().c - indic *om * shift_tot.get_mp().ya ;
00090 tbi.set(2) = *shift_tot(2).get_spectral_va().c + indic *om * shift_tot.get_mp().xa ;
00091 tbi.std_spectral_base() ;
00092 tbi.set(1).annule_domain(nz-1) ;
00093 tbi.set(2).annule_domain(nz-1) ;
00094 }
00095
00096 Vector derive_r (shift_auto.get_mp(), CON, *shift_auto.get_triad()) ;
00097 for (int i=1 ; i<=3 ; i++)
00098 derive_r.set(i) = tbi(i).dsdr() ;
00099
00100
00101
00102
00103 Valeur val_hor (shift_auto.get_mp().get_mg()) ;
00104 Valeur fonction_radiale (shift_auto.get_mp().get_mg()) ;
00105 Scalar enleve (shift_auto.get_mp()) ;
00106
00107 double erreur = 0 ;
00108 for (int comp=1 ; comp<=3 ; comp++) {
00109 val_hor.annule_hard() ;
00110 for (int k=0 ; k<np ; k++)
00111 for (int j=0 ; j<nt ; j++)
00112 for (int i=0 ; i<nr ; i++)
00113 val_hor.set(1, k, j, i) = derive_r(comp).
00114 val_grid_point(1, k, j, 0) ;
00115
00116 double r_0 = shift_auto.get_mp().val_r (1, -1, 0, 0) ;
00117 double r_1 = shift_auto.get_mp().val_r (1, 1, 0, 0) ;
00118
00119 fonction_radiale = pow(r_1-shift_auto.get_mp().r, 3.)*
00120 (shift_auto.get_mp().r-r_0)/pow(r_1-r_0, 3.) ;
00121 fonction_radiale.annule(0) ;
00122 fonction_radiale.annule(2, nz-1) ;
00123
00124 enleve = fonction_radiale * val_hor ;
00125 enleve.set_spectral_va().set_base (shift_auto(comp).
00126 get_spectral_va().get_base()) ;
00127
00128 if (norme(enleve)(1) != 0)
00129 shift_auto.set(comp) = shift_auto(comp) - enleve ;
00130 if (norme(shift_auto(comp))(1) > 1e-5) {
00131 Tbl diff (diffrelmax (shift_auto(comp), shift_old(comp))) ;
00132 if (erreur < diff(1))
00133 erreur = diff(1) ;
00134 }
00135 }
00136
00137 shift_auto.change_triad(shift_auto.get_mp().get_bvect_spher()) ;
00138
00139 beta_auto = shift_auto ;
00140
00141 return erreur ;
00142 }
00143
00144
00145
00146 double Single_hor::regularise_one () {
00147
00148 Vector shift (beta) ;
00149
00150 shift.change_triad(mp.get_bvect_cart()) ;
00151
00152 Vector tbi (shift) ;
00153
00154 for (int i=1 ; i<=3 ; i++) {
00155 tbi.set(i).set_spectral_va().coef_i() ;
00156 tbi.set(i).set_spectral_va().set_etat_c_qcq() ;
00157 }
00158
00159 for (int i=1 ; i<=3 ; i++)
00160 shift(i).get_spectral_va().coef_i() ;
00161
00162 tbi.set(1) = *shift(1).get_spectral_va().c - omega*mp.y ;
00163 tbi.set(2) = *shift(2).get_spectral_va().c + omega*mp.x ;
00164 if (shift(3).get_etat() != ETATZERO)
00165 tbi.set(3) = *shift(3).get_spectral_va().c ;
00166 else
00167 tbi.set(3) = 0. ;
00168 tbi.std_spectral_base() ;
00169
00170
00171 tbi.set(1).annule_domain(mp.get_mg()->get_nzone()-1) ;
00172 tbi.set(2).annule_domain(mp.get_mg()->get_nzone()-1) ;
00173
00174 Vector derive_r (mp, CON, mp.get_bvect_cart()) ;
00175 derive_r.set_etat_qcq() ;
00176 for (int i=1 ; i<=3 ; i++)
00177 derive_r.set(i) = tbi(i).dsdr() ;
00178
00179 Valeur val_hor (mp.get_mg()) ;
00180 Valeur fonction_radiale (mp.get_mg()) ;
00181 Scalar enleve (mp) ;
00182
00183 double erreur = 0 ;
00184 int np = mp.get_mg()->get_np(1) ;
00185 int nt = mp.get_mg()->get_nt(1) ;
00186 int nr = mp.get_mg()->get_nr(1) ;
00187
00188 double r_0 = mp.val_r(1, -1, 0, 0) ;
00189 double r_1 = mp.val_r(1, 1, 0, 0) ;
00190
00191 for (int comp=1 ; comp<=3 ; comp++) {
00192 val_hor.annule_hard() ;
00193 for (int k=0 ; k<np ; k++)
00194 for (int j=0 ; j<nt ; j++)
00195 for (int i=0 ; i<nr ; i++)
00196 val_hor.set(1, k, j, i) = derive_r(comp).val_grid_point(1, k, j, 0) ;
00197
00198 fonction_radiale = pow(r_1-mp.r, 3.)* (mp.r-r_0)/pow(r_1-r_0, 3.) ;
00199 fonction_radiale.annule(0) ;
00200 fonction_radiale.annule(2, nz-1) ;
00201
00202 enleve = fonction_radiale*val_hor ;
00203 enleve.set_spectral_va().base = shift(comp).get_spectral_va().base ;
00204
00205 Scalar copie (shift(comp)) ;
00206 shift.set(comp) = shift(comp)-enleve ;
00207 shift.std_spectral_base() ;
00208
00209 assert (shift(comp).check_dzpuis(0)) ;
00210
00211
00212 Tbl norm (norme(shift(comp))) ;
00213 if (norm(1) > 1e-5) {
00214 Tbl diff (diffrelmax (copie, shift(comp))) ;
00215 if (erreur<diff(1))
00216 erreur = diff(1) ;
00217 }
00218 }
00219
00220 shift.change_triad(mp.get_bvect_spher()) ;
00221 beta = shift ;
00222
00223 return erreur ;
00224 }