LORENE
tensor_sym_calculus.C
1/*
2 * Tensor calculus for class Tensor_sym
3 *
4 *
5 */
6
7/*
8 * Copyright (c) 2004 Eric Gourgoulhon & Jerome Novak
9 *
10 * Copyright (c) 1999-2001 Philippe Grandclement (for preceding class Tenseur)
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
31char tensor_sym_calculus_C[] = "$Header: /cvsroot/Lorene/C++/Source/Tensor/tensor_sym_calculus.C,v 1.5 2014/10/13 08:53:44 j_novak Exp $" ;
32
33/*
34 * $Id: tensor_sym_calculus.C,v 1.5 2014/10/13 08:53:44 j_novak Exp $
35 * $Log: tensor_sym_calculus.C,v $
36 * Revision 1.5 2014/10/13 08:53:44 j_novak
37 * Lorene classes and functions now belong to the namespace Lorene.
38 *
39 * Revision 1.4 2014/10/06 15:13:20 j_novak
40 * Modified #include directives to use c++ syntax.
41 *
42 * Revision 1.3 2004/02/26 22:50:33 e_gourgoulhon
43 * Added methods derive_cov, derive_con and derive_lie.
44 *
45 * Revision 1.2 2004/01/30 12:44:53 e_gourgoulhon
46 * Added Tensor_sym operator*(const Tensor_sym&, const Tensor_sym& ).
47 *
48 * Revision 1.1 2004/01/08 09:22:40 e_gourgoulhon
49 * First version.
50 *
51 *
52 * $Header: /cvsroot/Lorene/C++/Source/Tensor/tensor_sym_calculus.C,v 1.5 2014/10/13 08:53:44 j_novak Exp $
53 *
54 */
55
56// Headers C
57#include <cstdlib>
58#include <cassert>
59#include <cmath>
60
61// Headers Lorene
62#include "tensor.h"
63
64// Tensorial product
65//------------------
66
67namespace Lorene {
69
70 assert (t1.mp == t2.mp) ;
71
72 int val_res = t1.valence + t2.valence ;
73
75
76 for (int i=0 ; i<t1.valence ; i++)
77 tipe.set(i) = t1.type_indice(i) ;
78 for (int i=0 ; i<t2.valence ; i++)
79 tipe.set(i+t1.valence) = t2.type_indice(i) ;
80
81
82 const Base_vect* triad_res = t1.get_triad() ;
83
84 if ( t2.valence != 0 ) {
85 assert ( *(t2.get_triad()) == *triad_res ) ;
86 }
87
88 Tensor_sym res(*t1.mp, val_res, tipe, *triad_res, t1.sym_index1(),
89 t1.sym_index2()) ;
90
91 Itbl jeux_indice_t1(t1.valence) ;
92 Itbl jeux_indice_t2(t2.valence) ;
93
94 for (int i=0 ; i<res.n_comp ; i++) {
95 Itbl jeux_indice_res(res.indices(i)) ;
96 for (int j=0 ; j<t1.valence ; j++)
98 for (int j=0 ; j<t2.valence ; j++)
99 jeux_indice_t2.set(j) = jeux_indice_res(j+t1.valence) ;
100
102 }
103
104 return res ;
105}
106
107
109
110 assert (t1.mp == t2.mp) ;
111
112 int val_res = t1.valence + t2.valence ;
113
114 Itbl tipe(val_res) ;
115
116 for (int i=0 ; i<t1.valence ; i++)
117 tipe.set(i) = t1.type_indice(i) ;
118 for (int i=0 ; i<t2.valence ; i++)
119 tipe.set(i+t1.valence) = t2.type_indice(i) ;
120
121
122 const Base_vect* triad_res = t2.get_triad() ;
123
124 if ( t1.valence != 0 ) {
125 assert ( *(t1.get_triad()) == *triad_res ) ;
126 }
127
128 int ids1 = t2.sym_index1() + t1.valence ; // symmetry index 1 of the result
129 int ids2 = t2.sym_index2() + t1.valence ; // symmetry index 2 of the result
130
132
133 Itbl jeux_indice_t1(t1.valence) ;
134 Itbl jeux_indice_t2(t2.valence) ;
135
136 for (int i=0 ; i<res.n_comp ; i++) {
137 Itbl jeux_indice_res(res.indices(i)) ;
138 for (int j=0 ; j<t1.valence ; j++)
140 for (int j=0 ; j<t2.valence ; j++)
141 jeux_indice_t2.set(j) = jeux_indice_res(j+t1.valence) ;
142
144 }
145
146 return res ;
147}
148
149
150
152
153 assert (t1.mp == t2.mp) ;
154
155 int val_res = t1.valence + t2.valence ;
156
157 Itbl tipe(val_res) ;
158
159 for (int i=0 ; i<t1.valence ; i++)
160 tipe.set(i) = t1.type_indice(i) ;
161 for (int i=0 ; i<t2.valence ; i++)
162 tipe.set(i+t1.valence) = t2.type_indice(i) ;
163
164
165 const Base_vect* triad_res = t1.get_triad() ;
166
167 assert ( *(t2.get_triad()) == *triad_res ) ;
168
169 Tensor_sym res(*t1.mp, val_res, tipe, *triad_res, t1.sym_index1(),
170 t1.sym_index2()) ;
171
172 Itbl jeux_indice_t1(t1.valence) ;
173 Itbl jeux_indice_t2(t2.valence) ;
174
175 for (int i=0 ; i<res.n_comp ; i++) {
176 Itbl jeux_indice_res(res.indices(i)) ;
177 for (int j=0 ; j<t1.valence ; j++)
179 for (int j=0 ; j<t2.valence ; j++)
180 jeux_indice_t2.set(j) = jeux_indice_res(j+t1.valence) ;
181
183 }
184
185 return res ;
186}
187
188 //--------------------------//
189 // Covariant derivatives //
190 //--------------------------//
191
192const Tensor_sym& Tensor_sym::derive_cov(const Metric& gam) const {
193
194 const Tensor_sym* p_resu =
195 dynamic_cast<const Tensor_sym*>( &(Tensor::derive_cov(gam)) ) ;
196
197 assert(p_resu != 0x0) ;
198
199 return *p_resu ;
200
201}
202
203
204const Tensor_sym& Tensor_sym::derive_con(const Metric& gam) const {
205
206 const Tensor_sym* p_resu =
207 dynamic_cast<const Tensor_sym*>( &(Tensor::derive_con(gam)) ) ;
208
209 assert(p_resu != 0x0) ;
210
211 return *p_resu ;
212
213}
214
215 //--------------------------//
216 // Lie derivative //
217 //--------------------------//
218
220
222
224
225 return resu ;
226
227}
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246}
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
Basic integer array class.
Definition itbl.h:122
Metric for tensor calculation.
Definition metric.h:90
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
Base_val operator*(const Base_val &, const Base_val &)
This operator is used when calling multiplication or division of Valeur .
Tensor_sym derive_lie(const Vector &v) const
Computes the Lie derivative of this with respect to some vector field v.
const Tensor_sym & derive_cov(const Metric &gam) const
Returns the covariant derivative of this with respect to some metric .
const Map *const mp
Mapping on which the numerical values at the grid points are defined.
Definition tensor.h:295
const Tensor & derive_con(const Metric &gam) const
Returns the "contravariant" derivative of this with respect to some metric , by raising the last inde...
Definition tensor.C:1014
int id_sym1
Number of the first symmetric index (0<= id_sym1 < valence )
Definition tensor.h:1044
int valence
Valence of the tensor (0 = scalar, 1 = vector, etc...)
Definition tensor.h:298
int id_sym2
Number of the second symmetric index (id_sym1 < id_sym2 < valence )
Definition tensor.h:1049
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...
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...
const Tensor & derive_cov(const Metric &gam) const
Returns the covariant derivative of this with respect to some metric .
Definition tensor.C:1002
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