32char 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"
251 assert( mpi.get_mg() == &mgi ) ;
282 va.set_etat_nondef() ;
325 if (
etat == ETATZERO) return ;
335 if (
etat == ETATUN) return ;
345 if (
etat == ETATNONDEF) return ;
355 if (
etat == ETATQCQ) return ;
368 va.set_etat_c_qcq() ;
394 if ( (l_min == 0) && (l_max ==
va.mg->get_nzone()-1) ) {
399 assert(
etat != ETATNONDEF ) ;
401 if (
etat == ETATZERO ) {
405 assert( (
etat == ETATQCQ) || (
etat == ETATUN) ) ;
408 va.annule(l_min, l_max) ;
419 if (
p_lap != 0x0)
p_lap->annule(l_min, l_max) ;
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)) {
674Scalar::operator
Cmp()
const {
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 ;
773 va.display_coef(thres, precis, ost) ;
793 va.std_base_scal_odd() ;
816 assert(
etat != ETATNONDEF) ;
818 const Mg3d* mg =
mp->get_mg() ;
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 ) ;
856 assert(
va.c_cf != 0x0) ;
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) ;
910 mp->val_lx(
r, theta,
phi, l, xi) ;
913 if (l ==
mp->get_mg()->get_nzone() - 1){
917 return va.val_point(l, xi, theta,
phi);
922 return va.val_point(l, xi, theta,
phi)/
r ;
927 return va.val_point(l, xi, theta,
phi)/(
r*
r) ;
932 return va.val_point(l, xi, theta,
phi)/(
r*
r*
r) ;
937 return va.val_point(l, xi, theta,
phi)/(
r*
r*
r*
r) ;
942 cout <<
"scalar::val_point unexpected value of dzpuis !" << endl;
948 return va.val_point(l, xi, theta,
phi);
958 assert (
etat != ETATNONDEF) ;
960 const Mg3d* mg =
mp->get_mg() ;
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) {
1018 int nz =
mp->get_mg()->get_nzone() ;
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) ;
1023 if (coef) domain_c = (
va.c_cf->get_etat() == ETATQCQ) ;
1025 int np =
mp->get_mg()->get_np(lz) ;
1026 int nt =
mp->get_mg()->get_nt(lz) ;
1027 int nr =
mp->get_mg()->get_nr(lz) ;
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 ;
1043 int np =
mp->get_mg()->get_np(lz) + 2 ;
1044 int nt =
mp->get_mg()->get_nt(lz) ;
1045 int nr =
mp->get_mg()->get_nr(lz) ;
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 ;
Bases of the spectral expansions.
Vectorial bases (triads) with respect to which the tensorial components are defined.
Component of a tensorial field *** DEPRECATED : use class Scalar instead ***.
int get_etat() const
Returns the logical state.
Valeur va
The numerical value of the Cmp.
int get_dzpuis() const
Returns dzpuis.
void set_dzpuis(int)
Set a value to dzpuis.
const Map * get_mp() const
Returns the mapping.
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.
int get_type_r(int l) const
Returns the type of sampling in the radial direction in domain no.
Base_val base
Bases of the spectral expansions.
int get_etat() const
Gives the logical state.
Tbl ** t
Array (size nzone ) of pointers on the Tbl 's.
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
int get_nzone() const
Gives the number of zones (domains).
virtual void sauve(FILE *) const
Save in a file.
void set_etat_one()
Sets the logical state to ETATUN (one).
virtual void del_deriv() const
Logical destructor of the derivatives.
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).
virtual ~Scalar()
Destructor.
int get_dzpuis() const
Returns dzpuis.
Scalar * p_dsdrho
Pointer on of *this.
void operator=(const Scalar &a)
Assignment to another Scalar defined on the same mapping.
virtual void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
bool dz_nonzero() const
Returns true if the last domain is compactified and *this is not zero in this domain.
friend ostream & operator<<(ostream &, const Scalar &)
Display.
Scalar * p_dsdr
Pointer on of *this (0x0 if not up to date).
Scalar * p_stdsdp
Pointer on of *this (0x0 if not up to date).
Scalar * p_dsdx
Pointer on of *this , where (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.
bool is_nan(bool verbose=false) const
Looks for NaNs (not a number) in the scalar field.
Scalar * p_dsdz
Pointer on of *this , where (0x0 if not up to date).
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...
virtual void set_etat_zero()
Sets the logical state to ETATZERO (zero).
virtual void change_triad(const Base_vect &new_triad)
Sets a new vectorial basis (triad) of decomposition and modifies the components accordingly.
int ind_lap
Power of r by which the last computed Laplacian has been multiplied in the compactified external doma...
virtual void annule(int l_min, int l_max)
Sets the Scalar to zero in several domains.
Scalar(const Map &mpi)
Constructor from mapping.
Scalar * p_srstdsdp
Pointer on of *this (0x0 if not up to date).
void annule_hard()
Sets the Scalar to zero in a hard way.
void del_t()
Logical destructor.
int etat
The logical state ETATNONDEF (undefined), ETATZERO (null), ETATUN (one), or ETATQCQ (ordinary).
int get_etat() const
Returns the logical state ETATNONDEF (undefined), ETATZERO (null) or ETATQCQ (ordinary).
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).
void set_dzpuis(int)
Modifies the dzpuis flag.
Scalar * p_lapang
Pointer on the Laplacian of *this (0x0 if not up to date).
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.
Tbl multipole_spectrum() const
Gives the spectrum in terms of multipolar modes l .
virtual void std_spectral_base_odd()
Sets the spectral bases of the Valeur va to the standard odd ones for a scalar field.
Valeur va
The numerical value of the Scalar.
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.
Scalar * p_dsdradial
Pointer on of *this.
Tbl * p_integ
Pointer on the space integral of *this (values in each domain) (0x0 if not up to date).
Scalar * p_dsdt
Pointer on of *this (0x0 if not up to date).
void set_der_0x0() const
Sets the pointers for derivatives to 0x0.
Scalar * p_srdsdt
Pointer on of *this (0x0 if not up to date).
void set_spectral_base(const Base_val &)
Sets the spectral bases of the Valeur va.
int dzpuis
Power of r by which the quantity represented by this must be divided in the compactified external d...
void annule_hard()
Sets the Tbl to zero in a hard way.
void set_etat_zero()
Sets the logical state to ETATZERO (zero).
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).
Values and coefficients of a (real-value) function.
const Base_val & get_base() const
Return the bases for spectral expansions (member base ).
int get_etat() const
Returns the logical state.
void ylm()
Computes the coefficients of *this.
Mtbl_cf * c_cf
Coefficients of the spectral expansion of the function.
void coef() const
Computes the coeffcients of *this.
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 fwrite_be(const int *aa, int size, int nb, FILE *fich)
Writes integer(s) into a binary file according to the big endian convention.
const Map & get_mp() const
Returns the mapping.
const Map *const mp
Mapping on which the numerical values at the grid points are defined.
Tensor(const Map &map, int val, const Itbl &tipe, const Base_vect &triad_i)
Standard constructor.
int valence
Valence of the tensor (0 = scalar, 1 = vector, etc...).
Scalar ** cmp
Array of size n_comp of pointers onto the components.
virtual void del_deriv() const
Deletes the derived quantities.
const Mg3d * get_mg() const
Gives the Mg3d on which the mapping is defined.
Map(const Mg3d &)
Constructor from a multi-domain 3D grid.
Coord phi
coordinate centered on the grid
Coord x
x coordinate centered on the grid
Coord r
r coordinate centered on the grid