32char tenseur_C[] =
"$Header: /cvsroot/Lorene/C++/Source/Tenseur/tenseur.C,v 1.15 2014/10/13 08:53:41 j_novak Exp $" ;
184#include "utilitaires.h"
201 for (
int i=0;
i<N_MET_MAX;
i++) {
210 mp(&map), valence(0), triad(0x0),
211 type_indice(0), n_comp(1), etat(ETATNONDEF), poids(
weight),
225 mp(
ci.get_mp()), valence(0), triad(0x0),
226 type_indice(0), n_comp(1), etat(
ci.get_etat()), poids(
weight),
229 assert(
ci.get_etat() != ETATNONDEF) ;
234 if (
ci.get_etat() != ETATZERO ) {
235 assert(
ci.get_etat() == ETATQCQ ) ;
248 : mp(&map), valence(val), triad(&
triad_i), type_indice(
tipe),
249 n_comp(
int(
pow(3., val))), etat(ETATNONDEF), poids(
weight),
270 : mp(&map), valence(val), triad(
triad_i), type_indice(
tipe),
271 n_comp(
int(
pow(3., val))), etat(ETATNONDEF), poids(
weight),
299 : mp(&map), valence(val), triad(&
triad_i), type_indice(val),
300 n_comp(
int(
pow(3., val))), etat (ETATNONDEF), poids(
weight),
342 if (
source.p_gradient != 0x0)
345 if (
source.p_gradient_spher != 0x0)
348 for (
int i=0;
i<N_MET_MAX;
i++) {
354 if (
source.p_derive_cov[
i] != 0x0)
356 if (
source.p_derive_con[
i] != 0x0)
358 if (
source.p_carre_scal[
i] != 0x0)
389 if (
source.p_gradient != 0x0)
392 for (
int i=0;
i<N_MET_MAX;
i++) {
398 if (
source.p_derive_cov[
i] != 0x0)
400 if (
source.p_derive_con[
i] != 0x0)
402 if (
source.p_carre_scal[
i] != 0x0)
465 if (
etat == ETATQCQ) {
488 etat (ETATNONDEF), poids(
weight), metric(
met) {
511 mp(&map), valence(val), triad(&
triad_i), type_indice(val), n_comp(
compo),
512 etat (ETATNONDEF), poids(
weight), metric(
met) {
574 for (
int i=0;
i<N_MET_MAX;
i++)
592 for (
int i=0;
i<N_MET_MAX;
i++)
600 for (
int i=0;
i<N_MET_MAX;
i++)
612 for (
int i=0;
i<N_MET_MAX;
i++) {
616 if (
nmet == N_MET_MAX) {
617 cout <<
"Too many metrics in Tenseur::set_dependances" <<
endl ;
626 cout <<
"Too many dependancies in Tenseur::set_dependances " <<
endl ;
670 bi.change_basis(*
this) ;
753 cout <<
"Unknown state in Tenseur::operator= " <<
endl ;
767 switch (
ci.get_etat()) {
785 cout <<
"Unknown state in Tenseur::operator= " <<
endl ;
796 if (x ==
double(0)) {
892 assert ((indices(
i)>=0) && (indices(
i)<3)) ;
908 if ( (
l_min == 0) && (
l_max ==
mp->get_mg()->get_nzone()-1) ) {
915 if (
etat == ETATZERO ) {
929 for (
int j=0;
j<N_MET_MAX;
j++) {
947 if (
etat == ETATQCQ)
return *
c[0] ;
953 cout <<
"Undefined Tensor in Tenseur::operator() ..." <<
endl ;
959 return mp->cmp_zero() ;
964 cout <<
"Unknown state in Tenseur::operator()" <<
endl ;
983 cout <<
"Undefined Tensor in Tenseur::operator(int) ..." <<
endl ;
989 return mp->cmp_zero() ;
993 cout <<
"Unknown state in Tenseur::operator(int)" <<
endl ;
1006 if (
etat == ETATQCQ) {
1008 idx.set_etat_qcq() ;
1017 cout <<
"Undefined Tensor in Tenseur::operator(int, int) ..." <<
endl ;
1023 return mp->cmp_zero() ;
1027 cout <<
"Unknown state in Tenseur::operator(int, int)" <<
endl ;
1041 if (
etat == ETATQCQ) {
1043 idx.set_etat_qcq() ;
1053 cout <<
"Undefined Tensor in Tenseur::operator(int, int, int) ..." <<
endl ;
1059 return mp->cmp_zero() ;
1063 cout <<
"Unknown state in Tenseur::operator(int, int, int)" <<
endl ;
1076 assert ((indices(
i)>=0) && (indices(
i)<3)) ;
1078 if (
etat == ETATQCQ) {
1085 cout <<
"Undefined Tensor in Tenseur::operator(const Itbl&) ..." <<
endl ;
1091 return mp->cmp_zero() ;
1095 cout <<
"Unknown state in Tenseur::operator(const Itbl& )" <<
endl ;
1106 if (
etat == ETATZERO) {
1119 if (
etat == ETATZERO) {
1132 if (
etat == ETATZERO) {
1145 if (
etat == ETATZERO) {
1158 if (
etat == ETATZERO) {
1172 if (
etat == ETATZERO) {
1186 if (
triad->identify() == (
mp->get_bvect_cart()).identify() ) {
1190 for (
int i=0 ;
i<3 ;
i++)
1192 for (
int i=0 ;
i<3 ;
i++)
1197 assert(
triad->identify() == (
mp->get_bvect_spher()).identify()) ;
1200 for (
int i=0 ;
i<3 ;
i++)
1202 for (
int i=0 ;
i<3 ;
i++)
1212 if(
triad->identify() == (
mp->get_bvect_cart()).identify() ) {
1220 (
c[
i]->
va).set_base( (*
bases[indices(0)]) *
1221 (*
bases[indices(1)]) ) ;
1223 for (
int i=0 ;
i<3 ;
i++)
1228 assert(
triad->identify() == (
mp->get_bvect_spher()).identify()) ;
1235 (
c[
i]->
va).set_base( (*
bases[indices(0)]) *
1236 (*
bases[indices(1)]) ) ;
1238 for (
int i=0 ;
i<3 ;
i++)
1247 "Tenseur::set_std_base() : the case valence = " <<
valence
1248 <<
" is not treated !" <<
endl ;
1258 flux <<
"Valence : " <<
source.valence <<
endl ;
1259 if (
source.get_poids() != 0.)
1260 flux <<
"Tensor density of weight " <<
source.poids <<
endl ;
1262 if (
source.get_triad() != 0x0) {
1263 flux <<
"Vectorial basis (triad) on which the components are defined :"
1269 flux <<
"Type of the indices : " << endl ;
1270 for (
int i=0 ; i<source.
valence ; i++) {
1271 flux <<
"Index " << i <<
" : " ;
1273 flux <<
" contravariant." << endl ;
1275 flux <<
" covariant." << endl ;
1278 switch (source.
etat) {
1281 flux <<
"Null Tenseur. " << endl ;
1286 flux <<
"Undefined Tenseur. " << endl ;
1291 for (
int i=0 ; i<source.
n_comp ; i++) {
1294 flux <<
"Component " ;
1297 for (
int j=0 ; j<source.
valence ; j++)
1298 flux <<
" " << num_indices(j) ;
1302 flux <<
" : " << endl ;
1303 flux <<
"-------------" << endl ;
1306 if (source.
c[i] != 0x0)
1307 flux << *source.
c[i] << endl ;
1309 flux <<
"Unknown component ... " << endl ;
1315 cout <<
"Unknown case in operator<< (ostream&, const Tenseur&)" << endl ;
1321 flux <<
" -----------------------------------------------------" << endl ;
1337 if (
etat == ETATQCQ)
1355 tipe.set_etat_qcq() ;
1369 if (
etat == ETATZERO)
1404 "Tenseur::fait_gradient_spher : the valence must be zero !"
1412 if (
etat == ETATZERO) {
1511 grad.change_triad( *(
metre.con().get_triad()) ) ;
Bases of the spectral expansions.
Vectorial bases (triads) with respect to which the tensorial components are defined.
static Base_vect * bvect_from_file(FILE *)
Construction of a vectorial basis from a file (see sauve(FILE* ) ).
Component of a tensorial field *** DEPRECATED : use class Scalar instead ***.
void mult_r_zec()
Multiplication by r in the external compactified domain (ZEC)
void allocate_all()
Sets the logical state to ETATQCQ (ordinary state) and performs the memory allocation of all the elem...
void dec_dzpuis()
Decreases by 1 the value of dzpuis and changes accordingly the values of the Cmp in the external comp...
Valeur va
The numerical value of the Cmp
void std_base_scal()
Sets the spectral bases of the Valeur va to the standard ones for a scalar.
const Cmp & srstdsdp() const
Returns of *this .
void annule(int l)
Sets the Cmp to zero in a given domain.
void inc2_dzpuis()
Increases by 2 the value of dzpuis and changes accordingly the values of the Cmp in the external comp...
const Cmp & srdsdt() const
Returns of *this .
void dec2_dzpuis()
Decreases by 2 the value of dzpuis and changes accordingly the values of the Cmp in the external comp...
const Cmp & dsdr() const
Returns of *this .
void inc_dzpuis()
Increases by the value of dzpuis and changes accordingly the values of the Cmp in the external compac...
Time evolution with partial storage (*** under development ***).
Basic integer array class.
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
int get_dim(int i) const
Gives the i th dimension (ie {tt dim.dim[i] )
int & set(int i)
Read/write of a particular element (index i ) (1D case)
void sauve(FILE *) const
Save in a file.
int get_ndim() const
Gives the number of dimensions (ie dim.ndim )
Base class for coordinate mappings.
Class intended to describe tensors with a symmetry on the two last indices *** DEPRECATED : use class...
Tensor handling *** DEPRECATED : use class Tensor instead ***.
virtual Itbl donne_indices(int place) const
Returns the indices of a component given by its position in the Cmp 1-D array c .
Cmp & set()
Read/write for a scalar (see also operator=(const Cmp&) ).
Tenseur ** p_derive_con
Array of pointers on the contravariant derivatives of *this with respect to the corresponding metri...
friend Tenseur manipule(const Tenseur &, const Metrique &, int idx)
Raise or lower the index idx depending on its type, using the given Metrique .
void fait_carre_scal(const Metrique &, int i) const
Calculates, if needed, the scalar square of *this , with respect to met .
void allocate_all()
Sets the logical state to ETATQCQ (ordinary state) and performs the memory allocation of all the elem...
const Metrique * metric
For tensor densities: the metric defining the conformal factor.
void fait_gradient_spher() const
Calculates, if needed, the gradient of *this in a spherical orthonormal basis (scalar field only).
void sauve(FILE *) const
Save in a file.
virtual void operator=(const Tenseur &tens)
Assignment to another Tenseur.
Tenseur * p_gradient_spher
Pointer on the gradient of *this in a spherical orthonormal basis (scalar field only).
const Map *const mp
Reference mapping.
void inc_dzpuis()
dzpuis += 1 ;
virtual void fait_gradient() const
Calculates, if needed, the gradient of *this .
const Metrique ** met_depend
Array of pointers on the Metrique 's used to calculate derivatives members.
virtual int donne_place(const Itbl &idx) const
Returns the position in the Cmp 1-D array c of a component given by its indices.
const Tenseur & derive_cov(const Metrique &met) const
Returns the covariant derivative of *this , with respect to met .
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Tenseur(const Map &map, const Metrique *met=0x0, double weight=0)
Constructor for a scalar field.
void annule(int l)
Sets the Tenseur to zero in a given domain.
void dec2_dzpuis()
dzpuis -= 2 ;
Tenseur ** p_carre_scal
Array of pointers on the scalar squares of *this with respect to the corresponding metric in *met_d...
friend Tenseur contract(const Tenseur &, int id1, int id2)
Self contraction of two indices of a Tenseur .
int get_place_met(const Metrique &metre) const
Returns the position of the pointer on metre in the array met_depend .
void dec_dzpuis()
dzpuis -= 1 ;
const Tenseur & derive_con(const Metrique &) const
Returns the contravariant derivative of *this , with respect to met .
const Base_vect * triad
Vectorial basis (triad) with respect to which the tensor components are defined.
const Tenseur & gradient() const
Returns the gradient of *this (Cartesian coordinates)
virtual ~Tenseur()
Destructor.
int n_comp
Number of components, depending on the symmetry.
void new_der_met()
Builds the arrays met_depend , p_derive_cov , p_derive_con and p_carre_scal and fills them with null ...
void set_std_base()
Set the standard spectal basis of decomposition for each component.
void set_etat_zero()
Sets the logical state to ETATZERO (zero state).
void set_poids(double weight)
Sets the weight for a tensor density.
void mult_r_zec()
Multiplication by r in the external zone.
Itbl type_indice
Array of size valence contening the type of each index, COV for a covariant one and CON for a contrav...
void del_derive() const
Logical destructor of all the derivatives.
bool verif() const
Returns false for a tensor density without a defined metric.
const Cmp & operator()() const
Read only for a scalar.
void set_metric(const Metrique &met)
Sets the pointer on the metric for a tensor density.
void inc2_dzpuis()
dzpuis += 2 ;
const Tenseur & gradient_spher() const
Returns the gradient of *this (Spherical coordinates) (scalar field only).
void del_derive_met(int i) const
Logical destructor of the derivatives depending on the i-th element of *met_depend .
int etat
Logical state ETATZERO , ETATQCQ or ETATNONDEF.
double poids
For tensor densities: the weight.
void set_der_met_0x0(int i) const
Sets the pointers of the derivatives depending on the i-th element of *met_depend to zero (as well as...
Tenseur ** p_derive_cov
Array of pointers on the covariant derivatives of *this with respect to the corresponding metric in...
void set_der_0x0() const
Sets the pointers of all the derivatives to zero.
void change_triad(const Base_vect &new_triad)
Sets a new vectorial basis (triad) of decomposition and modifies the components accordingly.
void set_triad(const Base_vect &new_triad)
Assigns a new vectorial basis (triad) of decomposition.
void set_etat_nondef()
Sets the logical state to ETATNONDEF (undefined state).
Tenseur * p_gradient
Pointer on the gradient of *this .
void set_dependance(const Metrique &met) const
To be used to describe the fact that the derivatives members have been calculated with met .
void del_t()
Logical destructor.
virtual void fait_derive_cov(const Metrique &met, int i) const
Calculates, if needed, the covariant derivative of *this , with respect to met .
const Tenseur & carre_scal(const Metrique &) const
Returns the scalar square of *this , with respect to met .
virtual void fait_derive_con(const Metrique &, int i) const
Calculates, if needed, the contravariant derivative of *this , with respect to met .
Cmp pow(const Cmp &, int)
Power .
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.