LORENE
ope_helmholtz_minus_pseudo_1d_solp.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
21char ope_helmholtz_minus_pseudo_1d_solp_C[] = "$Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_helmholtz_minus_pseudo_1d/ope_helmholtz_minus_pseudo_1d_solp.C,v 1.3 2014/10/13 08:53:34 j_novak Exp $" ;
22
23/*
24 * $Id: ope_helmholtz_minus_pseudo_1d_solp.C,v 1.3 2014/10/13 08:53:34 j_novak Exp $
25 * $Header: /cvsroot/Lorene/C++/Source/Ope_elementary/Ope_helmholtz_minus_pseudo_1d/ope_helmholtz_minus_pseudo_1d_solp.C,v 1.3 2014/10/13 08:53:34 j_novak Exp $
26 *
27 */
28#include <cmath>
29#include <cstdlib>
30
31#include "proto.h"
32#include "ope_elementary.h"
33//--------------------------------------------------
34// Version Tbl --> Tbl a 1D pour la source
35//--------------------------------------------------
36
37
38namespace Lorene {
39Tbl _cl_helmholtz_minus_pseudo_1d_pas_prevu (const Tbl & source, int) {
40 cout << "Combinaison lineaire pas prevue..." << endl ;
41 abort() ;
42 exit(-1) ;
43 return source;
44}
45
46
47
48
49 //-------------------
50 //-- R_CHEBU -----
51 //-------------------
52Tbl _cl_helmholtz_minus_pseudo_1d_r_chebu_deux(const Tbl&) ;
53
54Tbl _cl_helmholtz_minus_pseudo_1d_r_chebu (const Tbl &source, int puis) {
55
56 int n=source.get_dim(0) ;
57 Tbl res(n) ;
58 res.set_etat_qcq() ;
59
60 switch(puis) {
61 case 2 :
62 res = _cl_helmholtz_minus_pseudo_1d_r_chebu_deux(source) ;
63 break ;
64
65 default :
66 abort() ;
67 exit(-1) ;
68 }
69 return res ;
70}
71
72// Cas dzpuis = 2 ;
73Tbl _cl_helmholtz_minus_pseudo_1d_r_chebu_deux (const Tbl &source) {
74
75 Tbl barre(source) ;
76 int n = source.get_dim(0) ;
77
78 int dirac = 1 ;
79 for (int i=0 ; i<n-2 ; i++) {
80 barre.set(i) = ((1+dirac)*source(i)-source(i+2)) ;
81 if (i==0) dirac = 0 ;
82 }
83
84 Tbl tilde(barre) ;
85 for (int i=0 ; i<n-4 ; i++)
86 tilde.set(i) = (barre(i)-barre(i+2)) ;
87
88 Tbl bis(tilde) ;
89 for (int i=0 ; i<n-4 ; i++)
90 bis.set(i) = (tilde(i)+tilde(i+1)) ;
91
92 Tbl res(bis) ;
93 for (int i=0 ; i<n-4 ; i++)
94 res.set(i) = (bis(i)-bis(i+1)) ;
95
96 return res ;
97}
98
99
100 //----------------------------
101 //- Routine a appeler ---
102 //------------------------------
103
104Tbl cl_helmholtz_minus_pseudo_1d (const Tbl &source, int puis, int base_r) {
105 // Routines de derivation
106 static Tbl (*cl_helmholtz_minus_pseudo_1d[MAX_BASE])(const Tbl &, int) ;
107 static int nap = 0 ;
108
109 // Premier appel
110 if (nap==0) {
111 nap = 1 ;
112 for (int i=0 ; i<MAX_BASE ; i++) {
113 cl_helmholtz_minus_pseudo_1d[i] = _cl_helmholtz_minus_pseudo_1d_pas_prevu ;
114 }
115 // Les routines existantes
116 cl_helmholtz_minus_pseudo_1d[R_CHEBU >> TRA_R] = _cl_helmholtz_minus_pseudo_1d_r_chebu ;
117
118 }
119
120 Tbl res(cl_helmholtz_minus_pseudo_1d[base_r](source, puis)) ;
121 return res ;
122}
123
124
125 //------------------------------------
126 // Routine pour les cas non prevus --
127 //------------------------------------
128Tbl _solp_helmholtz_minus_pseudo_1d_pas_prevu (const Matrice &, const Matrice &,
129 double, double, const Tbl &, int) {
130 cout << " Solution homogene pas prevue ..... : "<< endl ;
131 abort() ;
132 exit(-1) ;
133 Tbl res(1) ;
134 return res;
135}
136
137 //-------------------
138 //-- R_CHEBU -----
139 //-------------------
140Tbl _solp_helmholtz_minus_pseudo_1d_r_chebu_deux (const Matrice&, const Matrice&,
141 const Tbl&) ;
142
143Tbl _solp_helmholtz_minus_pseudo_1d_r_chebu (const Matrice &lap, const Matrice &nondege,
144 double, double,
145 const Tbl &source, int puis) {
146 int n = lap.get_dim(0) ;
147 Tbl res(n+2) ;
148 res.set_etat_qcq() ;
149
150 switch (puis) {
151 case 2 :
152 res = _solp_helmholtz_minus_pseudo_1d_r_chebu_deux
153 (lap, nondege, source) ;
154 break ;
155 default :
156 abort() ;
157 exit(-1) ;
158 }
159return res ;
160}
161
162// Cas dzpuis = 2 ;
163Tbl _solp_helmholtz_minus_pseudo_1d_r_chebu_deux (const Matrice &lap, const Matrice &nondege,
164 const Tbl &source) {
165
166 int n = lap.get_dim(0)+2 ;
167 int dege = n-nondege.get_dim(0) ;
168 assert (dege == 3) ;
169
170 Tbl source_cl (cl_helmholtz_minus_pseudo_1d(source, 2, R_CHEBU)) ;
171
172 Tbl so(n-dege) ;
173 so.set_etat_qcq() ;
174 for (int i=0 ; i<n-dege ; i++)
175 so.set(i) = source_cl(i);
176
177 Tbl sol (nondege.inverse(so)) ;
178
179 Tbl res(n) ;
180 res.annule_hard() ;
181 for (int i=1 ; i<n-2 ; i++) {
182 res.set(i) += sol(i-1)*(2*i+3) ;
183 res.set(i+1) += -sol(i-1)*(4*i+4) ;
184 res.set(i+2) += sol(i-1)*(2*i+1) ;
185 }
186
187 return res ;
188}
189
190
192
193 if (non_dege == 0x0)
194 do_non_dege() ;
195
196 // Routines de derivation
197 static Tbl (*solp_helmholtz_minus_pseudo_1d[MAX_BASE]) (const Matrice&, const Matrice&,
198 double, double,const Tbl&, int) ;
199 static int nap = 0 ;
200
201 // Premier appel
202 if (nap==0) {
203 nap = 1 ;
204 for (int i=0 ; i<MAX_BASE ; i++) {
205 solp_helmholtz_minus_pseudo_1d[i] = _solp_helmholtz_minus_pseudo_1d_pas_prevu ;
206 }
207 // Les routines existantes
208 solp_helmholtz_minus_pseudo_1d[R_CHEBU >> TRA_R] = _solp_helmholtz_minus_pseudo_1d_r_chebu ;
209 }
210
212 alpha, beta, so, dzpuis)) ;
213
214 Tbl valeurs (val_solp (res, alpha, base_r)) ;
215 valeurs *= sqrt(double(2)) ;
216
217 sp_plus = valeurs(0) ;
218 sp_minus = valeurs(1) ;
219 dsp_plus = valeurs(2) ;
220 dsp_minus = valeurs(3) ;
221
222
223 return res ;
224}
225}
Time evolution with partial storage (*** under development ***).
Definition evolution.h:371
Matrix handling.
Definition matrice.h:152
int get_dim(int i) const
Returns the dimension of the matrix.
Definition matrice.C:260
double beta
Parameter of the associated mapping.
double dsp_plus
Value of the derivative of the particular solution at the outer boundary.
double alpha
Parameter of the associated mapping.
int base_r
Radial basis of decomposition.
Matrice * ope_cl
Pointer on the banded-matrix of the operator.
double sp_minus
Value of the particular solution at the inner boundary.
Matrice * non_dege
Pointer on the non-degenerated matrix of the operator.
double sp_plus
Value of the particular solution at the outer boundary.
double dsp_minus
Value of the derivative of the particular solution at the inner boundary.
virtual Tbl get_solp(const Tbl &so) const
Computes the particular solution, given the source so .
int dzpuis
the associated dzpuis, if in the compactified domain.
virtual void do_non_dege() const
Computes the non-degenerated matrix of the operator.
Basic array class.
Definition tbl.h:161
int get_dim(int i) const
Gives the i-th dimension (ie dim.dim[i])
Definition tbl.h:403
Cmp sqrt(const Cmp &)
Square root.
Definition cmp_math.C:220
#define MAX_BASE
Nombre max. de bases differentes.
#define R_CHEBU
base de Chebychev ordinaire (fin), dev. en 1/r
#define TRA_R
Translation en R, used for a bitwise shift (in hex)
Lorene prototypes.
Definition app_hor.h:64