62 #include "utilitaires.h" 73 const Base_vect& triad_i,
int index_sym1,
int index_sym2)
74 :
Tensor(map, val, tipe, 6*int(
pow(3.,val-2)), triad_i),
101 const Base_vect& triad_i,
int index_sym1,
int index_sym2)
102 :
Tensor(map, val, tipe, 6*int(
pow(3.,val-2)), triad_i),
104 id_sym2(index_sym2) {
125 int index_sym1,
int index_sym2)
126 :
Tensor(map, 3, tipe0, 18, triad_i),
128 id_sym2(index_sym2) {
130 assert( (tipe0==COV) || (tipe0==CON) ) ;
131 assert( (tipe1==COV) || (tipe1==CON) ) ;
132 assert( (tipe2==COV) || (tipe2==CON) ) ;
156 :
Tensor(*source.mp, source.valence, source.type_indice,
157 6*int(
pow(3.,source.valence-2)) , *(source.triad)),
158 id_sym1(source.id_sym1),
159 id_sym2(source.id_sym2) {
161 for (
int i=0 ; i<
n_comp ; i++) {
167 *(
cmp[i]) = *(source.
cmp[posi]) ;
178 :
Tensor(map, triad_i, fd) {
209 for (
int id=0 ;
id<
valence ;
id++)
212 for (
int ic=0 ; ic<
n_comp ; ic++) {
214 *
cmp[ic] = *(tt.
cmp[posi]) ;
227 for (
int id=0 ;
id<
valence ;
id++)
234 for (
int ic=0 ; ic<
n_comp ; ic++) {
236 *
cmp[ic] = *(tt.
cmp[posi]) ;
253 for (
int i=0 ; i<
valence ; i++) {
254 assert( (idx(i)>=1) && (idx(i)<=3) ) ;
260 for (
int id=0 ;
id<
id_sym1;
id++) {
261 idx0.
set(
id) = idx(
id) ;
264 idx0.
set(
id) = idx(
id+1) ;
267 idx0.
set(
id) = idx(
id+2) ;
286 for (
int id=0 ;
id<
valence-2 ;
id++) {
287 pos = 3 * pos + idx0(
id) - 1 ;
315 assert( (place>=0) && (place<
n_comp) ) ;
321 int reste = div(place, 6).rem ;
322 place = int((place-reste)/6) ;
329 if ( (reste>2) && (reste<5) ) {
340 if (
valence == 2)
return idx0 ;
342 for (
int id=
valence-3 ;
id>=0 ;
id--) {
343 int ind = div(place, 3).rem ;
344 place = int((place-ind)/3) ;
345 idx0.
set(
id) = ind + 1 ;
353 for (
int id=0 ;
id<
id_sym1;
id++) {
354 idx.
set(
id) = idx0(
id) ;
359 idx.
set(
id) = idx0(
id-1) ;
364 idx.
set(
id) = idx0(
id-2) ;
virtual void sauve(FILE *) const
Save in a binary file.
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 operator=(const Tensor_sym &a)
Assignment to another Tensor_sym.
int get_ndim() const
Gives the number of dimensions (ie dim.ndim )
int id_sym2
Number of the second symmetric index (id_sym1 < id_sym2 < valence )
Base class for coordinate mappings.
virtual Itbl indices(int pos) const
Returns the indices of a component given by its position in the array cmp .
Basic integer array class.
const Base_vect * triad
Vectorial basis (triad) with respect to which the tensor components are defined.
virtual void sauve(FILE *) const
Save in a binary file.
Tensor_sym(const Map &map, int val, const Itbl &tipe, const Base_vect &triad_i, int index_sym1, int index_sym2)
Standard constructor.
Vectorial bases (triads) with respect to which the tensorial components are defined.
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.
Scalar ** cmp
Array of size n_comp of pointers onto the components.
virtual ~Tensor_sym()
Destructor.
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.
int id_sym1
Number of the first symmetric index (0<= id_sym1 < valence )
Cmp pow(const Cmp &, int)
Power .
int get_valence() const
Returns the valence.
virtual void del_deriv() const
Deletes the derived quantities.
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 valence
Valence of the tensor (0 = scalar, 1 = vector, etc...)
virtual int position(const Itbl &ind) const
Returns the position in the array cmp of a component given by its indices.
int get_dim(int i) const
Gives the i th dimension (ie {tt dim.dim[i] )
Symmetric tensors (with respect to two of their arguments).