30 char TBL_VAL_INTER_C[] =
"$Header: /cvsroot/Lorene/C++/Source/Valencia/tbl_val_interp.C,v 1.13 2014/10/13 08:53:48 j_novak Exp $" ;
95 int type_inter)
const {
97 assert(
etat != ETATNONDEF) ;
101 if (
etat == ETATZERO) {
102 resu.
annule(lmin, lmax-1) ;
106 int nzin = lmax - lmin ;
109 for (
int i=lmin; i<lmax; i++) {
110 if ((mgrid->
get_nt(i) > 1)&&(dim_spec==1)) dim_spec = 2;
111 if (mgrid->
get_np(i) > 1) dim_spec = 3;
115 int* ntet =
new int[nzin] ;
117 int* nphi =
new int[nzin] ;
119 for (
int i=lmin; i<lmax; i++) {
120 int tmp = mgrid->
get_np(i) ;
122 nphimax = (tmp > nphimax ? tmp : nphimax) ;
125 ntetmax = (tmp > ntetmax ? tmp : ntetmax) ;
128 for (
int i=lmin; i<lmax; i++) {
129 if ((nphimax % nphi[i-lmin]) != 0) {
130 cout <<
"Tbl_val::to_spectral: The numbers of points in phi" << endl ;
131 cout <<
"in the different domains of Meudon grid are not" << endl;
132 cout <<
"well defined; see the documentation." << endl ;
135 assert((ntet[i-lmin]-1) > 0) ;
136 if (((ntetmax-1) % (ntet[i-lmin]-1)) != 0) {
137 cout <<
"Tbl_val::to_spectral: The numbers of points in theta"<< endl ;
138 cout <<
"in the different domains of Meudon grid are not" << endl;
139 cout <<
"well defined; see the documentation." << endl ;
146 if (lmin>0) resu.
annule(0,lmin-1) ;
147 if (lmax < mgrid->get_nzone()) resu.
annule(lmax, mgrid->
get_nzone()-1) ;
152 for (
int l=lmin; l<lmax; l++) nrarr += mgrid->
get_nr(l) -1 ;
157 int tsize =
dim->
dim[0] + 2*fant ;
160 for (
int i=0; i<tsize; i++) fdep.
set(i) =
t[i] ;
165 for (
int l=lmin; l<lmax; l++) {
166 for (
int i=0; i<mgrid->
get_nr(l); i++) {
167 rarr.
set(inum) = (+rr)(l,0,0,i) ;
174 for (
int l=lmin; l<lmax; l++) {
175 for (
int i=0; i<mgrid->
get_nr(l); i++) {
185 int tsizex =
dim->
dim[1] + 2*fant ;
186 int tsizez =
dim->
dim[0] + 2*fant ;
187 Tbl fdep(tsizex, tsizez) ;
189 for (
int j=0; j<tsizex; j++) {
190 for (
int i=0; i<tsizez; i++) {
191 int l = tsizez*j + i ;
195 Tbl farr(ntetmax, nrarr) ;
198 Tbl tetarr(ntetmax) ;
202 for (
int l=lmin; l<lmax; l++) {
203 if (ntetmax == ntet[l-lmin]) ltmax = l ;
204 for (
int i=0; i<mgrid->
get_nr(l); i++) {
205 rarr.
set(inum) = (+rr)(l,0,0,i) ;
211 for (
int j=0; j<ntetmax; j++)
212 tetarr.
set(j) = (+tet)(ltmax,0,j,0) ;
215 for (
int l=lmin; l<lmax; l++) {
216 for (
int j=0; j<ntet[l-lmin]; j++) {
217 int itet = (ntetmax-1)/(ntet[l-lmin]-1)*j ;
218 for (
int i=0; i<mgrid->
get_nr(l); i++) {
222 inum -= mgrid->
get_nr(l) ;
224 inum += mgrid->
get_nr(l) - 1;
230 if (type_inter == 0) {
231 cout <<
"The use of routine INSMTS is not well suited" << endl ;
232 cout <<
"for 3D interpolation." << endl ;
235 int tsizey =
dim->
dim[2] + 2*fant ;
236 int tsizex =
dim->
dim[1] + 2*fant ;
237 int tsizez =
dim->
dim[0] + 2*fant ;
238 Tbl fdep(tsizey, tsizex, tsizez) ;
240 for (
int k=0; k<tsizey; k++) {
241 for (
int j=0; j<tsizex; j++) {
242 for (
int i=0; i<tsizez; i++) {
243 int l = (k*tsizex+j)*tsizez+i ;
248 Tbl farr(nphimax, ntetmax, nrarr) ;
251 Tbl tetarr(ntetmax) ;
253 Tbl phiarr(nphimax) ;
258 for (
int l=lmin; l<lmax; l++) {
259 if (ntetmax == ntet[l-lmin]) ltmax = l ;
260 if (nphimax == nphi[l-lmin]) lpmax = l ;
261 for (
int i=0; i<mgrid->
get_nr(l); i++) {
262 rarr.
set(inum) = (+rr)(l,0,0,i) ;
269 for (
int k=0; k<nphimax; k++) {
270 phiarr.
set(k) = (+phi)(lpmax,k,0,0) ;
272 for (
int j=0; j<ntetmax; j++)
273 tetarr.
set(j) = (+tet)(ltmax,0,j,0) ;
274 farr =
gval->
interpol3(fdep, rarr, tetarr, phiarr, type_inter) ;
276 for (
int l=lmin; l<lmax; l++) {
277 for (
int k=0; k<nphi[l-lmin]; k++) {
278 int iphi = (nphimax-1)/(nphi[l-lmin]-1)*k ;
279 for (
int j=0; j<ntet[l-lmin]; j++) {
280 int itet = (ntetmax-1)/(ntet[l-lmin]-1)*j ;
281 for (
int i=0; i<mgrid->
get_nr(l); i++) {
285 inum -= mgrid->
get_nr(l) ;
288 inum += mgrid->
get_nr(l) - 1 ;
294 cout <<
"Tbl_val::to_spectral:Strange error..." << endl ;
307 bool interfr,
bool interft)
309 assert(meudon.
get_etat() != ETATNONDEF) ;
315 cout <<
"Tbl_val::from_spectral() : " << endl ;
316 cout <<
"lmin, lmax : " << lmin <<
", " << lmax << endl ;
319 if (meudon.
get_etat() == ETATZERO) {
339 assert (gvs != 0x0) ;
345 assert (gvs != 0x0) ;
357 cout <<
"Tbl_val::from_spectral:Strange error..." << endl ;
Tbl interpol1(const Tbl &rdep, const Tbl &rarr, const Tbl &fdep, int flag, const int type_inter) const
Performs 1D interpolation.
double & set(int i)
Read/write of a particular element (index i) (1D case)
int get_np(int l) const
Returns the number of points in the azimuthal direction ( ) in domain no. l.
double * t
The array of double at the nodes.
virtual bool compatible(const Map *mp, const int lmax, const int lmin=0) const =0
Checks if the spectral grid and mapping are compatible with the Grille_val caracteristics for the int...
int etat
logical state (ETATNONDEF , ETATQCQ or ETATZERO ).
void from_spectral(const Scalar &meudon, int lmax, int lmin=0, bool interfr=false, bool interft=false)
Interpolation from a Scalar to a Tbl_val (spectral summation).
int get_nt(int l) const
Returns the number of points in the co-latitude direction ( ) in domain no. l.
double * somme_spectrale2ri(const Scalar &meudon) const
Same as before but at radial grid interfaces.
const Mg3d * get_mg() const
Gives the Mg3d on which the mapping is defined.
virtual Tbl interpol2(const Tbl &fdep, const Tbl &rarr, const Tbl &tetarr, const int type_inter) const =0
Performs 2D interpolation.
Coord r
r coordinate centered on the grid
double & set_grid_point(int l, int k, int j, int i)
Setting the value of the field at a given grid point.
virtual void somme_spectrale3(const Scalar &meudon, double *t, int taille) const =0
Same as before but for the 3D case.
int * dim
Array of dimensions (size: ndim).
Tbl * zr
Arrays containing the values of coordinate z (or r) on the nodes
Tensor field of valence 0 (or component of a tensorial field).
const Map & get_mp() const
Returns the mapping.
virtual Tbl interpol3(const Tbl &fdep, const Tbl &rarr, const Tbl &tetarr, const Tbl &phiarr, const int type_inter) const =0
Performs 3D interpolation.
double * t
The array of double.
double * tzri
The array at z (or r) interfaces.
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Active physical coordinates and mapping derivatives.
const Grille_val * gval
The Grille_val (cartesian or spherical) on which the array is defined.
Scalar to_spectral(const Map &map, const int lmax, const int lmin=0, int type_inter=2) const
Interpolation from a Tbl_val to a Scalar .
int get_ndim() const
Returns the number of dimensions.
void annule_hard()
Sets the Tbl_val to zero in a hard way.
int get_fantome() const
Returns the number of hidden cells.
virtual void allocate_all()
Sets the logical state to ETATQCQ (ordinary state) and performs the memory allocation of all the elem...
int get_nzone() const
Returns the number of domains.
Coord tet
coordinate centered on the grid
void somme_spectrale1(const Scalar &meudon, double *t, int taille) const
Makes the sommation of the spectral basis functions to know the values of the function described by t...
const Dim_tbl * dim
The Dim_tbl giving the dimensions and number of points (without the hidden cells).
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
int get_nr(int l) const
Returns the number of points in the radial direction ( ) in domain no. l.
virtual bool contenue_dans(const Map &mp, const int lmax, const int lmin=0) const =0
Checks if Grille_val is contained inside the spectral grid/mapping within the domains [lmin,...
Coord phi
coordinate centered on the grid
virtual void annule(int l_min, int l_max)
Sets the Scalar to zero in several domains.
int get_etat() const
Returns the logical state ETATNONDEF (undefined), ETATZERO (null) or ETATQCQ (ordinary).
int get_taille() const
Gives the size of the node array (including the hidden cells)
double * txti
The array at x (or ) interfaces.
double * somme_spectrale2ti(const Scalar &meudon) const
Same as before but at angular grid interfaces.
Class for spherical Godunov-type grids.
Base class for coordinate mappings.
virtual void somme_spectrale2(const Scalar &meudon, double *t, int taille) const =0
Same as before but for the 2D case.