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
00027
00028
00029 char eos_C[] = "$Header: /cvsroot/Lorene/C++/Source/Eos/eos.C,v 1.5 2004/01/14 15:59:42 f_limousin Exp $" ;
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 #include <stdlib.h>
00086 #include <string.h>
00087
00088
00089 #include "eos.h"
00090 #include "cmp.h"
00091 #include "scalar.h"
00092 #include "utilitaires.h"
00093
00094
00095
00096
00097
00098
00099
00100
00101 Eos::Eos(){
00102
00103 set_name("") ;
00104
00105 }
00106
00107
00108
00109 Eos::Eos(const char* name_i){
00110
00111 set_name(name_i) ;
00112
00113 }
00114
00115
00116
00117 Eos::Eos(const Eos& eos_i){
00118
00119 set_name(eos_i.name) ;
00120
00121 }
00122
00123
00124
00125 Eos::Eos(FILE* fich){
00126
00127 fread(name, sizeof(char), 100, fich) ;
00128
00129 }
00130
00131
00132
00133 Eos::Eos(ifstream& fich){
00134
00135 fich.getline(name, 100) ;
00136
00137 }
00138
00139
00140
00141
00142
00143
00144
00145 Eos::~Eos(){
00146
00147
00148
00149 }
00150
00151
00152
00153
00154
00155
00156 void Eos::set_name(const char* name_i) {
00157
00158 strncpy(name, name_i, 100) ;
00159
00160 }
00161
00162 const char* Eos::get_name() const {
00163
00164 return name ;
00165
00166 }
00167
00168
00169
00170
00171
00172 void Eos::sauve(FILE* fich) const {
00173
00174 int ident = identify() ;
00175 fwrite_be(&ident, sizeof(int), 1, fich) ;
00176
00177 fwrite(name, sizeof(char), 100, fich) ;
00178
00179 }
00180
00181
00182
00183
00184 ostream& operator<<(ostream& ost, const Eos& eqetat) {
00185 ost << eqetat.get_name() << endl ;
00186 eqetat >> ost ;
00187 return ost ;
00188 }
00189
00190
00191
00192
00193
00194
00195
00196 void Eos::calcule(const Cmp& ent, int nzet, int l_min,
00197 double (Eos::*fait)(double, const Param*) const, const Param* par, Cmp& resu) const {
00198
00199 assert(ent.get_etat() != ETATNONDEF) ;
00200
00201 const Map* mp = ent.get_mp() ;
00202
00203
00204 if (ent.get_etat() == ETATZERO) {
00205 resu.set_etat_zero() ;
00206 return ;
00207 }
00208
00209 assert(ent.get_etat() == ETATQCQ) ;
00210 const Valeur& vent = ent.va ;
00211 vent.coef_i() ;
00212
00213 const Mg3d* mg = mp->get_mg() ;
00214
00215 int nz = mg->get_nzone() ;
00216
00217
00218 resu.set_etat_qcq() ;
00219 Valeur& vresu = resu.va ;
00220 vresu.set_etat_c_qcq() ;
00221 vresu.c->set_etat_qcq() ;
00222
00223
00224 for (int l = l_min; l< l_min + nzet; l++) {
00225
00226 assert(l>=0) ;
00227 assert(l<nz) ;
00228
00229 Tbl* tent = vent.c->t[l] ;
00230 Tbl* tresu = vresu.c->t[l] ;
00231
00232 if (tent->get_etat() == ETATZERO) {
00233 tresu->set_etat_zero() ;
00234 }
00235 else {
00236 assert( tent->get_etat() == ETATQCQ ) ;
00237 tresu->set_etat_qcq() ;
00238
00239 for (int i=0; i<tent->get_taille(); i++) {
00240
00241 tresu->t[i] = (this->*fait)( tent->t[i], par ) ;
00242 }
00243
00244 }
00245
00246 }
00247
00248
00249
00250 if (l_min > 0) {
00251 resu.annule(0, l_min-1) ;
00252 }
00253
00254 if (l_min + nzet < nz) {
00255 resu.annule(l_min + nzet, nz - 1) ;
00256 }
00257 }
00258
00259
00260
00261 void Eos::calcule(const Scalar& ent, int nzet, int l_min,
00262 double (Eos::*fait)(double, const Param*) const, const Param* par, Scalar& resu) const {
00263
00264 assert(ent.get_etat() != ETATNONDEF) ;
00265
00266 const Map* mp = &(ent.get_mp()) ;
00267
00268
00269 if (ent.get_etat() == ETATZERO) {
00270 resu.set_etat_zero() ;
00271 return ;
00272 }
00273
00274 assert(ent.get_etat() == ETATQCQ) ;
00275 const Valeur& vent = ent.get_spectral_va() ;
00276 vent.coef_i() ;
00277
00278 const Mg3d* mg = mp->get_mg() ;
00279
00280 int nz = mg->get_nzone() ;
00281
00282
00283 resu.set_etat_qcq() ;
00284 Valeur& vresu = resu.set_spectral_va() ;
00285 vresu.set_etat_c_qcq() ;
00286 vresu.c->set_etat_qcq() ;
00287
00288
00289 for (int l = l_min; l< l_min + nzet; l++) {
00290
00291 assert(l>=0) ;
00292 assert(l<nz) ;
00293
00294 Tbl* tent = vent.c->t[l] ;
00295 Tbl* tresu = vresu.c->t[l] ;
00296
00297 if (tent->get_etat() == ETATZERO) {
00298 tresu->set_etat_zero() ;
00299 }
00300 else {
00301 assert( tent->get_etat() == ETATQCQ ) ;
00302 tresu->set_etat_qcq() ;
00303
00304 for (int i=0; i<tent->get_taille(); i++) {
00305
00306 tresu->t[i] = (this->*fait)( tent->t[i], par ) ;
00307 }
00308
00309 }
00310
00311 }
00312
00313
00314
00315 if (l_min > 0) {
00316 resu.annule(0, l_min-1) ;
00317 }
00318
00319 if (l_min + nzet < nz) {
00320 resu.annule(l_min + nzet, nz - 1) ;
00321 }
00322 }
00323
00324
00325
00326
00327
00328
00329
00330
00331 Cmp Eos::nbar_ent(const Cmp& ent, int nzet, int l_min, const Param* par) const {
00332
00333 Cmp resu(ent.get_mp()) ;
00334
00335 calcule(ent, nzet, l_min, &Eos::nbar_ent_p, par, resu) ;
00336
00337 return resu ;
00338
00339 }
00340
00341 Scalar Eos::nbar_ent(const Scalar& ent, int nzet, int l_min, const Param* par) const {
00342
00343 Scalar resu(ent.get_mp()) ;
00344
00345 calcule(ent, nzet, l_min, &Eos::nbar_ent_p, par, resu) ;
00346
00347 return resu ;
00348
00349 }
00350
00351
00352
00353
00354
00355
00356 Cmp Eos::ener_ent(const Cmp& ent, int nzet, int l_min, const Param* par) const {
00357
00358 Cmp resu(ent.get_mp()) ;
00359
00360 calcule(ent, nzet, l_min, &Eos::ener_ent_p, par, resu) ;
00361
00362 return resu ;
00363
00364 }
00365
00366 Scalar Eos::ener_ent(const Scalar& ent, int nzet, int l_min, const Param* par) const {
00367
00368 Scalar resu(ent.get_mp()) ;
00369
00370 calcule(ent, nzet, l_min, &Eos::ener_ent_p, par, resu) ;
00371
00372 return resu ;
00373
00374 }
00375
00376
00377
00378 Cmp Eos::press_ent(const Cmp& ent, int nzet, int l_min, const Param* par) const {
00379
00380 Cmp resu(ent.get_mp()) ;
00381
00382 calcule(ent, nzet, l_min, &Eos::press_ent_p, par, resu) ;
00383
00384 return resu ;
00385
00386 }
00387
00388 Scalar Eos::press_ent(const Scalar& ent, int nzet, int l_min, const Param* par) const {
00389
00390 Scalar resu(ent.get_mp()) ;
00391
00392 calcule(ent, nzet, l_min, &Eos::press_ent_p, par, resu) ;
00393
00394 return resu ;
00395
00396 }
00397
00398
00399
00400 Cmp Eos::der_nbar_ent(const Cmp& ent, int nzet, int l_min, const Param* par) const {
00401
00402 Cmp resu(ent.get_mp()) ;
00403
00404 calcule(ent, nzet, l_min, &Eos::der_nbar_ent_p, par, resu) ;
00405
00406 return resu ;
00407
00408 }
00409
00410 Scalar Eos::der_nbar_ent(const Scalar& ent, int nzet, int l_min, const Param* par) const {
00411
00412 Scalar resu(ent.get_mp()) ;
00413
00414 calcule(ent, nzet, l_min, &Eos::der_nbar_ent_p, par, resu) ;
00415
00416 return resu ;
00417
00418 }
00419
00420
00421
00422
00423 Cmp Eos::der_ener_ent(const Cmp& ent, int nzet, int l_min, const Param* par) const {
00424
00425 Cmp resu(ent.get_mp()) ;
00426
00427 calcule(ent, nzet, l_min, &Eos::der_ener_ent_p, par, resu) ;
00428
00429 return resu ;
00430
00431 }
00432
00433 Scalar Eos::der_ener_ent(const Scalar& ent, int nzet, int l_min, const Param* par) const {
00434
00435 Scalar resu(ent.get_mp()) ;
00436
00437 calcule(ent, nzet, l_min, &Eos::der_ener_ent_p, par, resu) ;
00438
00439 return resu ;
00440
00441 }
00442
00443
00444
00445 Cmp Eos::der_press_ent(const Cmp& ent, int nzet, int l_min, const Param* par) const {
00446
00447 Cmp resu(ent.get_mp()) ;
00448
00449 calcule(ent, nzet, l_min, &Eos::der_press_ent_p, par, resu) ;
00450
00451 return resu ;
00452
00453 }
00454
00455 Scalar Eos::der_press_ent(const Scalar& ent, int nzet, int l_min, const Param* par) const {
00456
00457 Scalar resu(ent.get_mp()) ;
00458
00459 calcule(ent, nzet, l_min, &Eos::der_press_ent_p, par, resu) ;
00460
00461 return resu ;
00462
00463 }