metric_flat.C

00001 /*
00002  *  Definition of methods for the class Metric_flat.
00003  *
00004  */
00005 
00006 /*
00007  *   Copyright (c) 2003 Eric Gourgoulhon & Jerome Novak
00008  *
00009  *   Copyright (c) 1999-2001 Philippe Grandclement (for previous class Metrique)
00010  *
00011  *   This file is part of LORENE.
00012  *
00013  *   LORENE is free software; you can redistribute it and/or modify
00014  *   it under the terms of the GNU General Public License version 2
00015  *   as published by the Free Software Foundation.
00016  *
00017  *   LORENE is distributed in the hope that it will be useful,
00018  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  *   GNU General Public License for more details.
00021  *
00022  *   You should have received a copy of the GNU General Public License
00023  *   along with LORENE; if not, write to the Free Software
00024  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025  *
00026  */
00027 
00028 char metric_flat_C[] = "$Header: /cvsroot/Lorene/C++/Source/Metric/metric_flat.C,v 1.5 2005/01/12 16:03:32 j_novak Exp $" ;
00029 
00030 /*
00031  * $Id: metric_flat.C,v 1.5 2005/01/12 16:03:32 j_novak Exp $
00032  * $Log: metric_flat.C,v $
00033  * Revision 1.5  2005/01/12 16:03:32  j_novak
00034  * We initialize the covariant representation of a flat metric, to avoid any
00035  * possible problem when building a general metric from a flat one.
00036  *
00037  * Revision 1.4  2004/02/19 10:57:18  e_gourgoulhon
00038  * Methods cov() and con(): set the spectral bases to the standard ones
00039  * after the initialization of p_met_cov and p_met_con.
00040  *
00041  * Revision 1.3  2003/12/30 23:07:29  e_gourgoulhon
00042  * Suppression of virtual methods fait_* : the actual computations
00043  *      are now performed via the virtual methods con(), cov(), connect(),
00044  *      ricci(), ricci_scal(), determinant().
00045  *
00046  * Revision 1.2  2003/10/11 14:40:39  e_gourgoulhon
00047  * Suppressed declaration of unusued argument in method operator=.
00048  *
00049  * Revision 1.1  2003/10/06 15:30:33  j_novak
00050  * Defined methods for flat metric.
00051  *
00052  *
00053  *
00054  * $Header: /cvsroot/Lorene/C++/Source/Metric/metric_flat.C,v 1.5 2005/01/12 16:03:32 j_novak Exp $
00055  *
00056  */
00057 
00058 // C headers
00059 #include<stdlib.h>
00060 
00061 // Lorene headers
00062 #include "metric.h"
00063 #include "utilitaires.h"
00064 
00065                     //-----------------//
00066                     //  Constructors   //
00067                     //-----------------//
00068 
00069 Metric_flat::Metric_flat(const Map& mpi, const Base_vect& triadi) :
00070   Metric(mpi), triad(&triadi) {
00071 
00072     cov() ; //## to avoid problems when initializing general metrics
00073             //## to flat ones. Might be improved??
00074   
00075 }
00076   
00077 
00078 Metric_flat::Metric_flat(const Metric_flat& meti) : Metric(meti), 
00079 triad(meti.triad) {
00080 
00081 
00082 }
00083 
00084 Metric_flat::Metric_flat(const Map& mpi, FILE* fd) : Metric(mpi, fd) {
00085 
00086   cout << "Metric_flat::Metric_flat(FILE*) : not implemented yet!" << endl ;
00087 
00088   abort() ;
00089 }
00090 
00091 
00092                     //---------------//
00093                     //  Destructor   //
00094                     //---------------//
00095 
00096 Metric_flat::~Metric_flat() {
00097 
00098 }
00099 
00100 
00101                     //-----------------------//
00102                     // Mutators / assignment //
00103                     //-----------------------//
00104 
00105 void Metric_flat::operator=(const Metric_flat& meti) {
00106 
00107   Metric::operator=(meti) ;
00108 
00109   triad = meti.triad ;
00110 }
00111 
00112 void Metric_flat::operator=(const Sym_tensor& ) {
00113   
00114   cout << "Metric_flat::operator=(const Sym_tensor& ) :" << '\n' ;
00115   cout << "Error: a flat metric should not be specified" << '\n' ;
00116   cout << "by a symmetric tensor!" << endl ;
00117 
00118   abort() ;
00119 }
00120   
00121 
00122             //----------------//
00123             //   Accessors    //
00124             //----------------//
00125 
00126 
00127 const Sym_tensor& Metric_flat::cov() const {
00128   
00129     if (p_met_cov == 0x0) {   // a new computation is necessary
00130 
00131         p_met_cov = new Sym_tensor(*mp, COV, *triad) ;
00132 
00133         p_met_cov->set(1,1) = 1 ; 
00134         p_met_cov->set(1,2) = 0 ; 
00135         p_met_cov->set(1,3) = 0 ; 
00136         p_met_cov->set(2,2) = 1 ; 
00137         p_met_cov->set(2,3) = 0 ; 
00138         p_met_cov->set(3,3) = 1 ; 
00139         
00140         p_met_cov->std_spectral_base() ; 
00141     }
00142 
00143     return *p_met_cov ; 
00144 }
00145 
00146 const Sym_tensor& Metric_flat::con() const {
00147   
00148     if (p_met_con == 0x0) {   // a new computation is necessary
00149   
00150         p_met_con = new Sym_tensor(*mp, CON, *triad) ;
00151 
00152         p_met_con->set(1,1) = 1 ; 
00153         p_met_con->set(1,2) = 0 ; 
00154         p_met_con->set(1,3) = 0 ; 
00155         p_met_con->set(2,2) = 1 ; 
00156         p_met_con->set(2,3) = 0 ; 
00157         p_met_con->set(3,3) = 1 ; 
00158 
00159         p_met_con->std_spectral_base() ; 
00160 
00161     }
00162 
00163 
00164     return *p_met_con ; 
00165 }
00166 
00167 
00168 const Connection& Metric_flat::connect() const {
00169 
00170     if (p_connect == 0x0) {   // a new computation is necessary
00171     
00172         const Base_vect_spher* bvs =
00173             dynamic_cast<const Base_vect_spher*>(triad) ;
00174   
00175         const Base_vect_cart* bvc =
00176             dynamic_cast<const Base_vect_cart*>(triad) ;
00177 
00178         if (bvs != 0x0) {
00179             assert (bvc == 0x0) ;
00180             p_connect = new Connection_fspher(*mp, *bvs) ;
00181         }
00182         else {
00183             assert(bvc != 0x0) ;
00184             p_connect = new Connection_fcart(*mp, *bvc) ;
00185         }
00186     }
00187 
00188     return *p_connect ; 
00189 
00190 }
00191 
00192 
00193 
00194 const Scalar& Metric_flat::ricci_scal() const {
00195 
00196     if (p_ricci_scal == 0x0) {   // a new computation is necessary
00197 
00198         p_ricci_scal = new Scalar(*mp) ;
00199         p_ricci_scal->set_etat_zero() ;
00200     }
00201 
00202     return *p_ricci_scal  ; 
00203 
00204 }
00205 
00206 
00207 const Scalar& Metric_flat::determinant() const {
00208 
00209     if (p_determinant == 0x0) {   // a new computation is necessary
00210 
00211         p_determinant = new Scalar(*mp) ;
00212         p_determinant->set_etat_one() ;
00213     }
00214 
00215     return *p_determinant ; 
00216 }
00217 
00218 
00219                 //---------//
00220                 // Outputs //
00221                 //---------//
00222 
00223  
00224 void Metric_flat::sauve(FILE* ) const {
00225 
00226   cout << "Metric_flat::sauve(FILE*) : not implemented yet!" << endl ;
00227 
00228   abort() ; //## What to do with the  triad ... ?
00229 
00230 }
00231 
00232 
00233 
00234 ostream& Metric_flat::operator>>(ostream& ost) const {
00235 
00236   ost << '\n' ;
00237 
00238   ost << "Flat metric in an orthonormal triad" << '\n' ;
00239   ost << "-----------------------------------" << '\n' ;
00240   ost << '\n' ;
00241 
00242   ost << *triad ;
00243 
00244   ost << endl ;
00245   return ost ;
00246 }
00247 

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