map_et_poisson_ylm.C

00001 /*
00002  *  Method of the class Map_et for the (iterative) resolution of the scalar
00003  *   Poisson equation with a multipole falloff condition at the outer boundary
00004  *
00005  *    (see file map.h for documentation).
00006  *
00007  */
00008 
00009 /*
00010  *   Copyright (c) 2004 Joshua A. Faber
00011  *
00012  *   This file is part of LORENE.
00013  *
00014  *   LORENE is free software; you can redistribute it and/or modify
00015  *   it under the terms of the GNU General Public License version 2
00016  *   as published by the Free Software Foundation.
00017  *
00018  *   LORENE is distributed in the hope that it will be useful,
00019  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  *   GNU General Public License for more details.
00022  *
00023  *   You should have received a copy of the GNU General Public License
00024  *   along with LORENE; if not, write to the Free Software
00025  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026  *
00027  */
00028 
00029 char map_et_poisson_ylm_C[] = "$Header: /cvsroot/Lorene/C++/Source/Map/map_et_poisson_ylm.C,v 1.1 2004/12/30 15:56:42 k_taniguchi Exp $" ;
00030 
00031 /*
00032  * $Id: map_et_poisson_ylm.C,v 1.1 2004/12/30 15:56:42 k_taniguchi Exp $
00033  * $Log: map_et_poisson_ylm.C,v $
00034  * Revision 1.1  2004/12/30 15:56:42  k_taniguchi
00035  * *** empty log message ***
00036  *
00037  *
00038  * $Header: /cvsroot/Lorene/C++/Source/Map/map_et_poisson_ylm.C,v 1.1 2004/12/30 15:56:42 k_taniguchi Exp $
00039  *
00040  */
00041 
00042 // Lorene headers
00043 #include "map.h"
00044 #include "cmp.h"
00045 #include "param.h"
00046 
00047 //*****************************************************************************
00048 
00049 void Map_et::poisson_ylm(const Cmp& source, Param& par, Cmp& uu, int nylm, double* intvec) const {
00050 
00051   assert(source.get_etat() != ETATNONDEF) ; 
00052     assert(source.get_mp() == this) ;
00053 
00054     assert(uu.get_mp() == this) ; 
00055 
00056 
00057     int nz = mg->get_nzone() ; 
00058 
00059     //-------------------------------
00060     // Computation of the prefactor a  ---> Cmp apre
00061     //-------------------------------
00062 
00063     Mtbl unjj = 1 + srdrdt*srdrdt + srstdrdp*srstdrdp ;
00064 
00065     Mtbl apre1(*mg) ; 
00066     apre1.set_etat_qcq() ; 
00067     for (int l=0; l<nz; l++) {
00068     *(apre1.t[l]) = alpha[l]*alpha[l] ; 
00069     }
00070 
00071     apre1 = apre1 * dxdr * dxdr * unjj ;
00072 
00073 
00074     Cmp apre(*this) ; 
00075     apre = apre1 ; 
00076     
00077     Tbl amax0 = max(apre1) ;    // maximum values in each domain
00078 
00079     // The maximum values of a in each domain are put in a Mtbl
00080     Mtbl amax1(*mg) ; 
00081     amax1.set_etat_qcq() ; 
00082     for (int l=0; l<nz; l++) {
00083     *(amax1.t[l]) = amax0(l) ; 
00084     }
00085 
00086     Cmp amax(*this) ; 
00087     amax = amax1 ; 
00088 
00089     //-------------------
00090     //  Initializations 
00091     //-------------------
00092     
00093     int nitermax = par.get_int() ; 
00094     int& niter = par.get_int_mod() ; 
00095     double lambda = par.get_double() ; 
00096     lambda=1.0;
00097     double unmlambda = 1. - lambda ; 
00098     double precis = par.get_double(1) ;     
00099 
00100     cout <<"relax in map_et:"<<lambda<<" "<<unmlambda<<endl;
00101     
00102     Cmp& ssj = par.get_cmp_mod() ; 
00103     
00104     Cmp ssjm1 = ssj ; 
00105     Cmp ssjm2 = ssjm1 ; 
00106 
00107     Valeur& vuu = uu.va ; 
00108 
00109     Valeur vuujm1(*mg) ;
00110     if (uu.get_etat() == ETATZERO) {
00111     vuujm1 = 1 ;    // to take relative differences
00112     vuujm1.set_base( vuu.base ) ; 
00113     }
00114     else{
00115     vuujm1 = vuu ; 
00116     }
00117     
00118     // Affine mapping for the Laplacian-tilde
00119 
00120     Map_af mpaff(*this) ; 
00121     Param par_nul ; 
00122 
00123     cout << "Map_et::poisson : relat. diff. u^J <-> u^{J-1} : " << endl ;
00124     
00125 //==========================================================================
00126 //==========================================================================
00127 //              Start of iteration 
00128 //==========================================================================
00129 //==========================================================================
00130 
00131     Tbl tdiff(nz) ; 
00132     double diff ; 
00133     niter = 0 ; 
00134     
00135     do {
00136 
00137     //====================================================================
00138     //      Computation of R(u)    (the result is put in uu)
00139     //====================================================================
00140 
00141 
00142     //-----------------------
00143     // First operations on uu
00144     //-----------------------
00145     
00146     Valeur duudx = (uu.va).dsdx() ;     // d/dx 
00147 
00148     const Valeur& d2uudtdx = duudx.dsdt() ;     // d^2/dxdtheta
00149 
00150     const Valeur& std2uudpdx = duudx.stdsdp() ;    // 1/sin(theta) d^2/dxdphi   
00151 
00152     //------------------
00153     // Angular Laplacian 
00154     //------------------
00155     
00156     Valeur sxlapang = uu.va ; 
00157 
00158     sxlapang.ylm() ; 
00159     
00160     sxlapang = sxlapang.lapang() ;    
00161     
00162     sxlapang = sxlapang.sx() ;    //  Lap_ang(uu) /x      in the nucleus
00163                   //  Lap_ang(uu)         in the shells
00164                   //  Lap_ang(uu) /(x-1)  in the ZEC
00165     
00166     //---------------------------------------------------------------
00167     //  Computation of 
00168     // [ 2 /(dRdx) ( A - 1 ) duu/dx + 1/R (B - 1) Lap_ang(uu) ] / x
00169     //
00170     // with A = 1/(dRdx) R/(x+beta_l/alpha_l) unjj 
00171     //      B = [1/(dRdx) R/(x+beta_l/alpha_l)]^2 unjj 
00172     // 
00173     //  The result is put in uu (via vuu)
00174     //---------------------------------------------------------------
00175 
00176     Valeur varduudx = duudx ; 
00177 
00178     uu.set_etat_qcq() ; 
00179     
00180     Base_val sauve_base = varduudx.base ; 
00181     
00182     vuu = 2. * dxdr * ( rsxdxdr * unjj - 1.) * varduudx 
00183         + ( rsxdxdr*rsxdxdr * unjj - 1.) * xsr * sxlapang ; 
00184 
00185     vuu.set_base(sauve_base) ; 
00186 
00187     vuu = vuu.sx() ; 
00188 
00189     //---------------------------------------
00190     // Computation of  R(u)  
00191     //
00192     //  The result is put in uu (via vuu)
00193     //---------------------------------------
00194 
00195 
00196     sauve_base = vuu.base ; 
00197 
00198     vuu =  xsr * vuu 
00199         + 2. * dxdr * ( sr2drdt * d2uudtdx 
00200                   + sr2stdrdp * std2uudpdx ) ;
00201 
00202     vuu += dxdr * ( lapr_tp + dxdr * ( 
00203         dxdr* unjj * d2rdx2 
00204         - 2. * ( sr2drdt * d2rdtdx  + sr2stdrdp * sstd2rdpdx ) ) 
00205                  ) * duudx ;            
00206 
00207     vuu.set_base(sauve_base) ; 
00208     
00209     // Since the assignment is performed on vuu (uu.va), the treatment
00210     //  of uu.dzpuis must be performed by hand:
00211     
00212 
00213     //====================================================================
00214     //   Computation of the effective source s^J of the ``affine''
00215     //     Poisson equation 
00216     //====================================================================
00217     
00218     ssj = lambda * ssjm1 + unmlambda * ssjm2 ; 
00219     
00220     ssj = ( source + uu + (amax - apre) * ssj ) / amax ; 
00221 
00222     (ssj.va).set_base((source.va).base) ; 
00223     
00224     //====================================================================
00225     //   Resolution of the ``affine'' Poisson equation 
00226     //====================================================================
00227     
00228     // *****************************************************************
00229 
00230     mpaff.poisson_ylm(ssj, par_nul, uu, nylm, intvec) ; 
00231 
00232     // *****************************************************************
00233 
00234     tdiff = diffrel(vuu, vuujm1) ; 
00235 
00236     diff = max(tdiff) ;
00237     
00238 
00239         cout << "  iter: " << niter << " :  " ; 
00240     for (int l=0; l<nz; l++) {
00241         cout << tdiff(l) << "  " ;  
00242     }
00243         cout << endl ; 
00244 
00245     //=================================
00246     //  Updates for the next iteration
00247     //=================================
00248     
00249     ssjm2 = ssjm1 ; 
00250     ssjm1 = ssj ; 
00251     vuujm1 = vuu ; 
00252     
00253     niter++ ; 
00254     
00255     }   // End of iteration 
00256     while ( (diff > precis) && (niter < nitermax) ) ;
00257     
00258 //==========================================================================
00259 //==========================================================================
00260 //              End of iteration 
00261 //==========================================================================
00262 //==========================================================================
00263 
00264    
00265 
00266 }
00267 
00268 

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