1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
/*
* Methods for Hot_eos and file manipulation
*
* (see file hoteos.h for documentation)
*/
/*
* Copyright (c) 2015 Jerome Novak
*
* This file is part of LORENE.
*
* LORENE is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* LORENE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LORENE; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
char hoteos_from_file_C[] = "$Header: /cvsroot/Lorene/C++/Source/Eos/hoteos_from_file.C,v 1.2 2015/12/08 10:52:18 j_novak Exp $" ;
/*
* $Id: hoteos_from_file.C,v 1.2 2015/12/08 10:52:18 j_novak Exp $
* $Log: hoteos_from_file.C,v $
* Revision 1.2 2015/12/08 10:52:18 j_novak
* New class Hoteos_tabul for tabulated temperature-dependent EoSs.
*
* Revision 1.1 2015/03/17 14:20:00 j_novak
* New class Hot_eos to deal with temperature-dependent EOSs.
*
* $Header: /cvsroot/Lorene/C++/Source/Eos/hoteos_from_file.C,v 1.2 2015/12/08 10:52:18 j_novak Exp $
*
*/
// Headers C
#include <cstdlib>
// Header Lorene
#include "headcpp.h"
#include "hoteos.h"
#include "utilitaires.h"
namespace Lorene {
//--------------------------------------//
// Identification virtual functions //
//--------------------------------------//
int Ideal_gas::identify() const { return 1; }
int Hoteos_tabul::identify() const { return 2; }
//-------------------------------------------------//
// Hot EOS construction from a binary file //
//-------------------------------------------------//
Hot_eos* Hot_eos::hoteos_from_file(FILE* fich) {
Hot_eos* p_eos ;
// Type (class) of EOS :
int identificator ;
fread_be(&identificator, sizeof(int), 1, fich) ;
switch(identificator) {
case 1 : {
p_eos = new Ideal_gas(fich) ;
break ;
}
case 2 : {
p_eos = new Hoteos_tabul(fich) ;
break ;
}
default : {
cout << "Hot_eos::hoteos_from_file : unknown type of EOS !" << endl ;
cout << " identificator = " << identificator << endl ;
abort() ;
break ;
}
}
return p_eos ;
}
//--------------------------------------------------//
// Hot EOS construction from a formatted file //
//--------------------------------------------------//
Hot_eos* Hot_eos::hoteos_from_file(ifstream& fich) {
int identificator ;
if (!fich) {
cerr << "Hot_eos::hoteos_from_file: file cannot be opened!" << endl ;
abort() ;
}
// EOS identificator :
fich >> identificator ; fich.ignore(1000, '\n') ;
Hot_eos* p_eos ;
switch(identificator) {
case 1 : {
p_eos = new Ideal_gas(fich) ;
break ;
}
case 2 : {
p_eos = new Hoteos_tabul(fich) ;
break ;
}
default : {
cout << "Hot_eos::hoteos_from_file : unknown type of EOS !" << endl ;
cout << " identificator = " << identificator << endl ;
abort() ;
break ;
}
}
return p_eos ;
}
}
|