100 assert( (ind_1 >= 0) && (ind_1 <
valence) ) ;
101 assert( (ind_2 >= 0) && (ind_2 <
valence) ) ;
102 assert( ind_1 != ind_2 ) ;
117 for (
int i=0 ; i<ind_1 ; i++)
119 for (
int i=ind_1 ; i<ind_2-1 ; i++)
121 for (
int i = ind_2-1 ; i<val_res ; i++)
134 for (
int j=0 ; j<ind_1 ; j++)
135 jeux_indice_source.
set(j) = jeux_indice_res(j) ;
136 for (
int j=ind_1+1 ; j<ind_2 ; j++)
137 jeux_indice_source.
set(j) = jeux_indice_res(j-1) ;
138 for (
int j=ind_2+1 ; j<
valence ; j++)
139 jeux_indice_source.
set(j) = jeux_indice_res(j-2) ;
141 Scalar& work = res.
set(jeux_indice_res) ;
144 for (
int j=1 ; j<=3 ; j++) {
145 jeux_indice_source.
set(ind_1) = j ;
146 jeux_indice_source.
set(ind_2) = j ;
159 assert( (ind1 >= 0) && (ind1 <
valence) ) ;
160 assert( (ind2 >= 0) && (ind2 <
valence) ) ;
161 assert( ind1 != ind2 ) ;
164 cout <<
"Tensor::trace(int, int, const Metric&) : Warning : \n" 165 <<
" the two indices for the trace have opposite types,\n" 166 <<
" hence the metric is useless !\n" ;
168 return trace(ind1, ind2) ;
172 return contract(gam.
con(), 0, 1, *
this, ind1, ind2) ;
175 return contract(gam.
cov(), 0, 1, *
this, ind1, ind2) ;
192 for (
int i=1; i<=3; i++) {
205 cout <<
"Tensor::trace(const Metric&) : Warning : \n" 206 <<
" the two indices have opposite types,\n" 207 <<
" hence the metric is useless to get the trace !\n" ;
231 assert ((place >=0) && (place <
valence)) ;
240 for (
int i=0 ; i<
valence ; i++)
242 tipe.set(place) = CON ;
248 for (
int i=0 ; i<res.
n_comp ; i++) {
252 place_auxi.
set(0) = place_res(place) ;
253 for (
int j=1 ; j<place+1 ; j++)
254 place_auxi.
set(j) = place_res(j-1) ;
255 place_res.set(place) = place_auxi(0) ;
257 for (
int j=place+1 ; j<
valence ; j++)
258 place_auxi.
set(j) = place_res(j);
260 res.
set(place_res) = auxi(place_auxi) ;
271 assert ((place >=0) && (place <
valence)) ;
279 for (
int i=0 ; i<
valence ; i++)
281 tipe.set(place) = COV ;
287 for (
int i=0 ; i<res.
n_comp ; i++) {
291 place_auxi.
set(0) = place_res(place) ;
292 for (
int j=1 ; j<place+1 ; j++)
293 place_auxi.
set(j) = place_res(j-1) ;
294 place_res.set(place) = place_auxi(0) ;
296 for (
int j=place+1 ; j<
valence ; j++)
297 place_auxi.
set(j) = place_res(j);
299 res.
set(place_res) = auxi(place_auxi) ;
313 for (
int i=0 ; i<
valence ; i++) {
316 auxi =
new Tensor( auxi_old->
up(i, met) ) ;
323 auxi_old =
new Tensor(*auxi) ;
328 Tensor result(*auxi_old) ;
362 assert(
triad != 0x0 ) ;
376 cerr <<
"Tensor::compute_derive_lie : unknown triad type !\n" ;
385 for (
int ic=0; ic<
n_comp; ic++) {
388 if (dzp > dz_in) dz_in = dzp ;
393 for (
int ic=0; ic<
n_comp; ic++) {
394 if ( !(
cmp[ic]->check_dzpuis(dz_in)) ) {
395 cout <<
"######## WARNING #######\n" ;
396 cout <<
" Tensor::compute_derive_lie: the tensor components \n" 397 <<
" do not have all the same dzpuis ! : \n" 398 <<
" ic, dzpuis(ic), dz_in : " << ic <<
" " 426 for (
int ic=0; ic<ncomp_resu; ic++) {
434 for (
int id=0;
id<
valence;
id++) {
441 for (
int k=1; k<=3; k++) {
449 for (
int k=1; k<=3; k++) {
458 "Tensor::compute_derive_lie: unexpected type of index !\n" ;
471 resu.
set(ind1) += tmp ;
Metric for tensor calculation.
virtual const Sym_tensor & con() const
Read-only access to the contravariant representation.
int & set(int i)
Read/write of a particular element (index i ) (1D case)
int n_comp
Number of stored components, depending on the symmetry.
virtual void set_etat_zero()
Sets the logical state to ETATZERO (zero).
Tensor up(int ind, const Metric &gam) const
Computes a new tensor by raising an index of *this.
Flat metric for tensor calculation.
Tensor derive_lie(const Vector &v) const
Computes the Lie derivative of this with respect to some vector field v.
Tensor field of valence 0 (or component of a tensorial field).
int get_n_comp() const
Returns the number of stored components.
Tensor up_down(const Metric &gam) const
Computes a new tensor by raising or lowering all the indices of *this .
Basic integer array class.
const Base_vect * triad
Vectorial basis (triad) with respect to which the tensor components are defined.
Tensor field of valence 1.
const Metric_flat & flat_met_cart() const
Returns the flat metric associated with the Cartesian coordinates and with components expressed in th...
Scalar trace() const
Trace on two different type indices for a valence 2 tensor.
Itbl type_indice
1D array of integers (class Itbl ) of size valence containing the type of each index: COV for a cova...
const Base_vect * get_triad() const
Returns the vectorial basis (triad) on which the components are defined.
virtual int position(const Itbl &ind) const
Returns the position in the array cmp of a component given by its indices.
void compute_derive_lie(const Vector &v, Tensor &resu) const
Computes the Lie derivative of this with respect to some vector field v (protected method; the public...
int get_dzpuis() const
Returns dzpuis.
Scalar ** cmp
Array of size n_comp of pointers onto the components.
Tenseur contract(const Tenseur &, int id1, int id2)
Self contraction of two indices of a Tenseur .
const Tensor & derive_cov(const Metric &gam) const
Returns the covariant derivative of this with respect to some metric .
Cartesian vectorial bases (triads).
Spherical orthonormal vectorial bases (triads).
int valence
Valence of the tensor (0 = scalar, 1 = vector, etc...)
virtual const Sym_tensor & cov() const
Read-only access to the covariant representation.
Scalar & set(const Itbl &ind)
Returns the value of a component (read/write version).
const Scalar & operator()(const Itbl &ind) const
Returns the value of a component (read-only version).
const Map *const mp
Mapping on which the numerical values at the grid points are defined.
virtual void dec_dzpuis(int dec=1)
Decreases by dec units the value of dzpuis and changes accordingly the values of the Scalar in the co...
const Metric_flat & flat_met_spher() const
Returns the flat metric associated with the spherical coordinates and with components expressed in th...
virtual Itbl indices(int pos) const
Returns the indices of a component given by its position in the array cmp .
Tensor(const Map &map, int val, const Itbl &tipe, const Base_vect &triad_i)
Standard constructor.
Tensor down(int ind, const Metric &gam) const
Computes a new tensor by lowering an index of *this.