map_radial_reevaluate.C

00001 /*
00002  *   Copyright (c) 2000-2001 Eric Gourgoulhon
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 map_radial_reevaluate_C[] = "$Header: /cvsroot/Lorene/C++/Source/Map/map_radial_reevaluate.C,v 1.2 2007/05/15 12:43:57 p_grandclement Exp $" ;
00024 
00025 /*
00026  * $Id: map_radial_reevaluate.C,v 1.2 2007/05/15 12:43:57 p_grandclement Exp $
00027  * $Log: map_radial_reevaluate.C,v $
00028  * Revision 1.2  2007/05/15 12:43:57  p_grandclement
00029  * Scalar version of reevaluate
00030  *
00031  * Revision 1.1.1.1  2001/11/20 15:19:27  e_gourgoulhon
00032  * LORENE
00033  *
00034  * Revision 2.0  2000/01/04  15:24:00  eric
00035  * *** empty log message ***
00036  *
00037  *
00038  * $Header: /cvsroot/Lorene/C++/Source/Map/map_radial_reevaluate.C,v 1.2 2007/05/15 12:43:57 p_grandclement Exp $
00039  *
00040  */
00041 
00042 // Headers C
00043 #include <stdlib.h>
00044 
00045 // Headers Lorene
00046 #include "map.h"
00047 #include "cmp.h"
00048 #include "param.h"
00049 #include "scalar.h"
00050 
00051 void Map_radial::reevaluate(const Map* mp_prev0, int nzet, Cmp& uu) const { 
00052     
00053     const Map_radial* mp_prev = dynamic_cast<const Map_radial*>(mp_prev0) ; 
00054 
00055     if (mp_prev == 0x0) {
00056     cout << 
00057         "Map_radial::reevaluate : the mapping mp_prev does not belong"
00058         << endl ; 
00059     cout << " to the class Map_radial !" << endl ; 
00060     abort() ;  
00061     }
00062 
00063     int nz = mg->get_nzone() ; 
00064 
00065     // Protections
00066     // -----------
00067     assert(uu.get_mp() == this) ; 
00068     assert(uu.get_dzpuis() == 0) ; 
00069     assert(uu.get_etat() != ETATNONDEF) ; 
00070     assert(mp_prev->mg == mg) ; 
00071     assert(nzet <= nz) ; 
00072     
00073     
00074     // Maybe nothing to do ?
00075     if ( uu.get_etat() == ETATZERO ) {
00076     return ; 
00077     }
00078     
00079     assert(uu.get_etat() == ETATQCQ) ; 
00080     (uu.va).coef() ;    // the coefficients of uu are required 
00081 
00082     // Copy of the coefficients
00083     Mtbl_cf va_cf = *((uu.va).c_cf) ;
00084     
00085     // Preparation of uu.va for the storage of the new values.
00086     // ------------------------------------------------------
00087     
00088     (uu.va).set_etat_c_qcq() ;  // Allocates the memory for the Mtbl uu.va.c
00089                 //  if it does not exist already
00090                 // Destroys the coefficients
00091 
00092     Mtbl& va_c = *((uu.va).c) ; // Reference to the Mtbl uu.va.c
00093                 
00094     va_c.set_etat_qcq() ;   // Allocates the memory for the Tbl's in each
00095                 //  domain if they do not exist already
00096 
00097 
00098     // Values of the Coord r
00099     // ---------------------
00100 
00101     if ( r.c == 0x0 ) r.fait() ; 
00102     const Mtbl& rc = *(r.c) ; 
00103     
00104     // Precision for val_lx_jk :
00105     // ------------------------
00106     int nitermax = 100 ; // Maximum number of iterations in the secant method
00107     int niter ;      // Number of iterations effectively used 
00108     double precis = 1.e-15 ; // Absolute precision in the secant method
00109     Param par ; 
00110     par.add_int(nitermax) ; 
00111     par.add_int_mod(niter) ; 
00112     par.add_double(precis) ; 
00113     
00114     // Loop on the domains where the evaluation is to be performed
00115     // -----------------------------------------------------------
00116     
00117     for (int l=0; l<nzet; l++) {
00118     int nr = mg->get_nr(l) ; 
00119     int nt = mg->get_nt(l) ; 
00120     int np = mg->get_np(l) ; 
00121 
00122     va_c.t[l]->set_etat_qcq() ; // Allocates the array of double to 
00123                     //  store the result 
00124 
00125     double* ptx = (va_c.t[l])->t ;  // Pointer on the allocated array
00126     
00127     double* pr = (rc.t[l])->t ; // Pointer on the values of r
00128 
00129     // Loop on all the grid points in the considered domain
00130 
00131     for (int k=0; k<np; k++) {
00132         for (int j=0; j<nt; j++) {
00133         for (int i=0; i<nr; i++) {
00134 
00135             // domain l0 and value of the coordinate xi0 of the 
00136             //  considered point in the previous mapping
00137         
00138             int l0 ; 
00139             double xi0 ; 
00140             mp_prev->val_lx_jk(*pr, j, k, par, l0, xi0) ;
00141         
00142             // Value of uu at this point
00143         
00144             *ptx = va_cf.val_point_jk(l0, xi0, j, k) ; 
00145             
00146             // next point
00147             pr++ ; 
00148             ptx++ ; 
00149         }
00150         }
00151     }
00152 
00153     
00154     }  // End of the loop on the domains where the evaluation had to be performed
00155 
00156     // In the remaining domains, uu is set to zero:
00157     // -------------------------------------------
00158     
00159     uu.annule(nzet, nz - 1) ; 
00160     
00161     
00162     
00163     
00164 }
00165 
00166 void Map_radial::reevaluate(const Map* mp_prev0, int nzet, Scalar& uu) const { 
00167     
00168     const Map_radial* mp_prev = dynamic_cast<const Map_radial*>(mp_prev0) ; 
00169 
00170     if (mp_prev == 0x0) {
00171     cout << 
00172         "Map_radial::reevaluate : the mapping mp_prev does not belong"
00173         << endl ; 
00174     cout << " to the class Map_radial !" << endl ; 
00175     abort() ;  
00176     }
00177 
00178     int nz = mg->get_nzone() ; 
00179 
00180     // Protections
00181     // -----------
00182     assert(uu.get_mp() == *this) ; 
00183     assert(uu.get_dzpuis() == 0) ; 
00184     assert(uu.get_etat() != ETATNONDEF) ; 
00185     assert(mp_prev->mg == mg) ; 
00186     assert(nzet <= nz) ; 
00187     
00188     
00189     // Maybe nothing to do ?
00190     if ( uu.get_etat() == ETATZERO ) {
00191     return ; 
00192     }
00193     
00194     assert(uu.get_etat() == ETATQCQ) ; 
00195     uu.set_spectral_va().coef() ;   // the coefficients of uu are required 
00196 
00197     // Copy of the coefficients
00198     Mtbl_cf va_cf = *(uu.set_spectral_va().c_cf) ;
00199     
00200     // Preparation of uu.va for the storage of the new values.
00201     // ------------------------------------------------------
00202     
00203     uu.set_spectral_va().set_etat_c_qcq() ; // Allocates the memory for the Mtbl uu.va.c
00204                 //  if it does not exist already
00205                 // Destroys the coefficients
00206 
00207     Mtbl& va_c = *(uu.set_spectral_va().c) ; // Reference to the Mtbl uu.va.c
00208                 
00209     va_c.set_etat_qcq() ;   // Allocates the memory for the Tbl's in each
00210                 //  domain if they do not exist already
00211 
00212 
00213     // Values of the Coord r
00214     // ---------------------
00215 
00216     if ( r.c == 0x0 ) r.fait() ; 
00217     const Mtbl& rc = *(r.c) ; 
00218     
00219     // Precision for val_lx_jk :
00220     // ------------------------
00221     int nitermax = 100 ; // Maximum number of iterations in the secant method
00222     int niter ;      // Number of iterations effectively used 
00223     double precis = 1.e-15 ; // Absolute precision in the secant method
00224     Param par ; 
00225     par.add_int(nitermax) ; 
00226     par.add_int_mod(niter) ; 
00227     par.add_double(precis) ; 
00228     
00229     // Loop on the domains where the evaluation is to be performed
00230     // -----------------------------------------------------------
00231     
00232     for (int l=0; l<nzet; l++) {
00233     int nr = mg->get_nr(l) ; 
00234     int nt = mg->get_nt(l) ; 
00235     int np = mg->get_np(l) ; 
00236 
00237     va_c.t[l]->set_etat_qcq() ; // Allocates the array of double to 
00238                     //  store the result 
00239 
00240     double* ptx = (va_c.t[l])->t ;  // Pointer on the allocated array
00241     
00242     double* pr = (rc.t[l])->t ; // Pointer on the values of r
00243 
00244     // Loop on all the grid points in the considered domain
00245 
00246     for (int k=0; k<np; k++) {
00247         for (int j=0; j<nt; j++) {
00248         for (int i=0; i<nr; i++) {
00249 
00250             // domain l0 and value of the coordinate xi0 of the 
00251             //  considered point in the previous mapping
00252         
00253             int l0 ; 
00254             double xi0 ; 
00255             mp_prev->val_lx_jk(*pr, j, k, par, l0, xi0) ;
00256         
00257             // Value of uu at this point
00258         
00259             *ptx = va_cf.val_point_jk(l0, xi0, j, k) ; 
00260             
00261             // next point
00262             pr++ ; 
00263             ptx++ ; 
00264         }
00265         }
00266     }
00267 
00268     
00269     }  // End of the loop on the domains where the evaluation had to be performed
00270 
00271     // In the remaining domains, uu is set to zero:
00272     // -------------------------------------------
00273     
00274     uu.annule(nzet, nz - 1) ; 
00275     
00276     
00277     
00278     
00279 }

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