| 1 |
/* |
| 2 |
* Main code for reading a time slice Sigma_t stored in file. |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
/* |
| 7 |
* Copyright (c) 2004 Eric Gourgoulhon & Jerome Novak |
| 8 |
* |
| 9 |
* This file is part of LORENE. |
| 10 |
* |
| 11 |
* LORENE is free software; you can redistribute it and/or modify |
| 12 |
* it under the terms of the GNU General Public License version 2 |
| 13 |
* as published by the Free Software Foundation. |
| 14 |
* |
| 15 |
* LORENE is distributed in the hope that it will be useful, |
| 16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 |
* GNU General Public License for more details. |
| 19 |
* |
| 20 |
* You should have received a copy of the GNU General Public License |
| 21 |
* along with LORENE; if not, write to the Free Software |
| 22 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 23 |
* |
| 24 |
*/ |
| 25 |
|
| 26 |
char read_tslice_C[] = "$Header: /cvsroot/Lorene/Codes/Einstein/read_tslice.C,v 1.6 2014/10/13 08:53:56 j_novak Exp $" ; |
| 27 |
|
| 28 |
/* |
| 29 |
* $Id: read_tslice.C,v 1.6 2014/10/13 08:53:56 j_novak Exp $ |
| 30 |
* $Log: read_tslice.C,v $ |
| 31 |
* Revision 1.6 2014/10/13 08:53:56 j_novak |
| 32 |
* Lorene classes and functions now belong to the namespace Lorene. |
| 33 |
* |
| 34 |
* Revision 1.5 2014/10/06 15:09:44 j_novak |
| 35 |
* Modified #include directives to use c++ syntax. |
| 36 |
* |
| 37 |
* Revision 1.4 2004/06/24 15:42:16 j_novak |
| 38 |
* Display of log(n) and log(psi) instead of N/psi. |
| 39 |
* |
| 40 |
* Revision 1.3 2004/06/15 10:25:27 e_gourgoulhon |
| 41 |
* Added plot of hrt and hrp. |
| 42 |
* |
| 43 |
* Revision 1.2 2004/05/31 20:32:50 e_gourgoulhon |
| 44 |
* Added graphical outputs. |
| 45 |
* |
| 46 |
* Revision 1.1 2004/05/27 15:25:38 e_gourgoulhon |
| 47 |
* First version. |
| 48 |
* |
| 49 |
* |
| 50 |
* $Header: /cvsroot/Lorene/Codes/Einstein/read_tslice.C,v 1.6 2014/10/13 08:53:56 j_novak Exp $ |
| 51 |
* |
| 52 |
*/ |
| 53 |
|
| 54 |
// C++ headers |
| 55 |
#include "headcpp.h" |
| 56 |
|
| 57 |
// C headers |
| 58 |
#include <cstdlib> |
| 59 |
#include <cmath> |
| 60 |
#include <cstring> |
| 61 |
|
| 62 |
// Lorene headers |
| 63 |
#include "time_slice.h" |
| 64 |
#include "param.h" |
| 65 |
#include "utilitaires.h" |
| 66 |
#include "graphique.h" |
| 67 |
|
| 68 |
using namespace Lorene ; |
| 69 |
|
| 70 |
int main(int argc, char** argv){ |
| 71 |
|
| 72 |
if (argc < 2) { |
| 73 |
cout << |
| 74 |
"read_tslice : the name of a file containing a configuration" |
| 75 |
<< endl << " must be given in argument !" << endl ; |
| 76 |
abort() ; |
| 77 |
} |
| 78 |
|
| 79 |
char* nomresu = argv[1] ; |
| 80 |
cout << "Name of the file to be read : " << nomresu << endl ; |
| 81 |
|
| 82 |
FILE* fich = fopen(nomresu, "r") ; |
| 83 |
if (fich == 0x0) { |
| 84 |
cout << "Problem in opening the file " << nomresu << " ! " << endl ; |
| 85 |
perror(" reason") ; |
| 86 |
abort() ; |
| 87 |
} |
| 88 |
|
| 89 |
Mg3d mgrid(fich) ; |
| 90 |
Map_af map(mgrid, fich) ; |
| 91 |
|
| 92 |
Base_vect* ptriad_file = Base_vect::bvect_from_file(fich) ; |
| 93 |
|
| 94 |
cout << "Computational grid :\n" |
| 95 |
<< "------------------ \n" |
| 96 |
<< " " << mgrid << endl ; |
| 97 |
|
| 98 |
cout << "Mapping computational grid --> physical space :\n" |
| 99 |
<< "---------------------------------------------\n" |
| 100 |
<< " " << map << endl ; |
| 101 |
|
| 102 |
const Base_vect_spher* triad_s = |
| 103 |
dynamic_cast<const Base_vect_spher*>(ptriad_file) ; |
| 104 |
const Base_vect_cart* triad_c = |
| 105 |
dynamic_cast<const Base_vect_cart*>(ptriad_file) ; |
| 106 |
|
| 107 |
const Base_vect* ptriad ; |
| 108 |
|
| 109 |
if ( triad_s != 0x0 ) ptriad = &(map.get_bvect_spher()) ; |
| 110 |
else { |
| 111 |
assert( triad_c != 0x0) ; |
| 112 |
ptriad = &(map.get_bvect_cart()) ; |
| 113 |
} |
| 114 |
|
| 115 |
delete ptriad_file ; |
| 116 |
|
| 117 |
|
| 118 |
// Flat metric f |
| 119 |
// ------------- |
| 120 |
|
| 121 |
const Metric_flat& ff = map.flat_met_spher() ; |
| 122 |
|
| 123 |
int depth ; |
| 124 |
fread_be(&depth, sizeof(int), 1, fich) ; |
| 125 |
|
| 126 |
// Time slice Sigma_t |
| 127 |
// ------------------- |
| 128 |
Tslice_dirac_max sigmat(map, *ptriad, ff, fich, false, depth) ; |
| 129 |
|
| 130 |
fclose(fich) ; |
| 131 |
|
| 132 |
Scalar lnn = log(sigmat.nn()) ; |
| 133 |
lnn.std_spectral_base() ; |
| 134 |
|
| 135 |
cout << sigmat << endl ; |
| 136 |
|
| 137 |
// For graphical outputs: |
| 138 |
char graph_device[40] ; |
| 139 |
strcpy(graph_device, "/xwin") ; |
| 140 |
int ngraph0 = 20 ; // index of the first graphic device to be used |
| 141 |
int nz = mgrid.get_nzone() ; |
| 142 |
double ray_des = 1.25 * map.val_r(nz-2, 1., 0., 0.) ; // outermost radius |
| 143 |
// for plots |
| 144 |
des_meridian(lnn, 0., ray_des, "log(N)", ngraph0, |
| 145 |
graph_device) ; |
| 146 |
des_meridian(sigmat.ln_psi(), 0., ray_des, "log(\\gQ)", ngraph0+1, |
| 147 |
graph_device) ; |
| 148 |
des_meridian(sigmat.beta()(1), 0., ray_des, "\\gb\\ur\\d", ngraph0+6, |
| 149 |
graph_device) ; |
| 150 |
des_meridian(sigmat.beta()(2), 0., ray_des, "\\gb\\u\\gh\\d", ngraph0+7, |
| 151 |
graph_device) ; |
| 152 |
des_meridian(sigmat.beta()(3), 0., ray_des, "\\gb\\u\\gf\\d", ngraph0+8, |
| 153 |
graph_device) ; |
| 154 |
des_meridian(sigmat.khi(), 0., ray_des, "\\gx", ngraph0+9, |
| 155 |
graph_device) ; |
| 156 |
des_meridian(sigmat.mu(), 0., ray_des, "\\gm", ngraph0+10, |
| 157 |
graph_device) ; |
| 158 |
des_meridian(sigmat.trh(), 0., ray_des, "tr h", ngraph0+11, |
| 159 |
graph_device) ; |
| 160 |
des_meridian(sigmat.hh()(1,1), 0., ray_des, "h\\urr\\d", ngraph0+12, |
| 161 |
graph_device) ; |
| 162 |
des_meridian(sigmat.hh()(1,2), 0., ray_des, "h\\ur\\gh\\d", ngraph0+13, |
| 163 |
graph_device) ; |
| 164 |
des_meridian(sigmat.hh()(1,3), 0., ray_des, "h\\ur\\gf\\d", ngraph0+14, |
| 165 |
graph_device) ; |
| 166 |
des_meridian(sigmat.hh()(2,3), 0., ray_des, "h\\u\\gh\\gf\\d", ngraph0+15, |
| 167 |
graph_device) ; |
| 168 |
des_meridian(sigmat.hh()(3,3), 0., ray_des, "h\\u\\gf\\gf\\d", ngraph0+16, |
| 169 |
graph_device) ; |
| 170 |
des_meridian(sigmat.aa()(1,1), 0., ray_des, "A\\urr\\d", ngraph0+17, |
| 171 |
graph_device) ; |
| 172 |
des_meridian(sigmat.aa()(2,3), 0., ray_des, "A\\u\\gh\\gf\\d", ngraph0+18, |
| 173 |
graph_device) ; |
| 174 |
des_meridian(sigmat.aa()(3,3), 0., ray_des, "A\\u\\gf\\gf\\d", ngraph0+19, |
| 175 |
graph_device) ; |
| 176 |
arrete() ; |
| 177 |
|
| 178 |
return EXIT_SUCCESS ; |
| 179 |
} |