LORENE
diff_id.C
1/*
2 * Methods for the class Diff_id
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_id_C[] = "$Header: /cvsroot/Lorene/C++/Source/Diff/diff_id.C,v 1.3 2014/10/13 08:52:50 j_novak Exp $" ;
29
30/*
31 * $Id: diff_id.C,v 1.3 2014/10/13 08:52:50 j_novak Exp $
32 * $Log: diff_id.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:05 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_id.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_id::Diff_id(int base_r, int nr) : Diff(base_r, nr) {
64 initialize() ;
65}
66
67Diff_id::Diff_id(const Diff_id& 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_id::operator=(const Diff_id& 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_id::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 for (int i=0; i<npoints; i++) {
115 for (int j=0; j<npoints; j++)
116 resu.set(i,j) = 0. ;
117 resu.set(i,i) = 1. ;
118 }
119 }
120 return *tab[base*max_points + indice] ;
121}
122
123ostream& Diff_id::operator>>(ostream& ost) const {
124
125 ost << " Identity " << endl ;
126
127 return ost ;
128
129}
130}
Class for the elementary differential operator Identity (see the base class Diff ).
Definition diff.h:210
virtual const Matrice & get_matrice() const
Returns the matrix associated with the operator.
Definition diff_id.C:91
virtual ~Diff_id()
Destructor.
Definition diff_id.C:71
void initialize()
Initializes arrays.
Definition diff_id.C:73
virtual ostream & operator>>(ostream &) const
Operator >> (virtual function called by the operator <<).
Definition diff_id.C:123
Diff_id(int base_r, int nr)
Standard constructor.
Definition diff_id.C:63
void operator=(const Diff_id &)
Assignment to another Diff_id.
Definition diff_id.C:85
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.
Lorene prototypes.
Definition app_hor.h:64