map_et_poisson_falloff.C

00001 /*
00002  *  Method of the class Map_et for the (iterative) resolution of the scalar
00003  *   Poisson equation with a 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_falloff_C[] = "$Header: /cvsroot/Lorene/C++/Source/Map/map_et_poisson_falloff.C,v 1.1 2004/11/30 20:53:59 k_taniguchi Exp $" ;
00030 
00031 /*
00032  * $Id: map_et_poisson_falloff.C,v 1.1 2004/11/30 20:53:59 k_taniguchi Exp $
00033  * $Log: map_et_poisson_falloff.C,v $
00034  * Revision 1.1  2004/11/30 20:53:59  k_taniguchi
00035  * *** empty log message ***
00036  *
00037  *
00038  * $Header: /cvsroot/Lorene/C++/Source/Map/map_et_poisson_falloff.C,v 1.1 2004/11/30 20:53:59 k_taniguchi Exp $
00039  *
00040  */
00041 
00042 // Header Lorene:
00043 #include "map.h"
00044 #include "cmp.h"
00045 #include "param.h"
00046 
00047 //*****************************************************************************
00048 
00049 void Map_et::poisson_falloff(const Cmp& source, Param& par, Cmp& uu, int k_falloff) const {
00050 
00051     assert(source.get_etat() != ETATNONDEF) ; 
00052     assert(source.get_mp() == this) ;
00053 
00054     assert(uu.get_mp() == this) ; 
00055 
00056     int nz = mg->get_nzone() ; 
00057 
00058     //-------------------------------
00059     // Computation of the prefactor a  ---> Cmp apre
00060     //-------------------------------
00061 
00062     Mtbl unjj = 1 + srdrdt*srdrdt + srstdrdp*srstdrdp ;
00063 
00064     Mtbl apre1(*mg) ; 
00065     apre1.set_etat_qcq() ; 
00066     for (int l=0; l<nz; l++) {
00067     *(apre1.t[l]) = alpha[l]*alpha[l] ; 
00068     }
00069 
00070     apre1 = apre1 * dxdr * dxdr * unjj ;
00071 
00072 
00073     Cmp apre(*this) ; 
00074     apre = apre1 ; 
00075     
00076     Tbl amax0 = max(apre1) ;    // maximum values in each domain
00077 
00078     // The maximum values of a in each domain are put in a Mtbl
00079     Mtbl amax1(*mg) ; 
00080     amax1.set_etat_qcq() ; 
00081     for (int l=0; l<nz; l++) {
00082     *(amax1.t[l]) = amax0(l) ; 
00083     }
00084 
00085     Cmp amax(*this) ; 
00086     amax = amax1 ; 
00087 
00088     //-------------------
00089     //  Initializations 
00090     //-------------------
00091     
00092     int nitermax = par.get_int() ; 
00093     int& niter = par.get_int_mod() ; 
00094     double lambda = par.get_double() ; 
00095     double unmlambda = 1. - lambda ; 
00096     double precis = par.get_double(1) ;     
00097     
00098     Cmp& ssj = par.get_cmp_mod() ; 
00099     
00100     Cmp ssjm1 = ssj ; 
00101     Cmp ssjm2 = ssjm1 ; 
00102 
00103     Valeur& vuu = uu.va ; 
00104 
00105     Valeur vuujm1(*mg) ;
00106     if (uu.get_etat() == ETATZERO) {
00107     vuujm1 = 1 ;    // to take relative differences
00108     vuujm1.set_base( vuu.base ) ; 
00109     }
00110     else{
00111     vuujm1 = vuu ; 
00112     }
00113     
00114     // Affine mapping for the Laplacian-tilde
00115 
00116     Map_af mpaff(*this) ; 
00117     Param par_nul ; 
00118 
00119     cout << "Map_et::poisson : relat. diff. u^J <-> u^{J-1} : " << endl ;
00120     
00121 //==========================================================================
00122 //==========================================================================
00123 //              Start of iteration 
00124 //==========================================================================
00125 //==========================================================================
00126 
00127     Tbl tdiff(nz) ; 
00128     double diff ; 
00129     niter = 0 ; 
00130     
00131     do {
00132 
00133     //====================================================================
00134     //      Computation of R(u)    (the result is put in uu)
00135     //====================================================================
00136 
00137 
00138     //-----------------------
00139     // First operations on uu
00140     //-----------------------
00141     
00142     Valeur duudx = (uu.va).dsdx() ;     // d/dx 
00143 
00144     const Valeur& d2uudtdx = duudx.dsdt() ;     // d^2/dxdtheta
00145 
00146     const Valeur& std2uudpdx = duudx.stdsdp() ;    // 1/sin(theta) d^2/dxdphi   
00147 
00148     //------------------
00149     // Angular Laplacian 
00150     //------------------
00151     
00152     Valeur sxlapang = uu.va ; 
00153 
00154     sxlapang.ylm() ; 
00155     
00156     sxlapang = sxlapang.lapang() ;    
00157     
00158     sxlapang = sxlapang.sx() ;    //  Lap_ang(uu) /x      in the nucleus
00159                   //  Lap_ang(uu)         in the shells
00160                   //  Lap_ang(uu) /(x-1)  in the ZEC
00161     
00162     //---------------------------------------------------------------
00163     //  Computation of 
00164     // [ 2 /(dRdx) ( A - 1 ) duu/dx + 1/R (B - 1) Lap_ang(uu) ] / x
00165     //
00166     // with A = 1/(dRdx) R/(x+beta_l/alpha_l) unjj 
00167     //      B = [1/(dRdx) R/(x+beta_l/alpha_l)]^2 unjj 
00168     // 
00169     //  The result is put in uu (via vuu)
00170     //---------------------------------------------------------------
00171 
00172     Valeur varduudx = duudx ; 
00173 
00174     uu.set_etat_qcq() ; 
00175     
00176     Base_val sauve_base = varduudx.base ; 
00177     
00178     vuu = 2. * dxdr * ( rsxdxdr * unjj - 1.) * varduudx 
00179         + ( rsxdxdr*rsxdxdr * unjj - 1.) * xsr * sxlapang ; 
00180 
00181     vuu.set_base(sauve_base) ; 
00182 
00183     vuu = vuu.sx() ; 
00184 
00185     //---------------------------------------
00186     // Computation of  R(u)  
00187     //
00188     //  The result is put in uu (via vuu)
00189     //---------------------------------------
00190 
00191 
00192     sauve_base = vuu.base ; 
00193 
00194     vuu =  xsr * vuu 
00195         + 2. * dxdr * ( sr2drdt * d2uudtdx 
00196                   + sr2stdrdp * std2uudpdx ) ;
00197 
00198     vuu += dxdr * ( lapr_tp + dxdr * ( 
00199         dxdr* unjj * d2rdx2 
00200         - 2. * ( sr2drdt * d2rdtdx  + sr2stdrdp * sstd2rdpdx ) ) 
00201                  ) * duudx ;            
00202 
00203     vuu.set_base(sauve_base) ; 
00204     
00205     // Since the assignment is performed on vuu (uu.va), the treatment
00206     //  of uu.dzpuis must be performed by hand:
00207     
00208 
00209     //====================================================================
00210     //   Computation of the effective source s^J of the ``affine''
00211     //     Poisson equation 
00212     //====================================================================
00213     
00214     ssj = lambda * ssjm1 + unmlambda * ssjm2 ; 
00215     
00216     ssj = ( source + uu + (amax - apre) * ssj ) / amax ; 
00217 
00218     (ssj.va).set_base((source.va).base) ; 
00219     
00220     //====================================================================
00221     //   Resolution of the ``affine'' Poisson equation 
00222     //====================================================================
00223     
00224     // *****************************************************************
00225 
00226     mpaff.poisson_falloff(ssj, par_nul, uu, k_falloff) ; 
00227 
00228     // *****************************************************************
00229 
00230     tdiff = diffrel(vuu, vuujm1) ; 
00231 
00232     diff = max(tdiff) ;
00233     
00234 
00235         cout << "  iter: " << niter << " :  " ; 
00236     for (int l=0; l<nz; l++) {
00237         cout << tdiff(l) << "  " ;  
00238     }
00239         cout << endl ; 
00240 
00241     //=================================
00242     //  Updates for the next iteration
00243     //=================================
00244     
00245     ssjm2 = ssjm1 ; 
00246     ssjm1 = ssj ; 
00247     vuujm1 = vuu ; 
00248     
00249     niter++ ; 
00250     
00251     }   // End of iteration 
00252     while ( (diff > precis) && (niter < nitermax) ) ;
00253     
00254 //==========================================================================
00255 //==========================================================================
00256 //              End of iteration 
00257 //==========================================================================
00258 //==========================================================================
00259 
00260    
00261 
00262 }

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