eos_bifluid.C

00001 /*
00002  * Methods of the class Eos_bifluid.
00003  *
00004  * (see file eos_bifluid.h for documentation).
00005  */
00006 
00007 /*
00008  *   Copyright (c) 2001 Jerome Novak
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_bifluid_C[] = "$Header: /cvsroot/Lorene/C++/Source/Eos/eos_bifluid.C,v 1.16 2008/08/19 06:42:00 j_novak Exp $" ;
00030 
00031 /*
00032  * $Id: eos_bifluid.C,v 1.16 2008/08/19 06:42:00 j_novak Exp $
00033  * $Log: eos_bifluid.C,v $
00034  * Revision 1.16  2008/08/19 06:42:00  j_novak
00035  * Minor modifications to avoid warnings with gcc 4.3. Most of them concern
00036  * cast-type operations, and constant strings that must be defined as const char*
00037  *
00038  * Revision 1.15  2006/03/10 08:38:55  j_novak
00039  * Use of C++-style casts.
00040  *
00041  * Revision 1.14  2004/09/01 16:12:30  r_prix
00042  * (hopefully) fixed seg-fault bug with my inconsistent treatment of eos-bifluid 'name'
00043  * (was char-array, now char*)
00044  *
00045  * Revision 1.13  2004/09/01 09:50:34  r_prix
00046  * adapted to change in read_variable() for strings
00047  *
00048  * Revision 1.12  2003/12/17 23:12:32  r_prix
00049  * replaced use of C++ <string> by standard ANSI char* to be backwards compatible
00050  * with broken compilers like MIPSpro Compiler 7.2 on SGI Origin200. ;-)
00051  *
00052  * Revision 1.11  2003/12/05 15:09:47  r_prix
00053  * adapted Eos_bifluid class and subclasses to use read_variable() for
00054  * (formatted) file-reading.
00055  *
00056  * Revision 1.10  2003/12/04 14:17:26  r_prix
00057  * new 2-fluid EOS subtype 'typeos=5': this is identical to typeos=0
00058  * (analytic EOS), but we perform the EOS inversion "slow-rot-style",
00059  * i.e. we don't switch to a 1-fluid EOS when one fluid vanishes.
00060  *
00061  * Revision 1.9  2003/11/18 18:28:38  r_prix
00062  * moved particle-masses m_1, m_2 of the two fluids into class eos_bifluid (from eos_bf_poly)
00063  *
00064  * Revision 1.8  2003/10/03 15:58:46  j_novak
00065  * Cleaning of some headers
00066  *
00067  * Revision 1.7  2002/10/16 14:36:35  j_novak
00068  * Reorganization of #include instructions of standard C++, in order to
00069  * use experimental version 3 of gcc.
00070  *
00071  * Revision 1.6  2002/05/31 16:13:36  j_novak
00072  * better inversion for eos_bifluid
00073  *
00074  * Revision 1.5  2002/05/10 09:55:27  j_novak
00075  * *** empty log message ***
00076  *
00077  * Revision 1.4  2002/05/10 09:26:52  j_novak
00078  * Added new class Et_rot_mag for magnetized rotating neutron stars (under development)
00079  *
00080  * Revision 1.3  2002/01/03 15:30:27  j_novak
00081  * Some comments modified.
00082  *
00083  * Revision 1.2  2001/12/04 21:27:53  e_gourgoulhon
00084  *
00085  * All writing/reading to a binary file are now performed according to
00086  * the big endian convention, whatever the system is big endian or
00087  * small endian, thanks to the functions fwrite_be and fread_be
00088  *
00089  * Revision 1.1.1.1  2001/11/20 15:19:27  e_gourgoulhon
00090  * LORENE
00091  *
00092  * Revision 1.5  2001/10/10  13:49:53  eric
00093  * Modif Joachim: &(Eos_bifluid::...) --> &Eos_bifluid::...
00094  *  pour conformite au compilateur HP.
00095  *
00096  * Revision 1.4  2001/08/31  15:48:11  novak
00097  * The flag tronc has been added to nbar_ent... functions
00098  *
00099  * Revision 1.3  2001/08/27 12:23:40  novak
00100  * The Cmp arguments delta2 put to const
00101  *
00102  * Revision 1.2  2001/08/27 09:52:49  novak
00103  * Use of new variable delta2
00104  *
00105  * Revision 1.1  2001/06/21 15:21:47  novak
00106  * Initial revision
00107  *
00108  *
00109  * $Header: /cvsroot/Lorene/C++/Source/Eos/eos_bifluid.C,v 1.16 2008/08/19 06:42:00 j_novak Exp $
00110  *
00111  */
00112 
00113 // Headers C
00114 #include <stdlib.h>
00115 #include <math.h>
00116 
00117 // Headers Lorene
00118 #include "eos_bifluid.h"
00119 #include "cmp.h"
00120 #include "utilitaires.h"
00121 
00122             //--------------//
00123             // Constructors //
00124             //--------------//
00125 
00126 
00127 // Standard constructor without name
00128 // ---------------------------------
00129 Eos_bifluid::Eos_bifluid() :
00130   m_1(1), m_2(1)
00131 {
00132   name = NULL;
00133   set_name("") ; 
00134 }
00135 
00136 // Standard constructor with name and masses
00137 // ---------------------------------
00138 Eos_bifluid::Eos_bifluid(const char* name_i, double mass1, double mass2) :
00139   m_1(mass1), m_2(mass2)
00140 {
00141   name = NULL;
00142   set_name(name_i) ; 
00143 }
00144 
00145 // Copy constructor
00146 // ----------------
00147 Eos_bifluid::Eos_bifluid(const Eos_bifluid& eos_i) :
00148   m_1(eos_i.m_1), m_2(eos_i.m_2)
00149 {
00150   name = NULL;
00151   set_name(eos_i.name) ; 
00152 }
00153 
00154 // Constructor from a binary file
00155 // ------------------------------
00156 Eos_bifluid::Eos_bifluid(FILE* fich)
00157 {
00158   char dummy [MAX_EOSNAME];
00159   fread(dummy, sizeof(char),MAX_EOSNAME, fich) ;
00160   name = reinterpret_cast<char*>(MyMalloc(strlen(dummy)+1));
00161   strcpy (name, dummy);
00162   fread_be(&m_1, sizeof(double), 1, fich) ;     
00163   fread_be(&m_2, sizeof(double), 1, fich) ; 
00164     
00165 }
00166 
00167 // Constructor from a formatted file
00168 // ---------------------------------
00169 Eos_bifluid::Eos_bifluid(char *fname)
00170 {
00171   int res=0;
00172   name = NULL;
00173   char* char_name = const_cast<char*>("name");
00174   char* char_m1 = const_cast<char*>("m_1") ;
00175   char* char_m2 = const_cast<char*>("m_2") ;
00176   res += read_variable (fname, char_name, &name);
00177   res += read_variable (fname, char_m1, m_1);
00178   res += read_variable (fname, char_m2, m_2);
00179 
00180   if (res)
00181     {
00182       cerr << "ERROR: Eos_bifluid(char*): could not read either of \
00183 the variables 'name', 'm_1, or 'm_2' from file " << fname << endl;
00184       exit (-1);
00185     }
00186 
00187 }
00188 
00189 
00190 
00191             //--------------//
00192             //  Destructor  //
00193             //--------------//
00194 
00195 Eos_bifluid::~Eos_bifluid()
00196 {
00197   if (name)
00198     free (name);
00199 }
00200 
00201             //--------------//
00202             //  Assignment  //
00203             //--------------//
00204 void Eos_bifluid::operator=(const Eos_bifluid& eosi) {
00205     
00206     set_name(eosi.name) ; 
00207 
00208     m_1 = eosi.m_1;
00209     m_2 = eosi.m_2;
00210     
00211 }
00212 
00213 
00214 
00215             //-------------------------//
00216             //  Manipulation of name   //
00217             //-------------------------//
00218             
00219             
00220 void Eos_bifluid::set_name(const char* name_i) 
00221 {
00222   if (name)
00223     free (name);
00224 
00225   name = reinterpret_cast<char*>(MyMalloc (strlen(name_i) +1));
00226   strcpy(name, name_i);
00227     
00228 }
00229 
00230 const char* Eos_bifluid::get_name() const {
00231     
00232     return name ; 
00233     
00234 }
00235 
00236             //------------//
00237             //  Outputs   //
00238             //------------//
00239 
00240 void Eos_bifluid::sauve(FILE* fich) const 
00241 {
00242   char dummy [MAX_EOSNAME];
00243   int ident = identify() ; 
00244 
00245   fwrite_be(&ident, sizeof(int), 1, fich) ; 
00246 
00247   strncpy (dummy, name, MAX_EOSNAME);
00248   dummy[MAX_EOSNAME-1] = 0;
00249   fwrite(dummy, sizeof(char), MAX_EOSNAME, fich );
00250 
00251   fwrite_be(&m_1, sizeof(double), 1, fich) ;    
00252   fwrite_be(&m_2, sizeof(double), 1, fich) ;    
00253    
00254 }
00255     
00256 
00257 ostream& operator<<(ostream& ost, const Eos_bifluid& eqetat)  {
00258     ost << eqetat.get_name() << endl ; 
00259     ost << "   Mean particle 1 mass : " << eqetat.get_m1() << " m_B" << endl ;
00260     ost << "   Mean particle 2 mass : " << eqetat.get_m2() << " m_B" << endl ;
00261 
00262     eqetat >> ost ;
00263     return ost ;
00264 }
00265 
00266 
00267             //-------------------------------//
00268             //    Computational routines     //
00269             //-------------------------------//
00270 
00271 // Complete computational routine giving all thermo variables
00272 //-----------------------------------------------------------
00273 
00274 void Eos_bifluid::calcule_tout(const Cmp& ent1, const Cmp& ent2, 
00275                    const Cmp& delta2, Cmp& nbar1, Cmp& nbar2,  
00276                    Cmp& ener, Cmp& press, 
00277                    int nzet, int l_min) const {
00278   
00279   assert(ent1.get_etat() != ETATNONDEF) ; 
00280   assert(ent2.get_etat() != ETATNONDEF) ; 
00281   assert(delta2.get_etat() != ETATNONDEF) ;
00282   
00283   const Map* mp = ent1.get_mp() ;   // Mapping
00284   assert(mp == ent2.get_mp()) ;
00285   assert(mp == delta2.get_mp()) ;
00286   assert(mp == ener.get_mp()) ;
00287   
00288   if ((ent1.get_etat() == ETATZERO)&&(ent2.get_etat() == ETATZERO)) {
00289     nbar1.set_etat_zero() ; 
00290     nbar2.set_etat_zero() ; 
00291     ener.set_etat_zero() ; 
00292     press.set_etat_zero() ; 
00293     return ; 
00294   }
00295   nbar1.allocate_all() ;
00296   nbar2.allocate_all() ;
00297   ener.allocate_all() ;
00298   press.allocate_all() ;
00299 
00300   const Mg3d* mg = mp->get_mg() ;   // Multi-grid
00301   
00302   int nz = mg->get_nzone() ;        // total number of domains
00303   
00304   // resu is set to zero in the other domains :
00305   
00306   if (l_min > 0) {
00307     nbar1.annule(0, l_min-1) ; 
00308     nbar2.annule(0, l_min-1) ; 
00309     ener.annule(0, l_min-1) ; 
00310     press.annule(0, l_min-1) ; 
00311   }
00312   
00313   if (l_min + nzet < nz) {
00314     nbar1.annule(l_min + nzet, nz - 1) ; 
00315     nbar2.annule(l_min + nzet, nz - 1) ; 
00316     ener.annule(l_min + nzet, nz - 1) ; 
00317     press.annule(l_min + nzet, nz - 1) ; 
00318   }
00319 
00320   int np0 = mp->get_mg()->get_np(0) ;
00321   int nt0 = mp->get_mg()->get_nt(0) ;
00322   for (int l=l_min; l<l_min+nzet; l++) {
00323     assert(mp->get_mg()->get_np(l) == np0) ;
00324     assert(mp->get_mg()->get_nt(l) == nt0) ; 
00325   }
00326 
00327   //**********************************************************************
00328   //RP: for comparison with slow-rotation, we might have to treat the 
00329   // 1-fluid region somewhat differently...
00330   bool slow_rot_style = false;  // off by default
00331 
00332   if ( identify() == 2 )  // only applies if newtonian 2-fluid polytrope
00333     {
00334       const Eos_bf_poly_newt *this_eos = dynamic_cast<const Eos_bf_poly_newt*>(this);
00335       if (this_eos -> get_typeos() == 5)
00336     {
00337       slow_rot_style = true;
00338       cout << "DEBUG: using EOS-inversion slow-rot-style!! " << endl;
00339     }
00340     }
00341 
00342   //**********************************************************************
00343 
00344   for (int k=0; k<np0; k++) {
00345     for (int j=0; j<nt0; j++) {
00346       bool inside = true ;
00347       bool inside1 = true ;
00348       bool inside2 = true ;
00349       for (int l=l_min; l< l_min + nzet; l++) {
00350     for (int i=0; i<mp->get_mg()->get_nr(l); i++) {
00351       double xx, xx1, xx2, n1, n2 ;
00352       xx1 = ent1(l,k,j,i) ; 
00353       xx2 = ent2(l,k,j,i) ; 
00354       xx = delta2(l,k,j,i) ;
00355       if (inside) {
00356         inside = (!nbar_ent_p(xx1, xx2, xx, n1, n2)) ; 
00357         //      inside1 = ((n1 > 0.)&&(xx1>0.)) ;
00358         inside1 = (n1 > 0.) ;
00359         //      inside2 = ((n2 > 0.)&&(xx2>0.)) ;
00360         inside2 = (n2 > 0.) ;
00361 
00362         // slowrot special treatment follows here.
00363         if (slow_rot_style)
00364           {
00365         inside = true;  // no 1-fluid transition!
00366         n1 = (n1 > 0) ? n1: 0;  // make sure only positive densities
00367         n2 = (n2 > 0) ? n2: 0;
00368           }
00369       }
00370       if (inside) {
00371         nbar1.set(l,k,j,i) = n1 ;
00372         nbar2.set(l,k,j,i) = n2 ;
00373       }
00374       else {
00375         if (inside1) {
00376           n1 = nbar_ent_p1(xx1) ;
00377           inside1 = (n1 > 0.) ;
00378         }
00379         if (inside2) {
00380           n2 = nbar_ent_p2(xx2) ;
00381           inside2 = (n2 > 0.) ;
00382         }
00383         if (!inside1) n1 = 0. ;
00384         if (!inside2) n2 = 0. ;
00385         nbar1.set(l,k,j,i) = n1 ;
00386         nbar2.set(l,k,j,i) = n2 ;
00387       }
00388 
00389       ener.set(l,k,j,i) = ener_nbar_p(n1, n2, xx) ;
00390       press.set(l,k,j,i) = press_nbar_p(n1, n2, xx) ;
00391 
00392     }
00393       }
00394     }
00395   }
00396 
00397 }
00398 
00399 // Baryon density from enthalpy 
00400 //------------------------------
00401 
00402 void Eos_bifluid::nbar_ent(const Cmp& ent1, const Cmp& ent2, const Cmp& delta2,
00403                Cmp& nbar1, Cmp& nbar2, int nzet, int l_min) const {
00404   
00405   assert(ent1.get_etat() != ETATNONDEF) ; 
00406   assert(ent2.get_etat() != ETATNONDEF) ; 
00407   assert(delta2.get_etat() != ETATNONDEF) ;
00408   
00409   const Map* mp = ent1.get_mp() ;   // Mapping
00410   assert(mp == ent2.get_mp()) ;
00411   assert(mp == delta2.get_mp()) ;
00412   assert(mp == nbar1.get_mp()) ;
00413   
00414   if ((ent1.get_etat() == ETATZERO)&&(ent2.get_etat() == ETATZERO)) {
00415     nbar1.set_etat_zero() ; 
00416     nbar2.set_etat_zero() ; 
00417     return ; 
00418   }
00419   nbar1.allocate_all() ;
00420   nbar2.allocate_all() ;
00421 
00422   const Mg3d* mg = mp->get_mg() ;   // Multi-grid
00423   
00424   int nz = mg->get_nzone() ;        // total number of domains
00425   
00426   // resu is set to zero in the other domains :
00427   
00428   if (l_min > 0) {
00429     nbar1.annule(0, l_min-1) ; 
00430     nbar2.annule(0, l_min-1) ; 
00431   }
00432   
00433   if (l_min + nzet < nz) {
00434     nbar1.annule(l_min + nzet, nz - 1) ; 
00435     nbar2.annule(l_min + nzet, nz - 1) ; 
00436   }
00437 
00438   int np0 = mp->get_mg()->get_np(0) ;
00439   int nt0 = mp->get_mg()->get_nt(0) ;
00440   for (int l=l_min; l<l_min+nzet; l++) {
00441     assert(mp->get_mg()->get_np(l) == np0) ;
00442     assert(mp->get_mg()->get_nt(l) == nt0) ; 
00443   }
00444 
00445   for (int k=0; k<np0; k++) {
00446     for (int j=0; j<nt0; j++) {
00447       bool inside = true ;
00448       bool inside1 = true ;
00449       bool inside2 = true ;
00450       for (int l=l_min; l< l_min + nzet; l++) {
00451     for (int i=0; i<mp->get_mg()->get_nr(l); i++) {
00452       double xx, xx1, xx2, n1, n2 ;
00453       xx1 = ent1(l,k,j,i) ; 
00454       xx2 = ent2(l,k,j,i) ; 
00455       xx = delta2(l,k,j,i) ;
00456       if (inside) {
00457         inside = (!nbar_ent_p(xx1, xx2, xx, n1, n2)) ; 
00458         inside1 = ((n1 > 0.)&&(xx1>0.)) ;
00459         inside2 = ((n2 > 0.)&&(xx2>0.)) ;
00460       }
00461       if (inside) {
00462         nbar1.set(l,k,j,i) = n1 ;
00463         nbar2.set(l,k,j,i) = n2 ;
00464       }
00465       else {
00466         if (inside1) {
00467           n1 = nbar_ent_p1(xx1) ;
00468           inside1 = (n1 > 0.) ;
00469         }
00470         if (!inside1) n1 = 0. ;
00471         if (inside2) {
00472           n2 = nbar_ent_p2(xx2) ;
00473           inside2 = (n2 > 0.) ;
00474         }
00475         if (!inside2) n2 = 0. ;
00476         nbar1.set(l,k,j,i) = n1 ;
00477         nbar2.set(l,k,j,i) = n2 ;
00478       }
00479     }
00480       }
00481     }
00482   }
00483 
00484 }
00485 
00486 
00487 // Energy density from enthalpy 
00488 //------------------------------
00489 
00490 Cmp Eos_bifluid::ener_ent(const Cmp& ent1, const Cmp& ent2, const Cmp& delta2, 
00491               int nzet, int l_min) const {
00492     
00493   Cmp ener(ent1.get_mp()) ; 
00494   assert(ent1.get_etat() != ETATNONDEF) ; 
00495   assert(ent2.get_etat() != ETATNONDEF) ; 
00496   assert(delta2.get_etat() != ETATNONDEF) ;
00497     
00498   const Map* mp = ent1.get_mp() ;   // Mapping
00499   assert(mp == ent2.get_mp()) ;
00500   assert(mp == delta2.get_mp()) ;
00501     
00502   if ((ent1.get_etat() == ETATZERO)&&(ent2.get_etat() == ETATZERO)) {
00503     ener.set_etat_zero() ; 
00504     return ener; 
00505   }
00506   
00507   ener.allocate_all() ;
00508 
00509   const Mg3d* mg = mp->get_mg() ;   // Multi-grid
00510   
00511   int nz = mg->get_nzone() ;        // total number of domains
00512   
00513   // resu is set to zero in the other domains :
00514   
00515   if (l_min > 0) 
00516     ener.annule(0, l_min-1) ; 
00517   
00518   if (l_min + nzet < nz) 
00519     ener.annule(l_min + nzet, nz - 1) ; 
00520 
00521   int np0 = mp->get_mg()->get_np(0) ;
00522   int nt0 = mp->get_mg()->get_nt(0) ;
00523   for (int l=l_min; l<l_min+nzet; l++) {
00524     assert(mp->get_mg()->get_np(l) == np0) ;
00525     assert(mp->get_mg()->get_nt(l) == nt0) ; 
00526   }
00527 
00528   for (int k=0; k<np0; k++) {
00529     for (int j=0; j<nt0; j++) {
00530       bool inside = true ;
00531       bool inside1 = true ;
00532       bool inside2 = true ;
00533       for (int l=l_min; l< l_min + nzet; l++) {
00534     for (int i=0; i<mp->get_mg()->get_nr(l); i++) {
00535       double xx, xx1, xx2, n1, n2 ;
00536       xx1 = ent1(l,k,j,i) ; 
00537       xx2 = ent2(l,k,j,i) ; 
00538       xx = delta2(l,k,j,i) ;
00539       if (inside) {
00540         inside = (!nbar_ent_p(xx1, xx2, xx, n1, n2)) ; 
00541         inside1 = ((n1 > 0.)&&(xx1>0.)) ;
00542         inside2 = ((n2 > 0.)&&(xx2>0.)) ;
00543       }
00544       if (inside) {
00545         ener.set(l,k,j,i) = ener_nbar_p(n1, n2, xx) ;
00546       }
00547       else {
00548         if (inside1) {
00549           n1 = nbar_ent_p1(xx1) ;
00550           inside1 = (n1 > 0.) ;
00551         }
00552         if (!inside1) n1 = 0. ;
00553         if (inside2) {
00554           n2 = nbar_ent_p2(xx2) ;
00555           inside2 = (n2 > 0.) ;
00556         }
00557         if (!inside2) n2 = 0. ;
00558         ener.set(l,k,j,i) = ener_nbar_p(n1, n2, 0.) ;
00559       }
00560     }
00561       }
00562     }
00563   }
00564   return ener ;
00565 }
00566 
00567 // Pressure from enthalpies 
00568 //-------------------------
00569 
00570 Cmp Eos_bifluid::press_ent(const Cmp& ent1, const Cmp& ent2, const Cmp& delta2, 
00571               int nzet, int l_min ) const {
00572     
00573   Cmp press(ent1.get_mp()) ; 
00574   assert(ent1.get_etat() != ETATNONDEF) ; 
00575   assert(ent2.get_etat() != ETATNONDEF) ; 
00576   assert(delta2.get_etat() != ETATNONDEF) ;
00577     
00578   const Map* mp = ent1.get_mp() ;   // Mapping
00579   assert(mp == ent2.get_mp()) ;
00580     
00581   if ((ent1.get_etat() == ETATZERO)&&(ent2.get_etat() == ETATZERO)) {
00582     press.set_etat_zero() ; 
00583     return press; 
00584   }
00585   press.allocate_all() ;
00586 
00587   const Mg3d* mg = mp->get_mg() ;   // Multi-grid
00588   
00589   int nz = mg->get_nzone() ;        // total number of domains
00590   
00591   // resu is set to zero in the other domains :
00592   
00593   if (l_min > 0) 
00594     press.annule(0, l_min-1) ; 
00595   
00596   if (l_min + nzet < nz) 
00597     press.annule(l_min + nzet, nz - 1) ; 
00598 
00599   int np0 = mp->get_mg()->get_np(0) ;
00600   int nt0 = mp->get_mg()->get_nt(0) ;
00601   for (int l=l_min; l<l_min+nzet; l++) {
00602     assert(mp->get_mg()->get_np(l) == np0) ;
00603     assert(mp->get_mg()->get_nt(l) == nt0) ; 
00604   }
00605 
00606   for (int k=0; k<np0; k++) {
00607     for (int j=0; j<nt0; j++) {
00608       bool inside = true ;
00609       bool inside1 = true ;
00610       bool inside2 = true ;
00611       for (int l=l_min; l< l_min + nzet; l++) {
00612     for (int i=0; i<mp->get_mg()->get_nr(l); i++) {
00613       double xx, xx1, xx2, n1, n2 ;
00614       xx1 = ent1(l,k,j,i) ; 
00615       xx2 = ent2(l,k,j,i) ; 
00616       xx = delta2(l,k,j,i) ;
00617       if (inside) {
00618         inside = (!nbar_ent_p(xx1, xx2, xx, n1, n2)) ; 
00619         inside1 = ((n1 > 0.)&&(xx1>0.)) ;
00620         inside2 = ((n2 > 0.)&&(xx2>0.)) ;
00621       }
00622       if (inside) 
00623         press.set(l,k,j,i) = press_nbar_p(n1, n2, xx) ;
00624       else {
00625         if (inside1) {
00626           n1 = nbar_ent_p1(xx1) ;
00627           inside1 = (n1 > 0.) ;
00628         }
00629         if (!inside1) n1 = 0. ;
00630         if (inside2) {
00631           n2 = nbar_ent_p2(xx2) ;
00632           inside2 = (n2 > 0.) ;
00633         }
00634         if (!inside2) n2 = 0. ;
00635         press.set(l,k,j,i) = press_nbar_p(n1, n2, 0. ) ;
00636       }
00637     }
00638       }
00639     }
00640   }
00641   return press ;
00642 }
00643 
00644 // Generic computational routine for get_Kxx
00645 //------------------------------------------
00646 
00647 void Eos_bifluid::calcule(const Cmp& nbar1, const Cmp& nbar2, const Cmp&
00648              x2, int nzet, int l_min, double
00649              (Eos_bifluid::*fait)(double, double, double) const, 
00650               Cmp& resu) const {
00651     
00652     assert(nbar1.get_etat() != ETATNONDEF) ; 
00653     assert(nbar2.get_etat() != ETATNONDEF) ; 
00654     assert(x2.get_etat() != ETATNONDEF) ; 
00655     
00656     const Map* mp = nbar1.get_mp() ;    // Mapping
00657     assert(mp == nbar2.get_mp()) ;
00658     
00659     
00660     if ((nbar1.get_etat() == ETATZERO)&&(nbar2.get_etat() == ETATZERO)) {
00661     resu.set_etat_zero() ; 
00662     return ; 
00663     }
00664     
00665     bool nb1 = nbar1.get_etat() == ETATQCQ ; 
00666     bool nb2 = nbar2.get_etat() == ETATQCQ ; 
00667     bool bx2 = x2.get_etat() == ETATQCQ ; 
00668     const Valeur* vnbar1 = 0x0 ;
00669     const Valeur* vnbar2 = 0x0 ;
00670     const Valeur* vx2 = 0x0 ;
00671     if (nb1) { vnbar1 = &nbar1.va ;
00672     vnbar1->coef_i() ; }
00673     if (nb2) { vnbar2 = &nbar2.va ;
00674     vnbar2->coef_i() ; }
00675     if (bx2) {vx2 = & x2.va ;
00676     vx2->coef_i() ; }
00677    
00678     const Mg3d* mg = mp->get_mg() ; // Multi-grid
00679     
00680     int nz = mg->get_nzone() ;      // total number of domains
00681     
00682     // Preparations for a point by point computation:
00683     resu.set_etat_qcq() ;
00684     Valeur& vresu = resu.va ; 
00685     vresu.set_etat_c_qcq() ;
00686     vresu.c->set_etat_qcq() ;
00687 
00688     // Loop on domains where the computation has to be done :
00689     for (int l = l_min; l< l_min + nzet; l++) {
00690     
00691       assert(l>=0) ; 
00692       assert(l<nz) ; 
00693       
00694       Tbl* tnbar1 = 0x0 ;
00695       Tbl* tnbar2 = 0x0 ;
00696       Tbl* tx2 = 0x0 ;
00697       
00698       if (nb1) tnbar1 = vnbar1->c->t[l] ;
00699       if (nb2) tnbar2 = vnbar2->c->t[l] ;
00700       if (bx2) tx2 = vx2->c->t[l] ;
00701       Tbl* tresu = vresu.c->t[l] ; 
00702       
00703       bool nb1b = false ;
00704       if (nb1) nb1b = tnbar1->get_etat() == ETATQCQ ;
00705       bool nb2b = false ;
00706       if (nb2) nb2b = tnbar2->get_etat() == ETATQCQ ;
00707       bool bx2b = false ;
00708       if (bx2) bx2b = tx2->get_etat() == ETATQCQ ;
00709       tresu->set_etat_qcq() ;
00710       
00711       double n1, n2, xx ;
00712       
00713       for (int i=0; i<tnbar1->get_taille(); i++) {
00714     
00715     n1 = nb1b ? tnbar1->t[i] : 0 ;
00716     n2 = nb2b ? tnbar2->t[i] : 0 ;
00717     xx = bx2b ? tx2->t[i] : 0 ;
00718     tresu->t[i] = (this->*fait)(n1, n2, xx ) ;
00719       }  
00720       
00721     }  // End of the loop on domains where the computation had to be done
00722     
00723     // resu is set to zero in the other domains :
00724     
00725     if (l_min > 0) {
00726       resu.annule(0, l_min-1) ; 
00727     }
00728     
00729     if (l_min + nzet < nz) {
00730       resu.annule(l_min + nzet, nz - 1) ; 
00731     }
00732 }
00733 
00734 Cmp Eos_bifluid::get_Knn(const Cmp& nbar1, const Cmp& nbar2, const Cmp&
00735              delta2, int nzet, int l_min) const {
00736     
00737     Cmp resu(nbar1.get_mp()) ; 
00738     
00739     calcule(nbar1, nbar2, delta2, nzet, l_min, &Eos_bifluid::get_K11, resu) ;
00740     
00741     return resu ; 
00742     
00743 }
00744 
00745 Cmp Eos_bifluid::get_Knp(const Cmp& nbar1, const Cmp& nbar2, const Cmp& 
00746              delta2, int nzet, int l_min) const {
00747     
00748     Cmp resu(delta2.get_mp()) ; 
00749     
00750     calcule(nbar1, nbar2, delta2, nzet, l_min, &Eos_bifluid::get_K12, resu) ;
00751     
00752     return resu ; 
00753     
00754 }
00755 
00756 Cmp Eos_bifluid::get_Kpp(const Cmp& nbar1, const Cmp& nbar2, const Cmp& 
00757              delta2, int nzet, int l_min) const {
00758     
00759     Cmp resu(nbar2.get_mp()) ; 
00760     
00761     calcule(nbar1, nbar2, delta2, nzet, l_min, &Eos_bifluid::get_K22, resu) ;
00762     
00763     return resu ; 
00764     
00765 }

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