Tensor Class Reference
[Tensorial fields]

Tensor handling. More...

#include <tensor.h>

Inheritance diagram for Tensor:
Scalar Tensor_sym Vector Sym_tensor Vector_divfree Sym_tensor_trans Sym_tensor_tt

List of all members.

Public Member Functions

 Tensor (const Map &map, int val, const Itbl &tipe, const Base_vect &triad_i)
 Standard constructor.
 Tensor (const Map &map, int val, const Itbl &tipe, const Base_vect *triad_i)
 Standard constructor with the triad passed as a pointer.
 Tensor (const Map &map, int val, int tipe, const Base_vect &triad_i)
 Standard constructor when all the indices are of the same type.
 Tensor (const Tensor &)
 Copy constructor.
 Tensor (const Map &map, const Base_vect &triad_i, FILE *fich)
 Constructor from a file (see sauve(FILE*) ).
virtual ~Tensor ()
 Destructor.
virtual void set_etat_nondef ()
 Sets the logical state of all components to ETATNONDEF (undefined state).
virtual void set_etat_zero ()
 Sets the logical state of all components to ETATZERO (zero state).
virtual void set_etat_qcq ()
 Sets the logical state of all components to ETATQCQ (ordinary state).
virtual void allocate_all ()
 Performs the memory allocation of all the elements, down to the double arrays of the Tbl s.
virtual void change_triad (const Base_vect &new_triad)
 Sets a new vectorial basis (triad) of decomposition and modifies the components accordingly.
void set_triad (const Base_vect &new_triad)
 Assigns a new vectorial basis (triad) of decomposition.
virtual void operator= (const Tensor &)
 Assignment to a Tensor.
Scalarset (const Itbl &ind)
 Returns the value of a component (read/write version).
Scalarset (int i1, int i2)
 Returns the value of a component for a tensor of valence 2 (read/write version).
Scalarset (int i1, int i2, int i3)
 Returns the value of a component for a tensor of valence 3 (read/write version).
Scalarset (int i1, int i2, int i3, int i4)
 Returns the value of a component for a tensor of valence 4 (read/write version).
void annule_domain (int l)
 Sets the Tensor to zero in a given domain.
virtual void annule (int l_min, int l_max)
 Sets the Tensor to zero in several domains.
void annule_extern_cn (int l_0, int deg)
 Performs a smooth (C^n) transition in a given domain to zero.
virtual void std_spectral_base ()
 Sets the standard spectal bases of decomposition for each component.
virtual void std_spectral_base_odd ()
 Sets the standard odd spectal bases of decomposition for each component.
virtual void dec_dzpuis (int dec=1)
 Decreases by dec units the value of dzpuis and changes accordingly the values in the compactified external domain (CED).
virtual void inc_dzpuis (int inc=1)
 Increases by inc units the value of dzpuis and changes accordingly the values in the compactified external domain (CED).
virtual void exponential_filter_r (int lzmin, int lzmax, int p, double alpha=-16.)
 Applies exponential filters to all components (see Scalar::exponential_filter_r ).
virtual void exponential_filter_ylm (int lzmin, int lzmax, int p, double alpha=-16.)
 Applies exponential filters to all components (see Scalar::exponential_filter_ylm ).
const Tensorderive_cov (const Metric &gam) const
 Returns the covariant derivative of this with respect to some metric $\gamma$.
const Tensorderive_con (const Metric &gam) const
 Returns the "contravariant" derivative of this with respect to some metric $\gamma$, by raising the last index of the covariant derivative (cf.
const Tensordivergence (const Metric &gam) const
 Computes the divergence of this with respect to some metric $\gamma$.
Tensor derive_lie (const Vector &v) const
 Computes the Lie derivative of this with respect to some vector field v.
Tensor up (int ind, const Metric &gam) const
 Computes a new tensor by raising an index of *this.
Tensor down (int ind, const Metric &gam) const
 Computes a new tensor by lowering an index of *this.
Tensor up_down (const Metric &gam) const
 Computes a new tensor by raising or lowering all the indices of *this .
Tensor trace (int ind1, int ind2) const
 Trace on two different type indices.
Tensor trace (int ind1, int ind2, const Metric &gam) const
 Trace with respect to a given metric.
Scalar trace () const
 Trace on two different type indices for a valence 2 tensor.
Scalar trace (const Metric &gam) const
 Trace with respect to a given metric for a valence 2 tensor.
virtual int position (const Itbl &ind) const
 Returns the position in the array cmp of a component given by its indices.
virtual Itbl indices (int pos) const
 Returns the indices of a component given by its position in the array cmp .
const Mapget_mp () const
 Returns the mapping.
const Base_vectget_triad () const
 Returns the vectorial basis (triad) on which the components are defined.
int get_valence () const
 Returns the valence.
int get_n_comp () const
 Returns the number of stored components.
int get_index_type (int i) const
 Gives the type (covariant or contravariant) of the index number i .
Itbl get_index_type () const
 Returns the types of all the indices.
int & set_index_type (int i)
 Sets the type of the index number i .
Itblset_index_type ()
 Sets the types of all the indices.
const Scalaroperator() (const Itbl &ind) const
 Returns the value of a component (read-only version).
const Scalaroperator() (int i1, int i2) const
 Returns the value of a component for a tensor of valence 2 (read-only version).
const Scalaroperator() (int i1, int i2, int i3) const
 Returns the value of a component for a tensor of valence 3 (read-only version).
const Scalaroperator() (int i1, int i2, int i3, int i4) const
 Returns the value of a component for a tensor of valence 4 (read-only version).
void operator+= (const Tensor &)
 += Tensor
void operator-= (const Tensor &)
 -= Tensor
virtual void sauve (FILE *) const
 Save in a binary file.
virtual void spectral_display (const char *comment=0x0, double threshold=1.e-7, int precision=4, ostream &ostr=cout) const
 Displays the spectral coefficients and the associated basis functions of each component.

Protected Member Functions

 Tensor (const Map &map)
 Constructor for a scalar field: to be used only by the derived class Scalar .
 Tensor (const Map &map, int val, const Itbl &tipe, int n_comp_i, const Base_vect &triad_i)
 Constructor to be used by derived classes, with symmetries among the components.
 Tensor (const Map &map, int val, int tipe, int n_comp_i, const Base_vect &triad_i)
 Constructor used by derived classes, with symmetries among the components, when all the indices are of the same type.
virtual void del_deriv () const
 Deletes the derived quantities.
void set_der_0x0 () const
 Sets the pointers on derived quantities to 0x0.
virtual void del_derive_met (int) const
 Logical destructor of the derivatives depending on the i-th element of met_depend .
void set_der_met_0x0 (int) const
 Sets all the i-th components of met_depend , p_derive_cov , etc.
void set_dependance (const Metric &) const
 To be used to describe the fact that the derivatives members have been calculated with met .
int get_place_met (const Metric &) const
 Returns the position of the pointer on metre in the array met_depend .
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 interface is method derive_lie ).

Protected Attributes

const Map *const mp
 Mapping on which the numerical values at the grid points are defined.
int valence
 Valence of the tensor (0 = scalar, 1 = vector, etc...).
const Base_vecttriad
 Vectorial basis (triad) with respect to which the tensor components are defined.
Itbl type_indice
 1D array of integers (class Itbl ) of size valence containing the type of each index: COV for a covariant one and CON for a contravariant one.
int n_comp
 Number of stored components, depending on the symmetry.
Scalar ** cmp
 Array of size n_comp of pointers onto the components.
const Metricmet_depend [N_MET_MAX]
 Array on the Metric 's which were used to compute derived quantities, like p_derive_cov , etc.
Tensorp_derive_cov [N_MET_MAX]
 Array of pointers on the covariant derivatives of this with respect to various metrics.
Tensorp_derive_con [N_MET_MAX]
 Array of pointers on the contravariant derivatives of this with respect to various metrics.
Tensorp_divergence [N_MET_MAX]
 Array of pointers on the divergence of this with respect to various metrics.

Friends

class Scalar
class Vector
class Sym_tensor
class Tensor_sym
class Metric
ostream & operator<< (ostream &, const Tensor &)
Scalar operator+ (const Tensor &, const Scalar &)
Scalar operator+ (const Scalar &, const Tensor &)
Scalar operator- (const Tensor &, const Scalar &)
Scalar operator- (const Scalar &, const Tensor &)
Tensor operator* (const Tensor &, const Tensor &)
Tensor_sym operator* (const Tensor &, const Tensor_sym &)
Tensor_sym operator* (const Tensor_sym &, const Tensor &)
Tensor_sym operator* (const Tensor_sym &, const Tensor_sym &)
 Tensorial product of two symmetric tensors.

Detailed Description

Tensor handling.

()

This class has been devised to replace Tenseur and Cmp (the latter via the derived class Scalar ).

The Tensor class is intended to store the components of a tensorial field with respect to a specific basis (triad).

All this is 3D meaning that the indices go from 1 to 3.

Definition at line 284 of file tensor.h.


Constructor & Destructor Documentation

Tensor::Tensor ( const Map map,
int  val,
const Itbl tipe,
const Base_vect triad_i 
)

Standard constructor.

Parameters:
map the mapping
val valence of the tensor
tipe 1-D array of integers (class Itbl ) of size valence containing the type of each index, COV for a covariant one and CON for a contravariant one, with the following storage convention:

  • tipe(0) : type of the first index
  • tipe(1) : type of the second index
  • and so on...
triad_i vectorial basis (triad) with respect to which the tensor components are defined

Definition at line 198 of file tensor.C.

References cmp, Itbl::get_dim(), Itbl::get_ndim(), n_comp, set_der_0x0(), and valence.

Tensor::Tensor ( const Map map,
int  val,
const Itbl tipe,
const Base_vect triad_i 
)

Standard constructor with the triad passed as a pointer.

Parameters:
map the mapping
val valence of the tensor
tipe 1-D array of integers (class Itbl ) of size valence containing the type of each index, COV for a covariant one and CON for a contravariant one, with the following storage convention:

  • tipe(0) : type of the first index
  • tipe(1) : type of the second index
  • and so on...
triad_i pointer on the vectorial basis (triad) with respect to which the tensor components are defined (can be set to 0x0 for a scalar field)

Definition at line 221 of file tensor.C.

References cmp, Itbl::get_dim(), Itbl::get_ndim(), n_comp, set_der_0x0(), and valence.

Tensor::Tensor ( const Map map,
int  val,
int  tipe,
const Base_vect triad_i 
)

Standard constructor when all the indices are of the same type.

Parameters:
map the mapping
val valence of the tensor
tipe the type (COV or CON ) of the indices.
triad_i vectorial basis (triad) with respect to which the tensor components are defined.

Definition at line 247 of file tensor.C.

References cmp, n_comp, set_der_0x0(), type_indice, and valence.

Tensor::Tensor ( const Tensor source  ) 

Copy constructor.

Definition at line 267 of file tensor.C.

References cmp, indices(), n_comp, position(), pow(), set_der_0x0(), and valence.

Tensor::Tensor ( const Map map,
const Base_vect triad_i,
FILE *  fich 
)

Constructor from a file (see sauve(FILE*) ).

Parameters:
map the mapping
triad_i vectorial basis (triad) with respect to which the tensor components are defined. It will be checked that it coincides with the basis saved in the file.
fich file which has been created by the function sauve(FILE*) .

Definition at line 291 of file tensor.C.

References Base_vect::bvect_from_file(), cmp, fread_be(), Map::get_mg(), mp, n_comp, set_der_0x0(), triad, and valence.

Tensor::Tensor ( const Map map  )  [explicit, protected]

Constructor for a scalar field: to be used only by the derived class Scalar .

Definition at line 318 of file tensor.C.

References cmp, n_comp, and set_der_0x0().

Tensor::Tensor ( const Map map,
int  val,
const Itbl tipe,
int  n_comp_i,
const Base_vect triad_i 
) [protected]

Constructor to be used by derived classes, with symmetries among the components.

The number of independent components is given as an argument (n_comp_i ), and not computed from the valence, as in the standard constructor.

Parameters:
map the mapping
val valence of the tensor
tipe 1-D array of integers (class Itbl ) of size valence containing the type of each index, COV for a covariant one and CON for a contravariant one, with the following storage convention:

  • tipe(0) : type of the first index
  • tipe(1) : type of the second index
  • and so on...
n_comp_i number of components to be stored
triad_i vectorial basis (triad) with respect to which the tensor components are defined

Definition at line 330 of file tensor.C.

References cmp, Itbl::get_dim(), Itbl::get_ndim(), n_comp, set_der_0x0(), and valence.

Tensor::Tensor ( const Map map,
int  val,
int  tipe,
int  n_comp_i,
const Base_vect triad_i 
) [protected]

Constructor used by derived classes, with symmetries among the components, when all the indices are of the same type.

The number of independent components is given as a argument (n_comp_i ), and not computed from the valence, as in the standard constructor.

Parameters:
map the mapping
val valence of the tensor
tipe the type of the indices.
n_comp_i number of components to be stored
triad_i vectorial basis (triad) with respect to which the tensor components are defined

Definition at line 355 of file tensor.C.

References cmp, n_comp, set_der_0x0(), type_indice, and valence.

Tensor::~Tensor (  )  [virtual]

Destructor.

Definition at line 381 of file tensor.C.

References cmp, del_deriv(), and n_comp.


Member Function Documentation

void Tensor::allocate_all (  )  [virtual]

Performs the memory allocation of all the elements, down to the double arrays of the Tbl s.

This function performs in fact recursive calls to set_etat_qcq() on each element of the chain Scalar -> Valeur -> Mtbl -> Tbl .

Reimplemented in Scalar.

Definition at line 504 of file tensor.C.

References Scalar::allocate_all(), cmp, del_deriv(), and n_comp.

void Tensor::annule ( int  l_min,
int  l_max 
) [virtual]

Sets the Tensor to zero in several domains.

Parameters:
l_min [input] The Tensor will be set (logically) to zero in the domains whose indices are in the range [l_min,l_max] .
l_max [input] see the comments for l_min .

Note that annule(0,nz-1) , where nz is the total number of domains, is equivalent to set_etat_zero() .

Reimplemented in Scalar.

Definition at line 667 of file tensor.C.

References Scalar::annule(), cmp, del_deriv(), Map::get_mg(), Mg3d::get_nzone(), mp, n_comp, and set_etat_zero().

void Tensor::annule_domain ( int  l  ) 

Sets the Tensor to zero in a given domain.

Parameters:
l [input] Index of the domain in which the Tensor will be set (logically) to zero.

Definition at line 662 of file tensor.C.

References annule().

void Tensor::annule_extern_cn ( int  l_0,
int  deg 
)

Performs a smooth (C^n) transition in a given domain to zero.

Parameters:
l_0 [input] in the domain of index l0 the tensor is multiplied by the right polynomial (of degree 2n+1), to ensure continuty of the function and its n first derivative at both ends of this domain. The tensor is unchanged in the domains l < l_0 and set to zero in domains l > l_0.
deg [input] the degree n of smoothness of the transition.

Definition at line 686 of file tensor.C.

References Scalar::allocate_all(), Scalar::annule(), Itbl::annule_hard(), cmp, del_deriv(), Map::get_mg(), Mg3d::get_nr(), Mg3d::get_nzone(), Mg3d::get_type_r(), mp, n_comp, pow(), Map::r, Tbl::set(), Itbl::set(), Scalar::set_domain(), Tbl::set_etat_qcq(), Scalar::std_spectral_base(), and Map::val_r().

void Tensor::change_triad ( const Base_vect new_triad  )  [virtual]
void Tensor::compute_derive_lie ( const Vector v,
Tensor resu 
) const [protected]

Computes the Lie derivative of this with respect to some vector field v (protected method; the public interface is method derive_lie ).

Definition at line 335 of file tensor_calculus.C.

References cmp, contract(), Scalar::dec_dzpuis(), derive_cov(), Map::flat_met_cart(), Map::flat_met_spher(), Scalar::get_dzpuis(), get_n_comp(), get_triad(), indices(), mp, n_comp, operator()(), set(), Itbl::set(), triad, type_indice, and valence.

void Tensor::dec_dzpuis ( int  dec = 1  )  [virtual]

Decreases by dec units the value of dzpuis and changes accordingly the values in the compactified external domain (CED).

Reimplemented in Scalar.

Definition at line 804 of file tensor.C.

References cmp, del_deriv(), and n_comp.

void Tensor::del_deriv (  )  const [protected, virtual]

Deletes the derived quantities.

Reimplemented in Scalar, Sym_tensor, Sym_tensor_trans, Sym_tensor_tt, Vector, and Vector_divfree.

Definition at line 394 of file tensor.C.

References del_derive_met(), and set_der_0x0().

void Tensor::del_derive_met ( int  j  )  const [protected, virtual]

Logical destructor of the derivatives depending on the i-th element of met_depend .

Reimplemented in Sym_tensor, and Vector.

Definition at line 410 of file tensor.C.

References met_depend, p_derive_con, p_derive_cov, p_divergence, set_der_met_0x0(), and Metric::tensor_depend.

const Tensor & Tensor::derive_con ( const Metric gam  )  const

Returns the "contravariant" derivative of this with respect to some metric $\gamma$, by raising the last index of the covariant derivative (cf.

method derive_cov() ) with $\gamma$.

Reimplemented in Scalar, and Tensor_sym.

Definition at line 1010 of file tensor.C.

References Metric::con(), contract(), derive_cov(), get_index_type(), get_place_met(), mp, p_derive_con, Itbl::set(), set_dependance(), Tensor_sym::sym_index1(), Tensor_sym::sym_index2(), Tensor(), triad, and valence.

const Tensor & Tensor::derive_cov ( const Metric gam  )  const

Returns the covariant derivative of this with respect to some metric $\gamma$.

$T$ denoting the tensor represented by this and $\nabla T$ its covariant derivative with respect to the metric $\gamma$, the extra index (with respect to the indices of $T$) of $\nabla T$ is chosen to be the last one. This convention agrees with that of MTW (see Eq. (10.17) of MTW). For instance, if $T$ is a 1-form, whose components w.r.t. the triad $e^i$ are $T_i$: $T=T_i \; e^i$, then the covariant derivative of $T$ is the bilinear form $\nabla T$ whose components $\nabla_j T_i$ are such that

\[ \nabla T = \nabla_j T_i \; e^i \otimes e^j \]

Parameters:
gam metric $\gamma$
Returns:
covariant derivative $\nabla T$ of this with respect to the connection $\nabla$ associated with the metric $\gamma$

Reimplemented in Scalar, and Tensor_sym.

Definition at line 998 of file tensor.C.

References Metric::connect(), get_place_met(), Connection::p_derive_cov(), p_derive_cov, and set_dependance().

Tensor Tensor::derive_lie ( const Vector v  )  const

Computes the Lie derivative of this with respect to some vector field v.

Reimplemented in Scalar, Sym_tensor, and Tensor_sym.

Definition at line 477 of file tensor_calculus.C.

References compute_derive_lie(), mp, triad, type_indice, and valence.

const Tensor & Tensor::divergence ( const Metric gam  )  const

Computes the divergence of this with respect to some metric $\gamma$.

The divergence is taken with respect of the last index of this which thus must be contravariant. For instance if the tensor $T$ represented by this is a twice contravariant tensor, whose components w.r.t. the triad $e_i$ are $T^{ij}$: $T = T^{ij} \; e_i \otimes e_j$, the divergence of $T$ w.r.t. $\gamma$ is the vector

\[ {\rm div}\, T = \nabla_k T^{ik} \; e_i \]

where $\nabla$ denotes the connection associated with the metric $\gamma$.

Parameters:
gam metric $\gamma$
Returns:
divergence of this with respect to $\gamma$.

Reimplemented in Sym_tensor, and Vector.

Definition at line 1051 of file tensor.C.

References Metric::connect(), get_place_met(), Connection::p_divergence(), p_divergence, and set_dependance().

Tensor Tensor::down ( int  ind,
const Metric gam 
) const

Computes a new tensor by lowering an index of *this.

Parameters:
ind index to be lowered, with the following convention :

  • ind1 = 0 : first index of the tensor
  • ind1 = 1 : second index of the tensor
  • and so on... (ind must be of covariant type (CON )).
gam metric used to lower the index (contraction with the twice covariant form of the metric on the index ind ).

Definition at line 261 of file tensor_calculus.C.

References contract(), Metric::cov(), indices(), mp, n_comp, set(), Itbl::set(), triad, type_indice, and valence.

void Tensor::exponential_filter_r ( int  lzmin,
int  lzmax,
int  p,
double  alpha = -16. 
) [virtual]

Applies exponential filters to all components (see Scalar::exponential_filter_r ).

Works only for Cartesian components.

Reimplemented in Scalar, Sym_tensor, and Vector.

Definition at line 1062 of file tensor.C.

References cmp, Map::get_bvect_cart(), Base_vect::identify(), mp, n_comp, and triad.

void Tensor::exponential_filter_ylm ( int  lzmin,
int  lzmax,
int  p,
double  alpha = -16. 
) [virtual]

Applies exponential filters to all components (see Scalar::exponential_filter_ylm ).

Works only for Cartesian components.

Reimplemented in Scalar, Sym_tensor, and Vector.

Definition at line 1075 of file tensor.C.

References cmp, Map::get_bvect_cart(), Base_vect::identify(), mp, n_comp, and triad.

Itbl Tensor::get_index_type (  )  const [inline]

Returns the types of all the indices.

Returns:
1-D array of integers (class Itbl ) of size valence containing the type of each index, COV for a covariant one and CON for a contravariant one.

Definition at line 892 of file tensor.h.

References type_indice.

int Tensor::get_index_type ( int  i  )  const [inline]

Gives the type (covariant or contravariant) of the index number i .

i must be strictly lower than valence and obey the following convention:

  • i = 0 : first index
  • i = 1 : second index
  • and so on...
Returns:
COV for a covariant index, CON for a contravariant one.

Definition at line 882 of file tensor.h.

References type_indice.

const Map& Tensor::get_mp (  )  const [inline]

Returns the mapping.

Definition at line 857 of file tensor.h.

References mp.

int Tensor::get_n_comp (  )  const [inline]

Returns the number of stored components.

Definition at line 868 of file tensor.h.

References n_comp.

int Tensor::get_place_met ( const Metric metre  )  const [protected]

Returns the position of the pointer on metre in the array met_depend .

Definition at line 439 of file tensor.C.

References met_depend.

const Base_vect* Tensor::get_triad (  )  const [inline]

Returns the vectorial basis (triad) on which the components are defined.

Definition at line 862 of file tensor.h.

References triad.

int Tensor::get_valence (  )  const [inline]

Returns the valence.

Definition at line 865 of file tensor.h.

References valence.

void Tensor::inc_dzpuis ( int  inc = 1  )  [virtual]

Increases by inc units the value of dzpuis and changes accordingly the values in the compactified external domain (CED).

Reimplemented in Scalar.

Definition at line 812 of file tensor.C.

References cmp, del_deriv(), and n_comp.

Itbl Tensor::indices ( int  pos  )  const [virtual]

Returns the indices of a component given by its position in the array cmp .

Parameters:
pos [input] position in the array cmp of the pointer to the Scalar representing a component
Returns:
1-D array of integers (class Itbl ) of size valence giving the value of each index for the component located at the position pos in the array cmp, with the following storage convention:
  • Itbl(0) : value of the first index (1, 2 or 3)
  • Itbl(1) : value of the second index (1, 2 or 3)
  • and so on...

Reimplemented in Tensor_sym, and Vector.

Definition at line 535 of file tensor.C.

References n_comp, Itbl::set(), and valence.

const Scalar & Tensor::operator() ( int  i1,
int  i2,
int  i3,
int  i4 
) const

Returns the value of a component for a tensor of valence 4 (read-only version).

Parameters:
i1 value of the first index (1, 2 or 3)
i2 value of the second index (1, 2 or 3)
i3 value of the third index (1, 2 or 3)
i4 value of the fourth index (1, 2 or 3)
Returns:
reference on the component specified by (i1,i2,i3,i4)

Definition at line 779 of file tensor.C.

References cmp, position(), Itbl::set(), and valence.

const Scalar & Tensor::operator() ( int  i1,
int  i2,
int  i3 
) const

Returns the value of a component for a tensor of valence 3 (read-only version).

Parameters:
i1 value of the first index (1, 2 or 3)
i2 value of the second index (1, 2 or 3)
i3 value of the third index (1, 2 or 3)
Returns:
reference on the component specified by (i1,i2,i3)

Definition at line 767 of file tensor.C.

References cmp, position(), Itbl::set(), and valence.

const Scalar & Tensor::operator() ( int  i1,
int  i2 
) const

Returns the value of a component for a tensor of valence 2 (read-only version).

Parameters:
i1 value of the first index (1, 2 or 3)
i2 value of the second index (1, 2 or 3)
Returns:
reference on the component specified by (i1,i2)

Definition at line 756 of file tensor.C.

References cmp, position(), Itbl::set(), and valence.

const Scalar & Tensor::operator() ( const Itbl ind  )  const

Returns the value of a component (read-only version).

Parameters:
ind 1-D Itbl of size valence containing the values of each index specifing the component, with the following storage convention:

  • ind(0) : value of the first index (1, 2 or 3)
  • ind(1) : value of the second index (1, 2 or 3)
  • and so on...
Returns:
reference on the component specified by ind

Definition at line 794 of file tensor.C.

References cmp, Itbl::get_dim(), Itbl::get_ndim(), position(), and valence.

void Tensor::operator+= ( const Tensor t  ) 

+= Tensor

Reimplemented in Scalar.

Definition at line 567 of file tensor.C.

References cmp, del_deriv(), indices(), n_comp, position(), triad, type_indice, and valence.

void Tensor::operator-= ( const Tensor t  ) 

-= Tensor

Reimplemented in Scalar.

Definition at line 583 of file tensor.C.

References cmp, del_deriv(), indices(), n_comp, position(), triad, type_indice, and valence.

void Tensor::operator= ( const Tensor t  )  [virtual]

Assignment to a Tensor.

Reimplemented in Scalar, Sym_tensor, Sym_tensor_trans, Sym_tensor_tt, Tensor_sym, Vector, and Vector_divfree.

Definition at line 549 of file tensor.C.

References cmp, del_deriv(), indices(), n_comp, position(), triad, type_indice, and valence.

int Tensor::position ( const Itbl ind  )  const [virtual]

Returns the position in the array cmp of a component given by its indices.

Parameters:
ind [input] 1-D array of integers (class Itbl ) of size valence giving the values of each index specifing the component, with the following storage convention:

  • ind(0) : value of the first index (1, 2 or 3)
  • ind(1) : value of the second index (1, 2 or 3)
  • and so on...
Returns:
position in the array cmp of the pointer to the Scalar containing the component specified by ind

Reimplemented in Tensor_sym, and Vector.

Definition at line 521 of file tensor.C.

References Itbl::get_dim(), Itbl::get_ndim(), and valence.

void Tensor::sauve ( FILE *  fd  )  const [virtual]

Save in a binary file.

Reimplemented in Scalar, and Tensor_sym.

Definition at line 902 of file tensor.C.

References cmp, fwrite_be(), n_comp, Base_vect::sauve(), Itbl::sauve(), triad, type_indice, and valence.

Scalar & Tensor::set ( int  i1,
int  i2,
int  i3,
int  i4 
)

Returns the value of a component for a tensor of valence 4 (read/write version).

Parameters:
i1 value of the first index (1, 2 or 3)
i2 value of the second index (1, 2 or 3)
i3 value of the third index (1, 2 or 3)
i4 value of the fourth index (1, 2 or 3)
Returns:
modifiable reference on the component specified by (i1,i2,i3,i4)

Definition at line 633 of file tensor.C.

References cmp, del_deriv(), position(), Itbl::set(), and valence.

Scalar & Tensor::set ( int  i1,
int  i2,
int  i3 
)

Returns the value of a component for a tensor of valence 3 (read/write version).

Parameters:
i1 value of the first index (1, 2 or 3)
i2 value of the second index (1, 2 or 3)
i3 value of the third index (1, 2 or 3)
Returns:
modifiable reference on the component specified by (i1,i2,i3)

Definition at line 617 of file tensor.C.

References cmp, del_deriv(), position(), Itbl::set(), and valence.

Scalar & Tensor::set ( int  i1,
int  i2 
)

Returns the value of a component for a tensor of valence 2 (read/write version).

Parameters:
i1 value of the first index (1, 2 or 3)
i2 value of the second index (1, 2 or 3)
Returns:
modifiable reference on the component specified by (i1,i2)

Definition at line 602 of file tensor.C.

References cmp, del_deriv(), position(), Itbl::set(), and valence.

Scalar & Tensor::set ( const Itbl ind  ) 

Returns the value of a component (read/write version).

Parameters:
ind 1-D Itbl of size valence containing the values of each index specifing the component, with the following storage convention:

  • ind(0) : value of the first index (1, 2 or 3)
  • ind(1) : value of the second index (1, 2 or 3)
  • and so on...
Returns:
modifiable reference on the component specified by ind

Definition at line 650 of file tensor.C.

References cmp, del_deriv(), Itbl::get_dim(), Itbl::get_ndim(), position(), and valence.

void Tensor::set_dependance ( const Metric met  )  const [protected]

To be used to describe the fact that the derivatives members have been calculated with met .

First it sets a null element of met_depend to &met and puts this in the list of the dependancies of met .

Definition at line 449 of file tensor.C.

References met_depend, and Metric::tensor_depend.

void Tensor::set_der_0x0 (  )  const [protected]

Sets the pointers on derived quantities to 0x0.

Reimplemented in Scalar, Sym_tensor, Sym_tensor_trans, Sym_tensor_tt, Vector, and Vector_divfree.

Definition at line 403 of file tensor.C.

References set_der_met_0x0().

void Tensor::set_der_met_0x0 ( int  i  )  const [protected]

Sets all the i-th components of met_depend , p_derive_cov , etc.

.. to 0x0.

Reimplemented in Sym_tensor, and Vector.

Definition at line 429 of file tensor.C.

References met_depend, p_derive_con, p_derive_cov, and p_divergence.

void Tensor::set_etat_nondef (  )  [virtual]

Sets the logical state of all components to ETATNONDEF (undefined state).

Reimplemented in Scalar.

Definition at line 485 of file tensor.C.

References cmp, del_deriv(), n_comp, and Scalar::set_etat_nondef().

void Tensor::set_etat_qcq (  )  [virtual]

Sets the logical state of all components to ETATQCQ (ordinary state).

Reimplemented in Scalar.

Definition at line 477 of file tensor.C.

References cmp, del_deriv(), n_comp, and Scalar::set_etat_qcq().

void Tensor::set_etat_zero (  )  [virtual]

Sets the logical state of all components to ETATZERO (zero state).

Reimplemented in Scalar.

Definition at line 493 of file tensor.C.

References cmp, del_deriv(), n_comp, and Scalar::set_etat_zero().

Itbl& Tensor::set_index_type (  )  [inline]

Sets the types of all the indices.

Returns:
a reference on the 1-D array of integers (class Itbl ) of size valence that can be modified (COV for a covariant one and CON for a contravariant one)

Definition at line 914 of file tensor.h.

References type_indice.

int& Tensor::set_index_type ( int  i  )  [inline]

Sets the type of the index number i .

i must be strictly lower than valence and obey the following convention:

  • i = 0 : first index
  • i = 1 : second index
  • and so on...
Returns:
reference on the type that can be modified (COV for a covariant index, CON for a contravariant one)

Definition at line 905 of file tensor.h.

References Itbl::set(), and type_indice.

void Tensor::set_triad ( const Base_vect new_triad  ) 

Assigns a new vectorial basis (triad) of decomposition.

NB: this function modifies only the member triad and leave unchanged the components (member cmp ). In order to change them coherently with the new basis, the function change_triad(const Base_vect& ) must be called instead.

Definition at line 515 of file tensor.C.

References triad.

void Tensor::spectral_display ( const char *  comment = 0x0,
double  threshold = 1.e-7,
int  precision = 4,
ostream &  ostr = cout 
) const [virtual]

Displays the spectral coefficients and the associated basis functions of each component.

This function shows only the values greater than a given threshold.

Parameters:
comment comment to be printed at top of the display (default: 0x0 = nothing printed)
threshold [input] Value above which a coefficient is printed (default: 1.e-7)
precision [input] Number of printed digits (default: 4)
ostr [input] Output stream used for the printing (default: cout)

Reimplemented in Scalar.

Definition at line 870 of file tensor.C.

References cmp, indices(), n_comp, Scalar::spectral_display(), and valence.

void Tensor::std_spectral_base (  )  [virtual]

Sets the standard spectal bases of decomposition for each component.

To be used only with valence lower than or equal 2.

Reimplemented in Scalar, and Vector.

Definition at line 922 of file tensor.C.

References cmp, Map::get_bvect_cart(), Map::get_bvect_spher(), Map::get_mg(), Base_vect::identify(), indices(), mp, n_comp, Scalar::set_spectral_base(), Mg3d::std_base_vect_cart(), Mg3d::std_base_vect_spher(), Scalar::std_spectral_base(), triad, and valence.

void Tensor::std_spectral_base_odd (  )  [virtual]

Sets the standard odd spectal bases of decomposition for each component.

Currently only implemented for a scalar.

Reimplemented in Scalar.

Definition at line 978 of file tensor.C.

References cmp, Scalar::std_spectral_base_odd(), and valence.

Scalar Tensor::trace ( const Metric gam  )  const

Trace with respect to a given metric for a valence 2 tensor.

Parameters:
gam metric used to raise or lower one of the indices, in order to take the trace

Definition at line 193 of file tensor_calculus.C.

References Metric::con(), contract(), Metric::cov(), trace(), type_indice, and valence.

Scalar Tensor::trace (  )  const

Trace on two different type indices for a valence 2 tensor.

Definition at line 176 of file tensor_calculus.C.

References mp, operator()(), Scalar::set_etat_zero(), type_indice, and valence.

Tensor Tensor::trace ( int  ind1,
int  ind2,
const Metric gam 
) const

Trace with respect to a given metric.

Parameters:
ind1 first index for the contraction, with the following convention :

  • ind1 = 0 : first index of the tensor
  • ind1 = 1 : second index of the tensor
  • and so on...
ind2 second index for the contraction
gam metric used to raise or lower ind1 in order that it has a opposite type than ind2

Definition at line 149 of file tensor_calculus.C.

References Metric::con(), contract(), Metric::cov(), trace(), type_indice, and valence.

Tensor Tensor::trace ( int  ind1,
int  ind2 
) const

Trace on two different type indices.

Parameters:
ind1 first index for the contraction, with the following convention :

  • ind1 = 0 : first index of the tensor
  • ind1 = 1 : second index of the tensor
  • and so on...
ind2 second index for the contraction

Definition at line 90 of file tensor_calculus.C.

References cmp, get_n_comp(), indices(), mp, position(), set(), Itbl::set(), Scalar::set_etat_zero(), triad, type_indice, and valence.

Tensor Tensor::up ( int  ind,
const Metric gam 
) const

Computes a new tensor by raising an index of *this.

Parameters:
ind index to be raised, with the following convention :

  • ind1 = 0 : first index of the tensor
  • ind1 = 1 : second index of the tensor
  • and so on... (ind must be of covariant type (COV )).
gam metric used to raise the index (contraction with the twice contravariant form of the metric on the index ind ).

Definition at line 221 of file tensor_calculus.C.

References Metric::con(), contract(), indices(), mp, n_comp, set(), Itbl::set(), triad, type_indice, and valence.

Tensor Tensor::up_down ( const Metric gam  )  const

Computes a new tensor by raising or lowering all the indices of *this .

Parameters:
gam metric used to lower the contravariant indices and raising the covariant ones.

Definition at line 301 of file tensor_calculus.C.

References down(), Tensor(), type_indice, up(), and valence.


Friends And Related Function Documentation

Tensor_sym operator* ( const Tensor_sym a,
const Tensor_sym b 
) [friend]

Tensorial product of two symmetric tensors.

NB: the output is an object of class Tensor_sym , with the two symmetric indices corresponding to the symmetric indices of tensor a . This means that the symmetries of tensor b indices are not used in the storage, since there is currently no class in Lorene to manage tensors with more than two symmetric indices.

Definition at line 147 of file tensor_sym_calculus.C.


Member Data Documentation

Scalar** Tensor::cmp [protected]

Array of size n_comp of pointers onto the components.

Definition at line 311 of file tensor.h.

const Metric* Tensor::met_depend[N_MET_MAX] [mutable, protected]

Array on the Metric 's which were used to compute derived quantities, like p_derive_cov , etc.

.. The i-th element of this array is the Metric used to compute the i-th element of p_derive_cov , etc..

Definition at line 323 of file tensor.h.

const Map* const Tensor::mp [protected]

Mapping on which the numerical values at the grid points are defined.

Definition at line 291 of file tensor.h.

int Tensor::n_comp [protected]

Number of stored components, depending on the symmetry.

Definition at line 308 of file tensor.h.

Tensor* Tensor::p_derive_con[N_MET_MAX] [mutable, protected]

Array of pointers on the contravariant derivatives of this with respect to various metrics.

See the comments of met_depend . See also the comments of method derive_con() for a precise definition of a "contravariant" derivative.

Definition at line 339 of file tensor.h.

Tensor* Tensor::p_derive_cov[N_MET_MAX] [mutable, protected]

Array of pointers on the covariant derivatives of this with respect to various metrics.

See the comments of met_depend . See also the comments of method derive_cov() for the index convention of the covariant derivation.

Definition at line 331 of file tensor.h.

Tensor* Tensor::p_divergence[N_MET_MAX] [mutable, protected]

Array of pointers on the divergence of this with respect to various metrics.

See the comments of met_depend . See also the comments of method divergence() for a precise definition of a the divergence with respect to a given metric.

Definition at line 347 of file tensor.h.

const Base_vect* Tensor::triad [protected]

Vectorial basis (triad) with respect to which the tensor components are defined.

Definition at line 299 of file tensor.h.

1D array of integers (class Itbl ) of size valence containing the type of each index: COV for a covariant one and CON for a contravariant one.

Definition at line 306 of file tensor.h.

int Tensor::valence [protected]

Valence of the tensor (0 = scalar, 1 = vector, etc...).

Definition at line 294 of file tensor.h.


The documentation for this class was generated from the following files:

Generated on 7 Oct 2014 for LORENE by  doxygen 1.6.1