| 1 |
/* |
| 2 |
* Code for testing the classes Sym_tensor, |
| 3 |
* in particular the transverse decomposion of a symmetric tensor. |
| 4 |
* |
| 5 |
*/ |
| 6 |
|
| 7 |
/* |
| 8 |
* Copyright (c) 2003-2004 Eric Gourgoulhon & Jerome Novak |
| 9 |
* |
| 10 |
* This file is part of LORENE. |
| 11 |
* |
| 12 |
* LORENE is free software; you can redistribute it and/or modify |
| 13 |
* it under the terms of the GNU General Public License version 2 |
| 14 |
* as published by the Free Software Foundation. |
| 15 |
* |
| 16 |
* LORENE is distributed in the hope that it will be useful, |
| 17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 |
* GNU General Public License for more details. |
| 20 |
* |
| 21 |
* You should have received a copy of the GNU General Public License |
| 22 |
* along with LORENE; if not, write to the Free Software |
| 23 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 24 |
* |
| 25 |
*/ |
| 26 |
|
| 27 |
char test_sym_tensor_C[] = "$Header: /cvsroot/Lorene/Codes/Test/Tensor/test_sym_tensor.C,v 1.9 2014/10/13 08:54:03 j_novak Exp $" ; |
| 28 |
|
| 29 |
/* |
| 30 |
* $Id: test_sym_tensor.C,v 1.9 2014/10/13 08:54:03 j_novak Exp $ |
| 31 |
* $Log: test_sym_tensor.C,v $ |
| 32 |
* Revision 1.9 2014/10/13 08:54:03 j_novak |
| 33 |
* Lorene classes and functions now belong to the namespace Lorene. |
| 34 |
* |
| 35 |
* Revision 1.8 2014/10/06 15:12:56 j_novak |
| 36 |
* Modified #include directives to use c++ syntax. |
| 37 |
* |
| 38 |
* Revision 1.7 2005/09/08 07:40:56 j_novak |
| 39 |
* Update of set_auxiliary arguments. |
| 40 |
* |
| 41 |
* Revision 1.6 2005/04/06 14:55:45 j_novak |
| 42 |
* Added the test on the decomposition onto eta/mu/W/X/T potentials. |
| 43 |
* |
| 44 |
* Revision 1.5 2004/02/19 22:15:55 e_gourgoulhon |
| 45 |
* New argument "comment" in functions spectral_display and diffrelmax. |
| 46 |
* |
| 47 |
* Revision 1.4 2004/02/18 18:56:35 e_gourgoulhon |
| 48 |
* Method trace() renamed the_trace(). |
| 49 |
* Tensor::trace used instead of Tensor::scontract. |
| 50 |
* |
| 51 |
* Revision 1.3 2004/02/09 13:01:35 e_gourgoulhon |
| 52 |
* Added test of the TT decomposition. |
| 53 |
* |
| 54 |
* Revision 1.2 2003/12/10 10:18:24 e_gourgoulhon |
| 55 |
* First operational version. |
| 56 |
* |
| 57 |
* Revision 1.1 2003/11/27 16:02:24 e_gourgoulhon |
| 58 |
* First version of code test_sym_tensor |
| 59 |
* |
| 60 |
* |
| 61 |
* $Header: /cvsroot/Lorene/Codes/Test/Tensor/test_sym_tensor.C,v 1.9 2014/10/13 08:54:03 j_novak Exp $ |
| 62 |
* |
| 63 |
*/ |
| 64 |
|
| 65 |
// C++ headers |
| 66 |
#include "headcpp.h" |
| 67 |
|
| 68 |
// C headers |
| 69 |
#include <cstdlib> |
| 70 |
|
| 71 |
// Lorene headers |
| 72 |
#include "metric.h" |
| 73 |
#include "nbr_spx.h" |
| 74 |
#include "utilitaires.h" |
| 75 |
|
| 76 |
|
| 77 |
using namespace Lorene ; |
| 78 |
|
| 79 |
int main() { |
| 80 |
|
| 81 |
// Construction of a multi-grid (Mg3d) |
| 82 |
// ----------------------------------- |
| 83 |
|
| 84 |
int nz = 3 ; // Number of domains |
| 85 |
int nzm1 = nz - 1 ; |
| 86 |
int nr = 33 ; // Number of collocation points in r in each domain |
| 87 |
int nt = 9 ; // Number of collocation points in theta in each domain |
| 88 |
int np = 16 ; // Number of collocation points in phi in each domain |
| 89 |
int symmetry_theta = SYM ; // symmetry with respect to the equatorial plane |
| 90 |
int symmetry_phi = NONSYM ; // no symmetry in phi |
| 91 |
bool compact = true ; // external domain is compactified |
| 92 |
|
| 93 |
Mg3d mgrid(nz, nr, nt, np, symmetry_theta, symmetry_phi, compact) ; |
| 94 |
|
| 95 |
|
| 96 |
// Construction of an affine mapping (Map_af) |
| 97 |
// ------------------------------------------ |
| 98 |
|
| 99 |
// Boundaries of each domains |
| 100 |
double r_limits[] = {0., 2., 3., __infinity} ; |
| 101 |
assert( nz == 3 ) ; // since the above array described only 3 domains |
| 102 |
|
| 103 |
Map_af map(mgrid, r_limits) ; |
| 104 |
|
| 105 |
|
| 106 |
// Construction of a flat metric |
| 107 |
// ----------------------------- |
| 108 |
|
| 109 |
Metric_flat mets(map, map.get_bvect_spher()) ; // spherical representation |
| 110 |
Metric_flat metc(map, map.get_bvect_cart()) ; // Cartesian representation |
| 111 |
|
| 112 |
|
| 113 |
// Construction of a symmetric tensor field |
| 114 |
// ----------------------------------------- |
| 115 |
|
| 116 |
const Coord& x = map.x ; |
| 117 |
const Coord& y = map.y ; |
| 118 |
const Coord& z = map.z ; |
| 119 |
const Coord& r = map.r ; |
| 120 |
const Coord& cost = map.cost ; |
| 121 |
const Coord& sint = map.sint ; |
| 122 |
const Coord& cosp = map.cosp ; |
| 123 |
const Coord& sinp = map.sinp ; |
| 124 |
|
| 125 |
Sym_tensor hhc(map, CON, map.get_bvect_cart()) ; |
| 126 |
|
| 127 |
|
| 128 |
Scalar tmp(map) ; |
| 129 |
|
| 130 |
hhc.set(1,1) = 2 ; |
| 131 |
tmp = 1 / (r*r*r*r) ; |
| 132 |
hhc.set(1,1).set_domain(nzm1) = tmp.domain(nzm1) ; |
| 133 |
hhc.set(1,1).set_dzpuis(4) ; |
| 134 |
|
| 135 |
hhc.set(1,2) = x ; |
| 136 |
tmp = sint*cosp / (r*r) ; |
| 137 |
hhc.set(1,2).set_domain(nzm1) = tmp.domain(nzm1) ; |
| 138 |
hhc.set(1,2).set_dzpuis(4); |
| 139 |
|
| 140 |
hhc.set(1,3) = y * z ; |
| 141 |
tmp = sint*sinp*cost / (r*r*r) ; |
| 142 |
hhc.set(1,3).set_domain(nzm1) = tmp.domain(nzm1) ; |
| 143 |
hhc.set(1,3).set_dzpuis(4); |
| 144 |
|
| 145 |
hhc.set(2,2) = x*y ; |
| 146 |
tmp = sint*sint*cosp*sinp / (r*r*r) ; |
| 147 |
hhc.set(2,2).set_domain(nzm1) = tmp.domain(nzm1) ; |
| 148 |
hhc.set(2,2).set_dzpuis(4); |
| 149 |
|
| 150 |
hhc.set(2,3) = z ; |
| 151 |
tmp = cost / (r*r) ; |
| 152 |
hhc.set(2,3).set_domain(nzm1) = tmp.domain(nzm1) ; |
| 153 |
hhc.set(2,3).set_dzpuis(4); |
| 154 |
|
| 155 |
hhc.set(3,3) = x ; |
| 156 |
tmp = sint*cosp / (r*r) ; |
| 157 |
hhc.set(3,3).set_domain(nzm1) = tmp.domain(nzm1) ; |
| 158 |
hhc.set(3,3).set_dzpuis(4); |
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
/* |
| 163 |
hhc.set(1,1) = 1. / (1 + pow(r,4)) ; ; |
| 164 |
tmp = 1. / (1. + 1./pow(r,4)) ; |
| 165 |
hhc.set(1,1).set_domain(nzm1) = tmp.domain(nzm1) ; |
| 166 |
hhc.set(1,1).set_dzpuis(4); |
| 167 |
|
| 168 |
hhc.set(1,2) = x / (1 + pow(r,5)) ; |
| 169 |
tmp = sint*cosp / (1. + 1./pow(r,5)) ; |
| 170 |
hhc.set(1,2).set_domain(nzm1) = tmp.domain(nzm1) ; |
| 171 |
hhc.set(1,2).set_dzpuis(4); |
| 172 |
|
| 173 |
hhc.set(1,3) = y * z / (1 + pow(r,6)) ; |
| 174 |
tmp = sint*sinp*cost / (1. + 1./pow(r,6)) ; |
| 175 |
hhc.set(1,3).set_domain(nzm1) = tmp.domain(nzm1) ; |
| 176 |
hhc.set(1,3).set_dzpuis(4); |
| 177 |
|
| 178 |
hhc.set(2,2) = x*y / (1 + pow(r,6)) ; |
| 179 |
tmp = sint*sint*cosp*sinp / (1. + 1./pow(r,6)) ; |
| 180 |
hhc.set(2,2).set_domain(nzm1) = tmp.domain(nzm1) ; |
| 181 |
hhc.set(2,2).set_dzpuis(4); |
| 182 |
|
| 183 |
hhc.set(2,3) = z / (1 + pow(r,5)) ; |
| 184 |
tmp = cost / (1. + 1./pow(r,5)) ; |
| 185 |
hhc.set(2,3).set_domain(nzm1) = tmp.domain(nzm1) ; |
| 186 |
hhc.set(2,3).set_dzpuis(4); |
| 187 |
|
| 188 |
hhc.set(3,3) = x / (1 + pow(r,5)) - y*z*z / (1 + pow(r,7)) ; |
| 189 |
tmp = sint*cosp / (1. + 1./pow(r,5)) |
| 190 |
- sint*sinp*cost*cost / (1. + 1./pow(r,7)) ; |
| 191 |
hhc.set(3,3).set_domain(nzm1) = tmp.domain(nzm1) ; |
| 192 |
hhc.set(3,3).set_dzpuis(4); |
| 193 |
*/ |
| 194 |
|
| 195 |
hhc.std_spectral_base() ; |
| 196 |
|
| 197 |
Sym_tensor hhs = hhc ; |
| 198 |
hhs.change_triad( map.get_bvect_spher() ) ; |
| 199 |
|
| 200 |
Scalar eta = hhs.eta() ; eta.div_r_dzpuis(4) ; |
| 201 |
Scalar mu = hhs.mu() ; mu.div_r_dzpuis(4) ; |
| 202 |
Scalar ww = hhs.www() ; |
| 203 |
Scalar xx = hhs.xxx() ; |
| 204 |
Scalar tt = hhs.ttt() ; |
| 205 |
cout << eta.get_dzpuis() << endl ; |
| 206 |
|
| 207 |
// Test of the eta/mu/W/X decomposition |
| 208 |
//------------------------------------- |
| 209 |
Sym_tensor hh_new(map, CON, map.get_bvect_spher()) ; |
| 210 |
hh_new.set_auxiliary(hhs(1,1), eta, mu, ww, xx, tt) ; |
| 211 |
|
| 212 |
cout << "Test of the decomposition on eta/mu/W/X potentials : " << endl ; |
| 213 |
for (int i=1; i<=3; i++) |
| 214 |
for (int j=i; j<=3; j++) { |
| 215 |
Scalar raz = (hhs(i,j) - hh_new(i,j)) ; |
| 216 |
cout << "Component: " << i << " , " << j << ": " ; |
| 217 |
maxabs(raz) ; |
| 218 |
cout << endl ; |
| 219 |
} |
| 220 |
arrete() ; |
| 221 |
|
| 222 |
// Transverse part |
| 223 |
// --------------- |
| 224 |
|
| 225 |
Sym_tensor_trans thhs = hhs.transverse(mets, 0x0, 6) ; |
| 226 |
arrete() ; |
| 227 |
|
| 228 |
thhs.dec_dzpuis(4) ; |
| 229 |
cout << "Max abs(trace) of the transverse part thhs : \n" ; |
| 230 |
maxabs( thhs.the_trace() ) ; |
| 231 |
|
| 232 |
Vector divt = thhs.divergence(mets) ; |
| 233 |
cout << "Max abs(divergence) of the transverse part thhs : " << endl ; |
| 234 |
maxabs( divt ) ; |
| 235 |
|
| 236 |
|
| 237 |
// TT part |
| 238 |
// ------- |
| 239 |
|
| 240 |
Sym_tensor_tt tthhs = hhs.transverse(mets).tt_part() ; |
| 241 |
tthhs.dec_dzpuis(4) ; |
| 242 |
|
| 243 |
Scalar tr_tthhs = tthhs.trace(mets) ; |
| 244 |
cout << "Max abs(trace) of the TT part tthhs : " << endl ; |
| 245 |
maxabs( tr_tthhs ) ; |
| 246 |
|
| 247 |
Vector divtt = tthhs.divergence(mets) ; |
| 248 |
cout << "Max abs(divergence) of the TT part tthhs : " << endl ; |
| 249 |
maxabs( divtt ) ; |
| 250 |
|
| 251 |
|
| 252 |
return EXIT_SUCCESS ; |
| 253 |
} |