00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 char meos_C[] = "$Header: /cvsroot/Lorene/C++/Source/Eos/meos.C,v 1.4 2004/04/01 11:09:26 e_gourgoulhon Exp $" ;
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 #include <stdlib.h>
00053
00054
00055 #include "headcpp.h"
00056 #include "eos.h"
00057 #include "utilitaires.h"
00058 #include "param.h"
00059
00060
00061
00062
00063
00064
00065 MEos::MEos(int ndom_i, const Eos** mono_eos_i) : ndom(ndom_i) ,
00066 constructed_from_file(false) {
00067
00068
00069 mono_eos = new const Eos* [ndom] ;
00070
00071 for (int l=0; l<ndom; l++) {
00072 mono_eos[l] = mono_eos_i[l] ;
00073 }
00074
00075 }
00076
00077
00078 MEos::MEos(const Eos& eos1, const Eos& eos2) : ndom(2) ,
00079 constructed_from_file(false) {
00080
00081 mono_eos = new const Eos* [ndom] ;
00082
00083 mono_eos[0] = &eos1 ;
00084 mono_eos[1] = &eos2 ;
00085
00086 }
00087
00088 MEos::MEos(const Eos& eos1, const Eos& eos2, const Eos& eos3) : ndom(3) ,
00089 constructed_from_file(false) {
00090
00091 mono_eos = new const Eos* [ndom] ;
00092
00093 mono_eos[0] = &eos1 ;
00094 mono_eos[1] = &eos2 ;
00095 mono_eos[2] = &eos3 ;
00096
00097 }
00098
00099 MEos::MEos(const Eos& eos1, const Eos& eos2, const Eos& eos3, const Eos& eos4) : ndom(4) ,
00100 constructed_from_file(false) {
00101
00102 mono_eos = new const Eos* [ndom] ;
00103
00104 mono_eos[0] = &eos1 ;
00105 mono_eos[1] = &eos2 ;
00106 mono_eos[2] = &eos3 ;
00107 mono_eos[3] = &eos4 ;
00108
00109 }
00110
00111
00112 MEos::MEos(const MEos& meos) : Eos(),
00113 ndom(meos.ndom),
00114 constructed_from_file(false) {
00115
00116 mono_eos = new const Eos* [ndom] ;
00117
00118 for (int l=0; l<ndom; l++) {
00119 mono_eos[l] = meos.mono_eos[l] ;
00120 }
00121
00122 }
00123
00124
00125
00126 MEos::MEos(FILE* fich) : Eos(fich), constructed_from_file(true) {
00127
00128 fread_be(&ndom, sizeof(int), 1, fich) ;
00129
00130 mono_eos = new const Eos* [ndom] ;
00131
00132 for (int l=0; l<ndom; l++) {
00133 mono_eos[l] = Eos::eos_from_file(fich) ;
00134 }
00135 }
00136
00137
00138 MEos::MEos(ifstream& fich) : Eos(fich),
00139 constructed_from_file(true) {
00140
00141 char blabla[80] ;
00142
00143 fich >> ndom ; fich.getline(blabla, 80) ;
00144
00145 mono_eos = new const Eos* [ndom] ;
00146
00147 for (int l=0; l<ndom; l++) {
00148 mono_eos[l] = Eos::eos_from_file(fich) ;
00149 }
00150 }
00151
00152
00153
00154
00155 MEos::~MEos() {
00156
00157 if (constructed_from_file) {
00158 for (int l=0; l<ndom; l++) {
00159 delete mono_eos[l] ;
00160 }
00161 }
00162
00163 delete [] mono_eos ;
00164
00165 }
00166
00167
00168
00169
00170
00171 void MEos::operator=(const MEos& ) {
00172
00173 cout << "MEos::operator= : not implemented yet !" << endl ;
00174 abort() ;
00175
00176 }
00177
00178
00179
00180
00181
00182
00183 void MEos::sauve(FILE* fich) const {
00184
00185 Eos::sauve(fich) ;
00186
00187 fwrite_be(&ndom, sizeof(int), 1, fich) ;
00188
00189 for (int l=0; l<ndom; l++) {
00190 mono_eos[l]->sauve(fich) ;
00191 }
00192
00193 }
00194
00195 ostream& MEos::operator>>(ostream & ost) const {
00196
00197 ost << "EOS of class MEos (multi-domain equation of state) : " << endl ;
00198 ost << " Number of domains : " << ndom << endl ;
00199
00200 for (int l=0; l<ndom; l++) {
00201 ost << "Equation of state in domain " << l << " : " << endl ;
00202 ost << "-------------------------------" << endl ;
00203 ost << *(mono_eos[l]) ;
00204 }
00205
00206 return ost ;
00207
00208 }
00209
00210
00211
00212
00213
00214
00215 bool MEos::operator==(const Eos& eos_i) const {
00216
00217 bool resu = true ;
00218
00219 if ( eos_i.identify() != identify() ) {
00220 cout << "The second EOS is not of type MEos !" << endl ;
00221 resu = false ;
00222 }
00223 else{
00224
00225 const MEos& eos = dynamic_cast<const MEos&>( eos_i ) ;
00226
00227 if (eos.ndom != ndom) {
00228 cout << "The two MEos have different number of domains" << endl ;
00229 resu = false ;
00230
00231 }
00232 else {
00233 for (int l=0; l<ndom; l++) {
00234 resu = resu && ( *(mono_eos[l]) == *(eos.mono_eos[l]) ) ;
00235 }
00236 }
00237 }
00238
00239 return resu ;
00240
00241 }
00242
00243 bool MEos::operator!=(const Eos& eos_i) const {
00244
00245 return !(operator==(eos_i)) ;
00246
00247 }
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257 double MEos::nbar_ent_p(double ent, const Param* par) const {
00258
00259 int l0 = par->get_int() ;
00260
00261 return mono_eos[l0]->nbar_ent_p(ent) ;
00262
00263 }
00264
00265
00266
00267
00268 double MEos::ener_ent_p(double ent, const Param* par) const {
00269
00270 int l0 = par->get_int() ;
00271
00272 return mono_eos[l0]->ener_ent_p(ent) ;
00273 }
00274
00275
00276
00277
00278 double MEos::press_ent_p(double ent, const Param* par) const {
00279
00280 int l0 = par->get_int() ;
00281
00282 return mono_eos[l0]->press_ent_p(ent) ;
00283 }
00284
00285
00286
00287
00288 double MEos::der_nbar_ent_p(double ent, const Param* par) const {
00289
00290 int l0 = par->get_int() ;
00291
00292 return mono_eos[l0]->der_nbar_ent_p(ent) ;
00293 }
00294
00295
00296
00297
00298 double MEos::der_ener_ent_p(double ent, const Param* par) const {
00299
00300 int l0 = par->get_int() ;
00301
00302 return mono_eos[l0]->der_ener_ent_p(ent) ;
00303 }
00304
00305
00306
00307
00308 double MEos::der_press_ent_p(double ent, const Param* par) const {
00309
00310 int l0 = par->get_int() ;
00311
00312 return mono_eos[l0]->der_press_ent_p(ent) ;
00313 }
00314
00315
00316