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