LORENE
diff_dsdx.C
1/*
2 * Methods for the class Diff_dsdx
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_dsdx_C[] = "$Header: /cvsroot/Lorene/C++/Source/Diff/diff_dsdx.C,v 1.4 2014/10/13 08:52:50 j_novak Exp $" ;
29
30/*
31 * $Id: diff_dsdx.C,v 1.4 2014/10/13 08:52:50 j_novak Exp $
32 * $Log: diff_dsdx.C,v $
33 * Revision 1.4 2014/10/13 08:52:50 j_novak
34 * Lorene classes and functions now belong to the namespace Lorene.
35 *
36 * Revision 1.3 2014/10/06 15:13:05 j_novak
37 * Modified #include directives to use c++ syntax.
38 *
39 * Revision 1.2 2006/04/10 15:20:52 j_novak
40 * Operators dsdx and sx can now be used in the nucleus.
41 *
42 * Revision 1.1 2005/01/10 16:34:52 j_novak
43 * New class for 1D mono-domain differential operators.
44 *
45 *
46 * $Header: /cvsroot/Lorene/C++/Source/Diff/diff_dsdx.C,v 1.4 2014/10/13 08:52:50 j_novak Exp $
47 *
48 */
49
50// C headers
51#include <cassert>
52#include <cstdlib>
53
54// Lorene headers
55#include "diff.h"
56#include "proto.h"
57
58namespace Lorene {
59
60namespace {
61 int nap = 0 ;
62 Matrice* tab[MAX_BASE*Diff::max_points] ;
63 int nr_done[Diff::max_points] ;
64}
65
66Diff_dsdx::Diff_dsdx(int base_r, int nr) : Diff(base_r, nr) {
67 initialize() ;
68}
69
70Diff_dsdx::Diff_dsdx(const Diff_dsdx& diff_in) : Diff(diff_in) {
71 assert (nap != 0) ;
72}
73
75
77 if (nap == 0) {
78 for (int i=0; i<max_points; i++) {
79 nr_done[i] = -1 ;
80 for (int j=0; j<MAX_BASE; j++)
81 tab[j*max_points+i] = 0x0 ;
82 }
83 nap = 1 ;
84 }
85 return ;
86}
87
88void Diff_dsdx::operator=(const Diff_dsdx& diff_in) {
89 assert (nap != 0) ;
90 Diff::operator=(diff_in) ;
91
92}
93
95
96 bool done = false ;
97 int indice ;
98 for (indice =0; indice<max_points; indice++) {
99 if (nr_done[indice] == npoints) {
100 if (tab[base*max_points + indice] != 0x0) done = true ;
101 break ;
102 }
103 if (nr_done[indice] == -1)
104 break ;
105 }
106 if (!done) { //The computation must be done ...
107 if (indice == max_points) {
108 cerr << "Diff_dsdx::get_matrice() : no space left!!" << '\n'
109 << "The value of Diff.max_points must be increased..." << endl ;
110 abort() ;
111 }
112 nr_done[indice] = npoints ;
113 tab[base*max_points + indice] = new Matrice(npoints, npoints) ;
114 Matrice& resu = *tab[base*max_points + indice] ;
115 resu.set_etat_qcq() ;
116
117 double* vect = new double[npoints] ;
118 for (int i=0; i<npoints; i++) {
119 for (int j=0; j<npoints; j++)
120 vect[j] = 0. ;
121 vect[i] = 1. ;
122 dsdx_1d(npoints, &vect, base << TRA_R) ;
123 for (int j=0; j<npoints; j++)
124 resu.set(j,i) = vect[j] ;
125 }
126 delete [] vect ;
127 }
128 return *tab[base*max_points + indice] ;
129}
130
131ostream& Diff_dsdx::operator>>(ostream& ost) const {
132
133 ost << " d / dx " << endl ;
134
135 return ost ;
136
137}
138}
Class for the elementary differential operator (see the base class Diff ).
Definition diff.h:129
Diff_dsdx(int base_r, int nr)
Standard constructor, the base is that of the functions the operator is acting on (starting base).
Definition diff_dsdx.C:66
virtual ~Diff_dsdx()
Destructor.
Definition diff_dsdx.C:74
void initialize()
Initializes arrays.
Definition diff_dsdx.C:76
virtual const Matrice & get_matrice() const
Returns the matrix associated with the operator.
Definition diff_dsdx.C:94
void operator=(const Diff_dsdx &)
Assignment to another Diff_dsdx.
Definition diff_dsdx.C:88
virtual ostream & operator>>(ostream &) const
Operator >> (virtual function called by the operator <<).
Definition diff_dsdx.C:131
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