diff_x3dsdx.C

00001 /*
00002  *  Methods for the class Diff_x3dsdx
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_x3dsdx_C[] = "$Header: /cvsroot/Lorene/C++/Source/Diff/diff_x3dsdx.C,v 1.3 2007/12/11 15:28:11 jl_cornou Exp $" ;
00029 
00030 /*
00031  * $Id: diff_x3dsdx.C,v 1.3 2007/12/11 15:28:11 jl_cornou Exp $
00032  * $Log: diff_x3dsdx.C,v $
00033  * Revision 1.3  2007/12/11 15:28:11  jl_cornou
00034  * Jacobi(0,2) polynomials partially implemented
00035  *
00036  * Revision 1.2  2005/01/11 15:52:38  j_novak
00037  * Corrected a mistake...
00038  *
00039  * Revision 1.1  2005/01/11 15:16:10  j_novak
00040  * More Diff operators.
00041  *
00042  * Revision 1.1  2005/01/10 16:34:52  j_novak
00043  * New class for 1D mono-domain differential operators.
00044  *
00045  *
00046  * $Header: /cvsroot/Lorene/C++/Source/Diff/diff_x3dsdx.C,v 1.3 2007/12/11 15:28:11 jl_cornou Exp $
00047  *
00048  */
00049 
00050 // C headers
00051 #include <assert.h>
00052 #include <stdlib.h>
00053 
00054 // Lorene headers
00055 #include "diff.h"
00056 #include "proto.h"
00057 
00058 void xpundsdx_1d(int, double**, int) ;
00059 void mult2_xp1_1d(int, double**, int) ;
00060 
00061 namespace {
00062     int nap = 0 ;
00063     Matrice* tab[MAX_BASE*Diff::max_points] ;
00064     int nr_done[Diff::max_points] ;
00065 }
00066 
00067 Diff_x3dsdx::Diff_x3dsdx(int base_r, int nr) : Diff(base_r, nr) {
00068     initialize() ;
00069 }
00070 
00071 Diff_x3dsdx::Diff_x3dsdx(const Diff_x3dsdx& diff_in) : Diff(diff_in) {
00072     assert (nap != 0) ;
00073 } 
00074 
00075 Diff_x3dsdx::~Diff_x3dsdx() {}
00076 
00077 void Diff_x3dsdx::initialize() {
00078     if (nap == 0) {
00079     for (int i=0; i<max_points; i++) {
00080         nr_done[i] = -1 ;
00081         for (int j=0; j<MAX_BASE; j++) 
00082         tab[j*max_points+i] = 0x0 ;
00083     }
00084     nap = 1 ;
00085     }
00086     return ;
00087 }
00088 
00089 void Diff_x3dsdx::operator=(const Diff_x3dsdx& diff_in) {
00090     assert (nap != 0) ;
00091     Diff::operator=(diff_in) ;
00092 
00093 }
00094 
00095 const Matrice& Diff_x3dsdx::get_matrice() const {
00096     
00097     bool done = false ;
00098     int indice ;
00099     for (indice =0; indice<max_points; indice++) {
00100     if (nr_done[indice] == npoints) {
00101         if (tab[base*max_points + indice] != 0x0) done = true ;
00102         break ;
00103     }
00104     if (nr_done[indice] == -1)
00105         break ;
00106     }
00107     if (!done) { //The computation must be done ...
00108     if (indice == max_points) {
00109         cerr << "Diff_x3dsdx::get_matrice() : no space left!!" << '\n'
00110          << "The value of Diff.max_points must be increased..." << endl ;
00111         abort() ;
00112     }
00113     nr_done[indice] = npoints ;
00114     tab[base*max_points + indice] = new Matrice(npoints, npoints) ;
00115     Matrice& resu = *tab[base*max_points + indice] ;
00116     resu.set_etat_qcq() ;
00117 
00118     double* vect = new double[npoints] ;
00119     double* cres = new double[npoints] ;
00120     for (int i=0; i<npoints; i++) {
00121         for (int j=0; j<npoints; j++)
00122         vect[j] = 0. ;
00123         vect[i] = 1. ;
00124         if (base == R_CHEBU) {
00125         dsdx_1d(npoints, &vect, R_CHEBU) ;
00126         mult_xm1_1d_cheb(npoints, vect, cres) ;
00127         mult2_xm1_1d_cheb(npoints, cres, vect) ;
00128         for (int j=0; j<npoints; j++)
00129             resu.set(j,i) = vect[j] ;
00130         }
00131         else if (base == R_JACO02) {
00132         xpundsdx_1d(npoints, &vect, base << TRA_R) ;
00133         mult2_xp1_1d(npoints, &vect, base << TRA_R) ;
00134         for (int j=0; j<npoints ; j++)
00135             resu.set(j,i) = vect[j] ;
00136         }
00137         else {
00138         xdsdx_1d(npoints, &vect, base << TRA_R) ;
00139         multx2_1d(npoints, &vect, base << TRA_R) ;
00140         for (int j=0; j<npoints; j++)
00141             resu.set(j,i) = vect[j] ;
00142         
00143         }
00144     }
00145     delete [] vect ;
00146     delete [] cres ;
00147     }
00148     
00149     return *tab[base*max_points + indice] ;
00150 }
00151 
00152 ostream& Diff_x3dsdx::operator>>(ostream& ost) const {
00153 
00154     ost << " xi^3 * d / dx " << endl ;
00155     return ost ;
00156 
00157 }

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