LORENE
tensor.h
1 /*
2  * Definition of Lorene classes Tensor and Sym_tensor
3  *
4  */
5 
6 /*
7  * Copyright (c) 2003-2004 Eric Gourgoulhon & Jerome Novak
8  *
9  * Copyright (c) 1999-2001 Philippe Grandclement (for preceding class Tenseur)
10  * Copyright (c) 2000-2001 Eric Gourgoulhon (for preceding class Tenseur)
11  * Copyright (c) 2002 Jerome Novak (for preceding class Tenseur)
12  *
13  * This file is part of LORENE.
14  *
15  * LORENE is free software; you can redistribute it and/or modify
16  * it under the terms of the GNU General Public License as published by
17  * the Free Software Foundation; either version 2 of the License, or
18  * (at your option) any later version.
19  *
20  * LORENE is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License
26  * along with LORENE; if not, write to the Free Software
27  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28  *
29  */
30 
31 
32 #ifndef __TENSOR_H_
33 #define __TENSOR_H_
34 
35 
36 /*
37  * $Id: tensor.h,v 1.61 2014/10/13 08:52:37 j_novak Exp $
38  * $Log: tensor.h,v $
39  * Revision 1.61 2014/10/13 08:52:37 j_novak
40  * Lorene classes and functions now belong to the namespace Lorene.
41  *
42  * Revision 1.60 2013/06/05 15:43:49 j_novak
43  * Suppression of leg_spectral_base()
44  *
45  * Revision 1.59 2013/01/11 15:44:54 j_novak
46  * Addition of Legendre bases (part 2).
47  *
48  * Revision 1.58 2008/12/05 08:44:02 j_novak
49  * New flag to control the "verbosity" of maxabs.
50  *
51  * Revision 1.57 2007/12/21 16:06:16 j_novak
52  * Methods to filter Tensor, Vector and Sym_tensor objects.
53  *
54  * Revision 1.56 2006/06/07 14:08:58 j_novak
55  * New methods set_index_type( / int).
56  *
57  * Revision 1.55 2005/10/25 08:56:34 p_grandclement
58  * addition of std_spectral_base in the case of odd functions near the origin
59  *
60  * Revision 1.54 2004/07/08 12:21:51 j_novak
61  * Replaced tensor::annule_extern_c2 with tensor::annule_extern_cn for a
62  * more general transition.
63  *
64  * Revision 1.53 2004/06/17 06:54:23 e_gourgoulhon
65  * Added method annule_extern_c2.
66  *
67  * Revision 1.52 2004/05/13 21:29:27 e_gourgoulhon
68  * Added (external) functions central_value, max_all_domains,
69  * min_all_domains and maxabs_all_domains.
70  *
71  * Revision 1.51 2004/03/24 14:53:39 j_novak
72  * Double declarations suppressed
73  *
74  * Revision 1.50 2004/03/22 13:12:43 j_novak
75  * Modification of comments to use doxygen instead of doc++
76  *
77  * Revision 1.49 2004/02/27 21:12:44 e_gourgoulhon
78  * Suppressed function contract_desal (since contract has now the
79  * boolean argument "desaliasing").
80  *
81  * Revision 1.48 2004/02/26 22:44:37 e_gourgoulhon
82  * -- constructor of Tensor from Map is now declared explicit.
83  * -- class Tensor: added methods compute_derive_lie and derive_lie
84  * -- class Tensor_sym: added methods derive_cov, derive_con and derive_lie.
85  *
86  * Revision 1.47 2004/02/19 22:08:51 e_gourgoulhon
87  * Added argument "comment" in method spectral_display,
88  * as well as in external functions min, max, maxabs, etc...
89  *
90  * Revision 1.46 2004/02/18 18:42:41 e_gourgoulhon
91  * -- Added methods trace.
92  * -- Method scontract suppressed ( since it is the same as trace(int, int) ).
93  *
94  * Revision 1.45 2004/02/18 15:52:39 e_gourgoulhon
95  * -- Added optional argument desaliasing in function contract.
96  * -- Added new function contract for double contraction.
97  *
98  * Revision 1.44 2004/02/16 10:48:06 e_gourgoulhon
99  * Added "class Tensor_sym;" at the beginning.
100  *
101  * Revision 1.43 2004/02/15 21:53:48 e_gourgoulhon
102  * Modif. comments: suppressed the mention *** under development ***.
103  *
104  * Revision 1.42 2004/01/30 12:44:17 e_gourgoulhon
105  * Added Tensor_sym operator*(const Tensor_sym&, const Tensor_sym& ).
106  *
107  * Revision 1.41 2004/01/27 13:05:10 j_novak
108  * Removed the method Tensor::mult_r_ced()
109  *
110  * Revision 1.40 2004/01/19 16:31:40 e_gourgoulhon
111  * Added operator()(int, int, int, int) and set(int, int, int, int)
112  * for direct access to components of valence 4 tensors.
113  *
114  * Revision 1.39 2004/01/15 11:09:27 f_limousin
115  * Modif in method contract_desal
116  *
117  * Revision 1.38 2004/01/15 11:00:44 f_limousin
118  * Added method contract_desal for the contraction of two tensors with desaliasing
119  *
120  * Revision 1.37 2004/01/14 11:39:00 f_limousin
121  * Added method contract for one tensor
122  *
123  * Revision 1.36 2004/01/08 09:21:39 e_gourgoulhon
124  * Added arithmetics of Tensor_sym.
125  * Added arithmetics with Scalar (to solve some ambiguities with respect
126  * to the Scalar arithmetics).
127  * Added Tensor_sym tensorial product.
128  *
129  * Revision 1.35 2004/01/04 20:47:37 e_gourgoulhon
130  * -- Introduction of new derived class Tensor_sym to store tensor with
131  * two symmetric indices
132  * -- Suppression of class Tensor_delta (now a special case of Tensor_sym).
133  *
134  * Revision 1.34 2003/12/27 14:58:01 e_gourgoulhon
135  * Improved documentation. In particular, better description of methods
136  * derive_cov(), derive_con() and divergence(), taking into account the
137  * new index convention for covariant derivatives.
138  *
139  * Revision 1.33 2003/12/05 16:41:05 f_limousin
140  * Added method operator*
141  *
142  * Revision 1.32 2003/11/06 14:43:37 e_gourgoulhon
143  * Gave a name to const arguments in certain method prototypes (e.g.
144  * constructors) to correct a bug of DOC++.
145  *
146  * Revision 1.31 2003/11/05 15:25:57 e_gourgoulhon
147  * Added declaration of external functions:
148  * max, min, maxabs, diffrel and diffrelmax.
149  *
150  * Revision 1.30 2003/11/03 10:58:00 j_novak
151  * Suppressed the constructor from a Sym_tensor.
152  *
153  * Revision 1.29 2003/10/29 11:00:42 e_gourgoulhon
154  * Virtual functions dec_dzpuis and inc_dzpuis have now an integer argument to
155  * specify by which amount dzpuis is to be increased.
156  * Accordingly virtual methods dec2_dzpuis and inc2_dzpuis have been suppressed.
157  *
158  * Revision 1.28 2003/10/28 21:21:50 e_gourgoulhon
159  * Member function Tensor::contract(int, int) renamed
160  * Tensor::scontract(int, int) in order not to mask
161  * the non-member function contract.
162  *
163  * Revision 1.27 2003/10/27 10:44:00 e_gourgoulhon
164  * Declaration of class Sym_tensor is now in file sym_tensor.h.
165  *
166  * Revision 1.26 2003/10/24 15:00:19 j_novak
167  * Forgotten Class declaration... thanks IBM aix!
168  *
169  * Revision 1.25 2003/10/20 14:26:02 j_novak
170  * New assignement operators.
171  *
172  * Revision 1.24 2003/10/20 09:32:10 j_novak
173  * Members p_potential and p_div_free of the Helmholtz decomposition
174  * + the method decompose_div(Metric).
175  *
176  * Revision 1.23 2003/10/19 19:47:31 e_gourgoulhon
177  * Introduced new virtual method spectral_display.
178  *
179  * Revision 1.22 2003/10/16 15:24:30 e_gourgoulhon
180  * Name of method annule(int ) changed to annule_domain(int ).
181  *
182  * Revision 1.21 2003/10/16 14:21:33 j_novak
183  * The calculation of the divergence of a Tensor is now possible.
184  *
185  * Revision 1.20 2003/10/13 13:52:39 j_novak
186  * Better managment of derived quantities.
187  *
188  * Revision 1.19 2003/10/08 14:24:08 j_novak
189  * replaced mult_r_zec with mult_r_ced
190  *
191  * Revision 1.18 2003/10/06 20:48:23 e_gourgoulhon
192  * Added methods down and up_down.
193  *
194  * Revision 1.17 2003/10/06 16:17:29 j_novak
195  * Calculation of contravariant derivative and Ricci scalar.
196  *
197  * Revision 1.16 2003/10/06 15:12:56 e_gourgoulhon
198  * Added tensor contraction and raising of index.
199  *
200  * Revision 1.15 2003/10/06 13:58:45 j_novak
201  * The memory management has been improved.
202  * Implementation of the covariant derivative with respect to the exact Tensor
203  * type.
204  *
205  * Revision 1.14 2003/10/05 21:07:27 e_gourgoulhon
206  * Method std_spectral_base() is now virtual.
207  *
208  * Revision 1.13 2003/10/03 11:21:45 j_novak
209  * More methods for the class Metric
210  *
211  * Revision 1.12 2003/10/02 15:45:48 j_novak
212  * New class Metric
213  *
214  * Revision 1.11 2003/10/01 15:41:14 e_gourgoulhon
215  * class name Delta changed to Tensor_delta.
216  *
217  * Revision 1.10 2003/10/01 13:03:52 e_gourgoulhon
218  * The method get_mp() returns now a reference (and not a pointer)
219  * onto a mapping.
220  *
221  * Revision 1.9 2003/09/29 13:48:17 j_novak
222  * New class Delta.
223  *
224  * Revision 1.8 2003/09/26 14:33:51 j_novak
225  * Arithmetic functions for the class Tensor
226  *
227  * Revision 1.7 2003/09/26 08:05:29 j_novak
228  * New class Vector.
229  *
230  * Revision 1.6 2003/09/25 21:01:50 e_gourgoulhon
231  * Improved comments.
232  *
233  * Revision 1.5 2003/09/25 13:37:38 j_novak
234  * Symmetric tensors of valence 2 are now implemented (not tested yet).
235  *
236  * Revision 1.4 2003/09/24 15:10:54 j_novak
237  * Suppression of the etat flag in class Tensor (still present in Scalar)
238  *
239  * Revision 1.3 2003/09/24 08:46:31 j_novak
240  * Added tensor.h and scalar.h to the documentation
241  *
242  * Revision 1.2 2003/09/23 08:53:11 e_gourgoulhon
243  * not ready yet
244  *
245  * Revision 1.1 2003/09/22 12:50:47 e_gourgoulhon
246  * First version: not ready yet!
247  *
248  *
249  * $Header: /cvsroot/Lorene/C++/Include/tensor.h,v 1.61 2014/10/13 08:52:37 j_novak Exp $
250  *
251  */
252 
253 #define COV -1
254 #define CON +1
255 
256 #define N_MET_MAX 5
257 
258 // Headers Lorene
259 #include "itbl.h"
260 #include "base_vect.h"
261 #include "map.h"
262 
263 namespace Lorene {
264 class Scalar ;
265 class Vector ;
266 class Tensor_sym ;
267 class Sym_tensor ;
268 class Metric ;
269 
270  //-------------------------//
271  // class Tensor //
272  //-------------------------//
273 
274 
288 class Tensor {
289 
290  // Data :
291  // -----
292  protected:
293 
295  const Map* const mp ;
296 
298  int valence ;
299 
303  const Base_vect* triad ;
304 
311 
312  int n_comp ;
313 
315  Scalar** cmp ;
316 
317 
318  // Derived data :
319  // ------------
320  protected:
327  mutable const Metric* met_depend[N_MET_MAX] ;
328 
335  mutable Tensor* p_derive_cov[N_MET_MAX];
336 
343  mutable Tensor* p_derive_con[N_MET_MAX];
344 
351  mutable Tensor* p_divergence[N_MET_MAX];
352 
353 
354  // Constructors - Destructor :
355  // -------------------------
356 
357  public:
358 
374  Tensor(const Map& map, int val, const Itbl& tipe,
375  const Base_vect& triad_i) ;
376 
393  Tensor(const Map& map, int val, const Itbl& tipe,
394  const Base_vect* triad_i) ;
395 
405  Tensor(const Map& map, int val, int tipe,
406  const Base_vect& triad_i) ;
407 
408  Tensor(const Tensor&) ;
409 
420  Tensor(const Map& map, const Base_vect& triad_i, FILE* fich) ;
421 
422  protected:
428  explicit Tensor(const Map& map) ;
429 
451  Tensor(const Map& map, int val, const Itbl& tipe, int n_comp_i,
452  const Base_vect& triad_i) ;
453 
468  Tensor(const Map& map, int val, int tipe, int n_comp_i,
469  const Base_vect& triad_i) ;
470 
471 
472  public:
473 
474  virtual ~Tensor() ;
475 
476  // Memory management
477  // -----------------
478  protected:
479  virtual void del_deriv() const ;
480 
482  void set_der_0x0() const ;
483 
488  virtual void del_derive_met(int) const ;
489 
494  void set_der_met_0x0(int) const ;
495 
505  void set_dependance (const Metric&) const ;
506 
512  int get_place_met(const Metric&) const ;
513 
514  // Mutators / assignment
515  // ---------------------
516  public:
521  virtual void set_etat_nondef() ;
522 
527  virtual void set_etat_zero() ;
528 
533  virtual void set_etat_qcq() ;
534 
543  virtual void allocate_all() ;
544 
548  virtual void change_triad(const Base_vect& new_triad) ;
549 
556  void set_triad(const Base_vect& new_triad) ;
557 
558 
559  virtual void operator=(const Tensor&) ;
560 
572  Scalar& set(const Itbl& ind) ;
573 
583  Scalar& set(int i1, int i2) ;
584 
585 
596  Scalar& set(int i1, int i2, int i3) ;
597 
610  Scalar& set(int i1, int i2, int i3, int i4) ;
611 
617  void annule_domain(int l) ;
618 
630  virtual void annule(int l_min, int l_max) ;
631 
643  void annule_extern_cn(int l_0, int deg) ;
644 
649  virtual void std_spectral_base() ;
650 
655  virtual void std_spectral_base_odd() ;
656 
661  virtual void dec_dzpuis(int dec = 1) ;
662 
667  virtual void inc_dzpuis(int inc = 1) ;
668 
673  virtual void exponential_filter_r(int lzmin, int lzmax, int p,
674  double alpha= -16.) ;
675 
680  virtual void exponential_filter_ylm(int lzmin, int lzmax, int p,
681  double alpha= -16.) ;
682 
683  // Computational methods
684  // ---------------------
685 
686  protected:
691  void compute_derive_lie(const Vector& v, Tensor& resu) const ;
692 
693 
694  public:
717  const Tensor& derive_cov(const Metric& gam) const ;
718 
724  const Tensor& derive_con(const Metric& gam) const ;
725 
743  const Tensor& divergence(const Metric& gam) const ;
744 
745 
749  Tensor derive_lie(const Vector& v) const ;
750 
763  Tensor up(int ind, const Metric& gam) const ;
764 
777  Tensor down(int ind, const Metric& gam) const ;
778 
786  Tensor up_down(const Metric& gam) const ;
787 
796  Tensor trace(int ind1, int ind2) const ;
797 
808  Tensor trace(int ind1, int ind2, const Metric& gam) const ;
809 
812  Scalar trace() const ;
813 
818  Scalar trace(const Metric& gam) const ;
819 
820 
821  // Accessors
822  // ---------
823  public:
839  virtual int position(const Itbl& ind) const ;
840 
857  virtual Itbl indices(int pos) const ;
858 
859  public:
861  const Map& get_mp() const {return *mp ;} ;
862 
866  const Base_vect* get_triad() const {return triad;} ;
867 
869  int get_valence() const {return valence ; } ;
870 
872  int get_n_comp() const {return n_comp ;} ;
873 
886  int get_index_type(int i) const {return type_indice(i) ;};
887 
896  Itbl get_index_type() const {return type_indice ; } ;
897 
909  int& set_index_type(int i) {return type_indice.set(i) ;};
910 
918  Itbl& set_index_type() {return type_indice ; } ;
919 
920 
932  const Scalar& operator()(const Itbl& ind) const ;
933 
943  const Scalar& operator()(int i1, int i2) const ;
944 
955  const Scalar& operator()(int i1, int i2, int i3) const ;
956 
968  const Scalar& operator()(int i1, int i2, int i3, int i4) const ;
969 
970  // Member arithmetics
971  // ------------------
972  public:
973  void operator+=(const Tensor &) ;
974  void operator-=(const Tensor &) ;
975 
976  // Outputs
977  // -------
978  public:
979  virtual void sauve(FILE *) const ;
980 
991  virtual void spectral_display(const char* comment = 0x0,
992  double threshold = 1.e-7, int precision = 4,
993  ostream& ostr = cout) const ;
994 
995  friend ostream& operator<<(ostream& , const Tensor & ) ;
996 
997 
998  // Friend classes
999  // ---------------
1000  friend class Scalar ;
1001  friend class Vector ;
1002  friend class Sym_tensor ;
1003  friend class Tensor_sym ;
1004  friend class Metric ;
1005 
1006  // Mathematical operators
1007  // ----------------------
1008 
1009  friend Scalar operator+(const Tensor&, const Scalar&) ;
1010  friend Scalar operator+(const Scalar&, const Tensor&) ;
1011  friend Scalar operator-(const Tensor&, const Scalar&) ;
1012  friend Scalar operator-(const Scalar&, const Tensor&) ;
1013  friend Tensor operator*(const Tensor&, const Tensor&) ;
1014  friend Tensor_sym operator*(const Tensor&, const Tensor_sym&) ;
1015  friend Tensor_sym operator*(const Tensor_sym&, const Tensor&) ;
1016  friend Tensor_sym operator*(const Tensor_sym&, const Tensor_sym&) ;
1017 
1018 };
1019 
1020 
1021 
1022  //-------------------------//
1023  // class Tensor_sym //
1024  //-------------------------//
1025 
1037 class Tensor_sym : public Tensor {
1038 
1039  // Data :
1040  // -----
1041  protected:
1042 
1044  int id_sym1 ;
1045 
1049  int id_sym2 ;
1050 
1051 
1052  // Constructors - Destructor :
1053  // -------------------------
1054 
1055  public:
1056 
1076  Tensor_sym(const Map& map, int val, const Itbl& tipe,
1077  const Base_vect& triad_i, int index_sym1,
1078  int index_sym2) ;
1079 
1093  Tensor_sym(const Map& map, int val, int tipe, const Base_vect& triad_i,
1094  int index_sym1, int index_sym2) ;
1095 
1109  Tensor_sym(const Map& map, int tipe0, int tipe1, int tipe2,
1110  const Base_vect& triad_i,
1111  int index_sym1, int index_sym2) ;
1112 
1113  Tensor_sym(const Tensor_sym& a) ;
1114 
1125  Tensor_sym(const Map& map, const Base_vect& triad_i, FILE* fich) ;
1126 
1127  public:
1128 
1129  virtual ~Tensor_sym() ;
1130 
1131  // Mutators / assignment
1132  // ---------------------
1133  public:
1134 
1136  virtual void operator=(const Tensor_sym& a) ;
1137 
1142  virtual void operator=(const Tensor& a) ;
1143 
1144 
1145  // Accessors
1146  // ---------
1147  public:
1149  int sym_index1() const {return id_sym1;} ;
1150 
1154  int sym_index2() const {return id_sym2;} ;
1155 
1171  virtual int position(const Itbl& ind) const ;
1172 
1189  virtual Itbl indices(int pos) const ;
1190 
1191 
1192  // Outputs
1193  // -------
1194  public:
1195  virtual void sauve(FILE *) const ;
1196 
1197 
1198  // Tensor calculus
1199  // ---------------
1200  public:
1201 
1216  const Tensor_sym& derive_cov(const Metric& gam) const ;
1217 
1223  const Tensor_sym& derive_con(const Metric& gam) const ;
1224 
1228  Tensor_sym derive_lie(const Vector& v) const ;
1229 
1230 
1231  // Mathematical operators
1232  // ----------------------
1233 
1234  friend Tensor_sym operator*(const Tensor&, const Tensor_sym&) ;
1235  friend Tensor_sym operator*(const Tensor_sym&, const Tensor&) ;
1236 
1237 };
1238 
1239 
1240 
1247 Tensor operator*(const Tensor& a, const Tensor& b) ;
1249 
1251 Tensor_sym operator*(const Tensor& a, const Tensor_sym& b) ;
1252 
1254 Tensor_sym operator*(const Tensor_sym& a, const Tensor& b) ;
1255 
1264 Tensor_sym operator*(const Tensor_sym& a, const Tensor_sym& b) ;
1265 
1266 
1286 Tensor contract(const Tensor& t1, int ind1, const Tensor& t2, int ind2,
1287  bool desaliasing = false) ;
1288 
1315 Tensor contract(const Tensor& t1, int ind_i1, int ind_j1,
1316  const Tensor& t2, int ind_i2, int ind_j2,
1317  bool desaliasing = false) ;
1318 
1319 
1335 Tensor contract(const Tensor& t1, int ind1, int ind2) ;
1336 
1337 
1349 Tbl max(const Tensor& aa, const char* comment = 0x0, ostream& ost = cout) ;
1350 
1351 
1363 Tbl min(const Tensor& aa, const char* comment = 0x0, ostream& ost = cout) ;
1364 
1376 Tbl maxabs(const Tensor& aa, const char* comment = 0x0, ostream& ost = cout,
1377  bool verb = true) ;
1378 
1379 
1394 Tbl diffrel(const Tensor& aa, const Tensor& bb, const char* comment = 0x0,
1395  ostream& ost = cout) ;
1396 
1411 Tbl diffrelmax(const Tensor& aa, const Tensor& bb, const char* comment = 0x0,
1412  ostream& ost = cout) ;
1413 
1424 Tbl central_value(const Tensor& aa, const char* comment = 0x0, ostream& ost = cout) ;
1425 
1438 Tbl max_all_domains(const Tensor& aa, int l_excluded = -1, const char* comment = 0x0,
1439  ostream& ost = cout) ;
1440 
1441 
1454 Tbl min_all_domains(const Tensor& aa, int l_excluded = -1, const char* comment = 0x0,
1455  ostream& ost = cout) ;
1456 
1469 Tbl maxabs_all_domains(const Tensor& aa, int l_excluded = -1, const char* comment = 0x0,
1470  ostream& ost = cout, bool verb = true) ;
1471 
1472 
1473 
1483 Tensor operator+(const Tensor& ) ;
1484 Tensor operator-(const Tensor& ) ;
1485 Tensor operator+(const Tensor& a, const Tensor& b) ;
1486 
1488 Scalar operator+(const Tensor& a, const Scalar& b) ;
1489 
1491 Scalar operator+(const Scalar& a, const Tensor& b) ;
1492 
1493 Tensor operator-(const Tensor& a, const Tensor& b) ;
1494 
1496 Scalar operator-(const Tensor& a, const Scalar& b) ;
1497 
1499 Scalar operator-(const Scalar& a, const Tensor& b) ;
1500 
1501 Tensor operator*(const Scalar& a , const Tensor& b) ;
1502 Tensor operator*(const Tensor& a, const Scalar& b) ;
1503 Tensor operator*(double , const Tensor&) ;
1504 Tensor operator* (const Tensor&, double) ;
1505 Tensor operator*(int, const Tensor &) ;
1506 Tensor operator*(const Tensor&, int) ;
1507 Tensor operator/(const Tensor&, const Scalar&) ;
1508 Tensor operator/(const Tensor&, double) ;
1509 Tensor operator/(const Tensor&, int) ;
1510 
1512 
1520 Tensor_sym operator+(const Tensor_sym&) ;
1521 
1525 Tensor_sym operator-(const Tensor_sym&) ;
1526 
1531 Tensor_sym operator+(const Tensor_sym&, const Tensor_sym&) ;
1532 
1537 Tensor_sym operator-(const Tensor_sym&, const Tensor_sym&) ;
1538 
1542 Tensor_sym operator*(const Scalar& a, const Tensor_sym& b) ;
1543 
1547 Tensor_sym operator*(const Tensor_sym& a, const Scalar& b) ;
1548 
1552 Tensor_sym operator*(double, const Tensor_sym&) ;
1553 
1557 Tensor_sym operator*(const Tensor_sym&, double) ;
1558 
1562 Tensor_sym operator*(int, const Tensor_sym&) ;
1563 
1567 Tensor_sym operator*(const Tensor_sym&, int) ;
1568 
1572 Tensor_sym operator/(const Tensor_sym&, const Scalar&) ;
1573 
1577 Tensor_sym operator/(const Tensor_sym&, double) ;
1578 
1582 Tensor_sym operator/(const Tensor_sym&, int) ;
1583 
1586 }
1587 #include "scalar.h"
1588 
1589 #include "vector.h"
1590 
1591 #include "sym_tensor.h"
1592 
1593 
1594 #endif
void annule_domain(int l)
Sets the Tensor to zero in a given domain.
Definition: tensor.C:666
Tbl maxabs(const Tensor &aa, const char *comment=0x0, ostream &ost=cout, bool verb=true)
Maxima in each domain of the absolute values of the tensor components.
Metric for tensor calculation.
Definition: metric.h:90
virtual void set_etat_qcq()
Sets the logical state of all components to ETATQCQ (ordinary state).
Definition: tensor.C:481
Tbl min_all_domains(const Tensor &aa, int l_excluded=-1, const char *comment=0x0, ostream &ost=cout)
Minimum value of each component of a tensor over all the domains.
virtual void operator=(const Tensor &)
Assignment to a Tensor.
Definition: tensor.C:553
int & set(int i)
Read/write of a particular element (index i ) (1D case)
Definition: itbl.h:247
int n_comp
Number of stored components, depending on the symmetry.
Definition: tensor.h:312
int sym_index1() const
Number of the first symmetric index (0<= id_sym1 < valence )
Definition: tensor.h:1149
Tbl central_value(const Tensor &aa, const char *comment=0x0, ostream &ost=cout)
Central value of each component of a tensor.
virtual void del_derive_met(int) const
Logical destructor of the derivatives depending on the i-th element of met_depend ...
Definition: tensor.C:414
Lorene prototypes.
Definition: app_hor.h:64
void set_dependance(const Metric &) const
To be used to describe the fact that the derivatives members have been calculated with met ...
Definition: tensor.C:453
Tensor up(int ind, const Metric &gam) const
Computes a new tensor by raising an index of *this.
Itbl & set_index_type()
Sets the types of all the indices.
Definition: tensor.h:918
Tensor derive_lie(const Vector &v) const
Computes the Lie derivative of this with respect to some vector field v.
friend Tensor operator*(const Tensor &, const Tensor &)
Tensorial product.
Tensor field of valence 0 (or component of a tensorial field).
Definition: scalar.h:387
virtual void set_etat_nondef()
Sets the logical state of all components to ETATNONDEF (undefined state).
Definition: tensor.C:489
int id_sym2
Number of the second symmetric index (id_sym1 < id_sym2 < valence )
Definition: tensor.h:1049
Base class for coordinate mappings.
Definition: map.h:670
int get_n_comp() const
Returns the number of stored components.
Definition: tensor.h:872
Tensor up_down(const Metric &gam) const
Computes a new tensor by raising or lowering all the indices of *this .
int sym_index2() const
Number of the second symmetric index (id_sym1 < id_sym2 < valence )
Definition: tensor.h:1154
Basic integer array class.
Definition: itbl.h:122
const Base_vect * triad
Vectorial basis (triad) with respect to which the tensor components are defined.
Definition: tensor.h:303
virtual void sauve(FILE *) const
Save in a binary file.
Definition: tensor.C:906
virtual void std_spectral_base_odd()
Sets the standard odd spectal bases of decomposition for each component.
Definition: tensor.C:982
Cmp operator/(const Cmp &, const Cmp &)
Cmp / Cmp.
Definition: cmp_arithm.C:457
Tbl min(const Cmp &)
Minimum values of a Cmp in each domain.
Definition: cmp_math.C:458
int get_place_met(const Metric &) const
Returns the position of the pointer on metre in the array met_depend .
Definition: tensor.C:443
Tensor field of valence 1.
Definition: vector.h:188
Vectorial bases (triads) with respect to which the tensorial components are defined.
Definition: base_vect.h:105
Tbl diffrel(const Cmp &a, const Cmp &b)
Relative difference between two Cmp (norme version).
Definition: cmp_math.C:504
Tensor * p_derive_cov[N_MET_MAX]
Array of pointers on the covariant derivatives of this with respect to various metrics.
Definition: tensor.h:335
Scalar trace() const
Trace on two different type indices for a valence 2 tensor.
virtual void dec_dzpuis(int dec=1)
Decreases by dec units the value of dzpuis and changes accordingly the values in the compactified ext...
Definition: tensor.C:808
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 ).
Definition: tensor.C:1066
void operator-=(const Tensor &)
-= Tensor
Definition: tensor.C:587
Itbl type_indice
1D array of integers (class Itbl ) of size valence containing the type of each index: COV for a covar...
Definition: tensor.h:310
const Base_vect * get_triad() const
Returns the vectorial basis (triad) on which the components are defined.
Definition: tensor.h:866
virtual int position(const Itbl &ind) const
Returns the position in the array cmp of a component given by its indices.
Definition: tensor.C:525
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...
Tbl maxabs_all_domains(const Tensor &aa, int l_excluded=-1, const char *comment=0x0, ostream &ost=cout, bool verb=true)
Maximum of the absolute value of each component of a tensor over all the domains. ...
Tbl max_all_domains(const Tensor &aa, int l_excluded=-1, const char *comment=0x0, ostream &ost=cout)
Maximum value of each component of a tensor over all the domains.
int get_index_type(int i) const
Gives the type (covariant or contravariant) of the index number i .
Definition: tensor.h:886
Itbl get_index_type() const
Returns the types of all the indices.
Definition: tensor.h:896
virtual void allocate_all()
Performs the memory allocation of all the elements, down to the double arrays of the Tbl s...
Definition: tensor.C:508
Scalar ** cmp
Array of size n_comp of pointers onto the components.
Definition: tensor.h:315
Tbl max(const Cmp &)
Maximum values of a Cmp in each domain.
Definition: cmp_math.C:435
Tensor * p_derive_con[N_MET_MAX]
Array of pointers on the contravariant derivatives of this with respect to various metrics...
Definition: tensor.h:343
int id_sym1
Number of the first symmetric index (0<= id_sym1 < valence )
Definition: tensor.h:1044
Tensor handling.
Definition: tensor.h:288
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 .
Definition: tensor.C:1002
int get_valence() const
Returns the valence.
Definition: tensor.h:869
int & set_index_type(int i)
Sets the type of the index number i .
Definition: tensor.h:909
const Tensor & divergence(const Metric &gam) const
Computes the divergence of this with respect to some metric .
Definition: tensor.C:1055
virtual void del_deriv() const
Deletes the derived quantities.
Definition: tensor.C:398
virtual void inc_dzpuis(int inc=1)
Increases by inc units the value of dzpuis and changes accordingly the values in the compactified ext...
Definition: tensor.C:816
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.
Definition: tensor.C:874
virtual ~Tensor()
Destructor.
Definition: tensor.C:385
int valence
Valence of the tensor (0 = scalar, 1 = vector, etc...)
Definition: tensor.h:298
Tensor * p_divergence[N_MET_MAX]
Array of pointers on the divergence of this with respect to various metrics.
Definition: tensor.h:351
void operator+=(const Tensor &)
+= Tensor
Definition: tensor.C:571
const Tensor & derive_con(const Metric &gam) const
Returns the "contravariant" derivative of this with respect to some metric , by raising the last inde...
Definition: tensor.C:1014
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 )...
Definition: tensor.C:1079
void set_der_met_0x0(int) const
Sets all the i-th components of met_depend , p_derive_cov , etc...
Definition: tensor.C:433
const Metric * met_depend[N_MET_MAX]
Array on the Metric &#39;s which were used to compute derived quantities, like p_derive_cov ...
Definition: tensor.h:327
void annule_extern_cn(int l_0, int deg)
Performs a smooth (C^n) transition in a given domain to zero.
Definition: tensor.C:690
friend Scalar operator-(const Tensor &, const Scalar &)
Tensor - Scalar. The Tensor must be of valence 0.
friend Scalar operator+(const Tensor &, const Scalar &)
Tensor + Scalar. The Tensor must be of valence 0.
const Scalar & operator()(const Itbl &ind) const
Returns the value of a component (read-only version).
Definition: tensor.C:798
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.
Definition: tensor.C:519
virtual void set_etat_zero()
Sets the logical state of all components to ETATZERO (zero state).
Definition: tensor.C:497
Basic array class.
Definition: tbl.h:161
Symmetric tensors (with respect to two of their arguments).
Definition: tensor.h:1037
void set_der_0x0() const
Sets the pointers on derived quantities to 0x0.
Definition: tensor.C:407
const Map *const mp
Mapping on which the numerical values at the grid points are defined.
Definition: tensor.h:295
const Map & get_mp() const
Returns the mapping.
Definition: tensor.h:861
virtual void annule(int l_min, int l_max)
Sets the Tensor to zero in several domains.
Definition: tensor.C:671
virtual void std_spectral_base()
Sets the standard spectal bases of decomposition for each component.
Definition: tensor.C:926
Class intended to describe valence-2 symmetric tensors.
Definition: sym_tensor.h:223
Tbl diffrelmax(const Cmp &a, const Cmp &b)
Relative difference between two Cmp (max version).
Definition: cmp_math.C:539
virtual Itbl indices(int pos) const
Returns the indices of a component given by its position in the array cmp .
Definition: tensor.C:539
Tensor(const Map &map, int val, const Itbl &tipe, const Base_vect &triad_i)
Standard constructor.
Definition: tensor.C:202
Tensor down(int ind, const Metric &gam) const
Computes a new tensor by lowering an index of *this.