LORENE
diff_dsdx2.C
1/*
2 * Methods for the class Diff_dsdx2
3 *
4 * (see file diff.h for documentation).
5 *
6 */
7
8/*
9 * Copyright (c) 2005 Jerome Novak
10 *
11 * This file is part of LORENE.
12 *
13 * LORENE is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2
15 * as published by the Free Software Foundation.
16 *
17 * LORENE is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with LORENE; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 */
27
28char diff_dsdx2_C[] = "$Header: /cvsroot/Lorene/C++/Source/Diff/diff_dsdx2.C,v 1.3 2014/10/13 08:52:50 j_novak Exp $" ;
29
30/*
31 * $Id: diff_dsdx2.C,v 1.3 2014/10/13 08:52:50 j_novak Exp $
32 * $Log: diff_dsdx2.C,v $
33 * Revision 1.3 2014/10/13 08:52:50 j_novak
34 * Lorene classes and functions now belong to the namespace Lorene.
35 *
36 * Revision 1.2 2014/10/06 15:13:04 j_novak
37 * Modified #include directives to use c++ syntax.
38 *
39 * Revision 1.1 2005/01/10 16:34:52 j_novak
40 * New class for 1D mono-domain differential operators.
41 *
42 *
43 * $Header: /cvsroot/Lorene/C++/Source/Diff/diff_dsdx2.C,v 1.3 2014/10/13 08:52:50 j_novak Exp $
44 *
45 */
46
47// C headers
48#include <cassert>
49#include <cstdlib>
50
51// Lorene headers
52#include "diff.h"
53#include "proto.h"
54
55namespace Lorene {
56
57namespace {
58 int nap = 0 ;
59 Matrice* tab[MAX_BASE*Diff::max_points] ;
60 int nr_done[Diff::max_points] ;
61}
62
63Diff_dsdx2::Diff_dsdx2(int base_r, int nr) : Diff(base_r, nr) {
64 initialize() ;
65}
66
67Diff_dsdx2::Diff_dsdx2(const Diff_dsdx2& diff_in) : Diff(diff_in) {
68 assert (nap != 0) ;
69}
70
72
74 if (nap == 0) {
75 for (int i=0; i<max_points; i++) {
76 nr_done[i] = -1 ;
77 for (int j=0; j<MAX_BASE; j++)
78 tab[j*max_points+i] = 0x0 ;
79 }
80 nap = 1 ;
81 }
82 return ;
83}
84
85void Diff_dsdx2::operator=(const Diff_dsdx2& diff_in) {
86 assert (nap != 0) ;
87 Diff::operator=(diff_in) ;
88
89}
90
92
93 bool done = false ;
94 int indice ;
95 for (indice =0; indice<max_points; indice++) {
96 if (nr_done[indice] == npoints) {
97 if (tab[base*max_points + indice] != 0x0) done = true ;
98 break ;
99 }
100 if (nr_done[indice] == -1)
101 break ;
102 }
103 if (!done) { //The computation must be done ...
104 if (indice == max_points) {
105 cerr << "Diff_dsdx2::get_matrice() : no space left!!" << '\n'
106 << "The value of Diff.max_points must be increased..." << endl ;
107 abort() ;
108 }
109 nr_done[indice] = npoints ;
110 tab[base*max_points + indice] = new Matrice(npoints, npoints) ;
111 Matrice& resu = *tab[base*max_points + indice] ;
112 resu.set_etat_qcq() ;
113
114 double* vect = new double[npoints] ;
115 for (int i=0; i<npoints; i++) {
116 for (int j=0; j<npoints; j++)
117 vect[j] = 0. ;
118 vect[i] = 1. ;
119 d2sdx2_1d(npoints, &vect, base << TRA_R) ;
120 for (int j=0; j<npoints; j++)
121 resu.set(j,i) = vect[j] ;
122 }
123 delete [] vect ;
124 }
125
126 return *tab[base*max_points + indice] ;
127}
128
129ostream& Diff_dsdx2::operator>>(ostream& ost) const {
130
131 ost << " d2 / dx2 " << endl ;
132 return ost ;
133
134}
135}
Class for the elementary differential operator (see the base class Diff ).
Definition diff.h:172
void operator=(const Diff_dsdx2 &)
Assignment to another Diff_dsdx2.
Definition diff_dsdx2.C:85
void initialize()
Initializes arrays.
Definition diff_dsdx2.C:73
Diff_dsdx2(int base_r, int nr)
Standard constructor.
Definition diff_dsdx2.C:63
virtual ostream & operator>>(ostream &) const
Operator >> (virtual function called by the operator <<).
Definition diff_dsdx2.C:129
virtual ~Diff_dsdx2()
Destructor.
Definition diff_dsdx2.C:71
virtual const Matrice & get_matrice() const
Returns the matrix associated with the operator.
Definition diff_dsdx2.C:91
Base (abstract) class for 1D spectral differential operators in one domain.
Definition diff.h:65
int npoints
Number of coefficients.
Definition diff.h:75
void operator=(const Diff &)
Assignment to another Diff.
Definition diff.C:75
static const int max_points
Maximal number of matrices stored per base.
Definition diff.h:71
int base
Base in radial direction.
Definition diff.h:74
Matrix handling.
Definition matrice.h:152
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Definition matrice.C:175
double & set(int j, int i)
Read/write of a particuliar element.
Definition matrice.h:277
#define MAX_BASE
Nombre max. de bases differentes.
#define TRA_R
Translation en R, used for a bitwise shift (in hex)
Lorene prototypes.
Definition app_hor.h:64