32 char scalar_C[] =
"$Header: /cvsroot/Lorene/C++/Source/Tensor/Scalar/scalar.C,v 1.40 2015/12/18 15:52:52 j_novak Exp $" ;
192 #include "type_parite.h"
193 #include "utilitaires.h"
204 Scalar::Scalar(
const Map& mpi) :
Tensor(mpi), etat(ETATNONDEF), dzpuis(0),
215 Scalar::Scalar(
const Tensor& ti) :
Tensor(*(ti.mp)), etat(ti.cmp[0]->etat),
216 dzpuis(ti.cmp[0]->dzpuis), va(ti.cmp[0]->va) {
229 dzpuis(sci.dzpuis), va(sci.va) {
240 dzpuis(ci.get_dzpuis()),
251 assert( mpi.
get_mg() == &mgi ) ;
325 if (
etat == ETATZERO) return ;
335 if (
etat == ETATUN) return ;
345 if (
etat == ETATNONDEF) return ;
355 if (
etat == ETATQCQ) return ;
399 assert(
etat != ETATNONDEF ) ;
401 if (
etat == ETATZERO ) {
405 assert( (
etat == ETATQCQ) || (
etat == ETATUN) ) ;
449 assert(&ci !=
this) ;
452 assert(
mp == ci.
mp ) ;
488 cout <<
"Unkwown state in Scalar::operator=(const Scalar&) !"
534 cout <<
"Unkwown state in Scalar::operator=(const Cmp&) !"
557 assert(vi.
get_etat() != ETATNONDEF) ;
582 cout <<
"Unkwown state in Scalar::operator=(const Valeur&) !" << endl ;
595 assert(mi.
get_etat() != ETATNONDEF) ;
597 assert(&mi !=
va.
c) ;
621 cout <<
"Unkwown state in Scalar::operator=(const Mtbl&) !" << endl ;
634 if (x ==
double(0)) {
638 if (x ==
double(1)) {
674 Scalar::operator
Cmp()
const {
702 ostream& operator<<(ostream& ost,
const Scalar& ci) {
706 ost <<
"*** UNDEFINED STATE *** " << endl ;
711 ost <<
"*** identically ZERO ***" << endl ;
716 ost <<
"*** identically ONE ***" << endl ;
721 ost <<
"*** dzpuis = " << ci.
get_dzpuis() << endl ;
722 ost << ci.
va << endl ;
727 cout <<
"operator<<(ostream&, const Scalar&) : unknown state !"
742 double thres,
int precis, ostream& ost)
const {
745 if (comment != 0x0) {
746 ost << comment <<
" : " << endl ;
752 if (
etat == ETATNONDEF) {
753 ost <<
"*** UNDEFINED ***" << endl << endl ;
757 if (
etat == ETATZERO) {
758 ost <<
"*** identically ZERO ***" << endl ;
762 if (
etat == ETATUN) {
763 ost <<
"*** identically ONE ***" << endl ;
771 ost <<
"*** dzpuis = " <<
dzpuis << endl ;
816 assert(
etat != ETATNONDEF) ;
825 if (
etat == ETATZERO) {
829 if (
etat == ETATUN) {
833 assert(
etat == ETATQCQ ) ;
835 if (
va.
etat == ETATZERO) {
839 assert(
va.
etat == ETATQCQ) ;
842 if ( (
va.
c)->get_etat() == ETATZERO ) {
846 assert( (
va.
c)->get_etat() == ETATQCQ ) ;
847 if ( (
va.
c)->t[nzm1]->get_etat() == ETATZERO ) {
851 assert( (
va.
c)->t[nzm1]->get_etat() == ETATQCQ ) ;
857 if ( (
va.
c_cf)->get_etat() == ETATZERO ) {
860 assert( (
va.
c_cf)->get_etat() == ETATQCQ ) ;
861 if ( (
va.
c_cf)->t[nzm1]->get_etat() == ETATZERO ) {
865 assert( (
va.
c_cf)->t[nzm1]->get_etat() == ETATQCQ ) ;
893 assert(
etat != ETATNONDEF) ;
895 if (
etat == ETATZERO) {
899 if (
etat == ETATUN) {
903 assert(
etat == ETATQCQ) ;
942 cout <<
"scalar::val_point unexpected value of dzpuis !" << endl;
958 assert (
etat != ETATNONDEF) ;
964 for (
int lz=0; lz<nzone; lz++)
965 lmax = (lmax < 2*mg->get_nt(lz) - 1 ? 2*mg->
get_nt(lz) - 1 : lmax) ;
967 Tbl resu(nzone, lmax) ;
968 if (
etat == ETATZERO) {
973 assert((
etat == ETATQCQ) || (
etat == ETATUN));
981 int m_quant, l_quant, base_r ;
982 for (
int lz=0; lz<nzone; lz++)
983 for (
int k=0 ; k<mg->
get_np(lz) ; k++)
984 for (
int j=0 ; j<mg->
get_nt(lz) ; j++) {
985 if (nullite_plm(j, mg->
get_nt(lz), k, mg->
get_np(lz), base) == 1)
988 donne_lm(nzone, lz, j, k, base, m_quant, l_quant, base_r) ;
989 for (
int i=0; i<mg->
get_nr(lz); i++) resu.
set(lz, l_quant)
990 += fabs((*va_copy.
c_cf)(lz, k, j, i)) ;
999 cout <<
"WARNING: Scalar::change_triad : "<< endl ;
1000 cout <<
"This method does nothing ... " << endl ;
1011 if (
etat == ETATQCQ) {
1019 for (
int lz=0; lz<nz; lz++) {
1020 bool domain_p = false ;
1021 bool domain_c = false ;
1022 if (phys) domain_p = (
va.
c->
get_etat() == ETATQCQ) ;
1028 for (
int k=0; k<np; k++) {
1029 for (
int j=0; j<nt; j++) {
1030 for (
int i=0; i<nr; i++) {
1031 if (isnan( (*
va.
c)(lz, k, j, i) ) ) {
1034 cout <<
"NaN found at physical grid point domain = " << lz
1035 <<
", i= " << i <<
", j= " << j <<
", k= " << k << endl ;
1046 for (
int k=0; k<np; k++) {
1047 for (
int j=0; j<nt; j++) {
1048 for (
int i=0; i<nr; i++) {
1049 if (isnan( (*
va.
c_cf)(lz, k, j, i) ) ) {
1052 cout <<
"NaN found at coefficient, domain = " << lz
1053 <<
", i= " << i <<
", j= " << j <<
", k= " << k << endl ;
virtual void sauve(FILE *) const
Save in a file.
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.
double & set(int i)
Read/write of a particular element (index i) (1D case)
Bases of the spectral expansions.
int get_np(int l) const
Returns the number of points in the azimuthal direction ( ) in domain no. l.
Values and coefficients of a (real-value) function.
Scalar * p_dsdz
Pointer on of *this , where (0x0 if not up to date)
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 set_etat_c_qcq()
Sets the logical state to ETATQCQ (ordinary state) for values in the configuration space (Mtbl c ).
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.
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...
void set_etat_one()
Sets the logical state to ETATUN (one).
virtual void std_spectral_base_odd()
Sets the spectral bases of the Valeur va to the standard odd ones for a scalar field.
void set_spectral_base(const Base_val &)
Sets the spectral bases of the Valeur va
Valeur va
The numerical value of the Scalar
void operator=(const Scalar &a)
Assignment to another Scalar defined on the same mapping.
int get_etat() const
Returns the logical state.
void del_t()
Logical destructor.
virtual void del_deriv() const
Deletes the derived quantities.
Scalar * p_dsdr
Pointer on of *this (0x0 if not up to date)
Mtbl_cf * c_cf
Coefficients of the spectral expansion of the function.
int get_nt(int l) const
Returns the number of points in the co-latitude direction ( ) in domain no. l.
void sauve(FILE *) const
Save in a file.
void annule_hard()
Sets the Tbl to zero in a hard way.
Valeur va
The numerical value of the Cmp
const Mg3d * get_mg() const
Gives the Mg3d on which the mapping is defined.
int get_etat() const
Returns the logical state.
virtual ~Scalar()
Destructor.
Scalar ** cmp
Array of size n_comp of pointers onto the components.
int get_etat() const
Returns the logical state.
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...
void annule(int l)
Sets the Valeur to zero in a given domain.
Scalar * p_stdsdp
Pointer on of *this (0x0 if not up to date)
Tensor field of valence 0 (or component of a tensorial field).
bool dz_nonzero() const
Returns true if the last domain is compactified and *this is not zero in this domain.
Mtbl * c
Values of the function at the points of the multi-grid
void coef() const
Computes the coeffcients of *this.
int etat
The logical state ETATNONDEF (undefined), ETATZERO (null), ETATUN (one), or ETATQCQ (ordinary).
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Scalar * p_srdsdt
Pointer on of *this (0x0 if not up to date)
const Map *const mp
Mapping on which the numerical values at the grid points are defined.
void annule_hard()
Sets the Valeur to zero in a hard way.
bool is_nan(bool verbose=false) const
Looks for NaNs (not a number) in the scalar field.
virtual void change_triad(const Base_vect &new_triad)
Sets a new vectorial basis (triad) of decomposition and modifies the components accordingly.
const Mg3d * mg
Multi-grid Mgd3 on which this is defined.
Scalar * p_dsdx
Pointer on of *this , where (0x0 if not up to date)
void std_base_scal()
Sets the bases for spectral expansions (member base ) to the standard ones for a scalar.
Component of a tensorial field *** DEPRECATED : use class Scalar instead ***.
int ind_lap
Power of r by which the last computed Laplacian has been multiplied in the compactified external doma...
void set_etat_zero()
Sets the logical state to ETATZERO (zero).
int etat
Logical state (ETATNONDEF , ETATQCQ or ETATZERO ).
void set_etat_nondef()
Sets the logical state to ETATNONDEF (undefined).
int get_etat() const
Gives the logical state.
virtual void allocate_all()
Sets the logical state to ETATQCQ (ordinary state) and performs the memory allocation of all the elem...
int get_nzone() const
Returns the number of domains.
int get_dzpuis() const
Returns dzpuis.
int get_nr(int l) const
Returns the number of points in the radial direction ( ) in domain no. l.
int fread_be(int *aa, int size, int nb, FILE *fich)
Reads integer(s) from a binary file according to the big endian convention.
void set_base(const Base_val &)
Sets the bases for spectral expansions (member base )
virtual void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
virtual void annule(int l_min, int l_max)
Sets the Scalar to zero in several domains.
int get_nzone() const
Gives the number of zones (domains)
virtual void set_etat_zero()
Sets the logical state to ETATZERO (zero).
void set_dzpuis(int)
Modifies the dzpuis flag.
void set_der_0x0() const
Sets the pointers for derivatives to 0x0.
Scalar * p_srstdsdp
Pointer on of *this (0x0 if not up to date)
Base_val base
Bases of the spectral expansions.
int valence
Valence of the tensor (0 = scalar, 1 = vector, etc...)
int dzpuis
Power of r by which the quantity represented by this must be divided in the compactified external d...
void std_base_scal_odd()
Sets the bases for spectral expansions (member base ) to the standard odd ones for a scalar.
Scalar * p_dsdt
Pointer on of *this (0x0 if not up to date)
virtual void std_spectral_base()
Sets the spectral bases of the Valeur va to the standard ones for a scalar field.
Tbl ** t
Array (size nzone ) of pointers on the Tbl 's.
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)
Scalar * p_dsdy
Pointer on of *this , where (0x0 if not up to date)
Tbl multipole_spectrum() const
Gives the spectrum in terms of multipolar modes l .
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 display_coef(double threshold=1.e-7, int precision=4, ostream &ostr=cout) const
Displays the spectral coefficients and the associated basis functions.
void set_etat_zero()
Sets the logical state to ETATZERO (zero).
const Base_val & get_base() const
Return the bases for spectral expansions (member base )
int get_dzpuis() const
Returns dzpuis.
void ylm()
Computes the coefficients of *this.
virtual 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)
Base class for coordinate mappings.
const Map * get_mp() const
Returns the mapping.
Tbl * p_integ
Pointer on the space integral of *this (values in each domain) (0x0 if not up to date)
Vectorial bases (triads) with respect to which the tensorial components are defined.
Scalar * p_dsdradial
Pointer on of *this
void set_dzpuis(int)
Set a value to dzpuis.
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
virtual void del_deriv() const
Logical destructor of the derivatives.
void del_t()
Logical destructor.