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

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