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
00027
00028
00029 char valeur_equipot_C[] = "$Header: /cvsroot/Lorene/C++/Source/Valeur/valeur_equipot.C,v 1.3 2003/12/19 15:05:56 j_novak Exp $" ;
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 #include <stdlib.h>
00060 #include <math.h>
00061
00062
00063 #include "valeur.h"
00064 #include "itbl.h"
00065 #include "param.h"
00066 #include "nbr_spx.h"
00067 #include "utilitaires.h"
00068
00069
00070 double valeur_equipot_fonc(double, const Param&) ;
00071
00072
00073
00074 void Valeur::equipot(double uu0, int nz_search, double precis, int nitermax,
00075 int& niter, Itbl& l_iso, Tbl& xi_iso) const {
00076
00077
00078 int nz = mg->get_nzone() ;
00079 int nt = mg->get_nt(0) ;
00080 int np = mg->get_np(0) ;
00081
00082
00083
00084 assert(etat == ETATQCQ) ;
00085 assert(nz_search > 0) ;
00086 assert(nz_search <= nz) ;
00087 for (int l=1; l<nz_search; l++) {
00088 assert( mg->get_nt(l) == nt ) ;
00089 assert( mg->get_np(l) == np ) ;
00090 }
00091
00092 coef() ;
00093
00094 l_iso.set_etat_qcq() ;
00095 xi_iso.set_etat_qcq() ;
00096
00097 Param parf ;
00098 int j, k, l2 ;
00099 parf.add_int_mod(j, 0) ;
00100 parf.add_int_mod(k, 1) ;
00101 parf.add_int_mod(l2, 2) ;
00102 parf.add_double(uu0) ;
00103 parf.add_mtbl_cf(*c_cf) ;
00104
00105
00106
00107
00108
00109 niter = 0 ;
00110
00111 for (k=0; k<np; k++) {
00112
00113 for (j=0; j<nt; j++) {
00114
00115
00116
00117
00118
00119 int i2 = 0;
00120 l2 = nz ;
00121 for (int l=nz_search-1; l>= 0; l--) {
00122 int nr = mg->get_nr(l) ;
00123
00124 for (int i=nr-1; i >= 0; i--) {
00125 double uux = (*this)(l, k, j, i) ;
00126 if ( ( (uux > uu0) || ( fabs(uux-uu0) < 1.e-14 ) ) &&
00127 (uux != __infinity) ) {
00128 l2 = l ;
00129 i2 = i ;
00130 break ;
00131 }
00132 }
00133
00134 if (l2 == l) break ;
00135 }
00136
00137 if (l2==nz) {
00138 cout << "Valeur::equipot: the point uu >= uu0 has not been found" << endl ;
00139 cout << " for the phi index " << k << endl ;
00140 cout << " and the theta index " << j << endl ;
00141 cout << " uu0 = " << uu0 << endl ;
00142 abort () ;
00143 }
00144
00145
00146 int i3 = 0 ;
00147 if (i2 < mg->get_nr(l2) -1) {
00148 i3 = i2 + 1 ;
00149 }
00150 else {
00151 if (l2<nz_search-1) {
00152
00153 double uux = (*this)(l2, k, j, i2) ;
00154 if ( ( fabs(uux-uu0) < 1.e-14 ) ) {
00155
00156 cout <<
00157 "Valeur::equipot: WARNING : fabs(uux-uu0) < 1.e-14" << endl ;
00158 l_iso.set(k, j) = l2 ;
00159 xi_iso.set(k, j) = (mg->get_grille3d(l2))->x[i2] ;
00160 }
00161 else{
00162 cout << "Valeur::equipot: PROBLEM !!!" << endl ;
00163 cout << " k, j : " << k << " " << j << endl ;
00164 cout << " uu0 : " << uu0 << endl ;
00165 abort () ;
00166 }
00167 }
00168 else {
00169 l_iso.set(k, j) = nz_search-1 ;
00170 xi_iso.set(k, j) = (mg->get_grille3d(l2))->x[i2] ;
00171 continue ;
00172 }
00173 }
00174
00175 l_iso.set(k, j) = l2 ;
00176
00177 double x2 = (mg->get_grille3d(l2))->x[i2] ;
00178 double x3 = (mg->get_grille3d(l2))->x[i3] ;
00179
00180 double y2 = (*this)(l2, k, j, i2) - uu0 ;
00181
00182
00183
00184 int niter0 = 0 ;
00185 if (fabs(y2) < 1.e-14) {
00186 xi_iso.set(k, j) = x2 ;
00187 }
00188 else {
00189 xi_iso.set(k, j) = zerosec(valeur_equipot_fonc, parf, x2, x3, precis,
00190 nitermax, niter0 ) ;
00191 }
00192
00193 niter = ( niter0 > niter ) ? niter0 : niter ;
00194
00195 }
00196 }
00197
00198 }
00199
00200
00201
00202
00203
00204 double valeur_equipot_fonc(double xi, const Param& par) {
00205
00206 int j = par.get_int_mod(0) ;
00207 int k = par.get_int_mod(1) ;
00208 int l = par.get_int_mod(2) ;
00209 double uu0 = par.get_double() ;
00210 const Mtbl_cf& cuu = par.get_mtbl_cf() ;
00211
00212 return cuu.val_point_jk(l, xi, j, k) - uu0 ;
00213 }
00214