LORENE
diff_x3dsdx.C
1/*
2 * Methods for the class Diff_x3dsdx
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
28
29
30/*
31 * $Id: diff_x3dsdx.C,v 1.6 2016/12/05 16:17:50 j_novak Exp $
32 * $Log: diff_x3dsdx.C,v $
33 * Revision 1.6 2016/12/05 16:17:50 j_novak
34 * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
35 *
36 * Revision 1.5 2014/10/13 08:52:51 j_novak
37 * Lorene classes and functions now belong to the namespace Lorene.
38 *
39 * Revision 1.4 2014/10/06 15:13:05 j_novak
40 * Modified #include directives to use c++ syntax.
41 *
42 * Revision 1.3 2007/12/11 15:28:11 jl_cornou
43 * Jacobi(0,2) polynomials partially implemented
44 *
45 * Revision 1.2 2005/01/11 15:52:38 j_novak
46 * Corrected a mistake...
47 *
48 * Revision 1.1 2005/01/11 15:16:10 j_novak
49 * More Diff operators.
50 *
51 * Revision 1.1 2005/01/10 16:34:52 j_novak
52 * New class for 1D mono-domain differential operators.
53 *
54 *
55 * $Header: /cvsroot/Lorene/C++/Source/Diff/diff_x3dsdx.C,v 1.6 2016/12/05 16:17:50 j_novak Exp $
56 *
57 */
58
59// C headers
60#include <cassert>
61#include <cstdlib>
62
63// Lorene headers
64#include "diff.h"
65#include "proto.h"
66
67namespace Lorene {
68void xpundsdx_1d(int, double**, int) ;
69void mult2_xp1_1d(int, double**, int) ;
70
71namespace {
72 int nap = 0 ;
74 int nr_done[Diff::max_points] ;
75}
76
77Diff_x3dsdx::Diff_x3dsdx(int base_r, int nr) : Diff(base_r, nr) {
78 initialize() ;
79}
80
81Diff_x3dsdx::Diff_x3dsdx(const Diff_x3dsdx& diff_in) : Diff(diff_in) {
82 assert (nap != 0) ;
83}
84
86
88 if (nap == 0) {
89 for (int i=0; i<max_points; i++) {
90 nr_done[i] = -1 ;
91 for (int j=0; j<MAX_BASE; j++)
92 tab[j*max_points+i] = 0x0 ;
93 }
94 nap = 1 ;
95 }
96 return ;
97}
98
99void Diff_x3dsdx::operator=(const Diff_x3dsdx& diff_in) {
100 assert (nap != 0) ;
101 Diff::operator=(diff_in) ;
102
103}
104
106
107 bool done = false ;
108 int indice ;
109 for (indice =0; indice<max_points; indice++) {
110 if (nr_done[indice] == npoints) {
111 if (tab[base*max_points + indice] != 0x0) done = true ;
112 break ;
113 }
114 if (nr_done[indice] == -1)
115 break ;
116 }
117 if (!done) { //The computation must be done ...
118 if (indice == max_points) {
119 cerr << "Diff_x3dsdx::get_matrice() : no space left!!" << '\n'
120 << "The value of Diff.max_points must be increased..." << endl ;
121 abort() ;
122 }
123 nr_done[indice] = npoints ;
124 tab[base*max_points + indice] = new Matrice(npoints, npoints) ;
125 Matrice& resu = *tab[base*max_points + indice] ;
126 resu.set_etat_qcq() ;
127
128 double* vect = new double[npoints] ;
129 double* cres = new double[npoints] ;
130 for (int i=0; i<npoints; i++) {
131 for (int j=0; j<npoints; j++)
132 vect[j] = 0. ;
133 vect[i] = 1. ;
134 if (base == R_CHEBU) {
135 dsdx_1d(npoints, &vect, R_CHEBU) ;
136 mult_xm1_1d_cheb(npoints, vect, cres) ;
137 mult2_xm1_1d_cheb(npoints, cres, vect) ;
138 for (int j=0; j<npoints; j++)
139 resu.set(j,i) = vect[j] ;
140 }
141 else if (base == R_JACO02) {
142 xpundsdx_1d(npoints, &vect, base << TRA_R) ;
143 mult2_xp1_1d(npoints, &vect, base << TRA_R) ;
144 for (int j=0; j<npoints ; j++)
145 resu.set(j,i) = vect[j] ;
146 }
147 else {
148 xdsdx_1d(npoints, &vect, base << TRA_R) ;
149 multx2_1d(npoints, &vect, base << TRA_R) ;
150 for (int j=0; j<npoints; j++)
151 resu.set(j,i) = vect[j] ;
152
153 }
154 }
155 delete [] vect ;
156 delete [] cres ;
157 }
158
159 return *tab[base*max_points + indice] ;
160}
161
162ostream& Diff_x3dsdx::operator>>(ostream& ost) const {
163
164 ost << " xi^3 * d / dx " << endl ;
165 return ost ;
166
167}
168}
void initialize()
Initializes arrays.
Definition diff_x3dsdx.C:87
virtual ostream & operator>>(ostream &) const
Operator >> (virtual function called by the operator <<).
Diff_x3dsdx(int base_r, int nr)
Standard constructor.
Definition diff_x3dsdx.C:77
virtual const Matrice & get_matrice() const
Returns the matrix associated with the operator.
void operator=(const Diff_x3dsdx &)
Assignment to another Diff_x3dsdx.
Definition diff_x3dsdx.C:99
virtual ~Diff_x3dsdx()
Destructor.
Definition diff_x3dsdx.C:85
int npoints
Number of coefficients.
Definition diff.h:75
void operator=(const Diff &)
Assignment to another Diff.
Definition diff.C:78
Diff(int base_r, int nr)
Standard constructor.
Definition diff.C:64
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:178
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 R_CHEBU
base de Chebychev ordinaire (fin), dev. en 1/r
#define R_JACO02
base de Jacobi(0,2) ordinaire (finjac)
#define TRA_R
Translation en R, used for a bitwise shift (in hex).
Lorene prototypes.
Definition app_hor.h:67