31 #include "utilitaires.h" 40 bool first_call = true ;
42 void (*coef_r[
MAX_BASE])(
const int*,
const int*,
double*,
const int*,
double*) ;
43 double (*som_r_1d[
MAX_BASE])(
const double*, int, double) ;
46 #include "proto_interp.h" 60 do_first_call_initializations(coef_r, som_r_1d) ;
66 const Map_af* p_mpa =
dynamic_cast<const Map_af*
>(p_mp) ;
68 throw(invalid_argument(
"Map_star::interpolate_from_map_af: the input Scalar field is not of type Map_af.")) ;
70 const Map_af& mpa = *p_mpa ;
76 if (!check_grids(mpa, *
this, ndom_a)) {
77 throw(invalid_argument(
"Map_star::interpolate_from_map_af: both mappings are not compatible")) ;
79 int np0 = mg_a->
get_np(0) ;
80 int nt0 = mg_a->
get_nt(0) ;
87 throw(invalid_argument(
"Map_star::interpolate_from_map_af: the input Scalar field is not defined.")) ;
114 for (
int l=0; l<ndom_a; l++) {
116 Tbl* cf = (interm.
t)[l];
135 coef_r[base_r](deg, deg, (f->
t), deg, (cf->
t)) ;
144 for (
int lz=0; lz<nzs; lz++) {
145 for (
int k=0; k<np0; k++) {
146 for (
int j=0; j<nt0; j++) {
148 for (
int i=0; i<nrs; i++) {
149 double radius = (+
r)(lz, k, j, i) ;
152 mpa.
val_lx_jk(radius, j, k, par_dummy, l_a, xi_a) ;
154 const double* cfr = &interm.
set(l_a, k, j, 0) ;
155 int nra = mg_a->
get_nr(l_a) ;
158 resu.
set_grid_point(lz, k, j, i) = som_r_1d[base_r](cfr, nra, xi_a) ;
166 throw(invalid_argument(
"Map_star::interpolate_from_map_af: the input Scalar field is ill-formed.")) ;
187 do_first_call_initializations(coef_r, som_r_1d) ;
195 throw(invalid_argument(
"Map_af::interpolate_from_map_star: the input Scalar field is not of type Map_star.")) ;
202 if (!check_grids(mps, *
this, ndom_a)) {
203 throw(invalid_argument(
"Map_star::interpolate_from_map_star: both mappings are not compatible")) ;
205 int np0 = mg_s->
get_np(0) ;
206 int nt0 = mg_s->
get_nt(0) ;
213 throw(invalid_argument(
"Map_af::interpolate_from_map_star: the input Scalar field is not defined.")) ;
241 for (
int l=0; l<nzs; l++) {
243 Tbl* cf = (interm.
t)[l];
262 coef_r[base_r](deg, deg, (f->
t), deg, (cf->
t)) ;
270 const Coord& r_s = mps.
r ;
272 int nrs_max = mg_s->
get_nr(nzs-1) ;
273 for (
int lz=0; lz<ndom_a; lz++) {
274 for (
int k=0; k<np0; k++) {
275 for (
int j=0; j<nt0; j++) {
276 double rmax_s = (+r_s)(nzs-1, k, j, nrs_max-1) ;
278 for (
int i=0; i<nra; i++) {
279 double radius_a = (+
r)(lz, k, j, i) ;
280 if (radius_a <= rmax_s) {
283 mps.
val_lx_jk(radius_a, j, k, par_dummy, l_s, xi_s) ;
285 const double* cfr = &interm.
set(l_s, k, j, 0) ;
286 int nrs = mg_s->
get_nr(l_s) ;
289 resu.
set_grid_point(lz, k, j, i) = som_r_1d[base_r](cfr, nrs, xi_s) ;
297 resu.
annule(ndom_a, nza-1) ;
301 throw(invalid_argument(
"Map_af::interpolate_from_map_star: the input Scalar field is ill-formed.")) ;
315 void do_first_call_initializations(
317 (
const int*,
const int*,
double*,
const int*,
double*),
318 double (*som_r_1d0[
MAX_BASE])(
const double*,
int,
double) ) {
321 coef_r0[i] = pasprevu_r ;
322 som_r_1d0[i] = som_r_1d_pas_prevu ;
324 coef_r0[
NONDEF] = base_non_def_r ;
344 bool check_grids(
const Map_af& mpa,
const Map_star& mps,
int& ndom) {
356 int np0 = mga->
get_np(0) ;
357 int nt0 = mga->
get_nt(0) ;
358 for (
int l=1; l<nza; l++)
359 resu = resu && (np0 == mga->
get_np(l)) && (nt0 == mga->
get_nt(l)) ;
360 for (
int l=0; l<nzs; l++)
361 resu = resu && (np0 == mgs->
get_np(l)) && (nt0 == mgs->
get_nt(l)) ;
368 int nr = mgs->
get_nr(nzs-1) ;
369 for (
int k=0; k<np0; k++) {
370 for (
int j=0; j<nt0; j++) {
371 if ((+rr)(nzs-1, k, j, nr-1) > rmax) {
372 rmax = (+rr)(nzs-1, k, j, nr-1) ;
381 mpa.
val_lx_jk(rmax, jmax, kmax, par_dummy, ndom, dummy) ;
387 bool check_grids(
const Map_star& mps,
const Map_af& mpa,
int& ndom) {
399 int np0 = mga->
get_np(0) ;
400 int nt0 = mga->
get_nt(0) ;
401 for (
int l=1; l<nza; l++)
402 resu = resu && (np0 == mga->
get_np(l)) && (nt0 == mga->
get_nt(l)) ;
403 for (
int l=0; l<nzs; l++)
404 resu = resu && (np0 == mgs->
get_np(l)) && (nt0 == mgs->
get_nt(l)) ;
411 int nr = mgs->
get_nr(nzs-1) ;
412 for (
int k=0; k<np0; k++) {
413 for (
int j=0; j<nt0; j++) {
414 if ((+rr)(nzs-1, k, j, nr-1) > rmax) {
415 rmax = (+rr)(nzs-1, k, j, nr-1) ;
424 mpa.
val_lx_jk(rmax, jmax, kmax, par_dummy, ndom, dummy) ;
int get_type_p() const
Returns the type of sampling in the direction: SYM : : symmetry with respect to the transformatio...
virtual void val_lx_jk(double rr, int j, int k, const Param &par, int &l, double &xi) const
Computes the domain index l and the value of corresponding to a point of arbitrary r but collocation...
int get_np(int l) const
Returns the number of points in the azimuthal direction ( ) in domain no. l.
virtual void set_etat_zero()
Sets the logical state to ETATZERO (zero).
virtual void annule(int l_min, int l_max)
Sets the Scalar to zero in several domains.
const Mg3d * get_mg() const
Gives the Mg3d on which the mapping is defined.
Tensor field of valence 0 (or component of a tensorial field).
void coef_i() const
Computes the physical value of *this.
Base class for coordinate mappings.
int get_type_t() const
Returns the type of sampling in the direction: SYM : : symmetry with respect to the equatorial pl...
int get_etat() const
Gives the logical state.
#define R_LEGP
base de Legendre paire (rare) seulement
virtual void allocate_all()
Sets the logical state to ETATQCQ (ordinary state) and performs the memory allocation of all the elem...
int get_etat() const
Returns the logical state ETATNONDEF (undefined), ETATZERO (null) or ETATQCQ (ordinary).
#define R_LEGI
base de Legendre impaire (rare) seulement
#define R_JACO02
base de Jacobi(0,2) ordinaire (finjac)
#define TRA_R
Translation en R, used for a bitwise shift (in hex)
int get_colloc_r(int l) const
Returns the type of collocation points used in domain no.
#define R_CHEBI
base de Cheb. impaire (rare) seulement
#define R_CHEBP
base de Cheb. paire (rare) seulement
Base_val base
Bases on which the spectral expansion is performed.
double * t
The array of double.
Mtbl * c
Values of the function at the points of the multi-grid.
int * b
Array (size: nzone ) of the spectral basis in each domain.
#define MSQ_R
Extraction de l'info sur R.
void set_etat_one()
Sets the logical state to ETATUN (one).
int get_nzone() const
Returns the number of domains.
int get_dim(int i) const
Gives the i-th dimension (ie dim.dim[i])
virtual void val_lx_jk(double rr, int j, int k, const Param &par, int &l, double &xi) const
Computes the domain index l and the value of corresponding to a point of arbitrary r but collocation...
Active physical coordinates and mapping derivatives.
Tbl & set(int l)
Read/write of the Tbl in a given domain.
void set_etat_zero()
Sets the logical state to ETATZERO (zero).
int get_nr(int l) const
Returns the number of points in the radial direction ( ) in domain no. l.
void annule_hard()
Sets the Mtbl to zero in a hard way.
const Mg3d * mg
Pointer on the multi-grid Mgd3 on which this is defined.
Bases of the spectral expansions.
double & set_grid_point(int l, int k, int j, int i)
Setting the value of the field at a given grid point.
#define NONDEF
base inconnue
bool admissible_fft(int)
Checks whether or not a given number of degrees of freedom is compatible with the FFT transform...
Scalar interpolate_from_map_star(const Scalar &f_s) const
Interpolates from a Scalar defined on a Map_star and returns the new Scalar defined on *this...
int get_nt(int l) const
Returns the number of points in the co-latitude direction ( ) in domain no. l.
#define R_CHEBU
base de Chebychev ordinaire (fin), dev. en 1/r
Tbl ** t
Array (size nzone ) of pointers on the Tbl 's.
Scalar interpolate_from_map_af(const Scalar &f_a) const
Interpolates from a Scalar defined on a Map_af and returns the new Scalar defined on *this...
const Map & get_mp() const
Returns the mapping.
#define MAX_BASE
Nombre max. de bases differentes.
const Valeur & get_spectral_va() const
Returns va (read only version)
Coord r
r coordinate centered on the grid
#define R_LEG
base de Legendre ordinaire (fin)
#define R_CHEB
base de Chebychev ordinaire (fin)