cmp_test_poisson.C

00001 /*
00002  * Method of class Cmp 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) 2000-2001 Eric Gourgoulhon
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 as published by
00016  *   the Free Software Foundation; either version 2 of the License, or
00017  *   (at your option) any later version.
00018  *
00019  *   LORENE is distributed in the hope that it will be useful,
00020  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022  *   GNU General Public License for more details.
00023  *
00024  *   You should have received a copy of the GNU General Public License
00025  *   along with LORENE; if not, write to the Free Software
00026  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00027  *
00028  */
00029 
00030 
00031 char cmp_test_poisson_C[] = "$Header: /cvsroot/Lorene/C++/Source/Cmp/cmp_test_poisson.C,v 1.2 2002/10/16 14:36:34 j_novak Exp $" ;
00032 
00033 /*
00034  * $Id: cmp_test_poisson.C,v 1.2 2002/10/16 14:36:34 j_novak Exp $
00035  * $Log: cmp_test_poisson.C,v $
00036  * Revision 1.2  2002/10/16 14:36:34  j_novak
00037  * Reorganization of #include instructions of standard C++, in order to
00038  * use experimental version 3 of gcc.
00039  *
00040  * Revision 1.1.1.1  2001/11/20 15:19:27  e_gourgoulhon
00041  * LORENE
00042  *
00043  * Revision 2.0  2000/10/05  14:22:24  eric
00044  * *** empty log message ***
00045  *
00046  *
00047  * $Header: /cvsroot/Lorene/C++/Source/Cmp/cmp_test_poisson.C,v 1.2 2002/10/16 14:36:34 j_novak Exp $
00048  *
00049  */
00050 
00051 // Headers Lorene
00052 #include "cmp.h"
00053 
00054 Tbl Cmp::test_poisson(const Cmp& uu, ostream& ostr, bool detail) const {
00055     
00056     assert( uu.get_mp() == mp ) ; 
00057     
00058     // Computation of the absolute and relative errors
00059     // -----------------------------------------------
00060     
00061     int dzi ;
00062     if ( check_dzpuis(4) ) {
00063     dzi = 4 ; 
00064     }
00065     else{
00066     if ( check_dzpuis(2) ) {
00067         dzi = 2 ; 
00068     }
00069     else{
00070         assert( check_dzpuis(0) ) ; 
00071         dzi = 0 ; 
00072     }
00073     }
00074     
00075     Tbl tdiff = max( abs( uu.laplacien(dzi) - *this ) ) ;
00076 
00077     Tbl tmax = max( abs(*this) ) ; 
00078     
00079     int nz = mp->get_mg()->get_nzone() ; 
00080     int nzm1 = nz - 1 ; 
00081     
00082     Tbl trel(nz) ; 
00083     trel.set_etat_qcq() ; 
00084 
00085     if ( (dzpuis == 0) || (tmax(nzm1) == double(0)) ) {
00086 
00087     double s_max = max( tmax ) ; 
00088 
00089     for (int l=0; l<nz; l++) {
00090         trel.set(l) = tdiff(l) / s_max ;     
00091     }
00092 
00093     }
00094     else{
00095 
00096     double s_max = 0 ; 
00097     for (int l=0; l<nzm1; l++) {
00098         s_max = (tmax(l) > s_max) ? tmax(l) : s_max ;     
00099     }
00100 
00101     for (int l=0; l<nzm1; l++) {
00102         trel.set(l) = tdiff(l) / s_max ;     
00103     }
00104 
00105     trel.set(nzm1) = tdiff(nzm1) / tmax(nzm1) ; 
00106 
00107     }
00108     
00109     // All the errors are set in the same output 2-D Tbl
00110     // -------------------------------------------------
00111 
00112     Tbl err(3, nz) ; 
00113     
00114     err.set_etat_qcq() ; 
00115     
00116     for(int l=0; l<nz; l++) {
00117     err.set(0, l) = trel(l) ; 
00118     err.set(1, l) = tdiff(l) ; 
00119     err.set(2, l) = tmax(l) ; 
00120     }
00121 
00122     // Display
00123     // -------
00124     
00125     if (detail) {
00126     ostr << "Max. source :" ;
00127     for (int l=0; l<nz; l++) {
00128         ostr << "  " << err(2, l) ;
00129     }
00130     
00131     ostr << endl << "Abs. error : " ;
00132     for (int l=0; l<nz; l++) {
00133         ostr << "  " << err(1, l) ;
00134     }
00135     }
00136     
00137     ostr << endl << "Rel. error : " ;
00138     for (int l=0; l<nz; l++) {
00139     ostr << "  " << err(0, l) ;
00140     }
00141     
00142     ostr << endl ; 
00143     
00144     return err ; 
00145 
00146 }
00147 

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