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