tensor_sym_calculus.C

00001 /*
00002  *  Tensor calculus for class Tensor_sym
00003  *
00004  *
00005  */
00006 
00007 /*
00008  *   Copyright (c) 2004 Eric Gourgoulhon & Jerome Novak
00009  *
00010  *   Copyright (c) 1999-2001 Philippe Grandclement (for preceding class Tenseur)
00011  *
00012  *   This file is part of LORENE.
00013  *
00014  *   LORENE is free software; you can redistribute it and/or modify
00015  *   it under the terms of the GNU General Public License as published by
00016  *   the Free Software Foundation; either version 2 of the License, or
00017  *   (at your option) any later version.
00018  *
00019  *   LORENE is distributed in the hope that it will be useful,
00020  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022  *   GNU General Public License for more details.
00023  *
00024  *   You should have received a copy of the GNU General Public License
00025  *   along with LORENE; if not, write to the Free Software
00026  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00027  *
00028  */
00029 
00030 
00031 char tensor_sym_calculus_C[] = "$Header: /cvsroot/Lorene/C++/Source/Tensor/tensor_sym_calculus.C,v 1.3 2004/02/26 22:50:33 e_gourgoulhon Exp $" ;
00032 
00033 /*
00034  * $Id: tensor_sym_calculus.C,v 1.3 2004/02/26 22:50:33 e_gourgoulhon Exp $
00035  * $Log: tensor_sym_calculus.C,v $
00036  * Revision 1.3  2004/02/26 22:50:33  e_gourgoulhon
00037  * Added methods derive_cov, derive_con and derive_lie.
00038  *
00039  * Revision 1.2  2004/01/30 12:44:53  e_gourgoulhon
00040  * Added Tensor_sym operator*(const Tensor_sym&, const Tensor_sym& ).
00041  *
00042  * Revision 1.1  2004/01/08 09:22:40  e_gourgoulhon
00043  * First version.
00044  *
00045  *
00046  * $Header: /cvsroot/Lorene/C++/Source/Tensor/tensor_sym_calculus.C,v 1.3 2004/02/26 22:50:33 e_gourgoulhon Exp $
00047  *
00048  */
00049 
00050 // Headers C
00051 #include <stdlib.h>
00052 #include <assert.h>
00053 #include <math.h>
00054 
00055 // Headers Lorene
00056 #include "tensor.h"
00057 
00058 // Tensorial product
00059 //------------------
00060 
00061 Tensor_sym operator*(const Tensor_sym& t1, const Tensor& t2) {
00062    
00063     assert (t1.mp == t2.mp) ;
00064     
00065     int val_res = t1.valence + t2.valence ;
00066      
00067     Itbl tipe(val_res) ;
00068   
00069     for (int i=0 ; i<t1.valence ; i++)
00070         tipe.set(i) = t1.type_indice(i) ;
00071     for (int i=0 ; i<t2.valence ; i++)
00072         tipe.set(i+t1.valence) = t2.type_indice(i) ;
00073     
00074     
00075     const Base_vect* triad_res = t1.get_triad() ; 
00076     
00077     if ( t2.valence != 0 ) {
00078         assert ( *(t2.get_triad()) == *triad_res ) ;
00079     }
00080     
00081     Tensor_sym res(*t1.mp, val_res, tipe, *triad_res, t1.sym_index1(),
00082                     t1.sym_index2()) ;
00083     
00084     Itbl jeux_indice_t1(t1.valence) ;
00085     Itbl jeux_indice_t2(t2.valence) ;
00086         
00087     for (int i=0 ; i<res.n_comp ; i++) {
00088         Itbl jeux_indice_res(res.indices(i)) ;
00089         for (int j=0 ; j<t1.valence ; j++)
00090             jeux_indice_t1.set(j) = jeux_indice_res(j) ;
00091         for (int j=0 ; j<t2.valence ; j++)
00092             jeux_indice_t2.set(j) = jeux_indice_res(j+t1.valence) ;
00093     
00094         res.set(jeux_indice_res) = t1(jeux_indice_t1)*t2(jeux_indice_t2) ;
00095     }
00096     
00097     return res ;
00098 }
00099 
00100 
00101 Tensor_sym operator*(const Tensor& t1, const Tensor_sym& t2) {
00102    
00103     assert (t1.mp == t2.mp) ;
00104     
00105     int val_res = t1.valence + t2.valence ;
00106      
00107     Itbl tipe(val_res) ;
00108   
00109     for (int i=0 ; i<t1.valence ; i++)
00110         tipe.set(i) = t1.type_indice(i) ;
00111     for (int i=0 ; i<t2.valence ; i++)
00112         tipe.set(i+t1.valence) = t2.type_indice(i) ;
00113     
00114     
00115     const Base_vect* triad_res = t2.get_triad() ; 
00116     
00117     if ( t1.valence != 0 ) {
00118         assert ( *(t1.get_triad()) == *triad_res ) ;
00119     }
00120     
00121     int ids1 = t2.sym_index1() + t1.valence ; // symmetry index 1 of the result
00122     int ids2 = t2.sym_index2() + t1.valence ; // symmetry index 2 of the result
00123 
00124     Tensor_sym res(*t2.mp, val_res, tipe, *triad_res, ids1, ids2) ;
00125     
00126     Itbl jeux_indice_t1(t1.valence) ;
00127     Itbl jeux_indice_t2(t2.valence) ;
00128         
00129     for (int i=0 ; i<res.n_comp ; i++) {
00130         Itbl jeux_indice_res(res.indices(i)) ;
00131         for (int j=0 ; j<t1.valence ; j++)
00132             jeux_indice_t1.set(j) = jeux_indice_res(j) ;
00133         for (int j=0 ; j<t2.valence ; j++)
00134             jeux_indice_t2.set(j) = jeux_indice_res(j+t1.valence) ;
00135     
00136         res.set(jeux_indice_res) = t1(jeux_indice_t1)*t2(jeux_indice_t2) ;
00137     }
00138     
00139     return res ;
00140 }
00141 
00142 
00143 
00144 Tensor_sym operator*(const Tensor_sym& t1, const Tensor_sym& t2) {
00145    
00146     assert (t1.mp == t2.mp) ;
00147     
00148     int val_res = t1.valence + t2.valence ;
00149      
00150     Itbl tipe(val_res) ;
00151   
00152     for (int i=0 ; i<t1.valence ; i++)
00153         tipe.set(i) = t1.type_indice(i) ;
00154     for (int i=0 ; i<t2.valence ; i++)
00155         tipe.set(i+t1.valence) = t2.type_indice(i) ;
00156     
00157     
00158     const Base_vect* triad_res = t1.get_triad() ; 
00159     
00160     assert ( *(t2.get_triad()) == *triad_res ) ;
00161     
00162     Tensor_sym res(*t1.mp, val_res, tipe, *triad_res, t1.sym_index1(),
00163                     t1.sym_index2()) ;
00164     
00165     Itbl jeux_indice_t1(t1.valence) ;
00166     Itbl jeux_indice_t2(t2.valence) ;
00167         
00168     for (int i=0 ; i<res.n_comp ; i++) {
00169         Itbl jeux_indice_res(res.indices(i)) ;
00170         for (int j=0 ; j<t1.valence ; j++)
00171             jeux_indice_t1.set(j) = jeux_indice_res(j) ;
00172         for (int j=0 ; j<t2.valence ; j++)
00173             jeux_indice_t2.set(j) = jeux_indice_res(j+t1.valence) ;
00174     
00175         res.set(jeux_indice_res) = t1(jeux_indice_t1)*t2(jeux_indice_t2) ;
00176     }
00177     
00178     return res ;
00179 }
00180 
00181                     //--------------------------//
00182                     //  Covariant derivatives   //
00183                     //--------------------------//
00184 
00185 const Tensor_sym& Tensor_sym::derive_cov(const Metric& gam) const {
00186   
00187     const Tensor_sym* p_resu = 
00188         dynamic_cast<const Tensor_sym*>( &(Tensor::derive_cov(gam)) ) ;
00189 
00190     assert(p_resu != 0x0) ;
00191 
00192     return *p_resu ;
00193   
00194 }
00195 
00196 
00197 const Tensor_sym& Tensor_sym::derive_con(const Metric& gam) const {
00198   
00199     const Tensor_sym* p_resu = 
00200         dynamic_cast<const Tensor_sym*>( &(Tensor::derive_con(gam)) ) ;
00201 
00202     assert(p_resu != 0x0) ;
00203 
00204     return *p_resu ;
00205   
00206 }
00207 
00208                     //--------------------------//
00209                     //       Lie derivative     //
00210                     //--------------------------//
00211 
00212 Tensor_sym Tensor_sym::derive_lie(const Vector& vv) const {
00213 
00214     Tensor_sym resu(*mp, valence, type_indice, *triad, id_sym1, id_sym2) ; 
00215     
00216     compute_derive_lie(vv, resu) ;
00217     
00218     return resu ; 
00219     
00220 }
00221 
00222 
00223 
00224 
00225 
00226 
00227 
00228 
00229 
00230 
00231 
00232 
00233 
00234 
00235 
00236 
00237 
00238  

Generated on Tue Feb 7 01:35:21 2012 for LORENE by  doxygen 1.4.6