32char tensor_sym_C[] =
"$Header: /cvsroot/Lorene/C++/Source/Tensor/tensor_sym.C,v 1.3 2014/10/13 08:53:44 j_novak Exp $" ;
59#include "utilitaires.h"
69Tensor_sym::Tensor_sym(
const Map& map,
int val,
const Itbl& tipe,
70 const Base_vect& triad_i,
int index_sym1,
int index_sym2)
71 :
Tensor(map, val, tipe, 6*int(
pow(3.,val-2)), triad_i),
97Tensor_sym::Tensor_sym(
const Map& map,
int val,
int tipe,
98 const Base_vect& triad_i,
int index_sym1,
int index_sym2)
99 :
Tensor(map, val, tipe, 6*int(
pow(3.,val-2)), triad_i),
101 id_sym2(index_sym2) {
120Tensor_sym::Tensor_sym(
const Map& map,
int tipe0,
int tipe1,
int tipe2,
122 int index_sym1,
int index_sym2)
123 :
Tensor(map, 3, tipe0, 18, triad_i),
125 id_sym2(index_sym2) {
127 assert( (tipe0==COV) || (tipe0==CON) ) ;
128 assert( (tipe1==COV) || (tipe1==CON) ) ;
129 assert( (tipe2==COV) || (tipe2==CON) ) ;
153 :
Tensor(*source.mp, source.valence, source.type_indice,
154 6*int(
pow(3.,source.valence-2)) , *(source.triad)),
155 id_sym1(source.id_sym1),
156 id_sym2(source.id_sym2) {
158 for (
int i=0 ; i<
n_comp ; i++) {
164 *(
cmp[i]) = *(source.
cmp[posi]) ;
174Tensor_sym::Tensor_sym(
const Map& map,
const Base_vect& triad_i, FILE* fd)
175 :
Tensor(map, triad_i, fd) {
206 for (
int id=0 ;
id<
valence ;
id++)
209 for (
int ic=0 ; ic<
n_comp ; ic++) {
211 *
cmp[ic] = *(tt.
cmp[posi]) ;
224 for (
int id=0 ;
id<
valence ;
id++)
231 for (
int ic=0 ; ic<
n_comp ; ic++) {
233 *
cmp[ic] = *(tt.
cmp[posi]) ;
250 for (
int i=0 ; i<
valence ; i++) {
251 assert( (idx(i)>=1) && (idx(i)<=3) ) ;
257 for (
int id=0 ;
id<
id_sym1;
id++) {
258 idx0.
set(
id) = idx(
id) ;
261 idx0.
set(
id) = idx(
id+1) ;
264 idx0.
set(
id) = idx(
id+2) ;
283 for (
int id=0 ;
id<
valence-2 ;
id++) {
284 pos = 3 * pos + idx0(
id) - 1 ;
312 assert( (place>=0) && (place<
n_comp) ) ;
318 int reste = div(place, 6).rem ;
319 place = int((place-reste)/6) ;
326 if ( (reste>2) && (reste<5) ) {
337 if (
valence == 2)
return idx0 ;
339 for (
int id=
valence-3 ;
id>=0 ;
id--) {
340 int ind = div(place, 3).rem ;
341 place = int((place-ind)/3) ;
342 idx0.
set(
id) = ind + 1 ;
350 for (
int id=0 ;
id<
id_sym1;
id++) {
351 idx.
set(
id) = idx0(
id) ;
356 idx.
set(
id) = idx0(
id-1) ;
361 idx.
set(
id) = idx0(
id-2) ;
Vectorial bases (triads) with respect to which the tensorial components are defined.
Basic integer array class.
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)
int get_ndim() const
Gives the number of dimensions (ie dim.ndim )
Base class for coordinate mappings.
Symmetric tensors (with respect to two of their arguments).
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.
virtual void sauve(FILE *) const
Save in a binary file.
virtual Itbl indices(int pos) const
Returns the indices of a component given by its position in the array cmp .
virtual void operator=(const Tensor_sym &a)
Assignment to another Tensor_sym.
int get_valence() const
Returns the valence.
virtual void sauve(FILE *) const
Save in a binary file.
virtual int position(const Itbl &ind) const
Returns the position in the array cmp of a component given by its indices.
int id_sym1
Number of the first symmetric index (0<= id_sym1 < valence )
int valence
Valence of the tensor (0 = scalar, 1 = vector, etc...)
Scalar ** cmp
Array of size n_comp of pointers onto the components.
int id_sym2
Number of the second symmetric index (id_sym1 < id_sym2 < valence )
const Base_vect * get_triad() const
Returns the vectorial basis (triad) on which the components are defined.
int n_comp
Number of stored components, depending on the symmetry.
virtual void del_deriv() const
Deletes the derived quantities.
virtual int position(const Itbl &ind) const
Returns the position in the array cmp of a component given by its indices.
Itbl type_indice
1D array of integers (class Itbl ) of size valence containing the type of each index: COV for a cov...
virtual ~Tensor_sym()
Destructor.
const Base_vect * triad
Vectorial basis (triad) with respect to which the tensor components are defined.