198 #include "type_parite.h" 199 #include "utilitaires.h" 222 dzpuis(ti.cmp[0]->dzpuis), va(ti.cmp[0]->va) {
235 dzpuis(sci.dzpuis), va(sci.va) {
246 dzpuis(ci.get_dzpuis()),
257 assert( mpi.
get_mg() == &mgi ) ;
331 if (
etat == ETATZERO) return ;
341 if (
etat == ETATUN) return ;
351 if (
etat == ETATNONDEF) return ;
361 if (
etat == ETATQCQ) return ;
405 assert(
etat != ETATNONDEF ) ;
407 if (
etat == ETATZERO ) {
411 assert( (
etat == ETATQCQ) || (
etat == ETATUN) ) ;
455 assert(&ci !=
this) ;
458 assert(
mp == ci.
mp ) ;
494 cout <<
"Unkwown state in Scalar::operator=(const Scalar&) !" 540 cout <<
"Unkwown state in Scalar::operator=(const Cmp&) !" 563 assert(vi.
get_etat() != ETATNONDEF) ;
588 cout <<
"Unkwown state in Scalar::operator=(const Valeur&) !" << endl ;
601 assert(mi.
get_etat() != ETATNONDEF) ;
603 assert(&mi !=
va.
c) ;
627 cout <<
"Unkwown state in Scalar::operator=(const Mtbl&) !" << endl ;
640 if (x ==
double(0)) {
644 if (x ==
double(1)) {
680 Scalar::operator
Cmp()
const {
708 ostream& operator<<(ostream& ost,
const Scalar& ci) {
712 ost <<
"*** UNDEFINED STATE *** " << endl ;
717 ost <<
"*** identically ZERO ***" << endl ;
722 ost <<
"*** identically ONE ***" << endl ;
727 ost <<
"*** dzpuis = " << ci.
get_dzpuis() << endl ;
728 ost << ci.
va << endl ;
733 cout <<
"operator<<(ostream&, const Scalar&) : unknown state !" 748 double thres,
int precis, ostream& ost)
const {
751 if (comment != 0x0) {
752 ost << comment <<
" : " << endl ;
758 if (
etat == ETATNONDEF) {
759 ost <<
"*** UNDEFINED ***" << endl << endl ;
763 if (
etat == ETATZERO) {
764 ost <<
"*** identically ZERO ***" << endl ;
768 if (
etat == ETATUN) {
769 ost <<
"*** identically ONE ***" << endl ;
777 ost <<
"*** dzpuis = " <<
dzpuis << endl ;
822 assert(
etat != ETATNONDEF) ;
831 if (
etat == ETATZERO) {
835 if (
etat == ETATUN) {
839 assert(
etat == ETATQCQ ) ;
841 if (
va.
etat == ETATZERO) {
845 assert(
va.
etat == ETATQCQ) ;
848 if ( (
va.
c)->get_etat() == ETATZERO ) {
852 assert( (
va.
c)->get_etat() == ETATQCQ ) ;
853 if ( (
va.
c)->t[nzm1]->get_etat() == ETATZERO ) {
857 assert( (
va.
c)->t[nzm1]->get_etat() == ETATQCQ ) ;
863 if ( (
va.
c_cf)->get_etat() == ETATZERO ) {
866 assert( (
va.
c_cf)->get_etat() == ETATQCQ ) ;
867 if ( (
va.
c_cf)->t[nzm1]->get_etat() == ETATZERO ) {
871 assert( (
va.
c_cf)->t[nzm1]->get_etat() == ETATQCQ ) ;
899 assert(
etat != ETATNONDEF) ;
901 if (
etat == ETATZERO) {
905 if (
etat == ETATUN) {
909 assert(
etat == ETATQCQ) ;
948 cout <<
"scalar::val_point unexpected value of dzpuis !" << endl;
964 assert (
etat != ETATNONDEF) ;
970 for (
int lz=0; lz<nzone; lz++)
971 lmax = (lmax < 2*mg->get_nt(lz) - 1 ? 2*mg->
get_nt(lz) - 1 : lmax) ;
973 Tbl resu(nzone, lmax) ;
974 if (
etat == ETATZERO) {
979 assert((
etat == ETATQCQ) || (
etat == ETATUN));
987 int m_quant, l_quant, base_r ;
988 for (
int lz=0; lz<nzone; lz++)
989 for (
int k=0 ; k<mg->
get_np(lz) ; k++)
990 for (
int j=0 ; j<mg->
get_nt(lz) ; j++) {
991 if (nullite_plm(j, mg->
get_nt(lz), k, mg->
get_np(lz), base) == 1)
994 donne_lm(nzone, lz, j, k, base, m_quant, l_quant, base_r) ;
995 for (
int i=0; i<mg->
get_nr(lz); i++) resu.
set(lz, l_quant)
996 += fabs((*va_copy.
c_cf)(lz, k, j, i)) ;
1005 cout <<
"WARNING: Scalar::change_triad : "<< endl ;
1006 cout <<
"This method does nothing ... " << endl ;
1017 if (
etat == ETATQCQ) {
1025 for (
int lz=0; lz<nz; lz++) {
1026 bool domain_p = false ;
1027 bool domain_c = false ;
1028 if (phys) domain_p = (
va.
c->
get_etat() == ETATQCQ) ;
1034 for (
int k=0; k<np; k++) {
1035 for (
int j=0; j<nt; j++) {
1036 for (
int i=0; i<nr; i++) {
1037 if (std::isnan( (*
va.
c)(lz, k, j, i) ) ) {
1040 cout <<
"NaN found at physical grid point domain = " << lz
1041 <<
", i= " << i <<
", j= " << j <<
", k= " << k << endl ;
1052 for (
int k=0; k<np; k++) {
1053 for (
int j=0; j<nt; j++) {
1054 for (
int i=0; i<nr; i++) {
1055 if (std::isnan( (*
va.
c_cf)(lz, k, j, i) ) ) {
1058 cout <<
"NaN found at coefficient, domain = " << lz
1059 <<
", i= " << i <<
", j= " << j <<
", k= " << k << endl ;
const Map * get_mp() const
Returns the mapping.
Scalar * p_srdsdt
Pointer on of *this (0x0 if not up to date)
void std_base_scal_odd()
Sets the bases for spectral expansions (member base ) to the standard odd ones for a scalar...
Scalar * p_srstdsdp
Pointer on of *this (0x0 if not up to date)
Mtbl_cf * c_cf
Coefficients of the spectral expansion of the function.
Component of a tensorial field *** DEPRECATED : use class Scalar instead ***.
int get_np(int l) const
Returns the number of points in the azimuthal direction ( ) in domain no. l.
void coef() const
Computes the coeffcients of *this.
virtual void set_etat_zero()
Sets the logical state to ETATZERO (zero).
void set_der_0x0() const
Sets the pointers for derivatives to 0x0.
virtual void annule(int l_min, int l_max)
Sets the Scalar to zero in several domains.
void set_etat_zero()
Sets the logical state to ETATZERO (zero).
Scalar(const Map &mpi)
Constructor from mapping.
void ylm()
Computes the coefficients of *this.
void annule_hard()
Sets the Valeur to zero in a hard way.
const Mg3d * get_mg() const
Gives the Mg3d on which the mapping is defined.
int get_etat() const
Returns the logical state.
double & set(int i)
Read/write of a particular element (index i) (1D case)
Tbl multipole_spectrum() const
Gives the spectrum in terms of multipolar modes l .
Tensor field of valence 0 (or component of a tensorial field).
virtual void change_triad(const Base_vect &new_triad)
Sets a new vectorial basis (triad) of decomposition and modifies the components accordingly.
Base class for coordinate mappings.
Scalar * p_dsdt
Pointer on of *this (0x0 if not up to date)
void display_coef(double threshold=1.e-7, int precision=4, ostream &ostr=cout) const
Displays the spectral coefficients and the associated basis functions.
int ind_lap
Power of r by which the last computed Laplacian has been multiplied in the compactified external doma...
virtual void std_spectral_base()
Sets the spectral bases of the Valeur va to the standard ones for a scalar field. ...
Values and coefficients of a (real-value) function.
virtual void allocate_all()
Sets the logical state to ETATQCQ (ordinary state) and performs the memory allocation of all the elem...
virtual void set_etat_nondef()
Sets the logical state to ETATNONDEF (undefined).
int dzpuis
Power of r by which the quantity represented by this must be divided in the compactified external do...
void annule(int l)
Sets the Valeur to zero in a given domain.
virtual void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
int get_etat() const
Returns the logical state.
Vectorial bases (triads) with respect to which the tensorial components are defined.
void set_base(const Base_val &)
Sets the bases for spectral expansions (member base )
void std_base_scal()
Sets the bases for spectral expansions (member base ) to the standard ones for a scalar.
void set_dzpuis(int)
Modifies the dzpuis flag.
void annule_hard()
Sets the Scalar to zero in a hard way.
Scalar * p_lap
Pointer on the Laplacian of *this (0x0 if not up to date)
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
int get_etat() const
Gives the logical state.
int get_etat() const
Returns the logical state.
Tbl * p_integ
Pointer on the space integral of *this (values in each domain) (0x0 if not up to date) ...
const Mg3d * mg
Multi-grid Mgd3 on which this is defined.
virtual void sauve(FILE *) const
Save in a file.
virtual void del_deriv() const
Logical destructor of the derivatives.
Scalar * p_dsdradial
Pointer on of *this.
int get_nzone() const
Gives the number of zones (domains)
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 ...
Scalar * p_dsdrho
Pointer on of *this.
void sauve(FILE *) const
Save in a file.
Scalar * p_dsdy
Pointer on of *this , where (0x0 if not up to date)
void operator=(const Scalar &a)
Assignment to another Scalar defined on the same mapping.
void set_etat_nondef()
Sets the logical state to ETATNONDEF (undefined).
Scalar * p_lapang
Pointer on the Laplacian of *this (0x0 if not up to date)
void del_t()
Logical destructor.
int get_dzpuis() const
Returns dzpuis.
Scalar ** cmp
Array of size n_comp of pointers onto the components.
virtual void spectral_display(const char *comment=0x0, double threshold=1.e-7, int precision=4, ostream &ostr=cout) const
Displays the spectral coefficients and the associated basis functions.
Mtbl * c
Values of the function at the points of the multi-grid.
void set_etat_one()
Sets the logical state to ETATUN (one).
int get_nzone() const
Returns the number of domains.
Valeur va
The numerical value of the Scalar.
void del_t()
Logical destructor.
virtual void std_spectral_base_odd()
Sets the spectral bases of the Valeur va to the standard odd ones for a scalar field.
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.
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
void set_etat_zero()
Sets the logical state to ETATZERO (zero).
virtual void del_deriv() const
Deletes the derived quantities.
double val_point(double r, double theta, double phi) const
Computes the value of the field at an arbitrary point , by means of the spectral expansion.
void set_spectral_base(const Base_val &)
Sets the spectral bases of the Valeur va
int fread_be(int *aa, int size, int nb, FILE *fich)
Reads integer(s) from a binary file according to the big endian convention.
int valence
Valence of the tensor (0 = scalar, 1 = vector, etc...)
int get_nr(int l) const
Returns the number of points in the radial direction ( ) in domain no. l.
Bases of the spectral expansions.
Scalar * p_dsdz
Pointer on of *this , where (0x0 if not up to date)
bool dz_nonzero() const
Returns true if the last domain is compactified and *this is not zero in this domain.
int get_dzpuis() const
Returns dzpuis.
virtual ~Scalar()
Destructor.
int etat
The logical state ETATNONDEF (undefined), ETATZERO (null), ETATUN (one), or ETATQCQ (ordinary)...
Scalar * p_stdsdp
Pointer on of *this (0x0 if not up to date)
Scalar * p_dsdr
Pointer on of *this (0x0 if not up to date)
void set_etat_c_qcq()
Sets the logical state to ETATQCQ (ordinary state) for values in the configuration space (Mtbl c )...
Base_val base
Bases of the spectral expansions.
int etat
Logical state (ETATNONDEF , ETATQCQ or ETATZERO ).
void set_dzpuis(int)
Set a value to dzpuis.
int get_nt(int l) const
Returns the number of points in the co-latitude direction ( ) in domain no. l.
int get_type_r(int l) const
Returns the type of sampling in the radial direction in domain no.
bool check_dzpuis(int dzi) const
Returns false if the last domain is compactified and *this is not zero in this domain and dzpuis is n...
bool is_nan(bool verbose=false) const
Looks for NaNs (not a number) in the scalar field.
const Map *const mp
Mapping on which the numerical values at the grid points are defined.
Tbl ** t
Array (size nzone ) of pointers on the Tbl 's.
void annule_hard()
Sets the Tbl to zero in a hard way.
Valeur va
The numerical value of the Cmp.
virtual void val_lx(double rr, double theta, double pphi, int &l, double &xi) const =0
Computes the domain index l and the value of corresponding to a point given by its physical coordina...
const Base_val & get_base() const
Return the bases for spectral expansions (member base )
Scalar * p_dsdx
Pointer on of *this , where (0x0 if not up to date)