Debian Codegraph @

C++/Include/tenseur.h

raw symbols SCIP
1 /*
2 * Definition of Lorene classes Tenseur
3 * Tenseur_sym
4 *
5 */
6
7 /*
8 * Copyright (c) 1999-2001 Philippe Grandclement
9 * Copyright (c) 2000-2001 Eric Gourgoulhon
10 * Copyright (c) 2002 Jerome Novak
11 *
12 * This file is part of LORENE.
13 *
14 * LORENE is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * LORENE is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with LORENE; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 *
28 */
29
30
31 #ifndef __TENSEUR_H_
32 #define __TENSEUR_H_
33
34
35 /*
36 * $Id: tenseur.h,v 1.19 2016/09/19 15:26:22 j_novak Exp $
37 * $Log: tenseur.h,v $
38 * Revision 1.19 2016/09/19 15:26:22 j_novak
39 * Correction of several bugs preventing the shared library compilation.
40 *
41 * Revision 1.18 2014/10/13 08:52:37 j_novak
42 * Lorene classes and functions now belong to the namespace Lorene.
43 *
44 * Revision 1.17 2010/02/02 13:34:12 e_gourgoulhon
45 * Marked DEPRECATED (in the documentation).
46 *
47 * Revision 1.16 2005/08/30 08:35:10 p_grandclement
48 * Addition of the Tau version of the vectorial Poisson equation for the Tensors
49 *
50 * Revision 1.15 2004/12/29 16:24:03 k_taniguchi
51 * Addition of the method for vectorial Poisson equations with a multipole
52 * falloff condition at the outer boundary.
53 *
54 * Revision 1.14 2004/12/22 18:25:12 k_taniguchi
55 * Change an argument of poisson_vect_falloff
56 *
57 * Revision 1.13 2004/11/30 20:43:32 k_taniguchi
58 * Addition of the method for vectorial Poisson equations with falloff
59 * condition at the outer boundary.
60 *
61 * Revision 1.12 2004/03/22 13:12:43 j_novak
62 * Modification of comments to use doxygen instead of doc++
63 *
64 * Revision 1.11 2003/11/06 12:17:31 r_prix
65 * fixed mini-bug in documentation: without explicit argument in function-prototype,
66 * doc++ seemed to merge docu of Tensor::operator=(Cmp&) and operator=(Tenseur&)
67 *
68 * Revision 1.10 2003/06/20 14:23:38 f_limousin
69 * Add the functions compare().
70 *
71 * Revision 1.9 2002/10/16 14:36:29 j_novak
72 * Reorganization of #include instructions of standard C++, in order to
73 * use experimental version 3 of gcc.
74 *
75 * Revision 1.8 2002/09/19 14:12:37 e_gourgoulhon
76 * Modif documentation for LaTeX compliance.
77 *
78 * Revision 1.7 2002/09/10 13:44:17 j_novak
79 * The method "manipule" of one indice has been removed for Tenseur_sym objects
80 * (the result cannot be a Tenseur_sym).
81 * The method "sans_trace" now computes the traceless part of a Tenseur (or
82 * Tenseur_sym) of valence 2.
83 *
84 * Revision 1.6 2002/09/06 14:49:25 j_novak
85 * Added method lie_derive for Tenseur and Tenseur_sym.
86 * Corrected various errors for derive_cov and arithmetic.
87 *
88 * Revision 1.5 2002/08/14 13:46:14 j_novak
89 * Derived quantities of a Tenseur can now depend on several Metrique's
90 *
91 * Revision 1.4 2002/08/08 15:10:44 j_novak
92 * The flag "plat" has been added to the class Metrique to show flat metrics.
93 *
94 * Revision 1.3 2002/08/07 16:14:11 j_novak
95 * class Tenseur can now also handle tensor densities, this should be transparent to older codes
96 *
97 * Revision 1.2 2002/06/17 14:05:17 j_novak
98 * friend functions are now also declared outside the class definition
99 *
100 * Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon
101 * LORENE
102 *
103 * Revision 2.46 2001/08/27 10:03:56 eric
104 * Ajout de l'operator% (produit tensoriel avec desaliasing)
105 *
106 * Revision 2.45 2001/06/19 15:38:00 eric
107 * Modif commentaires: mise en conformite Doc++ 3.4.8.
108 *
109 * Revision 2.44 2001/06/18 13:56:07 novak
110 * Ajout de la fonction abs()
111 *
112 * Revision 2.43 2001/05/29 16:10:43 eric
113 * Modif commentaires (mise en conformite Doc++ 3.4.7).
114 *
115 * Revision 2.42 2001/05/26 15:48:17 eric
116 * *** empty log message ***
117 *
118 * Revision 2.41 2001/05/26 15:42:54 eric
119 * Ajout de la fonction flat_scalar_prod_desal (desaliasage)
120 *
121 * Revision 2.40 2000/10/19 10:37:51 phil
122 * *** empty log message ***
123 *
124 * Revision 2.39 2000/10/19 09:47:15 phil
125 * *** empty log message ***
126 *
127 * Revision 2.38 2000/10/19 09:41:48 phil
128 * ajout de inverse_poisson_vect
129 *
130 * Revision 2.37 2000/10/06 12:37:09 keisuke
131 * Add a vectorial Poisson equation Tenseur::poisson_vect_regu.
132 *
133 * Revision 2.36 2000/09/27 08:52:34 eric
134 * Modif commentaires.
135 *
136 * Revision 2.35 2000/09/13 12:21:36 eric
137 * Modif commentaires.
138 *
139 * Revision 2.34 2000/09/13 12:11:26 eric
140 * Ajout de la fonction allocate_all().
141 *
142 * Revision 2.33 2000/05/22 14:39:11 phil
143 * ajout de inc_dzpuis et dec_dzpuis
144 *
145 * Revision 2.32 2000/04/03 15:18:54 phil
146 * suppression de poisson_vect_dirichlet
147 *
148 * Revision 2.31 2000/03/31 13:29:43 phil
149 * poisson_vect_neumann devient poisson_vect_dirichlet
150 *
151 * Revision 2.30 2000/03/30 16:10:46 phil
152 * *** empty log message ***
153 *
154 * Revision 2.29 2000/02/18 10:45:05 eric
155 * Modif commentaires.
156 *
157 * Revision 2.28 2000/02/11 19:11:55 phil
158 * commentaires
159 *
160 * Revision 2.27 2000/02/10 16:26:48 eric
161 * Modif commentaires.
162 *
163 * Revision 2.26 2000/02/10 16:10:49 eric
164 * Ajout de la fonction change_triad.
165 *
166 * Revision 2.25 2000/02/09 19:29:25 eric
167 * MODIF IMPORTANTE: la triade de decomposition est desormais passee en
168 * argument des constructeurs.
169 *
170 * Revision 2.24 2000/02/09 09:53:56 phil
171 * ajout de poisson_vect_oohara
172 * ,
173 *
174 * Revision 2.23 2000/02/08 19:04:25 eric
175 * Les fonctions arithmetiques ne sont plus amies.
176 * Ajout de nouvelles fonctions arithmetiques.
177 *
178 * Revision 2.22 2000/02/01 15:40:19 eric
179 * Ajout de la fonction sqrt
180 *
181 * Revision 2.21 2000/02/01 14:13:56 eric
182 * Modif commentaires.
183 * Ajout de la fonction amie flat_scalar_prod.
184 *
185 * Revision 2.20 2000/01/21 12:48:55 phil
186 * changement prototypage de Tenseur::poisson_vect
187 *
188 * Revision 2.19 2000/01/20 16:02:20 eric
189 * Ajout des operator=(double ) et operator=(int ).
190 *
191 * Revision 2.18 2000/01/20 14:52:08 phil
192 * *** empty log message ***
193 *
194 * Revision 2.17 2000/01/20 14:50:56 phil
195 * *** empty log message ***
196 *
197 * Revision 2.16 2000/01/20 14:39:31 phil
198 * *** empty log message ***
199 *
200 * Revision 2.15 2000/01/20 13:10:56 phil
201 * Ajout de Tenseur::poisson_vect (double)
202 *
203 * Revision 2.14 2000/01/20 11:20:17 phil
204 * changement prototypage
205 *
206 * Revision 2.13 2000/01/20 10:31:30 phil
207 * ajout de xksk
208 *
209 * Revision 2.12 2000/01/14 14:17:47 eric
210 * Modif commentaires.
211 *
212 * Revision 2.11 2000/01/14 14:04:07 eric
213 * Ajout de la fonction annule.
214 * classe Tenseur: constructeurs pour les classes derivees et fonctions
215 * de gestion memoire (del_t(), ...) declarees protected et non plus
216 * private.
217 *
218 * Revision 2.10 2000/01/13 14:15:30 eric
219 * Modif commentaires.
220 *
221 * Revision 2.9 2000/01/13 14:10:18 eric
222 * Ajout du constructeur par copie d'un Cmp (pour un scalaire)
223 * ainsi que l'affectation a un Cmp.
224 *
225 * Revision 2.8 2000/01/13 13:45:56 eric
226 * Ajout du membre p_gradient_spher et des fonctions fait_gradient_spher(),
227 * gradient_spher() pour le calcul du gradient d'un scalaire en
228 * coordonnees spheriques sur la triade spherique associee.
229 *
230 * Revision 2.7 2000/01/12 13:17:49 eric
231 * Les operator::(...) renvoie desormais une reference const sur le c[...]
232 * correspondant et non plus un Cmp copie de c[...].
233 * (ceci grace a Map::cmp_zero()).
234 *
235 * Revision 2.6 2000/01/11 11:13:16 eric
236 * Changement de nom pour la base vectorielle : base --> triad
237 *
238 * Revision 2.5 2000/01/10 17:22:26 eric
239 * Modif des #include
240 *
241 * Revision 2.4 2000/01/10 15:14:58 eric
242 * Ajout du membre base (base vectorielle sur laquelle sont definies
243 * les composantes).
244 *
245 * Revision 2.3 1999/12/09 12:39:39 phil
246 * changement prototypage des derivees
247 *
248 * Revision 2.2 1999/12/07 15:24:17 phil
249 * ajout include
250 *
251 * Revision 2.1 1999/12/03 09:37:11 phil
252 * *** empty log message ***
253 *
254 * Revision 2.0 1999/12/02 17:15:32 phil
255 * *** empty log message ***
256 *
257 * Revision 1.1 1999/12/02 17:13:29 phil
258 * Initial revision
259 *
260 *
261 * $Header: /cvsroot/Lorene/C++/Include/tenseur.h,v 1.19 2016/09/19 15:26:22 j_novak Exp $
262 *
263 */
264
265 #define COV -1
266 #define CON +1
267
268 #define N_MET_MAX 5
269
270 // Headers Lorene
271 #include "cmp.h"
272 #include "itbl.h"
273 #include "base_vect.h"
274
275 namespace Lorene {
276 class Metrique ;
277 class Tenseur_sym ;
278
279 //---------------------------------//
280 // class Tenseur //
281 //---------------------------------//
282
283
284 /**
285 * Tensor handling *** DEPRECATED : use class \c Tensor instead ***. \ingroup (otens)
286 *
287 * This class is intended to store the components of a tensorial field in
288 * a specific basis. \a Tensor \a densities can also be stored. A tensor
289 * density \f$\tau^{i_1\ldots i_p}_{j_1\ldots j_q}\f$ is defined by:
290 * \f$ \tau^{i_1\ldots i_p}_{j_1\ldots j_q} = \gamma^{\frac{n}{2}}
291 * T^{i_1\ldots i_p}_{j_1\ldots j_q}\f$ where \e T is a \e q -covariant
292 * \e p -contravariant tensor and \f$\gamma\f$ is the determinant of the
293 * used 3-metric. \e n is called the weight of the tensor density.
294 *
295 * All this is \b 3D meaning that the indices go from 0 to 2. Moreover,
296 * the components are described in orthonormal bases.
297 *
298 * When first constructed, the memory for each component is not allocated.
299 *
300 */
301 class Tenseur {
302
303 // Data :
304 // -----
305 protected:
306 const Map* const mp ; ///< Reference mapping
307 int valence ; ///< Valence
308
309 /** Vectorial basis (triad) with respect to which the tensor
310 * components are defined.
311 */
312 const Base_vect* triad ;
313
314 /** Array of size \c valence contening the type of each index,
315 * \c COV for a covariant one and \c CON for a contravariant one.
316 *
317 */
318 Itbl type_indice ;
319
320 int n_comp ; ///< Number of components, depending on the symmetry.
321 int etat ; ///< Logical state \c ETATZERO , \c ETATQCQ or \c ETATNONDEF
322 Cmp** c ; ///< The components.
323 double poids ; ///< For tensor densities: the weight
324 /// For tensor densities: the metric defining the conformal factor
325 const Metrique* metric ;
326
327 // Derived data :
328 // ------------
329 protected:
330 /** Array of pointers on the \c Metrique 's used to calculate
331 * derivatives members. If no such member has been calculated
332 * the pointer is set to zero. The array has the size
333 * \c N_MET_MAX abd the i-th corresponds to the i-th ones
334 * in \c p_derive_cov and p_derive_con.
335 *
336 */
337 const Metrique** met_depend ;
338
339 /** Pointer on the gradient of \c *this .
340 * It is set to zero if it has not been calculated yet.
341 *
342 */
343 mutable Tenseur* p_gradient ;
344
345 /** Pointer on the gradient of \c *this in a spherical orthonormal
346 * basis (scalar field only).
347 * It is set to zero if it has not been calculated yet.
348 *
349 */
350 mutable Tenseur* p_gradient_spher ;
351
352 /** Array of pointers on the covariant derivatives of \c *this
353 * with respect to the corresponding metric in \c *met_depend .
354 * It is set to zero if it has not been calculated yet, or
355 * for a scalar field.
356 *
357 */
358 Tenseur** p_derive_cov ;
359
360 /** Array of pointers on the contravariant derivatives of \c *this
361 * with respect to the corresponding metric in \c *met_depend .
362 * It is set to zero if it has not been calculated yet.
363 *
364 */
365 Tenseur** p_derive_con ;
366
367 /** Array of pointers on the scalar squares of \c *this
368 * with respect to the corresponding metric in \c *met_depend .
369 * It is set to zero if it has not been calculated yet.
370 *
371 */
372 Tenseur** p_carre_scal ;
373
374 // Constructors - Destructor :
375 // -------------------------
376 protected:
377 /// Returns false for a tensor density without a defined metric
378 bool verif() const ;
379
380 /** Builds the arrays \c met_depend , \c p_derive_cov ,
381 * \c p_derive_con and \c p_carre_scal and fills them with
382 * null pointers.
383 *
384 */
385 void new_der_met() ;
386
387 public:
388 explicit Tenseur (const Map& map, const Metrique* met = 0x0,
389 double weight = 0) ; ///< Constructor for a scalar field.
390
391 /// Constructor for a scalar field and from a \c Cmp .
392 explicit Tenseur (const Cmp& cmp, const Metrique* met = 0x0,
393 double weight = 0) ;
394
395 /** Standard constructor.
396 *
397 * @param map the mapping
398 * @param val valence of the tensor
399 * @param tipe 1-D \c Itbl of size \c valence containing the type
400 * of each index, \c COV for a covariant one
401 * and \c CON for a contravariant one, with the
402 * following storage convention:
403 * \li \c tipe(0) : type of the first index
404 * \li \c tipe(1) : type of the second index
405 * \li and so on...
406 * @param triad_i vectorial basis (triad) with respect to which
407 * the tensor components are defined
408 * @param met for tensor densities only: a pointer on the metric
409 * defining the conformal factor
410 * @param weight for tensor densities: the weight
411 */
412 Tenseur (const Map& map, int val, const Itbl& tipe,
413 const Base_vect& triad_i, const Metrique* met = 0x0,
414 double weight = 0) ;
415
416 /** Standard constructor with the triad passed as a pointer.
417 *
418 * @param map the mapping
419 * @param val valence of the tensor
420 * @param tipe 1-D \c Itbl of size \c valence containing the type
421 * of each index, \c COV for a covariant one
422 * and \c CON for a contravariant one, with the
423 * following storage convention:
424 * \li \c tipe(0) : type of the first index
425 * \li \c tipe(1) : type of the second index
426 * \li and so on...
427 * @param triad_i pointer on the vectorial basis (triad) with respect
428 * to which the tensor components are defined
429 * (can be set to 0x0 for a scalar field)
430 * @param met for tensor densities only: a pointer on the metric
431 * defining the conformal factor
432 * @param weight for tensor densities: the weight
433 */
434 Tenseur (const Map& map, int val, const Itbl& tipe,
435 const Base_vect* triad_i, const Metrique* met = 0x0,
436 double weight = 0) ;
437
438 /** Standard constructor when all the indices are of
439 * the same type.
440 *
441 * @param map the mapping
442 * @param val valence of the tensor
443 * @param tipe the type of the indices.
444 * @param triad_i vectorial basis (triad) with respect to which
445 * the tensor components are defined.
446 * @param met for tensor densities only: a pointer on the metric
447 * defining the conformal factor
448 * @param weight for tensor densities: the weight
449 */
450 Tenseur (const Map& map, int val, int tipe, const
451 Base_vect& triad_i, const Metrique* met = 0x0,
452 double weight = 0) ;
453
454 Tenseur (const Tenseur&) ; ///< Copy constructor
455
456 /// Constructor from a symmetric tensor.
457 explicit Tenseur (const Tenseur_sym&) ;
458
459 /** Constructor from a file (see \c sauve(FILE*) ).
460 *
461 * @param map the mapping
462 * @param triad_i vectorial basis (triad) with respect to which
463 * the tensor components are defined. It will
464 * be checked that it coincides with the basis
465 * saved in the file.
466 * @param fich file which has been created by
467 * the function \c sauve(FILE*) .
468 * @param met for tensor densities only: a pointer on the metric
469 * defining the conformal factor
470 */
471 Tenseur (const Map& map, const Base_vect& triad_i, FILE* fich,
472 const Metrique* met = 0x0) ;
473
474 /** Constructor from a file for a scalar field
475 * (see \c sauve(FILE*) ).
476 *
477 * @param map the mapping
478 * @param fich file which has been created by
479 * the function \c sauve(FILE*) .
480 * @param met for tensor densities only: a pointer on the metric
481 * defining the conformal factor
482 */
483 Tenseur (const Map& map, FILE* fich, const Metrique* met = 0x0) ;
484
485
486 protected:
487 /**
488 * Constructor used by the derived classes.
489 *
490 * @param map the mapping
491 * @param val valence of the tensor
492 * @param tipe 1-D \c Itbl of size \c valence containing the type
493 * of each index, \c COV for a covariant one
494 * and \c CON for a contravariant one, with the
495 * following storage convention:
496 * \li \c tipe(0) : type of the first index
497 * \li \c tipe(1) : type of the second index
498 * \li and so on...
499 * @param n_comp the number of components.
500 * @param triad_i vectorial basis (triad) with respect to which
501 * the tensor components are defined
502 * @param met for tensor densities only: a pointer on the metric
503 * defining the conformal factor
504 * @param weight for tensor densities: the weight
505 */
506 Tenseur (const Map& map, int val, const Itbl& tipe, int n_comp,
507 const Base_vect& triad_i, const Metrique* met = 0x0,
508 double weight = 0) ;
509
510 /**
511 * Constructor used by the derived classes when all the indices are of
512 * the same type.
513 *
514 * @param map the mapping
515 * @param val valence of the tensor
516 * @param tipe the type of the indices.
517 * @param n_comp the number of components.
518 * @param triad_i vectorial basis (triad) with respect to which
519 * the tensor components are defined
520 * @param met for tensor densities only: a pointer on the metric
521 * defining the conformal factor
522 * @param weight for tensor densities: the weight
523 */
524 Tenseur (const Map&, int val, int tipe, int n_comp,
525 const Base_vect& triad_i, const Metrique* met = 0x0,
526 double weight = 0) ;
527
528
529 public:
530
531 virtual ~Tenseur() ; ///< Destructor
532
533 // Memory management
534 // -----------------
535 protected:
536 void del_t() ; ///< Logical destructor
537
538 /**
539 * Logical destructor of the derivatives depending on the i-th
540 * element of \c *met_depend .
541 */
542 void del_derive_met(int i) const ;
543
544 /**
545 * Logical destructor of all the derivatives.
546 */
547 void del_derive() const ;
548
549 /**
550 * Sets the pointers of the derivatives depending on the i-th
551 * element of \c *met_depend to zero (as well as that i-th
552 * element).
553 */
554 void set_der_met_0x0(int i) const ;
555
556 /**
557 * Sets the pointers of all the derivatives
558 * to zero.
559 */
560 void set_der_0x0() const ;
561
562 // Mutators / assignment
563 // ---------------------
564 public:
565 /**
566 * Sets the logical state to \c ETATNONDEF (undefined state).
567 * The components are not allocated.
568 */
569 void set_etat_nondef() ;
570
571 /**
572 * Sets the logical state to \c ETATZERO (zero state).
573 * The components are not allocated.
574 */
575 void set_etat_zero() ;
576
577 /**
578 * Sets the logical state to \c ETATQCQ (ordinary state).
579 * The components are now allocated and set to \c ETATNONDEF .
580 */
581 void set_etat_qcq() ;
582
583 /**
584 * Sets the logical state to \c ETATQCQ (ordinary state)
585 * and performs the memory allocation of all the
586 * elements, down to the \c double arrays of the \c Tbl s.
587 * This function performs in fact recursive calls to
588 * \c set_etat_qcq()
589 * on each element of the chain \c Tenseur -> \c Cmp ->
590 * \c Valeur -> \c Mtbl -> \c Tbl .
591 */
592 void allocate_all() ;
593
594 /** Sets a new vectorial basis (triad) of decomposition and modifies
595 * the components accordingly.
596 */
597 void change_triad(const Base_vect& new_triad) ;
598
599 /** Assigns a new vectorial basis (triad) of decomposition.
600 * NB: this function modifies only the member \c triad and
601 * leave unchanged the components (member \c c ). In order to
602 * change them coherently with the new basis, the function
603 * \c change_triad(const Base_vect\&) must be called instead.
604 */
605 void set_triad(const Base_vect& new_triad) ;
606 void set_poids(double weight) ; ///<Sets the weight for a tensor density
607 /// Sets the pointer on the metric for a tensor density
608 void set_metric(const Metrique& met) ;
609
610 /// Assignment to another \c Tenseur
611 virtual void operator=(const Tenseur& tens) ;
612
613 /// Assignment to a \c Cmp (scalar field only)
614 void operator=(const Cmp& field) ;
615
616 /// Assignment to a \c double (scalar field only, except for zero)
617 void operator=(double ) ;
618
619 /// Assignment to a \c int (scalar field only, except for zero)
620 void operator=(int ) ;
621
622 /// Read/write for a scalar (see also \c operator=(const \c Cmp\&) ).
623 Cmp& set () ;
624 Cmp& set (int) ; ///< Read/write for a vector.
625 Cmp& set (int, int) ; ///< Read/write for a tensor of valence 2.
626 Cmp& set (int, int, int) ; ///< Read/write for a tensor of valence 3.
627 Cmp& set (const Itbl&) ; ///< Read/write in the general case.
628
629 /**
630 * Sets the \c Tenseur to zero in a given domain.
631 * @param l [input] Index of the domain in which the \c Tenseur
632 * will be set (logically) to zero.
633 */
634 void annule(int l) ;
635
636 /**
637 * Sets the \c Tenseur to zero in several domains.
638 * @param l_min [input] The \c Tenseur will be set (logically)
639 * to zero
640 * in the domains whose indices are in the range
641 * \c [l_min,l_max] .
642 * @param l_max [input] see the comments for \c l_min .
643 *
644 * Note that \c annule(0,nz-1), where \c nz is the total number
645 * of domains, is equivalent to \c set_etat_zero() .
646 */
647 void annule(int l_min, int l_max) ;
648
649 /**
650 * Set the standard spectal basis of decomposition for each component.
651 * To be used only with \c valence strictly lower than 3.
652 *
653 */
654 void set_std_base() ;
655
656 void dec_dzpuis() ; ///< dzpuis -= 1 ;
657 void inc_dzpuis() ; ///< dzpuis += 1 ;
658 void dec2_dzpuis() ; ///< dzpuis -= 2 ;
659 void inc2_dzpuis() ; ///< dzpuis += 2 ;
660 void mult_r_zec() ; ///< Multiplication by \e r in the external zone.
661
662 /**
663 * Compute \f$\Delta + \lambda \nabla\nabla\f$ of \c *this , \c *this
664 * being of valence 1.
665 */
666 Tenseur inverse_poisson_vect (double lambda) const ;
667
668 // Accessors
669 // ---------
670 public:
671 /**
672 * Returns the position in the \c Cmp 1-D array \c c of a
673 * component given by its indices.
674 *
675 * @return position in the \c Cmp 1-D array \c c
676 * corresponding to the indices given in \c idx . \c idx
677 * must be a 1-D \c Itbl of size \c valence ,
678 * each element of which must be 0, 1 or 2,
679 * corresponding to spatial indices 1, 2 or 3 respectively.
680 */
681 virtual int donne_place (const Itbl& idx) const ;
682
683 /**
684 * Returns the indices of a component given by its position in the
685 * \c Cmp 1-D array \c c .
686 *
687 * @return 1-D array of integers (\c Itbl ) of
688 * size \c valence giving the value of each index
689 * for the component located at the position \c place
690 * in the \c Cmp 1-D array \c c .
691 * Each element of this \c Itbl is 0, 1 or 2, which
692 * corresponds to spatial indices 1, 2 or 3 respectively.
693 * If \c (*this) is a scalar the function returns an undefined
694 * \c Itbl .
695 */
696 virtual Itbl donne_indices (int place) const ;
697
698 /// Returns pointer on the mapping.
699 const Map* get_mp() const {return mp ;} ;
700
701 /** Returns the vectorial basis (triad) on which the components
702 * are defined.
703 */
704 const Base_vect* get_triad() const {return triad;} ;
705
706 /// Returns the logical state.
707 int get_etat() const {return etat ;} ;
708
709 ///Returns the valence.
710 int get_valence() const {return valence ; } ;
711
712 ///Returns the number of components.
713 int get_n_comp() const {return n_comp ;} ;
714
715 /**
716 * Returns the type of the index number \c i . \c i must be
717 * strictly lower than \c valence and obey the following
718 * convention:
719 * \li \c i = 0 : first index
720 * \li \c i = 1 : second index
721 * \li and so on...
722 *
723 * @return COV for a covariant index, CON for a
724 * contravariant one.
725 */
726 int get_type_indice (int i) const {return type_indice(i) ;};
727
728 /**
729 * Returns the types of all the indices.
730 *
731 * @return 1-D \c Itbl of size \c valence containing the type
732 * of each index, \c COV for a covariant one and \c CON
733 * for a contravariant one.
734 */
735 Itbl get_type_indice () const {return type_indice ; } ;
736
737 ///Returns the weight
738 double get_poids() const {return poids ; } ;
739
740 /**
741 * Returns a pointer on the metric defining the conformal factor
742 * for tensor densities. Otherwise (case of a pure tensor), it
743 * returns 0x0.
744 */
745 const Metrique* get_metric() const {return metric ; } ;
746
747 const Cmp& operator()() const ; ///< Read only for a scalar.
748 const Cmp& operator()(int) const ; ///< Read only for a vector.
749 const Cmp& operator()(int, int) const ; ///< Read only for a tensor of valence 2.
750 const Cmp& operator()(int, int, int) const ; ///< Read only for a tensor of valence 3.
751 const Cmp& operator()(const Itbl&) const ; ///< Read only in the general case.
752
753 // Outputs
754 // -------
755 public:
756 void sauve(FILE *) const ; ///< Save in a file
757 friend ostream& operator<<(ostream& , const Tenseur & ) ;
758
759 // Computation of derived members
760 // ------------------------------
761 protected:
762 /**
763 * Calculates, if needed, the gradient of \c *this .
764 * The result is in \c *p_gradient
765 */
766 virtual void fait_gradient () const ;
767
768 /**
769 * Calculates, if needed, the gradient of \c *this in a
770 * spherical orthonormal basis (scalar field only).
771 * The result is in \c *p_gradient_spher
772 */
773 void fait_gradient_spher () const ;
774
775 /**
776 * Calculates, if needed, the covariant derivative of \c *this ,
777 * with respect to \c met .
778 * The result is in \c *p_derive_cov[i]
779 */
780 virtual void fait_derive_cov (const Metrique& met, int i) const ;
781
782 /**
783 * Calculates, if needed, the contravariant derivative of \c *this ,
784 * with respect to \c met .
785 * The result is in \c *p_derive_con[i]
786 */
787 virtual void fait_derive_con (const Metrique&, int i) const ;
788
789 /**
790 * Calculates, if needed, the scalar square of \c *this ,
791 * with respect to \c met .
792 * The result is in \c *p_carre_scal[i]
793 */
794 void fait_carre_scal (const Metrique&, int i) const ;
795
796 /**
797 * To be used to describe the fact that the derivatives members have
798 * been calculated with \c met .
799 *
800 * First it sets a null element of \c met_depend to
801 * \c \&met and puts \c this in
802 * the list of the dependancies of \c met .
803 *
804 */
805 void set_dependance (const Metrique& met) const ;
806
807 /**
808 * Returns the position of the pointer on \c metre in
809 * the array \c met_depend .
810 *
811 */
812 int get_place_met(const Metrique& metre) const ;
813
814 // Differential operators
815 // ----------------------
816 public:
817 /// Returns the gradient of \c *this (Cartesian coordinates)
818 const Tenseur& gradient() const ;
819
820 /** Returns the gradient of \c *this (Spherical coordinates)
821 * (scalar field only).
822 */
823 const Tenseur& gradient_spher() const ;
824
825 /**
826 * Returns the covariant derivative of \c *this , with respect to
827 * \c met .
828 */
829 const Tenseur& derive_cov (const Metrique& met) const ;
830
831 /**
832 * Returns the contravariant derivative of \c *this , with respect to
833 * \c met .
834 */
835 const Tenseur& derive_con (const Metrique&) const ;
836
837 /**
838 * Returns the scalar square of \c *this , with respect to
839 * \c met .
840 */
841 const Tenseur& carre_scal (const Metrique&) const ;
842
843 // Resolution d'EDP :
844 /**
845 * Solves the vectorial Poisson equation :
846 * \f$\Delta N^i +\lambda \nabla^i \nabla_k N^k = S^i\f$.
847 * with \f$\lambda \not= 1\f$.
848 *
849 * \c *this must be given with \c dzpuis = 4.
850 *
851 * It uses the Shibata scheme, where \f$N^i\f$ is given by :
852 * \f[
853 * N^i = \frac{1}{2}\frac{\lambda+2}{\lambda+1}W^i-\frac{1}{2}
854 * \frac{\lambda}{\lambda+1}\left(\nabla^i\chi+\nabla^iW^kx_k\right)
855 * \f]
856 * with \f$\Delta W^i = S^i\f$ and \f$\Delta \chi = -x_kS^k\f$.
857 *
858 * @param lambda [input] \f$\lambda\f$.
859 * @param par [input/output] see Map::donne_para_poisson_vect.
860 * @param shift [input] solution \f$N^i\f$ at the previous step.
861 * Zero if nothing is known.
862 * @param shift [output] solution at this step.
863 * @param vect [input/output] the same thing than for \c shift but for
864 * \f$W^i\f$.
865 * @param scal [input/output] the same thing than for \c shift but for
866 * \f$\chi\f$.
867 */
868
869 void poisson_vect(double lambda, Param& par, Tenseur& shift, Tenseur& vect
870 , Tenseur& scal) const ;
871
872 /*
873 * Same as poisson_vect with a Tau method
874 **/
875 void poisson_vect_tau(double lambda, Param& par, Tenseur& shift, Tenseur& vect
876 , Tenseur& scal) const ;
877
878 void poisson_vect_falloff(double lambda, Param& par, Tenseur& shift,
879 Tenseur& vect, Tenseur& scal, int* k_falloff) const ;
880
881 void poisson_vect_ylm(double lambda, Param& para, Tenseur& shift,
882 Tenseur& vecteur, Tenseur& scalaire, int nylm,
883 double* intvec) const ;
884
885 /**
886 * Solves the vectorial Poisson equation \f$\Delta N^i +\lambda \nabla^i
887 * \nabla_k N^k = S^i\f$.
888 * with \f$\lambda \not= 1\f$.
889 *
890 * \c *this must be given with \c dzpuis = 4.
891 *
892 * It uses the Shibata scheme, where \f$N^i\f$ is given by :
893 * \f[
894 * N^i = \frac{1}{2}\frac{\lambda+2}{\lambda+1}W^i-\frac{1}{2}
895 * \frac{\lambda}{\lambda+1}\left(\nabla^i\chi+\nabla^iW^kx_k\right)
896 * \f]
897 * with \f$\Delta W^i = S^i\f$ and \f$\Delta \chi = -x_kS^k\f$.
898 *
899 * This version is to be used only with an affine mapping.
900 *
901 * @param lambda [input] \f$\lambda\f$.
902 * @param vect [input] \f$W^i\f$ at the previous step.
903 * Zero if nothing is known.
904 * @param vect [output] \f$W^i\f$ at this step.
905 * @param scal [input/output] the same thing than for \c shift but for
906 * \f$\chi\f$.
907 *
908 * @return the solution \f$N^i\f$.
909 */
910
911
912 Tenseur poisson_vect(double lambda, Tenseur& vect , Tenseur& scal ) const ;
913
914 /*
915 * Same as poisson_vect with a Tau method
916 **/
917 Tenseur poisson_vect_tau(double lambda, Tenseur& vect , Tenseur& scal ) const ;
918
919 Tenseur poisson_vect_falloff(double lambda, Tenseur& vect ,
920 Tenseur& scal, int* k_falloff ) const ;
921
922 Tenseur poisson_vect_ylm(double lambda, Tenseur& vecteur,
923 Tenseur& scalaire, int nylm, double* intvec) const ;
924
925 /**
926 * Solves the vectorial Poisson equation \f$\Delta N^i +\lambda \nabla^i
927 * \nabla_k N^k = S^i\f$.
928 * with \f$\lambda \not= 1\f$.
929 *
930 * \c *this must be given with \c dzpuis = 3 or 4 and be continuous.
931 *
932 * It uses the Oohara scheme, where \f$N^i\f$ is given by
933 * \f[
934 * \Delta N^i = S^i-\lambda \nabla^i \chi
935 * \f]
936 * with \f$\chi\f$ solution of :
937 * \f[
938 * \Delta \chi = \frac{1}{\lambda+1}\nabla_k S^k
939 * \f]
940 *
941 * @param lambda [input] \f$\lambda\f$.
942 * @param par [input/output] see Map::donne_para_poisson_vect.
943 * @param shift [input] solution \f$N^i\f$ at the previous step.
944 * Zero if nothing is known.
945 * @param shift [output] solution at this step.
946 * @param scal [input/output] the same thing than for \c shift but for
947 * \f$\chi\f$.
948 */
949
950 void poisson_vect_oohara(double lambda, Param& par, Tenseur& shift,
951 Tenseur& scal) const ;
952
953 /*
954 * Same as poisson_vect_oohara with a Tau method
955 **/
956 void poisson_vect_oohara_tau(double lambda, Param& par, Tenseur& shift,
957 Tenseur& scal) const ;
958
959 /**
960 * Solves the vectorial Poisson equation \f$\Delta N^i +\lambda \nabla^i
961 * \nabla_k N^k = S^i\f$.
962 * with \f$\lambda \not= 1\f$.
963 *
964 * \c *this must be given with \c dzpuis = 3 or 4 and be continuous.
965 *
966 * This version is to be used only with an affine mapping.
967 *
968 * It uses the Oohara scheme, where \f$N^i\f$ is given by :
969 * \f[
970 * \Delta N^i = S^i-\lambda \nabla^i \chi
971 * \f]
972 *
973 * with \f$\chi\f$ solution of :
974 * \f[
975 * \Delta \chi = \frac{1}{\lambda+1}\nabla_k S^k
976 * \f]
977 *
978 * This version is to be used only with an affine mapping.
979 *
980 * @param lambda [input] \f$\lambda\f$.
981 * @param scal [input]\f$\chi\f$ at the previous step.
982 * Zero if nothing is known.
983 * @param scal [output] \f$\chi\f$ at this step.
984 * @return the solution \f$N^i\f$.
985 */
986
987 Tenseur poisson_vect_oohara(double lambda, Tenseur& scal) const ;
988 /*
989 * Same as poisson_vect_oohara with a Tau method
990 **/
991 Tenseur poisson_vect_oohara_tau(double lambda, Tenseur& scal) const ;
992
993 /**
994 * Solves the vectorial Poisson equation :
995 * \f$\Delta N^i +\lambda \nabla^i \nabla_k N^k = S^i\f$.
996 * with \f$\lambda \not= 1\f$ by regularizing the source term.
997 *
998 * \c *this must be given with \c dzpuis = 4.
999 *
1000 * It uses the Shibata scheme, where \f$N^i\f$ is given by :
1001 * \f[
1002 * N^i = \frac{1}{2}\frac{\lambda+2}{\lambda+1}W^i-\frac{1}{2}
1003 * \frac{\lambda}{\lambda+1}\left(\nabla^i\chi+\nabla^iW^kx_k\right)
1004 * \f]
1005 * with \f$\Delta W^i = S^i\f$ and \f$\Delta \chi = -x_kS^k\f$.
1006 *
1007 * @param k_div [input] regularization degree.
1008 * @param nzet [input] number of domains covering a star.
1009 * @param unsgam1 [input] \f$1/(\gamma - 1)\f$.
1010 * @param lambda [input] \f$\lambda\f$.
1011 * @param par [input/output] see Map::donne_para_poisson_vect.
1012 * @param shift [input] solution \f$N^i\f$ at the previous step.
1013 * Zero if nothing is known.
1014 * @param shift [output] solution at this step.
1015 * @param vect [input/output] the same thing than for \c shift but for
1016 * \f$W^i\f$.
1017 * @param scal [input/output] the same thing than for \c shift but for
1018 * \f$\chi\f$.
1019 */
1020
1021 void poisson_vect_regu(int k_div, int nzet, double unsgam1,
1022 double lambda, Param& par, Tenseur& shift,
1023 Tenseur& vect, Tenseur& scal) const ;
1024
1025
1026 // Friend classes
1027 // ---------------
1028 friend class Tenseur_sym ;
1029 friend class Metrique ;
1030
1031 // Mathematical operators
1032 // ----------------------
1033
1034 friend Tenseur operator* (const Tenseur&, const Tenseur&) ;
1035 friend Tenseur operator% (const Tenseur&, const Tenseur&) ;
1036 friend Tenseur contract(const Tenseur&, int id1, int id2) ;
1037 friend Tenseur contract(const Tenseur&, int id1, const Tenseur&,
1038 int id2) ;
1039 friend Tenseur contract_desal(const Tenseur&, int id1, const Tenseur&,
1040 int id2) ;
1041 friend Tenseur flat_scalar_prod(const Tenseur& t1, const Tenseur& t2) ;
1042 friend Tenseur flat_scalar_prod_desal(const Tenseur& t1,
1043 const Tenseur& t2) ;
1044 friend Tenseur manipule(const Tenseur&, const Metrique&, int idx) ;
1045 friend Tenseur manipule(const Tenseur&, const Metrique&) ;
1046 friend Tenseur skxk (const Tenseur&) ;
1047 friend Tenseur lie_derive(const Tenseur& , const Tenseur& ,
1048 const Metrique* ) ;
1049
1050 };
1051
1052
1053 /**
1054 * \defgroup tens_cal Tenseur calculus
1055 * \ingroup (otens)
1056 *
1057 *@{
1058 */
1059 /// Tensorial product.
1060 Tenseur operator*(const Tenseur&, const Tenseur&) ;
1061
1062 /// Tensorial product with desaliasing.
1063 Tenseur operator%(const Tenseur&, const Tenseur&) ;
1064
1065 /**
1066 * Self contraction of two indices of a \c Tenseur .
1067 *
1068 * The two indices must be of different type, i.e. covariant and
1069 * contravariant, or contravariant and covariant.
1070 *
1071 * @param id1 [input] number of the first index for the contraction;
1072 * \c id1 must be strictly lower than the
1073 * valence of the tensor and obeys the following
1074 * convention:
1075 * \li \c id1 = 0 : first index
1076 * \li \c id1 = 1 : second index
1077 * \li and so on...
1078 * @param id2 [input] number of the second index for the contraction;
1079 * \c id2 must be strictly lower than the
1080 * valence of the tensor and obeys the following
1081 * convention:
1082 * \li \c id2 = 0 : first index
1083 * \li \c id2 = 1 : second index
1084 * \li and so on...
1085 *
1086 */
1087 Tenseur contract(const Tenseur&, int id1, int id2) ;
1088
1089 /**
1090 * Contraction of two \c Tenseur .
1091 *
1092 * The two indices must be of different type, i.e. covariant and
1093 * contravariant, or contravariant and covariant.
1094 *
1095 * @param id1 [input] number of the index of contraction for
1096 * the first \c Tenseur ;
1097 * \c id1 must be strictly lower than the
1098 * valence of the tensor and obeys the following
1099 * convention:
1100 * \li \c id1 = 0 : first index
1101 * \li \c id1 = 1 : second index
1102 * \li and so on...
1103 * @param id2 [input] number of index of contraction for the second one;
1104 * \c id2 must be strictly lower than the
1105 * valence of the tensor and obeys the following
1106 * convention:
1107 * \li \c id2 = 0 : first index
1108 * \li \c id2 = 1 : second index
1109 * \li and so on...
1110 */
1111 Tenseur contract(const Tenseur&, int id1, const Tenseur&, int id2) ;
1112
1113 /**
1114 * Scalar product of two \c Tenseur when the metric is
1115 * \f$\delta_{ij}\f$: performs the contraction of the
1116 * last index of \c t1 with the first one of \c t2 , irrespective
1117 * of the type of these indices.
1118 */
1119 Tenseur flat_scalar_prod(const Tenseur& t1, const Tenseur& t2) ;
1120
1121 /**
1122 * Same as \c flat_scalar_prod but with desaliasing.
1123 */
1124 Tenseur flat_scalar_prod_desal(const Tenseur& t1, const Tenseur& t2) ;
1125
1126 /**
1127 * Raise or lower the index \c idx depending on its type, using the
1128 * given \c Metrique .
1129 */
1130 Tenseur manipule(const Tenseur&, const Metrique&, int idx) ;
1131
1132 /**
1133 * Raise or lower all the indices, depending on their type, using the given
1134 * \c Metrique .
1135 */
1136 Tenseur manipule(const Tenseur&, const Metrique&) ;
1137
1138 /**
1139 * Contraction of the last index of (*this) with \f$x^k\f$ or \f$x_k\f$, depending
1140 * on the type of \e S .
1141 *
1142 * The calculation is performed to avoid singularities in the external
1143 * zone. This is done only for a flat metric.
1144 */
1145 Tenseur skxk (const Tenseur&) ;
1146
1147 /**
1148 * Lie Derivative of \c t with respect to \c x . If no other argument
1149 * is given, it uses partial derivatives with respect to cartesian coordinates
1150 * to calculate the result (this is the default). Otherwise, it uses the
1151 * covariant derivative associated to the metric given as last argument.
1152 */
1153 Tenseur lie_derive (const Tenseur& t, const Tenseur& x, const Metrique* = 0x0);
1154
1155 /**
1156 * Computes the traceless part of a \c Tenseur of valence 2.
1157 *
1158 * @param tens [input] the \c Tenseur of valence 2
1159 * @param metre [input] the metric used to raise or lower the indices
1160 *
1161 * @return The traceless part of the input \c Tenseur
1162 */
1163 Tenseur sans_trace(const Tenseur& tens, const Metrique& metre) ;
1164
1165
1166 /** @} */
1167
1168 /**
1169 * \defgroup tens_ma Tenseur mathematics
1170 * \ingroup (otens)
1171 *
1172 * @{
1173 */
1174 Tenseur operator+(const Tenseur& ) ; ///< + Tenseur
1175 Tenseur operator-(const Tenseur& ) ; ///< \c - Tenseur
1176 Tenseur operator+(const Tenseur&, const Tenseur &) ; ///< Tenseur + Tenseur
1177
1178 /// Tenseur + double (the \c Tenseur must be a scalar)
1179 Tenseur operator+(const Tenseur&, double ) ;
1180
1181 /// double + Tenseur (the \c Tenseur must be a scalar)
1182 Tenseur operator+(double, const Tenseur& ) ;
1183
1184 /// Tenseur + int (the \c Tenseur must be a scalar)
1185 Tenseur operator+(const Tenseur&, int ) ;
1186
1187 /// int + Tenseur (the \c Tenseur must be a scalar)
1188 Tenseur operator+(int, const Tenseur& ) ;
1189
1190 Tenseur operator-(const Tenseur &, const Tenseur &) ; ///< Tenseur - Tenseur
1191
1192 /// Tenseur - double (the \c Tenseur must be a scalar)
1193 Tenseur operator-(const Tenseur&, double ) ;
1194
1195 /// double - Tenseur (the \c Tenseur must be a scalar)
1196 Tenseur operator-(double, const Tenseur& ) ;
1197
1198 /// Tenseur - int (the \c Tenseur must be a scalar)
1199 Tenseur operator-(const Tenseur&, int ) ;
1200
1201 /// int - Tenseur (the \c Tenseur must be a scalar)
1202 Tenseur operator-(int, const Tenseur& ) ;
1203
1204 /// Tenseur * double
1205 Tenseur operator*(const Tenseur&, double ) ;
1206
1207 /// double * Tenseur
1208 Tenseur operator*(double, const Tenseur& ) ;
1209
1210 /// Tenseur * int
1211 Tenseur operator*(const Tenseur&, int ) ;
1212
1213 /// int * Tenseur
1214 Tenseur operator*(int, const Tenseur& ) ;
1215
1216 /// Tenseur / Tenseur (\c b must be a scalar)
1217 Tenseur operator/(const Tenseur& a, const Tenseur& b) ;
1218
1219 Tenseur operator/(const Tenseur&, double ) ; ///< Tenseur / double
1220
1221 /// double / Tenseur (the \c Tenseur must be a scalar)
1222 Tenseur operator/(double, const Tenseur &) ;
1223
1224 Tenseur operator/(const Tenseur&, int ) ; ///< Tenseur / int
1225
1226 /// int / Tenseur (the \c Tenseur must be a scalar)
1227 Tenseur operator/(int, const Tenseur &) ;
1228
1229 Tenseur exp(const Tenseur& ) ; ///< Exponential (for a scalar only)
1230 Tenseur log(const Tenseur& ) ; ///< Neperian logarithm (for a scalar only)
1231 Tenseur sqrt(const Tenseur& ) ; ///< Square root (for a scalar only)
1232 Tenseur abs(const Tenseur& ) ; ///< Absolute value (for a scalar only)
1233 Tenseur pow(const Tenseur&, int ) ; ///< Power (for a scalar only)
1234 Tenseur pow(const Tenseur&, double ) ; ///< Power (for a scalar only)
1235
1236 /** @} */
1237
1238
1239
1240
1241
1242 //---------------------------------//
1243 // class Tenseur_sym //
1244 //---------------------------------//
1245
1246 /**
1247 * Class intended to describe tensors with a symmetry on the two last indices *** DEPRECATED : use class \c Tensor_sym instead ***.
1248 * The storage and the calculations are different and quicker than with an
1249 * usual \c Tenseur . \ingroup (otens)
1250 *
1251 * The valence must be >1.
1252 */
1253 class Tenseur_sym : public Tenseur {
1254
1255 // Constructors - Destructor :
1256 // -------------------------
1257
1258 public:
1259 /** Standard constructor.
1260 *
1261 * @param map the mapping
1262 * @param val valence of the tensor; must be greater or equal to 2.
1263 * @param tipe 1-D \c Itbl of size \c valence containing the type
1264 * of each index, \c COV for a covariant one
1265 * and \c CON for a contravariant one, with the
1266 * following storage convention:
1267 * \li \c tipe(0) : type of the first index
1268 * \li \c tipe(1) : type of the second index
1269 * \li and so on...
1270 * @param triad_i vectorial basis (triad) with respect to which
1271 * the tensor components are defined
1272 */
1273 Tenseur_sym (const Map& map, int val, const Itbl& tipe,
1274 const Base_vect& triad_i, const Metrique* met = 0x0,
1275 double weight = 0) ;
1276
1277 /** Standard constructor when all the indices are of the same type.
1278 *
1279 * @param map the mapping
1280 * @param val valence of the tensor; must be greater or equal to 2.
1281 * @param tipe the type of the indices.
1282 * @param triad_i vectorial basis (triad) with respect to which
1283 * the tensor components are defined
1284 *
1285 */
1286 Tenseur_sym (const Map& map, int val, int tipe,
1287 const Base_vect& triad_i, const Metrique* met = 0x0,
1288 double weight = 0) ;
1289
1290 Tenseur_sym (const Tenseur_sym&) ; ///< Copy constructor
1291
1292 /** Constructor from a \c Tenseur .
1293 * The symmetry is assumed to be true but not checked.
1294 */
1295 explicit Tenseur_sym (const Tenseur&) ;
1296
1297 /** Constructor from a file (see \c sauve(FILE*) ).
1298 *
1299 * @param map the mapping
1300 * @param triad_i vectorial basis (triad) with respect to which
1301 * the tensor components are defined. It will
1302 * be checked that it coincides with the basis
1303 * saved in the file.
1304 * @param fich file which has been created by
1305 * the function \c sauve(FILE*) .
1306 */
1307 Tenseur_sym (const Map& map, const Base_vect& triad_i, FILE* fich,
1308 const Metrique* met = 0x0) ;
1309
1310 virtual ~Tenseur_sym() ; ///< Destructor
1311
1312 // Mutators / assignment
1313 // ---------------------
1314 public:
1315 /**
1316 * Assignment from a \c Tenseur .
1317 *
1318 * The symmetry is assumed but not checked.
1319 */
1320 virtual void operator= (const Tenseur&) ;
1321
1322
1323 // Accessors
1324 // ---------
1325 public:
1326 /**
1327 * Returns the position in the \c Cmp 1-D array \c c of a
1328 * component given by its indices.
1329 *
1330 * @return position in the \c Cmp 1-D array \c c
1331 * corresponding to the indices given in \c idx . \c idx
1332 * must be a 1-D \c Itbl of size \c valence ,
1333 * each element of which must be 0, 1 or 2,
1334 * corresponding to spatial indices 1, 2 or 3 respectively.
1335 */
1336 virtual int donne_place (const Itbl& idx) const ;
1337
1338 /**
1339 * Returns the indices of a component given by its position in the
1340 * \c Cmp 1-D array \c c .
1341 *
1342 * @return 1-D array of integers (\c Itbl ) of
1343 * size \c valence giving the value of each index
1344 * for the component located at the position \c place
1345 * in the \c Cmp 1-D array \c c .
1346 * Each element of this \c Itbl is 0, 1 or 2, which
1347 * corresponds to spatial indices 1, 2 or 3 respectively.
1348 */
1349 virtual Itbl donne_indices (int place) const ;
1350
1351 // Computation of derived members
1352 // ------------------------------
1353 protected:
1354 /**
1355 * Calculates, if needed, the gradient of \c *this .
1356 * The result is in \c *p_gradient
1357 */
1358 virtual void fait_gradient () const ;
1359
1360 /**
1361 * Calculates, if needed, the covariant derivative of \c *this , with
1362 * respect to \c met .
1363 * The result is in \c *p_derive_cov[i]
1364 */
1365 virtual void fait_derive_cov (const Metrique& met, int i) const ;
1366
1367 /**
1368 * Calculates, if needed, the contravariant derivative of \c *this ,
1369 * with respect to \c met .
1370 * The result is in \c *p_derive_con[i]
1371 */
1372 virtual void fait_derive_con (const Metrique&, int i) const ;
1373
1374 // Mathematical operators
1375 // ----------------------
1376 friend Tenseur_sym operator* (const Tenseur&, const Tenseur_sym&) ;
1377 friend Tenseur_sym manipule(const Tenseur_sym&, const Metrique&) ;
1378 friend Tenseur lie_derive (const Tenseur& , const Tenseur& ,
1379 const Metrique* );
1380
1381 } ;
1382 /**
1383 * \defgroup tsym_cal Tenseur_sym calculus
1384 * \ingroup (otens)
1385 *
1386 * @{
1387 */
1388 /// Tensorial product.
1389 Tenseur_sym operator* (const Tenseur&, const Tenseur_sym&) ;
1390
1391 /**
1392 * Raise or lower all the indices, depending on their type, using the given
1393 * \c Metrique .
1394 */
1395 Tenseur_sym manipule(const Tenseur_sym&, const Metrique&) ;
1396
1397 /**
1398 * Lie Derivative of \c t with respect to \c x . If no other
1399 * argument is given, it uses partial derivatives with respect to
1400 * cartesian coordinates to calculate the result (this is the
1401 * default). Otherwise, it uses the covariant derivative associated
1402 * to the metric given as last argument.
1403 */
1404 Tenseur_sym lie_derive (const Tenseur_sym& t, const Tenseur& x,
1405 const Metrique* = 0x0);
1406
1407 /**
1408 * Computes the traceless part of a \c Tenseur_sym of valence 2.
1409 *
1410 * @param tens [input] the \c Tenseur_sym of valence 2
1411 * @param metre [input] the metric used to raise or lower the indices
1412 *
1413 * @return The traceless part of the input \c Tenseur_sym
1414 */
1415 Tenseur_sym sans_trace(const Tenseur_sym& tens, const Metrique& metre) ;
1416
1417 /** @} */
1418
1419
1420
1421 /**
1422 * \defgroup tsym_mat Tenseur_sym mathematics
1423 * \ingroup (otens)
1424 *
1425 * @{
1426 */
1427 Tenseur_sym operator+(const Tenseur_sym& ) ; ///< + Tenseur_sym
1428 Tenseur_sym operator-(const Tenseur_sym& ) ; ///< \c - Tenseur_sym
1429
1430 /// Tenseur_sym + Tenseur_sym
1431 Tenseur_sym operator+(const Tenseur_sym&, const Tenseur_sym &) ;
1432
1433 /// Tenseur_sym - Tenseur_sym
1434 Tenseur_sym operator-(const Tenseur_sym &, const Tenseur_sym &) ;
1435
1436 /// Tenseur_sym * double
1437 Tenseur_sym operator*(const Tenseur_sym&, double ) ;
1438
1439 /// double * Tenseur_sym
1440 Tenseur_sym operator*(double, const Tenseur_sym& ) ;
1441
1442 /// Tenseur_sym * int
1443 Tenseur_sym operator*(const Tenseur_sym&, int ) ;
1444
1445 /// int * Tenseur_sym
1446 Tenseur_sym operator*(int, const Tenseur_sym& ) ;
1447
1448 /// Tenseur_sym / Tenseur (\c b must be a scalar)
1449 Tenseur_sym operator/(const Tenseur_sym& a, const Tenseur& b) ;
1450
1451 Tenseur_sym operator/(const Tenseur_sym&, double ) ; ///< Tenseur_sym / double
1452
1453 Tenseur_sym operator/(const Tenseur_sym&, int ) ; ///< Tenseur_sym / int
1454
1455 /** @} */
1456
1457
1458
1459
1460
1461 }
1462 #endif