29char scalar_import_C[] =
"$Header: /cvsroot/Lorene/C++/Source/Tensor/Scalar/scalar_import.C,v 1.5 2014/10/13 08:53:46 j_novak Exp $" ;
70 int nz =
mp->get_mg()->get_nzone() ;
95 int align_rel = (
mp->get_bvect_cart()).get_align()
96 * (mp_d->get_bvect_cart()).get_align() ;
116 cout <<
"Scalar::import : unexpected value of align_rel : "
117 << align_rel << endl ;
159 assert(cm_d.
get_etat() != ETATNONDEF) ;
163 "Scalar::import : the dzpuis of the Scalar to be imported must be zero !"
169 const Mg3d* mg_a =
mp->get_mg() ;
171 assert(nzet <= nz_a) ;
176 assert(cm_d.
get_etat() == ETATQCQ) ;
187 va.set_etat_c_qcq() ;
189 va.c->set_etat_qcq() ;
194 double xo_d = mp_d->get_ori_x() ;
195 double yo_d = mp_d->get_ori_y() ;
196 double zo_d = mp_d->get_ori_z() ;
199 double rot_phi_d = mp_d->get_rot_phi() ;
202 double rot_phi_a =
mp->get_rot_phi() ;
207 if ( (
mp->r).c == 0x0 ) (
mp->r).fait() ;
208 if ( (
mp->tet).c == 0x0 ) (
mp->tet).fait() ;
209 if ( (
mp->phi).c == 0x0 ) (
mp->phi).fait() ;
210 if ( (
mp->xa).c == 0x0 ) (
mp->xa).fait() ;
211 if ( (
mp->ya).c == 0x0 ) (
mp->ya).fait() ;
212 if ( (
mp->za).c == 0x0 ) (
mp->za).fait() ;
214 const Mtbl* mr_a = (
mp->r).c ;
215 const Mtbl* mtet_a = (
mp->tet).c ;
216 const Mtbl* mphi_a = (
mp->phi).c ;
217 const Mtbl* mxa_a = (
mp->xa).c ;
218 const Mtbl* mya_a = (
mp->ya).c ;
219 const Mtbl* mza_a = (
mp->za).c ;
224 double precis = 1e-15 ;
233 for (
int l=0; l < nzet; l++) {
235 int nr = mg_a->
get_nr(l) ;
236 int nt = mg_a->
get_nt(l) ;
237 int np = mg_a->
get_np(l) ;
240 const double* pr_a = mr_a->
t[l]->
t ;
241 const double* ptet_a = mtet_a->
t[l]->
t ;
242 const double* pphi_a = mphi_a->
t[l]->
t ;
243 const double* pxa_a = mxa_a->
t[l]->
t ;
244 const double* pya_a = mya_a->
t[l]->
t ;
245 const double* pza_a = mza_a->
t[l]->
t ;
249 double* ptx = (
va.c->t[l])->t ;
254 for (
int k=0 ; k<np ; k++) {
255 for (
int j=0 ; j<nt ; j++) {
256 for (
int i=0 ; i<nr ; i++) {
259 double rd, tetd, phid ;
260 if (
r == __infinity) {
263 phid = *pphi_a + rot_phi_a - rot_phi_d ;
264 if (phid < 0) phid += 2*M_PI ;
270 double xd = *pxa_a - xo_d ;
271 double yd = *pya_a - yo_d ;
272 double zd = *pza_a - zo_d ;
275 double rhod2 = xd*xd + yd*yd ;
276 double rhod =
sqrt( rhod2 ) ;
277 rd =
sqrt(rhod2 + zd*zd) ;
278 tetd = atan2(rhod, zd) ;
279 phid = atan2(yd, xd) - rot_phi_d ;
280 if (phid < 0) phid += 2*M_PI ;
293 mp_d->val_lx(rd, tetd, phid, par_precis, ld, xxd) ;
354 int align = (
mp->get_bvect_cart()).get_align() ;
356 assert( align * (mp_d->get_bvect_cart()).get_align() == -1 ) ;
358 assert(cm_d.
get_etat() == ETATQCQ) ;
362 "Scalar::import : the dzpuis of the Scalar to be imported must be zero !"
368 const Mg3d* mg_a =
mp->get_mg() ;
370 assert(nzet <= nz_a) ;
382 va.set_etat_c_qcq() ;
384 va.c->set_etat_qcq() ;
390 double xx_a, yy_a, zz_a ;
392 xx_a = mp_d->get_ori_x() -
mp->get_ori_x() ;
393 yy_a = mp_d->get_ori_y() -
mp->get_ori_y() ;
396 xx_a =
mp->get_ori_x() - mp_d->get_ori_x() ;
397 yy_a =
mp->get_ori_y() - mp_d->get_ori_y() ;
399 zz_a =
mp->get_ori_z() - mp_d->get_ori_z() ;
405 if ( (
mp->r).c == 0x0 ) (
mp->r).fait() ;
406 if ( (
mp->tet).c == 0x0 ) (
mp->tet).fait() ;
407 if ( (
mp->phi).c == 0x0 ) (
mp->phi).fait() ;
408 if ( (
mp->x).c == 0x0 ) (
mp->x).fait() ;
409 if ( (
mp->y).c == 0x0 ) (
mp->y).fait() ;
410 if ( (
mp->z).c == 0x0 ) (
mp->z).fait() ;
412 const Mtbl* mr_a = (
mp->r).c ;
413 const Mtbl* mtet_a = (
mp->tet).c ;
414 const Mtbl* mphi_a = (
mp->phi).c ;
415 const Mtbl* mx_a = (
mp->x).c ;
416 const Mtbl* my_a = (
mp->y).c ;
417 const Mtbl* mz_a = (
mp->z).c ;
422 double precis = 1e-15 ;
431 for (
int l=0; l < nzet; l++) {
433 int nr = mg_a->
get_nr(l) ;
434 int nt = mg_a->
get_nt(l) ;
435 int np = mg_a->
get_np(l) ;
438 const double* pr_a = mr_a->
t[l]->
t ;
439 const double* ptet_a = mtet_a->
t[l]->
t ;
440 const double* pphi_a = mphi_a->
t[l]->
t ;
441 const double* px_a = mx_a->
t[l]->
t ;
442 const double* py_a = my_a->
t[l]->
t ;
443 const double* pz_a = mz_a->
t[l]->
t ;
447 double* ptx = (
va.c->t[l])->t ;
452 for (
int k=0 ; k<np ; k++) {
453 for (
int j=0 ; j<nt ; j++) {
454 for (
int i=0 ; i<nr ; i++) {
457 double rd, tetd, phid ;
458 if (
r == __infinity) {
461 phid = *pphi_a + M_PI ;
462 if (phid < 0) phid += 2*M_PI ;
467 double xd = - *px_a + xx_a ;
468 double yd = - *py_a + yy_a ;
469 double zd = *pz_a + zz_a ;
472 double rhod2 = xd*xd + yd*yd ;
473 double rhod =
sqrt( rhod2 ) ;
474 rd =
sqrt(rhod2 + zd*zd) ;
475 tetd = atan2(rhod, zd) ;
476 phid = atan2(yd, xd) ;
477 if (phid < 0) phid += 2*M_PI ;
490 mp_d->val_lx(rd, tetd, phid, par_precis, ld, xxd) ;
550 int align = (
mp->get_bvect_cart()).get_align() ;
552 assert( align * (mp_d->get_bvect_cart()).get_align() == 1 ) ;
554 assert(cm_d.
get_etat() == ETATQCQ) ;
558 "Scalar::import : the dzpuis of the Scalar to be imported must be zero !"
564 const Mg3d* mg_a =
mp->get_mg() ;
566 assert(nzet <= nz_a) ;
578 va.set_etat_c_qcq() ;
580 va.c->set_etat_qcq() ;
586 double xx_a, yy_a, zz_a ;
588 xx_a =
mp->get_ori_x() - mp_d->get_ori_x() ;
589 yy_a =
mp->get_ori_y() - mp_d->get_ori_y() ;
592 xx_a = mp_d->get_ori_x() -
mp->get_ori_x() ;
593 yy_a = mp_d->get_ori_y() -
mp->get_ori_y() ;
595 zz_a =
mp->get_ori_z() - mp_d->get_ori_z() ;
601 if ( (
mp->r).c == 0x0 ) (
mp->r).fait() ;
602 if ( (
mp->tet).c == 0x0 ) (
mp->tet).fait() ;
603 if ( (
mp->phi).c == 0x0 ) (
mp->phi).fait() ;
604 if ( (
mp->x).c == 0x0 ) (
mp->x).fait() ;
605 if ( (
mp->y).c == 0x0 ) (
mp->y).fait() ;
606 if ( (
mp->z).c == 0x0 ) (
mp->z).fait() ;
608 const Mtbl* mr_a = (
mp->r).c ;
609 const Mtbl* mtet_a = (
mp->tet).c ;
610 const Mtbl* mphi_a = (
mp->phi).c ;
611 const Mtbl* mx_a = (
mp->x).c ;
612 const Mtbl* my_a = (
mp->y).c ;
613 const Mtbl* mz_a = (
mp->z).c ;
618 double precis = 1e-15 ;
627 for (
int l=0; l < nzet; l++) {
629 int nr = mg_a->
get_nr(l) ;
630 int nt = mg_a->
get_nt(l) ;
631 int np = mg_a->
get_np(l) ;
634 const double* pr_a = mr_a->
t[l]->
t ;
635 const double* ptet_a = mtet_a->
t[l]->
t ;
636 const double* pphi_a = mphi_a->
t[l]->
t ;
637 const double* px_a = mx_a->
t[l]->
t ;
638 const double* py_a = my_a->
t[l]->
t ;
639 const double* pz_a = mz_a->
t[l]->
t ;
643 double* ptx = (
va.c->t[l])->t ;
648 for (
int k=0 ; k<np ; k++) {
649 for (
int j=0 ; j<nt ; j++) {
650 for (
int i=0 ; i<nr ; i++) {
653 double rd, tetd, phid ;
654 if (
r == __infinity) {
662 double xd = *px_a + xx_a ;
663 double yd = *py_a + yy_a ;
664 double zd = *pz_a + zz_a ;
667 double rhod2 = xd*xd + yd*yd ;
668 double rhod =
sqrt( rhod2 ) ;
669 rd =
sqrt(rhod2 + zd*zd) ;
670 tetd = atan2(rhod, zd) ;
671 phid = atan2(yd, xd) ;
672 if (phid < 0) phid += 2*M_PI ;
685 mp_d->val_lx(rd, tetd, phid, par_precis, ld, xxd) ;
int get_np(int l) const
Returns the number of points in the azimuthal direction ( ) in domain no. l.
int get_nt(int l) const
Returns the number of points in the co-latitude direction ( ) in domain no. l.
int get_nzone() const
Returns the number of domains.
int get_nr(int l) const
Returns the number of points in the radial direction ( ) in domain no. l.
double val_point(int l, double x, double theta, double phi) const
Computes the value of the field represented by *this at an arbitrary point, by means of the spectral ...
Tbl ** t
Array (size nzone ) of pointers on the Tbl 's.
void add_double(const double &x, int position=0)
Adds the the address of a new double to the list.
void add_int_mod(int &n, int position=0)
Adds the address of a new modifiable int to the list.
void add_int(const int &n, int position=0)
Adds the address of a new int to the list.
void set_etat_one()
Sets the logical state to ETATUN (one).
void import_align(int nzet, const Scalar &ci)
Assignment to another Scalar defined on a different mapping, when the two mappings have aligned Carte...
int get_dzpuis() const
Returns dzpuis.
virtual void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
void import_gal(int nzet, const Scalar &ci)
Assignment to another Scalar defined on a different mapping, when the two mappings do not have a part...
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.
Scalar(const Map &mpi)
Constructor from mapping.
const Valeur & get_spectral_va() const
Returns va (read only version).
void del_t()
Logical destructor.
int get_etat() const
Returns the logical state ETATNONDEF (undefined), ETATZERO (null) or ETATQCQ (ordinary).
void set_dzpuis(int)
Modifies the dzpuis flag.
Valeur va
The numerical value of the Scalar.
friend Scalar sqrt(const Scalar &)
Square root.
void import_anti(int nzet, const Scalar &ci)
Assignment to another Scalar defined on a different mapping, when the two mappings have anti-aligned ...
void import(const Scalar &ci)
Assignment to another Scalar defined on a different mapping.
double * t
The array of double.
Values and coefficients of a (real-value) function.
Mtbl_cf * c_cf
Coefficients of the spectral expansion of the function.
void coef() const
Computes the coeffcients of *this.
const Map & get_mp() const
Returns the mapping.
const Map *const mp
Mapping on which the numerical values at the grid points are defined.
Map(const Mg3d &)
Constructor from a multi-domain 3D grid.
Coord r
r coordinate centered on the grid