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.63 2023/08/31 08:27:26 g_servignat Exp $
38  * $Log: tensor.h,v $
39  * Revision 1.63 2023/08/31 08:27:26 g_servignat
40  * Added the possibility to filter in the r direction within the ylm filter. An order filtering of 0 means no filtering (for all 3 directions).
41  *
42  * Revision 1.62 2023/08/28 09:53:33 g_servignat
43  * Added ylm filter for Tensor and Scalar in theta + phi directions
44  *
45  * Revision 1.61 2014/10/13 08:52:37 j_novak
46  * Lorene classes and functions now belong to the namespace Lorene.
47  *
48  * Revision 1.60 2013/06/05 15:43:49 j_novak
49  * Suppression of leg_spectral_base()
50  *
51  * Revision 1.59 2013/01/11 15:44:54 j_novak
52  * Addition of Legendre bases (part 2).
53  *
54  * Revision 1.58 2008/12/05 08:44:02 j_novak
55  * New flag to control the "verbosity" of maxabs.
56  *
57  * Revision 1.57 2007/12/21 16:06:16 j_novak
58  * Methods to filter Tensor, Vector and Sym_tensor objects.
59  *
60  * Revision 1.56 2006/06/07 14:08:58 j_novak
61  * New methods set_index_type( / int).
62  *
63  * Revision 1.55 2005/10/25 08:56:34 p_grandclement
64  * addition of std_spectral_base in the case of odd functions near the origin
65  *
66  * Revision 1.54 2004/07/08 12:21:51 j_novak
67  * Replaced tensor::annule_extern_c2 with tensor::annule_extern_cn for a
68  * more general transition.
69  *
70  * Revision 1.53 2004/06/17 06:54:23 e_gourgoulhon
71  * Added method annule_extern_c2.
72  *
73  * Revision 1.52 2004/05/13 21:29:27 e_gourgoulhon
74  * Added (external) functions central_value, max_all_domains,
75  * min_all_domains and maxabs_all_domains.
76  *
77  * Revision 1.51 2004/03/24 14:53:39 j_novak
78  * Double declarations suppressed
79  *
80  * Revision 1.50 2004/03/22 13:12:43 j_novak
81  * Modification of comments to use doxygen instead of doc++
82  *
83  * Revision 1.49 2004/02/27 21:12:44 e_gourgoulhon
84  * Suppressed function contract_desal (since contract has now the
85  * boolean argument "desaliasing").
86  *
87  * Revision 1.48 2004/02/26 22:44:37 e_gourgoulhon
88  * -- constructor of Tensor from Map is now declared explicit.
89  * -- class Tensor: added methods compute_derive_lie and derive_lie
90  * -- class Tensor_sym: added methods derive_cov, derive_con and derive_lie.
91  *
92  * Revision 1.47 2004/02/19 22:08:51 e_gourgoulhon
93  * Added argument "comment" in method spectral_display,
94  * as well as in external functions min, max, maxabs, etc...
95  *
96  * Revision 1.46 2004/02/18 18:42:41 e_gourgoulhon
97  * -- Added methods trace.
98  * -- Method scontract suppressed ( since it is the same as trace(int, int) ).
99  *
100  * Revision 1.45 2004/02/18 15:52:39 e_gourgoulhon
101  * -- Added optional argument desaliasing in function contract.
102  * -- Added new function contract for double contraction.
103  *
104  * Revision 1.44 2004/02/16 10:48:06 e_gourgoulhon
105  * Added "class Tensor_sym;" at the beginning.
106  *
107  * Revision 1.43 2004/02/15 21:53:48 e_gourgoulhon
108  * Modif. comments: suppressed the mention *** under development ***.
109  *
110  * Revision 1.42 2004/01/30 12:44:17 e_gourgoulhon
111  * Added Tensor_sym operator*(const Tensor_sym&, const Tensor_sym& ).
112  *
113  * Revision 1.41 2004/01/27 13:05:10 j_novak
114  * Removed the method Tensor::mult_r_ced()
115  *
116  * Revision 1.40 2004/01/19 16:31:40 e_gourgoulhon
117  * Added operator()(int, int, int, int) and set(int, int, int, int)
118  * for direct access to components of valence 4 tensors.
119  *
120  * Revision 1.39 2004/01/15 11:09:27 f_limousin
121  * Modif in method contract_desal
122  *
123  * Revision 1.38 2004/01/15 11:00:44 f_limousin
124  * Added method contract_desal for the contraction of two tensors with desaliasing
125  *
126  * Revision 1.37 2004/01/14 11:39:00 f_limousin
127  * Added method contract for one tensor
128  *
129  * Revision 1.36 2004/01/08 09:21:39 e_gourgoulhon
130  * Added arithmetics of Tensor_sym.
131  * Added arithmetics with Scalar (to solve some ambiguities with respect
132  * to the Scalar arithmetics).
133  * Added Tensor_sym tensorial product.
134  *
135  * Revision 1.35 2004/01/04 20:47:37 e_gourgoulhon
136  * -- Introduction of new derived class Tensor_sym to store tensor with
137  * two symmetric indices
138  * -- Suppression of class Tensor_delta (now a special case of Tensor_sym).
139  *
140  * Revision 1.34 2003/12/27 14:58:01 e_gourgoulhon
141  * Improved documentation. In particular, better description of methods
142  * derive_cov(), derive_con() and divergence(), taking into account the
143  * new index convention for covariant derivatives.
144  *
145  * Revision 1.33 2003/12/05 16:41:05 f_limousin
146  * Added method operator*
147  *
148  * Revision 1.32 2003/11/06 14:43:37 e_gourgoulhon
149  * Gave a name to const arguments in certain method prototypes (e.g.
150  * constructors) to correct a bug of DOC++.
151  *
152  * Revision 1.31 2003/11/05 15:25:57 e_gourgoulhon
153  * Added declaration of external functions:
154  * max, min, maxabs, diffrel and diffrelmax.
155  *
156  * Revision 1.30 2003/11/03 10:58:00 j_novak
157  * Suppressed the constructor from a Sym_tensor.
158  *
159  * Revision 1.29 2003/10/29 11:00:42 e_gourgoulhon
160  * Virtual functions dec_dzpuis and inc_dzpuis have now an integer argument to
161  * specify by which amount dzpuis is to be increased.
162  * Accordingly virtual methods dec2_dzpuis and inc2_dzpuis have been suppressed.
163  *
164  * Revision 1.28 2003/10/28 21:21:50 e_gourgoulhon
165  * Member function Tensor::contract(int, int) renamed
166  * Tensor::scontract(int, int) in order not to mask
167  * the non-member function contract.
168  *
169  * Revision 1.27 2003/10/27 10:44:00 e_gourgoulhon
170  * Declaration of class Sym_tensor is now in file sym_tensor.h.
171  *
172  * Revision 1.26 2003/10/24 15:00:19 j_novak
173  * Forgotten Class declaration... thanks IBM aix!
174  *
175  * Revision 1.25 2003/10/20 14:26:02 j_novak
176  * New assignement operators.
177  *
178  * Revision 1.24 2003/10/20 09:32:10 j_novak
179  * Members p_potential and p_div_free of the Helmholtz decomposition
180  * + the method decompose_div(Metric).
181  *
182  * Revision 1.23 2003/10/19 19:47:31 e_gourgoulhon
183  * Introduced new virtual method spectral_display.
184  *
185  * Revision 1.22 2003/10/16 15:24:30 e_gourgoulhon
186  * Name of method annule(int ) changed to annule_domain(int ).
187  *
188  * Revision 1.21 2003/10/16 14:21:33 j_novak
189  * The calculation of the divergence of a Tensor is now possible.
190  *
191  * Revision 1.20 2003/10/13 13:52:39 j_novak
192  * Better managment of derived quantities.
193  *
194  * Revision 1.19 2003/10/08 14:24:08 j_novak
195  * replaced mult_r_zec with mult_r_ced
196  *
197  * Revision 1.18 2003/10/06 20:48:23 e_gourgoulhon
198  * Added methods down and up_down.
199  *
200  * Revision 1.17 2003/10/06 16:17:29 j_novak
201  * Calculation of contravariant derivative and Ricci scalar.
202  *
203  * Revision 1.16 2003/10/06 15:12:56 e_gourgoulhon
204  * Added tensor contraction and raising of index.
205  *
206  * Revision 1.15 2003/10/06 13:58:45 j_novak
207  * The memory management has been improved.
208  * Implementation of the covariant derivative with respect to the exact Tensor
209  * type.
210  *
211  * Revision 1.14 2003/10/05 21:07:27 e_gourgoulhon
212  * Method std_spectral_base() is now virtual.
213  *
214  * Revision 1.13 2003/10/03 11:21:45 j_novak
215  * More methods for the class Metric
216  *
217  * Revision 1.12 2003/10/02 15:45:48 j_novak
218  * New class Metric
219  *
220  * Revision 1.11 2003/10/01 15:41:14 e_gourgoulhon
221  * class name Delta changed to Tensor_delta.
222  *
223  * Revision 1.10 2003/10/01 13:03:52 e_gourgoulhon
224  * The method get_mp() returns now a reference (and not a pointer)
225  * onto a mapping.
226  *
227  * Revision 1.9 2003/09/29 13:48:17 j_novak
228  * New class Delta.
229  *
230  * Revision 1.8 2003/09/26 14:33:51 j_novak
231  * Arithmetic functions for the class Tensor
232  *
233  * Revision 1.7 2003/09/26 08:05:29 j_novak
234  * New class Vector.
235  *
236  * Revision 1.6 2003/09/25 21:01:50 e_gourgoulhon
237  * Improved comments.
238  *
239  * Revision 1.5 2003/09/25 13:37:38 j_novak
240  * Symmetric tensors of valence 2 are now implemented (not tested yet).
241  *
242  * Revision 1.4 2003/09/24 15:10:54 j_novak
243  * Suppression of the etat flag in class Tensor (still present in Scalar)
244  *
245  * Revision 1.3 2003/09/24 08:46:31 j_novak
246  * Added tensor.h and scalar.h to the documentation
247  *
248  * Revision 1.2 2003/09/23 08:53:11 e_gourgoulhon
249  * not ready yet
250  *
251  * Revision 1.1 2003/09/22 12:50:47 e_gourgoulhon
252  * First version: not ready yet!
253  *
254  *
255  * $Header: /cvsroot/Lorene/C++/Include/tensor.h,v 1.63 2023/08/31 08:27:26 g_servignat Exp $
256  *
257  */
258 
259 #define COV -1
260 #define CON +1
261 
262 #define N_MET_MAX 5
263 
264 // Headers Lorene
265 #include "itbl.h"
266 #include "base_vect.h"
267 #include "map.h"
268 
269 namespace Lorene {
270 class Scalar ;
271 class Vector ;
272 class Tensor_sym ;
273 class Sym_tensor ;
274 class Metric ;
275 
276  //-------------------------//
277  // class Tensor //
278  //-------------------------//
279 
280 
294 class Tensor {
295 
296  // Data :
297  // -----
298  protected:
299 
301  const Map* const mp ;
302 
304  int valence ;
305 
309  const Base_vect* triad ;
310 
317 
318  int n_comp ;
319 
321  Scalar** cmp ;
322 
323 
324  // Derived data :
325  // ------------
326  protected:
333  mutable const Metric* met_depend[N_MET_MAX] ;
334 
341  mutable Tensor* p_derive_cov[N_MET_MAX];
342 
349  mutable Tensor* p_derive_con[N_MET_MAX];
350 
357  mutable Tensor* p_divergence[N_MET_MAX];
358 
359 
360  // Constructors - Destructor :
361  // -------------------------
362 
363  public:
364 
380  Tensor(const Map& map, int val, const Itbl& tipe,
381  const Base_vect& triad_i) ;
382 
399  Tensor(const Map& map, int val, const Itbl& tipe,
400  const Base_vect* triad_i) ;
401 
411  Tensor(const Map& map, int val, int tipe,
412  const Base_vect& triad_i) ;
413 
414  Tensor(const Tensor&) ;
415 
426  Tensor(const Map& map, const Base_vect& triad_i, FILE* fich) ;
427 
428  protected:
434  explicit Tensor(const Map& map) ;
435 
457  Tensor(const Map& map, int val, const Itbl& tipe, int n_comp_i,
458  const Base_vect& triad_i) ;
459 
474  Tensor(const Map& map, int val, int tipe, int n_comp_i,
475  const Base_vect& triad_i) ;
476 
477 
478  public:
479 
480  virtual ~Tensor() ;
481 
482  // Memory management
483  // -----------------
484  protected:
485  virtual void del_deriv() const ;
486 
488  void set_der_0x0() const ;
489 
494  virtual void del_derive_met(int) const ;
495 
500  void set_der_met_0x0(int) const ;
501 
511  void set_dependance (const Metric&) const ;
512 
518  int get_place_met(const Metric&) const ;
519 
520  // Mutators / assignment
521  // ---------------------
522  public:
527  virtual void set_etat_nondef() ;
528 
533  virtual void set_etat_zero() ;
534 
539  virtual void set_etat_qcq() ;
540 
549  virtual void allocate_all() ;
550 
554  virtual void change_triad(const Base_vect& new_triad) ;
555 
562  void set_triad(const Base_vect& new_triad) ;
563 
564 
565  virtual void operator=(const Tensor&) ;
566 
578  Scalar& set(const Itbl& ind) ;
579 
589  Scalar& set(int i1, int i2) ;
590 
591 
602  Scalar& set(int i1, int i2, int i3) ;
603 
616  Scalar& set(int i1, int i2, int i3, int i4) ;
617 
623  void annule_domain(int l) ;
624 
636  virtual void annule(int l_min, int l_max) ;
637 
649  void annule_extern_cn(int l_0, int deg) ;
650 
655  virtual void std_spectral_base() ;
656 
661  virtual void std_spectral_base_odd() ;
662 
667  virtual void dec_dzpuis(int dec = 1) ;
668 
673  virtual void inc_dzpuis(int inc = 1) ;
674 
679  virtual void exponential_filter_r(int lzmin, int lzmax, int p,
680  double alpha= -16.) ;
681 
686  virtual void exponential_filter_ylm(int lzmin, int lzmax, int p,
687  double alpha= -16.) ;
688 
693  virtual void exponential_filter_ylm_phi(int lzmin, int lzmax, int p_r, int p_tet, int p_phi,
694  double alpha= -16.) ;
695 
696  // Computational methods
697  // ---------------------
698 
699  protected:
704  void compute_derive_lie(const Vector& v, Tensor& resu) const ;
705 
706 
707  public:
730  const Tensor& derive_cov(const Metric& gam) const ;
731 
737  const Tensor& derive_con(const Metric& gam) const ;
738 
756  const Tensor& divergence(const Metric& gam) const ;
757 
758 
762  Tensor derive_lie(const Vector& v) const ;
763 
776  Tensor up(int ind, const Metric& gam) const ;
777 
790  Tensor down(int ind, const Metric& gam) const ;
791 
799  Tensor up_down(const Metric& gam) const ;
800 
809  Tensor trace(int ind1, int ind2) const ;
810 
821  Tensor trace(int ind1, int ind2, const Metric& gam) const ;
822 
825  Scalar trace() const ;
826 
831  Scalar trace(const Metric& gam) const ;
832 
833 
834  // Accessors
835  // ---------
836  public:
852  virtual int position(const Itbl& ind) const ;
853 
870  virtual Itbl indices(int pos) const ;
871 
872  public:
874  const Map& get_mp() const {return *mp ;} ;
875 
879  const Base_vect* get_triad() const {return triad;} ;
880 
882  int get_valence() const {return valence ; } ;
883 
885  int get_n_comp() const {return n_comp ;} ;
886 
899  int get_index_type(int i) const {return type_indice(i) ;};
900 
909  Itbl get_index_type() const {return type_indice ; } ;
910 
922  int& set_index_type(int i) {return type_indice.set(i) ;};
923 
931  Itbl& set_index_type() {return type_indice ; } ;
932 
933 
945  const Scalar& operator()(const Itbl& ind) const ;
946 
956  const Scalar& operator()(int i1, int i2) const ;
957 
968  const Scalar& operator()(int i1, int i2, int i3) const ;
969 
981  const Scalar& operator()(int i1, int i2, int i3, int i4) const ;
982 
983  // Member arithmetics
984  // ------------------
985  public:
986  void operator+=(const Tensor &) ;
987  void operator-=(const Tensor &) ;
988 
989  // Outputs
990  // -------
991  public:
992  virtual void sauve(FILE *) const ;
993 
1004  virtual void spectral_display(const char* comment = 0x0,
1005  double threshold = 1.e-7, int precision = 4,
1006  ostream& ostr = cout) const ;
1007 
1008  friend ostream& operator<<(ostream& , const Tensor & ) ;
1009 
1010 
1011  // Friend classes
1012  // ---------------
1013  friend class Scalar ;
1014  friend class Vector ;
1015  friend class Sym_tensor ;
1016  friend class Tensor_sym ;
1017  friend class Metric ;
1018 
1019  // Mathematical operators
1020  // ----------------------
1021 
1022  friend Scalar operator+(const Tensor&, const Scalar&) ;
1023  friend Scalar operator+(const Scalar&, const Tensor&) ;
1024  friend Scalar operator-(const Tensor&, const Scalar&) ;
1025  friend Scalar operator-(const Scalar&, const Tensor&) ;
1026  friend Tensor operator*(const Tensor&, const Tensor&) ;
1027  friend Tensor_sym operator*(const Tensor&, const Tensor_sym&) ;
1028  friend Tensor_sym operator*(const Tensor_sym&, const Tensor&) ;
1029  friend Tensor_sym operator*(const Tensor_sym&, const Tensor_sym&) ;
1030 
1031 };
1032 
1033 
1034 
1035  //-------------------------//
1036  // class Tensor_sym //
1037  //-------------------------//
1038 
1050 class Tensor_sym : public Tensor {
1051 
1052  // Data :
1053  // -----
1054  protected:
1055 
1057  int id_sym1 ;
1058 
1062  int id_sym2 ;
1063 
1064 
1065  // Constructors - Destructor :
1066  // -------------------------
1067 
1068  public:
1069 
1089  Tensor_sym(const Map& map, int val, const Itbl& tipe,
1090  const Base_vect& triad_i, int index_sym1,
1091  int index_sym2) ;
1092 
1106  Tensor_sym(const Map& map, int val, int tipe, const Base_vect& triad_i,
1107  int index_sym1, int index_sym2) ;
1108 
1122  Tensor_sym(const Map& map, int tipe0, int tipe1, int tipe2,
1123  const Base_vect& triad_i,
1124  int index_sym1, int index_sym2) ;
1125 
1126  Tensor_sym(const Tensor_sym& a) ;
1127 
1138  Tensor_sym(const Map& map, const Base_vect& triad_i, FILE* fich) ;
1139 
1140  public:
1141 
1142  virtual ~Tensor_sym() ;
1143 
1144  // Mutators / assignment
1145  // ---------------------
1146  public:
1147 
1149  virtual void operator=(const Tensor_sym& a) ;
1150 
1155  virtual void operator=(const Tensor& a) ;
1156 
1157 
1158  // Accessors
1159  // ---------
1160  public:
1162  int sym_index1() const {return id_sym1;} ;
1163 
1167  int sym_index2() const {return id_sym2;} ;
1168 
1184  virtual int position(const Itbl& ind) const ;
1185 
1202  virtual Itbl indices(int pos) const ;
1203 
1204 
1205  // Outputs
1206  // -------
1207  public:
1208  virtual void sauve(FILE *) const ;
1209 
1210 
1211  // Tensor calculus
1212  // ---------------
1213  public:
1214 
1229  const Tensor_sym& derive_cov(const Metric& gam) const ;
1230 
1236  const Tensor_sym& derive_con(const Metric& gam) const ;
1237 
1241  Tensor_sym derive_lie(const Vector& v) const ;
1242 
1243 
1244  // Mathematical operators
1245  // ----------------------
1246 
1247  friend Tensor_sym operator*(const Tensor&, const Tensor_sym&) ;
1248  friend Tensor_sym operator*(const Tensor_sym&, const Tensor&) ;
1249 
1250 };
1251 
1252 
1253 
1260 Tensor operator*(const Tensor& a, const Tensor& b) ;
1262 
1264 Tensor_sym operator*(const Tensor& a, const Tensor_sym& b) ;
1265 
1267 Tensor_sym operator*(const Tensor_sym& a, const Tensor& b) ;
1268 
1277 Tensor_sym operator*(const Tensor_sym& a, const Tensor_sym& b) ;
1278 
1279 
1299 Tensor contract(const Tensor& t1, int ind1, const Tensor& t2, int ind2,
1300  bool desaliasing = false) ;
1301 
1328 Tensor contract(const Tensor& t1, int ind_i1, int ind_j1,
1329  const Tensor& t2, int ind_i2, int ind_j2,
1330  bool desaliasing = false) ;
1331 
1332 
1348 Tensor contract(const Tensor& t1, int ind1, int ind2) ;
1349 
1350 
1362 Tbl max(const Tensor& aa, const char* comment = 0x0, ostream& ost = cout) ;
1363 
1364 
1376 Tbl min(const Tensor& aa, const char* comment = 0x0, ostream& ost = cout) ;
1377 
1389 Tbl maxabs(const Tensor& aa, const char* comment = 0x0, ostream& ost = cout,
1390  bool verb = true) ;
1391 
1392 
1407 Tbl diffrel(const Tensor& aa, const Tensor& bb, const char* comment = 0x0,
1408  ostream& ost = cout) ;
1409 
1424 Tbl diffrelmax(const Tensor& aa, const Tensor& bb, const char* comment = 0x0,
1425  ostream& ost = cout) ;
1426 
1437 Tbl central_value(const Tensor& aa, const char* comment = 0x0, ostream& ost = cout) ;
1438 
1451 Tbl max_all_domains(const Tensor& aa, int l_excluded = -1, const char* comment = 0x0,
1452  ostream& ost = cout) ;
1453 
1454 
1467 Tbl min_all_domains(const Tensor& aa, int l_excluded = -1, const char* comment = 0x0,
1468  ostream& ost = cout) ;
1469 
1482 Tbl maxabs_all_domains(const Tensor& aa, int l_excluded = -1, const char* comment = 0x0,
1483  ostream& ost = cout, bool verb = true) ;
1484 
1485 
1486 
1496 Tensor operator+(const Tensor& ) ;
1497 Tensor operator-(const Tensor& ) ;
1498 Tensor operator+(const Tensor& a, const Tensor& b) ;
1499 
1501 Scalar operator+(const Tensor& a, const Scalar& b) ;
1502 
1504 Scalar operator+(const Scalar& a, const Tensor& b) ;
1505 
1506 Tensor operator-(const Tensor& a, const Tensor& b) ;
1507 
1509 Scalar operator-(const Tensor& a, const Scalar& b) ;
1510 
1512 Scalar operator-(const Scalar& a, const Tensor& b) ;
1513 
1514 Tensor operator*(const Scalar& a , const Tensor& b) ;
1515 Tensor operator*(const Tensor& a, const Scalar& b) ;
1516 Tensor operator*(double , const Tensor&) ;
1517 Tensor operator* (const Tensor&, double) ;
1518 Tensor operator*(int, const Tensor &) ;
1519 Tensor operator*(const Tensor&, int) ;
1520 Tensor operator/(const Tensor&, const Scalar&) ;
1521 Tensor operator/(const Tensor&, double) ;
1522 Tensor operator/(const Tensor&, int) ;
1523 
1525 
1533 Tensor_sym operator+(const Tensor_sym&) ;
1534 
1538 Tensor_sym operator-(const Tensor_sym&) ;
1539 
1544 Tensor_sym operator+(const Tensor_sym&, const Tensor_sym&) ;
1545 
1550 Tensor_sym operator-(const Tensor_sym&, const Tensor_sym&) ;
1551 
1555 Tensor_sym operator*(const Scalar& a, const Tensor_sym& b) ;
1556 
1560 Tensor_sym operator*(const Tensor_sym& a, const Scalar& b) ;
1561 
1565 Tensor_sym operator*(double, const Tensor_sym&) ;
1566 
1570 Tensor_sym operator*(const Tensor_sym&, double) ;
1571 
1575 Tensor_sym operator*(int, const Tensor_sym&) ;
1576 
1580 Tensor_sym operator*(const Tensor_sym&, int) ;
1581 
1585 Tensor_sym operator/(const Tensor_sym&, const Scalar&) ;
1586 
1590 Tensor_sym operator/(const Tensor_sym&, double) ;
1591 
1595 Tensor_sym operator/(const Tensor_sym&, int) ;
1596 
1599 }
1600 #include "scalar.h"
1601 
1602 #include "vector.h"
1603 
1604 #include "sym_tensor.h"
1605 
1606 
1607 #endif
friend Tensor_sym operator*(const Tensor &, const Tensor_sym &)
Tensorial product with symmetries.
void annule_domain(int l)
Sets the Tensor to zero in a given domain.
Definition: tensor.C:675
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:490
virtual void sauve(FILE *) const
Save in a binary file.
Definition: tensor_sym.C:375
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:562
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:318
virtual void operator=(const Tensor_sym &a)
Assignment to another Tensor_sym.
Definition: tensor_sym.C:201
int sym_index1() const
Number of the first symmetric index (0<= id_sym1 < valence )
Definition: tensor.h:1162
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:423
Lorene prototypes.
Definition: app_hor.h:67
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:462
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:931
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:393
virtual void set_etat_nondef()
Sets the logical state of all components to ETATNONDEF (undefined state).
Definition: tensor.C:498
Base_val operator*(const Base_val &, const Base_val &)
This operator is used when calling multiplication or division of Valeur .
int id_sym2
Number of the second symmetric index (id_sym1 < id_sym2 < valence )
Definition: tensor.h:1062
Base class for coordinate mappings.
Definition: map.h:688
int get_n_comp() const
Returns the number of stored components.
Definition: tensor.h:885
virtual Itbl indices(int pos) const
Returns the indices of a component given by its position in the array cmp .
Definition: tensor_sym.C:313
Tensor up_down(const Metric &gam) const
Computes a new tensor by raising or lowering all the indices of *this .
const Tensor_sym & derive_con(const Metric &gam) const
Returns the "contravariant" derivative of this with respect to some metric , by raising the last inde...
int sym_index2() const
Number of the second symmetric index (id_sym1 < id_sym2 < valence )
Definition: tensor.h:1167
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:309
virtual void sauve(FILE *) const
Save in a binary file.
Definition: tensor.C:915
virtual void std_spectral_base_odd()
Sets the standard odd spectal bases of decomposition for each component.
Definition: tensor.C:991
Cmp operator/(const Cmp &, const Cmp &)
Cmp / Cmp.
Definition: cmp_arithm.C:460
Tbl min(const Cmp &)
Minimum values of a Cmp in each domain.
Definition: cmp_math.C:461
Tensor_sym(const Map &map, int val, const Itbl &tipe, const Base_vect &triad_i, int index_sym1, int index_sym2)
Standard constructor.
Definition: tensor_sym.C:72
int get_place_met(const Metric &) const
Returns the position of the pointer on metre in the array met_depend .
Definition: tensor.C:452
Tensor field of valence 1.
Definition: vector.h:188
const Tensor_sym & derive_cov(const Metric &gam) const
Returns the covariant derivative of this with respect to some metric .
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:507
virtual void exponential_filter_ylm_phi(int lzmin, int lzmax, int p_r, int p_tet, int p_phi, double alpha=-16.)
Applies exponential filters to all components (see Scalar::exponential_filter_ylm_phi )...
Definition: tensor.C:1101
Tensor * p_derive_cov[N_MET_MAX]
Array of pointers on the covariant derivatives of this with respect to various metrics.
Definition: tensor.h:341
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:817
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:1075
void operator-=(const Tensor &)
-= Tensor
Definition: tensor.C:596
Itbl type_indice
1D array of integers (class Itbl ) of size valence containing the type of each index: COV for a cova...
Definition: tensor.h:316
const Base_vect * get_triad() const
Returns the vectorial basis (triad) on which the components are defined.
Definition: tensor.h:879
virtual int position(const Itbl &ind) const
Returns the position in the array cmp of a component given by its indices.
Definition: tensor.C:534
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. ...
Cmp operator+(const Cmp &)
Definition: cmp_arithm.C:107
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:899
Itbl get_index_type() const
Returns the types of all the indices.
Definition: tensor.h:909
virtual void allocate_all()
Performs the memory allocation of all the elements, down to the double arrays of the Tbl s...
Definition: tensor.C:517
Scalar ** cmp
Array of size n_comp of pointers onto the components.
Definition: tensor.h:321
Tbl max(const Cmp &)
Maximum values of a Cmp in each domain.
Definition: cmp_math.C:438
virtual ~Tensor_sym()
Destructor.
Definition: tensor_sym.C:192
Tensor * p_derive_con[N_MET_MAX]
Array of pointers on the contravariant derivatives of this with respect to various metrics...
Definition: tensor.h:349
int id_sym1
Number of the first symmetric index (0<= id_sym1 < valence )
Definition: tensor.h:1057
Tensor handling.
Definition: tensor.h:294
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:1011
int get_valence() const
Returns the valence.
Definition: tensor.h:882
int & set_index_type(int i)
Sets the type of the index number i .
Definition: tensor.h:922
const Tensor & divergence(const Metric &gam) const
Computes the divergence of this with respect to some metric .
Definition: tensor.C:1064
virtual void del_deriv() const
Deletes the derived quantities.
Definition: tensor.C:407
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:825
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:883
virtual ~Tensor()
Destructor.
Definition: tensor.C:394
int valence
Valence of the tensor (0 = scalar, 1 = vector, etc...)
Definition: tensor.h:304
Tensor * p_divergence[N_MET_MAX]
Array of pointers on the divergence of this with respect to various metrics.
Definition: tensor.h:357
void operator+=(const Tensor &)
+= Tensor
Definition: tensor.C:580
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:1023
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:1088
void set_der_met_0x0(int) const
Sets all the i-th components of met_depend , p_derive_cov , etc...
Definition: tensor.C:442
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:333
void annule_extern_cn(int l_0, int deg)
Performs a smooth (C^n) transition in a given domain to zero.
Definition: tensor.C:699
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.
virtual int position(const Itbl &ind) const
Returns the position in the array cmp of a component given by its indices.
Definition: tensor_sym.C:248
const Scalar & operator()(const Itbl &ind) const
Returns the value of a component (read-only version).
Definition: tensor.C:807
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:528
Cmp operator-(const Cmp &)
- Cmp
Definition: cmp_arithm.C:111
virtual void set_etat_zero()
Sets the logical state of all components to ETATZERO (zero state).
Definition: tensor.C:506
Symmetric tensors (with respect to two of their arguments).
Definition: tensor.h:1050
void set_der_0x0() const
Sets the pointers on derived quantities to 0x0.
Definition: tensor.C:416
Tensor_sym derive_lie(const Vector &v) const
Computes the Lie derivative of this with respect to some vector field v.
const Map *const mp
Mapping on which the numerical values at the grid points are defined.
Definition: tensor.h:301
const Map & get_mp() const
Returns the mapping.
Definition: tensor.h:874
virtual void annule(int l_min, int l_max)
Sets the Tensor to zero in several domains.
Definition: tensor.C:680
virtual void std_spectral_base()
Sets the standard spectal bases of decomposition for each component.
Definition: tensor.C:935
Class intended to describe valence-2 symmetric tensors.
Definition: sym_tensor.h:226
Tbl diffrelmax(const Cmp &a, const Cmp &b)
Relative difference between two Cmp (max version).
Definition: cmp_math.C:542
virtual Itbl indices(int pos) const
Returns the indices of a component given by its position in the array cmp .
Definition: tensor.C:548
Tensor(const Map &map, int val, const Itbl &tipe, const Base_vect &triad_i)
Standard constructor.
Definition: tensor.C:211
Tensor down(int ind, const Metric &gam) const
Computes a new tensor by lowering an index of *this.