31 char tensor_calculus_C[] =
"$Header: /cvsroot/Lorene/C++/Source/Tensor/tensor_calculus.C,v 1.10 2014/10/13 08:53:44 j_novak Exp $" ;
97 assert( (ind_1 >= 0) && (ind_1 <
valence) ) ;
98 assert( (ind_2 >= 0) && (ind_2 <
valence) ) ;
99 assert( ind_1 != ind_2 ) ;
114 for (
int i=0 ; i<ind_1 ; i++)
116 for (
int i=ind_1 ; i<ind_2-1 ; i++)
118 for (
int i = ind_2-1 ; i<val_res ; i++)
131 for (
int j=0 ; j<ind_1 ; j++)
132 jeux_indice_source.
set(j) = jeux_indice_res(j) ;
133 for (
int j=ind_1+1 ; j<ind_2 ; j++)
134 jeux_indice_source.
set(j) = jeux_indice_res(j-1) ;
135 for (
int j=ind_2+1 ; j<
valence ; j++)
136 jeux_indice_source.
set(j) = jeux_indice_res(j-2) ;
138 Scalar& work = res.
set(jeux_indice_res) ;
141 for (
int j=1 ; j<=3 ; j++) {
142 jeux_indice_source.
set(ind_1) = j ;
143 jeux_indice_source.
set(ind_2) = j ;
156 assert( (ind1 >= 0) && (ind1 <
valence) ) ;
157 assert( (ind2 >= 0) && (ind2 <
valence) ) ;
158 assert( ind1 != ind2 ) ;
161 cout <<
"Tensor::trace(int, int, const Metric&) : Warning : \n" 162 <<
" the two indices for the trace have opposite types,\n" 163 <<
" hence the metric is useless !\n" ;
165 return trace(ind1, ind2) ;
169 return contract(gam.
con(), 0, 1, *
this, ind1, ind2) ;
172 return contract(gam.
cov(), 0, 1, *
this, ind1, ind2) ;
189 for (
int i=1; i<=3; i++) {
202 cout <<
"Tensor::trace(const Metric&) : Warning : \n" 203 <<
" the two indices have opposite types,\n" 204 <<
" hence the metric is useless to get the trace !\n" ;
228 assert ((place >=0) && (place <
valence)) ;
237 for (
int i=0 ; i<
valence ; i++)
239 tipe.set(place) = CON ;
243 Itbl place_auxi(valence) ;
245 for (
int i=0 ; i<res.
n_comp ; i++) {
249 place_auxi.
set(0) = place_res(place) ;
250 for (
int j=1 ; j<place+1 ; j++)
251 place_auxi.
set(j) = place_res(j-1) ;
252 place_res.set(place) = place_auxi(0) ;
254 for (
int j=place+1 ; j<
valence ; j++)
255 place_auxi.
set(j) = place_res(j);
257 res.
set(place_res) = auxi(place_auxi) ;
268 assert ((place >=0) && (place <
valence)) ;
276 for (
int i=0 ; i<
valence ; i++)
278 tipe.set(place) = COV ;
282 Itbl place_auxi(valence) ;
284 for (
int i=0 ; i<res.
n_comp ; i++) {
288 place_auxi.
set(0) = place_res(place) ;
289 for (
int j=1 ; j<place+1 ; j++)
290 place_auxi.
set(j) = place_res(j-1) ;
291 place_res.set(place) = place_auxi(0) ;
293 for (
int j=place+1 ; j<
valence ; j++)
294 place_auxi.
set(j) = place_res(j);
296 res.
set(place_res) = auxi(place_auxi) ;
310 for (
int i=0 ; i<
valence ; i++) {
313 auxi =
new Tensor( auxi_old->
up(i, met) ) ;
320 auxi_old =
new Tensor(*auxi) ;
325 Tensor result(*auxi_old) ;
359 assert(
triad != 0x0 ) ;
373 cerr <<
"Tensor::compute_derive_lie : unknown triad type !\n" ;
382 for (
int ic=0; ic<
n_comp; ic++) {
385 if (dzp > dz_in) dz_in = dzp ;
390 for (
int ic=0; ic<
n_comp; ic++) {
391 if ( !(
cmp[ic]->check_dzpuis(dz_in)) ) {
392 cout <<
"######## WARNING #######\n" ;
393 cout <<
" Tensor::compute_derive_lie: the tensor components \n" 394 <<
" do not have all the same dzpuis ! : \n" 395 <<
" ic, dzpuis(ic), dz_in : " << ic <<
" " 423 for (
int ic=0; ic<ncomp_resu; ic++) {
431 for (
int id=0;
id<
valence;
id++) {
438 for (
int k=1; k<=3; k++) {
446 for (
int k=1; k<=3; k++) {
455 "Tensor::compute_derive_lie: unexpected type of index !\n" ;
468 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 covar...
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.