| 1 |
/* |
| 2 |
* Methods of class Metconf |
| 3 |
* |
| 4 |
* (see file metconf.h for documentation) |
| 5 |
* |
| 6 |
*/ |
| 7 |
|
| 8 |
/* |
| 9 |
* Copyright (c) 2002 Jerome Novak |
| 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 as published by |
| 15 |
* the Free Software Foundation; either version 2 of the License, or |
| 16 |
* (at your option) any later version. |
| 17 |
* |
| 18 |
* LORENE is distributed in the hope that it will be useful, |
| 19 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 |
* GNU General Public License for more details. |
| 22 |
* |
| 23 |
* You should have received a copy of the GNU General Public License |
| 24 |
* along with LORENE; if not, write to the Free Software |
| 25 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 26 |
* |
| 27 |
*/ |
| 28 |
|
| 29 |
|
| 30 |
char metconf_C[] = "$Header: /cvsroot/Lorene/C++/Source/Metrique/metconf.C,v 1.9 2014/10/13 08:53:07 j_novak Exp $" ; |
| 31 |
|
| 32 |
/* |
| 33 |
* $Id: metconf.C,v 1.9 2014/10/13 08:53:07 j_novak Exp $ |
| 34 |
* $Log: metconf.C,v $ |
| 35 |
* Revision 1.9 2014/10/13 08:53:07 j_novak |
| 36 |
* Lorene classes and functions now belong to the namespace Lorene. |
| 37 |
* |
| 38 |
* Revision 1.8 2005/02/18 13:14:09 j_novak |
| 39 |
* Changing of malloc/free to new/delete + suppression of some unused variables |
| 40 |
* (trying to avoid compilation warnings). |
| 41 |
* |
| 42 |
* Revision 1.7 2003/06/20 14:47:50 f_limousin |
| 43 |
* Put some assert on poids on comments. |
| 44 |
* |
| 45 |
* Revision 1.6 2003/03/03 19:43:09 f_limousin |
| 46 |
* Add a new constructo from a tensor and a metric and put some assert into comments. |
| 47 |
* |
| 48 |
* Revision 1.5 2002/10/16 14:36:42 j_novak |
| 49 |
* Reorganization of #include instructions of standard C++, in order to |
| 50 |
* use experimental version 3 of gcc. |
| 51 |
* |
| 52 |
* Revision 1.4 2002/08/14 15:31:17 j_novak |
| 53 |
* The ZEC is now correctly treated in Metconf. A test code is added in |
| 54 |
* Codes/Test/Metrique |
| 55 |
* |
| 56 |
* Revision 1.3 2002/08/14 13:46:15 j_novak |
| 57 |
* Derived quantities of a Tenseur can now depend on several Metrique's |
| 58 |
* |
| 59 |
* Revision 1.2 2002/08/13 08:02:45 j_novak |
| 60 |
* Handling of spherical vector/tensor components added in the classes |
| 61 |
* Mg3d and Tenseur. Minor corrections for the class Metconf. |
| 62 |
* |
| 63 |
* Revision 1.1 2002/08/09 15:41:09 j_novak |
| 64 |
* New class Metconf added for conformal metric handling. |
| 65 |
* |
| 66 |
* |
| 67 |
* $Header: /cvsroot/Lorene/C++/Source/Metrique/metconf.C,v 1.9 2014/10/13 08:53:07 j_novak Exp $ |
| 68 |
* |
| 69 |
*/ |
| 70 |
|
| 71 |
// Headers C |
| 72 |
#include <cstdlib> |
| 73 |
#include <cassert> |
| 74 |
#include <cmath> |
| 75 |
|
| 76 |
// Headers Lorene |
| 77 |
#include "metconf.h" |
| 78 |
#include "utilitaires.h" |
| 79 |
|
| 80 |
namespace Lorene { |
| 81 |
|
| 82 |
//Constructeur standard (ne fait pas grand chose) : |
| 83 |
Metconf::Metconf (const Map& mapping, const Metrique& metric, const Metrique& |
| 84 |
metplat, bool jauge, bool plate) : |
| 85 |
Metrique(mapping, plate), gamij(&metric), fij(&metplat), dirac(jauge) { |
| 86 |
assert (metplat.is_flat()) ; |
| 87 |
assert(metplat.get_etat() != ETATNONDEF) ; |
| 88 |
assert(metplat.cov().get_poids() == 0.) ; |
| 89 |
// assert(metric.cov().get_poids() == 0.) ; |
| 90 |
// assert(metric.get_etat() != ETATNONDEF) ; |
| 91 |
// assert( *(metplat.cov().get_triad()) == *(metric.cov().get_triad()) ) ; |
| 92 |
set_der_0x0() ; |
| 93 |
} |
| 94 |
|
| 95 |
// COPY : |
| 96 |
Metconf::Metconf (const Metconf& source) : Metrique(source), |
| 97 |
gamij(source.gamij), |
| 98 |
fij(source.fij), |
| 99 |
dirac(source.dirac) { |
| 100 |
if (source.p_delta != 0x0) |
| 101 |
p_delta = new Tenseur_sym(*source.p_delta) ; |
| 102 |
else |
| 103 |
p_delta = 0x0 ; |
| 104 |
|
| 105 |
if (source.p_Hi != 0x0) |
| 106 |
p_Hi = new Tenseur(*source.p_Hi) ; |
| 107 |
else |
| 108 |
p_Hi = 0x0 ; |
| 109 |
} |
| 110 |
|
| 111 |
|
| 112 |
// Constructeur from Tensor d'ordre 2 symetrique : |
| 113 |
Metconf::Metconf (const Tenseur_sym& source, const Metrique& metplat, |
| 114 |
bool jauge, bool plate) : |
| 115 |
Metrique(source, plate), gamij(source.get_metric()), fij(&metplat), |
| 116 |
dirac(jauge) { |
| 117 |
|
| 118 |
assert(metplat.is_flat()) ; |
| 119 |
assert(metplat.get_etat() != ETATNONDEF) ; |
| 120 |
assert(metplat.cov().get_poids() == 0.) ; |
| 121 |
// assert(gamij->cov().get_poids() == 0.) ; |
| 122 |
assert(gamij->get_etat() != ETATNONDEF) ; |
| 123 |
assert( metplat.cov().get_triad()->identify() == |
| 124 |
gamij->cov().get_triad()->identify() ) ; |
| 125 |
//int tipe = source.get_type_indice(0) ; |
| 126 |
|
| 127 |
// if (tipe == CON) assert(source.get_poids() == 2./3.) ; |
| 128 |
//else assert(source.get_poids() == -2./3.) ; |
| 129 |
set_der_0x0() ; |
| 130 |
} |
| 131 |
|
| 132 |
// Constructeur from Tensor d'ordre 2 symetrique and a metric : |
| 133 |
Metconf::Metconf (const Tenseur_sym& source, const Metrique& metric, const Metrique& metplat, bool jauge, bool plate) : |
| 134 |
Metrique(source, plate), gamij(&metric), fij(&metplat), |
| 135 |
dirac(jauge) { |
| 136 |
|
| 137 |
assert(metplat.is_flat()) ; |
| 138 |
assert(metplat.get_etat() != ETATNONDEF) ; |
| 139 |
assert(metplat.cov().get_poids() == 0.) ; |
| 140 |
assert(gamij->cov().get_poids() == 0.) ; |
| 141 |
assert(gamij->get_etat() != ETATNONDEF) ; |
| 142 |
assert( metplat.cov().get_triad()->identify() == |
| 143 |
gamij->cov().get_triad()->identify() ) ; |
| 144 |
int tipe = source.get_type_indice(0) ; |
| 145 |
|
| 146 |
if (tipe == CON) assert(source.get_poids() == 2./3.) ; |
| 147 |
else assert(source.get_poids() == -2./3.) ; |
| 148 |
set_der_0x0() ; |
| 149 |
} |
| 150 |
|
| 151 |
|
| 152 |
// From a file and a mapping : |
| 153 |
Metconf::Metconf (const Map& mapping, const Base_vect& triad, const Metrique& |
| 154 |
metric, const Metrique& metplat, FILE* fd) : |
| 155 |
Metrique(mapping, triad, fd), gamij(&metric), fij(&metplat) { |
| 156 |
|
| 157 |
assert (metplat.is_flat()) ; |
| 158 |
assert(metplat.get_etat() != ETATNONDEF) ; |
| 159 |
assert(metplat.cov().get_poids() == 0.) ; |
| 160 |
assert(metric.cov().get_poids() == 0.) ; |
| 161 |
assert(metric.get_etat() != ETATNONDEF) ; |
| 162 |
assert( *(metplat.cov().get_triad()) == *(metric.cov().get_triad()) ) ; |
| 163 |
int jauge ; |
| 164 |
fread_be (&jauge, sizeof(int), 1, fd) ; |
| 165 |
dirac = jauge ; |
| 166 |
set_der_0x0() ; |
| 167 |
|
| 168 |
} |
| 169 |
|
| 170 |
//Destructor : |
| 171 |
Metconf::~Metconf() { |
| 172 |
del_deriv() ; |
| 173 |
} |
| 174 |
|
| 175 |
void Metconf::del_deriv() { |
| 176 |
if (p_delta != 0x0) |
| 177 |
delete p_delta ; |
| 178 |
|
| 179 |
if (p_Hi != 0x0) |
| 180 |
delete p_Hi ; |
| 181 |
|
| 182 |
Metrique::del_deriv() ; |
| 183 |
} |
| 184 |
|
| 185 |
void Metconf::set_der_0x0() { |
| 186 |
Metrique::set_der_0x0() ; |
| 187 |
p_delta = 0x0 ; |
| 188 |
p_Hi = 0x0 ; |
| 189 |
} |
| 190 |
|
| 191 |
//AFFECTATIONS : |
| 192 |
|
| 193 |
void Metconf::operator= (const Metconf& source) { |
| 194 |
|
| 195 |
Metrique::operator=(source) ; |
| 196 |
del_deriv() ; |
| 197 |
|
| 198 |
dirac = source.dirac ; |
| 199 |
gamij = source.gamij ; |
| 200 |
fij = source.fij ; |
| 201 |
if (source.etat == ETATZERO) |
| 202 |
set_etat_zero() ; |
| 203 |
else { |
| 204 |
if (source.p_delta != 0x0) |
| 205 |
p_delta = new Tenseur_sym (*source.p_delta) ; |
| 206 |
if (source.p_Hi != 0x0) |
| 207 |
p_Hi = new Tenseur(*source.p_Hi) ; |
| 208 |
} |
| 209 |
} |
| 210 |
|
| 211 |
|
| 212 |
void Metconf::operator= (const Tenseur_sym& source) { |
| 213 |
|
| 214 |
int tipe = source.get_type_indice(0) ; |
| 215 |
if (tipe == COV) assert(source.get_poids() == -2./3.) ; |
| 216 |
else assert(source.get_poids() == 2./3.) ; |
| 217 |
|
| 218 |
Metrique::operator=(source) ; |
| 219 |
gamij = source.get_metric() ; |
| 220 |
assert(gamij->cov().get_poids() == 0.) ; |
| 221 |
assert(gamij->get_etat() != ETATNONDEF) ; |
| 222 |
} |
| 223 |
|
| 224 |
void Metconf::set_dirac_gauge(bool gauge) { |
| 225 |
dirac = gauge ; |
| 226 |
del_deriv() ; |
| 227 |
} |
| 228 |
|
| 229 |
void Metconf::set_flat_metric(const Metrique& metflat) { |
| 230 |
assert(metflat.is_flat()) ; |
| 231 |
assert(metflat.get_etat() != ETATNONDEF) ; |
| 232 |
assert( *(metflat.cov().get_triad()) == *(gamij->cov().get_triad()) ) ; |
| 233 |
fij = &metflat ; |
| 234 |
del_deriv() ; |
| 235 |
} |
| 236 |
|
| 237 |
void Metconf::sauve(FILE* fd) const { |
| 238 |
|
| 239 |
Metrique::sauve(fd) ; |
| 240 |
int jauge = dirac ; |
| 241 |
fwrite_be (&jauge, sizeof(int), 1, fd) ; |
| 242 |
|
| 243 |
} |
| 244 |
|
| 245 |
// Le calcul des Delta's |
| 246 |
void Metconf::fait_delta() const { |
| 247 |
|
| 248 |
assert (etat != ETATNONDEF) ; |
| 249 |
if (p_delta != 0x0) |
| 250 |
return ; |
| 251 |
|
| 252 |
else { // Calcul a faire : |
| 253 |
Itbl tipe (3) ; |
| 254 |
tipe.set_etat_qcq() ; |
| 255 |
tipe.set(0) = CON ; tipe.set(1) = COV ; tipe.set(2) = COV ; |
| 256 |
p_delta = new Tenseur_sym (*mp, 3, tipe, mp->get_bvect_cart() ) ; |
| 257 |
bool cart = cov().get_triad()->identify() == |
| 258 |
(mp->get_bvect_cart()).identify() ; |
| 259 |
|
| 260 |
if ( (etat == ETATZERO) || (plat && cart) ) |
| 261 |
p_delta->set_etat_zero() ; |
| 262 |
else { |
| 263 |
p_delta->set_etat_qcq() ; |
| 264 |
assert(fij != 0x0) ; |
| 265 |
Tenseur t1 (contract(con(), 1, cov().derive_cov(*fij), 2)) ; |
| 266 |
Tenseur t2 (contract(con(), 1, cov().derive_cov(*fij), 0)) ; |
| 267 |
|
| 268 |
Cmp auxi(mp) ; |
| 269 |
|
| 270 |
// Boucle sur les composantes : |
| 271 |
for (int i=0 ; i<3 ; i++) |
| 272 |
for (int j=0 ; j<3 ; j++) |
| 273 |
for (int k=j ; k<3 ; k++) { |
| 274 |
auxi = 0.5*( t1(i, j, k) + t1(i, k, j) - t2(i, j, k) ) ; |
| 275 |
p_delta->set(i, j, k) = auxi ; |
| 276 |
} |
| 277 |
} |
| 278 |
} |
| 279 |
} |
| 280 |
|
| 281 |
// Le calcul des Christoffel, cas general : |
| 282 |
void Metconf::fait_gamma() const { |
| 283 |
|
| 284 |
assert (etat != ETATNONDEF) ; |
| 285 |
if (p_gamma != 0x0) |
| 286 |
return ; |
| 287 |
|
| 288 |
else { // Calcul a faire : |
| 289 |
|
| 290 |
Itbl tipe (3) ; |
| 291 |
tipe.set_etat_qcq() ; |
| 292 |
tipe.set(0) = CON ; tipe.set(1) = COV ; tipe.set(2) = COV ; |
| 293 |
|
| 294 |
p_gamma = new Tenseur_sym (*mp, 3, tipe, *((*this).cov().get_triad()) ) ; |
| 295 |
if (etat == ETATZERO) p_gamma->set_etat_zero() ; |
| 296 |
else { |
| 297 |
assert(fij != 0x0) ; |
| 298 |
p_gamma->set_etat_qcq() ; |
| 299 |
*p_gamma = delta() + fij->gamma() ; |
| 300 |
} |
| 301 |
} |
| 302 |
} |
| 303 |
|
| 304 |
// Le calcul de H^i |
| 305 |
void Metconf::fait_Hi() const { |
| 306 |
|
| 307 |
assert (etat != ETATNONDEF) ; |
| 308 |
if (p_Hi != 0x0) |
| 309 |
return ; |
| 310 |
|
| 311 |
else // Calcul a faire : |
| 312 |
{ |
| 313 |
p_Hi = new Tenseur(*mp, 1, CON, mp->get_bvect_cart(), gamij, |
| 314 |
2./3.) ; |
| 315 |
|
| 316 |
if ((etat == ETATZERO) || (dirac)) p_Hi->set_etat_zero() ; |
| 317 |
else { |
| 318 |
p_Hi->set_etat_qcq() ; |
| 319 |
*p_Hi = - contract(contract(con(), 0, delta(), 1), 0, 2) ; |
| 320 |
} |
| 321 |
} |
| 322 |
} |
| 323 |
|
| 324 |
// Calcul de ricci : |
| 325 |
void Metconf::fait_ricci() const { |
| 326 |
|
| 327 |
assert(etat != ETATNONDEF) ; |
| 328 |
if (p_ricci != 0x0) |
| 329 |
return ; |
| 330 |
|
| 331 |
else { |
| 332 |
p_ricci = new Tenseur_sym (*mp, 2, COV, mp->get_bvect_cart() ) ; |
| 333 |
if ( (etat == ETATZERO) || (plat) ) |
| 334 |
p_ricci->set_etat_zero() ; |
| 335 |
else { |
| 336 |
|
| 337 |
p_ricci->set_etat_qcq() ; |
| 338 |
|
| 339 |
Tenseur_sym dcov(cov().derive_cov(*fij)) ; |
| 340 |
Tenseur_sym dcov2(dcov) ; |
| 341 |
dcov2.dec2_dzpuis() ; |
| 342 |
Tenseur_sym dd(dcov2.derive_cov(*fij)) ; |
| 343 |
dd.inc_dzpuis() ; |
| 344 |
Tenseur_sym dcon(con().derive_cov(*fij)) ; |
| 345 |
Tenseur Hi2(Hi()) ; |
| 346 |
Hi2.dec2_dzpuis() ; |
| 347 |
Tenseur dH(Hi2.derive_cov(*fij)) ; |
| 348 |
dH.inc_dzpuis() ; |
| 349 |
|
| 350 |
Tenseur_sym T1( contract(contract(delta(), 0, delta(), 2) , 1,2) ) ; |
| 351 |
T1.dec_dzpuis() ; |
| 352 |
|
| 353 |
Tenseur_sym T2( contract(contract(con(), 0, dd, 0) , 0, 1) ) ; |
| 354 |
|
| 355 |
Tenseur auxi(contract(contract(dcon, 1, dcov, 0), 1, 2) ) ; |
| 356 |
auxi.dec_dzpuis() ; |
| 357 |
auxi = auxi + contract(cov(), 1, dH, 1) ; |
| 358 |
Tenseur_sym T3(*mp, 2, COV, mp->get_bvect_cart() ) ; |
| 359 |
T3.set_etat_qcq() ; |
| 360 |
// Boucle sur les composantes : |
| 361 |
for (int i=0 ; i<3 ; i++) |
| 362 |
for (int j=i ; j<3 ; j++) |
| 363 |
T3.set(i, j) = auxi(i, j) + auxi(j, i) ; |
| 364 |
Tenseur_sym T4 (contract(Hi(), 0, dcov, 0) ); |
| 365 |
T4.dec_dzpuis() ; |
| 366 |
|
| 367 |
*p_ricci = -0.5*(T2 + T3 + T4) - T1 ; |
| 368 |
} |
| 369 |
} |
| 370 |
} |
| 371 |
|
| 372 |
// Calcul du scalaire de ricci : |
| 373 |
void Metconf::fait_ricci_scal() const { |
| 374 |
|
| 375 |
assert(etat != ETATNONDEF) ; |
| 376 |
if (p_ricci_scal != 0x0) |
| 377 |
return ; |
| 378 |
|
| 379 |
else { |
| 380 |
|
| 381 |
// Il s'agit d'une densite de scalaire ... |
| 382 |
p_ricci_scal = new Tenseur(*mp, gamij, 2./3.) ; |
| 383 |
if ( (etat == ETATZERO) || (plat) ) |
| 384 |
p_ricci_scal->set_etat_zero() ; |
| 385 |
else { |
| 386 |
|
| 387 |
p_ricci_scal->set_etat_qcq() ; |
| 388 |
Tenseur Hi2(Hi()) ; |
| 389 |
Hi2.dec2_dzpuis() ; |
| 390 |
Tenseur T0(contract(Hi2.derive_cov(*fij), 0, 1) ) ; |
| 391 |
T0.inc_dzpuis() ; |
| 392 |
Tenseur_sym dcov(cov().derive_cov(*fij)) ; |
| 393 |
Tenseur_sym dcon(con().derive_cov(*fij)) ; |
| 394 |
Tenseur auxi(contract(dcon, 1, dcov, 1)) ; |
| 395 |
Tenseur auxi1(contract(auxi, 1, 3)) ; |
| 396 |
Tenseur auxi2(contract(auxi, 1, 2)) ; |
| 397 |
Tenseur T1(contract(contract(con(), 0, auxi1, 0), 0, 1)) ; |
| 398 |
T1.dec_dzpuis() ; |
| 399 |
Tenseur T2(contract(contract(con(), 0, auxi2, 0), 0, 1)) ; |
| 400 |
T2.dec_dzpuis() ; |
| 401 |
|
| 402 |
*p_ricci_scal = -T0 + 0.25*T1 - 0.5*T2 ; |
| 403 |
if (dirac) p_ricci_scal->inc_dzpuis() ; |
| 404 |
} |
| 405 |
} |
| 406 |
} |
| 407 |
|
| 408 |
|
| 409 |
// Calcul du determinant : |
| 410 |
void Metconf::fait_determinant() const { |
| 411 |
|
| 412 |
assert(etat != ETATNONDEF) ; |
| 413 |
if (p_determinant != 0x0) |
| 414 |
return ; |
| 415 |
|
| 416 |
else { |
| 417 |
|
| 418 |
p_determinant = new Tenseur(*mp, this, 2) ; |
| 419 |
if (etat == ETATZERO) |
| 420 |
p_determinant->set_etat_zero() ; |
| 421 |
else { |
| 422 |
|
| 423 |
p_determinant->set_etat_qcq() ; |
| 424 |
|
| 425 |
p_determinant->set() = 1. ; |
| 426 |
} |
| 427 |
} |
| 428 |
} |
| 429 |
|
| 430 |
|
| 431 |
const Tenseur_sym& Metconf::delta() const{ |
| 432 |
if (p_delta == 0x0) |
| 433 |
fait_delta() ; |
| 434 |
return *p_delta ; |
| 435 |
} |
| 436 |
|
| 437 |
const Tenseur& Metconf::Hi() const{ |
| 438 |
if (p_Hi == 0x0) |
| 439 |
fait_Hi() ; |
| 440 |
return *p_Hi ; |
| 441 |
} |
| 442 |
|
| 443 |
} |