scalar_test_poisson.C

00001 /*
00002  * Method of class Scalar to check if a Poisson equation has been correctly
00003  * solved.
00004  *
00005  * (see file cmp.h for documentation)
00006  *
00007  */
00008 
00009 /*
00010  *   Copyright (c) 2003 Eric Gourgoulhon & Jerome Novak
00011  *
00012  *   Copyright (c) 2000-2001 Eric Gourgoulhon (for a preceding Cmp version)
00013  *
00014  *   This file is part of LORENE.
00015  *
00016  *   LORENE is free software; you can redistribute it and/or modify
00017  *   it under the terms of the GNU General Public License as published by
00018  *   the Free Software Foundation; either version 2 of the License, or
00019  *   (at your option) any later version.
00020  *
00021  *   LORENE is distributed in the hope that it will be useful,
00022  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024  *   GNU General Public License for more details.
00025  *
00026  *   You should have received a copy of the GNU General Public License
00027  *   along with LORENE; if not, write to the Free Software
00028  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00029  *
00030  */
00031 
00032 
00033 char scalar_test_poisson_C[] = "$Header: /cvsroot/Lorene/C++/Source/Tensor/Scalar/scalar_test_poisson.C,v 1.3 2003/10/29 13:14:29 e_gourgoulhon Exp $" ;
00034 
00035 /*
00036  * $Id: scalar_test_poisson.C,v 1.3 2003/10/29 13:14:29 e_gourgoulhon Exp $
00037  * $Log: scalar_test_poisson.C,v $
00038  * Revision 1.3  2003/10/29 13:14:29  e_gourgoulhon
00039  * Change of method name: laplacien --> laplacian.
00040  *
00041  * Revision 1.2  2003/10/01 13:04:44  e_gourgoulhon
00042  * The method Tensor::get_mp() returns now a reference (and not
00043  * a pointer) onto a mapping.
00044  *
00045  * Revision 1.1  2003/09/25 09:13:11  e_gourgoulhon
00046  * First version.
00047  *
00048  *
00049  * $Header: /cvsroot/Lorene/C++/Source/Tensor/Scalar/scalar_test_poisson.C,v 1.3 2003/10/29 13:14:29 e_gourgoulhon Exp $
00050  *
00051  */
00052 
00053 // Headers Lorene
00054 #include "tensor.h"
00055 
00056 Tbl Scalar::test_poisson(const Scalar& uu, ostream& ostr, bool detail) const {
00057     
00058     assert( &(uu.get_mp()) == mp ) ; 
00059     
00060     // Computation of the absolute and relative errors
00061     // -----------------------------------------------
00062     
00063     int dzi ;
00064     if ( check_dzpuis(4) ) {
00065     dzi = 4 ; 
00066     }
00067     else{
00068     if ( check_dzpuis(2) ) {
00069         dzi = 2 ; 
00070     }
00071     else{
00072         assert( check_dzpuis(0) ) ; 
00073         dzi = 0 ; 
00074     }
00075     }
00076     
00077     Tbl tdiff = max( abs( uu.laplacian(dzi) - *this ) ) ;
00078 
00079     Tbl tmax = max( abs(*this) ) ; 
00080     
00081     int nz = mp->get_mg()->get_nzone() ; 
00082     int nzm1 = nz - 1 ; 
00083     
00084     Tbl trel(nz) ; 
00085     trel.set_etat_qcq() ; 
00086 
00087     if ( (dzpuis == 0) || (tmax(nzm1) == double(0)) ) {
00088 
00089     double s_max = max( tmax ) ; 
00090 
00091     for (int l=0; l<nz; l++) {
00092         trel.set(l) = tdiff(l) / s_max ;     
00093     }
00094 
00095     }
00096     else{
00097 
00098     double s_max = 0 ; 
00099     for (int l=0; l<nzm1; l++) {
00100         s_max = (tmax(l) > s_max) ? tmax(l) : s_max ;     
00101     }
00102 
00103     for (int l=0; l<nzm1; l++) {
00104         trel.set(l) = tdiff(l) / s_max ;     
00105     }
00106 
00107     trel.set(nzm1) = tdiff(nzm1) / tmax(nzm1) ; 
00108 
00109     }
00110     
00111     // All the errors are set in the same output 2-D Tbl
00112     // -------------------------------------------------
00113 
00114     Tbl err(3, nz) ; 
00115     
00116     err.set_etat_qcq() ; 
00117     
00118     for(int l=0; l<nz; l++) {
00119     err.set(0, l) = trel(l) ; 
00120     err.set(1, l) = tdiff(l) ; 
00121     err.set(2, l) = tmax(l) ; 
00122     }
00123 
00124     // Display
00125     // -------
00126     
00127     if (detail) {
00128     ostr << "Max. source :" ;
00129     for (int l=0; l<nz; l++) {
00130         ostr << "  " << err(2, l) ;
00131     }
00132     
00133     ostr << endl << "Abs. error : " ;
00134     for (int l=0; l<nz; l++) {
00135         ostr << "  " << err(1, l) ;
00136     }
00137     }
00138     
00139     ostr << endl << "Rel. error : " ;
00140     for (int l=0; l<nz; l++) {
00141     ostr << "  " << err(0, l) ;
00142     }
00143     
00144     ostr << endl ; 
00145     
00146     return err ; 
00147 
00148 }
00149 

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