metric_flat.C
/*
* 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 ;
}
}
Lorene::Base_vect_cart
Cartesian vectorial bases (triads).
Definition base_vect.h:201
Lorene::Base_vect_spher
Spherical orthonormal vectorial bases (triads).
Definition base_vect.h:308
Lorene::Base_vect
Vectorial bases (triads) with respect to which the tensorial components are defined.
Definition base_vect.h:105
Lorene::Connection_fcart
Class Connection_fcart.
Definition connection.h:546
Lorene::Connection_fspher
Class Connection_fspher.
Definition connection.h:452
Lorene::Connection
Class Connection.
Definition connection.h:113
Lorene::Metric_flat::connect
virtual const Connection & connect() const
Returns the connection.
Definition metric_flat.C:175
Lorene::Metric_flat::~Metric_flat
virtual ~Metric_flat()
Destructor.
Definition metric_flat.C:103
Lorene::Metric_flat::Metric_flat
Metric_flat(const Map &, const Base_vect &)
Standard constructor.
Definition metric_flat.C:76
Lorene::Metric_flat::ricci_scal
virtual const Scalar & ricci_scal() const
Returns the Ricci scalar.
Definition metric_flat.C:201
Lorene::Metric_flat::con
virtual const Sym_tensor & con() const
Read-only access to the contravariant representation.
Definition metric_flat.C:153
Lorene::Metric_flat::cov
virtual const Sym_tensor & cov() const
Read-only access to the covariant representation.
Definition metric_flat.C:134
Lorene::Metric_flat::sauve
virtual void sauve(FILE *) const
Save in a file.
Definition metric_flat.C:231
Lorene::Metric_flat::operator=
void operator=(const Metric_flat &)
Assignment to another Metric_flat.
Definition metric_flat.C:112
Lorene::Metric_flat::triad
const Base_vect * triad
Vectorial basis (triad) with respect to which the components of the flat metric are defined.
Definition metric.h:270
Lorene::Metric_flat::operator>>
virtual ostream & operator>>(ostream &) const
Operator >> (virtual function called by the operator <<).
Definition metric_flat.C:241
Lorene::Metric_flat::determinant
virtual const Scalar & determinant() const
Returns the determinant.
Definition metric_flat.C:214
Lorene::Metric::Metric
Metric(const Sym_tensor &tens)
Standard constructor from a Sym_tensor .
Definition metric.C:104
Lorene::Metric::mp
const Map *const mp
Reference mapping.
Definition metric.h:95
Lorene::Metric::p_met_con
Sym_tensor * p_met_con
Pointer on the covariant representation.
Definition metric.h:105
Lorene::Metric::p_met_cov
Sym_tensor * p_met_cov
Pointer on the contravariant representation.
Definition metric.h:100
Lorene::Metric::p_determinant
Scalar * p_determinant
Pointer on the determinant.
Definition metric.h:132
Lorene::Metric::operator=
void operator=(const Metric &met)
Assignment to another Metric.
Definition metric.C:220
Lorene::Metric::p_ricci_scal
Scalar * p_ricci_scal
Pointer on the Ricci scalar.
Definition metric.h:119
Lorene::Metric::p_connect
Connection * p_connect
Connection associated with the metric.
Definition metric.h:112
Lorene::Scalar
Tensor field of valence 0 (or component of a tensorial field).
Definition scalar.h:387
Lorene::Sym_tensor
Class intended to describe valence-2 symmetric tensors.
Definition sym_tensor.h:223
Lorene
Lorene prototypes.
Definition app_hor.h:64
Lorene::Map
Map(const Mg3d &)
Constructor from a multi-domain 3D grid.
Definition map.C:139