eos_from_file.C

00001 /*
00002  * Methods for Eos and file manipulation
00003  *
00004  * (see file eos.h for documentation)
00005  */
00006 
00007 /*
00008  *   Copyright (c) 2000-2001 Eric Gourgoulhon
00009  *
00010  *   This file is part of LORENE.
00011  *
00012  *   LORENE is free software; you can redistribute it and/or modify
00013  *   it under the terms of the GNU General Public License as published by
00014  *   the Free Software Foundation; either version 2 of the License, or
00015  *   (at your option) any later version.
00016  *
00017  *   LORENE is distributed in the hope that it will be useful,
00018  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  *   GNU General Public License for more details.
00021  *
00022  *   You should have received a copy of the GNU General Public License
00023  *   along with LORENE; if not, write to the Free Software
00024  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025  *
00026  */
00027 
00028 
00029 char eos_from_file_C[] = "$Header: /cvsroot/Lorene/C++/Source/Eos/eos_from_file.C,v 1.10 2011/06/16 10:49:18 j_novak Exp $" ;
00030 
00031 /*
00032  * $Id: eos_from_file.C,v 1.10 2011/06/16 10:49:18 j_novak Exp $
00033  * $Log: eos_from_file.C,v $
00034  * Revision 1.10  2011/06/16 10:49:18  j_novak
00035  * New class Eos_mag for EOSs depending on density and magnetic field.
00036  *
00037  * Revision 1.9  2010/02/02 13:22:16  j_novak
00038  * New class Eos_Compstar.
00039  *
00040  * Revision 1.8  2005/05/22 20:51:41  k_taniguchi
00041  * Add a new Eos Eos_fit_AkmalPR.
00042  *
00043  * Revision 1.7  2004/09/26 18:53:08  k_taniguchi
00044  * Introduction of new EOSs: Eos_fit_SLy4 and Eos_fit_FPS
00045  *
00046  * Revision 1.6  2004/05/07 08:06:45  k_taniguchi
00047  * Add the case of Eos_multi_poly.C
00048  *
00049  * Revision 1.5  2003/12/08 15:47:03  m_bejger
00050  * GlendNH3 EOS (Glendenning 1985, case 3) added
00051  *
00052  * Revision 1.4  2002/10/16 14:36:35  j_novak
00053  * Reorganization of #include instructions of standard C++, in order to
00054  * use experimental version 3 of gcc.
00055  *
00056  * Revision 1.3  2002/04/09 14:32:15  e_gourgoulhon
00057  * 1/ Added extra parameters in EOS computational functions (argument par)
00058  * 2/ New class MEos for multi-domain EOS
00059  *
00060  * Revision 1.2  2001/12/04 21:27:53  e_gourgoulhon
00061  *
00062  * All writing/reading to a binary file are now performed according to
00063  * the big endian convention, whatever the system is big endian or
00064  * small endian, thanks to the functions fwrite_be and fread_be
00065  *
00066  * Revision 1.1.1.1  2001/11/20 15:19:27  e_gourgoulhon
00067  * LORENE
00068  *
00069  * Revision 2.6  2001/09/11  16:23:08  eric
00070  * Ajout de Eos_AkmalPR, Eos_BBB2 et Eos_BalbN1H1.
00071  *
00072  * Revision 2.5  2000/11/23  22:34:10  eric
00073  * Ajout de Eos_BPAL12.
00074  *
00075  * Revision 2.4  2000/11/23  14:46:16  eric
00076  * Ajout de Eos_strange_cr.
00077  *
00078  * Revision 2.3  2000/11/22  19:30:55  eric
00079  * Ajout des Eos_SLy4 et Eos_FPS
00080  *
00081  * Revision 2.2  2000/10/24  15:29:22  eric
00082  * Ajout de l'EOS matiere etrange (Eos_strange).
00083  *
00084  * Revision 2.1  2000/02/14  14:33:41  eric
00085  * Ajout du constructeur par lecture de fichier formate.
00086  *
00087  * Revision 2.0  2000/01/21  15:18:08  eric
00088  * *** empty log message ***
00089  *
00090  *
00091  * $Header: /cvsroot/Lorene/C++/Source/Eos/eos_from_file.C,v 1.10 2011/06/16 10:49:18 j_novak Exp $
00092  *
00093  */
00094  
00095 // Headers C
00096 #include <stdlib.h>
00097 
00098 // Header Lorene
00099 #include "headcpp.h"
00100 #include "eos.h"
00101 #include "eos_multi_poly.h"
00102 #include "eos_fitting.h"
00103 #include "utilitaires.h"
00104 
00105         //--------------------------------------//
00106         //  Identification virtual functions    //
00107         //--------------------------------------//
00108 
00109 
00110 int Eos_poly::identify() const      { return 1; }
00111 
00112 int Eos_poly_newt::identify() const { return 2; }
00113 
00114 int Eos_incomp::identify() const    { return 3; }
00115 
00116 int Eos_incomp_newt::identify() const   { return 4; }
00117 
00118 int Eos_strange::identify() const   { return 5; }
00119 
00120 int Eos_strange_cr::identify() const    { return 6; }
00121 
00122 int Eos_SLy4::identify() const      { return 10; }
00123 
00124 int Eos_FPS::identify() const       { return 11; }
00125 
00126 int Eos_BPAL12::identify() const    { return 12; }
00127 
00128 int Eos_AkmalPR::identify() const   { return 13; }
00129 
00130 int Eos_BBB2::identify() const      { return 14; }
00131 
00132 int Eos_BalbN1H1::identify() const  { return 15; }
00133 
00134 int Eos_GlendNH3::identify() const  { return 16; }
00135 
00136 int Eos_Compstar::identify() const  { return 17; }
00137 
00138 int Eos_mag::identify() const   { return 18; }
00139 
00140 int MEos::identify() const  { return 100; }
00141 
00142 int Eos_multi_poly::identify() const    { return 110; }
00143 
00144 int Eos_fit_SLy4::identify() const      { return 120; }
00145 
00146 int Eos_fit_FPS::identify() const       { return 121; }
00147 
00148 int Eos_fit_AkmalPR::identify() const   { return 122; }
00149 
00150         //---------------------------------------------//
00151         //    EOS construction from a binary file      //
00152         //---------------------------------------------//
00153 
00154 Eos* Eos::eos_from_file(FILE* fich) {
00155     
00156     Eos* p_eos ; 
00157     
00158     // Type (class) of EOS :
00159     int identificator ;     
00160     fread_be(&identificator, sizeof(int), 1, fich) ;        
00161 
00162     switch(identificator) {
00163     
00164     case 1 : {
00165         p_eos = new Eos_poly(fich) ; 
00166         break ; 
00167     }
00168     
00169     case 2 : {
00170         p_eos = new Eos_poly_newt(fich) ; 
00171         break ; 
00172     }
00173     
00174     case 3 : {
00175         p_eos = new Eos_incomp(fich) ; 
00176         break ; 
00177     }
00178     
00179     case 4 : {
00180         p_eos = new Eos_incomp_newt(fich) ; 
00181         break ; 
00182     }
00183     
00184     case 5 : {
00185         p_eos = new Eos_strange(fich) ;
00186         break ;
00187     }
00188     
00189     case 6 : {
00190         p_eos = new Eos_strange_cr(fich) ;
00191         break ;
00192     }
00193     
00194     case 10 : {
00195         p_eos = new Eos_SLy4(fich) ;
00196         break ;
00197     }
00198     
00199     case 11 : {
00200         p_eos = new Eos_FPS(fich) ;
00201         break ;
00202     }
00203     
00204     case 12 : {
00205         p_eos = new Eos_BPAL12(fich) ;
00206         break ;
00207     }
00208     
00209     case 13 : {
00210         p_eos = new Eos_AkmalPR(fich) ;
00211         break ;
00212     }
00213     
00214     case 14 : {
00215         p_eos = new Eos_BBB2(fich) ;
00216         break ;
00217     }
00218     
00219     case 15 : {
00220         p_eos = new Eos_BalbN1H1(fich) ;
00221         break ;
00222     }
00223 
00224     case 16 : {
00225         p_eos = new Eos_GlendNH3(fich) ;
00226         break ;
00227     }
00228 
00229     case 17 : {
00230         p_eos = new Eos_Compstar(fich) ;
00231         break ;
00232     }
00233 
00234     case 18 : {
00235         p_eos = new Eos_mag(fich) ;
00236         break ;
00237     }
00238 
00239     case 100 : {
00240         p_eos = new MEos(fich) ;
00241         break ;
00242     }
00243 
00244     case 110 : {
00245         p_eos = new Eos_multi_poly(fich) ;
00246         break ;
00247     }
00248 
00249     case 120 : {
00250         p_eos = new Eos_fit_SLy4(fich) ;
00251         break ;
00252     }
00253 
00254     case 121 : {
00255         p_eos = new Eos_fit_FPS(fich) ;
00256         break ;
00257     }
00258 
00259     case 122 : {
00260         p_eos = new Eos_fit_AkmalPR(fich) ;
00261         break ;
00262     }
00263 
00264     default : {
00265         cout << "Eos::eos_from_file : unknown type of EOS !" << endl ; 
00266         cout << " identificator = " << identificator << endl ; 
00267         abort() ; 
00268         break ; 
00269     }
00270     
00271     }
00272     
00273     return p_eos ; 
00274     
00275 }
00276 
00277         //----------------------------------------------//
00278         //    EOS construction from a formatted file    //
00279         //----------------------------------------------//
00280 
00281 Eos* Eos::eos_from_file(ifstream& fich) {
00282     
00283     int identificator ; 
00284     char blabla[80] ;
00285 
00286     // EOS identificator : 
00287     fich >> identificator ; fich.getline(blabla, 80) ;
00288 
00289     Eos* p_eos ; 
00290     
00291     switch(identificator) {
00292     
00293     case 1 : {
00294         p_eos = new Eos_poly(fich) ; 
00295         break ; 
00296     }
00297     
00298     case 2 : {
00299         p_eos = new Eos_poly_newt(fich) ; 
00300         break ; 
00301     }
00302     
00303     case 3 : {
00304         p_eos = new Eos_incomp(fich) ; 
00305         break ; 
00306     }
00307     
00308     case 4 : {
00309         p_eos = new Eos_incomp_newt(fich) ; 
00310         break ; 
00311     }
00312     
00313     case 5 : {
00314         p_eos = new Eos_strange(fich) ;
00315         break ;
00316     }
00317     
00318     case 6 : {
00319         p_eos = new Eos_strange_cr(fich) ;
00320         break ;
00321     }
00322     
00323     case 10 : {
00324         p_eos = new Eos_SLy4(fich) ;
00325         break ;
00326     }
00327     
00328     case 11 : {
00329         p_eos = new Eos_FPS(fich) ;
00330         break ;
00331     }
00332     
00333     case 12 : {
00334         p_eos = new Eos_BPAL12(fich) ;
00335         break ;
00336     }
00337     
00338     case 13 : {
00339         p_eos = new Eos_AkmalPR(fich) ;
00340         break ;
00341     }
00342     
00343     case 14 : {
00344         p_eos = new Eos_BBB2(fich) ;
00345         break ;
00346     }
00347     
00348     case 15 : {
00349         p_eos = new Eos_BalbN1H1(fich) ;
00350         break ;
00351     }
00352 
00353     case 16 : {
00354         p_eos = new Eos_GlendNH3(fich) ;
00355         break ;
00356     }
00357 
00358     case 17 : {
00359         p_eos = new Eos_Compstar(fich) ;
00360         break ;
00361     }
00362 
00363     case 18 : {
00364         p_eos = new Eos_mag(fich) ;
00365         break ;
00366     }
00367 
00368     case 100 : {
00369         p_eos = new MEos(fich) ;
00370         break ;
00371     }
00372 
00373     case 110 : {
00374         p_eos = new Eos_multi_poly(fich) ;
00375         break ;
00376     }
00377 
00378     case 120 : {
00379         p_eos = new Eos_fit_SLy4(fich) ;
00380         break ;
00381     }
00382 
00383     case 121 : {
00384         p_eos = new Eos_fit_FPS(fich) ;
00385         break ;
00386     }
00387 
00388     case 122 : {
00389         p_eos = new Eos_fit_AkmalPR(fich) ;
00390         break ;
00391     }
00392 
00393     default : {
00394         cout << "Eos::eos_from_file : unknown type of EOS !" << endl ; 
00395         cout << " identificator = " << identificator << endl ; 
00396         abort() ; 
00397         break ; 
00398     }
00399     
00400     }
00401     
00402     return p_eos ; 
00403     
00404 }
00405 
00406 
00407 
00408 
00409 
00410 

Generated on Tue Feb 7 01:35:16 2012 for LORENE by  doxygen 1.4.6