1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
|
/*
* Definition of methods for the class Metric_flat.
*
*/
/*
* Copyright (c) 2003 Eric Gourgoulhon & Jerome Novak
*
* Copyright (c) 1999-2001 Philippe Grandclement (for previous class Metrique)
*
* This file is part of LORENE.
*
* LORENE is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* LORENE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LORENE; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
char metric_flat_C[] = "$Header: /cvsroot/Lorene/C++/Source/Metric/metric_flat.C,v 1.7 2014/10/13 08:53:07 j_novak Exp $" ;
/*
* $Id: metric_flat.C,v 1.7 2014/10/13 08:53:07 j_novak Exp $
* $Log: metric_flat.C,v $
* Revision 1.7 2014/10/13 08:53:07 j_novak
* Lorene classes and functions now belong to the namespace Lorene.
*
* Revision 1.6 2014/10/06 15:13:14 j_novak
* Modified #include directives to use c++ syntax.
*
* Revision 1.5 2005/01/12 16:03:32 j_novak
* We initialize the covariant representation of a flat metric, to avoid any
* possible problem when building a general metric from a flat one.
*
* Revision 1.4 2004/02/19 10:57:18 e_gourgoulhon
* Methods cov() and con(): set the spectral bases to the standard ones
* after the initialization of p_met_cov and p_met_con.
*
* Revision 1.3 2003/12/30 23:07:29 e_gourgoulhon
* Suppression of virtual methods fait_* : the actual computations
* are now performed via the virtual methods con(), cov(), connect(),
* ricci(), ricci_scal(), determinant().
*
* Revision 1.2 2003/10/11 14:40:39 e_gourgoulhon
* Suppressed declaration of unusued argument in method operator=.
*
* Revision 1.1 2003/10/06 15:30:33 j_novak
* Defined methods for flat metric.
*
*
*
* $Header: /cvsroot/Lorene/C++/Source/Metric/metric_flat.C,v 1.7 2014/10/13 08:53:07 j_novak Exp $
*
*/
// C headers
#include <cstdlib>
// Lorene headers
#include "metric.h"
#include "utilitaires.h"
//-----------------//
// Constructors //
//-----------------//
namespace Lorene {
Metric_flat::Metric_flat(const Map& mpi, const Base_vect& triadi) :
Metric(mpi), triad(&triadi) {
cov() ; //## to avoid problems when initializing general metrics
//## to flat ones. Might be improved??
}
Metric_flat::Metric_flat(const Metric_flat& meti) : Metric(meti),
triad(meti.triad) {
}
Metric_flat::Metric_flat(const Map& mpi, FILE* fd) : Metric(mpi, fd) {
cout << "Metric_flat::Metric_flat(FILE*) : not implemented yet!" << endl ;
abort() ;
}
//---------------//
// Destructor //
//---------------//
Metric_flat::~Metric_flat() {
}
//-----------------------//
// Mutators / assignment //
//-----------------------//
void Metric_flat::operator=(const Metric_flat& meti) {
Metric::operator=(meti) ;
triad = meti.triad ;
}
void Metric_flat::operator=(const Sym_tensor& ) {
cout << "Metric_flat::operator=(const Sym_tensor& ) :" << '\n' ;
cout << "Error: a flat metric should not be specified" << '\n' ;
cout << "by a symmetric tensor!" << endl ;
abort() ;
}
//----------------//
// Accessors //
//----------------//
const Sym_tensor& Metric_flat::cov() const {
if (p_met_cov == 0x0) { // a new computation is necessary
p_met_cov = new Sym_tensor(*mp, COV, *triad) ;
p_met_cov->set(1,1) = 1 ;
p_met_cov->set(1,2) = 0 ;
p_met_cov->set(1,3) = 0 ;
p_met_cov->set(2,2) = 1 ;
p_met_cov->set(2,3) = 0 ;
p_met_cov->set(3,3) = 1 ;
p_met_cov->std_spectral_base() ;
}
return *p_met_cov ;
}
const Sym_tensor& Metric_flat::con() const {
if (p_met_con == 0x0) { // a new computation is necessary
p_met_con = new Sym_tensor(*mp, CON, *triad) ;
p_met_con->set(1,1) = 1 ;
p_met_con->set(1,2) = 0 ;
p_met_con->set(1,3) = 0 ;
p_met_con->set(2,2) = 1 ;
p_met_con->set(2,3) = 0 ;
p_met_con->set(3,3) = 1 ;
p_met_con->std_spectral_base() ;
}
return *p_met_con ;
}
const Connection& Metric_flat::connect() const {
if (p_connect == 0x0) { // a new computation is necessary
const Base_vect_spher* bvs =
dynamic_cast<const Base_vect_spher*>(triad) ;
const Base_vect_cart* bvc =
dynamic_cast<const Base_vect_cart*>(triad) ;
if (bvs != 0x0) {
assert (bvc == 0x0) ;
p_connect = new Connection_fspher(*mp, *bvs) ;
}
else {
assert(bvc != 0x0) ;
p_connect = new Connection_fcart(*mp, *bvc) ;
}
}
return *p_connect ;
}
const Scalar& Metric_flat::ricci_scal() const {
if (p_ricci_scal == 0x0) { // a new computation is necessary
p_ricci_scal = new Scalar(*mp) ;
p_ricci_scal->set_etat_zero() ;
}
return *p_ricci_scal ;
}
const Scalar& Metric_flat::determinant() const {
if (p_determinant == 0x0) { // a new computation is necessary
p_determinant = new Scalar(*mp) ;
p_determinant->set_etat_one() ;
}
return *p_determinant ;
}
//---------//
// Outputs //
//---------//
void Metric_flat::sauve(FILE* ) const {
cout << "Metric_flat::sauve(FILE*) : not implemented yet!" << endl ;
abort() ; //## What to do with the triad ... ?
}
ostream& Metric_flat::operator>>(ostream& ost) const {
ost << '\n' ;
ost << "Flat metric in an orthonormal triad" << '\n' ;
ost << "-----------------------------------" << '\n' ;
ost << '\n' ;
ost << *triad ;
ost << endl ;
return ost ;
}
}
|