98 int type_inter)
const {
100 assert(
etat != ETATNONDEF) ;
104 if (
etat == ETATZERO) {
105 resu.annule(lmin, lmax-1) ;
109 int nzin = lmax - lmin ;
112 for (
int i=lmin; i<lmax; i++) {
113 if ((mgrid->
get_nt(i) > 1)&&(dim_spec==1)) dim_spec = 2;
114 if (mgrid->
get_np(i) > 1) dim_spec = 3;
118 int* ntet =
new int[nzin] ;
120 int* nphi =
new int[nzin] ;
122 for (
int i=lmin; i<lmax; i++) {
123 int tmp = mgrid->
get_np(i) ;
125 nphimax = (tmp > nphimax ? tmp : nphimax) ;
128 ntetmax = (tmp > ntetmax ? tmp : ntetmax) ;
131 for (
int i=lmin; i<lmax; i++) {
132 if ((nphimax % nphi[i-lmin]) != 0) {
133 cout <<
"Tbl_val::to_spectral: The numbers of points in phi" << endl ;
134 cout <<
"in the different domains of Meudon grid are not" << endl;
135 cout <<
"well defined; see the documentation." << endl ;
138 assert((ntet[i-lmin]-1) > 0) ;
139 if (((ntetmax-1) % (ntet[i-lmin]-1)) != 0) {
140 cout <<
"Tbl_val::to_spectral: The numbers of points in theta"<< endl ;
141 cout <<
"in the different domains of Meudon grid are not" << endl;
142 cout <<
"well defined; see the documentation." << endl ;
148 resu.allocate_all() ;
149 if (lmin>0) resu.annule(0,lmin-1) ;
150 if (lmax < mgrid->get_nzone()) resu.annule(lmax, mgrid->
get_nzone()-1) ;
155 for (
int l=lmin; l<lmax; l++) nrarr += mgrid->
get_nr(l) -1 ;
160 int tsize =
dim->
dim[0] + 2*fant ;
163 for (
int i=0; i<tsize; i++) fdep.
set(i) =
t[i] ;
168 for (
int l=lmin; l<lmax; l++) {
169 for (
int i=0; i<mgrid->
get_nr(l); i++) {
170 rarr.
set(inum) = (+rr)(l,0,0,i) ;
177 for (
int l=lmin; l<lmax; l++) {
178 for (
int i=0; i<mgrid->
get_nr(l); i++) {
179 resu.set_grid_point(l,0,0,i) = farr(inum) ;
188 int tsizex =
dim->
dim[1] + 2*fant ;
189 int tsizez =
dim->
dim[0] + 2*fant ;
190 Tbl fdep(tsizex, tsizez) ;
192 for (
int j=0; j<tsizex; j++) {
193 for (
int i=0; i<tsizez; i++) {
194 int l = tsizez*j + i ;
198 Tbl farr(ntetmax, nrarr) ;
201 Tbl tetarr(ntetmax) ;
205 for (
int l=lmin; l<lmax; l++) {
206 if (ntetmax == ntet[l-lmin]) ltmax = l ;
207 for (
int i=0; i<mgrid->
get_nr(l); i++) {
208 rarr.
set(inum) = (+rr)(l,0,0,i) ;
214 for (
int j=0; j<ntetmax; j++)
215 tetarr.
set(j) = (+tet)(ltmax,0,j,0) ;
218 for (
int l=lmin; l<lmax; l++) {
219 for (
int j=0; j<ntet[l-lmin]; j++) {
220 int itet = (ntetmax-1)/(ntet[l-lmin]-1)*j ;
221 for (
int i=0; i<mgrid->
get_nr(l); i++) {
222 resu.set_grid_point(l,0,j,i) = farr(itet,inum) ;
225 inum -= mgrid->
get_nr(l) ;
227 inum += mgrid->
get_nr(l) - 1;
233 if (type_inter == 0) {
234 cout <<
"The use of routine INSMTS is not well suited" << endl ;
235 cout <<
"for 3D interpolation." << endl ;
238 int tsizey =
dim->
dim[2] + 2*fant ;
239 int tsizex =
dim->
dim[1] + 2*fant ;
240 int tsizez =
dim->
dim[0] + 2*fant ;
241 Tbl fdep(tsizey, tsizex, tsizez) ;
243 for (
int k=0; k<tsizey; k++) {
244 for (
int j=0; j<tsizex; j++) {
245 for (
int i=0; i<tsizez; i++) {
246 int l = (k*tsizex+j)*tsizez+i ;
251 Tbl farr(nphimax, ntetmax, nrarr) ;
254 Tbl tetarr(ntetmax) ;
256 Tbl phiarr(nphimax) ;
261 for (
int l=lmin; l<lmax; l++) {
262 if (ntetmax == ntet[l-lmin]) ltmax = l ;
263 if (nphimax == nphi[l-lmin]) lpmax = l ;
264 for (
int i=0; i<mgrid->
get_nr(l); i++) {
265 rarr.
set(inum) = (+rr)(l,0,0,i) ;
272 for (
int k=0; k<nphimax; k++) {
273 phiarr.
set(k) = (+phi)(lpmax,k,0,0) ;
275 for (
int j=0; j<ntetmax; j++)
276 tetarr.
set(j) = (+tet)(ltmax,0,j,0) ;
277 farr =
gval->
interpol3(fdep, rarr, tetarr, phiarr, type_inter) ;
279 for (
int l=lmin; l<lmax; l++) {
280 for (
int k=0; k<nphi[l-lmin]; k++) {
281 int iphi = (nphimax-1)/(nphi[l-lmin]-1)*k ;
282 for (
int j=0; j<ntet[l-lmin]; j++) {
283 int itet = (ntetmax-1)/(ntet[l-lmin]-1)*j ;
284 for (
int i=0; i<mgrid->
get_nr(l); i++) {
285 resu.set_grid_point(l,k,j,i) = farr(iphi,itet,inum) ;
288 inum -= mgrid->
get_nr(l) ;
291 inum += mgrid->
get_nr(l) - 1 ;
297 cout <<
"Tbl_val::to_spectral:Strange error..." << endl ;
310 bool interfr,
bool interft)
312 assert(meudon.
get_etat() != ETATNONDEF) ;
318 cout <<
"Tbl_val::from_spectral() : " << endl ;
319 cout <<
"lmin, lmax : " << lmin <<
", " << lmax << endl ;
322 if (meudon.
get_etat() == ETATZERO) {
342 assert (gvs != 0x0) ;
348 assert (gvs != 0x0) ;
360 cout <<
"Tbl_val::from_spectral:Strange error..." << endl ;
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...
int get_fantome() const
Returns the number of hidden cells.
int get_ndim() const
Returns the number of dimensions.
int get_np(int l) const
Returns the number of points in the azimuthal direction ( ) in domain no. l.
const Mg3d * get_mg() const
Gives the Mg3d on which the mapping is defined.
double & set(int i)
Read/write of a particular element (index i) (1D case)
Tensor field of valence 0 (or component of a tensorial field).
Base class for coordinate mappings.
double * somme_spectrale2ri(const Scalar &meudon) const
Same as before but at radial grid interfaces.
const Dim_tbl * dim
The Dim_tbl giving the dimensions and number of points (without the hidden cells).
int etat
logical state (ETATNONDEF , ETATQCQ or ETATZERO ).
int get_etat() const
Returns the logical state ETATNONDEF (undefined), ETATZERO (null) or ETATQCQ (ordinary).
virtual Tbl interpol3(const Tbl &fdep, const Tbl &rarr, const Tbl &tetarr, const Tbl &phiarr, const int type_inter) const =0
Performs 3D interpolation.
Coord tet
coordinate centered on the grid
Coord phi
coordinate centered on the grid
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
double * t
The array of double.
virtual void somme_spectrale2(const Scalar &meudon, double *t, int taille) const =0
Same as before but for the 2D case.
Tbl * zr
Arrays containing the values of coordinate z (or r) on the nodes.
int get_nzone() const
Returns the number of domains.
double * tzri
The array at z (or r) interfaces.
double * somme_spectrale2ti(const Scalar &meudon) const
Same as before but at angular grid interfaces.
virtual Tbl interpol2(const Tbl &fdep, const Tbl &rarr, const Tbl &tetarr, const int type_inter) const =0
Performs 2D interpolation.
Active physical coordinates and mapping derivatives.
int get_nr(int l) const
Returns the number of points in the radial direction ( ) in domain no. l.
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...
Class for spherical Godunov-type grids.
void annule_hard()
Sets the Tbl_val to zero in a hard way.
double * t
The array of double at the nodes.
virtual void somme_spectrale3(const Scalar &meudon, double *t, int taille) const =0
Same as before but for the 3D case.
int get_taille() const
Gives the size of the node array (including the hidden cells)
int get_nt(int l) const
Returns the number of points in the co-latitude direction ( ) in domain no. l.
Tbl interpol1(const Tbl &rdep, const Tbl &rarr, const Tbl &fdep, int flag, const int type_inter) const
Performs 1D interpolation.
const Map & get_mp() const
Returns the mapping.
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).
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 .
double * txti
The array at x (or ) interfaces.
const Grille_val * gval
The Grille_val (cartesian or spherical) on which the array is defined.
int * dim
Array of dimensions (size: ndim).
Coord r
r 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...