LORENE
sym_tensor.C
1/*
2 * Methods of class Sym_tensor
3 *
4 * (see file tensor.h for documentation)
5 *
6 */
7
8/*
9 * Copyright (c) 2003-2004 Eric Gourgoulhon & Jerome Novak
10 *
11 * Copyright (c) 1999-2001 Philippe Grandclement (Cmp version)
12 * Copyright (c) 2000-2001 Eric Gourgoulhon (Cmp version)
13 *
14 * This file is part of LORENE.
15 *
16 * LORENE is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * LORENE is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with LORENE; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 *
30 */
31
32
33char sym_tensor_C[] = "$Header: /cvsroot/Lorene/C++/Source/Tensor/sym_tensor.C,v 1.24 2014/10/13 08:53:43 j_novak Exp $" ;
34
35/*
36 * $Id: sym_tensor.C,v 1.24 2014/10/13 08:53:43 j_novak Exp $
37 * $Log: sym_tensor.C,v $
38 * Revision 1.24 2014/10/13 08:53:43 j_novak
39 * Lorene classes and functions now belong to the namespace Lorene.
40 *
41 * Revision 1.23 2014/10/06 15:13:19 j_novak
42 * Modified #include directives to use c++ syntax.
43 *
44 * Revision 1.22 2007/12/21 16:07:08 j_novak
45 * Methods to filter Tensor, Vector and Sym_tensor objects.
46 *
47 * Revision 1.21 2007/12/03 13:00:00 n_vasset
48 * Adjusting memory management for new member p_tilde_c
49 *
50 * Revision 1.20 2006/06/12 07:27:20 j_novak
51 * New members concerning A and tilde{B}, dealing with the transverse part of the
52 * Sym_tensor.
53 *
54 * Revision 1.19 2005/04/04 15:25:24 j_novak
55 * Added new members www, xxx, ttt and the associated methods.
56 *
57 * Revision 1.18 2005/04/01 14:28:32 j_novak
58 * Members p_eta and p_mu are now defined in class Sym_tensor.
59 *
60 * Revision 1.17 2004/03/30 14:01:19 j_novak
61 * Copy constructors and operator= now copy the "derived" members.
62 *
63 * Revision 1.16 2004/02/26 22:48:50 e_gourgoulhon
64 * -- Method divergence: call to Tensor::divergence and cast of the
65 * result.
66 * -- Added method derive_lie.
67 *
68 * Revision 1.15 2004/01/04 20:54:00 e_gourgoulhon
69 * Sym_tensor is now a derived class of Tensor_sym.
70 * Methods indices and position have been suppressed (they are now
71 * implemented at the Tensor_sym level).
72 *
73 * Revision 1.14 2003/12/30 23:09:47 e_gourgoulhon
74 * Change in methods derive_cov() and divergence() to take into account
75 * the change of name: Metric::get_connect() --> Metric::connect().
76 *
77 * Revision 1.13 2003/11/26 21:58:15 e_gourgoulhon
78 * Added new data member p_transverse and p_longit_pot.
79 * Modified the memory management consequently.
80 *
81 * Revision 1.12 2003/10/28 12:34:08 e_gourgoulhon
82 * Corrected bug in the copy constructor and constructor from Tensor:
83 * the cmp have already been created by the (special) Tensor constructor called
84 * by these constructors.
85 *
86 * Revision 1.11 2003/10/20 14:26:03 j_novak
87 * New assignement operators.
88 *
89 * Revision 1.10 2003/10/16 14:21:36 j_novak
90 * The calculation of the divergence of a Tensor is now possible.
91 *
92 * Revision 1.9 2003/10/13 13:52:39 j_novak
93 * Better managment of derived quantities.
94 *
95 * Revision 1.8 2003/10/11 16:47:10 e_gourgoulhon
96 * Suppressed the call to Ibtl::set_etat_qcq() after the construction
97 * of the Itbl's, thanks to the new property of the Itbl class.
98 *
99 * Revision 1.7 2003/10/07 09:56:59 j_novak
100 * method Sym_tensor::inverse() implemented (but not tested!)
101 *
102 * Revision 1.6 2003/10/06 13:58:48 j_novak
103 * The memory management has been improved.
104 * Implementation of the covariant derivative with respect to the exact Tensor
105 * type.
106 *
107 * Revision 1.5 2003/10/03 11:21:48 j_novak
108 * More methods for the class Metric
109 *
110 * Revision 1.4 2003/10/02 15:45:51 j_novak
111 * New class Metric
112 *
113 * Revision 1.3 2003/10/01 15:39:43 e_gourgoulhon
114 * Added assert to insure that both indices have the same type.
115 *
116 * Revision 1.2 2003/09/26 08:05:31 j_novak
117 * New class Vector.
118 *
119 * Revision 1.1 2003/09/25 13:37:40 j_novak
120 * Symmetric tensors of valence 2 are now implemented (not tested yet).
121 *
122 *
123 * $Header: /cvsroot/Lorene/C++/Source/Tensor/sym_tensor.C,v 1.24 2014/10/13 08:53:43 j_novak Exp $
124 *
125 */
126
127// Headers C
128#include <cstdlib>
129#include <cassert>
130#include <cmath>
131
132// Headers Lorene
133#include "metric.h"
134
135 //--------------//
136 // Constructors //
137 //--------------//
138
139// Standard constructor
140// --------------------
141namespace Lorene {
142Sym_tensor::Sym_tensor(const Map& map, const Itbl& tipe,
143 const Base_vect& triad_i)
144 : Tensor_sym(map, 2, tipe, triad_i, 0, 1) {
145
146 set_der_0x0() ;
147
148}
149
150// Standard constructor when all the indices are of the same type
151// --------------------------------------------------------------
152Sym_tensor::Sym_tensor(const Map& map, int tipe, const Base_vect& triad_i)
153 : Tensor_sym(map, 2, tipe, triad_i, 0, 1) {
154
155 set_der_0x0() ;
156}
157
158// Copy constructor
159// ----------------
160Sym_tensor::Sym_tensor(const Sym_tensor& source)
161 : Tensor_sym( source ) {
162
163 set_der_0x0() ;
164
165 for (int i_met = 0; i_met < N_MET_MAX; i_met++) {
166
167 if ( source.p_transverse[i_met] != 0x0 ) {
168 set_dependance( *source.met_depend[i_met] ) ;
169 int jp = get_place_met( *source.met_depend[i_met] ) ;
170 assert ((jp>=0) && (jp<N_MET_MAX)) ;
171 p_transverse[jp] =
172 new Sym_tensor_trans ( *source.p_transverse[i_met] ) ;
173 }
174
175 if ( source.p_longit_pot[i_met] != 0x0 ) {
176 set_dependance( *source.met_depend[i_met] ) ;
177 int jp = get_place_met( *source.met_depend[i_met] ) ;
178 assert ((jp>=0) && (jp<N_MET_MAX)) ;
179 p_longit_pot[jp] =
180 new Vector ( *source.p_longit_pot[i_met] ) ;
181 }
182 }
183 if (source.p_eta != 0x0) p_eta = new Scalar( *(source.p_eta) ) ;
184 if (source.p_mu != 0x0) p_mu = new Scalar( *(source.p_mu) ) ;
185 if (source.p_www != 0x0) p_www = new Scalar( *(source.p_www) ) ;
186 if (source.p_xxx != 0x0) p_xxx = new Scalar( *(source.p_xxx) ) ;
187
188}
189
190
191// Constructor from a Tensor
192// --------------------------
193Sym_tensor::Sym_tensor(const Tensor& source)
194 : Tensor_sym(*source.mp, 2, source.type_indice, *(source.triad),
195 0, 1) {
196
197 assert(source.valence == 2) ;
198
199 for (int ic=0 ; ic<n_comp ; ic++) {
200 int posi = source.position(indices(ic)) ;
201 *(cmp[ic]) = *(source.cmp[posi]) ;
202 }
203
204 set_der_0x0() ;
205}
206
207
208// Constructor from a file
209// -----------------------
210Sym_tensor::Sym_tensor(const Map& map, const Base_vect& triad_i, FILE* fd)
211 : Tensor_sym(map, triad_i, fd) {
212
213 assert (valence == 2) ;
214 assert (n_comp == 6) ;
215 set_der_0x0() ;
216}
217
218 //--------------//
219 // Destructor //
220 //--------------//
221
227
228
229
230 //--------------//
231 // Assignment //
232 //--------------//
233
235
237
238 del_deriv() ;
239
240 for (int i_met = 0; i_met < N_MET_MAX; i_met++) {
241
242 if ( source.p_transverse[i_met] != 0x0 ) {
243 set_dependance( *source.met_depend[i_met] ) ;
244 int jp = get_place_met( *source.met_depend[i_met] ) ;
245 assert ((jp>=0) && (jp<N_MET_MAX)) ;
246 p_transverse[jp] =
247 new Sym_tensor_trans ( *source.p_transverse[i_met] ) ;
248 }
249
250 if ( source.p_longit_pot[i_met] != 0x0 ) {
251 set_dependance( *source.met_depend[i_met] ) ;
252 int jp = get_place_met( *source.met_depend[i_met] ) ;
253 assert ((jp>=0) && (jp<N_MET_MAX)) ;
254 p_longit_pot[jp] =
255 new Vector ( *source.p_longit_pot[i_met] ) ;
256 }
257
258 }
259 if (source.p_eta != 0x0) p_eta = new Scalar( *(source.p_eta) ) ;
260 if (source.p_mu != 0x0) p_mu = new Scalar( *(source.p_mu) ) ;
261 if (source.p_www != 0x0) p_www = new Scalar( *(source.p_www) ) ;
262 if (source.p_xxx != 0x0) p_xxx = new Scalar( *(source.p_xxx) ) ;
263
264}
265
266
268
270
271 del_deriv() ;
272}
273
274
276
278
279 del_deriv() ;
280}
281
282 //-------------------//
283 // Memory managment //
284 //-------------------//
285
287
288 for (int i=0; i<N_MET_MAX; i++)
290
291 if (p_eta != 0x0) delete p_eta ;
292 if (p_mu != 0x0) delete p_mu ;
293 if (p_www != 0x0) delete p_www ;
294 if (p_xxx != 0x0) delete p_xxx ;
295 if (p_ttt != 0x0) delete p_ttt ;
296 if (p_aaa != 0x0) delete p_aaa ;
297 if (p_tilde_b != 0x0) delete p_tilde_b ;
298 if (p_tilde_c != 0x0) delete p_tilde_c ;
299
300 set_der_0x0() ;
302
303}
304
306
307 for (int i=0; i<N_MET_MAX; i++)
309 p_eta = 0x0 ;
310 p_mu = 0x0 ;
311 p_www = 0x0 ;
312 p_xxx = 0x0 ;
313 p_ttt = 0x0 ;
314 p_aaa = 0x0 ;
315 p_tilde_b = 0x0 ;
316 p_tilde_c = 0x0 ;
317}
318
319
321
322 assert( (j>=0) && (j<N_MET_MAX) ) ;
323
324 if (met_depend[j] != 0x0) {
325 if ( p_transverse[j] != 0x0) delete p_transverse[j] ;
326 if ( p_longit_pot[j] != 0x0) delete p_longit_pot[j] ;
327
329
331 }
332}
333
334
336
337 assert( (i>=0) && (i<N_MET_MAX) ) ;
338
339 p_transverse[i] = 0x0 ;
340 p_longit_pot[i] = 0x0 ;
341
342}
343
344
345 //----------------------------------//
346 // Computation of derived members //
347 //----------------------------------//
348
349const Vector& Sym_tensor::divergence(const Metric& gam) const {
350
351 const Vector* pvect =
352 dynamic_cast<const Vector*>( &(Tensor::divergence(gam)) ) ;
353
354 assert(pvect != 0x0) ;
355
356 return *pvect ;
357}
358
359
361
363
365
366 return resu ;
367
368}
369
370
371
373
374 //Le resultat :
375 Sym_tensor* res =
376 new Sym_tensor(*mp, -type_indice(0), *triad) ;
377
378 // le determinant :
379 Scalar determ1(*mp) ;
380 determ1 = double(1)/
381 (operator()(1, 1)*operator()(2, 2)*operator()(3, 3)
382 + operator()(1, 2)*operator()(2, 3)*operator()(1, 3)
383 + operator()(1, 3)*operator()(1, 2)*operator()(2, 3)
384 - operator()(1, 3)*operator()(2, 2)*operator()(1, 3)
385 - operator()(2, 3)*operator()(2, 3)*operator()(1, 1)
386 - operator()(3, 3)*operator()(1, 2)*operator()(1, 2) ) ;
387
388 int sgn ; // Le signe du co-facteur ...
389 int l_up, l_down, c_left, c_right ; // Coordonnees du cofacteur :
390
392
393 for (int i=1 ; i<=3 ; i++) {
394 sgn = 1 ;
395 for (int j=i ; j<=3 ; j++) {
396
397 switch (j) {
398
399 case 1 : {
400 c_left = 2 ;
401 c_right = 3 ;
402 break ;
403 }
404 case 2 : {
405 c_left = 1 ;
406 c_right = 3 ;
407 break ;
408 }
409 default : {
410 c_left = 1 ;
411 c_right = 2 ;
412 break ;
413 }
414 }
415
416 switch (i) {
417
418 case 1 : {
419 l_up = 2 ;
420 l_down = 3 ;
421 break ;
422 }
423 case 2 : {
424 l_up = 1 ;
425 l_down = 3 ;
426 break ;
427 }
428 default : {
429 l_up = 1 ;
430 l_down = 2 ;
431 break ;
432 }
433 }
434
437
438 res->set(i, j) = cofacteur ;
439 sgn *= -1 ;
440 }
441 }
442 return res ;
443
444}
445
447 double alpha) {
448 if( triad->identify() == (mp->get_bvect_cart()).identify() )
449 for (int i=0; i<n_comp; i++)
450 cmp[i]->exponential_filter_r(lzmin, lzmax, p, alpha) ;
451 else {
452 assert( triad->identify() == (mp->get_bvect_spher()).identify()) ;
453 Scalar srr_tmp = operator()(1,1) ;
454 srr_tmp.exponential_filter_r(lzmin, lzmax, p, alpha) ;
455 Scalar eta_tmp = eta() ;
456 eta_tmp.div_r() ; //## to change one day...
457 eta_tmp.exponential_filter_r(lzmin, lzmax, p, alpha) ;
458 Scalar mu_tmp = mu() ;
459 mu_tmp.div_r() ; //## to change one day...
460 mu_tmp.exponential_filter_r(lzmin, lzmax, p, alpha) ;
461 Scalar w_tmp = www() ;
462 w_tmp.exponential_filter_r(lzmin, lzmax, p, alpha) ;
463 Scalar x_tmp = xxx() ;
464 x_tmp.exponential_filter_r(lzmin, lzmax, p, alpha) ;
465 Scalar t_tmp = ttt() ;
466 t_tmp.exponential_filter_r(lzmin, lzmax, p, alpha) ;
468 }
469}
470
472 double alpha) {
473 if( triad->identify() == (mp->get_bvect_cart()).identify() )
474 for (int i=0; i<n_comp; i++)
476 else {
477 assert( triad->identify() == (mp->get_bvect_spher()).identify()) ;
478 Scalar srr_tmp = operator()(1,1) ;
479 srr_tmp.exponential_filter_ylm(lzmin, lzmax, p, alpha) ;
480 Scalar eta_tmp = eta() ;
481 eta_tmp.div_r() ; //## to change one day...
482 eta_tmp.exponential_filter_ylm(lzmin, lzmax, p, alpha) ;
483 Scalar mu_tmp = mu() ;
484 mu_tmp.div_r() ; //## to change one day...
485 mu_tmp.exponential_filter_ylm(lzmin, lzmax, p, alpha) ;
486 Scalar w_tmp = www() ;
487 w_tmp.exponential_filter_ylm(lzmin, lzmax, p, alpha) ;
488 Scalar x_tmp = xxx() ;
489 x_tmp.exponential_filter_ylm(lzmin, lzmax, p, alpha) ;
490 Scalar t_tmp = ttt() ;
491 t_tmp.exponential_filter_ylm(lzmin, lzmax, p, alpha) ;
493 }
494}
495}
Vectorial bases (triads) with respect to which the tensorial components are defined.
Definition base_vect.h:105
Time evolution with partial storage (*** under development ***).
Definition evolution.h:371
int position(int j) const
Gives the position in the arrays step, the_time and val corresponding to the time step j.
Definition evolution.C:273
Basic integer array class.
Definition itbl.h:122
Base class for coordinate mappings.
Definition map.h:670
Metric for tensor calculation.
Definition metric.h:90
Tensor field of valence 0 (or component of a tensorial field).
Definition scalar.h:387
Transverse symmetric tensors of rank 2.
Definition sym_tensor.h:608
Class intended to describe valence-2 symmetric tensors.
Definition sym_tensor.h:223
const Scalar & xxx() const
Gives the field X (see member p_xxx ).
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 sym_tensor.C:471
virtual void del_derive_met(int i) const
Logical destructor of the derivatives depending on the i-th element of met_depend specific to the cla...
Definition sym_tensor.C:320
Sym_tensor * inverse() const
Returns a pointer on the inverse of the Sym_tensor (seen as a matrix).
Definition sym_tensor.C:372
virtual void operator=(const Sym_tensor &a)
Assignment to another Sym_tensor.
Definition sym_tensor.C:234
Scalar * p_ttt
Field T defined as .
Definition sym_tensor.h:315
Scalar * p_aaa
Field A defined from X and insensitive to the longitudinal part of the Sym_tensor (only for ).
Definition sym_tensor.h:322
void set_der_met_0x0(int i) const
Sets all the i-th components of met_depend specific to the class Sym_tensor (p_transverse ,...
Definition sym_tensor.C:335
Scalar * p_tilde_b
Field defined from and h insensitive to the longitudinal part of the Sym_tensor.
Definition sym_tensor.h:334
Scalar * p_mu
Field such that the components of the tensor are written (has only meaning with spherical component...
Definition sym_tensor.h:274
Scalar * p_tilde_c
Field defined from and h insensitive to the longitudinal part of the Sym_tensor.
Definition sym_tensor.h:346
const Scalar & ttt() const
Gives the field T (see member p_ttt ).
virtual const Scalar & eta(Param *par=0x0) const
Gives the field (see member p_eta ).
const Scalar & www() const
Gives the field W (see member p_www ).
Sym_tensor_trans * p_transverse[N_MET_MAX]
Array of the transverse part of the tensor with respect to various metrics, transverse meaning diver...
Definition sym_tensor.h:239
const Scalar & mu(Param *par=0x0) const
Gives the field (see member p_mu ).
virtual void del_deriv() const
Deletes the derived quantities.
Definition sym_tensor.C:286
Scalar * p_eta
Field such that the components of the tensor are written (has only meaning with spherical component...
Definition sym_tensor.h:260
Scalar * p_xxx
Field X such that the components and of the tensor are written (has only meaning with spherical com...
Definition sym_tensor.h:312
Sym_tensor derive_lie(const Vector &v) const
Computes the Lie derivative of this with respect to some vector field v.
Definition sym_tensor.C:360
void set_auxiliary(const Scalar &trr, const Scalar &eta_over_r, const Scalar &mu_over_r, const Scalar &www, const Scalar &xxx, const Scalar &ttt)
Assigns the component and the derived members p_eta , p_mu , p_www, p_xxx and p_ttt ,...
void set_der_0x0() const
Sets the pointers on derived quantities to 0x0.
Definition sym_tensor.C:305
Scalar * p_www
Field W such that the components and of the tensor are written (has only meaning with spherical com...
Definition sym_tensor.h:293
virtual ~Sym_tensor()
Destructor.
Definition sym_tensor.C:222
Vector * p_longit_pot[N_MET_MAX]
Array of the vector potential of the longitudinal part of the tensor with respect to various metrics ...
Definition sym_tensor.h:246
const Vector & divergence(const Metric &) const
Returns the divergence of this with respect to a Metric .
Definition sym_tensor.C:349
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 sym_tensor.C:446
Symmetric tensors (with respect to two of their arguments).
Definition tensor.h:1037
Tensor handling.
Definition tensor.h:288
Tensor field of valence 1.
Definition vector.h:188
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
const Map *const mp
Mapping on which the numerical values at the grid points are defined.
Definition tensor.h:295
virtual Itbl indices(int pos) const
Returns the indices of a component given by its position in the array cmp .
Definition tensor_sym.C:310
virtual void operator=(const Tensor_sym &a)
Assignment to another Tensor_sym.
Definition tensor_sym.C:198
int get_place_met(const Metric &) const
Returns the position of the pointer on metre in the array met_depend .
Definition tensor.C:443
const Metric * met_depend[N_MET_MAX]
Array on the Metric 's which were used to compute derived quantities, like p_derive_cov ,...
Definition tensor.h:327
int valence
Valence of the tensor (0 = scalar, 1 = vector, etc...)
Definition tensor.h:298
const Scalar & operator()(const Itbl &ind) const
Returns the value of a component (read-only version).
Definition tensor.C:798
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
Scalar ** cmp
Array of size n_comp of pointers onto the components.
Definition tensor.h:315
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...
int n_comp
Number of stored components, depending on the symmetry.
Definition tensor.h:312
virtual void del_deriv() const
Deletes the derived quantities.
Definition tensor.C:398
const Tensor & divergence(const Metric &gam) const
Computes the divergence of this with respect to some metric .
Definition tensor.C:1055
Itbl type_indice
1D array of integers (class Itbl ) of size valence containing the type of each index: COV for a cov...
Definition tensor.h:310
const Base_vect * triad
Vectorial basis (triad) with respect to which the tensor components are defined.
Definition tensor.h:303
Lorene prototypes.
Definition app_hor.h:64