57 void radial_smoothing(
double* ,
const double* ,
int ,
double) ;
60 void Tbl_val::smooth_atmosphere(
double atmosphere_thr) {
62 const Gval_spher* gspher =
dynamic_cast<const Gval_spher*
>(
gval) ;
63 assert(gspher != 0x0) ;
64 int ndim = gspher->get_ndim() ;
65 int fant = gspher->get_fantome() ;
70 radial_smoothing(
t, gspher->zr->t, nr, atmosphere_thr) ;
75 for (
int j=0; j<nt; j++)
76 radial_smoothing(
t+j*nr, gspher->zr->t, nr, atmosphere_thr) ;
82 for (
int j=0; j<nt; j++)
83 for (
int k=0; k<np; k++)
84 radial_smoothing(
t+k*nt*nr+j*nr, gspher->zr->t, nr, atmosphere_thr) ;
89 cerr <<
"Tbl_val::smooth_atmosphere : strange number of dimensions!" 98 void radial_smoothing(
double* tab,
const double* rr,
int n,
double rho) {
100 assert((tab!= 0x0)&&(rr!=0x0)) ;
103 if (fabs(tab[n-1]) > rho)
106 double* t = tab + (n-1) ;
110 for (
int i=0; ((i<n)&&(atmos)); i++) {
111 if (atmos) atmos = ( fabs(*t) < rho) ;
114 jump = ( fabs(*t) > rho ) ;
119 if (indice == -1) return ;
120 int np = 2*(n-indice-2)/3 ;
121 int nm = indice / 100 + 3 ;
123 if (indice < n - np+1) {
128 int ileft = indice - nm + 2 ;
129 int iright = indice + np - 1 ;
130 double alpha = ( rr[ileft - 2] - rr[ileft - 1]) /
131 ( rr[ileft -1] - rr[ileft]) ;
132 double der_l = ( alpha*(alpha+2.)*tab[ileft]
133 - (1.+alpha)*(1.+alpha)*tab[ileft-1]
135 ( (1.+alpha)*(rr[ileft - 1] - rr[ileft - 2]) ) ;
136 double f_l = tab[ileft] ;
137 double f_r = tab[iright] ;
138 double tau = rr[ileft] - rr[iright] ;
139 double alp = der_l / (tau*tau) + 2.*(f_r - f_l)/(tau*tau*tau) ;
140 double bet = 0.5*(der_l + alp*tau*(rr[iright] - 3*rr[ileft])) / tau ;
141 for (
int i=ileft; i<iright; i++) {
142 tab[i] = f_r + (alp*rr[i]+bet)*(rr[i] - rr[iright])*(rr[i] - rr[iright]);
147 double alpha = ( rr[ileft - 2] - rr[ileft - 1]) /
148 ( rr[ileft -1] - rr[ileft]) ;
149 double der_l = ( alpha*(alpha+2.)*tab[ileft]
150 - (1.+alpha)*(1.+alpha)*tab[ileft-1]
152 ( (1.+alpha)*(rr[ileft - 1] - rr[ileft - 2]) ) ;
153 for (
int i=ileft; i<n; i++) {
154 tab[i] = tab[ileft] + (rr[i] - rr[ileft])*der_l ;
int get_dim(int i) const
Gives the i th dimension (ie dim->dim[i] , without hidden cells)
double * t
The array of double at the nodes.
const Grille_val * gval
The Grille_val (cartesian or spherical) on which the array is defined.