separation.C

00001 /*
00002  *   Copyright (c) 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 separation_C[] = "$Header: /cvsroot/Lorene/C++/Source/Bhole_binaire/separation.C,v 1.2 2003/10/03 15:58:44 j_novak Exp $" ;
00024 
00025 /*
00026  * $Id: separation.C,v 1.2 2003/10/03 15:58:44 j_novak Exp $
00027  * $Log: separation.C,v $
00028  * Revision 1.2  2003/10/03 15:58:44  j_novak
00029  * Cleaning of some headers
00030  *
00031  * Revision 1.1.1.1  2001/11/20 15:19:28  e_gourgoulhon
00032  * LORENE
00033  *
00034  * Revision 2.6  2001/04/02  12:16:20  phil
00035  * *** empty log message ***
00036  *
00037  * Revision 2.5  2001/03/30  13:48:17  phil
00038  * on appelle raccord externe
00039  *
00040  * Revision 2.4  2001/03/22  10:40:30  phil
00041  * modification prototypage
00042  *
00043  * Revision 2.3  2001/03/02  10:19:05  phil
00044  * modification parametrage pour affichage
00045  *
00046  * Revision 2.2  2001/02/28  13:39:34  phil
00047  * modif cas etat_zero
00048  *
00049  * Revision 2.1  2001/02/28  13:23:00  phil
00050  * modif etat initial
00051  *
00052  * Revision 2.0  2001/02/28  11:24:34  phil
00053  * *** empty log message ***
00054  *
00055  *
00056  * $Header: /cvsroot/Lorene/C++/Source/Bhole_binaire/separation.C,v 1.2 2003/10/03 15:58:44 j_novak Exp $
00057  *
00058  */
00059 
00060 //standard
00061 #include <stdlib.h>
00062 
00063 // Lorene
00064 #include "cmp.h"
00065 #include "proto.h"
00066 
00067 void separation (const Cmp& c1, const Cmp& c2, Cmp& res1, Cmp& res2, int decrois, 
00068     int puiss, int lmax, double precision, const double relax, const int itemax, const int flag) {
00069     
00070     assert (c1.get_etat() != ETATNONDEF) ;
00071     assert (c2.get_etat() != ETATNONDEF) ;
00072     
00073     if ((c1.get_etat() == ETATZERO) && (c2.get_etat() == ETATZERO)) {
00074     res1.set_etat_zero() ;
00075     res2.set_etat_zero() ;
00076     return ;
00077     }
00078     else {
00079     
00080     res1 = c1 ;
00081     if (res1.get_etat() == ETATZERO) {
00082         res1.annule_hard() ;
00083         res1.std_base_scal() ;
00084         }
00085         
00086     res1.raccord_externe (decrois, puiss, lmax) ;
00087     for (int i=0 ; i<decrois ; i++)
00088     res1.dec_dzpuis() ;
00089     
00090     res2 = c2 ;
00091     if (res2.get_etat() == ETATZERO) {
00092         res2.annule_hard() ;
00093         res2.std_base_scal() ;
00094         }
00095     res2.raccord_externe (decrois, puiss, lmax) ;
00096     for (int i=0 ; i<decrois ; i++)
00097     res2.dec_dzpuis() ;
00098     
00099     int indic = 1 ;
00100     int conte = 0 ;
00101     // On commence la boucle pour separer :
00102     while (indic == 1) {
00103     Cmp old_un (res1) ;
00104     Cmp old_deux (res2) ;
00105 
00106     // On fait les modifications :
00107     Mtbl xa_mtbl_un (c1.get_mp()->xa) ;
00108     Mtbl ya_mtbl_un (c1.get_mp()->ya) ;
00109     Mtbl za_mtbl_un (c1.get_mp()->za) ;
00110     
00111     Mtbl xa_mtbl_deux (c2.get_mp()->xa) ;
00112     Mtbl ya_mtbl_deux (c2.get_mp()->ya) ;
00113     Mtbl za_mtbl_deux (c2.get_mp()->za) ;
00114     
00115     double xabs, yabs, zabs, air, theta, phi ;
00116     int np, nt, nr ;
00117     
00118     // On modifie le Cmp 1
00119     int nz_un = c1.get_mp()->get_mg()->get_nzone() ;
00120     for (int l=1 ; l<nz_un-1 ; l++) {
00121         
00122         np = c1.get_mp()->get_mg()->get_np(l) ;
00123         nt = c1.get_mp()->get_mg()->get_nt(l) ;
00124         nr = c1.get_mp()->get_mg()->get_nr(l) ;
00125         
00126         for (int k=0 ; k<np ; k++)
00127         for (int j=0 ; j<nt ; j++)
00128             for (int i=0 ; i<nr ; i++) {
00129             xabs = xa_mtbl_un (l, k, j, i) ;
00130             yabs = ya_mtbl_un (l, k, j, i) ;
00131             zabs = za_mtbl_un (l, k, j, i) ;
00132             
00133             c2.get_mp()->convert_absolute(xabs, yabs, zabs, air, theta, phi) ;
00134             res1.set(l, k, j, i) = 
00135         (1-relax)*res1.set(l, k, j, i) +
00136     relax*(c1(l, k, j, i) - old_deux.val_point(air, theta, phi)) ;  
00137         }
00138     }
00139 
00140     // On modifie le trou 2 
00141     int nz_deux = c2.get_mp()->get_mg()->get_nzone() ;
00142     for (int l=1 ; l<nz_deux-1 ; l++) {
00143         
00144         np = c2.get_mp()->get_mg()->get_np(l) ;
00145         nt = c2.get_mp()->get_mg()->get_nt(l) ;
00146         nr = c2.get_mp()->get_mg()->get_nr(l) ;
00147         
00148         for (int k=0 ; k<np ; k++)
00149         for (int j=0 ; j<nt ; j++)
00150             for (int i=0 ; i<nr ; i++) {
00151             
00152             xabs = xa_mtbl_deux (l, k, j, i) ;
00153             yabs = ya_mtbl_deux (l, k, j, i) ;
00154             zabs = za_mtbl_deux (l, k, j, i) ;
00155             
00156             c1.get_mp()->convert_absolute(xabs, yabs, zabs, air, theta, phi) ;
00157             res2.set(l, k, j, i) = 
00158         (1-relax)*res2.set(l, k, j, i) +
00159     relax*(c2(l, k, j, i) - old_un.val_point(air, theta, phi)) ;    
00160         }
00161     }
00162     
00163     // les coefficients ne sont plus a jour :
00164     res1.va.set_etat_c_qcq() ;
00165     res2.va.set_etat_c_qcq() ;
00166     // On raccord dans la zec :
00167     res1.raccord_externe (decrois, puiss, lmax) ;
00168     for (int i=0 ; i<decrois ; i++)
00169         res1.dec_dzpuis() ;
00170         
00171     res1.va.coef_i() ;
00172     res2.raccord_externe (decrois, puiss, lmax) ;
00173     for (int i=0 ; i<decrois ; i++)
00174         res2.dec_dzpuis() ;
00175     res2.va.coef_i() ;
00176     
00177     // On regarde si on a converge :
00178     
00179     double erreur = 0 ;
00180     
00181     Tbl diff_un (diffrelmax(res1, old_un)) ;
00182     for (int i=1 ; i<nz_un-1 ; i++)
00183         if (diff_un(i)>erreur)
00184         erreur = diff_un(i) ;
00185     
00186     Tbl diff_deux (diffrelmax(res2, old_deux)) ;
00187     for (int i=1 ; i<nz_deux-1 ; i++)
00188         if (diff_deux(i)>erreur)
00189         erreur = diff_deux(i) ;
00190     
00191     if (flag == 1) 
00192         cout << "Pas " << conte << " : erreur = " << erreur << endl ;
00193     if (erreur<=precision)
00194         indic = -1 ;
00195     
00196     conte ++ ;
00197     if (conte > itemax)
00198         indic = -1 ;
00199     }
00200     }
00201 }

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