prolonge_c1.C

00001 /*
00002  *  Small utility for determining the surface for 2-fluid stars.
00003  *
00004  */
00005 
00006 /*
00007  *   Copyright (c) 2002  Jerome Novak
00008  *
00009  *   This file is part of LORENE.
00010  *
00011  *   LORENE is free software; you can redistribute it and/or modify
00012  *   it under the terms of the GNU General Public License version 2
00013  *   as published by the Free Software Foundation.
00014  *
00015  *   LORENE is distributed in the hope that it will be useful,
00016  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *   GNU General Public License for more details.
00019  *
00020  *   You should have received a copy of the GNU General Public License
00021  *   along with LORENE; if not, write to the Free Software
00022  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *
00024  */
00025 
00026 char name_of_this_file_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Utilities/prolonge_c1.C,v 1.2 2003/12/19 16:21:49 j_novak Exp $" ;
00027 
00028 #include "cmp.h"
00029 
00030 Cmp prolonge_c1(const Cmp& uu, const int nzet) {
00031 
00032   const Map_radial* mpi = dynamic_cast<const Map_radial*>( uu.get_mp() ) ; 
00033   
00034   if (mpi == 0x0) {
00035     cout << 
00036       "prolonge_c1 : The mapping does not belong to the class Map_radial !"
00037      << endl ; 
00038     abort() ;
00039   }
00040   
00041   const Map_radial& mp = *mpi ; 
00042 
00043   const Mg3d& mg = *(mp.get_mg()) ; 
00044     
00045   int nz = mg.get_nzone() ; 
00046   assert((nzet > 0)&&(nzet<nz)) ; 
00047 
00048   Cmp resu(mp) ;
00049   resu.allocate_all() ;
00050   double nbc = uu(0, 0, 0, 0) ;
00051   double resu_ext =  - 0.2 * nbc ;
00052   const Coord& rr = mp.r ;
00053   double rout = (+rr)(nzet,0,0,mg.get_nr(nzet)-1) ;
00054   double rin = 0 ; double resu1 = 0 ; double dresu1 = 0 ;
00055   double a = 0 ; double b = 0 ;
00056   for (int k=0; k<mg.get_np(0); k++) 
00057     for (int j=0; j<mg.get_nt(0); j++) { 
00058       double ir = 0 ;
00059       double nm2 = nbc ;
00060       double nm1 = nbc ;
00061       double nb0 = nbc ;
00062       double np1 = nbc ;
00063       double rm2 = 0 ;
00064       double rm1 = 0 ;
00065       double r0 = 0 ;
00066       double rp1 = 0 ;
00067       bool dedans = true ;
00068       for (int lz=0; lz <= nzet; lz++) {
00069     for (int i=1; i<mg.get_nr(lz); i++) {
00070       ir++ ;
00071       rm2 = rm1 ;
00072       rm1 = r0 ;
00073       r0 = rp1 ;
00074       rp1 = (+rr)(lz,k,j,i) ;
00075       nm2 = nm1 ;
00076       nm1 = nb0 ;
00077       nb0 = np1 ;
00078       np1 = uu(lz,k,j,i) ;
00079       if ((np1<=0.) && dedans) {
00080         if (ir<2) {
00081           cout << "Problem prolonge_c1!" << endl ;
00082           abort() ;
00083         }
00084         resu1 = nm1 * (r0-rp1)*(rm2-rp1) 
00085           / ((r0-rm1)*(rm2-rm1))
00086           + nm2 * (r0-rp1)*(rm1-rp1) / ((r0-rm2)*(rm1-rm2))
00087           + nb0 * (rm1-rp1)*(rm2-rp1) / ((rm1-r0)*(rm2-r0)) ;
00088         resu.set(lz,k,j,i) = resu1 ; 
00089         dresu1 = nm1 * ((rp1-r0) + (rp1-rm2)) 
00090           / ((r0-rm1)*(rm2-rm1))
00091           + nm2 * ((rp1-r0) + (rp1-rm1)) / ((r0-rm2)*(rm1-rm2))
00092           + nb0 * ((rp1-rm1) + (rp1-rm2)) / ((rm1-r0)*(rm2-r0)) ;
00093         a = (dresu1 - 2*(resu_ext - resu1)/(rout - rp1))/
00094           ((rout-rp1)*(rout-rp1)) ;
00095         b = 0.5*(-dresu1/(rout-rp1) - a*(rout+rp1)) ;
00096         rin = rp1 ;
00097         dedans = false ;
00098       }
00099       else {
00100         resu.set(lz,k,j,i) = (dedans ? np1 : 
00101           resu1*(rout-rp1)/(rout-rin) + resu_ext*(rin-rp1)/(rin-rout)
00102                   +(rp1-rin)*(rp1-rout)*(a*rp1+b) );
00103       }
00104     }
00105     resu.set(lz,k,j,0) = (lz==0 ? nbc : 
00106                   resu(lz-1, k, j, mg.get_nr(lz-1)-1 ) ) ;
00107       }
00108     }
00109   Cmp resu2(mp) ;
00110   resu2 = resu_ext ;
00111   resu2.annule(0,nzet) ;
00112   resu.annule(nzet+1, nz-1) ;
00113   resu += resu2 ;
00114   resu.std_base_scal() ;
00115   return resu ;
00116 }

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