LORENE
ope_helmholtz_minus_2d_solh.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_solh.C,v 1.5 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_solh.C,v 1.5 2016/12/05 16:18:11 j_novak Exp $
26  *
27  */
28 #include <cmath>
29 #include <cstdlib>
30 #include <gsl/gsl_sf_bessel.h>
31 
32 #include "proto.h"
33 #include "ope_elementary.h"
34 
35  //------------------------------------
36  // Routine pour les cas non prevus --
37  //------------------------------------
38 namespace Lorene {
39 Tbl _solh_helmholtz_minus_2d_pas_prevu (int, int, double, double, double) {
40 
41  cout << " Solution homogene pas prevue ..... : "<< endl ;
42  exit(-1) ;
43  Tbl res(1) ;
44  return res;
45 }
46 
47 
48  //-------------------
49  //-- R_CHEB ------
50  //-------------------
51 
52 Tbl _solh_helmholtz_minus_2d_r_cheb (int n, int l, double masse, double alpha, double beta) {
53 
54 
55  double echelle = beta / alpha ;
56 
57  Tbl res(2, n) ;
58  res.set_etat_qcq() ;
59  double* coloc = new double[n] ;
60 
61  int * deg = new int[3] ;
62  deg[0] = 1 ;
63  deg[1] = 1 ;
64  deg[2] = n ;
65 
66  //Construction de la premiere solution homogene :
67  for (int i=0 ; i<n ; i++)
68  coloc[i] = gsl_sf_bessel_In (l, masse*alpha*(echelle-cos(M_PI*i/(n-1)))) ;
69 
70  cfrcheb(deg, deg, coloc, deg, coloc) ;
71  for (int i=0 ; i<n ;i++)
72  res.set(0, i) = coloc[i] ;
73 
74  // construction de la seconde solution homogene :
75  for (int i=0 ; i<n ; i++)
76  coloc[i] = gsl_sf_bessel_Kn (l, masse*alpha*(echelle-cos(M_PI*i/(n-1)))) ;
77 
78  cfrcheb(deg, deg, coloc, deg, coloc) ;
79  for (int i=0 ; i<n ;i++)
80  res.set(1, i) = coloc[i] ;
81 
82  delete [] coloc ;
83  delete [] deg ;
84 
85  return res ;
86 }
87 
88  //-------------------
89  //-- R_CHEBU -----
90  //-------------------
91 
92 Tbl _solh_helmholtz_minus_2d_r_chebu (int n, int l, double masse,
93  double alpha, double) {
94 
95 
96  Tbl res(n) ;
97  res.set_etat_qcq() ;
98  double* coloc = new double[n] ;
99 
100  int * deg = new int[3] ;
101  deg[0] = 1 ;
102  deg[1] = 1 ;
103  deg[2] = n ;
104 
105  for (int i=0 ; i<n-1 ; i++)
106  coloc[i] = gsl_sf_bessel_Kn (l, masse/alpha/(-1-cos(M_PI*i/(n-1)))) ;
107  coloc[n-1] = 0 ;
108 
109  cfrcheb(deg, deg, coloc, deg, coloc) ;
110  for (int i=0 ; i<n ;i++)
111  res.set(i) = coloc[i] ;
112 
113  delete [] coloc ;
114  delete [] deg ;
115 
116  return res ;
117 }
118 
119 
121 
122  // Routines de derivation
123  static Tbl (*solh_helmholtz_minus_2d[MAX_BASE]) (int, int, double, double, double) ;
124  static int nap = 0 ;
125 
126  // Premier appel
127  if (nap==0) {
128  nap = 1 ;
129  for (int i=0 ; i<MAX_BASE ; i++) {
130  solh_helmholtz_minus_2d[i] = _solh_helmholtz_minus_2d_pas_prevu ;
131  }
132  // Les routines existantes
133  solh_helmholtz_minus_2d[R_CHEB >> TRA_R] = _solh_helmholtz_minus_2d_r_cheb ;
134  solh_helmholtz_minus_2d[R_CHEBU >> TRA_R] = _solh_helmholtz_minus_2d_r_chebu ;
135  }
136 
137  Tbl res(solh_helmholtz_minus_2d[base_r](nr,l_quant, masse, alpha, beta)) ;
138 
139  // Un peu tricky...
140 
141  if (res.get_ndim() == 1) {
142  Tbl val_lim (val_solp (res, alpha, base_r)) ;
143  val_lim *= sqrt(double(2)) ;
144 
145  s_one_plus = val_lim(0) ;
146  s_one_minus = val_lim(1) ;
147  ds_one_plus = val_lim(2) ;
148  ds_one_minus = val_lim(3) ;
149 
150  }
151  else {
152  Tbl auxi (nr) ;
153  auxi.set_etat_qcq() ;
154  for (int i=0 ; i<nr ; i++)
155  auxi.set(i) = res(0,i) ;
156 
157  Tbl val_one (val_solp (auxi, alpha, base_r)) ;
158  val_one *= sqrt(double(2)) ;
159 
160  s_one_plus = val_one(0) ;
161  s_one_minus = val_one(1) ;
162  ds_one_plus = val_one(2) ;
163  ds_one_minus = val_one(3) ;
164 
165  for (int i=0 ; i<nr ; i++)
166  auxi.set(i) = res(1,i) ;
167 
168  Tbl val_two (val_solp (auxi, alpha, base_r)) ;
169  val_two *= sqrt(double(2)) ;
170 
171  s_two_plus = val_two(0) ;
172  s_two_minus = val_two(1) ;
173  ds_two_plus = val_two(2) ;
174  ds_two_minus = val_two(3) ;
175 
176  }
177 
178  return res ;
179 }
180 }
double alpha
Parameter of the associated mapping.
double s_one_minus
Value of the first homogeneous solution at the inner boundary.
Cmp sqrt(const Cmp &)
Square root.
Definition: cmp_math.C:223
double ds_two_minus
Value of the derivative of the second homogeneous solution at the inner boundary. ...
double beta
Parameter of the associated mapping.
Lorene prototypes.
Definition: app_hor.h:67
double & set(int i)
Read/write of a particular element (index i) (1D case)
Definition: tbl.h:301
double ds_two_plus
Value of the derivative of the second homogeneous solution at the outer boundary. ...
virtual Tbl get_solh() const
Computes the homogeneous solutions(s).
Cmp cos(const Cmp &)
Cosine.
Definition: cmp_math.C:97
int base_r
Radial basis of decomposition.
void set_etat_qcq()
Sets the logical state to ETATQCQ (ordinary state).
Definition: tbl.C:364
double masse
The mass term.
#define TRA_R
Translation en R, used for a bitwise shift (in hex)
Definition: type_parite.h:158
double ds_one_plus
Value of the derivative of the first homogeneous solution at the outer boundary.
int get_ndim() const
Gives the number of dimensions (ie dim.ndim)
Definition: tbl.h:420
double s_two_minus
Value of the second homogeneous solution at the inner boundary.
double s_one_plus
Value of the first homogeneous solution at the outer boundary.
int nr
Number of radial points.
double ds_one_minus
Value of the derivative of the first homogeneous solution at the inner boundary.
Basic array class.
Definition: tbl.h:164
#define R_CHEBU
base de Chebychev ordinaire (fin), dev. en 1/r
Definition: type_parite.h:180
double s_two_plus
Value of the second homogeneous solution at the outer boundary.
#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