lindquist.C

00001 /*
00002  *   Copyright (c) 2000-2001 Philippe Grandclement
00003  *
00004  *   This file is part of LORENE.
00005  *
00006  *   LORENE is free software; you can redistribute it and/or modify
00007  *   it under the terms of the GNU General Public License as published by
00008  *   the Free Software Foundation; either version 2 of the License, or
00009  *   (at your option) any later version.
00010  *
00011  *   LORENE is distributed in the hope that it will be useful,
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *   GNU General Public License for more details.
00015  *
00016  *   You should have received a copy of the GNU General Public License
00017  *   along with LORENE; if not, write to the Free Software
00018  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 
00022 
00023 char lindquist_C[] = "$Header: /cvsroot/Lorene/C++/Source/Bhole_binaire/lindquist.C,v 1.2 2002/10/16 14:36:33 j_novak Exp $" ;
00024 
00025 /*
00026  * $Id: lindquist.C,v 1.2 2002/10/16 14:36:33 j_novak Exp $
00027  * $Log: lindquist.C,v $
00028  * Revision 1.2  2002/10/16 14:36:33  j_novak
00029  * Reorganization of #include instructions of standard C++, in order to
00030  * use experimental version 3 of gcc.
00031  *
00032  * Revision 1.1.1.1  2001/11/20 15:19:28  e_gourgoulhon
00033  * LORENE
00034  *
00035  * Revision 2.0  2000/12/13  15:42:57  phil
00036  * *** empty log message ***
00037  *
00038  *
00039  * $Header: /cvsroot/Lorene/C++/Source/Bhole_binaire/lindquist.C,v 1.2 2002/10/16 14:36:33 j_novak Exp $
00040  *
00041  */
00042 
00043 
00044 //standard
00045 #include <stdlib.h>
00046 #include <math.h>
00047 
00048 // LORENE
00049 #include "type_parite.h"
00050 #include "nbr_spx.h"
00051 #include "proto.h"
00052 #include "coord.h"
00053 #include "tenseur.h"
00054 
00055 double serie_lindquist_plus (double rayon, double distance, double xa, double ya, 
00056     double za, double precision, double itemax) {
00057         
00058         
00059     double result = 0.5 ;
00060     double c_n = rayon ;
00061     double d_n = distance/2. ;
00062     
00063     int indic = 1 ;
00064     int conte=0 ;
00065     while ((indic == 1) && (conte <= itemax)) {
00066     
00067     double norme_plus = sqrt ((xa+d_n)*(xa+d_n)+ya*ya+za*za) ;
00068         
00069     double terme = c_n * 1./norme_plus ;
00070     if (fabs(terme/result) < precision)
00071         indic = -1 ;
00072     
00073         result = result + terme ;
00074     
00075     c_n *= rayon/(distance/2. + d_n) ;
00076     d_n = distance/2. - rayon*rayon/(distance/2.+d_n) ;
00077     conte ++ ;
00078     }
00079 
00080     if (conte > itemax)
00081     result = 1 ;
00082 return result ;
00083 }
00084 
00085 double serie_lindquist_moins (double rayon, double distance, double xa, double ya, 
00086     double za, double precision, double itemax) {
00087         
00088         
00089     double result = 0.5 ;
00090     double c_n = rayon ;
00091     double d_n = distance/2. ;
00092     
00093     int indic = 1 ;
00094     int conte=0 ;
00095     while ((indic == 1) && (conte <= itemax)) {
00096     
00097     double norme_plus = sqrt ((xa-d_n)*(xa-d_n)+ya*ya+za*za) ;
00098         
00099     double terme = c_n * 1./norme_plus ;
00100     if (fabs(terme/result) < precision)
00101         indic = -1 ;
00102     
00103         result = result + terme ;
00104     
00105     c_n *= rayon/(distance/2. + d_n) ;
00106     d_n = distance/2. - rayon*rayon/(distance/2.+d_n) ;
00107     conte ++ ;
00108     }
00109 
00110     if (conte > itemax)
00111     result = 1 ;
00112 return result ;
00113 }
00114 
00115 double adm_serie (double rayon, double distance, double precision) {
00116     
00117     double result = 0 ;
00118     double c_n = rayon ;
00119     double d_n = distance/2. ;
00120     
00121     int indic =1 ;
00122     while (indic == 1) {
00123     
00124     result += 4*c_n ;
00125     if (fabs(c_n/result) < precision)
00126         indic = -1 ;
00127     
00128     c_n *= rayon/(distance/2. + d_n) ;
00129     d_n = distance/2. - rayon*rayon/(distance/2.+d_n) ;
00130     }
00131 return result ;
00132 }
00133 
00134 double bare_serie (double rayon, double distance, double precision) {
00135     
00136     double result = 0 ;
00137     double c_n = rayon ;
00138     double d_n = distance/2. ;
00139     
00140     int indic =1 ;
00141     int n = 1 ;
00142     while (indic == 1) {
00143     
00144     result += 4*c_n*n ;
00145     if (fabs(c_n/result) < precision)
00146         indic = -1 ;
00147     
00148     c_n *= rayon/(distance/2. + d_n) ;
00149     d_n = distance/2. - rayon*rayon/(distance/2.+d_n) ;
00150     n++ ;
00151     }
00152 return result ;
00153 }
00154 
00155 void set_lindquist (Cmp& psi_un, Cmp& psi_deux, double rayon, double precision) {
00156     
00157     // Pour les allocations !
00158     psi_un = 1 ;
00159     psi_deux = 1 ;
00160     
00161     double distance = psi_un.get_mp()->get_ori_x()-psi_deux.get_mp()->get_ori_x() ;
00162     
00163     // On regarde psi 1 :
00164     Mtbl xa_mtbl_un (psi_un.get_mp()->xa) ;
00165     Mtbl ya_mtbl_un (psi_un.get_mp()->ya) ;
00166     Mtbl za_mtbl_un (psi_un.get_mp()->za) ;
00167     
00168     int nz_un = psi_un.get_mp()->get_mg()->get_nzone() ;
00169     for (int l=1 ; l<nz_un ; l++) {
00170     int np = psi_un.get_mp()->get_mg()->get_np (l) ;
00171     int nt = psi_un.get_mp()->get_mg()->get_nt (l) ;
00172     int nr = psi_un.get_mp()->get_mg()->get_nr (l) ;
00173     double xa, ya, za ;
00174     for (int k=0 ; k<np ; k++) 
00175         for (int j=0 ; j<nt ; j++)
00176         for (int i=0 ; i<nr ; i++) {
00177             xa = xa_mtbl_un (l, k, j, i) ;
00178             ya = ya_mtbl_un (l, k, j, i) ;
00179             za = za_mtbl_un (l, k, j, i) ;
00180             
00181             psi_un.set(l, k, j, i) = 
00182 serie_lindquist_moins (rayon, distance, xa, ya, za, precision, 30) ;
00183         }
00184     }
00185     
00186     psi_un.set_val_inf (0.5) ;
00187     psi_un.std_base_scal() ;
00188     
00189       // On regarde psi 2 :
00190     Mtbl xa_mtbl_deux (psi_deux.get_mp()->xa) ;
00191     Mtbl ya_mtbl_deux (psi_deux.get_mp()->ya) ;
00192     Mtbl za_mtbl_deux (psi_deux.get_mp()->za) ;
00193     
00194     int nz_deux = psi_deux.get_mp()->get_mg()->get_nzone() ;
00195     for (int l=1 ; l<nz_deux ; l++) {
00196     int np = psi_deux.get_mp()->get_mg()->get_np (l) ;
00197     int nt = psi_deux.get_mp()->get_mg()->get_nt (l) ;
00198     int nr = psi_deux.get_mp()->get_mg()->get_nr (l) ;
00199     double xa, ya, za ;
00200     for (int k=0 ; k<np ; k++) 
00201         for (int j=0 ; j<nt ; j++)
00202         for (int i=0 ; i<nr ; i++) {
00203             xa = xa_mtbl_deux (l, k, j, i) ;
00204             ya = ya_mtbl_deux (l, k, j, i) ;
00205             za = za_mtbl_deux (l, k, j, i) ;
00206             
00207             psi_deux.set(l, k, j, i) = 
00208 serie_lindquist_plus (rayon, distance, xa, ya, za, precision, 30) ;
00209         }
00210     }
00211     psi_deux.set_val_inf (0.5) ;
00212     psi_deux.std_base_scal() ;
00213 }

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