Debian Codegraph @

Codes/Einstein/visu_evol.C

raw
1 /*
2 * Main code for reading a series of time slices Sigma_t stored in files.
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 visu_evol_C[] = "$Header: /cvsroot/Lorene/Codes/Einstein/visu_evol.C,v 1.5 2014/10/13 08:53:56 j_novak Exp $" ;
27
28 /*
29 * $Id: visu_evol.C,v 1.5 2014/10/13 08:53:56 j_novak Exp $
30 * $Log: visu_evol.C,v $
31 * Revision 1.5 2014/10/13 08:53:56 j_novak
32 * Lorene classes and functions now belong to the namespace Lorene.
33 *
34 * Revision 1.4 2014/10/06 15:09:44 j_novak
35 * Modified #include directives to use c++ syntax.
36 *
37 * Revision 1.3 2004/06/24 00:07:28 e_gourgoulhon
38 * Introduced the reference 'field' and string 'fieldname' for
39 * a easier selection of the field to be visualized.
40 * Better determination of the max of the field.
41 *
42 * Revision 1.2 2004/06/02 21:34:39 e_gourgoulhon
43 * Added creation of file anime.dxcont for OpenDX.
44 *
45 * Revision 1.1 2004/05/31 20:34:20 e_gourgoulhon
46 * First version
47 *
48 *
49 * $Header: /cvsroot/Lorene/Codes/Einstein/visu_evol.C,v 1.5 2014/10/13 08:53:56 j_novak Exp $
50 *
51 */
52
53 // C++ headers
54 #include "headcpp.h"
55
56 // C headers
57 #include <cstdlib>
58 #include <cmath>
59 #include <cstring>
60 #include <cstdio>
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(){
71
72 ifstream fpar("par_visu_evol.d") ;
73 if ( !fpar.good() ) {
74 cout << "Problem with opening the file par_visu_evol.d ! " << endl ;
75 abort() ;
76 }
77
78 char rootname[80], rootdxname[80], section_type ;
79 int jmin, jmax, jstep, nu, nv ;
80 double a_section, umin, umax, vmin, vmax ;
81 fpar.ignore(1000,'\n') ; // skip title
82 fpar.ignore(1000,'\n') ; // skip comment
83 fpar.getline(rootname, 80) ;
84 fpar >> jmin ; fpar.ignore(1000,'\n') ;
85 fpar >> jmax ; fpar.ignore(1000,'\n') ;
86 fpar >> jstep ; fpar.ignore(1000,'\n') ;
87 fpar.ignore(1000,'\n') ; // skip comment
88 fpar.getline(rootdxname, 80) ;
89 fpar.get(section_type) ; fpar.ignore(1000,'\n') ;
90 fpar >> a_section ; fpar.ignore(1000,'\n') ;
91 fpar >> umin ; fpar >> umax ; fpar.ignore(1000,'\n') ;
92 fpar >> vmin ; fpar >> vmax ; fpar.ignore(1000,'\n') ;
93 fpar >> nu ; fpar.ignore(1000,'\n') ;
94 fpar >> nv ; fpar.ignore(1000,'\n') ;
95
96 cout << "Root name of files to be read : " << rootname << endl ;
97 cout << "jmin = " << jmin << endl ;
98 cout << "jmax = " << jmax << endl ;
99 cout << "jstep = " << jstep << endl ;
100 cout << "section_type = " << section_type << endl ;
101 cout << "a_section = " << a_section << endl ;
102 cout << "umin, umax = " << umin << ", " << umax << endl ;
103 cout << "vmin, vmax = " << vmin << ", " << vmax << endl ;
104 cout << "nu x nv = " << nu << " x " << nv << endl ;
105 arrete() ;
106
107 ofstream fdx("anime.dxcont") ;
108 fdx << "fieldname jmin jmax jstep ampli " << endl ;
109 fdx << rootdxname << " " << jmin << " " << jmax << " " << jstep ;
110
111 char fieldname[100] ;
112
113 double max_field = 0 ;
114
115 for (int j=jmin; j<=jmax; j += jstep) {
116
117 char* filename = new char[ strlen(rootname)+10 ] ;
118 strcpy(filename, rootname) ;
119 char nomj[7] ;
120 sprintf(nomj, "%06d", j) ;
121 strcat(filename, nomj) ;
122 strcat(filename, ".d") ;
123
124
125 FILE* fich = fopen(filename, "r") ;
126 if (fich == 0x0) {
127 cout << "Problem in opening the file " << filename << " ! " << endl ;
128 perror(" reason") ;
129 abort() ;
130 }
131
132 Mg3d mgrid(fich) ;
133 Map_af map(mgrid, fich) ;
134
135 Base_vect* ptriad = Base_vect::bvect_from_file(fich) ;
136
137 // Flat metric f
138 // -------------
139
140 const Metric_flat& ff = map.flat_met_spher() ;
141
142 int depth ;
143 fread_be(&depth, sizeof(int), 1, fich) ;
144
145 Tslice_dirac_max sigma(map, *ptriad, ff, fich, false, depth) ;
146
147 assert(sigma.get_latest_j() == j) ;
148
149 double tc = sigma.get_time()[j] ;
150
151 cout <<
152 "==============================================================\n"
153 << " step: " << j << " time = " << tc << endl
154 << "==============================================================\n" ;
155
156
157 cout << sigma << endl ;
158
159 bool start_dx = ( (j >= jmax - jstep) && (j != jmax) ) ;
160 // bool start_dx = false ;
161
162 // Selection of the field to be vizualized
163 // ---------------------------------------
164 const Scalar& field = sigma.gam().ricci_scal() ;
165 strcpy(fieldname, "R") ;
166
167 // field.spectral_display(fieldname) ;
168
169 field.visu_section_anim(section_type, a_section, umin, umax,
170 vmin, vmax, j, tc, 1, fieldname, rootdxname,
171 start_dx, nu, nv) ;
172
173 double max_field_j = max(maxabs(field)) ;
174 if (max_field_j > max_field) max_field = max_field_j ;
175
176 delete ptriad ;
177
178 }
179
180 fdx << " " << 1. / max_field << endl ;
181 fdx.close() ;
182
183 return EXIT_SUCCESS ;
184 }