diff_id.C

00001 /*
00002  *  Methods for the class Diff_id
00003  *
00004  *    (see file diff.h for documentation).
00005  *
00006  */
00007 
00008 /*
00009  *   Copyright (c) 2005 Jerome Novak
00010  *
00011  *   This file is part of LORENE.
00012  *
00013  *   LORENE is free software; you can redistribute it and/or modify
00014  *   it under the terms of the GNU General Public License version 2
00015  *   as published by the Free Software Foundation.
00016  *
00017  *   LORENE is distributed in the hope that it will be useful,
00018  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  *   GNU General Public License for more details.
00021  *
00022  *   You should have received a copy of the GNU General Public License
00023  *   along with LORENE; if not, write to the Free Software
00024  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025  *
00026  */
00027 
00028 char diff_id_C[] = "$Header: /cvsroot/Lorene/C++/Source/Diff/diff_id.C,v 1.1 2005/01/10 16:34:52 j_novak Exp $" ;
00029 
00030 /*
00031  * $Id: diff_id.C,v 1.1 2005/01/10 16:34:52 j_novak Exp $
00032  * $Log: diff_id.C,v $
00033  * Revision 1.1  2005/01/10 16:34:52  j_novak
00034  * New class for 1D mono-domain differential operators.
00035  *
00036  *
00037  * $Header: /cvsroot/Lorene/C++/Source/Diff/diff_id.C,v 1.1 2005/01/10 16:34:52 j_novak Exp $
00038  *
00039  */
00040 
00041 // C headers
00042 #include <assert.h>
00043 #include <stdlib.h>
00044 
00045 // Lorene headers
00046 #include "diff.h"
00047 #include "proto.h"
00048 
00049 namespace {
00050     int nap = 0 ;
00051     Matrice* tab[MAX_BASE*Diff::max_points] ;
00052     int nr_done[Diff::max_points] ;
00053 }
00054 
00055 Diff_id::Diff_id(int base_r, int nr) : Diff(base_r, nr) {
00056     initialize() ;
00057 }
00058 
00059 Diff_id::Diff_id(const Diff_id& diff_in) : Diff(diff_in) {
00060     assert (nap != 0) ;
00061 } 
00062 
00063 Diff_id::~Diff_id() {}
00064 
00065 void Diff_id::initialize() {
00066     if (nap == 0) {
00067     for (int i=0; i<max_points; i++) {
00068         nr_done[i] = -1 ;
00069         for (int j=0; j<MAX_BASE; j++) 
00070         tab[j*max_points+i] = 0x0 ;
00071     }
00072     nap = 1 ;
00073     }
00074     return ;
00075 }
00076 
00077 void Diff_id::operator=(const Diff_id& diff_in) {
00078     assert (nap != 0) ;
00079     Diff::operator=(diff_in) ;
00080 
00081 }
00082 
00083 const Matrice& Diff_id::get_matrice() const {
00084     
00085     bool done = false ;
00086     int indice ;
00087     for (indice =0; indice<max_points; indice++) {
00088     if (nr_done[indice] == npoints) {
00089         if (tab[base*max_points + indice] != 0x0) done = true ;
00090         break ;
00091     }
00092     if (nr_done[indice] == -1)
00093         break ;
00094     }
00095     if (!done) { //The computation must be done ...
00096     if (indice == max_points) {
00097         cerr << "Diff_id::get_matrice() : no space left!!" << '\n'
00098          << "The value of Diff.max_points must be increased..." << endl ;
00099         abort() ;
00100     }
00101     nr_done[indice] = npoints ;
00102     tab[base*max_points + indice] = new Matrice(npoints, npoints) ;
00103     Matrice& resu = *tab[base*max_points + indice] ;
00104     resu.set_etat_qcq() ;
00105 
00106     for (int i=0; i<npoints; i++) {
00107         for (int j=0; j<npoints; j++)
00108         resu.set(i,j) = 0. ;
00109         resu.set(i,i) = 1. ;
00110     }
00111     }
00112     return *tab[base*max_points + indice] ;
00113 }
00114 
00115 ostream& Diff_id::operator>>(ostream& ost) const {
00116 
00117     ost << " Identity " << endl ;
00118 
00119     return ost ;
00120 
00121 }

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