LORENE
ope_helmholtz_minus_2d_cl.C
1 /*
2  * Copyright (c) 2004 Philippe Grandclement
3  *
4  * This file is part of LORENE.
5  *
6  * LORENE is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2
8  * as published by the Free Software Foundation.
9  *
10  * LORENE is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with LORENE; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  */
20 
21 
22 
23 /*
24  * $Id: ope_helmholtz_minus_2d_cl.C,v 1.4 2016/12/05 16:18:11 j_novak Exp $
25  * $Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_helmholtz_minus_2d/ope_helmholtz_minus_2d_cl.C,v 1.4 2016/12/05 16:18:11 j_novak Exp $
26  *
27  */
28 #include <cmath>
29 #include <cstdlib>
30 
31 #include "proto.h"
32 #include "ope_elementary.h"
33 
34 // Version Matrice --> Matrice
35 namespace Lorene {
36 Matrice _cl_helmholtz_minus_2d_pas_prevu (const Matrice & source, int) {
37  cout << "Combinaison lineaire pas prevu..." << endl ;
38  abort() ;
39  exit(-1) ;
40  return source;
41 }
42 
43 
44  //-------------------
45  //-- R_CHEB ------
46  //-------------------
47 
48 Matrice _cl_helmholtz_minus_2d_r_cheb (const Matrice &source, int) {
49  int n = source.get_dim(0) ;
50  assert (n == source.get_dim(1)) ;
51  Matrice barre(source) ;
52  int dirac = 1 ;
53  for (int i=0 ; i<n-2 ; i++) {
54  for (int j=0 ; j<n ; j++)
55  barre.set(i, j) = ((1+dirac)*source(i, j)-source(i+2, j))
56  /(i+1) ;
57  if (i==0) dirac = 0 ;
58  }
59 
60  Matrice res(barre) ;
61  for (int i=0 ; i<n-4 ; i++)
62  for (int j=0 ; j<n ; j++)
63  res.set(i, j) = barre(i, j)-barre(i+2, j) ;
64 
65  return res ;
66 }
67 
68  //-------------------
69  //-- R_CHEBU -----
70  //-------------------
71 
72 Matrice _cl_helmholtz_minus_2d_r_chebu_deux (const Matrice&) ;
73 
74 
75 Matrice _cl_helmholtz_minus_2d_r_chebu (const Matrice &source, int puis) {
76  int n = source.get_dim(0) ;
77  assert (n == source.get_dim(1)) ;
78 
79  Matrice res(n, n) ;
80  res.set_etat_qcq() ;
81 
82  switch (puis) {
83  case 2 :
84  res = _cl_helmholtz_minus_2d_r_chebu_deux(source) ;
85  break ;
86  default :
87  abort() ;
88  exit(-1) ;
89  }
90 
91  return res ;
92 }
93 
94 
95 //Cas dzpuis == 2
96 Matrice _cl_helmholtz_minus_2d_r_chebu_deux (const Matrice &source) {
97 
98  int n = source.get_dim(0) ;
99  assert (n == source.get_dim(1)) ;
100 
101  Matrice barre(source) ;
102  int dirac = 1 ;
103  for (int i=0 ; i<n-2 ; i++) {
104  for (int j=0 ; j<n ; j++)
105  barre.set(i, j) = ((1+dirac)*source(i, j)-source(i+2, j)) ;
106  if (i==0) dirac = 0 ;
107  }
108 
109  Matrice tilde(barre) ;
110  for (int i=0 ; i<n-4 ; i++)
111  for (int j=0 ; j<n ; j++)
112  tilde.set(i, j) = (barre(i, j)-barre(i+2, j)) ;
113 
114  Matrice bis(tilde) ;
115  for (int i=0 ; i<n-4 ; i++)
116  for (int j=0 ; j<n ; j++)
117  bis.set(i, j) = (tilde(i, j)+tilde(i+1, j)) ;
118 
119  Matrice res (bis) ;
120  for (int i=0 ; i<n-4 ; i++)
121  for (int j=0 ; j<n ; j++)
122  res.set(i, j) = (bis(i, j)-bis(i+1, j)) ;
123 
124  return res ;
125 }
126 
128  if (ope_mat == 0x0)
129  do_ope_mat() ;
130 
131  if (ope_cl != 0x0)
132  delete ope_cl ;
133 
134  // Routines de derivation
135  static Matrice (*cl_helmholtz_minus_2d[MAX_BASE])(const Matrice&, int);
136  static int nap = 0 ;
137 
138  // Premier appel
139  if (nap==0) {
140  nap = 1 ;
141  for (int i=0 ; i<MAX_BASE ; i++) {
142  cl_helmholtz_minus_2d[i] = _cl_helmholtz_minus_2d_pas_prevu ;
143  }
144  // Les routines existantes
145  cl_helmholtz_minus_2d[R_CHEB >> TRA_R] = _cl_helmholtz_minus_2d_r_cheb ;
146  cl_helmholtz_minus_2d[R_CHEBU >> TRA_R] = _cl_helmholtz_minus_2d_r_chebu ;
147  }
148  ope_cl = new Matrice(cl_helmholtz_minus_2d[base_r](*ope_mat, dzpuis)) ;
149 }
150 
151 
152 }
Matrice * ope_cl
Pointer on the banded-matrix of the operator.
virtual void do_ope_cl() const
Computes the banded-matrix of the operator.
Lorene prototypes.
Definition: app_hor.h:67
Matrice * ope_mat
Pointer on the matrix representation of the operator.
int base_r
Radial basis of decomposition.
#define TRA_R
Translation en R, used for a bitwise shift (in hex)
Definition: type_parite.h:158
Matrix handling.
Definition: matrice.h:152
int get_dim(int i) const
Returns the dimension of the matrix.
Definition: matrice.C:263
int dzpuis
the associated dzpuis, if in the compactified domain.
virtual void do_ope_mat() const
Computes the matrix of the operator.
#define R_CHEBU
base de Chebychev ordinaire (fin), dev. en 1/r
Definition: type_parite.h:180
#define MAX_BASE
Nombre max. de bases differentes.
Definition: type_parite.h:144
#define R_CHEB
base de Chebychev ordinaire (fin)
Definition: type_parite.h:166