LORENE
eos_bf_file.C
1/*
2 * Methods for Eos_bifluid and file manipulation
3 *
4 * (see file eos_bifluid.h for documentation)
5 */
6
7/*
8 * Copyright (c) 2001 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 as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * LORENE is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with LORENE; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 */
27
28
29
30
31/*
32 * $Id: eos_bf_file.C,v 1.13 2017/10/06 12:36:33 a_sourie Exp $
33 * $Log: eos_bf_file.C,v $
34 * Revision 1.13 2017/10/06 12:36:33 a_sourie
35 * Cleaning of tabulated 2-fluid EoS class + superfluid rotating star model.
36 *
37 * Revision 1.12 2016/12/05 16:17:51 j_novak
38 * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
39 *
40 * Revision 1.11 2015/06/11 14:41:59 a_sourie
41 * Corrected minor bug
42 *
43 * Revision 1.10 2015/06/10 14:39:17 a_sourie
44 * New class Eos_bf_tabul for tabulated 2-fluid EoSs and associated functions for the computation of rotating stars with such EoSs.
45 *
46 * Revision 1.9 2014/10/13 08:52:52 j_novak
47 * Lorene classes and functions now belong to the namespace Lorene.
48 *
49 * Revision 1.8 2014/10/06 15:13:06 j_novak
50 * Modified #include directives to use c++ syntax.
51 *
52 * Revision 1.7 2014/04/25 10:43:51 j_novak
53 * The member 'name' is of type string now. Correction of a few const-related issues.
54 *
55 * Revision 1.6 2008/08/19 06:42:00 j_novak
56 * Minor modifications to avoid warnings with gcc 4.3. Most of them concern
57 * cast-type operations, and constant strings that must be defined as const char*
58 *
59 * Revision 1.5 2003/12/05 15:09:47 r_prix
60 * adapted Eos_bifluid class and subclasses to use read_variable() for
61 * (formatted) file-reading.
62 *
63 * Revision 1.4 2002/10/16 14:36:34 j_novak
64 * Reorganization of #include instructions of standard C++, in order to
65 * use experimental version 3 of gcc.
66 *
67 * Revision 1.3 2002/01/11 14:09:34 j_novak
68 * Added newtonian version for 2-fluid stars
69 *
70 * Revision 1.2 2001/12/04 21:27:53 e_gourgoulhon
71 *
72 * All writing/reading to a binary file are now performed according to
73 * the big endian convention, whatever the system is big endian or
74 * small endian, thanks to the functions fwrite_be and fread_be
75 *
76 * Revision 1.1.1.1 2001/11/20 15:19:27 e_gourgoulhon
77 * LORENE
78 *
79 * Revision 1.1 2001/06/21 15:22:15 novak
80 * Initial revision
81 *
82 *
83 * $Header: /cvsroot/Lorene/C++/Source/Eos/eos_bf_file.C,v 1.13 2017/10/06 12:36:33 a_sourie Exp $
84 *
85 */
86
87// Headers C
88#include <cstdlib>
89
90// Header Lorene
91#include "headcpp.h"
92#include "eos_bifluid.h"
93#include "utilitaires.h"
94
95 //--------------------------------------//
96 // Identification virtual functions //
97 //--------------------------------------//
98
99
100namespace Lorene {
101int Eos_bf_poly::identify() const { return 1; } // (Special-)relativistic polytropic EoS
102
103int Eos_bf_poly_newt::identify() const { return 2; } // Newtonian polytropic EoS
104
105int Eos_bf_tabul::identify() const { return 3; } // (Special-)relativistic tabulated EoS
106
107 //---------------------------------------------//
108 // EOS construction from a binary file //
109 //---------------------------------------------//
110
112
113 Eos_bifluid* p_eos ;
114
115 // Type (class) of EOS :
116 int identificator ;
117 fread_be(&identificator, sizeof(int), 1, fich) ;
118
119 switch(identificator) {
120
121 case 1 : {
122 p_eos = new Eos_bf_poly(fich) ;
123 break ;
124 }
125
126 case 3 : {
127 p_eos = new Eos_bf_tabul(fich) ;
128 break ;
129 }
130
131 default : {
132 cout << "Eos_bifluid::eos_from_file : unknown type of EOS !" << endl ;
133 cout << " identificator = " << identificator << endl ;
134 abort() ;
135 break ;
136 }
137
138 }
139
140 return p_eos ;
141
142}
143
144 //----------------------------------------------//
145 // EOS construction from a formatted file //
146 //----------------------------------------------//
147
149
150 int identificator ;
151
152 // EOS identificator :
153 if (read_variable (fname, const_cast<char*>("ident"), identificator) != 0)
154 {
155 cerr << "ERROR: Could not read the required variable 'ident' in " << fname << endl;
156 exit (-1);
157 }
158
159 Eos_bifluid* p_eos ;
160
161 switch(identificator) {
162
163 case 1 : {
164 p_eos = new Eos_bf_poly(fname) ;
165 break ;
166 }
167
168 case 2 : {
169 p_eos = new Eos_bf_poly_newt(fname) ;
170 break ;
171 }
172
173 default : {
174 cout << "Eos_bifluid::eos_from_file : unknown type of EOS !" << endl ;
175 cout << " identificator = " << identificator << endl ;
176 abort() ;
177 break ;
178 }
179
180 }
181
182 return p_eos ;
183
184}
185
186 //----------------------------------------------//
187 // EOS construction from a formatted file //
188 //----------------------------------------------//
189
191
192 int identificator ;
193
194 // EOS identificator :
195 fich >> identificator ; fich.ignore(1000, '\n') ;
196
197 Eos_bifluid* p_eos ;
198
199 switch(identificator) {
200
201 case 3 : {
202 p_eos = new Eos_bf_tabul(fich) ;
203 break ;
204 }
205
206 default : {
207 cout << "Eos_bifluid::eos_from_file : unknown type of EOS !" << endl ;
208 cout << " identificator = " << identificator << endl ;
209 abort() ;
210 break ;
211 }
212
213 }
214
215 return p_eos ;
216
217}
218
219
220
221
222
223
224}
Analytic equation of state for two fluids (Newtonian case).
virtual int identify() const
Returns a number to identify the sub-classe of Eos_bifluid the object belongs to.
Analytic equation of state for two fluids (relativistic case).
virtual int identify() const
Returns a number to identify the sub-classe of Eos_bifluid the object belongs to.
Class for a two-fluid (tabulated) equation of state.
virtual int identify() const
Returns a number to identify the sub-classe of Eos the object belongs to.
static Eos_bifluid * eos_from_file(FILE *)
Construction of an EOS from a binary file.
Eos_bifluid()
Standard constructor.
int fread_be(int *aa, int size, int nb, FILE *fich)
Reads integer(s) from a binary file according to the big endian convention.
Definition fread_be.C:72
int read_variable(const char *fname, const char *var_name, char *fmt, void *varp)
Reads a variable from file.
Lorene prototypes.
Definition app_hor.h:67