Debian Codegraph @

C++/Source/Metric/metric_flat.C

raw
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
85 Metric_flat::Metric_flat(const Metric_flat& meti) : Metric(meti),
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
103 Metric_flat::~Metric_flat() {
104
105 }
106
107
108 //-----------------------//
109 // Mutators / assignment //
110 //-----------------------//
111
112 void Metric_flat::operator=(const Metric_flat& meti) {
113
114 Metric::operator=(meti) ;
115
116 triad = meti.triad ;
117 }
118
119 void Metric_flat::operator=(const Sym_tensor& ) {
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
147 p_met_cov->std_spectral_base() ;
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
166 p_met_con->std_spectral_base() ;
167
168 }
169
170
171 return *p_met_con ;
172 }
173
174
175 const Connection& Metric_flat::connect() const {
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
201 const Scalar& Metric_flat::ricci_scal() const {
202
203 if (p_ricci_scal == 0x0) { // a new computation is necessary
204
205 p_ricci_scal = new Scalar(*mp) ;
206 p_ricci_scal->set_etat_zero() ;
207 }
208
209 return *p_ricci_scal ;
210
211 }
212
213
214 const Scalar& Metric_flat::determinant() const {
215
216 if (p_determinant == 0x0) { // a new computation is necessary
217
218 p_determinant = new Scalar(*mp) ;
219 p_determinant->set_etat_one() ;
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 }