Debian Codegraph @

Codes/Einstein/analyse_evol.C

raw
1 /*
2 * Main code for reading a series of time slices Sigma_t stored in files
3 * and performoning some analysis of it
4 *
5 */
6
7 /*
8 * Copyright (c) 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 analyse_evol_C[] = "$Header: /cvsroot/Lorene/Codes/Einstein/analyse_evol.C,v 1.4 2014/10/13 08:53:55 j_novak Exp $" ;
28
29 /*
30 * $Id: analyse_evol.C,v 1.4 2014/10/13 08:53:55 j_novak Exp $
31 * $Log: analyse_evol.C,v $
32 * Revision 1.4 2014/10/13 08:53:55 j_novak
33 * Lorene classes and functions now belong to the namespace Lorene.
34 *
35 * Revision 1.3 2014/10/06 15:09:44 j_novak
36 * Modified #include directives to use c++ syntax.
37 *
38 * Revision 1.2 2010/10/20 08:00:43 j_novak
39 * New flag to control output on screen.
40 *
41 * Revision 1.1 2004/06/24 20:37:44 e_gourgoulhon
42 * First version.
43 *
44 *
45 * $Header: /cvsroot/Lorene/Codes/Einstein/analyse_evol.C,v 1.4 2014/10/13 08:53:55 j_novak Exp $
46 *
47 */
48
49 // C++ headers
50 #include "headcpp.h"
51
52 // C headers
53 #include <cstdlib>
54 #include <cmath>
55 #include <cstring>
56 #include <cstdio>
57
58 // Lorene headers
59 #include "time_slice.h"
60 #include "param.h"
61 #include "utilitaires.h"
62 #include "graphique.h"
63
64 using namespace Lorene ;
65
66 int main(){
67
68 ifstream fpar("par_ana_evol.d") ;
69 if ( !fpar.good() ) {
70 cout << "Problem with opening the file par_ana_evol.d ! " << endl ;
71 abort() ;
72 }
73
74 char rootname[80] ;
75 int jmin, jmax, jstep ;
76 fpar.ignore(1000,'\n') ; // skip title
77 fpar.ignore(1000,'\n') ; // skip comment
78 fpar.getline(rootname, 80) ;
79 fpar >> jmin ; fpar.ignore(1000,'\n') ;
80 fpar >> jmax ; fpar.ignore(1000,'\n') ;
81 fpar >> jstep ; fpar.ignore(1000,'\n') ;
82
83 cout << "Root name of files to be read : " << rootname << endl ;
84 cout << "jmin = " << jmin << endl ;
85 cout << "jmax = " << jmax << endl ;
86 cout << "jstep = " << jstep << endl << endl ;
87
88 ofstream fresu1("psidot.d") ;
89 ofstream fresu2("psidot_diff.d") ;
90 ofstream fresu3("psidot_diff_rel.d") ;
91
92 fresu1 << "# t max(abs(d/dt ln Psi)) in each domain" << endl ;
93 fresu2 <<
94 "# t Absolute error on the d/dt ln Psi relation in each domain"
95 << endl ;
96 fresu3 <<
97 "# t Relative error on the d/dt ln Psi relation in each domain"
98 << endl ;
99
100 for (int j=jmin; j<=jmax; j += jstep) {
101
102 char* filename = new char[ strlen(rootname)+10 ] ;
103 strcpy(filename, rootname) ;
104 char nomj[7] ;
105 sprintf(nomj, "%06d", j) ;
106 strcat(filename, nomj) ;
107 strcat(filename, ".d") ;
108
109
110 FILE* fich = fopen(filename, "r") ;
111 if (fich == 0x0) {
112 cout << "Problem in opening the file " << filename << " ! " << endl ;
113 perror(" reason") ;
114 abort() ;
115 }
116
117 Mg3d mgrid(fich) ;
118 Map_af map(mgrid, fich) ;
119
120 Base_vect::bvect_from_file(fich) ; //## skip the triad stored in file
121 const Base_vect* ptriad = &(map.get_bvect_spher()) ;
122
123 // Flat metric f
124 // -------------
125
126 const Metric_flat& ff = map.flat_met_spher() ;
127
128 int depth ;
129 fread_be(&depth, sizeof(int), 1, fich) ;
130
131 Tslice_dirac_max sigma(map, *ptriad, ff, fich, false, depth) ;
132
133 assert(sigma.get_latest_j() == j) ;
134
135 double tc = sigma.get_time()[j] ;
136
137 cout <<
138 "==============================================================\n"
139 << " step: " << j << " time = " << tc << endl
140 << "==============================================================\n" ;
141
142
143 cout << sigma << endl ;
144
145 int nz = mgrid.get_nzone() ;
146 Tbl tlnpsi_dot(nz) ;
147 Tbl tdiff(nz) ;
148 Tbl tdiff_rel(nz) ;
149 sigma.check_psi_dot(tlnpsi_dot, tdiff, tdiff_rel) ;
150
151 fresu1 << tc ;
152 for (int l = 0; l<nz ; l++) {
153 fresu1 << " " << tlnpsi_dot(l) ;
154 }
155 fresu1 << endl ;
156
157 fresu2 << tc ;
158 for (int l = 0; l<nz ; l++) {
159 fresu2 << " " << tdiff(l) ;
160 }
161 fresu2 << endl ;
162
163 fresu3 << tc ;
164 for (int l = 0; l<nz ; l++) {
165 fresu3 << " " << tdiff_rel(l) ;
166 }
167 fresu3 << endl ;
168
169 }
170
171 fresu1.close() ;
172 fresu2.close() ;
173 fresu3.close() ;
174
175 return EXIT_SUCCESS ;
176 }