sol_elliptic_no_zec.C

00001 /*
00002  *   Copyright (c) 2003 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 version 2
00008  *   as published by the Free Software Foundation.
00009  *
00010  *   LORENE is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with LORENE; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018  *
00019  */
00020 
00021 char sol_elliptic_no_zec_C[] = "$Header: /cvsroot/Lorene/C++/Source/Non_class_members/PDE/sol_elliptic_no_zec.C,v 1.5 2004/08/24 09:14:44 p_grandclement Exp $" ;
00022 
00023 /*
00024  * $Id: sol_elliptic_no_zec.C,v 1.5 2004/08/24 09:14:44 p_grandclement Exp $
00025  * $Log: sol_elliptic_no_zec.C,v $
00026  * Revision 1.5  2004/08/24 09:14:44  p_grandclement
00027  * Addition of some new operators, like Poisson in 2d... It now requieres the
00028  * GSL library to work.
00029  *
00030  * Also, the way a variable change is stored by a Param_elliptic is changed and
00031  * no longer uses Change_var but rather 2 Scalars. The codes using that feature
00032  * will requiere some modification. (It should concern only the ones about monopoles)
00033  *
00034  * Revision 1.4  2004/06/22 08:49:58  p_grandclement
00035  * Addition of everything needed for using the logarithmic mapping
00036  *
00037  * Revision 1.3  2004/03/17 15:58:49  p_grandclement
00038  * Slight modification of sol_elliptic_no_zec
00039  *
00040  * Revision 1.2  2003/12/19 16:21:49  j_novak
00041  * Shadow hunt
00042  *
00043  * Revision 1.1  2003/12/11 14:48:49  p_grandclement
00044  * Addition of ALL (and that is a lot !) the files needed for the general elliptic solver ... UNDER DEVELOPEMENT...
00045  *
00046  * 
00047  * $Header: /cvsroot/Lorene/C++/Source/Non_class_members/PDE/sol_elliptic_no_zec.C,v 1.5 2004/08/24 09:14:44 p_grandclement Exp $
00048  *
00049  */
00050 
00051 // Header C : 
00052 #include <stdlib.h>
00053 #include <math.h>
00054 
00055 // Headers Lorene :
00056 #include "tbl.h"
00057 #include "mtbl_cf.h"
00058 #include "map.h"
00059 #include "param_elliptic.h"
00060           
00061 
00062         //----------------------------------------------
00063        //       Version Mtbl_cf
00064       //----------------------------------------------
00065 
00066 Mtbl_cf elliptic_solver_no_zec  (const Param_elliptic& ope_var, const Mtbl_cf& source, double valeur) {
00067   // Verifications d'usage sur les zones
00068   int nz = source.get_mg()->get_nzone() ;
00069   assert (nz>1) ;
00070   assert (source.get_mg()->get_type_r(0) == RARE) ;
00071   assert (source.get_mg()->get_type_r(nz-1) == UNSURR) ;
00072   for (int l=1 ; l<nz-1 ; l++)
00073     assert(source.get_mg()->get_type_r(l) == FIN) ;
00074    
00075   // donnees sur la zone
00076   int nr, nt, np ;
00077   
00078   //Rangement des valeurs intermediaires 
00079   Tbl *so ;
00080   Tbl *sol_hom ;
00081   Tbl *sol_part ;
00082    
00083   
00084   // Rangement des solutions, avant raccordement
00085   Mtbl_cf solution_part(source.get_mg(), source.base) ;
00086   Mtbl_cf solution_hom_un(source.get_mg(), source.base) ;
00087   Mtbl_cf solution_hom_deux(source.get_mg(), source.base) ;
00088   Mtbl_cf resultat(source.get_mg(), source.base) ;
00089 
00090   solution_part.annule_hard() ;
00091   solution_hom_un.annule_hard() ;
00092   solution_hom_deux.annule_hard() ;
00093   resultat.annule_hard() ;
00094  
00095   // Computation of the SP and SH's in every domain but the ZEC ...
00096   int conte = 0 ;
00097   for (int zone=0 ; zone<nz-1 ; zone++) {
00098     nr = source.get_mg()->get_nr(zone) ;
00099     nt = source.get_mg()->get_nt(zone) ;
00100     np = source.get_mg()->get_np(zone) ;
00101      
00102     for (int k=0 ; k<np+1 ; k++)
00103       for (int j=0 ; j<nt ; j++) {
00104     if (ope_var.operateurs[conte] != 0x0) {
00105       // Calcul de la SH
00106       sol_hom = new Tbl(ope_var.operateurs[conte]->get_solh()) ;
00107 
00108       //Calcul de la SP
00109       so = new Tbl(nr) ;
00110       so->set_etat_qcq() ;
00111       for (int i=0 ; i<nr ; i++)
00112         so->set(i) = source(zone, k, j, i) ;
00113       
00114       sol_part = new Tbl(ope_var.operateurs[conte]->get_solp(*so)) ;
00115 
00116       // Rangement dans les tableaux globaux ;
00117       for (int i=0 ; i<nr ; i++) {
00118         solution_part.set(zone, k, j, i) = (*sol_part)(i) ;
00119         if (sol_hom->get_ndim()==1)
00120           solution_hom_un.set(zone, k, j, i) = (*sol_hom)(i) ;
00121         else
00122           {
00123         solution_hom_un.set(zone, k, j, i) = (*sol_hom)(0,i) ;
00124         solution_hom_deux.set(zone, k, j, i) = (*sol_hom)(1,i) ;
00125           }
00126       }
00127       
00128       delete so ;
00129       delete sol_hom ;
00130       delete sol_part ;
00131       
00132     }
00133     conte ++ ;
00134       }
00135   }
00136   
00137   //-------------------------------------------------
00138   // ON EST PARTI POUR LE RACCORD (Be carefull ....)
00139   //-------------------------------------------------
00140   
00141   // C'est pas simple toute cette sombre affaire...
00142   // POUR LE MOMENT QUE LE CAS l==0 ;
00143   // Que le cas meme nombre de points dans chaque domaines...
00144 
00145   int start = 0 ;
00146   for (int k=0 ; k<1 ; k++)
00147     for (int j=0 ; j<1 ; j++) {
00148       if (ope_var.operateurs[start] != 0x0) {
00149     
00150     int taille = 2*nz - 3 ;
00151     Matrice systeme (taille, taille) ;
00152     systeme.set_etat_qcq() ;
00153     for (int i=0 ; i<taille ; i++)
00154       for (int j2=0 ; j2<taille ; j2++)
00155         systeme.set(i,j2) = 0 ;
00156     Tbl sec_membre (taille) ;
00157     sec_membre.set_etat_qcq() ;
00158     for (int i=0 ; i<taille ; i++)
00159       sec_membre.set(i) = 0 ;
00160     
00161     //---------
00162     //  Noyau :
00163     //---------
00164     conte = start ;
00165        
00166     systeme.set(0,0) = ope_var.G_plus(0) * 
00167       ope_var.operateurs[conte]->val_sh_one_plus() ;
00168     systeme.set(1,0) = 
00169       ope_var.dG_plus(0) * ope_var.operateurs[conte]->val_sh_one_plus() +  
00170       ope_var.G_plus(0) * ope_var.operateurs[conte]->der_sh_one_plus() ;
00171     
00172     sec_membre.set(0) -= ope_var.F_plus(0,k,j) + 
00173       ope_var.G_plus(0) * ope_var.operateurs[conte]->val_sp_plus() ;
00174     sec_membre.set(1) -= ope_var.dF_plus(0,k,j) + 
00175       ope_var.dG_plus(0) * ope_var.operateurs[conte]->val_sp_plus() + 
00176       ope_var.G_plus(0) * ope_var.operateurs[conte]->der_sp_plus() ;
00177 
00178     //----------
00179     // SHELLS :
00180     //----------
00181     
00182     
00183     for (int l=1 ; l<nz-1 ; l++) {
00184     
00185       // On se met au bon endroit :
00186       int np_prec = source.get_mg()->get_np(l-1) ;
00187       int nt_prec = source.get_mg()->get_nt(l-1) ;
00188       conte += (np_prec+1)*nt_prec ;
00189       
00190       systeme.set(2*l-2, 2*l-1) = -ope_var.G_minus(l) * 
00191         ope_var.operateurs[conte]->val_sh_one_minus() ;
00192       systeme.set(2*l-2, 2*l) = - ope_var.G_minus(l) * 
00193         ope_var.operateurs[conte]->val_sh_two_minus() ;
00194       systeme.set(2*l-1, 2*l-1) = 
00195         -ope_var.dG_minus(l)*ope_var.operateurs[conte]->val_sh_one_minus()-  
00196         ope_var.G_minus(l)*ope_var.operateurs[conte]->der_sh_one_minus() ;
00197       systeme.set(2*l-1, 2*l) =
00198         -ope_var.dG_minus(l)*ope_var.operateurs[conte]->val_sh_two_minus()-  
00199         ope_var.G_minus(l)*ope_var.operateurs[conte]->der_sh_two_minus() ;
00200       
00201       sec_membre.set(2*l-2) += ope_var.F_minus(l,k,j) + 
00202         ope_var.G_minus(l) * ope_var.operateurs[conte]->val_sp_minus() ;
00203       sec_membre.set(2*l-1) += ope_var.dF_minus(l,k,j) + 
00204         ope_var.dG_minus(l) * ope_var.operateurs[conte]->val_sp_minus() + 
00205         ope_var.G_minus(l) * ope_var.operateurs[conte]->der_sp_minus() ;
00206       
00207       // Valeurs en +1 :
00208       systeme.set(2*l, 2*l-1) = ope_var.G_plus(l) * 
00209         ope_var.operateurs[conte]->val_sh_one_plus() ;
00210       systeme.set(2*l, 2*l) = ope_var.G_plus(l) * 
00211         ope_var.operateurs[conte]->val_sh_two_plus() ;
00212       if (l!=nz-2) {
00213         systeme.set(2*l+1, 2*l-1) = 
00214         ope_var.dG_plus(l)*ope_var.operateurs[conte]->val_sh_one_plus()+  
00215         ope_var.G_plus(l)*ope_var.operateurs[conte]->der_sh_one_plus() ;
00216         systeme.set(2*l+1, 2*l) =
00217           ope_var.dG_plus(l)*ope_var.operateurs[conte]->val_sh_two_plus()+
00218           ope_var.G_plus(l)*ope_var.operateurs[conte]->der_sh_two_plus() ;
00219       }
00220 
00221       if (l!=nz-2) {
00222         sec_membre.set(2*l) -= ope_var.F_plus(l,k,j) + 
00223           ope_var.G_plus(l) * ope_var.operateurs[conte]->val_sp_plus();
00224 
00225         sec_membre.set(2*l+1) -=  ope_var.dF_plus(l,k,j) + 
00226           ope_var.dG_plus(l) * ope_var.operateurs[conte]->val_sp_plus() + 
00227           ope_var.G_plus(l) * ope_var.operateurs[conte]->der_sp_plus() ;
00228     }
00229       else
00230         sec_membre.set(2*l) -=  -valeur + ope_var.F_plus(l,k,j) + 
00231           ope_var.G_plus(l) * ope_var.operateurs[conte]->val_sp_plus();
00232     }
00233     
00234     // On resout le systeme ...
00235     if (taille > 2)
00236       systeme.set_band(2,2) ;
00237     else
00238       systeme.set_band(1,1) ;
00239     
00240     systeme.set_lu() ;
00241     Tbl facteur (systeme.inverse(sec_membre)) ;
00242     
00243     // On range tout ca :
00244     // Noyau 
00245     nr = source.get_mg()->get_nr(0) ;
00246     for (int i=0 ; i<nr ; i++)
00247       resultat.set(0,k,j,i) = solution_part(0,k,j,i) 
00248         +facteur(0)*solution_hom_un(0,k,j,i) ;
00249   
00250     // Shells
00251     for (int l=1 ; l<nz-1 ; l++) {
00252       nr = source.get_mg()->get_nr(l) ;
00253       for (int i=0 ; i<nr ; i++)
00254         resultat.set(l,k,j,i) = solution_part(l,k,j,i) + 
00255           facteur(2*l-1)*solution_hom_un(l,k,j,i) +
00256           facteur(2*l)*solution_hom_deux(l,k,j,i) ;
00257     }
00258       }
00259     start ++ ;
00260     }
00261 
00262   return resultat;
00263 }
00264 
00265 

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