25 char tenseur_operateur_C[] =
"$Header: /cvsroot/Lorene/C++/Source/Tenseur/tenseur_operateur.C,v 1.10 2014/10/13 08:53:42 j_novak Exp $" ;
115 #include "metrique.h" 121 assert ((t1.
etat != ETATNONDEF) && (t2.
etat != ETATNONDEF)) ;
122 assert (t1.
mp == t2.
mp) ;
126 poids_res = (fabs(poids_res) < 1.e-10 ? 0. : poids_res) ;
127 const Metrique* met_res = 0x0 ;
128 if (poids_res != 0.) {
131 else met_res = t2.
metric ;
136 Tenseur scal(*t1.
mp, met_res, poids_res) ;
138 if ((t1.
etat == ETATZERO) || (t2.
etat == ETATZERO))
142 scal.
set() = t1() * t2() ;
149 Itbl tipe (val_res) ;
151 for (
int i=0 ; i<t1.
valence ; i++)
153 for (
int i=0 ; i<t2.
valence ; i++)
169 Tenseur res(*t1.
mp, val_res, tipe, triad_res, met_res, poids_res) ;
171 if ((t1.
etat == ETATZERO) || (t2.
etat == ETATZERO))
180 for (
int i=0 ; i<res.
n_comp ; i++) {
182 for (
int j=0 ; j<t1.
valence ; j++)
183 jeux_indice_t1.
set(j) = jeux_indice_res(j) ;
184 for (
int j=0 ; j<t2.
valence ; j++)
185 jeux_indice_t2.
set(j) = jeux_indice_res(j+t1.
valence) ;
187 res.
set(jeux_indice_res) = t1(jeux_indice_t1)*t2(jeux_indice_t2) ;
201 assert ((t1.
etat != ETATNONDEF) && (t2.
etat != ETATNONDEF)) ;
202 assert (t1.
mp == t2.
mp) ;
206 poids_res = (fabs(poids_res) < 1.e-10 ? 0. : poids_res) ;
207 const Metrique* met_res = 0x0 ;
208 if (poids_res != 0.) {
211 else met_res = t2.
metric ;
216 Tenseur scal(*t1.
mp, met_res, poids_res) ;
218 if ((t1.
etat == ETATZERO) || (t2.
etat == ETATZERO))
222 scal.
set() = t1() % t2() ;
229 Itbl tipe (val_res) ;
231 for (
int i=0 ; i<t1.
valence ; i++)
233 for (
int i=0 ; i<t2.
valence ; i++)
249 Tenseur res(*t1.
mp, val_res, tipe, triad_res, met_res, poids_res) ;
253 if ((t1.
etat == ETATZERO) || (t2.
etat == ETATZERO))
262 for (
int i=0 ; i<res.
n_comp ; i++) {
264 for (
int j=0 ; j<t1.
valence ; j++)
265 jeux_indice_t1.
set(j) = jeux_indice_res(j) ;
266 for (
int j=0 ; j<t2.
valence ; j++)
267 jeux_indice_t2.
set(j) = jeux_indice_res(j+t1.
valence) ;
269 res.
set(jeux_indice_res) = t1(jeux_indice_t1) %
283 assert (source.
etat != ETATNONDEF) ;
284 assert ((ind_1 >= 0) && (ind_1 < source.
valence)) ;
285 assert ((ind_2 >= 0) && (ind_2 < source.
valence)) ;
296 int val_res = source.
valence - 2 ;
298 Itbl tipe (val_res) ;
300 for (
int i=0 ; i<ind_1 ; i++)
302 for (
int i=ind_1 ; i<ind_2-1 ; i++)
304 for (
int i = ind_2-1 ; i<val_res ; i++)
311 if (source.
etat == ETATZERO) {
318 Cmp work(source.
mp) ;
325 for (
int i=0 ; i<res.
n_comp ; i++) {
327 for (
int j=0 ; j<ind_1 ; j++)
328 jeux_indice_source.
set(j) = jeux_indice_res(j) ;
329 for (
int j=ind_1+1 ; j<ind_2 ; j++)
330 jeux_indice_source.
set(j) = jeux_indice_res(j-1) ;
331 for (
int j=ind_2+1 ; j<source.
valence ; j++)
332 jeux_indice_source.
set(j) = jeux_indice_res(j-2) ;
336 for (
int j=0 ; j<3 ; j++) {
337 jeux_indice_source.
set(ind_1) = j ;
338 jeux_indice_source.
set(ind_2) = j ;
339 work = work + source(jeux_indice_source) ;
342 res.
set(jeux_indice_res) = work ;
350 assert ((t1.
etat != ETATNONDEF) && (t2.
etat != ETATNONDEF)) ;
352 assert ((ind1>=0) && (ind1<t1.
valence)) ;
353 assert ((ind2>=0) && (ind2<t2.
valence)) ;
354 assert (*(t1.
mp) == *(t2.
mp)) ;
364 poids_res = (fabs(poids_res) < 1.e-10 ? 0. : poids_res) ;
365 const Metrique* met_res = 0x0 ;
366 if (poids_res != 0.) {
369 else met_res = t2.
metric ;
373 for (
int i=0 ; i<ind1 ; i++)
375 for (
int i=ind1 ; i<t1.
valence-1 ; i++)
379 for (
int i = t1.
valence+ind2-1 ; i<val_res ; i++)
384 Tenseur res(*t1.
mp, val_res, tipe, triad_res, met_res, poids_res) ;
387 if ( (t1.
etat == ETATZERO) || (t2.
etat == ETATZERO) ) {
403 for (
int comp=0 ; comp<res.
n_comp ; comp++) {
405 for (
int i=0 ; i<ind1 ; i++)
406 jeux_indice_t1.
set(i) = jeux_indice_res(i) ;
407 for (
int i=ind1+1 ; i<t1.
valence ; i++)
408 jeux_indice_t1.
set(i) = jeux_indice_res(i-1) ;
409 for (
int i=0 ; i<ind2 ; i++)
410 jeux_indice_t2.
set(i) = jeux_indice_res(t1.
valence+i-1) ;
411 for (
int i=ind2+1 ; i<t2.
valence ; i++)
412 jeux_indice_t2.
set(i) = jeux_indice_res(t1.
valence+i-2) ;
417 for (
int j=0 ; j<3 ; j++) {
418 jeux_indice_t1.
set(ind1) = j ;
419 jeux_indice_t2.
set(ind2) = j ;
420 work = work + t1(jeux_indice_t1)*t2(jeux_indice_t2) ;
423 res.
set(jeux_indice_res) = work ;
430 assert ((t1.
etat != ETATNONDEF) && (t2.
etat != ETATNONDEF)) ;
432 assert ((ind1>=0) && (ind1<t1.
valence)) ;
433 assert ((ind2>=0) && (ind2<t2.
valence)) ;
434 assert (t1.
mp == t2.
mp) ;
444 poids_res = (fabs(poids_res) < 1.e-10 ? 0. : poids_res) ;
445 const Metrique* met_res = 0x0 ;
446 if (poids_res != 0.) {
449 else met_res = t2.
metric ;
453 for (
int i=0 ; i<ind1 ; i++)
455 for (
int i=ind1 ; i<t1.
valence-1 ; i++)
459 for (
int i = t1.
valence+ind2-1 ; i<val_res ; i++)
464 Tenseur res(*t1.
mp, val_res, tipe, triad_res, met_res, poids_res) ;
467 if ( (t1.
etat == ETATZERO) || (t2.
etat == ETATZERO) ) {
483 for (
int comp=0 ; comp<res.
n_comp ; comp++) {
485 for (
int i=0 ; i<ind1 ; i++)
486 jeux_indice_t1.
set(i) = jeux_indice_res(i) ;
487 for (
int i=ind1+1 ; i<t1.
valence ; i++)
488 jeux_indice_t1.
set(i) = jeux_indice_res(i-1) ;
489 for (
int i=0 ; i<ind2 ; i++)
490 jeux_indice_t2.
set(i) = jeux_indice_res(t1.
valence+i-1) ;
491 for (
int i=ind2+1 ; i<t2.
valence ; i++)
492 jeux_indice_t2.
set(i) = jeux_indice_res(t1.
valence+i-2) ;
497 for (
int j=0 ; j<3 ; j++) {
498 jeux_indice_t1.
set(ind1) = j ;
499 jeux_indice_t2.
set(ind2) = j ;
500 work = work + t1(jeux_indice_t1)%t2(jeux_indice_t2) ;
503 res.
set(jeux_indice_res) = work ;
511 assert (t1.
etat != ETATNONDEF) ;
512 assert (met.get_etat() != ETATNONDEF) ;
515 assert (valen != 0) ;
516 assert ((place >=0) && (place < valen)) ;
521 for (
int i=1 ; i<place+1 ; i++)
523 for (
int i=place+1 ; i<valen ; i++)
529 auxi =
contract (met.con(), 1, t1, place) ;
531 auxi =
contract (met.cov(), 1, t1, place) ;
535 for (
int i=0 ; i<valen ; i++)
537 tipe.
set(place) *= -1 ;
542 Itbl place_auxi(valen) ;
545 for (
int i=0 ; i<res.
n_comp ; i++) {
549 place_auxi.
set(0) = place_res(place) ;
550 for (
int j=1 ; j<place+1 ; j++)
551 place_auxi.
set(j) = place_res(j-1) ;
552 place_res.set(place) = place_auxi(0) ;
553 for (
int j=place+1 ; j<valen ; j++)
554 place_auxi.
set(j) = place_res(j);
557 res.
set(place_res) = auxi(place_auxi) ;
567 for (
int i=0 ; i<t1.
valence ; i++) {
570 auxi_old =
new Tenseur(*auxi) ;
584 assert (source.
etat != ETATNONDEF) ;
588 int val_res = source.
valence-1 ;
589 Itbl tipe (val_res) ;
591 for (
int i=0 ; i<val_res ; i++)
598 if (source.
etat == ETATZERO)
603 for (
int i=0 ; i<res.
n_comp ; i++) {
605 Itbl indices_so (val_res+1) ;
606 indices_so.set_etat_qcq() ;
607 for (
int j=0 ; j<val_res ; j++)
608 indices_so.set(j) = indices_res(j) ;
611 indices_so.set(val_res) = 0 ;
612 Cmp resu(source(indices_so)) ;
617 assert( dynamic_cast<const Map_radial*>(source.
get_mp()) != 0x0) ;
619 resu.
va = (resu.
va).mult_st() ;
620 resu.
va = (resu.
va).mult_cp() ;
624 indices_so.
set(val_res) = 1 ;
625 Cmp auxiliaire (source(indices_so)) ;
629 auxiliaire.
va = (auxiliaire.
va).mult_st() ;
630 auxiliaire.
va = (auxiliaire.
va).mult_sp() ;
632 resu = resu + auxiliaire ;
636 indices_so.
set(val_res) = 2 ;
637 auxiliaire = source(indices_so) ;
639 auxiliaire.mult_r() ;
641 auxiliaire.va = (auxiliaire.va).mult_ct() ;
643 resu = resu + auxiliaire ;
645 res.
set(indices_res) = resu ;
655 assert ((t1.
etat != ETATNONDEF) && (t2.
etat != ETATNONDEF)) ;
657 assert (t1.
mp == t2.
mp) ;
666 poids_res = (fabs(poids_res) < 1.e-10 ? 0. : poids_res) ;
667 const Metrique* met_res = 0x0 ;
668 if (poids_res != 0.) {
671 else met_res = t2.
metric ;
676 for (
int i=0 ; i<t1.
valence - 1 ; i++)
678 for (
int i = t1.
valence-1 ; i<val_res ; i++)
681 Tenseur res(*t1.
mp, val_res, tipe, t1.
triad, met_res, poids_res) ;
684 if ( (t1.
etat == ETATZERO) || (t2.
etat == ETATZERO) ) {
700 for (
int ir=0 ; ir<res.
n_comp ; ir++) {
707 for (
int i=0 ; i<t1.
valence - 1 ; i++) {
708 jeux_indice_t1.
set(i) = jeux_indice_res(i) ;
712 for (
int i=1 ; i<t2.
valence ; i++) {
713 jeux_indice_t2.
set(i) = jeux_indice_res(t1.
valence+i-2) ;
720 for (
int j=0 ; j<3 ; j++) {
722 jeux_indice_t2.
set(0) = j ;
723 work = work + t1(jeux_indice_t1)*t2(jeux_indice_t2) ;
726 res.
set(jeux_indice_res) = work ;
737 assert ((t1.
etat != ETATNONDEF) && (t2.
etat != ETATNONDEF)) ;
739 assert (t1.
mp == t2.
mp) ;
748 poids_res = (fabs(poids_res) < 1.e-10 ? 0. : poids_res) ;
749 const Metrique* met_res = 0x0 ;
750 if (poids_res != 0.) {
753 else met_res = t2.
metric ;
758 for (
int i=0 ; i<t1.
valence - 1 ; i++)
760 for (
int i = t1.
valence-1 ; i<val_res ; i++)
763 Tenseur res(*t1.
mp, val_res, tipe, t1.
triad, met_res, poids_res) ;
766 if ( (t1.
etat == ETATZERO) || (t2.
etat == ETATZERO) ) {
782 for (
int ir=0 ; ir<res.
n_comp ; ir++) {
789 for (
int i=0 ; i<t1.
valence - 1 ; i++) {
790 jeux_indice_t1.
set(i) = jeux_indice_res(i) ;
794 for (
int i=1 ; i<t2.
valence ; i++) {
795 jeux_indice_t2.
set(i) = jeux_indice_res(t1.
valence+i-2) ;
802 for (
int j=0 ; j<3 ; j++) {
804 jeux_indice_t2.
set(0) = j ;
805 work = work + t1(jeux_indice_t1) % t2(jeux_indice_t2) ;
808 res.
set(jeux_indice_res) = work ;
833 for (
int i=0 ; i<val ; i++)
850 for (
int i=0 ; i<val ; i++) {
854 Itbl indices_aux(val) ;
859 indices_aux.
set(val-1) = indices(i) ;
860 for (
int idx=0 ; idx<val-1 ; idx++)
862 indices_aux.
set(idx) = indices(idx) ;
864 indices_aux.
set(idx) = indices(idx+1) ;
866 resu.
set(indices) += (*auxi)(indices_aux) ;
872 Itbl indices_aux(val) ;
879 indices_aux.
set(val-1) = indices(i) ;
880 for (
int idx=0 ; idx<val-1 ; idx++)
882 indices_aux.
set(idx) = indices(idx) ;
884 indices_aux.
set(idx) = indices(idx+1) ;
885 resu.
set(indices) -= (*auxi)(indices_aux) ;
892 resu = resu + poids*
contract(dx,0,1)*t ;
899 assert(t.
get_etat() != ETATNONDEF) ;
900 assert(metre.get_etat() != ETATNONDEF) ;
904 if (resu.get_etat() == ETATZERO)
return resu ;
905 assert(resu.get_etat() == ETATQCQ) ;
911 mix.
set(0) = (t0 == t1 ? -t0 : t0) ;
926 resu = resu - 1./3.*trace * metre.cov() ;
930 resu = resu - 1./3.*trace * metre.con() ;
934 cout <<
"Erreur bizarre dans sans_trace!" << endl ;
943 for (
int i=0; i<3; i++)
944 for (
int j=i; j<3; j++)
945 delta.set(i,j) = (i==j ? 1 : 0) ;
946 resu = resu - trace/3. * delta ;
Itbl type_indice
Array of size valence contening the type of each index, COV for a covariant one and CON for a contrav...
const Map *const mp
Reference mapping.
double get_poids() const
Returns the weight.
const Base_vect * triad
Vectorial basis (triad) with respect to which the tensor components are defined.
int get_type_indice(int i) const
Returns the type of the index number i .
Component of a tensorial field *** DEPRECATED : use class Scalar instead ***.
int & set(int i)
Read/write of a particular element (index i ) (1D case)
int n_comp
Number of components, depending on the symmetry.
void set_std_base()
Set the standard spectal basis of decomposition for each component.
Class intended to describe tensors with a symmetry on the two last indices *** DEPRECATED : use class...
Base_val operator*(const Base_val &, const Base_val &)
This operator is used when calling multiplication or division of Valeur .
int etat
Logical state ETATZERO , ETATQCQ or ETATNONDEF.
Tenseur flat_scalar_prod(const Tenseur &t1, const Tenseur &t2)
Scalar product of two Tenseur when the metric is : performs the contraction of the last index of t1 w...
virtual Itbl donne_indices(int place) const
Returns the indices of a component given by its position in the Cmp 1-D array c . ...
Basic integer array class.
Cmp operator%(const Cmp &, const Cmp &)
Cmp * Cmp with desaliasing.
Vectorial bases (triads) with respect to which the tensorial components are defined.
int get_valence() const
Returns the valence.
void mult_r()
Multiplication by r everywhere.
void set_etat_zero()
Sets the logical state to ETATZERO (zero).
Cmp & set()
Read/write for a scalar (see also operator=(const Cmp&) ).
const Map * get_mp() const
Returns pointer on the mapping.
Tenseur flat_scalar_prod_desal(const Tenseur &t1, const Tenseur &t2)
Same as flat_scalar_prod but with desaliasing.
Tenseur skxk(const Tenseur &)
Contraction of the last index of (*this) with or , depending on the type of S .
const Metrique * get_metric() const
Returns a pointer on the metric defining the conformal factor for tensor densities.
const Base_vect * get_triad() const
Returns the vectorial basis (triad) on which the components are defined.
Tenseur lie_derive(const Tenseur &t, const Tenseur &x, const Metrique *=0x0)
Lie Derivative of t with respect to x .
double poids
For tensor densities: the weight.
virtual int identify() const =0
Returns a number to identify the sub-classe of Base_vect the object belongs to.
int get_etat() const
Returns the logical state.
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Tenseur contract(const Tenseur &, int id1, int id2)
Self contraction of two indices of a Tenseur .
int get_n_comp() const
Returns the number of components.
Tenseur sans_trace(const Tenseur &tens, const Metrique &metre)
Computes the traceless part of a Tenseur of valence 2.
Tbl & set(int l)
Read/write of the value in a given domain.
const Base_vect_cart & get_bvect_cart() const
Returns the Cartesian basis associated with the coordinates (x,y,z) of the mapping, i.e.
const Metrique * metric
For tensor densities: the metric defining the conformal factor.
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
const Tenseur & derive_cov(const Metrique &met) const
Returns the covariant derivative of *this , with respect to met .
void set_etat_zero()
Sets the logical state to ETATZERO (zero state).
Valeur va
The numerical value of the Cmp.
Tensor handling *** DEPRECATED : use class Tensor instead ***.
const Tenseur & gradient() const
Returns the gradient of *this (Cartesian coordinates)
Tbl & set(int l)
Read/write of the value in a given domain (configuration space).
Tenseur manipule(const Tenseur &, const Metrique &, int idx)
Raise or lower the index idx depending on its type, using the given Metrique .