202#include "utilitaires.h"
219 int nzone = mg->get_nzone() ;
221 alpha =
new double[nzone] ;
222 beta =
new double[nzone] ;
224 for (
int l=0 ; l<nzone ; l++) {
225 switch (mg->get_type_r(l)) {
227 alpha[l] = bornes[l+1] - bornes[l] ;
228 beta[l] = bornes[l] ;
233 alpha[l] = (bornes[l+1] - bornes[l]) * .5 ;
234 beta[l] = (bornes[l+1] + bornes[l]) * .5 ;
239 double umax = 1./bornes[l] ;
240 double umin = 1./bornes[l+1] ;
241 alpha[l] = (umin - umax) * .5 ;
242 beta[l] = (umin + umax) * .5 ;
247 cout <<
"Map_af::Map_af: unkown type_r ! " << endl ;
264 int nzone = mg->get_nzone() ;
266 alpha =
new double[nzone] ;
267 beta =
new double[nzone] ;
269 for (
int l=0 ; l<nzone ; l++) {
270 switch (mg->get_type_r(l)) {
272 alpha[l] = bornes(l+1) - bornes(l) ;
273 beta[l] = bornes(l) ;
278 alpha[l] = (bornes(l+1) - bornes(l)) * .5 ;
279 beta[l] = (bornes(l+1) + bornes(l)) * .5 ;
284 assert (l==nzone-1) ;
285 double umax = 1./bornes(l) ;
287 alpha[l] = (umin - umax) * .5 ;
288 beta[l] = (umin + umax) * .5 ;
293 cout <<
"Map_af::Map_af: unkown type_r ! " << endl ;
310 int nzone = mg->get_nzone() ;
312 alpha =
new double[nzone] ;
313 beta =
new double[nzone] ;
315 for (
int l=0; l<nzone; l++){
327 ifstream parfile(filename.c_str()) ;
329 string message =
"Unable to open file " ;
330 message += filename ;
331 throw ios_base::failure(message);
334 string tmp_str =
"Definition of the Map_af" ;
336 string mesg =
"No data found to contruct an object Map_af in " ;
338 throw invalid_argument(mesg) ;
340 parfile.ignore(1000,
'\n') ;
345 parfile >> nz ; parfile.ignore(1000,
'\n') ;
346 if (mg->get_nzone() != nz) {
347 string mesg =
"Wrong number of domains for Map_af in " ;
349 throw(invalid_argument(mesg)) ;
353 for (
int i=0; i<nz; i++) {
354 parfile >> bornes.
set(i) ;
355 parfile.ignore(1000,
'\n') ;
358 string last_boundary ;
359 parfile >> last_boundary ;
361 if (last_boundary.compare(
"infinity") == 0) {
362 bornes.
set(nz) = __infinity ;
364 string mesg = filename
365 +
": infinite outer boundary can be set only in the ced case." ;
366 throw(invalid_argument(mesg)) ;
372 rout = stod(last_boundary) ;
374 catch(invalid_argument& ia) {
375 cerr <<
"Map_af constructor from a file, invalid argument in file\n"
376 << last_boundary << endl ;
379 bornes.
set(nz) = rout ;
381 string mesg = filename
382 +
": the ced grid type cannot accept a finite outer radius." ;
383 throw(invalid_argument(mesg)) ;
389 alpha =
new double[nz] ;
390 beta =
new double[nz] ;
392 for (
int l=0 ; l<nz ; l++) {
393 switch (mg->get_type_r(l)) {
395 alpha[l] = bornes(l+1) - bornes(l) ;
396 beta[l] = bornes(l) ;
401 alpha[l] = (bornes(l+1) - bornes(l)) * .5 ;
402 beta[l] = (bornes(l+1) + bornes(l)) * .5 ;
408 double umax = 1./bornes(l) ;
410 alpha[l] = (umin - umax) * .5 ;
411 beta[l] = (umin + umax) * .5 ;
416 cout <<
"Map_af::Map_af: unkown type_r ! " << endl ;
430 int nz = mg->get_nzone() ;
431 alpha =
new double[nz] ;
432 beta =
new double[nz] ;
450 int nz = mg->get_nzone() ;
452 alpha =
new double[nz] ;
453 beta =
new double[nz] ;
458 if( (mp0 == 0x0) && (mp1 == 0x0) ) {
459 cout <<
"Map_af::Map_af(const Map& ) : unkown mapping type !"
465 assert( mp1 == 0x0 ) ;
466 for (
int l=0; l<nz; l++){
474 assert( mp0 == 0x0 ) ;
475 for (
int l=0; l<nz; l++){
482 set_ori( mpi.get_ori_x(), mpi.get_ori_y(), mpi.get_ori_z() ) ;
509 assert(mpi.mg == mg) ;
511 set_ori( mpi.ori_x, mpi.ori_y, mpi.ori_z ) ;
515 for (
int l = 0; l<mg->get_nzone(); l++) {
533 r.set(
this, map_af_fait_r) ;
534 tet.set(
this, map_af_fait_tet) ;
535 phi.set(
this, map_af_fait_phi) ;
536 sint.set(
this, map_af_fait_sint) ;
537 cost.set(
this, map_af_fait_cost) ;
538 sinp.set(
this, map_af_fait_sinp) ;
539 cosp.set(
this, map_af_fait_cosp) ;
541 x.set(
this, map_af_fait_x) ;
542 y.set(
this, map_af_fait_y) ;
543 z.set(
this, map_af_fait_z) ;
545 xa.set(
this, map_af_fait_xa) ;
546 ya.set(
this, map_af_fait_ya) ;
547 za.set(
this, map_af_fait_za) ;
550 xsr.set(
this, map_af_fait_xsr) ;
551 dxdr.set(
this, map_af_fait_dxdr) ;
552 drdt.set(
this, map_af_fait_drdt) ;
553 stdrdp.set(
this, map_af_fait_stdrdp) ;
554 srdrdt.set(
this, map_af_fait_srdrdt) ;
555 srstdrdp.set(
this, map_af_fait_srstdrdp) ;
556 sr2drdt.set(
this, map_af_fait_sr2drdt) ;
557 sr2stdrdp.set(
this, map_af_fait_sr2stdrdp) ;
558 d2rdx2.set(
this, map_af_fait_d2rdx2) ;
559 lapr_tp.set(
this, map_af_fait_lapr_tp) ;
560 d2rdtdx.set(
this, map_af_fait_d2rdtdx) ;
561 sstd2rdpdx.set(
this, map_af_fait_sstd2rdpdx) ;
562 sr2d2rdt2.set(
this, map_af_fait_sr2d2rdt2) ;
569 double precis = 1e-10 ;
577 if (*mg != *(mpi.get_mg()))
580 if (fabs(ori_x-mpi.get_ori_x()) > precis) resu = false ;
581 if (fabs(ori_y-mpi.get_ori_y()) > precis) resu = false ;
582 if (fabs(ori_z-mpi.get_ori_z()) > precis) resu = false ;
584 if (
bvect_spher != mpi.get_bvect_spher()) resu = false ;
585 if (
bvect_cart != mpi.get_bvect_cart()) resu = false ;
587 int nz = mg->get_nzone() ;
588 for (
int i=0 ; i<nz ; i++) {
591 if ((i!=0) && (i!=nz-1))
620 int nz = mg->get_nzone() ;
634 ost <<
"Affine mapping (class Map_af)" << endl ;
635 int nz = mg->get_nzone() ;
636 for (
int l=0; l<nz; l++) {
637 ost <<
" Domain #" << l <<
" : alpha_l = " <<
alpha[l]
638 <<
" , beta_l = " <<
beta[l] << endl ;
641 ost << endl <<
" Values of r at the outer boundary of each domain [km] :"
644 for (
int l=0; l<nz; l++) {
645 ost <<
" " <<
val_r(l, 1., 0., 0.) / km ;
649 ost <<
" Coord r : " ;
650 for (
int l=0; l<nz; l++) {
651 int nrm1 = mg->get_nr(l) - 1 ;
652 ost <<
" " << (+
r)(l, 0, 0, nrm1) / km ;
666 int nz = mg->get_nzone() ;
668 for (
int l=0; l<nz; l++) {
669 if (mg->get_type_r(l) == UNSURR) {
691 if (mg->get_type_r(l) != FIN) {
692 cout <<
"Map_af::resize can be applied only to a shell !" << endl ;
698 double n_alpha = 0.5 * ( (lambda + 1.) *
alpha[l] +
699 (lambda - 1.) *
beta[l] ) ;
701 double n_beta = 0.5 * ( (lambda - 1.) *
alpha[l] +
702 (lambda + 1.) *
beta[l] ) ;
709 assert(l<mg->get_nzone()-1) ;
712 if (mg->get_type_r(lp1) == UNSURR) {
720 assert( mg->get_type_r(lp1) == FIN ) ;
723 alpha[lp1] = n_alpha ;
747 double asauve =
alpha[1] ;
749 beta[1] = (1+fact)/2.*
beta[1]+ (1-fact)/2. * asauve ;
760 assert(l<mg->get_nzone()) ;
771 assert(l<mg->get_nzone()) ;
787 double Rb =
val_r_jk(l_zone, 1., 0, 0) ;
801 const char* f = __FILE__ ;
806 Cmp& uu,
double lambda)
const {
Component of a tensorial field *** DEPRECATED : use class Scalar instead ***.
virtual ostream & operator>>(ostream &) const
Operator >>.
const double * get_beta() const
Returns the pointer on the array beta.
const double * get_alpha() const
Returns the pointer on the array alpha.
void set_beta(double beta0, int l)
Modifies the value of in domain no. l.
virtual void adapt(const Cmp &ent, const Param &par, int nbr=0)
Adaptation of the mapping to a given scalar field.
void set_coord()
Assignment of the building functions to the member Coords.
Map_af(const Mg3d &mgrille, const double *r_limits)
Standard Constructor.
virtual ~Map_af()
Destructor.
virtual void sauve(FILE *) const
Save in a file.
double * beta
Array (size: mg->nzone ) of the values of in each domain.
virtual void operator=(const Map_af &)
Assignment to another affine mapping.
void homothetie_interne(double lambda)
Sets a new radial scale at the bondary between the nucleus and the first shell.
virtual void homothetie(double lambda)
Sets a new radial scale.
virtual void poisson_angu(const Scalar &source, Param &par, Scalar &uu, double lambda=0) const
Computes the solution of the generalized angular Poisson equation.
double * alpha
Array (size: mg->nzone ) of the values of in each domain.
virtual bool operator==(const Map &) const
Comparison operator (egality).
void set_alpha(double alpha0, int l)
Modifies the value of in domain no. l.
virtual void resize(int l, double lambda)
Rescales the outer boundary of one domain.
virtual double val_r_jk(int l, double xi, int j, int k) const
Returns the value of the radial coordinate r for a given and a given collocation point in in a give...
virtual const Map_af & mp_angu(int) const
Returns the "angular" mapping for the outside of domain l_zone.
virtual double val_r(int l, double xi, double theta, double pphi) const
Returns the value of the radial coordinate r for a given in a given domain.
Radial mapping of rather general form.
const double * get_alpha() const
Returns a pointer on the array alpha (values of in each domain).
const double * get_beta() const
Returns a pointer on the array beta (values of in each domain).
Coord d2rdx2
in the nucleus and in the non-compactified shells; \ in the compactified outer domain.
Coord sr2drdt
in the nucleus and in the non-compactified shells; \ in the compactified outer domain.
Coord srstdrdp
in the nucleus and in the non-compactified shells; \ in the compactified outer domain.
Coord d2rdtdx
in the nucleus and in the non-compactified shells; \ in the compactified outer domain.
Coord sstd2rdpdx
in the nucleus and in the non-compactified shells; \ in the compactified outer domain.
virtual void reset_coord()
Resets all the member Coords.
Coord lapr_tp
in the nucleus and in the non-compactified shells; \ in the compactified outer domain.
Coord sr2stdrdp
in the nucleus and in the non-compactified shells; \ in the compactified outer domain.
Coord drdt
in the nucleus and in the non-compactified shells; \ in the compactified external domain (CED).
Coord srdrdt
in the nucleus and in the non-compactified shells; \ in the compactified outer domain.
Map_radial(const Mg3d &mgrid)
Constructor from a grid (protected to make Map_radial an abstract class).
Coord xsr
in the nucleus; \ 1/R in the non-compactified shells; \ in the compactified outer domain.
virtual void sauve(FILE *) const
Save in a file.
Coord dxdr
in the nucleus and in the non-compactified shells; \ in the compactified outer domain.
Coord sr2d2rdt2
in the nucleus and in the non-compactified shells; \ in the compactified outer domain.
Coord stdrdp
in the nucleus and in the non-compactified shells; \ in the compactified external domain (CED).
const Mg3d * get_angu_1dom() const
Returns the pointer on the associated mono-domain angular grid.
int get_type_r(int l) const
Returns the type of sampling in the radial direction in domain no.
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
double & set(int i)
Read/write of a particular element (index i) (1D case).
Base_vect_spher bvect_spher
Base class for coordinate mappings.
void c_est_pas_fait(const char *)
Helpful function to say something is not implemented yet.
int fread_be(int *aa, int size, int nb, FILE *fich)
Reads integer(s) from a binary file according to the big endian convention.
bool search_file(ifstream &infile, const string &pattern)
A function that searches for a pattern in a file and places the file stream after the found pattern.
int fwrite_be(const int *aa, int size, int nb, FILE *fich)
Writes integer(s) into a binary file according to the big endian convention.
Map_af * p_mp_angu
Pointer on the "angular" mapping.
Coord z
z coordinate centered on the grid
Base_vect_cart bvect_cart
Cartesian basis associated with the coordinates (x,y,z) of the mapping, i.e.
const Mg3d * get_mg() const
Gives the Mg3d on which the mapping is defined.
Coord y
y coordinate centered on the grid
Map(const Mg3d &)
Constructor from a multi-domain 3D grid.
Coord phi
coordinate centered on the grid
Coord tet
coordinate centered on the grid
void set_rot_phi(double phi0)
Sets a new rotation angle.
Coord x
x coordinate centered on the grid
Coord xa
Absolute x coordinate.
Coord za
Absolute z coordinate.
void set_ori(double xa0, double ya0, double za0)
Sets a new origin.
Coord r
r coordinate centered on the grid
Coord ya
Absolute y coordinate.
Standard units of space, time and mass.